Skip to content

Commit

Permalink
added setter and getter for decay constant
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Jan 15, 2024
1 parent 4132ad8 commit f003704
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions festim/sources/radioactive_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,17 @@ def __init__(self, decay_constant, volume, field="all") -> None:
self.decay_constant = decay_constant
super().__init__(value=None, volume=volume, field=field)

@property
def decay_constant(self):
return self._decay_constant

@decay_constant.setter
def decay_constant(self, value):
if not isinstance(value, (float, int)):
raise TypeError("decay_constant must be a float or an int")
if value <= 0:
raise ValueError("decay_constant must be positive")
self._decay_constant = value

def form(self, concentration):
return self.decay_constant * concentration

0 comments on commit f003704

Please sign in to comment.