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

Fix issues with nonlinear problems when using MPhys wrapper #268

Merged
merged 51 commits into from
Jun 24, 2024

Conversation

A-CGray
Copy link
Contributor

@A-CGray A-CGray commented Oct 30, 2023

  • Nonlinear solves are failing when run through the TACS MPhys wrapper
  • For example, nonlinear cantilever works fine when run directly with pyTACS, but if I setup the same problem through MPhys, the first linear solve produces NaN's:
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|  Iter   |    Time     |  Increment  |     Lambda      |  SubIter  |  Lin iters  |     Lin res     |    Res norm     |  Rel res norm   |     U norm      |     LS step     |  LS iters  |    Flags     |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|      0  |  0.000e+00  |        0    |   2.000000e-01  |       0   |      -      |        -        |   5.656854e-01  |   1.000000e+00  |   0.000000e+00  |        -        |     -      |              |
|      1  |  2.081e-03  |        0    |   2.000000e-01  |       1   |        1    |           nan   |           nan   |           nan   |           nan   |           nan   |      25    |      PD      |
  • I think the might be being caused by the fact that we gave the nonlinear solvers their own linear solvers. But when the static problem create's a new matrix and preconditioner we don't pass those on to the nonlinear solver linear solvers.

This PR addresses this by passing the new stiffness matrix and preconditioner to the nonlinear solvers' linear solvers.

I also added a version of the nonlinear hemispherical shell integration test that uses the MPhys wrapper so that using the nonlinear solver through MPhys is covered in the tests. As part of this I found that getting accurate complex-step derivatives was very sensitive to how the solver converged. I therefore added an option to the static problem class that tells TACS to reset the state variables before every solve, which seemed to fix the issue.

Finally I altered the mphys buckling integration test to stop it writing out loads of .f5 files

@A-CGray A-CGray requested a review from timryanb October 30, 2023 14:55
@A-CGray A-CGray marked this pull request as ready for review June 18, 2024 00:35
@A-CGray
Copy link
Contributor Author

A-CGray commented Jun 18, 2024

@timryanb , took me a while but I finally got this sorted!

"resetBeforeSolve": [
bool,
False,
"Reset the states before every solve, this can be useful for avoiding issues when testing derivatives with dinite-difference/complex-step",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small typo in "finite"

Copy link
Collaborator

@timryanb timryanb left a comment

Choose a reason for hiding this comment

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

Other than that, this looks good to me

@A-CGray
Copy link
Contributor Author

A-CGray commented Jun 24, 2024

Thanks @timryanb , are you happy to merge this right away or do you want to wait for a release like #319 ?

@timryanb
Copy link
Collaborator

Thanks @timryanb , are you happy to merge this right away or do you want to wait for a release like #319 ?

I'm fine merging now if there aren't any breaking changes

@A-CGray A-CGray merged commit 9fc5c39 into master Jun 24, 2024
5 checks passed
@A-CGray A-CGray deleted the fixNonlinearMPhys branch June 24, 2024 18:09
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