#author: Riley Doyle
#date: 7/16/20
#file: calc_CO2_loss_alk
#status:working

import numpy as np
import matplotlib.pyplot as plt
from calc_Ks import *
from calc_alphas import *


def calc_CO2_loss_alk (pK1, pK2, Kh, pH, d, PCO2, alkin, alkend, delalk, kLain, kLaend, delkLa):
    L = np.array(['-', '--', '-.', ':', '--'])
    alk = np.arange(alkin, alkend, delalk)
    kLasteps = np.arange(kLain, kLaend, delkLa)
    nkLasteps = len(kLasteps)
    y = np.zeros((nkLasteps, len(alk)))
    i = 0
    for c in kLasteps:
        alpha0 = calc_alpha0(pH, pK1, pK2)
        alpha1 = calc_alpha1(pH, pK1, pK2)
        alpha2 = calc_alpha2(pH, pK1, pK2)
        CO2sat = PCO2*Kh*1000
            
        H = 10**(-pH)
        OH = 10**(-(14-pH))
        bt = (1/(alpha1 + (2*alpha2)))
        tp = (alk - OH + H)
        CT = tp * bt
            
        H2CO3 = alpha0*CT
        y[i,:] = c*(H2CO3 - CO2sat)*24*44
        y = y*d
        plt.plot(alk, y[i,:].T, linestyle=L[i])
        i += 1
af9db97c3b3f2a8d21e4b76025497f20bba11a6f
<mask token>

<mask token>


def calc_CO2_loss_alk(pK1, pK2, Kh, pH, d, PCO2, alkin, alkend, delalk,
    kLain, kLaend, delkLa):
    L = np.array(['-', '--', '-.', ':', '--'])
    alk = np.arange(alkin, alkend, delalk)
    kLasteps = np.arange(kLain, kLaend, delkLa)
    nkLasteps = len(kLasteps)
    y = np.zeros((nkLasteps, len(alk)))
    i = 0
    for c in kLasteps:
        alpha0 = calc_alpha0(pH, pK1, pK2)
        alpha1 = calc_alpha1(pH, pK1, pK2)
        alpha2 = calc_alpha2(pH, pK1, pK2)
        CO2sat = PCO2 * Kh * 1000
        H = 10 ** -pH
        OH = 10 ** -(14 - pH)
        bt = 1 / (alpha1 + 2 * alpha2)
        tp = alk - OH + H
        CT = tp * bt
        H2CO3 = alpha0 * CT
        y[i, :] = c * (H2CO3 - CO2sat) * 24 * 44
        y = y * d
        plt.plot(alk, y[i, :].T, linestyle=L[i])
        i += 1

import numpy as np
import matplotlib.pyplot as plt
from calc_Ks import *
from calc_alphas import *


def calc_CO2_loss_alk(pK1, pK2, Kh, pH, d, PCO2, alkin, alkend, delalk,
    kLain, kLaend, delkLa):
    L = np.array(['-', '--', '-.', ':', '--'])
    alk = np.arange(alkin, alkend, delalk)
    kLasteps = np.arange(kLain, kLaend, delkLa)
    nkLasteps = len(kLasteps)
    y = np.zeros((nkLasteps, len(alk)))
    i = 0
    for c in kLasteps:
        alpha0 = calc_alpha0(pH, pK1, pK2)
        alpha1 = calc_alpha1(pH, pK1, pK2)
        alpha2 = calc_alpha2(pH, pK1, pK2)
        CO2sat = PCO2 * Kh * 1000
        H = 10 ** -pH
        OH = 10 ** -(14 - pH)
        bt = 1 / (alpha1 + 2 * alpha2)
        tp = alk - OH + H
        CT = tp * bt
        H2CO3 = alpha0 * CT
        y[i, :] = c * (H2CO3 - CO2sat) * 24 * 44
        y = y * d
        plt.plot(alk, y[i, :].T, linestyle=L[i])
        i += 1

#author: Riley Doyle
#date: 7/16/20
#file: calc_CO2_loss_alk
#status:working

import numpy as np
import matplotlib.pyplot as plt
from calc_Ks import *
from calc_alphas import *


def calc_CO2_loss_alk (pK1, pK2, Kh, pH, d, PCO2, alkin, alkend, delalk, kLain, kLaend, delkLa):
    L = np.array(['-', '--', '-.', ':', '--'])
    alk = np.arange(alkin, alkend, delalk)
    kLasteps = np.arange(kLain, kLaend, delkLa)
    nkLasteps = len(kLasteps)
    y = np.zeros((nkLasteps, len(alk)))
    i = 0
    for c in kLasteps:
        alpha0 = calc_alpha0(pH, pK1, pK2)
        alpha1 = calc_alpha1(pH, pK1, pK2)
        alpha2 = calc_alpha2(pH, pK1, pK2)
        CO2sat = PCO2*Kh*1000
            
        H = 10**(-pH)
        OH = 10**(-(14-pH))
        bt = (1/(alpha1 + (2*alpha2)))
        tp = (alk - OH + H)
        CT = tp * bt
            
        H2CO3 = alpha0*CT
        y[i,:] = c*(H2CO3 - CO2sat)*24*44
        y = y*d
        plt.plot(alk, y[i,:].T, linestyle=L[i])
        i += 1