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

Towards a generic MARGO model structure (with abstract submodel types) #44

Open
hdrake opened this issue Aug 25, 2020 · 1 comment
Open
Assignees
Labels
enhancement New feature or request priority

Comments

@hdrake
Copy link
Collaborator

hdrake commented Aug 25, 2020

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 #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.

generalized_MARGO

One huge advantage of abstract types is that some methods will apply to the abstract types while others will apply to specific model types.

@hdrake
Copy link
Collaborator Author

hdrake commented Aug 25, 2020

I've started implemented this in the WIP PR #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) = ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority
Projects
None yet
Development

No branches or pull requests

2 participants