In [5]:
from future.builtins import range
import numpy as np
import modred as mr
In [6]:
# Define the handles for the snapshots
num_vecs = 30
direct_snapshots = [
mr.VecHandleArrayText('ModredTest/direct_vec%d.txt' % i)
for i in range(num_vecs)]
adjoint_snapshots = [
mr.VecHandleArrayText('ModredTest/adjoint_vec%d.txt' % i)
for i in range(num_vecs)]
In [40]:
# Save arbitrary data in text files
x = np.linspace(0, np.pi, 200)
x = np.vstack((x,x))
for i, snap in enumerate(direct_snapshots):
snap.put(np.sin(x*i))
for i, snap in enumerate(adjoint_snapshots):
snap.put(np.cos(0.5*x*i))
In [42]:
np.sin(x*i).shape
Out[42]:
In [44]:
for i, snap in enumerate(direct_snapshots):
a = snap.get()
In [46]:
a.shape
Out[46]:
In [48]:
# Calculate and save POD modes
my_POD = mr.PODHandles(np.vdot, max_vecs_per_node=30)
modes, eig_vals = my_POD.compute_decomp(direct_snapshots)
In [18]:
In [ ]: