Skip to content

Snapshot dmd #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jun 21, 2024
Merged

Snapshot dmd #289

merged 33 commits into from
Jun 21, 2024

Conversation

ptranq
Copy link
Collaborator

@ptranq ptranq commented May 22, 2024

Adds the SnapshotDMD class derived from DMD. This class essentially performs DMD but interpolates the current snapshots to new "artificial snapshots" in large enough quantity to produce a DMD ROM with the given reduced dimension. This interpolation is performed with the SnapshotInterpolator class, specifically with PCHIP interpolation.

The wave_equation example is extended to provide the option of using snapshotDMD, as well minor improvements to provide the option to use initial condition projection for windows after the first, and the option to provide an output directory to minimize clutter after running the example.

ptranq added 23 commits April 16, 2024 22:19
with DMD.  Pivoting the DMD changes to derived class SnapshotDMD in
future commits.  Turned off "window overlap" in parametric_dw_csv.
SnapshotInterpolator and its unit test.
to the wave equation example.  Improved wave equation example to
include projected initial conditions in later windows, as well as
print output to a specified directory to keep the running directory
clean.
Copy link
Member

@siuwuncheung siuwuncheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! An exciting enhancement to DMD. Thanks, @ptranq

d_snapshots = new_snapshots;
d_sampled_times = new_times;
d_dt = d_sampled_times[2]->getData()[0]-d_sampled_times[1]->getData()[0];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Vector* state_offset) :
DMD(eigs, phi_real, phi_imaginary, k, dt, t_offset, state_offset) {}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

{
result_u = dmd_u[curr_window]->predict(ts[i]);
cout << "Projecting solution for new window at " << ts[i] << endl;
dmd_u[curr_window+1]->projectInitialCondition(result_u, ts[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me to better understand the changes, I guess this projection is not necessarily relevant to the snapshot interpolation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This is simply projecting the initial conditions in each subsequent window to come from the final conditions of the preceding window. This makes the DMD solution be a prediction across the entire time domain, instead of a series of approximations each across only a single window.

// wave_equation -tf 2 -nwinsamp 25 -rdim 27 -visit -snap -proj
//
// Output 2:
// Relative error of DMD solution (u) at t_final: 2 is 0.0029577152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that the error is higher than the original outputs, with a mixed effect of enabling snapshot interpolation and the projection of initial condition. It could be helpful if we know which one is the source of the increase of the error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the output for command 1 to reflect what I obtain on quartz. I get a different error than what was reported previously while running on this branch, and confirmed the same (new) numbers on the master branch. Additionally, I have added two new examples: the first performs the current "command 1" with projection enabled, and the second performs the current "command 2" with projection disabled. The errors are much closer together and should, hopefully, clear things up.

@chldkdtn chldkdtn changed the base branch from snapshot_interpolation to master June 20, 2024 16:46
}
protected:
/**
* @brief Obtain DMD model interpolant at desired parameter point by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is just declaring the existing function as a friend, I don't think we need to copy the comments here. They are already in ParametricDMD.h. Maybe just a 1-line comment like See ParametricDMD.h for documentation. The comments could be removed also from existing files like DMD.h and NonuniformDMD.h, since they are just duplicated. I wonder if there is a better design, perhaps with getParametricDMD being a method of the base DMD class, but we can leave that question for another PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of the original intention of parametricDMD being its own class. It would be my preference to leave the comments here, so that it is easy to find out what each one does, since this function provides essential functionality to the class. If noone else agrees, I am happy to ditch them though.

*
*****************************************************************************/

// Description: Implementation of the AdaptiveDMD algorithm.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AdaptiveDMD -> SnapshotDMD

@ptranq ptranq merged commit 1c523cb into master Jun 21, 2024
4 checks passed
@dylan-copeland dylan-copeland deleted the SnapshotDMD branch June 22, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants