Skip to content

Commit af1af22

Browse files
committed
remove leftover stuff of snapshot class
1 parent 8d67bd2 commit af1af22

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

romtools/__init__.py

+1-64
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
The Python library, called `romtools`, contains abstract interfaces and functions required for, e.g.,
6363
6464
- Constructing parameter spaces
65-
- Constructing a snapshot data class
6665
- Constructing trial spaces
6766
- Constructing and exploiting ROMs via outer loop workflows
6867
@@ -81,10 +80,6 @@
8180
8281
## Representative abstract base classes
8382
84-
- `AbstractSnapshotData`
85-
- This class defines the minimum API requirements for a "snapshot_data" class that will be used in the construction
86-
of a trial space.
87-
8883
- `AbstractTrialSpace`
8984
- This class defines the minimum API requirements for a trial space
9085
@@ -107,66 +102,8 @@
107102
108103
In this section, we present some demos/examples showing how to use `romtools` in practice.
109104
110-
## 1. Snapshot data
111-
112-
The first demo is a simple example of how you could use collect snapshot data for a basic problem.\
113-
For the sake of exposition, suppose that we are solving the [1D heat equation](https://aquaulb.github.io/book_solving_pde_mooc/solving_pde_mooc/notebooks/04_PartialDifferentialEquations/04_03_Diffusion_Explicit.html)
114-
115-
$$\\partial_t T(x,t) = \\alpha \\frac{d^2 T} {dx^2}(x,t) + \\sigma (x,t)$$
116-
117-
where $x$ is space, $t$ is time, $T$ is the temperature, $\\alpha$ is the diffusivity,
118-
and $\\sigma$ is the source term.
119-
Instead of the numerical solution, for now let's work with the analytical solution:
120-
121-
$$T(x,t)=e^{-4\\pi^2\\alpha t}\\sin(2\\pi x) + \\frac{2}{\\pi^2\\alpha}(1-e^{-\\pi^2\\alpha t})\\sin(\\pi x)$$
122-
123-
124-
```python
125-
import numpy as np
126-
127-
def exact_solution(x,t, alpha):
128-
"""
129-
Returns the exact solution of the 1D heat equation with
130-
heat source term sin(np.pi*x) and initial condition sin(2*np.pi*x)
105+
TBD
131106
132-
Parameters
133-
----------
134-
x : array of floats, grid points coordinates
135-
t : float, time
136-
137-
Returns
138-
-------
139-
f : array of floats, exact solution
140-
"""
141-
f = (np.exp(-4*np.pi**2*alpha*t) * np.sin(2*np.pi*x)
142-
+ 2.0*(1-np.exp(-np.pi**2*alpha*t)) * np.sin(np.pi*x)
143-
/ (np.pi**2*alpha))
144-
145-
return f
146-
147-
import romtools as rt
148-
class HeatSnapshots(rt.AbstractSnapshotData):
149-
def __init__(self, snapshots: list):
150-
rt.AbstractSnapshotData.__init__(self, var_names=['T'])
151-
self.snapshots = snapshots
152-
153-
def getMeshGids(self):
154-
# this method is a noop for now but needs to be defined
155-
# since it is an abstract method in the base class
156-
pass
157-
158-
def getSnapshotsAsListOfArrays(self):
159-
return self.snapshots
160-
161-
if __name__=="__main__":
162-
numPoints, numTimes = 21, 11
163-
x = np.linspace(0., 1., numPoints)
164-
times = np.linspace(0., 5., numTimes)
165-
166-
alpha = 0.1
167-
data = [exact_solution(x, t, alpha) for t in times]
168-
snapshots = HeatSnapshots(data)
169-
```
170107
# License
171108
```plaintext
172109
.. include:: ../LICENSE

0 commit comments

Comments
 (0)