Skip to content

Commit

Permalink
get_K_S_0 and get_E_K_S
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Oct 30, 2024
1 parent 14c7455 commit ce8cc87
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion src/festim/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,58 @@ def get_E_D(self, species=None):
else:
raise TypeError("E_D must be either a float, int or a dict")

def get_K_S_0(self, species=None) -> float:
"""Returns the pre-exponential factor of the solubility coefficient
Args:
species: the species we want the pre-exponential
factor of the solubility coefficient of. Only needed if K_S_0 is a dict.
Returns:
the pre-exponential factor of the solubility coefficient
"""

if isinstance(self.K_S_0, (float, int)):
return self.K_S_0

Check warning on line 131 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L130-L131

Added lines #L130 - L131 were not covered by tests

elif isinstance(self.K_S_0, dict):
if species is None:
raise ValueError("species must be provided if K_S_0 is a dict")

Check warning on line 135 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L133-L135

Added lines #L133 - L135 were not covered by tests

if species in self.K_S_0:
return self.K_S_0[species]
elif species.name in self.K_S_0:
return self.K_S_0[species.name]

Check warning on line 140 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L137-L140

Added lines #L137 - L140 were not covered by tests
else:
raise ValueError(f"{species} is not in K_S_0 keys")

Check warning on line 142 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L142

Added line #L142 was not covered by tests

else:
raise TypeError("K_S_0 must be either a float, int or a dict")

Check warning on line 145 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L145

Added line #L145 was not covered by tests

def get_E_K_S(self, species=None) -> float:
"""Returns the activation energy of the solubility coefficient
Args:
species: the species we want the activation
energy of the solubility coefficient of. Only needed if E_K_S is a dict.
Returns:
the activation energy of the solubility coefficient
"""

if isinstance(self.E_K_S, (float, int)):
return self.E_K_S

Check warning on line 157 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L156-L157

Added lines #L156 - L157 were not covered by tests

elif isinstance(self.E_K_S, dict):
if species is None:
raise ValueError("species must be provided if E_K_S is a dict")

Check warning on line 161 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L159-L161

Added lines #L159 - L161 were not covered by tests

if species in self.E_K_S:
return self.E_K_S[species]
elif species.name in self.E_K_S:
return self.E_K_S[species.name]

Check warning on line 166 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L163-L166

Added lines #L163 - L166 were not covered by tests
else:
raise ValueError(f"{species} is not in E_K_S keys")

Check warning on line 168 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L168

Added line #L168 was not covered by tests

else:
raise TypeError("E_K_S must be either a float, int or a dict")

Check warning on line 171 in src/festim/material.py

View check run for this annotation

Codecov / codecov/patch

src/festim/material.py#L171

Added line #L171 was not covered by tests

def get_diffusion_coefficient(self, mesh, temperature, species=None):
"""Defines the diffusion coefficient
Args:
Expand Down Expand Up @@ -181,7 +233,7 @@ def get_solubility_coefficient(self, mesh, temperature, species=None):
Returns:
ufl.algebra.Product: the solubility coefficient
"""
# TODO use get_D_0 and get_E_D to refactore this method, something like:
# TODO use get_K_S0 and get_E_K_S to refactore this method, something like:
# K_S_0 = self.get_K_S_0(species=species)
# E_K_S = self.get_E_K_S(species=species)

Expand Down

0 comments on commit ce8cc87

Please sign in to comment.