-
Notifications
You must be signed in to change notification settings - Fork 5
Train ROM
In this section of the tutorial, we run the following commands
cd examples/poisson ../../bin/main -i poisson.sample.yml ../../bin/main -i poisson.train.yml ../../bin/main -i poisson.sample.yml -f model_reduction/subdomain_training=individual ../../bin/main -i poisson.train.dom.yml
By "training ROM", here we refer to performing proper orthogonal decomposition (POD) over the collected snapshots from the sample generation stage. This can be specified in the input file as main/mode
:
main:
mode: train_rom
solver: poisson
In order to train ROM, we need to specify the list of basis for which we collected snapshots. In the example of examples/poisson/poisson.train.yml
, we have the option
basis:
prefix: "poisson0"
number_of_basis: 3
tags:
- name: "empty"
- name: "square-circle"
- name: "square-square"
- name: "square-star"
svd:
save_spectrum: true
update_right_sv: false
Here are the description for the input options:
-
basis/prefix
: the prefix string used for snapshots and basis, which is usually the same assample_generation/file_path/prefix
. -
basis/number_of_basis
: the default number of basis vectors for all basis tags, unless their custom number of basis is specified. -
basis/tags
: the list of snapshots/basis names according tomodel_reduction/subdomain_training
- For
universal
subdomain training, the snapshots/basis are named after their reference component names. - For
individual
subdomain training, the snapshots/basis are named asdom0
,dom1
, ...
- For
-
basis/svd
: sets the option of saving singular value spectrum or computing right-hand singular vectors.
By default, train_rom
mode will attempt to read the snapshot file in the format of
[basis/prefix]_[basis/tag]_snapshots.000000
We first generate the snapshots by running the command
cd examples/poisson
../../bin/main -i poisson.sample.yml
Running the command
../../bin/main -i poisson.train.yml
performs POD over 4 reference components.
![Screenshot 2023-12-14 at 2 18 06 PM](https://private-user-images.githubusercontent.com/16692800/290670741-e39d7693-cc8a-4c80-a3aa-4c66b3e99562.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzAwMjgyMDMsIm5iZiI6MTczMDAyNzkwMywicGF0aCI6Ii8xNjY5MjgwMC8yOTA2NzA3NDEtZTM5ZDc2OTMtY2M4YS00YzgwLWEzYWEtNGM2NmIzZTk5NTYyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEwMjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMDI3VDExMTgyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyMjgzYmYwZGY3OTUyNGU5ZmYwNWU3MGZmYzEyNzI0YTY5MDcwNmQ2OTdjNDc4YjMxOTg0ZDBiOGRhZWJkNTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.UMrg25onLweIUior-PM0rmz388u-WboG5VjTKYsW4r0)
It is possible to train ROM with a custom number of basis or a custom snapshot file. In the example of examples/poisson/poisson.train.dom.yml
,
basis:
prefix: "poisson0"
number_of_basis: 3
tags:
- name: "empty"
snapshot_files: [poisson0_sample_dom2_snapshot]
- name: "square-circle"
snapshot_files: [poisson0_sample_dom0_snapshot]
number_of_basis: 2
- name: "square-square"
snapshot_files: [poisson0_sample_dom1_snapshot]
- name: "square-star"
snapshot_files: [poisson0_sample_dom3_snapshot]
train_rom
mode will attempt to read a file with the specified name followed by .000000
. For example of empty
component, the file poisson0_sample_dom2_snapshot.000000
will be attempted to be read. Note that the file names are given as a list of strings, not a string itself. This is to support multiple snapshot files in future.
In order to generate the snapshot files named as above, we run the following command:
../../bin/main -i poisson.sample.yml -f model_reduction/subdomain_training=individual
It is also possible to set different number of basis for each basis tag. For the example of examples/poisson/poisson.train.dom.yml
, square-circle
component will have 2 basis vectors, while the others will have the default 3 basis vectors. Running
../../bin/main -i poisson.train.dom.yml
performs the POD as follows:
![Screenshot 2023-12-14 at 2 29 08 PM](https://private-user-images.githubusercontent.com/16692800/290672794-8593a129-fee8-4f1c-bf62-9116a1ec8814.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzAwMjgyMDMsIm5iZiI6MTczMDAyNzkwMywicGF0aCI6Ii8xNjY5MjgwMC8yOTA2NzI3OTQtODU5M2ExMjktZmVlOC00ZjFjLWJmNjItOTExNmExZWM4ODE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEwMjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMDI3VDExMTgyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3MDE5ZmVmOGY2N2ViZmI5ODQyNzFmMGI3MzJiYWE3ZTY0ZTNkYTA4YjIxNGQ1YWZlN2Q3YjJiMjkyMzI2MGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.86MkIzgYAWyYewUHv7qhckRPYfZ3qu3XJVF2vUrWVY8)
We see that by using 2 basis vectors only, ROM basis for the square-circle
component covers only 81% of the snapshots, while the others can cover 100% (by taking the same number of basis as that of the snapshots).