SINDBAD Spinup
This documentation introduces SINDBAD spinup and provides a framework for adding new spinup methods while maintaining consistency with SINDBAD's architecture.
Spinup is carried out in every experiment to take the model state to an equilibrium. The equilibrium is dependent on data, model and parameters, and should therefore, a Spinup is always required.
Configuration
Spinup is configured in the experiment settings file through two main sections:
- Flags Section:
"flags": {
"spinup_TEM": true,
"store_spinup": false
}
spinup_TEM
: Activates the spinup processstore_spinup
: Controls whether to store spinup results from each sequence
- Model Spinup Section:
"model_spinup": {
"restart_file": null,
"sequence": [
{
"forcing": "all_years",
"n_repeat": 1,
"spinup_mode": "all_forward_models"
}
]
}
restart_file
: Path to a previous simulation's state (null for no restart)sequence
: Array of spinup steps executed sequentiallyforcing
: Forcing variant to usen_repeat
: Number of sequence repetitionsspinup_mode
: The spinup method to use
Available Spinup Methods
Spinup methods are stored in spinup functions within SindbadTEM. The different methods are dispatched on types generated.
using SindbadTEM
?SindbadTEM.spinup
To list all available spinup methods and their purposes, use:
using Sindbad
showMethodsOf(SpinupMode)
This will display a formatted list of all spinup methods and their descriptions.
Current methods include:
AllForwardModels
: Use all forward models for spinupEtaScaleA0H
: Scale carbon pools using diagnostic scalars for ηH and c_remainEtaScaleAH
: Scale carbon pools using diagnostic scalars for ηH and ηANlsolveFixedpointTrustregionCEco
: Use a fixed-point nonlinear solver with trust region for carbon pools (cEco)NlsolveFixedpointTrustregionCEcoTWS
: Use a fixed-point nonlinear solver with trust region for both cEco and TWSNlsolveFixedpointTrustregionTWS
: Use a fixed-point nonlinear solver with trust region for Total Water Storage (TWS)ODEAutoTsit5Rodas5
: Use the AutoVern7(Rodas5) method from DifferentialEquations.jl for solving ODEsODEDP5
: Use the DP5 method from DifferentialEquations.jl for solving ODEsODETsit5
: Use the Tsit5 method from DifferentialEquations.jl for solving ODEsSelSpinupModels
: Run only the models selected for spinup in the model structureSSPDynamicSSTsit5
: Use the SteadyState solver with DynamicSS and Tsit5 methodsSSPSSRootfind
: Use the SteadyState solver with SSRootfind method
Adding New Spinup Methods
SINDBAD uses a type-based dispatch system for spinup methods. To add a new spinup method, you need to:
Define a new type in
src/Types/SpinupTypes.jl
Implement the spinup function in
spinupTEM.jl
Update the spinup sequence handling if needed
1. Define the New Spinup Method Type
In src/Types/SpinupTypes.jl
, add a new struct and its purpose function:
import SindbadUtils: purpose
# Define the new spinup type
struct YourNewSpinupMode <: SpinupMode end
# Define its purpose
purpose(::Type{YourNewSpinupMode}) = "Description of what YourNewSpinupMode does"
When naming new spinup types that use external packages, follow the convention PackageNameMethodName
. For example:
ODEAutoTsit5Rodas5
for the AutoVern7(Rodas5) method from DifferentialEquations.jlNlsolveFixedpointTrustregionCEco
for the fixed-point solver from NLsolve.jlSSPDynamicSSTsit5
for the SteadyState solver with DynamicSS and Tsit5 methods
This convention helps identify both the package and the specific method being used.
The purpose function should:
Be concise but informative
Focus on what the spinup method does and which pools it affects
Include any special conditions or requirements
Use consistent formatting with other spinup methods
2. Implement the Spinup Function
In spinupTEM.jl
, implement the spinup function:
function spinup(spinup_models, spinup_forcing, loc_forcing_t, land, tem_info, n_timesteps, ::YourNewSpinupMode)
# Your implementation here
end
The function should:
Update the land state using provided models and forcing
Return the updated land state
Example implementation:
function spinup(spinup_models, spinup_forcing, loc_forcing_t, land, tem_info, n_timesteps, ::YourNewSpinupMode)
# Create custom spinup structure if needed
spinup_struct = YourSpinupStruct(spinup_models, spinup_forcing, tem_info, land, loc_forcing_t, n_timesteps)
# Implement spinup logic
# This could involve:
# - Running time loops
# - Using solvers
# - Applying scaling factors
# Update land state
land = updateLandState(land, spinup_results)
return land
end
3. Update Spinup Sequence Handling (if needed)
If your method requires special sequence handling:
function spinupSequence(spinup_models, sel_forcing, loc_forcing_t, land, tem_info, n_timesteps, log_index, n_repeat, ::YourNewSpinupMode)
land = spinupSequenceLoop(spinup_models, sel_forcing, loc_forcing_t, land, tem_info, n_timesteps, log_index, n_repeat, YourNewSpinupMode())
return land
end
Important Considerations
State Variables: Handle all relevant state variables (carbon pools, water storage, etc.)
Performance: Implement efficient memory management and consider parallelization
Convergence: Include appropriate convergence criteria and error handling
Documentation: Add comprehensive docstrings explaining:
Mode/Method purpose
Required parameters
Return values
Special considerations
Testing
After implementation:
Test with small experiments
Verify spinup results match expectations