Skip to content

Commit

Permalink
add unique variable names for activation energies
Browse files Browse the repository at this point in the history
  • Loading branch information
darryl-ad committed Aug 7, 2023
1 parent f0cc984 commit dfdfb32
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions pybamm/parameters/bpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _positive_electrode_entropic_change(sto, c_s_max):
k_n_norm = pybamm_dict[
negative_electrode.pre_name + "reaction rate constant [mol.m-2.s-1]"
]
E_a_n = pybamm_dict.get(
Ea_k_n = pybamm_dict.get(
negative_electrode.pre_name + "reaction rate activation energy [J.mol-1]", 0.0
)
# Note that in BPX j = 2*F*k_norm*sqrt((ce/ce0)*(c/c_max)*(1-c/c_max))*sinh(...),
Expand All @@ -270,7 +270,7 @@ def _positive_electrode_entropic_change(sto, c_s_max):
def _negative_electrode_exchange_current_density(c_e, c_s_surf, c_s_max, T):
k_ref = k_n # (A/m2)(m3/mol)**1.5 - includes ref concentrations

arrhenius = exp(E_a_n / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_k_n / constants.R * (1 / T_ref - 1 / T))
return (
k_ref
* arrhenius
Expand All @@ -290,7 +290,7 @@ def _negative_electrode_exchange_current_density(c_e, c_s_surf, c_s_max, T):
k_p_norm = pybamm_dict[
positive_electrode.pre_name + "reaction rate constant [mol.m-2.s-1]"
]
E_a_p = pybamm_dict.get(
Ea_k_p = pybamm_dict.get(
positive_electrode.pre_name + "reaction rate activation energy [J.mol-1]", 0.0
)
# Note that in BPX j = 2*F*k_norm*sqrt((ce/ce0)*(c/c_max)*(1-c/c_max))*sinh(...),
Expand All @@ -300,7 +300,7 @@ def _negative_electrode_exchange_current_density(c_e, c_s_surf, c_s_max, T):
def _positive_electrode_exchange_current_density(c_e, c_s_surf, c_s_max, T):
k_ref = k_p # (A/m2)(m3/mol)**1.5 - includes ref concentrations

arrhenius = exp(E_a_p / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_k_p / constants.R * (1 / T_ref - 1 / T))
return (
k_ref
* arrhenius
Expand All @@ -316,21 +316,21 @@ def _positive_electrode_exchange_current_density(c_e, c_s_surf, c_s_max, T):
# diffusivity

# negative electrode
E_a = pybamm_dict.get(
Ea_D_n = pybamm_dict.get(
negative_electrode.pre_name + "diffusivity activation energy [J.mol-1]", 0.0
)
D_n_ref = pybamm_dict[negative_electrode.pre_name + "diffusivity [m2.s-1]"]

if callable(D_n_ref):

def _negative_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_n / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_n_ref(sto)

elif isinstance(D_n_ref, tuple):

def _negative_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_n / constants.R * (1 / T_ref - 1 / T))
name, (x, y) = D_n_ref
return arrhenius * pybamm.Interpolant(
x, y, sto, name=name, interpolator="linear"
Expand All @@ -339,29 +339,29 @@ def _negative_electrode_diffusivity(sto, T):
else:

def _negative_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_n / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_n_ref

pybamm_dict[negative_electrode.pre_name + "diffusivity [m2.s-1]"] = _copy_func(
_negative_electrode_diffusivity
)

# positive electrode
E_a = pybamm_dict.get(
Ea_D_p = pybamm_dict.get(
positive_electrode.pre_name + "diffusivity activation energy [J.mol-1]", 0.0
)
D_p_ref = pybamm_dict[positive_electrode.pre_name + "diffusivity [m2.s-1]"]

if callable(D_p_ref):

def _positive_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_p / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_p_ref(sto)

elif isinstance(D_p_ref, tuple):

def _positive_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_p / constants.R * (1 / T_ref - 1 / T))
name, (x, y) = D_p_ref
return arrhenius * pybamm.Interpolant(
x, y, sto, name=name, interpolator="linear"
Expand All @@ -370,29 +370,29 @@ def _positive_electrode_diffusivity(sto, T):
else:

def _positive_electrode_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_p / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_p_ref

pybamm_dict[positive_electrode.pre_name + "diffusivity [m2.s-1]"] = _copy_func(
_positive_electrode_diffusivity
)

# electrolyte
E_a = pybamm_dict.get(
Ea_D_e = pybamm_dict.get(
electrolyte.pre_name + "diffusivity activation energy [J.mol-1]", 0.0
)
D_e_ref = pybamm_dict[electrolyte.pre_name + "diffusivity [m2.s-1]"]

if callable(D_e_ref):

def _electrolyte_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_e / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_e_ref(sto)

elif isinstance(D_e_ref, tuple):

def _electrolyte_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_e / constants.R * (1 / T_ref - 1 / T))
name, (x, y) = D_e_ref
return arrhenius * pybamm.Interpolant(
x, y, sto, name=name, interpolator="linear"
Expand All @@ -401,39 +401,39 @@ def _electrolyte_diffusivity(sto, T):
else:

def _electrolyte_diffusivity(sto, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
arrhenius = exp(Ea_D_e / constants.R * (1 / T_ref - 1 / T))
return arrhenius * D_e_ref

pybamm_dict[electrolyte.pre_name + "diffusivity [m2.s-1]"] = _copy_func(
_electrolyte_diffusivity
)

# conductivity
E_a = pybamm_dict.get(
Ea_sigma_e = pybamm_dict.get(
electrolyte.pre_name + "conductivity activation energy [J.mol-1]", 0.0
)
C_e_ref = pybamm_dict[electrolyte.pre_name + "conductivity [S.m-1]"]
sigma_e_ref = pybamm_dict[electrolyte.pre_name + "conductivity [S.m-1]"]

if callable(C_e_ref):
if callable(sigma_e_ref):

def _conductivity(c_e, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
return arrhenius * C_e_ref(c_e)
arrhenius = exp(Ea_sigma_e / constants.R * (1 / T_ref - 1 / T))
return arrhenius * sigma_e_ref(c_e)

elif isinstance(C_e_ref, tuple):
elif isinstance(sigma_e_ref, tuple):

def _conductivity(c_e, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
name, (x, y) = C_e_ref
arrhenius = exp(Ea_sigma_e / constants.R * (1 / T_ref - 1 / T))
name, (x, y) = sigma_e_ref
return arrhenius * pybamm.Interpolant(
x, y, c_e, name=name, interpolator="linear"
)

else:

def _conductivity(c_e, T):
arrhenius = exp(E_a / constants.R * (1 / T_ref - 1 / T))
return arrhenius * C_e_ref
arrhenius = exp(Ea_sigma_e / constants.R * (1 / T_ref - 1 / T))
return arrhenius * sigma_e_ref

pybamm_dict[electrolyte.pre_name + "conductivity [S.m-1]"] = _copy_func(
_conductivity
Expand Down

0 comments on commit dfdfb32

Please sign in to comment.