Skip to content

Commit

Permalink
Merge pull request #822 from festim-dev/fix_821
Browse files Browse the repository at this point in the history
Assign traps ids before
  • Loading branch information
RemDelaporteMathurin authored Jul 26, 2024
2 parents b884fdf + 95c1740 commit 4cf700b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion festim/h_transport_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ def initialise(self, mesh, materials, dt=None):
self.mobile.T = self.T
self.attribute_flux_boundary_conditions()

self.traps.assign_traps_ids()

# Define functions
self.define_function_space(mesh)
self.initialise_concentrations()
self.traps.assign_traps_ids()
self.traps.make_traps_materials(materials)
self.traps.initialise_extrinsic_traps(self.V_CG1)

Expand Down
37 changes: 37 additions & 0 deletions test/simulation/test_initialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,40 @@ def test_error_raised_when_no_final_time():

with pytest.raises(AttributeError, match="final_time argument must be provided"):
my_model.initialise()


def test_initial_concentration_traps():
"""test to catch #821"""
model = F.Simulation()

model.mesh = F.MeshFromVertices([0, 1, 2, 3])

model.materials = F.Material(id=1, D_0=1, E_D=0)

trap = F.Trap(
k_0=2,
E_k=0,
p_0=1,
E_p=0,
density=3,
materials=model.materials[0],
)
model.traps = F.Traps([trap])

model.initial_conditions = [
F.InitialCondition(field="1", value=2),
]

model.T = F.Temperature(300)

model.dt = F.Stepsize(
initial_value=1,
)

model.settings = F.Settings(
absolute_tolerance=1e-10,
relative_tolerance=1e-10,
final_time=10,
)

model.initialise()

0 comments on commit 4cf700b

Please sign in to comment.