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

Squared singular values to calculate POD variance #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

axla-io
Copy link
Collaborator

@axla-io axla-io commented Feb 3, 2025

Current libROM implementation of BasisGenerator::finalSummary sums the singular values to calculate the total POD energy, but this should actually be the sum of squared singular values, compare to Chatterjee (2000) chapter 6.4. This short PR adresses that in libROM.

Test mixed nonlinear diffusion

To test with mixed nonlinear diffusion, run:

./mixed_nonlinear_diffusion -p 1 -offline -id 0 -sh 0.25
./mixed_nonlinear_diffusion -p 1 -offline -id 1 -sh 0.15
// Merge
./mixed_nonlinear_diffusion -p 1 -merge -ns 2

On the current master, the file mergedSV_FR reads

For energy fraction: 0.9, take first 5 of 200 basis vectors
For energy fraction: 0.99, take first 8 of 200 basis vectors
For energy fraction: 0.999, take first 12 of 200 basis vectors
For energy fraction: 0.9999, take first 16 of 200 basis vectors
For energy fraction: 0.99990, take first 16 of 200 basis vectors

In this PR, the file reads

For energy fraction: 0.9, take first 3 of 200 basis vectors
For energy fraction: 0.99, take first 5 of 200 basis vectors
For energy fraction: 0.999, take first 7 of 200 basis vectors
For energy fraction: 0.9999, take first 8 of 200 basis vectors
For energy fraction: 0.99990, take first 8 of 200 basis vectors

Test nonlinear elasticity

To test with nonlinear elasticity, run:

./nonlinear_elasticity_global_rom -offline -dt 0.01 -tf 5.0 -s 14 -vs 100 -sc 0.9 -id 0
./nonlinear_elasticity_global_rom -offline -dt 0.01 -tf 5.0 -s 14 -vs 100 -sc 1.1 -id 1

// Merge:
./nonlinear_elasticity_global_rom -merge -ns 2 -dt 0.01 -tf 5.0

On the current master, the file mergedSV_H.txt reads

For energy fraction: 0.9, take first 12 of 1002 basis vectors
For energy fraction: 0.99, take first 29 of 1002 basis vectors
For energy fraction: 0.999, take first 59 of 1002 basis vectors
For energy fraction: 0.9999, take first 96 of 1002 basis vectors
For energy fraction: 0.99999, take first 134 of 1002 basis vectors
For energy fraction: 0.999999, take first 165 of 1002 basis vectors
For energy fraction: 0.9999999, take first 189 of 1002 basis vectors
For energy fraction: 0.99999990, take first 189 of 1002 basis vectors

In this PR, the file reads

For energy fraction: 0.9, take first 5 of 1002 basis vectors
For energy fraction: 0.99, take first 11 of 1002 basis vectors
For energy fraction: 0.999, take first 19 of 1002 basis vectors
For energy fraction: 0.9999, take first 26 of 1002 basis vectors
For energy fraction: 0.99999, take first 35 of 1002 basis vectors
For energy fraction: 0.999999, take first 49 of 1002 basis vectors
For energy fraction: 0.9999999, take first 67 of 1002 basis vectors
For energy fraction: 0.99999990, take first 67 of 1002 basis vectors

@@ -321,7 +321,7 @@ BasisGenerator::finalSummary(

double sum = 0.0;
for (int sv = first_sv; sv < sing_vals->dim(); ++sv) {
sum += (*sing_vals)(sv);
sum += std::pow((*sing_vals)(sv), 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using pow(x,2) can be slower than x*x, but that is only a concern within a bottleneck. Here it shouldn't matter.

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

Successfully merging this pull request may close these issues.

2 participants