Skip to content

Commit d14e191

Browse files
removed special class for species
1 parent c2516b1 commit d14e191

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/festim/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from .reaction import Reaction
5252
from .settings import Settings
5353
from .source import HeatSource, ParticleSource, SourceBase
54-
from .species import ImplicitSpecies, Species, find_species_from_name, SpeciesChangeVar
54+
from .species import ImplicitSpecies, Species, find_species_from_name
5555
from .stepsize import Stepsize
5656
from .subdomain.interface import Interface
5757
from .subdomain.surface_subdomain import SurfaceSubdomain, find_surface_from_id

src/festim/hydrogen_transport_problem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,17 @@ def initialise(self):
861861

862862
self.create_implicit_species_value_fenics()
863863

864+
for species in self.species:
865+
species.change_var = True
866+
864867
self.define_temperature()
865868
self.define_boundary_conditions()
866869
self.create_source_values_fenics()
867870
self.create_flux_values_fenics()
868871
self.create_initial_conditions()
869872
self.create_formulation()
870873
self.create_solver()
871-
self.override_post_processing_solution() # NOTE this is the only difference with parent class
874+
self.override_post_processing_solution()
872875
self.initialise_exports()
873876

874877
def create_formulation(self):

src/festim/species.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Species:
6565
subdomain_to_post_processing_solution: dict
6666
subdomain_to_collapsed_function_space: dict
6767
subdomain_to_function_space: dict
68+
change_var: bool = False
6869

6970
def __init__(self, name: str = None, mobile=True, subdomains=None) -> None:
7071
self.name = name
@@ -92,7 +93,14 @@ def __str__(self) -> str:
9293

9394
@property
9495
def concentration(self):
95-
return self.solution
96+
if self.change_var:
97+
return self._concentration
98+
else:
99+
return self.solution
100+
101+
@concentration.setter
102+
def concentration(self, value):
103+
self._concentration = value
96104

97105
@property
98106
def legacy(self) -> bool:
@@ -225,13 +233,3 @@ def find_species_from_name(name: str, species: list):
225233
if spe.name == name:
226234
return spe
227235
raise ValueError(f"Species {name} not found in list of species")
228-
229-
230-
class SpeciesChangeVar(Species):
231-
@property
232-
def concentration(self):
233-
return self._concentration
234-
235-
@concentration.setter
236-
def concentration(self, value):
237-
self._concentration = value

test/system_tests/test_multi_material_change_of_var.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def test_run():
103103
right_surface,
104104
]
105105

106-
H = F.SpeciesChangeVar("H", mobile=True)
107-
trapped_H = F.SpeciesChangeVar("H_trapped", mobile=False)
106+
H = F.Species("H", mobile=True)
107+
trapped_H = F.Species("H_trapped", mobile=False)
108108
empty_trap = F.ImplicitSpecies(n=0.5, others=[trapped_H])
109109

110110
my_model.species = [H, trapped_H]
@@ -193,7 +193,7 @@ def c_exact_bot_np(x):
193193
bottom_surface,
194194
]
195195

196-
H = F.SpeciesChangeVar("H", mobile=True)
196+
H = F.Species("H", mobile=True)
197197

198198
my_model.species = [H]
199199

0 commit comments

Comments
 (0)