New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset capability #243
Reset capability #243
Conversation
CarbonCycleModel is already an abstract class, so leaving the methods inherited from IModelComponent abstract does no harm and catches certain kinds of errors at compile time instead of run time.
Not yet implemented: ocean, temperature, simpleNbox.
When an attempt to retrieve a value fails because of a unit mismatch, report the expected and actual units.
The component operates as it always did, and then at the end of each time step it copies all of the values it's tracking into a time indexed array. This proved to be a lot easier to implement than changing all of the component's working variables into time indexed values. This change incidentally fixes a problem with the handling of the temperature fertilization effect in soil. This calculation is subject to a ratchet effect; the calculated value can never be less than the previous year's value. However, that previous value was being stored in a scalar variable. This scheme worked ok when there was only one global biome, but would likely have produced incorrect results when we tried to run with multiple biomes. The new scheme should be safe to use with multiple biomes.
Running Core::reset causes all components to reset.
If you run a scenario, then reset and rerun the spinup, then rerun the scenario from the new start state, you will get a discrepancy between the old and new run. This happens because the initial state produced by the spinup is slightly different from what the original spinup produced. The fractional discrepancy is approximately 1e-3*eps_spinup, where eps_spinup is the spinup tolerance. With the default eps_spinup of 0.001, these discrepancies are small enough to be ignorable for scientific purposes, but for things like Monte Carlo runs we may want to set eps_spinup to something like 1e-6, so as to ensure that for any given set of parameters results will agree to within the limits of single precision arithmetic.
Inexplicably, clang doesn't put the functions in cmath into the std namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks completely solid--nice job. See a few suggestions below.
source/components/bc_component.cpp
Outdated
// reset. | ||
oldDate = time; | ||
H_LOG(logger, Logger::NOTICE) | ||
<< getComponentName() << " resetting to time= " << time << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other messages say "reset to time" - let's be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done.
Add method
reset
to the public interface ofCore
. Calling this method causes the entire model to reset its state to a specified (previous) time. Additionally, resetting to a time prior to the start of the model causes the spinup to be rerun, allowing us to change model parameters and restart the scenario in a state consistent with the new parameters.Closes #240