Repository navigation
Fix/tub counter and terrame parity - #18
Merged
Merged
Conversation
Tub kept its execution counter in ``self._step``, the attribute where dissmodel's Model stores the interval between ticks. Each increment widened the interval, so a run from t=1 to 30 executed only at ticks 1, 2, 4, 7, 11, 16, 22 and 29 (8 executions instead of 30), and the periodic inflow never matched the TerraME Tub example. The counter is now ``_tick``. A new test checks, for every exported model, that it executes exactly once per tick; it fails on the old Tub and passes on all models now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GTEeQcZQHHFJCk7Jdqe61
The examples used Environment() with env.run(N), or start_time=0, which runs N + 1 steps (t = 0..N, end_time is inclusive). A TerraME Timer with finalTime = N runs N steps at t = 1..N. The difference is one extra step in every model and, in RoomTemperature, a one-hour shift of the outside temperature curve (up to 2.3 degrees at the same step). Notebooks, CLI and Streamlit examples, the demo app and the docs now use Environment(start_time=1, end_time=N) and env.run(). docs/models.md explains the convention. All notebooks execute (no stored outputs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GTEeQcZQHHFJCk7Jdqe61
tests/test_terrame_parity.py transcribes, step by step, the update rule of each model in terrame/sysdyn (lua/<Model>.lua, commit 9e671cb) with the TerraME default parameters and finalTime, and compares the whole trajectory with the DisSModel model run from t=1 to finalTime (rtol = atol = 1e-9). Coffee, ChaoticGrowth, Homeostasis, LimitedGrowth, Lorenz, PopulationGrowth, PredatorPrey, RoomTemperature, SIR, Tub (default and with the periodic inflow) and Yeast match. Two models differ and are marked as strict xfail, with the cause, so that a fix shows up: - MonoLake: TerraME's sci.Spline is a Catmull-Rom curve sampled at 1000 points per segment and read by linear interpolation (transcribed in the test); the model uses scipy CubicSpline. Up to 26 KAF in 50 steps. - Daisyworld: TerraME recomputes the planet albedo for the black daisies after updating the white area. Up to 0.61 of area during the run, same equilibrium at t = 100. RandomWalk is not compared (different random generators). The SIR "maximum" event and the PredatorPrey "period" option are not ported; they are inactive with the default values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GTEeQcZQHHFJCk7Jdqe61
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.
No description provided.