Skip to content

Fix/tub counter and terrame parity - #18

Merged
profsergiocosta merged 3 commits into
mainfrom
fix/tub-counter-and-terrame-parity
Oct 21, 2026
Merged

profsergiocosta merged 3 commits into
mainfrom
fix/tub-counter-and-terrame-parity

Conversation

@profsergiocosta

Copy link
Copy Markdown
Member

No description provided.

profsergiocosta and others added 3 commits October 21, 2026 08:38
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
@profsergiocosta
profsergiocosta merged commit 5886751 into main Oct 21, 2026
2 checks passed
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.

1 participant