20 #ifndef included_ParametricDMD_h
21 #define included_ParametricDMD_h
23 #include "manifold_interp/MatrixInterpolator.h"
24 #include "linalg/Matrix.h"
25 #include "linalg/Vector.h"
53 const std::vector<Vector>& parameter_points,
54 std::vector<T*>& dmds,
55 const Vector & desired_point,
56 std::string rbf =
"G",
57 std::string interp_method =
"LS",
58 double closest_rbf_val = 0.9,
59 bool reorthogonalize_W =
false)
61 CAROM_VERIFY(parameter_points.size() == dmds.size());
62 CAROM_VERIFY(dmds.size() > 1);
63 for (
int i = 0; i < dmds.size() - 1; i++)
65 CAROM_VERIFY(dmds[i]->d_dt == dmds[i + 1]->d_dt);
66 CAROM_VERIFY(dmds[i]->d_k == dmds[i + 1]->d_k);
68 CAROM_VERIFY(closest_rbf_val >= 0.0 && closest_rbf_val <= 1.0);
71 MPI_Initialized(&mpi_init);
73 MPI_Init(
nullptr,
nullptr);
76 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
78 std::vector<std::shared_ptr<CAROM::Matrix>> bases;
79 std::vector<std::shared_ptr<CAROM::Matrix>> A_tildes;
80 for (
int i = 0; i < dmds.size(); i++)
82 bases.push_back(dmds[i]->d_basis);
83 A_tildes.push_back(dmds[i]->d_A_tilde);
87 std::vector<std::shared_ptr<CAROM::Matrix>> rotation_matrices =
91 rotation_matrices, bases, ref_point,
"B", rbf, interp_method, closest_rbf_val);
92 std::shared_ptr<Matrix> W = basis_interpolator.
interpolate(desired_point,
96 rotation_matrices, A_tildes, ref_point,
"R", rbf, interp_method,
98 std::shared_ptr<Matrix> A_tilde = A_tilde_interpolator.
interpolate(
103 std::vector<std::complex<double>> eigs = eigenpair.
eigs;
106 std::shared_ptr<CAROM::Matrix> phi_real = W->mult(*eigenpair.
ev_real);
107 std::shared_ptr<CAROM::Matrix> phi_imaginary = W->mult(*eigenpair.
ev_imaginary);
109 parametric_dmd.reset(
new T(eigs, phi_real, phi_imaginary, dmds[0]->d_k,
110 dmds[0]->d_dt, dmds[0]->d_t_offset,
111 dmds[0]->d_state_offset));
137 const std::vector<Vector>& parameter_points,
138 std::vector<std::string>& dmd_paths,
139 const Vector & desired_point,
140 std::string rbf =
"G",
141 std::string interp_method =
"LS",
142 double closest_rbf_val = 0.9,
143 bool reorthogonalize_W =
false)
145 std::vector<T*> dmds;
146 for (
int i = 0; i < dmd_paths.size(); i++)
148 T* dmd =
new T(dmd_paths[i]);
153 rbf, interp_method, closest_rbf_val, reorthogonalize_W);
154 for (
int i = 0; i < dmds.size(); i++)
std::shared_ptr< Matrix > interpolate(const Vector &point, bool orthogonalize=false)
Obtain the interpolated reduced matrix of the unsampled parameter point.
ComplexEigenPair NonSymmetricRightEigenSolve(const Matrix &A)
Computes the eigenvectors/eigenvalues of an NxN real nonsymmetric matrix.
std::vector< std::shared_ptr< Matrix > > obtainRotationMatrices(const std::vector< Vector > ¶meter_points, const std::vector< std::shared_ptr< Matrix >> &bases, int ref_point)
Obtain the rotation matrices for all the parameter points using the basis of the reference point.
void getParametricDMD(std::unique_ptr< T > ¶metric_dmd, const std::vector< Vector > ¶meter_points, std::vector< T * > &dmds, const Vector &desired_point, std::string rbf="G", std::string interp_method="LS", double closest_rbf_val=0.9, bool reorthogonalize_W=false)
Constructor.
int getClosestPoint(const std::vector< const Vector * > &points, const Vector &test_point)
Get closest point to a test point among a group of points.
Matrix * ev_real
The real component of the eigenvectors in matrix form.
std::vector< std::complex< double > > eigs
The corresponding complex eigenvalues.
Matrix * ev_imaginary
The imaginary component of the eigenvectors in matrix form.