Exemplo n.º 1
0
def epsilon_family(
        limited_srm,
        par_dict,
        control_start_values, 
        times,
        func_dict,
        epsilons
    ):    
    z=Symbol('z')
    eps=Symbol('eps')
    u_z_exp=half_saturation(z,eps)
    bm=BastinModel(limited_srm,u_z_exp,z)
    fig=plt.figure()
    ax1=fig.add_subplot(1,1,1)
    ax1.set_title("control u for different values of epsilon")
    for eps_val in epsilons:
        par_dict[eps]=eps_val
        bmr=BastinModelRun(
            bm, 
            par_dict,
            control_start_values, 
            times,
            func_dict
        )
        phi_num=bmr.phi_num((z,))
        soln=bmr.solve() 
        z_sol=soln[:,3]
        pe('bm.u_expr',locals())
        u=phi_num(z_sol)
        ax1.plot(times,u)
        ax1.legend(loc=3)
     
    fig.savefig(my_func_name()+'.pdf')
Exemplo n.º 2
0
def panel_two(bm, par_dict_v1, control_start_values, times, func_dict):
    start_values=control_start_values[:-1]
    bmr=BastinModelRun( bm, par_dict_v1, control_start_values, times, func_dict)
    soln_controlled = bmr.solve()

    tup=(bm.time_symbol,bm.z_sym)
    phi_num=bmr.phi_num(tup)
    z_vals=soln_controlled[:,3]
    u_vals=phi_num(times,z_vals)
    
    efl=bmr.external_input_flux_funcs()
    f=efl[0]
    values=f(times)

    fig=plt.figure(figsize=(10,10))
    #fig1.title('Total carbon'+title_suffs[version])
    ax1=fig.add_subplot(2,1,1)
    ax1.tick_params(axis='both', which='major', labelsize=12)
    ax1.plot(times, u_vals,color='green',label='u')
    ax1.set_ylabel('$u(t)$ (unitless)', fontsize=15)
    #ax1.legend(loc=2)
    ax1.set_title("(a)")
    ax1.set_xlim(1900, 2500)

    ax2=fig.add_subplot(2,1,2)
    ax2.tick_params(axis='both', which='major', labelsize=12)
    ax2.plot(times, values,color='blue' ,label='u d')
    ax2.set_ylabel('Allowed carbon emissions (Pg C/yr)', fontsize=15)
    ax2.set_xlabel('Time (yr)', fontsize=15)
    ax2.set_ylim(ax1.get_ylim())
    ax2.set_xlim(1900, 2500)
    ax2.set_title("(b)")
    
    fig.savefig(my_func_name()+'.pdf', bbox_inches='tight')
Exemplo n.º 3
0
def panel_one(limited_srm,bm, par_dict_v1, control_start_values, times, func_dict):
    start_values=control_start_values[:-1]
    limited_smr = SmoothModelRun(limited_srm, par_dict_v1, start_values, times, func_dict)
    bmr=BastinModelRun( bm, par_dict_v1, control_start_values, times, func_dict)

    soln_uncontrolled = limited_smr.solve()

    soln_controlled = bmr.solve()
    fig=plt.figure(figsize=(10,10))
    #fig1.title('Total carbon'+title_suffs[version])
    ax1=fig.add_subplot(2,1,1)
    ax1.tick_params(axis='both', which='major', labelsize=12)
    ax1.plot(times, soln_uncontrolled[:,0],color='blue' ,label='Atmosphere')
    ax1.plot(times, soln_uncontrolled[:,1],color='green',label='Terrestrial Biosphere')
    ax1.plot(times, soln_uncontrolled[:,2],color='red'  ,label='Surface ocean')
    ax1.set_ylabel('Carbon stocks (Pg C)', fontsize=15)
    ax1.legend(loc=2)
    ax1.set_title("(a)")
    ax1.set_xlim(1900, 2500)

    ax2=fig.add_subplot(2,1,2)
    ax2.tick_params(axis='both', which='major', labelsize=12)
    ax2.plot(times, soln_controlled[:,0],color='blue' ,label='Atmosphere')
    ax2.plot(times, soln_controlled[:,1],color='green',label='Terrestrial Biosphere')
    ax2.plot(times, soln_controlled[:,2],color='red'  ,label='Surface ocean')
    ax2.set_ylabel('Carbon stocks (Pg C)', fontsize=15)
    ax2.set_xlabel('Time (yr)', fontsize=15)
    ax2.set_ylim(ax1.get_ylim())
    ax2.set_xlim(1900, 2500)
    ax2.set_title("(b)")
    
    #limited_soln_uncontrolled 
    fig.savefig(my_func_name()+'.pdf', bbox_inches='tight')
Exemplo n.º 4
0
def epsilon_family_2(limited_srm, par_dict, start_values, times, func_dict, zs,
                     epsilons):
    z = Symbol('z')
    eps = Symbol('eps')
    z0 = Symbol('z0')
    u_z_exp = half_saturation(z, eps)
    bm = BastinModel(limited_srm, u_z_exp, z)
    fig = plt.figure()
    ax1 = fig.add_subplot(1, 1, 1)
    ax1.set_title("control u for different values of epsilon")
    for z0_val in zs:
        for eps_val in epsilons:
            control_start_values = np.array(list(start_values) + [z0_val])
            par_dict[eps] = eps_val
            par_dict[z0] = z0_val,
            bmr = BastinModelRun(bm, par_dict, control_start_values, times,
                                 func_dict)
            phi_num = bmr.phi_num((z, ))
            soln = bmr.solve()
            z_sol = soln[:, 3]
            pe('bm.u_expr', locals())
            u = phi_num(z_sol)
            ax1.plot(times,
                     u,
                     label="eps:" + str(eps_val) + ",z0=" + str(z0_val))
    ax1.legend(loc=3)

    fig.savefig(my_func_name() + '.pdf')
Exemplo n.º 5
0
def deceleration_family(limited_srm, par_dict, start_values, times, func_dict,
                        zs, alphas):
    z = Symbol('z')
    z_max = Symbol('z_max')
    alph = Symbol('alph')
    u_z_exp = deceleration(z, z_max, alph)
    bm = BastinModel(limited_srm, u_z_exp, z)
    fig = plt.figure()
    ax1 = fig.add_subplot(1, 1, 1)
    ax1.set_title(
        "control u with deceleration limiter for different values of alph")
    for z_max_val in zs:
        for alpha_val in alphas:
            control_start_values = np.array(list(start_values) + [z_max_val])
            par_dict[z_max] = z_max_val
            par_dict[alph] = alpha_val
            bmr = BastinModelRun(bm, par_dict, control_start_values, times,
                                 func_dict)
            phi_num = bmr.phi_num((z, ))
            soln = bmr.solve()
            z_sol = soln[:, 3]
            pe('bm.u_expr', locals())
            u = phi_num(z_sol)
            ax1.plot(times,
                     u,
                     label="alph:" + str(alpha_val) + ",z_max=" +
                     str(z_max_val))
    ax1.legend(loc=3)

    fig.savefig(my_func_name() + '.pdf')
Exemplo n.º 6
0
def cubic_family(
        limited_srm,
        par_dict,
        start_values, 
        times,
        func_dict,
        zs
    ):    
    z=Symbol('z')
    z_max=Symbol('z_max')
    u_z_exp=cubic(z,z_max)
    bm=BastinModel(limited_srm,u_z_exp,z)
    fig=plt.figure()
    ax1=fig.add_subplot(1,1,1)
    #ax1.set_title("control u for different values of z_max")
    for z_max_val in zs:
        control_start_values=np.array(list(start_values)+[z_max_val])
        par_dict[z_max]=z_max_val
        bmr=BastinModelRun(
            bm, 
            par_dict,
            control_start_values, 
            times,
            func_dict
        )
        phi_num=bmr.phi_num((z,))
        soln=bmr.solve() 
        z_sol=soln[:,3]
        pe('bm.u_expr',locals())
        u=phi_num(z_sol)
        ax1.plot(times,u,label="$z_{max}$="+str(z_max_val))
        ax1.set_ylabel('$u(t)$ (unitless)')
        ax1.set_xlabel('Time (years)')
        ax1.legend(loc=3)
     
    fig.savefig(my_func_name()+'.pdf')