Skip to content
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

Merged
merged 17 commits into from Aug 30, 2018
Merged

Reset capability #243

merged 17 commits into from Aug 30, 2018

Conversation

rplzzz
Copy link
Contributor

@rplzzz rplzzz commented Aug 14, 2018

Add method reset to the public interface of Core. 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

rplzzz added 14 commits June 20, 2018 10:55
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.
@rplzzz rplzzz requested a review from cahartin August 14, 2018 12:55
@bpbond bpbond self-requested a review August 14, 2018 13:00
Inexplicably, clang doesn't put the functions in cmath into the std
namespace.
@rplzzz rplzzz mentioned this pull request Aug 14, 2018
7 tasks
Copy link
Member

@bpbond bpbond left a 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.

headers/data/tvector.hpp Show resolved Hide resolved
headers/data/tvector.hpp Show resolved Hide resolved
// reset.
oldDate = time;
H_LOG(logger, Logger::NOTICE)
<< getComponentName() << " resetting to time= " << time << "\n";
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done.

@rplzzz rplzzz merged commit 5d1deab into master Aug 30, 2018
@rplzzz rplzzz deleted the reset-capability branch September 5, 2018 17:31
@rplzzz rplzzz mentioned this pull request Sep 21, 2018
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.

None yet

2 participants