Skip to content

fix: separate scenario from Model object and improve update of soil properties - #68

Open
nielsvharten-tennet wants to merge 10 commits into
alliander-opensource:mainfrom
nielsvharten-tennet:feature/provide-scenario-for-run
Open

fix: separate scenario from Model object and improve update of soil properties#68
nielsvharten-tennet wants to merge 10 commits into
alliander-opensource:mainfrom
nielsvharten-tennet:feature/provide-scenario-for-run

Conversation

@nielsvharten-tennet

Copy link
Copy Markdown
Contributor

Separate scenario from model

Rationale: The model should represent only the static environment and optional persistent configuration. A scenario is execution-specific data and should therefore be supplied per run rather than stored as part of the model state. Keeping scenario as a model attribute complicates state management.

Breaking change: This PR changes the public API of abstract_model and model_factory.

  • scenario is now passed as a parameter to model.run() and is no longer stored as an attribute of Model.
  • model.set_scenario() has been removed.
  • scenario to be passed to model.run() may be unvalidated. Scenario validation is done as first step of model.run().
  • temperature_result is no longer stored as attribute of Model; it is now part of the simulation_run.
  • Documentation is updated to reflect these changes.

Improve updates of soil properties

  • cable._update_capacity_grid() now always updates capacity_grid and no longer checks whether the update is significant. No measurable runtime impact is expected because this operation is not part of finite_difference_matrix_diagonals.
  • cable._update_rho_grid() now accepts either a scalar value or a NumPy array of rho values, enabling more efficient updates from cable_soil._update_soil_resistivity().
  • cable_soil._update_soil_resistivity() now calls self._update_rho_grid() only once instead of twice. This significantly improves efficiency when soil_drying=True and avoids invalidating finite_difference_matrix_diagonals due to intermediate partial updates.
  • Removed model_soil._check_if_daily_update_due(). The method obscured update behavior and provided only limited runtime benefits. Runtime impact is expected only for scenarios where soil_rho fluctuates by more than 1% within a 24-hour period. Users who wish to avoid per-timestep soil_rho updates should preprocess or resample the input scenario accordingly.

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
… model

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
… and always update capacity_grid.

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
…compatibility

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
…rio-for-run

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
…lidated internally)

Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
Signed-off-by: Harten-Antuma, Niels van <niels.van.harten-antuma@tennet.eu>
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