libROM  v1.0
Data-driven physical simulation library
Public Member Functions | Protected Member Functions | Friends | List of all members
CAROM::SnapshotDMD Class Reference
Inheritance diagram for CAROM::SnapshotDMD:
CAROM::DMD

Public Member Functions

 SnapshotDMD (int dim, double dt, bool alt_output_basis=false, std::shared_ptr< Vector > state_offset=nullptr)
 Constructor. Basic DMD with uniform time step size. Inherited directly from base DMD class. More...
 
 SnapshotDMD (std::string base_file_name)
 Constructor. DMD from saved models. Inherited directly from base DMD class. More...
 
 ~SnapshotDMD ()
 Destroy the SnapshotDMD object.
 
void interpolateToNSnapshots (int n)
 Interpolate the current snapshots to n, new snapshots distributed uniformly over the currently sampled time domain. More...
 
void train (int k, const Matrix *W0=NULL, double linearity_tol=0.0)
 Train the DMD model with specified reduced dimension. If k is too large then new snapshots are computed using interpolateToNSnapshots(k+1). More...
 
void train (double energy_fraction, const Matrix *W0=NULL, double linearity_tol=0.0)
 Train the DMD model with energy fraction criterion. More...
 
std::vector< std::shared_ptr< Vector > > getSnapshotVectors ()
 Returns a copy of the current snapshot vector "d_snapshots".
 
- Public Member Functions inherited from CAROM::DMD
 DMD (int dim, double dt, bool alt_output_basis=false, std::shared_ptr< Vector > state_offset=nullptr)
 Constructor. Basic DMD with uniform time step size. More...
 
 DMD (std::string base_file_name)
 Constructor. DMD from saved models. More...
 
virtual ~DMD ()
 Destroy the DMD object.
 
virtual void setOffset (std::shared_ptr< Vector > &offset_vector, int order)
 Set the offset of a certain order.
 
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. More...
 
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, (phi* x phi)^{-1} x phi* x init, where phi* is the conjugate transpose. More...
 
std::unique_ptr< Vectorpredict (double t, int deg=0)
 Predict state given a time. Uses the projected initial condition of the training dataset (the first column). More...
 
double getTimeOffset () const
 Get the time offset contained within d_t_offset.
 
int getNumSamples () const
 Returns the number of samples taken. More...
 
int getDimension () const
 
std::unique_ptr< const MatrixgetSnapshotMatrix ()
 Get the snapshot matrix contained within d_snapshots.
 
virtual void load (std::string base_file_name)
 Load the object state from a file. More...
 
void load (const char *base_file_name)
 Load the object state from a file. More...
 
virtual void save (std::string base_file_name)
 Save the object state to a file. More...
 
void save (const char *base_file_name)
 Save the object state to a file. More...
 
void summary (std::string base_file_name)
 Output the DMD record in CSV files.
 

Protected Member Functions

 SnapshotDMD (std::vector< std::complex< double >> &eigs, std::shared_ptr< Matrix > &phi_real, std::shared_ptr< Matrix > &phi_imaginary, int k, double dt, double t_offset, std::shared_ptr< Vector > &state_offset)
 Constructor. More...
 
- Protected Member Functions inherited from CAROM::DMD
 DMD (int dim, bool alt_output_basis=false, std::shared_ptr< Vector > state_offset=nullptr)
 Constructor. Variant of DMD with non-uniform time step size. More...
 
 DMD (std::vector< std::complex< double >> &eigs, std::shared_ptr< Matrix > &phi_real, std::shared_ptr< Matrix > &phi_imaginary, int k, double dt, double t_offset, std::shared_ptr< Vector > &state_offset)
 Constructor. Specified from DMD components. More...
 
 DMD ()
 Unimplemented default constructor.
 
 DMD (const DMD &other)
 Unimplemented copy constructor.
 
DMDoperator= (const DMD &rhs)
 Unimplemented assignment operator.
 
std::pair< std::shared_ptr< Matrix >, std::shared_ptr< Matrix > > phiMultEigs (double t, int deg=0)
 Internal function to multiply d_phi with the eigenvalues.
 
void constructDMD (const Matrix &f_snapshots, int rank, int num_procs, const Matrix *W0, double linearity_tol)
 Construct the DMD object.
 
virtual std::pair< Matrix *, Matrix * > computeDMDSnapshotPair (const Matrix &snapshots)
 Returns a pair of pointers to the minus and plus snapshot matrices.
 
virtual void computePhi (DMDInternal dmd_internal_obj)
 Compute phi.
 
virtual std::complex< double > computeEigExp (std::complex< double > eig, double t)
 Compute the appropriate exponential function when predicting the solution.
 
virtual void addOffset (Vector &result, double t=0.0, int deg=0)
 Add the appropriate offset when predicting the solution.
 
std::unique_ptr< const MatrixcreateSnapshotMatrix (const std::vector< std::shared_ptr< Vector >> &snapshots)
 Get the snapshot matrix contained within d_snapshots.
 

Friends

void getParametricDMD (std::unique_ptr< SnapshotDMD > &parametric_dmd, const std::vector< Vector > &parameter_points, std::vector< SnapshotDMD * > &dmds, const Vector &desired_point, std::string rbf, std::string interp_method, double closest_rbf_val, bool reorthogonalize_W)
 Obtain DMD model interpolant at desired parameter point by interpolation of DMD models from training parameter points. More...
 

Additional Inherited Members

- Protected Attributes inherited from CAROM::DMD
int d_rank
 The rank of the process this object belongs to.
 
int d_num_procs
 The number of processors being run on.
 
int d_dim
 The total dimension of the sample vector.
 
double d_dt = -1.0
 The time step size between samples.
 
double d_t_offset
 The time offset of the first sample.
 
std::vector< std::shared_ptr< Vector > > d_snapshots
 std::vector holding the snapshots.
 
std::vector< double > d_sampled_times
 The stored times of each sample.
 
std::shared_ptr< Vectord_state_offset
 State offset in snapshot.
 
bool d_trained
 Whether the DMD has been trained or not.
 
bool d_init_projected
 Whether the initial condition has been projected.
 
int d_num_singular_vectors
 The maximum number of singular vectors.
 
std::vector< double > d_sv
 std::vector holding the signular values.
 
double d_energy_fraction
 The energy fraction used to obtain the DMD modes.
 
int d_k
 The number of columns used after obtaining the SVD decomposition.
 
std::shared_ptr< Matrixd_basis
 The left singular vector basis.
 
bool d_alt_output_basis = false
 Whether to use the alternative basis for output, i.e. phi = U^(+)*V*Omega^(-1)*X.
 
std::shared_ptr< Matrixd_A_tilde
 A_tilde.
 
std::shared_ptr< Matrixd_phi_real
 The real part of d_phi.
 
std::shared_ptr< Matrixd_phi_imaginary
 The imaginary part of d_phi.
 
std::unique_ptr< Matrixd_phi_real_squared_inverse
 The real part of d_phi_squared_inverse.
 
std::unique_ptr< Matrixd_phi_imaginary_squared_inverse
 The imaginary part of d_phi_squared_inverse.
 
std::shared_ptr< Vectord_projected_init_real
 The real part of the projected initial condition.
 
std::shared_ptr< Vectord_projected_init_imaginary
 The imaginary part of the projected initial condition.
 
std::vector< std::complex< double > > d_eigs
 A vector holding the complex eigenvalues of the eigenmodes.
 

Detailed Description

Definition at line 10 of file SnapshotDMD.h.

Constructor & Destructor Documentation

◆ SnapshotDMD() [1/3]

CAROM::SnapshotDMD::SnapshotDMD ( int  dim,
double  dt,
bool  alt_output_basis = false,
std::shared_ptr< Vector state_offset = nullptr 
)
inline

Constructor. Basic DMD with uniform time step size. Inherited directly from base DMD class.

Parameters
[in]dimThe full-order state dimension.
[in]dtThe dt between samples.
[in]alt_output_basisWhether to use the alternative basis for output, i.e. phi = U^(+)*V*Omega^(-1)*X.
[in]state_offsetThe state offset.

Definition at line 24 of file SnapshotDMD.h.

◆ SnapshotDMD() [2/3]

CAROM::SnapshotDMD::SnapshotDMD ( std::string  base_file_name)
inline

Constructor. DMD from saved models. Inherited directly from base DMD class.

Parameters
[in]base_file_nameThe base part of the filename of the database to load when restarting from a save.

Definition at line 35 of file SnapshotDMD.h.

◆ SnapshotDMD() [3/3]

CAROM::SnapshotDMD::SnapshotDMD ( std::vector< std::complex< double >> &  eigs,
std::shared_ptr< Matrix > &  phi_real,
std::shared_ptr< Matrix > &  phi_imaginary,
int  k,
double  dt,
double  t_offset,
std::shared_ptr< Vector > &  state_offset 
)
inlineprotected

Constructor.

Parameters
[in]eigsd_eigs
[in]phi_reald_phi_real
[in]phi_imaginaryd_phi_imaginary
[in]kd_k
[in]dtd_dt
[in]t_offsetd_t_offset
[in]state_offsetd_state_offset
[in]derivative_offsetd_derivative_offset

Definition at line 123 of file SnapshotDMD.h.

Member Function Documentation

◆ interpolateToNSnapshots()

void CAROM::SnapshotDMD::interpolateToNSnapshots ( int  n)

Interpolate the current snapshots to n, new snapshots distributed uniformly over the currently sampled time domain.

Parameters
[in]nThe number of desired snapshots.

Definition at line 49 of file SnapshotDMD.cpp.

◆ train() [1/2]

void CAROM::SnapshotDMD::train ( double  energy_fraction,
const Matrix W0 = NULL,
double  linearity_tol = 0.0 
)
virtual

Train the DMD model with energy fraction criterion.

Parameters
[in]energy_fractionThe energy fraction to keep after doing SVD.
[in]W0The initial basis to prepend to W.
[in]linearity_tolThe tolerance for determining whether a column of W is linearly independent with W0.

Reimplemented from CAROM::DMD.

Definition at line 43 of file SnapshotDMD.cpp.

◆ train() [2/2]

void CAROM::SnapshotDMD::train ( int  k,
const Matrix W0 = NULL,
double  linearity_tol = 0.0 
)
virtual

Train the DMD model with specified reduced dimension. If k is too large then new snapshots are computed using interpolateToNSnapshots(k+1).

Parameters
[in]kThe number of modes to keep after doing SVD.
[in]W0The initial basis to prepend to W.
[in]linearity_tolThe tolerance for determining whether a column of W is linearly independent with W0.

Reimplemented from CAROM::DMD.

Definition at line 26 of file SnapshotDMD.cpp.

Friends And Related Function Documentation

◆ getParametricDMD

void getParametricDMD ( std::unique_ptr< SnapshotDMD > &  parametric_dmd,
const std::vector< Vector > &  parameter_points,
std::vector< SnapshotDMD * > &  dmds,
const Vector desired_point,
std::string  rbf,
std::string  interp_method,
double  closest_rbf_val,
bool  reorthogonalize_W 
)
friend

Obtain DMD model interpolant at desired parameter point by interpolation of DMD models from training parameter points.

Parameters
[in]parametric_dmdThe interpolant DMD model at the desired point.
[in]parameter_pointsThe training parameter points.
[in]dmdsThe DMD objects associated with each training parameter point.
[in]desired_pointThe desired point at which to create a parametric DMD.
[in]rbfThe RBF type ("G" == gaussian, "IQ" == inverse quadratic, "IMQ" == inverse multiquadric)
[in]interp_methodThe interpolation method type ("LS" == linear solve, "IDW" == inverse distance weighting, "LP" == lagrangian polynomials)
[in]closest_rbf_valThe RBF parameter determines the width of influence. Set the RBF value of the nearest two parameter points to a value between 0.0 to 1.0
[in]reorthogonalize_WWhether to reorthogonalize the interpolated W (basis) matrix.

The documentation for this class was generated from the following files: