Skip to content
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

Latent dynamics & GP factorization #8

Merged
merged 15 commits into from
Sep 16, 2024
Merged

Latent dynamics & GP factorization #8

merged 15 commits into from
Sep 16, 2024

Conversation

dreamer2368
Copy link
Collaborator

@dreamer2368 dreamer2368 commented Aug 22, 2024

latent_dynamics module

  • A general abstract class that calibrates the coefficients for latent dynamics right-hand side, and predicts the latent trajectories.
  • Coefficients coefs are now 1d array at each parameter point, in order to generalize GP sampling for general latent dynamics classes.

latent_dynamics.sindy module

  • Strong-form SINDy class
  • Existing SINDy functions are factored out here.
  • For prediction, SINDy class takes 1d array of coefficients, reshapes it into a 2d matrix, then conducts the standard time-integration.

gp module

Previously, Gaussian-process modules go through unnecessary data preparation steps. Also, the routines are limited to SINDy, limiting the use of general latent dynamics. Now GP-related routines are simplified into three functions:

  • fit_gps: returns a list of GP objects given parameter points and coefficients
  • eval_gp: evaluate mean/standard deviation of coefficients using GP dictionary at given parameter points
  • sample_coefs: generate samples of coefficients at the given parameter point, using GP dictionary

gplasdi module

  • find_sindy_coefs is removed. Instead, computing coefficients and sindy/coefficient losses is delegated to LatentDynamics class.
  • get_new_sample: new sample point selection is now factored out as a single function.
  • average_rom: computes latent trajectories at parameter points using average values of coefficients.
  • sample_roms: generate samples of latent trajectories at parameter points, with coefficients sampled from GP dictionary.

postprocess module

  • compute_error computes error and residual on a single snapshot. Residual is computed by physics class.
  • Addition of new plotting functions:
    • plot_gp2d: plot standard deviation and average of latent dynamics coefficients on 2d parameter space, together with training data points.
    • heatmap2d: plot a heat map of a scalar field on the 2d parameter space, together with training data points.

timing module

A light-weight timer class Timer is implemented for computation time profiling.

Separating/removing unnecessary and complex routines

Several routines that use unnecessary and complex steps are now either factorized and removed:

  • build_interpolation_data
  • interpolate_coef_matrix->sample_coefs
  • interpolate_coef_matrix_mean
  • simulate_uncertain_sindy
  • simulate_interpolated_sindy
  • simulate_uncertain_sindy_mean
  • simulate_interpolated_sindy_mean
  • compute_errors
  • residual

Moved legacy codes

Legacy code examples are now moved into the directory legacy.

@dreamer2368 dreamer2368 marked this pull request as ready for review September 3, 2024 21:25
@dreamer2368 dreamer2368 requested review from CBonneville45, chldkdtn and andersonw1 and removed request for CBonneville45 September 3, 2024 23:30
@dreamer2368 dreamer2368 added the RFR Ready for Review label Sep 3, 2024
Copy link
Collaborator

@CBonneville45 CBonneville45 left a comment

Choose a reason for hiding this comment

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

Very nice work on refactoring the code! Is the plan to make (just) GPLaSDI easier to use or are there plans to bring-in some elements of other LaSDI models (e.g. weak form). A full "production-ready" LaSDI library could be really cool!

@dreamer2368
Copy link
Collaborator Author

dreamer2368 commented Sep 4, 2024

Very nice work on refactoring the code! Is the plan to make (just) GPLaSDI easier to use or are there plans to bring-in some elements of other LaSDI models (e.g. weak form). A full "production-ready" LaSDI library could be really cool!

Thanks! Full "production-ready" LaSDI library is indeed the plan of this refactoring. On one hand we'd like to make small simple modules with which people can easily prototype, and on the other hand we'd like to incorporate all variation of LaSDI. This PR lays the ground for such incorporation. Hopefully more people will be able to jump in for introducing more variations.

Copy link
Collaborator

@andersonw1 andersonw1 left a comment

Choose a reason for hiding this comment

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

Great work, Kevin! This looks good and I was able to run with accurate results after making some of the minor changes in the jupyter notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants