Skip to content

Commit

Permalink
Merge pull request #534 from RemDelaporteMathurin/neutron_trap_fix
Browse files Browse the repository at this point in the history
Don't know what the drop in coverage is due to... merging this! thanks James
  • Loading branch information
RemDelaporteMathurin authored Dec 19, 2022
2 parents df01a38 + c71ebf6 commit a8e5022
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion festim/concentration/traps/neutron_induced_trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NeutronInducedTrap(ExtrinsicTrapBase):
Class for neutron induced trap creation with annealing.
The temporal evolution of the trap density is given by
dn_t/dt = phi*K*(1 - n_t/n_max) + A_0*exp(-E_A/(k_B*T))*n_t
dn_t/dt = phi*K*(1 - n_t/n_max) - A_0*exp(-E_A/(k_B*T))*n_t
Args:
k_0 (float, list): trapping pre-exponential factor (m3 s-1)
Expand Down Expand Up @@ -55,6 +55,7 @@ def __init__(
A_0=A_0,
E_A=E_A,
id=id,
**kwargs,
)

def create_form_density(self, dx, dt, T):
Expand Down
45 changes: 45 additions & 0 deletions test/unit/test_traps/test_neutron_induced_trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,48 @@ def test_create_form_density(self):
print(expected_form)
print(self.my_trap.form_density)
assert self.my_trap.form_density.equals(expected_form)


class TestNeutronInducedTrapSolverParameters:
"""
Test for NeutronInducedTrap class, with defined ExtrinsicTrapBase
solver parameters
"""

my_trap = festim.NeutronInducedTrap(
1,
1,
1,
1,
"mat_name",
phi=1,
K=2,
n_max=3,
A_0=4,
E_A=5,
absolute_tolerance=2.5,
relative_tolerance=1.2e-10,
maximum_iterations=13,
linear_solver="mumps",
)

def test_attributes_from_instanciation(self):
"""
Tests the solver paramters are assigned and ensures that
the default values have been updated
"""

assert self.my_trap.absolute_tolerance == 2.5
assert self.my_trap.relative_tolerance == 1.2e-10
assert self.my_trap.maximum_iterations == 13
assert self.my_trap.linear_solver == "mumps"

def test_attributes_change_since_instanciation(self):
"""
Test to ensure values can be updated after instanciation
"""

expected_tolerance = 3.6
self.my_trap.absolute_tolerance = 3.6

assert self.my_trap.absolute_tolerance == expected_tolerance

0 comments on commit a8e5022

Please sign in to comment.