Repository navigation
Raise when a run stops before its STOP time - #8
Merged
Merged
Conversation
RAMSES ends a run on "Divergence. Simulation stopped" by setting its end-of-simulation flag alone, so ramses() returns 0, the same flag as a run that reached STOP. execSim() took that 0 as success, which is how the reduced GB network passed for three months while its trajectory ended at 0.34 s. execSim() and contSim() now compare getSimTime() with the STOP time of the disturbance file when the engine returns 0, and raise RAMSESError when the run fell short, quoting the engine's last "t = ..." line from the part of the trace file the call wrote. endSim() skips the check, as does $LATENCY early stopping, which the engine logs as "All equipment is latent". A STOP added through addDisturb() moves the time checked against. tests/test_divergence.py reaches the engine's divergence branch on the Nordic case with an unreachable $NEWTON_TOLER, and checks that a run reaching STOP and an endSim() before STOP still pass.
…engine The engine now returns -1 for a diverged run, with the message in getLastErr(), which the non-zero-flag path already raises on. The engine test accepts either that or the STOP-time check, so it passes against the bundled 3.84 library and a newer one alike. Six fake-engine tests pin the STOP-time check on its own, whatever library is bundled: an unflagged early end raises and quotes the engine's line from this call's part of the trace only; reaching STOP, a latency early stop and a pause pass; a STOP added at run time moves the time checked against. The check stays as the backstop for older engines and for early ends the engine still does not flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
execSim(case)returned normally when RAMSES stopped onDivergence. Simulation stopped. The reduced GB network in stepss-test-systems diverged at t = 0.35 s on RAMSES 3.81 to 3.84 and its notebook reported it as running for three months, because the trajectory just ended at 0.34 s.Cause (engine side)
The engine's return flag does not tell divergence apart from a finished run. In
stepss-ramses, both divergence branches (src/core/simul_integr.f90:1040andsrc/core/simul_decomp.f90:1727) only setend_simul=.true.and write the message to thelogunit.diagnostays 0, soramses()returns 0, the same as a run that reached STOP. The message never reacheslasterrormsglog, sogetLastErr()cannot report it either. Reproduced on the bundled 3.84 library:execSimreturned 0 withgetSimTime() == 0.001against a STOP at 3.0 s.Change (wrapper side)
execSim()andcontSim(): when the engine returns 0 (not 112), comparegetSimTime()with the STOP time of the case's.dstand raiseRAMSESErrorif the run fell short. The message quotes the engine's lastt = ...line from the part of the trace file this call wrote (the engine opens its log on that file in append mode):RAMSES: Function execSim() returned without an error flag, but the simulation stopped at t = 0.0010 s, before the STOP time 3.0000 s. The engine reported: t = 0.0010 Divergence. Simulation stoppedendSim()(ending early is what it does), and none for$LATENCYearly stopping, which the engine logs asAll equipment is latent.addDisturb(t, '... STOP')at an earlier time moves the STOP time checked against.stepss.cases._dstStopTime()reads the first STOP using the same rules as_dstProblem.Tests
tests/test_divergence.py, each engine run in its own subprocess:$NEWTON_TOLERdiverges at t = 0.001 s and now raises, namingDivergenceand the STOP time (failed before the fix)endSim()does not raise_dstStopTimeLocally (macOS arm64, Python 3.14): 256 passed, 1 failed. The failure is
test_ssa_archive.py::test_tar_round_trip_without_the_extraction_filter, aNameErrorinside Python 3.14'starfile. It fails the same way on unmodified master, so it is not caused by this change.Engine change
Done in SPS-L/stepss-ramses#26: divergence now returns -1 with the message in
getLastErr(), which the existing non-zero-flag path raises on. The second commit here makes the engine test accept either route and adds six fake-engine tests that pin the STOP-time check on its own. The check stays, for engines up to 3.84 and for early ends the engine still does not flag (a model stop inside the Newton evaluation under$SCHEME DEis still suspected to return 0, see SPS-L/stepss-ramses#26).Verified against both the bundled 3.84 library and a
ramses.sobuilt from SPS-L/stepss-ramses#26:tests/test_divergence.pypasses (13 tests) and the full suite gives 262 passed, 1 failed (the Python 3.14tarfileissue above).