Skip to content

Commit

Permalink
process temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Oct 11, 2023
1 parent 4dd4c50 commit 17aa043
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions festim/hydrogen_transport_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HydrogenTransportProblem:
mesh (festim.Mesh): the mesh of the model
subdomains (list of festim.Subdomain): the subdomains of the model
species (list of festim.Species): the species of the model
temperature (float or dolfinx.Function): the temperature of the model
temperature (float or fem.Constant): the temperature of the model
sources (list of festim.Source): the hydrogen sources of the model
boundary_conditions (list of festim.BoundaryCondition): the boundary conditions of the model
solver_parameters (dict): the solver parameters of the model
Expand All @@ -28,7 +28,7 @@ class HydrogenTransportProblem:
mesh (festim.Mesh): the mesh of the model
subdomains (list of festim.Subdomain): the subdomains of the model
species (list of festim.Species): the species of the model
temperature (float or dolfinx.Function): the temperature of the model
temperature (float or fem.Constant): the temperature of the model
boundary_conditions (list of festim.BoundaryCondition): the boundary conditions of the model
solver_parameters (dict): the solver parameters of the model
exports (list of festim.Export): the exports of the model
Expand Down Expand Up @@ -98,6 +98,17 @@ def initialise(self):
self.define_markers_and_measures()
self.assign_functions_to_species()

if isinstance(self.temperature, float):
self.temperature = fem.Constant(self.mesh.mesh, self.temperature)

Check warning on line 102 in festim/hydrogen_transport_problem.py

View check run for this annotation

Codecov / codecov/patch

festim/hydrogen_transport_problem.py#L102

Added line #L102 was not covered by tests
elif isinstance(self.temperature, fem.Constant):
pass
elif self.temperature is None:
raise ValueError("Temperature not defined")

Check warning on line 106 in festim/hydrogen_transport_problem.py

View check run for this annotation

Codecov / codecov/patch

festim/hydrogen_transport_problem.py#L105-L106

Added lines #L105 - L106 were not covered by tests
else:
raise TypeError(

Check warning on line 108 in festim/hydrogen_transport_problem.py

View check run for this annotation

Codecov / codecov/patch

festim/hydrogen_transport_problem.py#L108

Added line #L108 was not covered by tests
f"Temperature must be float or dolfinx.Constant, not {type(self.temperature)}"
)

self.volume_subdomains = []
for sub_dom in self.subdomains:
if isinstance(sub_dom, F.VolumeSubdomain1D):
Expand Down

0 comments on commit 17aa043

Please sign in to comment.