rom-py / rompy

Relocatable Ocean Modelling in PYthon (rompy) combines templated cookie-cutter model configuration with various xarray extensions to assist in the setup and evaluation of coastal ocean model
https://rom-py.github.io/rompy/
BSD 3-Clause "New" or "Revised" License
2 stars 9 forks source link

Ensuring nhot_write values are aligned with ihfskip values when configuring Schism hotstart writes with a validator #73

Open benjaminleighton opened 4 months ago

benjaminleighton commented 4 months ago

Add a pydantic validator to enforce the following rules for hotstarts

if nhot=1 indicating that a hotstart file is to be written, this could occur at multiple times during the simulation but typically occurs at the end. When the hotstart file is written is determined by nhot_write. nhot_write must be a multiple of ihfskip, for example if ihfskip is set to the end of the simulation then nhot_write would be equal to it because it doesn't make sense for it to be longer. If multiple hotfiles need to be written then ihfskip would also need to be a fraction of the total timestep to allow this. notes:

ifhskip is the time when you'd like to write outputs, it must be a multiple of the time step aka dt and it is typically equal to the timestep * the number of timesteps in the simulation that is the final timestep of the simulation because normally only one output is written.

example

if the total length of a simulation is 31 days then the number of seconds is 2678400 and if dt (aka timestep) is 120 seconds then, if you want the simulation output and hotfile to be written at the simulation then the ihfskip and also the nhot_write value would be 22320 because 22320 timesteps of 120 seconds is 2678400 which is the end of the 31st day.

for ifhskip and nhot_write in the situation where you'd like an output and hotfile every n days then ihfskip and nhot_write can be calulated by *(86400write_every_n_days)/dt**