Open hdrake opened 3 years ago
I've started implemented this in the WIP PR https://github.com/hdrake/ClimateMARGO.jl/pull/45
For example, there is now an abstract type EBMparams
which includes lists of parameters for several difference simple energy balance models.
abstract type EBMParams end
mutable struct DeepLayerEBM <: EBMParams
λ::Real # feedback parameter
Cd::Real # deep ocean heat capacity
κ::Real # deep ocean heat uptake rate
end
mutable struct TwoLayerEBM <: EBMParams
λ::Real # feedback parameter
κ::Real # deep ocean heat uptake rate
Cu::Real # upper ocean heat capacity
Cd::Real # deep ocean heat capacity
ϵ::Real # heat uptake efficacy
end
TwoLayerEBM(λ, κ, Cu, Cd) = TwoLayerEBM(λ, κ, Cu, Cd, 1.)
UpperLayerEBM(λ, Cu) = TwoLayerEBM(λ, 0., Cu, Cu)
In addition to these three types having different numbers of parameters (with different values), they are have different physics and thus different solutions. Thus, they will require different methods of the diagnostic functions:
T(ebm::UpperLayerEBM) = ...
T(ebm::DeepLayerEBM) = ...
T(ebm::TwoLayerEBM) = ...
I've been working on implementing a more accurate version of MARGO's 1.5-layer (or "Deep-layer") Energy Balance Model. The improved solution is an exact analytical solution to the two-layer problem (see https://github.com/hdrake/ClimateMARGO.jl/issues/43).
I quickly ran into a problem that the MARGO code, as it is currently written, is not nearly as flexible as we would like it to be. In particular, we do not have the appropriate abstractions for allowing submodules to be swapped out for others on the fly.
I imagine that in addition to the bare-bones MARGO configuration, other configurations could be easily created by picking and choosing the complexity of various components. If we define the abstract types in this way, it would also be easier for others in the community to make their own changes and possibly contribute them to the master branch.
One huge advantage of abstract types is that some methods will apply to the abstract types while others will apply to specific model types.