18 #ifndef included_DMD_h
19 #define included_DMD_h
21 #include "ParametricDMD.h"
29 class ComplexEigenPair;
83 DMD(
int dim,
double dt,
bool alt_output_basis =
false,
84 Vector* state_offset = NULL);
92 DMD(std::string base_file_name);
114 virtual void takeSample(
double* u_in,
double t);
124 virtual void train(
double energy_fraction,
const Matrix* W0 = NULL,
125 double linearity_tol = 0.0);
135 virtual void train(
int k,
const Matrix* W0 = NULL,
double linearity_tol = 0.0);
171 int getDimension()
const
187 virtual void load(std::string base_file_name);
195 void load(
const char* base_file_name);
203 virtual void save(std::string base_file_name);
211 void save(
const char* base_file_name);
216 void summary(std::string base_file_name);
239 friend void getParametricDMD<DMD>(
DMD*& parametric_dmd,
240 std::vector<Vector*>& parameter_points,
241 std::vector<DMD*>& dmds,
244 std::string interp_method,
245 double closest_rbf_val,
246 bool reorthogonalize_W);
256 DMD(
int dim,
bool alt_output_basis =
false,
Vector* state_offset = NULL);
269 DMD(std::vector<std::complex<double>> eigs,
Matrix* phi_real,
270 Matrix* phi_imaginary,
int k,
271 double dt,
double t_offset,
Vector* state_offset);
293 std::pair<Matrix*, Matrix*>
phiMultEigs(
double t,
int deg = 0);
302 double linearity_tol);
318 virtual std::complex<double>
computeEigExp(std::complex<double> eig,
double t);
448 std::vector<std::complex<double>>
d_eigs;
std::pair< Matrix *, Matrix * > phiMultEigs(double t, int deg=0)
Internal function to multiply d_phi with the eigenvalues.
Matrix * d_phi_real
The real part of d_phi.
std::vector< std::complex< double > > d_eigs
A vector holding the complex eigenvalues of the eigenmodes.
Matrix * d_phi_real_squared_inverse
The real part of d_phi_squared_inverse.
int getNumSamples() const
Returns the number of samples taken.
virtual ~DMD()
Destroy the DMD object.
double d_energy_fraction
The energy fraction used to obtain the DMD modes.
int d_dim
The total dimension of the sample vector.
Vector * predict(double t, int deg=0)
Predict state given a time. Uses the projected initial condition of the training dataset (the first c...
virtual void train(double energy_fraction, const Matrix *W0=NULL, double linearity_tol=0.0)
Train the DMD model with energy fraction criterion.
bool d_init_projected
Whether the initial condition has been projected.
Matrix * d_A_tilde
A_tilde.
virtual void takeSample(double *u_in, double t)
Sample the new state, u_in. Any samples in d_snapshots taken at the same or later time will be erased...
virtual void addOffset(Vector *&result, double t=0.0, int deg=0)
Add the appropriate offset when predicting the solution.
virtual std::complex< double > computeEigExp(std::complex< double > eig, double t)
Compute the appropriate exponential function when predicting the solution.
const Matrix * createSnapshotMatrix(std::vector< Vector * > snapshots)
Get the snapshot matrix contained within d_snapshots.
void constructDMD(const Matrix *f_snapshots, int rank, int num_procs, const Matrix *W0, double linearity_tol)
Construct the DMD object.
void projectInitialCondition(const Vector *init, double t_offset=-1.0)
Project new initial condition using d_phi. Calculate pinv(phi) x init, or more precisely,...
void summary(std::string base_file_name)
Output the DMD record in CSV files.
virtual std::pair< Matrix *, Matrix * > computeDMDSnapshotPair(const Matrix *snapshots)
Returns a pair of pointers to the minus and plus snapshot matrices.
double d_dt
The time step size between samples.
Vector * d_state_offset
State offset in snapshot.
virtual void save(std::string base_file_name)
Save the object state to a file.
const Matrix * getSnapshotMatrix()
Get the snapshot matrix contained within d_snapshots.
std::vector< double > d_sv
std::vector holding the signular values.
virtual void setOffset(Vector *offset_vector, int order)
Set the offset of a certain order.
std::vector< Vector * > d_sampled_times
The stored times of each sample.
double getTimeOffset() const
Get the time offset contained within d_t_offset.
int d_num_singular_vectors
The maximum number of singular vectors.
Matrix * d_phi_imaginary
The imaginary part of d_phi.
double d_t_offset
The time offset of the first sample.
Vector * d_projected_init_real
The real part of the projected initial condition.
DMD(const DMD &other)
Unimplemented copy constructor.
int d_rank
The rank of the process this object belongs to.
std::vector< Vector * > d_snapshots
std::vector holding the snapshots.
DMD()
Unimplemented default constructor.
DMD & operator=(const DMD &rhs)
Unimplemented assignment operator.
Matrix * d_basis
The left singular vector basis.
int d_num_procs
The number of processors being run on.
bool d_alt_output_basis
Whether to use the alternative basis for output, i.e. phi = U^(+)*V*Omega^(-1)*X.
virtual void load(std::string base_file_name)
Load the object state from a file.
Matrix * d_phi_imaginary_squared_inverse
The imaginary part of d_phi_squared_inverse.
Vector * d_projected_init_imaginary
The imaginary part of the projected initial condition.
bool d_trained
Whether the DMD has been trained or not.
virtual void computePhi(DMDInternal dmd_internal_obj)
Compute phi.
int d_k
The number of columns used after obtaining the SVD decomposition.
Matrix * snapshots_in
The snapshot vectors of input.
ComplexEigenPair * eigenpair
The resultant DMD eigenvalues and eigenvectors.
Matrix * snapshots_out
The snapshot vectors of output.
Matrix * basis
The left singular vector basis.
Matrix * basis_right
The right singular vector basis.
Matrix * S_inv
The inverse of singular values.