コード例 #1
0
 def test_creation_from_matrix(self):
     A = ImmutableMatrix(1, 1, [1])
     B = ImmutableMatrix(1, 1, [1])
     D = A*B
     C = CompartmentalMatrix(D)
     print(C, type(C))
     self.assertEqual(type(C), CompartmentalMatrix)
コード例 #2
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
    'r':
    '"fraction of decomposer biomass released as CO$_2$"'  # "\\text{time}^{-1}"
    ,
    's':
    '"decomposers production rate of soil organic matter"'  # "\\text{time}^{-1}"
    ,
    'Phi_l':
    'fresh organic matter carbon flux'  # "(\\text{quantity of carbon})(\\text{time}))^{-1}"
}

for name in sym_dict.keys():
    var(name)
t = TimeSymbol("t")  # unit: ""
x = StateVariableTuple((C_s, C_ds))
u = InputTuple((0, Phi_l))
B = CompartmentalMatrix([[0, s - A], [0, A - r - s]])

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="FB2005 - The model of SOM dynamics (model 2)",
            longName="The C-N model of SOM dynamics, two decomposer types",
            version="1",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="22/03/2016",
            doi="10.1111/j.1461-0248.2005.00813.x",
            sym_dict=sym_dict),
        B,  # the overall compartmental matrix
        u,  # the overall input
        t,  # time for the complete system
コード例 #3
0
for name in sym_dict.keys():
    var(name)

x_nup = Min(1,(N_min/(F_nupmin*Delta_t)))
x_pup = Min(1,(P_lab/(F_pupmin*Delta_t)))
x_npup = Min(x_nup,x_pup)
x_nleaf = (n_leaf/(n_leaf+k_n))
x_pleaf = (p_leaf/(p_leaf+k_p))
x_npleaf = Min(x_nleaf,x_pleaf)
F_c = x_npleaf*x_npup*F_cmax #unit: "gC*m^{-2}*d^{-1}" 
u = F_c
x = StateVariableTuple((C_leaf, C_root, C_wood))
b = (a_leaf, a_root, a_wood)
Input = InputTuple(u * ImmutableMatrix(b))
A = CompartmentalMatrix(
    diag(-mu_leaf, -mu_root, -mu_wood)
)
t = TimeSymbol("t") #'day'
#        timeResolution = daily # or yearly? incongruent turnover units

# Commented out the following lines because original publication only has 3 parameter values
# In original publication: 
## See table 1 for parameter values; a_(leaf,wood,root) and 1/mu_(leaf,wood,root) are based on CASA
## 1/mu_(leaf,wood,root) = Mean residence time of plant tissue
## 1/n_max,leaf  and  1/p_max,leaf : maximal leaf N:C and P:C ratios = 1.2*mean (min is obtained by 0.8*mean)  
#    # mean estimates were obtained from Glopnet datasets for each biome (Wright et al., 2004)
#np1 = NumericParameterization(
#    par_dict={#"Evergreen needle leaf forest":
#    Delta_t: 1, 
#    k_n: 0.01, #"gN*(gC)^{-1}"
#    k_p: 0.0006, #"gP*(gC)^{-1}"
コード例 #4
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
    ,
    'i': 'mean annual carbon input'  # "kgC m^{-2}yr^{-1}"
    ,
    'h': 'humification coefficient',
    'r': 'climatic and edaphic factors'
}

for name in sym_dict.keys():
    var(name)
xi = r  #environmental effects multiplier
T = ImmutableMatrix([[-1, 0], [h, -1]])  #transition operator
N = diag(k_1, k_2)  #decomposition operator
t = TimeSymbol("t")  # unit: "year"
x = StateVariableTuple((Y, O))
u = InputTuple((i, 0))
B = CompartmentalMatrix(xi * T * N)
#        - "Bare fallow":
np1 = NumericParameterization(par_dict={
    k_1: 0.8,
    k_2: 0.00605,
    i: 0,
    h: 0.13,
    r: 1.32
},
                              func_dict=frozendict({}))
nsv1 = NumericStartValueDict({Y: 0.3, O: 3.96})

#        - "+N +straw":
np2 = NumericParameterization(par_dict={
    k_1: 0.8,
    k_2: 0.00605,
コード例 #5
0
    var(name)

epsilon_L = 1 - epsilon_R - epsilon_S
a_S = (epsilon_S + (Omega * (1.5 - L -
                             (0.5 * N_ava)))) / (1 + (Omega *
                                                      (3 - L - W - N_ava)))
a_R = (epsilon_R + (Omega * (1.5 - W -
                             (0.5 * N_ava)))) / (1 + (Omega *
                                                      (3 - L - W - N_ava)))
a_L = epsilon_L / (1 + (Omega * (3 - L - W - N_ava)))  #, "a_L = 1-a_S-a_R"

x = StateVariableTuple((C_S, C_R, C_L))
u = NPP
b = (a_S, a_R, a_L)
Input = InputTuple(u * ImmutableMatrix(b))
A = CompartmentalMatrix([[-gamma_S, 0, 0], [0, -gamma_R, 0], [0, 0, -gamma_L]])
t = TimeSymbol("t")

mvs = MVarSet({
    BibInfo(  # Bibliographical Information
        name="CEVSA2  ",
        longName="",
        version="2",
        entryAuthor="Verónika Ceballos-Núñez",
        entryAuthorOrcid="0000-0002-0046-1160",
        entryCreationDate="",
        doi="10.1016/j.ecocom.2010.04.002",
        sym_dict=sym_dict),
    A,  # the overall compartmental matrix
    Input,  # the overall input
    t,  # time for the complete system
コード例 #6
0
P = f_C * sigma_r * W_r / (f_N * sigma_c * A)
Q = f_N / (Beta * f_C)
lambda_p = P / (1 + P + Q)
lambda_s = Q / (1 + P + Q)
lambda_r = 1 / (1 + P + Q)

x = StateVariableTuple((W_N, W_C, W_p, W_s, W_r))
u = (sigma_c * A, sigma_r * W_r, 0, 0, 0)
b = 1
Input = InputTuple(b * ImmutableMatrix(u))
A = CompartmentalMatrix(
    [[
        -((f_cp * lambda_p * W_p) + (f_cs * lambda_s * W_s) +
          (f_cr * lambda_r * W_r)) * ((kappa * W_N) / W_g**2), 0, 0, 0, 0
    ],
     [
         0, -((f_np * lambda_p * W_p) + (f_ns * lambda_s * W_s) +
              (f_nr * lambda_r * W_r)) * ((kappa * W_C) / W_g**2), 0, 0, 0
     ], [0, (kappa * N * lambda_p * W_p) / W_g, 0, 0, 0],
     [0, (kappa * N * lambda_s * W_s) / W_g, 0, 0, 0],
     [0, (kappa * N * lambda_r * W_r) / W_g, 0, 0, 0]])
t = TimeSymbol("t")  # unit: "day"

np1 = NumericParameterization(par_dict={
    sigma_r: 0.01,
    I_dens: 1000,
    f_C: 0.5,
    Beta: 0.05,
    f_cp: 0.60,
    f_cr: 0.45,
    f_cs: 0.45,
コード例 #7
0
        'l_dr': 'Litter decomposition/respiration',
        's_dr': 'Soil decomposition/respiration',
        'u': 'scalar function of photosynthetic inputs'
}
for name in sym_dict.keys():
    var(name)

#Model based on Fig. 1 in page 127 (3 in the PDF) of doi= "10.1016/0304-3800(88)90112-3", no ODEs in publication
t = TimeSymbol("t") #"the model has a daily and a yearly component. Allocation occurs yearly"
x = StateVariableTuple((C_f, C_r, C_w,C_frl,C_s))
b = ImmutableMatrix((eta_f, eta_w, eta_r))
Input = InputTuple(tuple(u * b)+(0,0))
A = CompartmentalMatrix(
[[-gamma_f,    0   ,    0   ,   (l_p*eta_f)  ,(s_p*eta_f)],
 [    0   ,-gamma_r,    0   ,   (l_p*eta_r)  ,(s_p*eta_r)],
 [    0   ,    0   ,-gamma_w,   (l_p*eta_w)  ,(s_p*eta_w)],
 [ gamma_f, gamma_r, gamma_w, -(l_p+l_s+l_dr),      0    ],
 [    0   ,    0   ,    0   ,       l_s      ,-(s_p+s_dr)]
])

## The following are default values suggested by this entry's creator only to be able to run the model:
np1 = NumericParameterization(
    par_dict={u: 1400, eta_f: 0.48, eta_r: 0.44, eta_w: 0.49, gamma_r: 3.03, gamma_f: 23.32, gamma_w: 0.04},
    func_dict=frozendict({})
)

nsv1 = NumericStartValueDict({
    C_f: 200, 
    C_w: 5000, 
    C_r: 300
})
コード例 #8
0
g_l * A / ((C_i - Gamma) * (1 + (D / D_0)))
A_n = G_s * (C_a - C_i)
A_c = A_n * (1 - exp(-k * L)) / k
GPP = A_c * 3600 * 12 / 1000000  # Scaling expression from TECO fortran code, line 667.' # gC*day^{-1}
f_W = Min((0.5 * W), 1)
f_T = Q_10 * ((T - 10) / 10)
xi = f_W * f_T
t = TimeSymbol("t")  # unit: "day"
x = StateVariableTuple((x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8))
u = GPP
b = ImmutableMatrix((b_1, b_2, b_3))
Input = InputTuple(tuple(u * b) + (0, 0, 0, 0, 0))
B = CompartmentalMatrix([[-c_1, 0, 0, 0, 0, 0, 0, 0],
                         [0, -c_2, 0, 0, 0, 0, 0, 0],
                         [0, 0, -c_3, 0, 0, 0, 0, 0],
                         [f_41, 0, f_43, -c_4, 0, 0, 0, 0],
                         [f_51, f_52, f_53, 0, -c_5, 0, 0, 0],
                         [0, 0, 0, f_64, f_65, -c_6, f_67, f_68],
                         [0, 0, 0, 0, f_75, f_76, -c_7, 0],
                         [0, 0, 0, 0, 0, f_86, f_87, -c_8]])
np1 = NumericParameterization(par_dict={
    GPP: 3.370,
    b_1: 0.14,
    b_2: 0.26,
    b_3: 0.14,
    f_41: 0.9,
    f_51: 0.1,
    f_52: 1,
    f_43: 0.2,
    f_53: 0.8,
    f_64: 0.45,
    f_65: 0.275,
コード例 #9
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
x = StateVariableTuple((P, M, Q, B, D, EP, EM))
u = InputTuple((I_P, 0, 0, 0, I_D, 0, 0))
T = ImmutableMatrix(
    [[-1, 0, 0, (1 - g_D) * (1 - p_EP - p_EM) * F_E / (F_E + F_R), 0, 0, 0],
     [1 - f_D, -1, 0, 0, 0, 0, 0], [0, 0, -1, 0, F_A / (F_U + F_A), 0, 0],
     [0, 0, 0, -1, F_U / (F_U + F_A), 0, 0],
     [f_D, 1, 1, g_D * (1 - p_EP - p_EM) * F_E / (F_E + F_R), -1, 1, 1],
     [0, 0, 0, p_EP * F_E / (F_E + F_R), 0, -1, 0],
     [0, 0, 0, p_EM * F_E / (F_E + F_R), 0, 0, -1]])
N = ImmutableMatrix([[V_P * EP / (K_P + P), 0, 0, 0, 0, 0, 0],
                     [0, V_M * EM / (K_M + M), 0, 0, 0, 0, 0],
                     [0, 0, K_des / Q_max, 0, 0, 0, 0],
                     [0, 0, 0, F_E + F_R, 0, 0, 0],
                     [0, 0, 0, 0, F_U + F_A, 0, 0], [0, 0, 0, 0, 0, r_EP, 0],
                     [0, 0, 0, 0, 0, 0, r_EM]])
B = CompartmentalMatrix(T * N)

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="MEND",
            longName="Microbial-Enzyme-Mediated Decomposition model",
            version="1",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="21/03/2016",
            doi="10.1890/12-0681.1",
            further_references=BibInfo(
                doi="10.2307/1313568"),  #Li2014Biogeochemistry
            sym_dict=sym_dict),
        B,  # the overall compartmental matrix
コード例 #10
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
f_W = Min((0.5 * W), 1)
f_T = Q_10**((T - 10) / 10)
xi = f_W * f_T
x = StateVariableTuple((x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8))
B = (b_1, b_2, b_3, 0, 0, 0, 0, 0)
Input = InputTuple(U * ImmutableMatrix(B))
A = ImmutableMatrix([[-1, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0],
                     [0, 0, -1, 0, 0, 0, 0, 0],
                     [f_41, 0, f_43, -1, 0, 0, 0, 0],
                     [f_51, f_52, f_53, 0, -1, 0, 0, 0],
                     [0, 0, 0, f_64, f_65, -1, f_67, f_68],
                     [0, 0, 0, 0, f_75, f_76, -1, 0],
                     [0, 0, 0, 0, 0, f_86, f_87, -1]])
C = ImmutableMatrix(diag(c_1, c_2, c_3, c_4, c_5, c_6, c_7, c_8))
CM = CompartmentalMatrix(xi * A * C)
t = TimeSymbol("t")

# "Original parameters of the publication. Parameter value of GPP corresponds to an annual average"
# T, Q_10, and W are variables that should be looked at in a data set. What I have here are invented values
np1 = NumericParameterization(
    par_dict={
        Q_10: 1,
        W: 4.2,
        T: 25,
        U: 3370  #"gC*day^{-1}" # Average estimated value
        ,
        b_1: 0.14,
        b_2: 0.14,
        b_3: 0.26,
        c_1: 0.00258,
コード例 #11
0
                    allocated to wood""",
    'tau_f': 'Inverse Residence time of carbon in foliage',
    'tau_r': 'Inverse Residence time of carbon in roots',
    'tau_w': 'Inverse Residence time of carbon in wood'
}
for name in sym_dict.keys():
    var(name)

IPAR = SOL * FPAR * 0.5
NPP = IPAR * epsilon
x = StateVariableTuple((C_f, C_r, C_w))
u = NPP
b = (alpha_f, alpha_r, alpha_w)

Input = InputTuple(u * ImmutableMatrix(b))
A = CompartmentalMatrix(diag(-tau_f, -tau_r, -tau_w))
t = TimeSymbol("t")

# model_run_data is incomplete :
# Even parameter_sets cannot fully parameterize the symbolic model: mm made up
# a purely fictional parameters to show how a purely numeric could be build.
# (The yaml file lacks consistent unit information).
np1 = NumericParameterization(
    par_dict={
        alpha_f: Rational(1, 3),
        alpha_r: Rational(1, 3),
        alpha_w: Rational(1, 3),
        tau_f: 1.5,
        tau_r: 3,
        tau_w: 50,
        SOL: 1,  # completely faked by mm
コード例 #12
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
x_pup = Min(1,(P_lab/(F_pupmin*Delta_t)))
x_npup = Min(x_nup,x_pup)
x_nleaf = (n_leaf/(n_leaf+k_n))
x_pleaf = (p_leaf/(p_leaf+k_p))
x_npleaf = Min(x_nleaf,x_pleaf)
F_c = x_npleaf*x_npup*F_cmax #unit: "gC*m^{-2}*d^{-1}" 
u = F_c
x = StateVariableTuple((C_leaf, C_root, C_wood, C_j1, C_j2, C_j3, C_k1, C_k2, C_k3))
b = ImmutableMatrix((a_leaf, a_root, a_wood))
Input = InputTuple(tuple(u*b)+(0,0,0,0,0,0))
A = CompartmentalMatrix([
 [-mu_leaf*(b1l+b2l),         0        ,      0     ,          0         ,          0         ,           0        ,        0       ,        0       ,        0       ]
,[         0        ,-mu_root*(b1r+b2r),      0     ,          0         ,          0         ,           0        ,        0       ,        0       ,        0       ]
,[         0        ,         0        ,-mu_wood*b3w,          0         ,          0         ,           0        ,        0       ,        0       ,        0       ]
,[    mu_leaf*b1l   ,    mu_root*b1r   ,      0     ,-mu_j1*m_n*(c11+c21),          0         ,           0        ,        0       ,        0       ,        0       ]
,[    mu_leaf*b2l   ,    mu_root*b2r   ,      0     ,          0         ,-mu_j2*m_n*(c12+c22),           0        ,        0       ,        0       ,        0       ]
,[         0        ,         0        , mu_wood*b3w,          0         ,          0         ,-mu_j3*m_n*(c23+c33),        0       ,        0       ,        0       ]
,[         0        ,         0        ,      0     ,    mu_j1*m_n*c11   ,    mu_j2*m_n*c12   ,           0        ,-mu_k1*(d21+d31),    mu_k2*d12   ,    mu_k3*d13   ]
,[         0        ,         0        ,      0     ,    mu_j1*m_n*c21   ,    mu_j2*m_n*c22   ,    mu_j3*m_n*c23   ,    mu_k1*d21   ,-mu_k2*(d12+d32),    mu_k3*d23   ]
,[         0        ,         0        ,      0     ,          0         ,          0         ,    mu_j3*m_n*c33   ,    mu_k1*d31   ,    mu_k2*d32   ,-mu_k3*(d13+d23)]
])
### When not explicit in equations B1, B2, B3 (Appendix B), followed the fluxes from Fig 1. However, the soil fluxes are not clear.
t = TimeSymbol("t") #'day' # or 'year'? incongruent turnover units

# Commented out the following lines because original publication only has 3 parameter values
# In original publication: 
## See table 1 for parameter values; a_(leaf,wood,root) and 1/mu_(leaf,wood,root) are based on CASA
## 1/mu_(leaf,wood,root) = Mean residence time of plant tissue
## 1/n_max,leaf  and  1/p_max,leaf : maximal leaf N:C and P:C ratios = 1.2*mean (min is obtained by 0.8*mean)  
#    # mean estimates were obtained from Glopnet datasets for each biome (Wright et al., 2004)
#np1 = NumericParameterization(
コード例 #13
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
        ,'k': '"rate of fresh organic matter decomposition under substrate limitation ($N$ excess)"' # "\\text{time}^{-1}"
        ,'alpha': '"$N:C$ ratio in soil organic matter and in decomposers"'
        ,'beta': '"$N:C$ ratio in fresh organic matter"'
        ,'Phi_l': 'fresh organic matter carbon flux' # "(\\text{quantity of carbon})(\\text{time}))^{-1}"
        ,'Phi_i': 'nitrogen that flows into the ecosystem' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
        ,'Phi_o': 'nitrogen that flows out of the ecosystem' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
        ,'Phi_up': 'nitrogen flux associated with the nitrogen uptake by the plant cover' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
}

for name in sym_dict.keys():
    var(name)
t = TimeSymbol("t") # unit: ""
x = StateVariableTuple((C_s, C_f, C_ds, N))
u = InputTuple((0, Phi_l, 0, Phi_i-Phi_o-Phi_up))
B = CompartmentalMatrix([[0,              0,     s-A, 0],
                         [0,             -k,       0, 0],
                         [0,              k,   A-s-r, 0],
                         [0, k*(beta-alpha), alpha*r, 0]])

mvs = CMTVS(
    {
        BibInfo(# Bibliographical Information
            name="FB2005 - The C-N model of SOM dynamics with a single type of decomposer (model 3)",
            longName="The C-N model of SOM dynamics, two decomposer types", 
            version="1 - C limitation",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="22/03/2016",
            doi="10.1111/j.1461-0248.2005.00813.x",
            sym_dict=sym_dict
        ),
        B,  # the overall compartmental matrix
コード例 #14
0
    ,
    'alpha': 'annual decomposition rate of labile pool'  # "yr^{-1}"
    ,
    'beta': 'annual decomposition rate of stable pool'  # "yr^{-1}"
    ,
    'm': 'annual organic matter input'  # "MgC yr^{-1}"
    ,
    'K': 'isohumic coefficient'
}

for name in sym_dict.keys():
    var(name)
t = TimeSymbol("t")  # unit: "year"
C = StateVariableTuple((A, B))
I = InputTuple((m, 0))
A_GeM = CompartmentalMatrix([[-alpha, 0], [alpha * K, -beta]])

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="",
            longName="Henin and Dupois",
            version="1",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="09/03/2016",
            doi="",
            #        bibtex="@inproceedings{Henin1945Annalesagronomiques,
            #                     author = {H\\'{e}nin, S and Dupuis, M},
            #                     booktitle = {Annales agronomiques},
            #                     pages = {17--29},
コード例 #15
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
alpha_53 = 0.45 * (1 - A_l)
alpha_61 = 0.7 * A_l
alpha_63 = alpha_61
alpha_65 = 1 - E_s - 0.004
t = TimeSymbol("t")  # unit: "year" #??? monthly
x = StateVariableTuple((C_1, C_2, C_3, C_4, C_5, C_6, C_7))
u = InputTuple((J_1 * F_s, J_1 * F_m, J_2 * F_s, J_2 * F_m, 0, 0, 0))
xi = f_T * f_W  #environmental effects multiplier (DEFAG)
A = ([-k_1, 0, 0, 0, 0, 0,
      0], [0, -K_2, 0, 0, 0, 0,
           0], [0, 0, -k_3, 0, 0, 0, 0], [0, 0, 0, -K_4, 0, 0, 0], [
               alpha_51 * k_1, 0.45 * K_2, alpha_53 * k_3, 0.45 * K_4, -k_5,
               0.42 * K_6, 0.45 * K_7
           ], [alpha_61 * k_1, 0, alpha_63 * k_3, 0, alpha_65 * k_5, -K_6,
               0], [0, 0, 0, 0, 0.004 * k_5, 0.03 * K_6, -K_7])
B = CompartmentalMatrix(xi * ImmutableMatrix(A))
#Original values without effects of temperature and soil moisture:
np1 = NumericParameterization(par_dict={
    K_1: 0.076,
    K_2: 0.28,
    K_3: 0.094,
    K_4: 0.35,
    K_5: 0.14,
    K_6: 0.0038,
    K_7: 0.00013,
    xi: 1
},
                              func_dict=frozendict({}))
nsv1 = NumericStartValueDict({
    C_1: 100,
    C_2: 200,
コード例 #16
0
 def test_immutability(self):
     A = CompartmentalMatrix(2, 2, [1, 0, 1, 0])
     with self.assertRaises(TypeError):
         A[1, 1] = 1
コード例 #17
0
A_g = Min(J_e, J_c, J_s)
# A_g = Min(J_i,J_e,J_c) #C4
fT_stem = exp(E_0 * ((1 / (15 - T_0)) - (1 / (T_stem - T_0))))
R_leaf = gamma * V_m
fT_soil = exp(E_0 * ((1 / (15 - T_0)) - (1 / (T_soil - T_0))))
R_stem = Beta_stem * lambda_sapwood * C_is * fT_stem
R_root = Beta_root * C_ir * fT_soil
A_n = A_g - R_leaf
GPP_i = integrate(A_g, t)
NPP_i = ((1 - eta) * (integrate(A_g - R_leaf - R_stem - R_root, t)))

x = StateVariableTuple((C_il, C_is, C_ir))
u = NPP_i
b = (a_il, a_is, a_ir)
Input = InputTuple(u * ImmutableMatrix(b))
A = CompartmentalMatrix(diag(-1 / tau_il, -1 / tau_is, -1 / tau_ir))
t = TimeSymbol("t")

#model_run_data:
#    parameter_sets:
#        - "Tropical evergreen trees":
#            values: {a_il: 0.25,a_is: 0.5,a_ir: 0.25}

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="IBIS",
            longName="Integrated Biosphere Simulator",
            version="1",
            entryAuthor="Verónika Ceballos-Núñez",
            entryAuthorOrcid="0000-0002-0046-1160",
コード例 #18
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
R = 0.008314  # "kJ mol^{-1} K^{-1}"
V_U = V_Umax * exp(-E_aU / (R * (T + 273)))  #
V = V_max * exp(-E_a / (R * (T + 273)))  #
E_C = epsilon_0 + epsilon_s * T  #
K_U = K_U0 + K_Us * T  # "mg C cm^{-3}"
K = K_0 + K_s * T  # "mg C cm^{-3}"
t = TimeSymbol("t")  # unit: "hour"
x = StateVariableTuple((S, D, B, E))
u = InputTuple((I_S, I_D, 0, 0))
T_M = ImmutableMatrix([[-1, 0, a_BS * r_B / (r_B + r_E), 0],
                       [1, -1, (1 - a_BS) * r_B / (r_B + r_E), 1],
                       [1, E_C, -1, 0], [0, 0, r_E / (r_B + r_E), -1]])
N = ImmutableMatrix([[V * E / (K + S), 0, 0, 0],
                     [0, V_U * B / (K_U + D), 0, 0], [0, 0, r_B + r_E, 0],
                     [0, 0, 0, r_L]])
B = CompartmentalMatrix((T_M * N))
#np1 = NumericParameterization(
#    par_dict={
#},
#    func_dict=frozendict({})
#)
#
#nsv1 = NumericStartValueDict({
#})
#ntimes = NumericSimulationTimes(np.arange())
# still don't know how to bring parameter sets here
# different model descriptions in Li and in original paper
# different units

# we would need to be able to split the yaml file into two versions of the model
コード例 #19
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
NPP = GPP - (R_c + R_m)
a_w = 1 - a_f - a_r
x = StateVariableTuple(
    (C_f, C_r, C_w, C_wl, C_u, C_m, C_v, C_n, C_a, C_s, C_p))
u = NPP
b = ImmutableMatrix((a_f, a_r, a_w))
Input = InputTuple(tuple(u * b) + (0, 0, 0, 0, 0, 0, 0, 0))
A = CompartmentalMatrix([[-s_f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [0, -s_r, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [0, 0, -s_w, 0, 0, 0, 0, 0, 0, 0, 0],
                         [0, 0, s_w, -d_wl, 0, 0, 0, 0, 0, 0, 0],
                         [buf * s_f, 0, 0, 0, -d_u, 0, 0, 0, 0, 0, 0],
                         [bmf * s_f, bmr * s_r, 0, 0, 0, -d_m, 0, 0, 0, 0, 0],
                         [0, bvr * s_r, 0, 0, 0, 0, -d_v, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0, 0, -d_n, 0, 0, 0],
                         [
                             0, 0, 0, baw * d_wl, bau * d_u, bam * d_m,
                             bav * d_v, ban * d_n, -d_a, bas * d_s, bap * d_p
                         ],
                         [
                             0, 0, 0, bsw * d_wl, bsu * d_u, 0, bsv * d_v, 0,
                             bsa * d_a, -d_s, 0
                         ],
                         [0, 0, 0, 0, 0, 0, 0, 0, bpa * d_a, bps * d_s, -d_p]])
t = TimeSymbol("t")

np1 = NumericParameterization(
    par_dict={
        a_f: 0.16
        #    ,buf:
        #    ,bvr:
コード例 #20
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
K = ImmutableMatrix.diag([
    k_leaf, k_root, k_wood, k_metlit, k_stlit, k_CWD, k_mic, k_slowsom,
    k_passsom
])
A = ImmutableMatrix(
    [[-1, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, -1, 0, 0, 0, 0,
      0, 0], [f_leaf2metlit, f_root2metlit, 0, -1, 0, 0, 0, 0, 0],
     [f_leaf2stlit, f_root2stlit, 0, 0, -1, 0, 0, 0, 0],
     [0, 0, f_wood2CWD, 0, 0, -1, 0, 0,
      0], [0, 0, 0, f_metlit2mic, f_stlit2mic, 0, -1, 0, 0],
     [0, 0, 0, 0, f_stlit2slowsom, f_CWD2slowsom, f_mic2slowsom, -1, 0],
     [0, 0, 0, 0, 0, f_CWD2passsom, f_mic2passsom, f_slowsom2passsom,
      -1]])  # tranfer

B = CompartmentalMatrix(A * K)
t = TimeSymbol("t")  # unit: "day"
u = NPP(t)
b = ImmutableMatrix([beta_leaf, beta_root, beta_wood, 0, 0, 0, 0, 0, 0])
Input = InputTuple(u * b)

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="CABLE_yuanyuan",
            longName="Terrestrial Ecosystem Model",
            version="",
            entryAuthor="Markus Müller",
            entryAuthorOrcid="0000-0003-0009-4169",
            entryCreationDate="08/24/2021",
            doi="",
コード例 #21
0
ファイル: source.py プロジェクト: chrislxj/bgc_md2
# matrix of cycling rates
A = CompartmentalMatrix(
    [
        [
            (
                (-1)
                * (
                    ((1 - p_14) * p_5 * (1 - p_16) * multtf * T_rate)
                    + ((1 - p_14) * p_5 * p_16 * multtf * T_rate)
                    + (p_5 * p_14 * multtf)
                )
            ),
            (p_15 * (1 - p_16) * multtl * T_rate),
            0,
            0,
        ],
        [
            ((1 - p_14) * p_5 * (1 - p_16) * multtf * T_rate),
            (
                (-p_15 * (1 - p_16) * multtl * T_rate)
                - (p_15 * p_16 * multtl * T_rate)
            ),
            0,
            0,
        ],
        [0, 0, -p_6, 0],
        [0, 0, 0, -p_7],
    ]
)
Input = InputTuple(u * ImmutableMatrix(b))
コード例 #22
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
        ,'beta': '"$N:C$ ratio in fresh organic matter"'
        ,'i': '"rate of mineral $N$ diffusion in soil"' # "\\text{time}^{-1}"
        ,'Phi_l': 'fresh organic matter carbon flux' # "(\\text{quantity of carbon})(\\text{time}))^{-1}"
        ,'Phi_i': 'nitrogen that flows into the ecosystem' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
        ,'Phi_o': 'nitrogen that flows out of the ecosystem' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
        ,'Phi_up': 'nitrogen flux associated with the nitrogen uptake by the plant cover' # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
}

for name in sym_dict.keys():
    var(name)
t = TimeSymbol("t") # unit: ""
x = StateVariableTuple((C_s, C_f, C_ds, C_df, N))
u = InputTuple((0, Phi_l, 0, 0, Phi_i-Phi_o-Phi_up))
B = CompartmentalMatrix([[-A/C_s*C_ds,           0,       s,                           s,               0],
                         [          0,             -y,       0,       -alpha*r/(alpha-beta), -i/(alpha-beta)],
                         [ A/C_s*C_ds,              y,  -(s+r),                           0,               0],
                         [          0,              0,       0, -(s+r)+alpha*r/(alpha-beta),  i/(alpha-beta)],
                         [          0, (beta-alpha)*y, alpha*r,                           0,              -i]])
#suggested_steady_states:
#    - C_f: (s+r-3)/y*C_ds
#      C_df: (s+r-A)*(Phi_i-Phi_o-Phi_up+beta*Phi_l-alpha*(A-s)*Phi_l/(s+r-A))
#      C_ds: (s+r)*(-(Phi_i-Phi_o-Phi_up+beta*Phi_l) + alpha*s*Phi_l/(s+r))/(A*r*alpha)
#      N: alpha*s-beta*(s+r)/i*C_df

mvs = CMTVS(
    {
        BibInfo(# Bibliographical Information
            name="",
            longName="The C-N model of SOM dynamics, two decomposer types", 
            version="SOM decomposers C limited, FOM composers N limited (case 4)",
            entryAuthor="Holger Metzler",
コード例 #23
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
GPP = A_c * 3600 * 12 / 1000000  # Scaling expression from TECO fortran code, line 667.' # gC*day^{-1}
f_W = Min((0.5 * W), 1)
f_T = Q_10 * ((T - 10) / 10)
xi = f_W * f_T
t = TimeSymbol("t")  # unit: "day"
#x = StateVariableTuple((C_foliage, C_roots, C_wood, C_metlit, C_stlit, C_fastsom, C_slowsom, C_passsom))
x = StateVariableTuple((C_foliage, C_wood, C_roots, C_metlit, C_stlit,
                        C_fastsom, C_slowsom, C_passsom))
u = GPP
b = (b_foliage, b_roots, b_wood, 0, 0, 0, 0, 0)
Input = InputTuple(u * ImmutableMatrix(b))
B = CompartmentalMatrix(
    [[-cr_foliage, 0, 0, 0, 0, 0, 0, 0], [0, -cr_wood, 0, 0, 0, 0, 0, 0],
     [0, 0, -cr_root, 0, 0, 0, 0,
      0], [f_foliage2metlit, 0, f_roots2metlit, -cr_metlit, 0, 0, 0, 0],
     [f_foliage2stlit, f_wood2stlit, f_roots2stlit, 0, -cr_stlit, 0, 0, 0],
     [
         0, 0, 0, f_metlit2fastsom, f_stlit2fastsom, -cr_fastsom,
         f_slowsom2fastsom, f_passsom2fastsom
     ], [0, 0, 0, 0, f_stlit2slowsom, f_fastsom2slowsom, -cr_slowsom, 0],
     [0, 0, 0, 0, 0, f_fastsom2passsom, f_slowsom2passsom, -cr_passsom]])
np1 = NumericParameterization(par_dict={
    GPP: 3.370,
    b_foliage: 0.14,
    b_roots: 0.26,
    b_wood: 0.14,
    f_foliage2metlit: 0.9,
    f_foliage2stlit: 0.1,
    f_wood2stlit: 1,
    f_roots2metlit: 0.2,
    f_roots2stlit: 0.8,
    f_metlit2fastsom: 0.45,
コード例 #24
0
 def test_creation_from_list(self):
     C = CompartmentalMatrix(2, 2, [1, 2, 3, 4])
     print(C, type(C))
     self.assertEqual(type(C), CompartmentalMatrix)
コード例 #25
0
ファイル: source.py プロジェクト: chrislxj/bgc_md2
A_S = (Piecewise((a_S * G, N < 0), (a_S * N + R_gS + R_mS, N > 0)))
A_R = (Piecewise((a_R * G, N < 0), (a_R * N + R_gR + R_mR, N >= 0)))
#beta_T=(Piecewise((1,T_air>= T_cold),(Piecewise((((T_air-T_cold-5)/5),T_air>(T_cold-5)),(0,T_air<=(T_cold-5))),T_cold>T_air))) # Had to comment it out because of problems of piecewise in matrix
gamma_T = gamma_Tmax * (1 - beta_T)**b_T
D_L = (gamma_N + gamma_W + gamma_T) * C_L
D_S = gamma_S * C_S
D_R = gamma_R * C_R

x = StateVariableTuple((C_L, C_S, C_R))
b = 1
u = (C_L, C_S, C_R)
Input = InputTuple(
    ImmutableMatrix(u) * 1
)  #Fixme: does input always have to be a Tuple? what happens when, in this case, "f_v = u + A*x"?
A = CompartmentalMatrix([[-(gamma_N + gamma_W + gamma_T), 0, 0],
                         [0, -gamma_S - R_gS - R_mS, 0],
                         [0, 0, -gamma_R - R_gR - R_mR]])
#
t = TimeSymbol("t")

#    parameter_sets:
#        - "Original dataset of the publication":
#            values: {k_n: 0.5, omega: 0.8, epsilon_L: 0.35, epsilon_S: 0.1, epsilon_R: 0.55}
#            desc: Eastern US and Germany, cold broadleaf deciduous
#            doi: 10.1111/j.1365-2486.2004.00890.x

mvs = MVarSet({
    BibInfo(  # Bibliographical Information
        name="CTEM",
        longName="Canadian Terrestrial Ecosystem Model",
        version="1",
コード例 #26
0
 def test_creation_from_index_function(self):
     C = CompartmentalMatrix(2, 2, lambda i, j: i + j)
     print(C, type(C))
     self.assertEqual(type(C), CompartmentalMatrix)
コード例 #27
0
    'gamma_f': 'Foliage turnover rate',
    'gamma_r': 'Roots turnover rate',
    'gamma_w': 'Wood turnover rate'
}
for name in sym_dict.keys():
    var(name)

f_W = Min((0.5 * W), 1)
f_T = Q_10**((T - 10) / 10)
epsilon_t = f_W * f_T
x = StateVariableTuple((C_f, C_r, C_w))
u = GPP * epsilon_t
b = (eta_f, eta_w, eta_r)

Input = InputTuple(u * ImmutableMatrix(b))
A = CompartmentalMatrix(diag(-gamma_f, -gamma_w, -gamma_r))
t = TimeSymbol("t")

# "Original parameters of the publication. Parameter value of GPP corresponds to an annual average"
# T, Q_10, and W are variables that should be looked at in a data set. What I have here are invented values
np1 = NumericParameterization(
    par_dict={
        Q_10: 1,
        W: 4.2,
        T: 25,
        GPP: 3370,  #"gC*day^{-1}"
        eta_f: 0.14,
        eta_r: 0.26,
        eta_w: 0.14,
        gamma_f: 0.00258,
        gamma_w: 0.0000586,
コード例 #28
0
 def test_creation_from_expression(self):
     A = ImmutableMatrix(1, 1, [1])
     B = ImmutableMatrix(1, 1, [1])
     C = CompartmentalMatrix(A*B)
     print(C, type(C))
     self.assertEqual(type(C), CompartmentalMatrix)
コード例 #29
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
A_S = (Piecewise((a_S * G, N < 0), (a_S * N + R_gS + R_mS, N > 0)))
A_R = (Piecewise((a_R * G, N < 0), (a_R * N + R_gR + R_mR, N >= 0)))
#beta_T=(Piecewise((1,T_air>= T_cold),(Piecewise((((T_air-T_cold-5)/5),T_air>(T_cold-5)),(0,T_air<=(T_cold-5))),T_cold>T_air))) # Had to comment it out because of problems of piecewise in matrix
gamma_T = gamma_Tmax * (1 - beta_T)**b_T
D_L = (gamma_N + gamma_W + gamma_T) * C_L
D_S = gamma_S * C_S
D_R = gamma_R * C_R

x = StateVariableTuple((C_L, C_S, C_R, C_D, C_H))
u = (G, 0, 0, 0, 0)
Input = InputTuple(u)  #f_v = u + A*x
A = CompartmentalMatrix([[
    -(gamma_N + gamma_W + gamma_T + (A_R + A_S + ((R_gL + R_mL) / C_L))), 0, 0,
    0, 0
], [A_S, -gamma_S - ((R_gS - R_mS) / C_S), 0, 0, 0],
                         [A_R, 0, -gamma_R - ((R_gR - R_mR) / C_R), 0, 0],
                         [
                             gamma_N + gamma_W + gamma_T, gamma_S, gamma_R,
                             -gamma_DH - (R_hD / C_D), 0
                         ], [0, 0, 0, gamma_DH, -(R_hH / C_H)]])
### Had to divide Respiration fluxes by state variables because the flux was not presented as a rate*state variable tuple.

t = TimeSymbol("t")

#    parameter_sets:
#        - "Original dataset of the publication":
#            values: {k_n: 0.5, omega: 0.8, epsilon_L: 0.35, epsilon_S: 0.1, epsilon_R: 0.55}
#            desc: Eastern US and Germany, cold broadleaf deciduous
#            doi: 10.1111/j.1365-2486.2004.00890.x

mvs = CMTVS(
コード例 #30
0
ファイル: source.py プロジェクト: MPIBGC-TEE/bgc_md2
    'nitrogen that flows into the ecosystem'  # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
    ,
    'Phi_o':
    'nitrogen that flows out of the ecosystem'  # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
    ,
    'Phi_up':
    'nitrogen flux associated with the nitrogen uptake by the plant cover'  # "(\\text{quantity of nitrogen})(\\text{time}))^{-1}"
}

for name in sym_dict.keys():
    var(name)
t = TimeSymbol("t")  # unit: ""
C = StateVariableTuple((C_s, C_f, C_ds, C_df, N))
I = InputTuple((0, Phi_l, 0, 0, Phi_i - Phi_o - Phi_up))
A_GeM = CompartmentalMatrix(
    [[0, 0, s - A, s, 0], [0, -(y + u), 0, 0, 0], [0, y, A - s - r, 0, 0],
     [0, u, 0, -(s + r), 0],
     [0, (beta - alpha) * (y + u), alpha * r, alpha * r, 0]])

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name=
            "FB2005 - The C-N model of SOM dynamics, two decomposer types (model 4)",
            longName="The C-N model of SOM dynamics, two decomposer types",
            version="1 - C limitation",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="22/03/2016",
            doi="10.1111/j.1461-0248.2005.00813.x",
            sym_dict=sym_dict),
        A_GeM,  # the overall compartmental matrix