Пример #1
0
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,
    i: 0.285,
    h: 0.125,
    r: 1.00
},
                              func_dict=frozendict({}))
nsv2 = NumericStartValueDict({Y: 0.3, O: 4.11})

#        - "-N +straw":
np3 = NumericParameterization(par_dict={
    k_1: 0.8,
Пример #2
0
        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,
        gamma_r: 0.00239
    },
    func_dict=frozendict({})
    # state_var_units=gram/kilometer**2,
    # time_unit=day
)
nsv1 = NumericStartValueDict({C_f: 250, C_w: 4145, C_r: 192})

ntimes = NumericSimulationTimes(np.arange(0, 150, 2.5))

mvs = MVarSet({
    BibInfo(  # Bibliographical Information
        name="",
        longName="",
        version="",
        entryAuthor="Verónika Ceballos-Núñez",
        entryAuthorOrcid="0000-0002-0046-1160",
        entryCreationDate="24/3/2016",
        doi="",
        #        further_references=BibInfo(doi=""),
        #        modApproach: process based,
        #        partitioningScheme: fixed,
Пример #3
0
    f_cs: 0.45,
    f_np: 0.16,
    f_nr: 0.03,
    f_ns: 0.005,
    h_max: 0.0003,
    h_half: 200,
    kappa: 300,
    rho: '5*10**5',
    C_i: 240
},
                              func_dict=frozendict({}))
nsv1 = NumericStartValueDict({
    N: 0.01,
    C: 0.15,
    W_p: 100,
    W_s: 100,
    W_r: 100,
    W_C: 45,
    W_N: 30
})
ntimes = NumericSimulationTimes(np.arange(0, 150, 25))
#ntimes = NumericSimulationTimes(np.arange(0, 1, 0.001)) #Fixme: There were 2 in the yaml file, not sure which one works best

mvs = MVarSet({
    BibInfo(  # Bibliographical Information
        name="",
        longName="",
        version="1",
        entryAuthor="Verónika Ceballos-Núñez",
        entryAuthorOrcid="0000-0002-0046-1160",
        entryCreationDate="29/7/2015",
Пример #4
0
    cr_foliage: 0.00258,
    cr_wood: 0.0000586,
    cr_root: 0.002390,
    cr_metlit: 0.0109,
    cr_stlit: 0.00095,
    cr_fastsom: 0.0105,
    cr_slowsom: 0.0000995,
    cr_passsom: 0.0000115
},
                              func_dict=frozendict({}))
# "Initial values as in Wang and Luo"
nsv1 = NumericStartValueDict({
    C_foliage: 250,
    C_roots: 4145,
    C_wood: 192,
    C_metlit: 93,
    C_stlit: 545,
    C_fastsom: 146,
    C_slowsom: 1585,
    C_passsom: 300
})
ntimes = NumericSimulationTimes(np.arange(0, 200, 1))

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="TECO",
            longName="Terrestrial Ecosystem Model",
            version="",
            entryAuthor="Carlos A. Sierra",
            entryAuthorOrcid="0000-0003-0009-4169",
            entryCreationDate="12/4/2018",
Пример #5
0
[[-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
})

ntimes = NumericSimulationTimes(np.arange(0, 20000, 0.01))

#    doi: 10.1016/0304-3800(88)90112-3
np2 = NumericParameterization(
    par_dict={
    eta_f: Rational(25,100), eta_r: Rational(40,100), eta_w: Rational(35,100), gamma_r: Rational(40,100), gamma_f: Rational(33,100), gamma_w: Rational(0,100)},
    func_dict=frozendict({})
)

#    doi: 10.1093/treephys/9.1-2.161 # Hunt1991TreePhysiol
np3 = NumericParameterization(
    par_dict={
Пример #6
0
        #
        # Althouhg p10 is considered to have unit 1/Kelvin
        # inspection of the T_rate expression connects it
        # to Temperature DIFFERENCE from  the triple point
        p_10: 0.0693,  # /kelvin
        p_14: 0.45,
        p_15: 0.001,  # 1/day
        p_16: 0.251,
    },
    func_dict=frozendict({})
    # state_var_units=kilogram/meter**2,
    # time_unit=day
)
nsv1 = NumericStartValueDict({
    C_f: 58,
    C_lab: 60,
    C_w: 770,
    C_r: 102
})

## We create the parameterized model explicitly , although the framework would find the ingredients
nsrm = NumericParameterizedSmoothReservoirModel(srm,np1)



ntimes = NumericSimulationTimes(np.arange(0, 1096, 1))

## We create the model run explicitly again, although the framework would find the ingredients
nsmr= numeric_model_run_1(
    nsrm, 
    numeric_start_value_array_1(nsv1,x),
    ntimes
Пример #7
0
    c_1: 0.00258,
    c_2: 0.0000586,
    c_3: 0.002390,
    c_4: 0.0109,
    c_5: 0.00095,
    c_6: 0.0105,
    c_7: 0.0000995,
    c_8: 0.0000115
},
                              func_dict=frozendict({}))
# "Initial values as in Wang and Luo"
nsv1 = NumericStartValueDict({
    x_1: 250,
    x_2: 4145,
    x_3: 192,
    x_4: 93,
    x_5: 545,
    x_6: 146,
    x_7: 1585,
    x_8: 300
})
ntimes = NumericSimulationTimes(np.arange(0, 200, 1))

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="TECO",
            longName="Terrestrial Ecosystem Model",
            version="",
            entryAuthor="Carlos A. Sierra",
            entryAuthorOrcid="0000-0003-0009-4169",
            entryCreationDate="12/4/2018",
Пример #8
0
    def test_numeric_input_tuple(self):
        # setup the paths to the testdata
        cable_out_path = Path(
            '/home/data/cable-data/example_runs/parallel_1901_2004_with_spinup/output/new4'
        )
        # cable_data_set = cH.cable_ds(cable_out_path)
        time_slice = slice(0, None)
        landpoint_slice = slice(1590, 1637)  # cheated
        # landpoint_slice = slice(None,None)
        # time_slice=slice(None,None,None)

        zarr_cache_path = cP.slice_dir_path(
            cable_out_path,
            sub_dir_trunk="zarr_mm11",
            time_slice=time_slice,
            landpoint_slice=landpoint_slice,
        )
        if "cable_data_set" not in dir():
            cable_data_set = cH.cable_ds(cable_out_path)
        args = {
            "cable_data_set": cable_data_set,
            "zarr_cache_path": zarr_cache_path,
            "landpoint_slice": landpoint_slice,
            "time_slice": time_slice,
            #'batch_size': 128,
            "batch_size": 12,
            #'rm': True
        }

        x_org_iveg = cH.cacheWrapper(cC.x_org_iveg, **args)
        time = cH.cacheWrapper(cC.time, **args)

        patches, landpoints = cC.all_pools_vary_cond_nz(**args)
        pcs = patches.compute()
        lpcs = landpoints.compute()
        pcs, lpcs
        p = Path('plots')
        p.mkdir(exist_ok=True)
        ind = 0  # first pair that has a nonconstant solution for
        lp = lpcs[ind]
        patch = lpcs[ind]

        # get the symbolic represantation from the database
        mvs = self.mvs

        # define some stuff to extend it with

        def default(t):
            return 1

        leaf = Symbol('leaf')
        fine_root = Symbol('fine_root')
        Npp = Function("Npp")
        bvec_leaf = Function("bvec_leaf")
        bvec_fine_root = Function("bvec_fine_root")
        xk_leaf_cold = Function("xk_leaf_cold")
        xk_leaf_dry = Function("xk_leaf_dry")
        kleaf = Function("kleaf")
        kfroot = Function("kfroot")
        # bvec_wood = Function("bvec_wood")

        np1 = NumericParameterization(
            par_dict={},
            func_dict=frozendict({
                Npp: default,
                bvec_fine_root: default,
                bvec_leaf: default,
                xk_leaf_cold: default,
                kleaf: default,
                kfroot: default,
                xk_leaf_dry: default,
            }),
        )
        nsv1 = NumericStartValueDict({leaf: 0.3, fine_root: 3.96})
        ntimes1 = NumericSimulationTimes(np.linspace(0, 1, 11))

        # extend the symbolice version with the new stuff
        pvs = mvs.provided_mvar_values
        #from IPython import embed; embed()
        pvs1 = pvs.union(frozenset({np1, nsv1, ntimes1}))
        mvs1 = MVarSet(pvs1)

        x = mvs1.get_StateVariableTuple()
        Input = mvs1.get_InputTuple()
        #B = mvs1.get_CompartmentalMatrix()
        sym_times = mvs1.get_NumericSimulationTimes()
        sol_smooth = mvs1.get_NumericSolutionArray()

        comp_slice = slice(0, 100)
        n = sol_smooth.shape[1]
        fig = plt.figure()
        for pool in range(n):
            ax = fig.add_subplot(n + 1, 1, 2 + pool)
            title = "\$" + latex(x[pool]) + "\$"
            #ax.plot(
            #    sym_times[comp_slice],
            #    sol_smooth[comp_slice, pool],
            #    color='r'
            #)
            ax.plot(time[comp_slice],
                    x_org_iveg[comp_slice, pool, patch, lp],
                    color='b')
            fontsize = 10
            ax.set_title(title, fontsize=fontsize)

        fig.savefig('solution.pdf')
Пример #9
0
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,
    C_3: 00,
    C_4: 0,
    C_5: 0,
    C_6: 0,
    C_7: 0
})  #faked values by Markus to make it run
#ntimes = NumericSimulationTimes(np.arange())

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="Century",
            longName="",
            version="1",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="10/03/2016",
Пример #10
0
np1 = NumericParameterization(par_dict={
    D_max: 0.26,
    Y: 0.44,
    K_s: 3.0,
    theta: 0.23,
    ExuT: 0.8,
    BGF: 0.15,
    K_d: 14.5,
    K_r: 0.4,
    ExuM: 8.0,
    mu_max: 0.063
},
                              func_dict=frozendict({}))

# Standard version of BACWAVE, optimized to simulate bacterial biomass along wheat roots:
nsv1 = NumericStartValueDict({X: 0.5, S: 1.5})  # "Low"
nsv2 = NumericStartValueDict({X: 1.0, S: 2.5})  # "Medium"
nsv3 = NumericStartValueDict({X: 1.5, S: 4.0})  # "High"
ntimes = NumericSimulationTimes(np.arange(0, 2000, 0.1))

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="BACWAVE",
            longName="",
            version="",
            entryAuthor="Holger Metzler",
            entryAuthorOrcid="0000-0002-8239-1601",
            entryCreationDate="15/03/2016",
            doi="10.2307/4251775",
            sym_dict=sym_dict),
Пример #11
0
    F_1: 2.081,
    F_2: 0.0686,
    F_3: 0.5217,
    F_4: 0.5926,
    F_5: 9.813e-3,
    F_21: 0.8378,
    F_41: 0.5676,
    F_42: 0.0322,
    F_52: 4.425e-3,
    F_43: 0.1739,
    F_53: 0.0870,
    F_54: 0.0370
},
                              func_dict=frozendict({}))

nsv1 = NumericStartValueDict({x_1: 37, x_2: 452, x_3: 69, x_4: 81, x_5: 1121})
ntimes = NumericSimulationTimes(np.arange(0, 200, 0.1))

mvs = CMTVS(
    {
        BibInfo(  # Bibliographical Information
            name="",
            longName="",
            version="",
            entryAuthor="Carlos A. Sierra",
            entryAuthorOrcid="0000-0003-0009-4169",
            entryCreationDate="12/9/2016",
            doi="",
            #        bibtex= "@incollection{Emanuel1981,
            #                     author = {W. R. Emanuel and G. G. Killough and J. S. Olson},
            #                     booktitle = {Carbon Cycle Modelling},