RemDelaporteMathurin / h-transport-materials

:bar_chart: Easily access hydrogen transport properties
https://h-transport-materials.readthedocs.io
MIT License
13 stars 11 forks source link

Feature: predict permeation plot #109

Open RemDelaporteMathurin opened 1 year ago

RemDelaporteMathurin commented 1 year ago

Users should be able to predict a permeation plot for a given sample (material and thickness) at a given temperature and upstream pressure.

Something like:

plot_permeation(material="tungsten", temperature=600, upstream_pressure= ...)

plt.show()
RemDelaporteMathurin commented 1 year ago
def downstream_flux(t, P_up, permeability, L, D):
    """calculates the downstream H flux at a given time t

    Args:
        t (float, np.array): the time
        P_up (float): upstream partial pressure of H
        permeability (float): salt permeability
        L (float): salt thickness
        D (float): diffusivity of H in the salt

    Returns:
        float, np.array: the downstream flux of H
    """
    n_array = np.arange(1, 10000)[:, np.newaxis]
    summation = np.sum((-1)**n_array * np.exp(-(np.pi * n_array)**2 * D/L**2 * t), axis=0)
    return P_up * permeability / L * (2*summation + 1)
def downstream_pressure(t, P_up, diff, sol):

    tau = L**2 / (6 * diff)
    sum_term = 0
    n = np.arange(1, 10000)[:, np.newaxis]
    sum_term = np.sum(
        (-1) ** (n+1) / n**2 * np.exp(-diff * n**2 * np.pi**2 * t / L**2),
        axis=0
    )

    transient_term = 2 * L**2 / (np.pi**2 * diff) * sum_term
    return Rg * T / V_down * A / L * diff * sol * P_up * (t - tau + transient_term)