-
Notifications
You must be signed in to change notification settings - Fork 75
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
Unit testing tolerance improvements + Von Mises sensitivity fix #216
Conversation
I think this is good to go now |
@A-CGray we should probably add these improvements to the element tests too for consistency? |
OK, I've switched over the elements tests to use There is currently one failing test in the I think the error here is correct, but maybe @markleader knows more.
|
@markleader do you have any insight on the failing PCM test? |
@A-CGray Started looking into it today. Sorry for the delay. I haven't figured it out yet but I'll check in again soon |
@A-CGray This should be fixed now with the PR I just submitted. Take a look and let me know |
Great, thanks @markleader ! |
@gjkennedy can you merge this if you're happy with the changes |
In unit tests we currently use an essentially infinite absolute tolerance and a very large relative tolerance. This is done because it is very hard to specify a single absolute tolerance that is valid for test values that span multiple orders of magnitude, and relative errors can be very high even for accurate derivatives when the test values are very small.
This PR fixes this issue by implementing a new kind of check between test and reference values. In doing so, the constitutive unit tests now pass with tolerances 1000x tighter than before.
The check now performed is identical to that used by numpy's assert_allclose method:
fail = abs( test - ref ) > atol + rtol * abs(ref)
Where
ref
is the finite-difference or complex-step value andtest
is the analytic valueWhen
abs(ref) >> atol/rtol
this check acts like a relative tolerance check, but forabs(ref) << atol/rtol
it acts like an absolute tolerance check, thus avoiding the issues associated with relative tolerances of very small values.Changes:
TacsAssertAllClose
methodTacsAssertAllClose
for all constitutive model unit tests1e-5*self.rtol
clipped to be within 1e-8 - 1e-14TacsPrintErrorComponents