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

Add proper adaptive timestepping to elastic simulations #57

Closed
wants to merge 1 commit into from

Conversation

ilateur
Copy link
Collaborator

@ilateur ilateur commented Jan 15, 2025

Problem

Adaptive time stepping did not properly work with magnetoelastic simulations, because the absolute error of all Variables was used to gauge accuracy. An absolute error of 1e-5 or lower was seen as good enough for displacements of the order of ~1e-14 m and velocities of ~1e-4 m/s.

Solution

The essential difference is moving the maxError of adaptive time stepping from TimeSolver to DynamicEquation, so each equation has its own error to adhere to. This is not user-accessible, so the 3 relevant max errors can be set via the (Ferro)Magnet, with automatic telepathic pointer-communication (I'm not the biggest fan of this solution). This is the only (or maybe not) solver setting outside of TimeSolver :( but it also has a physical unit and is physics dependent.

As a consequence, the Relaxer cannot directly set maxError of the TimeSolver anymore. This is not a problem, because it needs to create new DynamicEquations anyway, so it can also assign a pointer to its own maxerr variable, then scale that.

Let me know if you have a better solution though.

Potential To-Do's

  • take a look at sensibleTimeStep()
  • may need to tweak default values 1e-18 and 1e-7 of displacementMaxError and velocityMaxError.
  • make starting value of maxerr_ in Relaxer user-assignable? This used to start at maxError of TimeSolver.
  • clean up Relaxer?
  • clean up raw pointer logic?

@ilateur ilateur added the enhancement New feature or request label Jan 15, 2025
@ilateur ilateur self-assigned this Jan 15, 2025
@DiegoDeGusem
Copy link
Contributor

The magnetization max error is a ferromagnet property, so it is possible to set 2 different errors in an antiferromagnet? That's a bit strange 🤔
Maybe this could also benefit from some tests and/or an example?
I don't immediately see a better way of handling this, so this method is fine by me I think

@ilateur
Copy link
Collaborator Author

ilateur commented Jan 20, 2025

Do you have a suggestion for any test?
As examples I figured it was fine to remove the fixed time step from all (magneto)elastic examples.

@ilateur
Copy link
Collaborator Author

ilateur commented Jan 20, 2025

The implementation has been done in a different way, see pull request #60.

@ilateur ilateur closed this Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants