16 #ifndef included_DMDc_h
17 #define included_DMDc_h
19 #include "ParametricDMDc.h"
27 class ComplexEigenPair;
44 DMDc(
int dim,
int dim_c,
double dt,
45 std::shared_ptr<Vector> state_offset =
nullptr);
53 DMDc(std::string base_file_name);
63 virtual void setOffset(std::shared_ptr<Vector> & offset_vector);
77 virtual void takeSample(
double* u_in,
double t,
double* f_in,
78 bool last_step =
false);
91 virtual void train(
double energy_fraction,
const Matrix* B = NULL);
116 double t_offset = -1.0);
124 std::unique_ptr<Vector>
predict(
double t);
141 int getDimension()
const
157 virtual void load(std::string base_file_name);
165 void load(
const char* base_file_name);
173 virtual void save(std::string base_file_name);
181 void save(
const char* base_file_name);
186 void summary(std::string base_file_name);
213 friend void getParametricDMDc<DMDc>(std::unique_ptr<DMDc>& parametric_dmdc,
214 const std::vector<Vector>& parameter_points,
215 std::vector<DMDc*>& dmdcs,
216 std::vector<std::shared_ptr<Matrix>> & controls,
217 std::shared_ptr<Matrix> & controls_interpolated,
218 const Vector & desired_point,
220 std::string interp_method,
221 double closest_rbf_val,
222 bool reorthogonalize_W);
231 DMDc(
int dim,
int dim_c, std::shared_ptr<Vector> state_offset =
nullptr);
248 DMDc(std::vector<std::complex<double>> & eigs,
249 std::shared_ptr<Matrix> & phi_real,
250 std::shared_ptr<Matrix> & phi_imaginary,
251 std::shared_ptr<Matrix> & B_tilde,
252 int k,
double dt,
double t_offset,
253 std::shared_ptr<Vector> & state_offset,
254 std::shared_ptr<Matrix> & basis);
276 std::pair<std::shared_ptr<Matrix>,std::shared_ptr<Matrix>>
283 const Matrix & f_controls,
297 virtual std::complex<double>
computeEigExp(std::complex<double> eig,
double t);
307 std::unique_ptr<const Matrix>
448 std::vector<std::complex<double>>
d_eigs;
DMDc(const DMDc &other)
Unimplemented copy constructor.
std::vector< double > d_sv
std::vector holding the signular values.
std::vector< std::shared_ptr< Vector > > d_controls
std::vector holding the controls.
std::shared_ptr< Vector > d_projected_init_real
The real part of the projected initial condition.
double d_dt
The time step size between samples.
std::shared_ptr< Matrix > d_phi_real_squared_inverse
The real part of d_phi_squared_inverse.
virtual void setOffset(std::shared_ptr< Vector > &offset_vector)
Set the state offset.
int d_num_procs
The number of processors being run on.
std::unique_ptr< Matrix > d_projected_controls_real
The real part of the projected controls.
virtual void addOffset(Vector &result)
Add the state offset when predicting the solution.
std::unique_ptr< Matrix > d_projected_controls_imaginary
The imaginary part of the projected controls.
int d_num_singular_vectors
The maximum number of singular vectors.
void project(const Vector &init, const Matrix &controls, double t_offset=-1.0)
Project U using d_phi, where U is the initial condition and the controls. Calculate pinv(phi) x U,...
std::shared_ptr< Matrix > d_A_tilde
A_tilde.
bool d_trained
Whether the DMDc has been trained or not.
std::shared_ptr< Vector > d_projected_init_imaginary
The imaginary part of the projected initial condition.
std::vector< std::shared_ptr< Vector > > d_snapshots
std::vector holding the snapshots.
std::vector< std::complex< double > > d_eigs
A vector holding the complex eigenvalues of the eigenmodes.
std::unique_ptr< Vector > predict(double t)
Predict state given a time. Uses the projected initial condition of the training dataset (the first c...
double d_t_offset
The time offset of the first sample.
virtual std::pair< Matrix *, Matrix * > computeDMDcSnapshotPair(const Matrix &snapshots, const Matrix &controls, const Matrix *B)
Returns a pair of pointers to the minus and plus snapshot matrices.
void constructDMDc(const Matrix &f_snapshots, const Matrix &f_controls, int rank, int num_procs, const Matrix *B)
Construct the DMDc object.
std::unique_ptr< const Matrix > getSnapshotMatrix()
Get the snapshot matrix contained within d_snapshots.
virtual void save(std::string base_file_name)
Save the object state to a file.
DMDc & operator=(const DMDc &rhs)
Unimplemented assignment operator.
virtual std::complex< double > computeEigExp(std::complex< double > eig, double t)
Compute the appropriate exponential function when predicting the solution.
int d_k
The number of columns used after obtaining the SVD decomposition.
bool d_init_projected
Whether the initial condition has been projected.
void summary(std::string base_file_name)
Output the DMDc record in CSV files.
std::unique_ptr< const Matrix > createSnapshotMatrix(const std::vector< std::shared_ptr< Vector >> &snapshots)
Get the snapshot matrix contained within d_snapshots.
std::vector< double > d_sampled_times
The stored times of each sample.
std::shared_ptr< Matrix > d_phi_real
The real part of d_phi.
std::shared_ptr< Matrix > d_basis
The left singular vector basis.
int d_dim_c
The total dimension of the control vector.
std::shared_ptr< Vector > d_state_offset
State offset in snapshot.
DMDc()
Unimplemented default constructor.
int getNumSamples() const
Returns the number of samples taken.
int d_rank
The rank of the process this object belongs to.
double d_energy_fraction
The energy fraction used to obtain the DMDc modes.
double getTimeOffset() const
Get the time offset contained within d_t_offset.
std::pair< std::shared_ptr< Matrix >, std::shared_ptr< Matrix > > phiMultEigs(double t)
Internal function to multiply d_phi with the eigenvalues.
int d_dim
The total dimension of the sample vector.
std::shared_ptr< Matrix > d_B_tilde
B_tilde.
std::shared_ptr< Matrix > d_phi_imaginary
The imaginary part of d_phi.
std::shared_ptr< Matrix > d_phi_imaginary_squared_inverse
The imaginary part of d_phi_squared_inverse.
virtual ~DMDc()
Destroy the DMDc object.
virtual void takeSample(double *u_in, double t, double *f_in, bool last_step=false)
Sample the new state, u_in. Any samples in d_snapshots taken at the same or later time will be erased...
virtual void load(std::string base_file_name)
Load the object state from a file.
virtual void train(double energy_fraction, const Matrix *B=NULL)
Train the DMDc model with energy fraction criterion. The control matrix B may be available and used i...