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]:
(2, 200)

In [44]:
for i, snap in enumerate(direct_snapshots):
    a = snap.get()

In [46]:
a.shape


Out[46]:
(2, 200)

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)


Warning: The vecs, of which there are 30, will be retrieved 2 times each. Increase number of nodes or max_vecs_per_node to reduce redundant "get"s for a speedup.
Computing the inner product matrix will take at least 0.0 minutes
Completed 96.4% of inner products
Completed 100.0% of inner products

In [18]:



  File "<ipython-input-18-e7b10df8cdb6>", line 1
    my_POD!
          ^
SyntaxError: invalid syntax

In [ ]: