Skip to content

Feature: Wall clock timers for RunWhile, Relax, Minimize#388

Merged
JonathanMaes merged 9 commits into
mumax:3.11.2from
jplauzie:WallClock
Apr 8, 2026
Merged

Feature: Wall clock timers for RunWhile, Relax, Minimize#388
JonathanMaes merged 9 commits into
mumax:3.11.2from
jplauzie:WallClock

Conversation

@jplauzie

Copy link
Copy Markdown
Contributor

Adds a function that allows the user to add some noise, then Run/Relax/Minimize for a specified amount of wallclock time or (for Relax/Minimize) if the solver converges. This is useful for stiff problems where one particular solver gets stuck (In my experience, this can happen with e.g. hysteresis loops at small external fields), to help jiggle out of a local minimum.

  • noise, Runwhile, Relax, Minimize , are each consecutively called for some user-input wallclock time. If a user wants a different order (say, no Run), they can just input 0 walltime, judiciously. This can also be looped in a while(for) loop to keep cycling between run->relax->minimize until it converges.
  • The current implementation is a bit messy, I basically copied Minimize/Relax verbatim. It would be cleaner to integrate the inputs/flags into existing Relax/Minimize directly (or possibly using injections?) but I didn't want to mess with such sensitive core functions.
  • Introduces a new magnetization Config, CurrentMag. This just makes the current magnetization into a Config. This is mostly useful for adding noise, as "m=Currentmag().add(0.1,randommag())". Works with stuff like .transl() as one would expect. Can be a bit memory intensive as it stores a Hostcopy of the magnetization whereas Configs usually are a mathematical function. I have not seen any issues with e.g. memory leaks.

adds wallclocktimer function.
Added Wallclocktimer function
@JonathanMaes
JonathanMaes changed the base branch from master to 3.11.2 March 18, 2026 15:26
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
Comment thread engine/ext_wallclocktimer.go Outdated
@JonathanMaes JonathanMaes added this to the 3.12 milestone Mar 25, 2026
moves CurrentMag to config.go

folds MinimizeForSeconds and RelaxForSeconds into minimize and relax respectively

RunSequence was not necessarily- this can now be accomplished in an mx3 script, and with more flexibility

RunForSeconds can also be done in an mx3 script, as Runwhile already accepts a bool condition
@jplauzie

Copy link
Copy Markdown
Contributor Author

This should be a bit cleaner implementation, I think.

  • Moves CurrentMag() to config.go
  • folds RelaxForSeconds and MinimizeForSeconds into Relax/Minimize respectively via a small WallTimer function, and exposes RelaxWallClockTime and MinimizeWallclockTime to the user as floats they can set
  • RunSequence was removed, as this can be done in an mx3 file
  • Since RunWhile already accepts a bool argument, RunForSeconds can also already be accomplished in an mx3 file, and RunForSeconds was effectively just a wrapper function, so I removed it to keep the code base a bit cleaner

In principle, there is a rare condition where you hit convergence in the loop just barely before the wallclock time, but by the time you hit the final MinimizeConverged check, the wallclock time is exceeded and returns false. So instead, just check the physical convergence condition at the end instead of WallClockTimer, since this doesn't change with time, only loop iterations. In practice this likely never happens, but may as well be safe

fixed left over reference to wallclock variable
Comment thread engine/relax.go Outdated
Comment thread engine/relax.go Outdated
fix bool return in relax

add wallclock to initial energy minimization in relax (not just torque minimizes)

accidentally deleted a !pause, put back in
Comment thread test/wallclocktime.mx3 Outdated
@JonathanMaes
JonathanMaes merged commit 0f592a9 into mumax:3.11.2 Apr 8, 2026
@JonathanMaes JonathanMaes mentioned this pull request Apr 10, 2026
4 tasks
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.

3 participants