-
Notifications
You must be signed in to change notification settings - Fork 12
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 #58 from fusion-energy/develop
replacing propert-tea with params
- Loading branch information
Showing
15 changed files
with
836 additions
and
377 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,3 +134,6 @@ dmypy.json | |
|
||
# vim swap files | ||
*.swp | ||
|
||
# image files created by tests | ||
tests/*.png |
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,26 @@ | ||
"""fuel_types.py | ||
Defines dictionary for determining mean energy and mass of reactants | ||
for a given fusion fuel type. | ||
""" | ||
|
||
from param import Parameterized, Number | ||
|
||
|
||
class Fuel(Parameterized): | ||
|
||
# mean energy, eV | ||
mean_energy = Number(None, bounds=(0, None), inclusive_bounds=(False, False)) | ||
|
||
# mass of the reactants, AMU | ||
mass_of_reactants = Number(None, bounds=(0, None), inclusive_bounds=(False, False)) | ||
|
||
def __init__(self, mean_energy, mass_of_reactants): | ||
self.mean_energy = mean_energy | ||
self.mass_of_reactants = mass_of_reactants | ||
|
||
|
||
fuel_types = { | ||
"DD": Fuel(mean_energy=2450000.0, mass_of_reactants=4), | ||
"DT": Fuel(mean_energy=14080000.0, mass_of_reactants=5), | ||
} |
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 |
---|---|---|
@@ -1,35 +1,47 @@ | ||
import openmc | ||
from typing import Tuple | ||
from param import Parameterized, Number, NumericTuple, ListSelector | ||
|
||
import openmc | ||
from .fuel_types import fuel_types | ||
|
||
|
||
class FusionPointSource(openmc.Source): | ||
class FusionPointSource(openmc.Source, Parameterized): | ||
"""An openmc.Source object with some presets to make it more convenient | ||
for fusion simulations using a point source. All attributes can be changed | ||
after initialization if required. Default isotropic point source at the | ||
origin with a Muir energy distribution. | ||
Args: | ||
coordinate (tuple[float,float,float]): Location of the point source. | ||
Each component is measured in metres. | ||
temperature (float): Temperature of the source (eV). | ||
fuel_type (str): The fusion fuel mix. Either 'DT' or 'DD'. | ||
""" | ||
|
||
coordinate = NumericTuple(None, length=3) | ||
temperature = Number(None, bounds=(0, None)) # temperature in eV | ||
fuel_type = ListSelector(fuel_types.keys()) | ||
|
||
def __init__( | ||
self, | ||
coordinate: Tuple[float, float, float] = (0, 0, 0), | ||
temperature: float = 20000.0, | ||
fuel: str = "DT", | ||
): | ||
# Set local attributes | ||
self.coordinate = coordinate | ||
self.temperature = temperature | ||
self.fuel_type = fuel | ||
self.fuel = fuel_types[self.fuel_type] | ||
|
||
# Call init for openmc.Source | ||
super().__init__() | ||
|
||
# performed after the super init as these are Source attributes | ||
self.space = openmc.stats.Point(coordinate) | ||
self.space = openmc.stats.Point(self.coordinate) | ||
self.angle = openmc.stats.Isotropic() | ||
if fuel == "DT": | ||
mean_energy = 14080000.0 # mean energy in eV | ||
mass_of_reactants = 5 # mass of the reactants (D + T) AMU | ||
elif fuel == "DD": | ||
mean_energy = 2450000.0 # mean energy in eV | ||
mass_of_reactants = 4 # mass of the reactants (D + D) AMU | ||
else: | ||
raise ValueError(f'fuel must be either "DT" or "DD", not {fuel}') | ||
self.energy = openmc.stats.Muir( | ||
e0=mean_energy, m_rat=mass_of_reactants, kt=temperature | ||
e0=self.fuel.mean_energy, | ||
m_rat=self.fuel.mass_of_reactants, | ||
kt=self.temperature, | ||
) |
Oops, something went wrong.