Skip to content

Commit

Permalink
always add trapping term
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Jan 16, 2024
1 parent 8679056 commit 9d26ac3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
63 changes: 31 additions & 32 deletions festim/concentration/mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,38 +106,37 @@ def create_diffusion_form(

# add the trapping terms
F_trapping = 0
if dt is not None:
if traps is not None:
for trap in traps.traps:
for i, mat in enumerate(trap.materials):
if type(trap.k_0) is list:
k_0 = trap.k_0[i]
E_k = trap.E_k[i]
p_0 = trap.p_0[i]
E_p = trap.E_p[i]
density = trap.density[i]
else:
k_0 = trap.k_0
E_k = trap.E_k
p_0 = trap.p_0
E_p = trap.E_p
density = trap.density[0]
c_m, _ = self.get_concentration_for_a_given_material(mat, T)
F_trapping += (
-k_0
* exp(-E_k / k_B / T.T)
* c_m
* (density - trap.solution)
* self.test_function
* dx(mat.id)
)
F_trapping += (
p_0
* exp(-E_p / k_B / T.T)
* trap.solution
* self.test_function
* dx(mat.id)
)
if traps is not None:
for trap in traps.traps:
for i, mat in enumerate(trap.materials):
if type(trap.k_0) is list:
k_0 = trap.k_0[i]
E_k = trap.E_k[i]
p_0 = trap.p_0[i]
E_p = trap.E_p[i]
density = trap.density[i]

Check warning on line 117 in festim/concentration/mobile.py

View check run for this annotation

Codecov / codecov/patch

festim/concentration/mobile.py#L113-L117

Added lines #L113 - L117 were not covered by tests
else:
k_0 = trap.k_0
E_k = trap.E_k
p_0 = trap.p_0
E_p = trap.E_p
density = trap.density[0]
c_m, _ = self.get_concentration_for_a_given_material(mat, T)
F_trapping += (
-k_0
* exp(-E_k / k_B / T.T)
* c_m
* (density - trap.solution)
* self.test_function
* dx(mat.id)
)
F_trapping += (
p_0
* exp(-E_p / k_B / T.T)
* trap.solution
* self.test_function
* dx(mat.id)
)
F += -F_trapping

self.F_diffusion = F
Expand Down
7 changes: 3 additions & 4 deletions test/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,11 @@ def test_run_MMS_steady_state(tmpdir):
k = k_0 * sp.exp(-E_k / k_B / T)

f = (
sp.diff(u, festim.t)
+ sp.diff(v, festim.t)
- D * sp.diff(u, festim.x, 2)
-D * sp.diff(u, festim.x, 2)
- sp.diff(D, festim.x) * sp.diff(u, festim.x)
- (p * v - k * u * (n_trap - v))
)
g = sp.diff(v, festim.t) + p * v - k * u * (n_trap - v)
g = p * v - k * u * (n_trap - v)

def run(h):
my_materials = festim.Materials(
Expand Down

0 comments on commit 9d26ac3

Please sign in to comment.