-
Notifications
You must be signed in to change notification settings - Fork 47
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
Bug with no permafrost run #752
Comments
Temporary SolutionManually setting
This suggests that there is some problem with how the R interface is setting the initial permafrost value to 0 but not with the actual hector C++ code. |
Thanks @kdorheim!! |
After a little investigation, this is a more general problem and has nothing to do with permafrost per se. > hector_inifile <- file.path(system.file("input", package = "hector"), "hector_ssp245.ini")
> hcore <- newcore(hector_inifile, suppresslogging = TRUE)
> fetchvars(hcore, NA, VEG_C())
scenario year variable value units
1 Unnamed Hector core NA veg_c 562 Pg C
# change the veg C value
> setvar(hcore, NA, VEG_C(), 560, "Pg C")
> fetchvars(hcore, NA, VEG_C())
scenario year variable value units
1 Unnamed Hector core NA veg_c 560 Pg C
# this seems okay, but now try running
> run(hcore)
Auto-resetting core to 1744
Hector core: Unnamed Hector core
Start date: 1745
End date: 2300
Current date: 2300
Input file: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/hector/input/hector_ssp245.ini
> fetchvars(hcore, 1745:1746, VEG_C()) # value is unchanged
scenario year variable value units
1 Unnamed Hector core 1745 veg_c 562.0000 Pg C
2 Unnamed Hector core 1746 veg_c 561.9828 Pg C 😕 What's going on? In the C++ code we have a note: // For `veg_c`, `detritus_c`, `soil_c`, and `permafrost_c`,
// if date is not provided, set only the "current" model pool,
// without touching the time series variable. This is to
// accommodate the way the INI file is parsed. For
// interactive use, you will usually want to pass the date
// -- otherwise, the current value will be overridden by a
// `reset` (which includes code like `veg_c = veg_c_tv.get(t)`). |
Oh okay, we just need to pass a date? > hector_inifile <- file.path(system.file("input", package = "hector"), "hector_ssp245.ini")
> hcore <- newcore(hector_inifile, suppresslogging = TRUE)
> setvar(hcore, 1745, VEG_C(), 560, "Pg C")
> run(hcore)
Auto-resetting core to 1744
Hector core: Unnamed Hector core
Start date: 1745
End date: 2300
Current date: 2300
Input file: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/hector/input/hector_ssp245.ini
> fetchvars(hcore, 1745:1746, VEG_C())
scenario year variable value units
1 Unnamed Hector core 1745 veg_c 562.0000 Pg C
2 Unnamed Hector core 1746 veg_c 561.9828 Pg C 😞 That didn't work. It reset to 1744 (???) and so picked up the previous value. Resetting to zero doesn't work either, I tried. What does work is to 'hack' the core by manually changing the reset date. > hector_inifile <- file.path(system.file("input", package = "hector"), "hector_ssp245.ini")
> hcore <- newcore(hector_inifile, suppresslogging = TRUE)
> setvar(hcore, 1745, VEG_C(), 560, "Pg C")
> hcore$reset_date <- 1745
> run(hcore)
Auto-resetting core to 1745
Hector core: Unnamed Hector core
Start date: 1745
End date: 2300
Current date: 2300
Input file: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/hector/input/hector_ssp245.ini
> fetchvars(hcore, 1745:1746, VEG_C())
scenario year variable value units
1 Unnamed Hector core 1745 veg_c 560.0000 Pg C
2 Unnamed Hector core 1746 veg_c 560.0529 Pg C 🎉 and @cahartin this trick works for your permafrost example above |
This is terrible behavior, right? No one would ever figure it out! At the very least, I think we need to improve documentation and print a warning if users request to change a carbon pool variable. Thoughts? |
Yes that is terrible behavior! Why doesn't that happen with the NPP0? |
Because |
hmm, would it make sense for veg_c and others at time 0 to also be considered a static parameter? |
That won't work, I don't think, because the carbon cycle has to be spun up to steady state before we begin history. |
Could this at all be related to issue #735? |
Not the reset behavior, but the funky indexing of the time series, yeah, related. Thanks for linking. |
Describe the bug
This was brought to our attention by @cahartin she was having issues with turning the permafrost module off.
To Reproduce
Expected behavior
Setting the permafrost carbon pool to 0 should mean that the size of the permafrost pool is set at 0 at the beginning on the run and is constant throughout the run.
Actual behavior
Additional context
Hector version 3.2.0
git 1ef0b4df8563a31580ffa94eb11b113e3f317b86
The text was updated successfully, but these errors were encountered: