Why
max_mhd_level defaults to 0 (check_max_mhd_level, pyphare/pharein/simulation.py:658-666), which makes sense for the Hybrid default case (model_options="HybridModel", no MHD levels at all). But nothing stops you from doing Simulation(model_options=["MHDModel"], ...) and leaving max_mhd_level untouched, and in that case things don't just behave oddly, they break silently.
In src/simulator/simulator.hpp:358:
multiphysInteg_->registerModel(0, maxMHDLevel_ - 1, mhdModel_);
With maxMHDLevel_ = 0 this is registerModel(0, -1, mhdModel_), an empty range, so no level gets the MHD model registered. The Hybrid-model registration branch right above it only runs when model_options includes "HybridModel", which it doesn't here. End result: a model_options=["MHDModel"] run with the default max_mhd_level ends up with literally no physics model attached to any level in the hierarchy.
What
Either:
- error out at
Simulation construction time if model_options=["MHDModel"] and max_mhd_level is left at 0, or
- default
max_mhd_level to max_nbr_levels when model_options is MHD-only, since that's what "every level is MHD" (the existing doc note for a pure MHD run) actually requires.
Ideas on how (optional)
In check_max_mhd_level (pyphare/pharein/simulation.py), make the default depend on model_options instead of being a flat 0:
def check_max_mhd_level(**kwargs):
default = kwargs["max_nbr_levels"] if kwargs["model_options"] == ["MHDModel"] else 0
max_mhd_level = kwargs.get("max_mhd_level", default)
...
(need to check ordering vs. check_model_options in checker, since model_options is currently validated after max_mhd_level)
Alternatives considered
No response
Additional context
Found while documenting max_mhd_level in the Simulation docstring.
Why
max_mhd_leveldefaults to 0 (check_max_mhd_level,pyphare/pharein/simulation.py:658-666), which makes sense for the Hybrid default case (model_options="HybridModel", no MHD levels at all). But nothing stops you from doingSimulation(model_options=["MHDModel"], ...)and leavingmax_mhd_leveluntouched, and in that case things don't just behave oddly, they break silently.In
src/simulator/simulator.hpp:358:With
maxMHDLevel_ = 0this isregisterModel(0, -1, mhdModel_), an empty range, so no level gets the MHD model registered. The Hybrid-model registration branch right above it only runs whenmodel_optionsincludes"HybridModel", which it doesn't here. End result: amodel_options=["MHDModel"]run with the defaultmax_mhd_levelends up with literally no physics model attached to any level in the hierarchy.What
Either:
Simulationconstruction time ifmodel_options=["MHDModel"]andmax_mhd_levelis left at 0, ormax_mhd_leveltomax_nbr_levelswhenmodel_optionsis MHD-only, since that's what "every level is MHD" (the existing doc note for a pure MHD run) actually requires.Ideas on how (optional)
In
check_max_mhd_level(pyphare/pharein/simulation.py), make the default depend onmodel_optionsinstead of being a flat 0:(need to check ordering vs.
check_model_optionsinchecker, sincemodel_optionsis currently validated aftermax_mhd_level)Alternatives considered
No response
Additional context
Found while documenting
max_mhd_levelin theSimulationdocstring.