-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import ufl | ||
from dolfinx import fem | ||
import festim as F | ||
|
||
|
||
class Material: | ||
""" | ||
Material class | ||
""" | ||
|
||
def __init__(self, D_0=None, E_D=None, name=None) -> None: | ||
"""Inits Material | ||
Args: | ||
D_0 (float): the diffusion coefficient at 0 K | ||
E_D (float): the activation energy for diffusion | ||
name (str): the name of the material | ||
""" | ||
self.D_0 = D_0 | ||
self.E_D = E_D | ||
self.name = name | ||
|
||
def define_diffusion_coefficient(self, mesh, temperature): | ||
"""Defines the diffusion coefficient | ||
Args: | ||
temperature (dolfinx.fem.Constant): the temperature | ||
Returns: | ||
float: the diffusion coefficient | ||
""" | ||
|
||
if isinstance(self.D_0, float): | ||
self.D_0 = fem.Constant(mesh, self.D_0) | ||
if isinstance(self.E_D, float): | ||
self.E_D = fem.Constant(mesh, self.E_D) | ||
|
||
return self.D_0 * ufl.exp(-self.E_D / F.k_B / temperature) | ||