Example #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')
Example #2
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')
Example #3
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')
Example #4
0
def continiuous_integral(t, Phi_func):
    # We compute the integral of the continious function
    # With an integration rule that
    #print(phi_vals)
    def rhs(tau, X):
        # although we do not need X we have to provide a
        # righthandside suitable for solve_ivp
        return np.matmul(Phi_func(t, tau), u_num(tau)).flatten()

    #pe('integrand_vals',locals())
    ys = solve_ivp(rhs, y0=np.zeros(nr_pools), t_span=(t_0, t)).y
    pe('ys.shape', locals())
    val = ys[:, -1].reshape(nr_pools, 1)
    #pe('val',locals())
    return val
Example #5
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')