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.
📝 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:
Changing simulation parameter ["ROM"]["type_of_decoder"] to "ann_enhanced".
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
Added rom_nn_utility.h file: implements RomNNUtility class with various static methods.
Added ann_prom_global_rom_builder_and_solver.h file: implements AnnPromGlobalROMBuilderAndSolver class, which inherits from ResidualBasedBlockBuilderAndSolver and is an alternative to GlobalROMBuilderAndSolver with different ProjectROM() and SolveROM() methods.
Added ann_prom_lspg_rom_builder_and_solver.h file: implements AnnPromLeastSquaresPetrovGalerkinROMBuilderAndSolver class, which inherits from AnnPromGlobalROMBuilderAndSolver and is an alternative to LeastSquaresPetrovGalerkinROMBuilderAndSolver with different ProjectROM() method.
Modified rom_nn_trainer.py file: added the NN_ROM_Interface class, which uses Tensoflow to build the decoder and pass the needed information to the builder&solver.
Modified rom_manager.py file: modified Fit(), Test() and RunROM() methods to be able to run the ANN-PROM simulations, and to instantiate the NN_ROM_Interface.
Modified rom_analysis.py file: modified ModifyAfterSolverInitialize() and ModifyInitialGeometry() methods to differentiate between cases with and without ANN-PROM.
Modified rom_solver.py file: modified CreateSolver class to call the correct Builder&Solvers
Modified rom_testing_utilities.py file: modified SetUpSimulationInstance() method to be able to pass the NN_ROM_Interface to the analysis stage.
📝 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:
🆕 Changelog