KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.02k stars 244 forks source link

[RomApp] Adding intrusive ROM simulation routine via ANN-PROM #12502

Closed NicolasSR closed 2 months ago

NicolasSR commented 3 months ago

📝 Description This pull request is the second one in the path to incorporate ANN-PROM into the ROM Application. We already incorporated the training routine for the neural networks in the first PR, and in this one we use these neural networks within the ROM simulation in Kratos. Note that neither petrov-galerkin nor HROM are implemented yet, only global galerkin and global LSPG. Additionally, LineSearch does is not compatible with this type of decoder (this will be solved in the next PR).

Essentially, ANN-PROM is an extension of PROM where a part of the modes form our latent space and are actually manipulated by the solver, and the rest of the modes (or some of them) are estimated by those first ones through a NN to give extra precision and information to the solver.

This implementation is done in a way that will utilize the data already available through the RomManager's database. So, from the user's perspective, they only need to add the NN's configuration within the ROM parameters (as in the last PR), and then set "type_of_decoder" to "ann_enhanced" instead of "linear". Then, any of the typical Fit(), Test(), or RunROM() methods can be called.

Internally, when calling an ANN-PROM simulation, a new global ROM Builder&Solver is called (there is one for galerkin and one for LSPG). All of these use static methods from a new utility called rom_nn_utility.h, which implements in C++ a forward pass of the decoder (including the NN) and the calculation of the derivative of the decoder with respect to its input. The weights of the NN are passed from TensorFlow by the python class NN_ROM_Interface.

Usage The usage is via:

  1. Changing simulation parameter ["ROM"]["type_of_decoder"] to "ann_enhanced".
    1. And then calling any of the following:
      • rom_manager.Fit(mu_train, mu_validation): To get the ROM Basis and train the NN.
      • rom_manager.Test(mu_train, mu_test): To evaluate an already-existing ROM Basis and NN on a test set. The train set used while training must be specified to retrieve the correct basis and NN weights.
      • rom_manager.RunROM(mu_train, mu_run): To run new ROM cases. The train set used while training must be specified to retrieve the correct basis and NN weights.

🆕 Changelog