-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #679 from festim-dev/radioactive-decay
Radioactive decay
- Loading branch information
Showing
9 changed files
with
372 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from festim import Source | ||
|
||
|
||
class RadioactiveDecay(Source): | ||
""" | ||
A radioactive decay source. | ||
dc/dt = ... - lambda * c | ||
where lambda is the decay constant in 1/s. | ||
Args: | ||
decay_constant (float): The decay constant of the source in 1/s. | ||
volume (int): The volume of the source. | ||
field (str, optional): The field to which the source is | ||
applied. If "all" the decay will be applied to all | ||
concentrations. Defaults to "all". | ||
""" | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.