-
Notifications
You must be signed in to change notification settings - Fork 11
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 #107 from fusion-energy/rem/refactoring
Refactoring and tidy up
- Loading branch information
Showing
6 changed files
with
212 additions
and
161 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 |
---|---|---|
@@ -1,51 +1,52 @@ | ||
from typing import Tuple | ||
|
||
import openmc | ||
import openmc.stats | ||
from openmc import IndependentSource | ||
|
||
from .fuel_types import get_neutron_energy_distribution | ||
|
||
from typing import Dict, List | ||
|
||
|
||
def fusion_point_source( | ||
coordinate: Tuple[float, float, float] = (0.0, 0.0, 0.0), | ||
temperature: float = 20000.0, | ||
fuel: dict = {"D": 0.5, "T": 0.5}, | ||
) -> list[openmc.IndependentSource]: | ||
fuel: Dict[str, float] = {"D": 0.5, "T": 0.5}, | ||
) -> List[IndependentSource]: | ||
"""Creates a list of openmc.IndependentSource objects representing an ICF source. | ||
Resulting ICF (Inertial Confinement Fusion) source will have an energy | ||
distribution according to the fuel composition. | ||
Args: | ||
coordinate (tuple[float,float,float]): Location of the point source. | ||
coordinate: Location of the point source. | ||
Each component is measured in metres. | ||
temperature (float): Temperature of the source (eV). | ||
fuel (dict): Isotopes as keys and atom fractions as values | ||
temperature: Temperature of the source (eV). | ||
fuel: Isotopes as keys and atom fractions as values | ||
Returns: | ||
A list of one openmc.IndependentSource instance. | ||
""" | ||
|
||
if ( | ||
if not ( | ||
isinstance(coordinate, tuple) | ||
and len(coordinate) == 3 | ||
and all(isinstance(x, (int, float)) for x in coordinate) | ||
): | ||
pass | ||
else: | ||
raise ValueError("coordinate must be a tuple of three floats.") | ||
|
||
if not isinstance(temperature, (int, float)): | ||
raise ValueError("Temperature must be a float.") | ||
if temperature <= 0: | ||
raise ValueError("Temperature must be positive float.") | ||
|
||
sources = [] | ||
source = openmc.IndependentSource() | ||
|
||
energy_distribution = get_neutron_energy_distribution( | ||
ion_temperature=temperature, fuel=fuel | ||
) | ||
|
||
source = openmc.IndependentSource() | ||
source.energy = energy_distribution | ||
source.space = openmc.stats.Point(coordinate) | ||
source.angle = openmc.stats.Isotropic() | ||
sources.append(source) | ||
|
||
return sources | ||
return [source] |
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.