Skip to content

Modifications to elliptic eigenproblem example #280

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

Merged
merged 28 commits into from
Jun 24, 2024
Merged

Conversation

siuwuncheung
Copy link
Member

@siuwuncheung siuwuncheung commented Apr 4, 2024

This is a follow up PR for #266 to enable the followings:

  1. Use eigenspace projection for error calculation
  2. Add boundary condition switch
  3. Clean up to retain only 4 problems, i.e. poisson, heterogeneous diffusion, Schrodinger equation with harmonic potential, Schrodinger equation with Gaussian potential well
  4. Extend to 3D examples
  5. Change some variable names

With the command lines,

./elliptic_eigenproblem_global_rom -offline -p 2 -rs 2 -id 0 -a 0 -n 4
./elliptic_eigenproblem_global_rom -offline -p 2 -rs 2 -id 1 -a 1 -n 4
./elliptic_eigenproblem_global_rom -merge -p 2 -rs 2 -ns 2 -n 4
./elliptic_eigenproblem_global_rom -fom -p 2 -rs 2 -a 0.5 -n 4 -visit
./elliptic_eigenproblem_global_rom -online -p 2 -rs 2 -a 0.5 -ef 1.0 -n 4 -visit

the output is

FOM solution for eigenvalue 0 = 19.878564
ROM solution for eigenvalue 0 = 19.878631
Absolute error of ROM solution for eigenvalue 0 = 6.6618756e-05
Relative error of ROM solution for eigenvalue 0 = 3.3512861e-06
FOM solution for eigenvalue 1 = 53.177886
ROM solution for eigenvalue 1 = 53.179662
Absolute error of ROM solution for eigenvalue 1 = 0.0017768914
Relative error of ROM solution for eigenvalue 1 = 3.3414104e-05
FOM solution for eigenvalue 2 = 53.177886
ROM solution for eigenvalue 2 = 53.179662
Absolute error of ROM solution for eigenvalue 2 = 0.0017769039
Relative error of ROM solution for eigenvalue 2 = 3.3414339e-05
FOM solution for eigenvalue 3 = 81.245811
ROM solution for eigenvalue 3 = 81.246105
Absolute error of ROM solution for eigenvalue 3 = 0.00029387266
Relative error of ROM solution for eigenvalue 3 = 3.6170808e-06
Relative l2 error of ROM eigenvector 0 = 0.0023815683
Relative l2 error of ROM eigenvector 1 = 0.0097810599
Relative l2 error of ROM eigenvector 2 = 0.0097816076
Relative l2 error of ROM eigenvector 3 = 0.0043291658

N.B.: It is a FOM issue rather than a ROM issue. If the Gaussian center falls on a grid point, the eigenvalue calculation for Schrodinger equation can be very unstable.

@siuwuncheung siuwuncheung added the WIP Work in progress label Apr 4, 2024
@siuwuncheung siuwuncheung self-assigned this Apr 4, 2024
@siuwuncheung siuwuncheung requested a review from ckendrick May 22, 2024 21:21
@chldkdtn chldkdtn added RFR Ready for review and removed WIP Work in progress labels May 30, 2024
@@ -43,7 +43,7 @@
// Elapsed time for assembling FOM: 1.471708e-03 second
// Elapsed time for solving FOM: 3.416310e-01 second
//
// Online phase: elliptic_eigenproblem_global_rom -online -p 2 -a 0.5
// Online phase: elliptic_eigenproblem_global_rom -online -p 2 -a 0.50
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am getting the following dramatically different outputs in Ruby for ROMs:

Number of unknowns: 289
Opening file: elliptic_eigenproblem_basis.000000
spatial basis dimension is 289 x 14
Eigenvalue 0: = 26.893636
Eigenvalue 1: = 67.093674
Eigenvalue 2: = 69.162828
Eigenvalue 3: = 109.44197
Eigenvalue 4: = 136.84225
norm_ref[i] = 273.80793
norm_ev[i] = 270.02649
ip[i] = 1.8178431
norm_ref[i] = 259.39492
norm_ev[i] = 264.66499
ip[i] = -12.477348
norm_ref[i] = 264.55127
norm_ev[i] = 264.93123
ip[i] = -22.66543
norm_ref[i] = 264.64771
norm_ev[i] = 259.31325
ip[i] = -97.06303
norm_ref[i] = 269.74102
norm_ev[i] = 273.78523
ip[i] = -18.535971
FOM solution for eigenvalue 0 = 26.893632
ROM solution for eigenvalue 0 = 26.893636
Absolute error of ROM solution for eigenvalue 0 = 3.97966e-06
Relative error of ROM solution for eigenvalue 0 = 1.4797778e-07
FOM solution for eigenvalue 1 = 67.093653
ROM solution for eigenvalue 1 = 67.093674
Absolute error of ROM solution for eigenvalue 1 = 2.1396013e-05
Relative error of ROM solution for eigenvalue 1 = 3.1889772e-07
FOM solution for eigenvalue 2 = 69.162823
ROM solution for eigenvalue 2 = 69.162828
Absolute error of ROM solution for eigenvalue 2 = 4.853771e-06
Relative error of ROM solution for eigenvalue 2 = 7.0178902e-08
FOM solution for eigenvalue 3 = 109.44196
ROM solution for eigenvalue 3 = 109.44197
Absolute error of ROM solution for eigenvalue 3 = 4.1389821e-06
Relative error of ROM solution for eigenvalue 3 = 3.7818969e-08
FOM solution for eigenvalue 4 = 136.84157
ROM solution for eigenvalue 4 = 136.84225
Absolute error of ROM solution for eigenvalue 4 = 0.0006786573
Relative error of ROM solution for eigenvalue 4 = 4.9594382e-06
Relative l2 error of ROM eigenvector 0 = 0.51582637
Relative l2 error of ROM eigenvector 1 = 1.9924533
Relative l2 error of ROM eigenvector 2 = 1.8788293
Relative l2 error of ROM eigenvector 3 = 1.9193804
Relative l2 error of ROM eigenvector 4 = 0.18407987
Unable to connect to GLVis server at localhost:19916
GLVis visualization disabled.
Elapsed time for assembling ROM: 1.196660e-02 second
Elapsed time for solving ROM: 5.293224e-02 second

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am getting the same results as you. I think the sample output comments in the header are old and haven't been updated with new values from the changes made in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is correct, then the relative l2 error for eigenvectors are pretty off.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am updating some examples and parameters with outputing more information. Eventually, I want to use this example:

./elliptic_eigenproblem_global_rom -offline -p 2 -id 0 -a 0.0
./elliptic_eigenproblem_global_rom -offline -p 2 -id 1 -a 1.0
./elliptic_eigenproblem_global_rom -merge -p 2 -ns 2
./elliptic_eigenproblem_global_rom -fom -p 2 -a 0.5 -visit
./elliptic_eigenproblem_global_rom -online -p 2 -a 0.5 -visit

With the most recent commit 11d63b0, the results are

Warning: eigenvector 1 in FOM and ROM are not directly comparable.
Inner product = 0.78603098
TODO: Projection error of eigenvector.
Warning: eigenvector 2 in FOM and ROM are not directly comparable.
Inner product = 0.78603092
TODO: Projection error of eigenvector.
FOM solution for eigenvalue 0 = 19.921322
ROM solution for eigenvalue 0 = 19.92139
Absolute error of ROM solution for eigenvalue 0 = 6.7559202e-05
Relative error of ROM solution for eigenvalue 0 = 3.391301e-06
FOM solution for eigenvalue 1 = 52.415509
ROM solution for eigenvalue 1 = 52.416907
Absolute error of ROM solution for eigenvalue 1 = 0.0013989485
Relative error of ROM solution for eigenvalue 1 = 2.6689592e-05
FOM solution for eigenvalue 2 = 52.415509
ROM solution for eigenvalue 2 = 52.416908
Absolute error of ROM solution for eigenvalue 2 = 0.0013990685
Relative error of ROM solution for eigenvalue 2 = 2.6691881e-05
FOM solution for eigenvalue 3 = 81.244631
ROM solution for eigenvalue 3 = 81.245048
Absolute error of ROM solution for eigenvalue 3 = 0.00041707441
Relative error of ROM solution for eigenvalue 3 = 5.1335627e-06
Relative l2 error of ROM eigenvector 0 = 0.0010013981
Relative l2 error of ROM eigenvector 1 = 0.65416973
Relative l2 error of ROM eigenvector 2 = 0.65416982
Relative l2 error of ROM eigenvector 3 = 0.0025055664

Right now, the L2 error of the eigenvectors with non-simple eigenvalues (eigenvector 1 and 2 above) are large because of the way it is calculated, which is direct comparison of the FOM/ROM eigenvectors of the same index.

I will update the results in the header of the script and on the libROM webpage soon after the next PR.

Copy link
Collaborator

@chldkdtn chldkdtn left a comment

Choose a reason for hiding this comment

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

Looks good!

@siuwuncheung siuwuncheung merged commit 7a018bd into master Jun 24, 2024
4 checks passed
@siuwuncheung siuwuncheung deleted the evp_modify branch June 27, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants