Closed dreamer2368 closed 1 month ago
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.
latent_dynamics
modulecoefs
are now 1d array at each parameter point, in order to generalize GP sampling for general latent dynamics classes.latent_dynamics.sindy
moduleSINDy
class takes 1d array of coefficients, reshapes it into a 2d matrix, then conducts the standard time-integration.gp
modulePreviously, 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 coefficientseval_gp
: evaluate mean/standard deviation of coefficients using GP dictionary at given parameter pointssample_coefs
: generate samples of coefficients at the given parameter point, using GP dictionarygplasdi
modulefind_sindy_coefs
is removed. Instead, computing coefficients and sindy/coefficient losses is delegated toLatentDynamics
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
modulecompute_error
computes error and residual on a single snapshot. Residual is computed byphysics
class.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
moduleA 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
.