예제 #1
0
def varying_salinity():

    salinities = [35, 40, 45]

    pH_fixed = 8.2
    temp_fixed = 15+273

    fig, (Xp_ax, Xc_ax) = plt.subplots(1,2)

    for sal in salinities:
        print("sal = ", sal)
        tol = 10e-15
        n = 100
        Nmax = 10**(n+10)

        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp_fixed, sal, pH_fixed)

        t0_s, T_end_s = 0, 0.999

        z0_s = np.array([0, 10**(-n)])

        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp_fixed, pH_fixed, sal)
        tf_c = t_f(r_TBT_c)

        X_p = np.zeros(len(t_s))
        X_c = np.zeros(len(t_s))
        for i in range(len(t_s)):
            X_p[i] = y_s[i][0]
            X_c[i] = y_s[i][1]

        Xp_ax.plot(t_s*tf_c, X_p, label=salinity_label(sal))
        Xc_ax.plot(t_s*tf_c, X_c, label=salinity_label(sal))
    
    Xp_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xc_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xp_ax.set_title(Xp_label)
    Xc_ax.set_title(Xc_label)
    Xp_ax.legend(loc="lower right")
    Xc_ax.legend(loc="lower right")
    Xp_ax.grid(True)
    Xc_ax.grid(True)
    fig.suptitle("With constant T = " + str(temp_fixed-273) + "$^o$C and pH = " + str(pH_fixed))
    plt.show()
예제 #2
0
def varying_temperature():

    temperature = [10+273, 15+273, 20+273, 25+273]

    pH_fixed = 8.2
    sal_fixed = 35.1

    fig, (Xp_ax, Xc_ax) = plt.subplots(1,2)

    for temp in temperature:
        tol = 10e-15
        n = 100
        Nmax = 10**(n+30)

        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp, sal_fixed, pH_fixed)

        t0_s, T_end_s = 0, 0.999

        z0_s = np.array([0, 10**(-n)])

        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp, pH_fixed, sal_fixed)
        tf_c = t_f(r_TBT_c)

        X_p = np.zeros(len(t_s))
        X_c = np.zeros(len(t_s))
        for i in range(len(t_s)):
            X_p[i] = y_s[i][0]
            X_c[i] = y_s[i][1]

        Xp_ax.plot(t_s*tf_c, X_p, label=temp_label(temp))
        Xc_ax.plot(t_s*tf_c, X_c, label=temp_label(temp))
    
    Xp_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xc_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xp_ax.set_title(Xp_label)
    Xc_ax.set_title(Xc_label)
    Xp_ax.legend(loc="lower right")
    Xc_ax.legend(loc="lower right")
    Xp_ax.grid(True)
    Xc_ax.grid(True)
    fig.suptitle("With constant salinity = " + str(sal_fixed) + " g salt/kg seawater and pH = " + str(pH_fixed))
    plt.show()
예제 #3
0
def varying_pH():

    pHs = [7.5, 8, 8.5]

    temp_fixed = 15+273
    sal_fixed = 35.1

    fig, (Xp_ax, Xc_ax) = plt.subplots(1,2)

    for pH_v in pHs:
        tol = 10e-15
        n = 100
        Nmax = 10**(n+50)

        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp_fixed, sal_fixed, pH_v)

        t0_s, T_end_s = 0, 0.999

        z0_s = np.array([0, 10**(-n)])

        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp_fixed, pH_v, sal_fixed)
        tf_c = t_f(r_TBT_c)

        X_p = np.zeros(len(t_s))
        X_c = np.zeros(len(t_s))
        for i in range(len(t_s)):
            X_p[i] = y_s[i][0]
            X_c[i] = y_s[i][1]

        Xp_ax.plot(t_s*tf_c, X_p, label=pH_label(pH_v))
        Xc_ax.plot(t_s*tf_c, X_c, label=pH_label(pH_v))
    
    Xp_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xc_ax.set(xlabel=x_label_day, ylabel=conversion_label)
    Xp_ax.set_title(Xp_label)
    Xc_ax.set_title(Xc_label)
    Xp_ax.legend(loc="lower right")
    Xc_ax.legend(loc="lower right")
    Xp_ax.grid(True)
    Xc_ax.grid(True)
    fig.suptitle("With constant T = " + str(temp_fixed-273) + "$^o$C and salinity = " + str(sal_fixed) + " g salt/kg seawater")
    plt.show()
예제 #4
0

# Run method
tol = 10e-20
n = 100
Nmax = 10**(n + 10)

### FIRST 400 days, Bueno Aires coastline ###

model_400 = ADVANCED_MODEL(p_400_temp, p_400_sal, p_400_pH)

t0_400, T_end_400 = 0, 400

l0_400 = np.array([0, 10**(-n)])

t_400, y_400 = ODE_solver(l0_400, t0_400, T_end_400, model_400, Nmax, tol)

### 20 DAYS VOYAGE ###
model_20 = ADVANCED_MODEL(p_20_temp, p_20_sal, p_20_pH)

t0_20, T_end_20 = 0, 19.9

l0_20 = np.array([y_400[-1][0], y_400[-1][1]])

t_20, y_20 = ODE_solver(l0_20, t0_20, T_end_20, model_20, Nmax, tol)

### 400 + 20 days modeling
t_1 = t_400[:]
y_1 = y_400[:]

t_2 = t_20[:] + 400
예제 #5
0
        return np.array([dzpdt, dzcdt])


# Run method
tol = 10e-10
n = 100
Nmax = 10**(n + 15)

idealized_route_model = IDEALIZED_ROUTE(p_i_temp, p_i_sal, p_i_pH)

t0_s, T_end_s = 0, 0.999

z0_s = np.array([0, 10**(-n)])

t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, idealized_route_model, Nmax, tol)


def plot_conversion_idealized():

    plt.plot(t_s, y_s)
    plt.plot([0.375, 0.375], [0, 0.7], '--', color="black")
    plt.plot([0.500, 0.500], [0, 0.7], '--', color="black")
    plt.plot([0.625, 0.625], [0, 0.7], '--', color="black")
    plt.plot([0.750, 0.750], [0, 0.7], '--', color="black")
    plt.plot([0.875, 0.875], [0, 0.7], '--', color="black")
    plt.legend(conversion_legend)
    plt.grid(True)
    plt.ylim(0, 0.75)
    plt.xlabel(tau_label)
    plt.ylabel(conversion_label)
예제 #6
0
    def __call__(self, t, z):
        dzp_dt = 1
        dzc_dt = (M_TBT * M_Cu2O) / M_unit * (rho_p * V_p * D_CuCl) / (
            r_TBT * 2 * V_c * rho_c) * C_CuCl_s / (z[1] * L_F - z[0] * L_F)

        return np.array([dzp_dt, dzc_dt])


model = MODEL()

# Run method
tol = 1.0e-15  # Tolerance in adaptive method
n = 100
Nmax = 10**(n + 25)

### FIRST, solve from tau = 0 to an upper limit
t0_0, T_0 = 0, 0.925
z0_0 = np.array([0, 10**(-n)])

ts_0, ys_0 = ODE_solver(z0_0, t0_0, T_0, model, Nmax, tol)

## SECOND, solve from tau = limit to tau = 1
t0_1, T_1 = ts_0[-1], 1
z0_1 = ys_0[-1]

ts_1, ys_1 = ODE_solver(z0_1, t0_1, T_1, model, Nmax, tol)

## MERGE the two solutions
tau_simple = np.concatenate((ts_0, ts_1))
X_simple = np.concatenate((ys_0, ys_1))
예제 #7
0
def release_sensitivity():
    temp_fixed = 15+273
    sal_fixed = 35.1
    pH_fixed = 8.2

    fig, (T_ax, sal_ax, pH_ax) = plt.subplots(1,3)

    temp_vary = [10+273, 15+273, 20+273, 25+273]
    sal_vary = [35, 40, 45]
    pH_vary = [7.5, 8, 8.5]

    tol = 10e-15
    n = 100
    Nmax = 10**(n+30)

    t0_s, T_end_s = 0, 0.999

    z0_s = np.array([0, 10**(-n)])

    for temp in temp_vary:
        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp, sal_fixed, pH_fixed)
        
        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp, pH_fixed, sal_fixed)
        tf_c = t_f(r_TBT_c)

        r_Cu = np.zeros(len(t_s))
        for i in range(len(t_s)):
            r_Cu[i] = r_Cu2O_advanced(temp, pH_fixed, sal_fixed, y_s[i][1]*L_F, y_s[i][0]*L_F) * M_Cu * 10**(-4)
            
        T_ax.plot(t_s[:]*tf_c, r_Cu[:], label=temp_label(temp))

    for sal in sal_vary:
        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp_fixed, sal, pH_fixed)
        
        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp_fixed, pH_fixed, sal)
        tf_c = t_f(r_TBT_c)

        r_Cu = np.zeros(len(t_s))
        for i in range(len(t_s)):
            r_Cu[i] = r_Cu2O_advanced(temp_fixed, pH_fixed, sal, y_s[i][1]*L_F, y_s[i][0]*L_F) * M_Cu * 10**(-4)
            
        sal_ax.plot(t_s[:]*tf_c, r_Cu[:], label=salinity_label(sal))

    for pH in pH_vary:
        sensitivity_model = SENSITIVTY_ANALYSIS_MODEL(temp_fixed, sal_fixed, pH)
        
        t_s, y_s = ODE_solver(z0_s, t0_s, T_end_s, sensitivity_model, Nmax, tol)

        r_TBT_c = r_TBT_advanced(temp_fixed, pH, sal_fixed)
        tf_c = t_f(r_TBT_c)

        r_Cu = np.zeros(len(t_s))
        for i in range(len(t_s)):
            r_Cu[i] = r_Cu2O_advanced(temp_fixed, pH, sal_fixed, y_s[i][1]*L_F, y_s[i][0]*L_F) * M_Cu * 10**(-4)
            
        pH_ax.plot(t_s[:]*tf_c, r_Cu[:], label=pH_label(pH))

    y_lim_upper=20

    T_ax.set(ylim = (0,y_lim_upper))
    T_ax.legend()
    T_ax.grid(True)
    T_ax.set(xlabel=x_label_day, ylabel=release_Cu_label)
    T_ax.set_title("Salinity = " + str(sal_fixed) + " g salt/kg saltwater and pH = " + str(pH_fixed))

    sal_ax.set(ylim=(0, y_lim_upper))
    sal_ax.legend()
    sal_ax.grid(True)
    sal_ax.set(xlabel=x_label_day)
    sal_ax.set_title("T = " + str(temp_fixed-273) + " $^o$C and pH = " + str(pH_fixed))
    
    pH_ax.set(ylim=(0, y_lim_upper))
    pH_ax.legend()
    pH_ax.grid(True)
    pH_ax.set(xlabel=x_label_day)
    pH_ax.set_title("T = " + str(temp_fixed-273) + " $^o$C and salinity = " + str(sal_fixed) + " g salt/kg saltwater")


    plt.show()