Skip to content

Normalisation fixes - #3482

Open
dschwoerer wants to merge 3 commits into
nextfrom
hermes-hotfix
Open

Normalisation fixes#3482
dschwoerer wants to merge 3 commits into
nextfrom
hermes-hotfix

Conversation

@dschwoerer

Copy link
Copy Markdown
Contributor

Both commits are required to have the 2D-production test for Hermes-3. I tested locally only the 2nd patch, and in CI the first patch only. Both failed on there own.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

}
return {.g11{1 / SQ(Bnorm * rho_s0)},
return {.g11{SQ(Bnorm * rho_s0)},
.g11_mul{true},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: braces around scalar initializer [clang-diagnostic-braced-scalar-init]

Suggested change
.g11_mul{true},
.g11_mul true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure what clang-tidy is trying to do here, but g++ 15.2.0 is not happy with the suggested change.

Comment thread src/mesh/tokamak_coordinates.cxx
Comment thread src/mesh/tokamak_coordinates.cxx
Comment thread src/mesh/tokamak_coordinates.cxx
Comment on lines +88 to +89
.g12{Bnorm},
.g12_mul{true},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this at all -- why is this not equivalent? Is it just loss of precision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, and that seems to cause the failures in Hermes-3. If you think we should not do this, and just update the expected results, then we can do that, too. But I thought it might be good if we do not change results without a somewhat good reason, and the _mul additions do not seem like a huge addition of code.

@dschwoerer

Copy link
Copy Markdown
Contributor Author

For the record, without these changes, Hermes-3 fails with:

      Start 14: 2D-production
14/20 Test #14: 2D-production ..............................***Failed   12.69 sec

libgomp: Invalid value for environment variable OMP_NUM_THREADS: 
2D-Production test: download took 0.00 seconds
2D-Production test: zip extraction took 1.77 seconds
2D-Production test: simulation took 2.08 seconds
2D-Production test: loading results took 6.95 seconds
2D-production test: Failed in 11.24 seconds
2D-production test failures:

inner_lower_target [ddt(Pe)]:

Not equal to tolerance rtol=1e-05, atol=1e-08

Mismatched elements: 1 / 16 (6.25%)
Mismatch at index:
 [8]: 0.03679871893512578 (ACTUAL), 0.036799153418756995 (DESIRED)
Max absolute difference among violations: 4.34483631e-07
Max relative difference among violations: 1.1806892e-05
 ACTUAL: array([-0.050165, -0.067434, -0.095253, -0.140382, -0.18905 , -0.238565,
       -0.344202, -0.562915,  0.036799, -0.091465, -0.586319, -0.396325,
       -0.224284, -0.064263,  0.009454,  0.049401])
 DESIRED: array([-0.050165, -0.067434, -0.095253, -0.140382, -0.18905 , -0.238565,
       -0.344202, -0.562915,  0.036799, -0.091465, -0.586319, -0.396325,
       -0.224284, -0.064263,  0.009454,  0.049401])

sol_ring [ddt(Pe)]:

Not equal to tolerance rtol=1e-05, atol=1e-08

Mismatched elements: 1 / 50 (2%)
Mismatch at index:
 [0]: 0.03679871893512578 (ACTUAL), 0.036799153418756995 (DESIRED)
Max absolute difference among violations: 4.34483631e-07
Max relative difference among violations: 1.1806892e-05
 ACTUAL: array([ 0.036799, -1.645953, -1.76924 , -1.600019, -1.298552, -0.991483,
       -0.854056, -0.782628, -0.775318, -0.861349, -0.864964, -0.775591,
       -0.790239, -0.855372, -0.999383, -1.299618, -1.591131, -1.75628 ,...
 DESIRED: array([ 0.036799, -1.645953, -1.76924 , -1.600019, -1.298552, -0.991483,
       -0.854056, -0.782628, -0.775318, -0.861349, -0.864964, -0.775591,
       -0.790239, -0.855372, -0.999383, -1.299618, -1.591131, -1.75628 ,...

So it seems the rounding errors in doubles, cause differences in 1e-5 range.

@dschwoerer

Copy link
Copy Markdown
Contributor Author

There are rounding differences between B/Bnorm and B * (1/Bnorm) - they are numerically not the same. It seems such differences cause enough of a differences to cause larger differences in the end, i.e. the 2D-production test is very sensitive to such grid details

The PR address this by normalising just the same way that Hermes-3 used to normalise the metrics

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