Skip to content

Commit

Permalink
[skip ci] Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell authored and github-actions[bot] committed Apr 2, 2024
1 parent 479eddb commit d1695ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/openmc_plasma_source/fuel_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ def neutron_energy_std_dev(ion_temperature: float, reaction: str) -> float:
return std_dev



def get_reactions_from_fuel(fuel):
if ["D", "T"] == sorted(set(fuel.keys())):
return ['DT', 'DD', 'TT']
return ["DT", "DD", "TT"]
elif ["D"] == sorted(set(fuel.keys())):
return ['DD']
return ["DD"]
elif ["T"] == sorted(set(fuel.keys())):
return ['TT']
return ["TT"]
else:
msg = 'reactions of fuel {fuel} could not be found. Supported fuel keys are "T" and "D"'
raise ValueError(msg)


def get_neutron_energy_distribution(
ion_temperature: float,
fuel: dict,
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_neutron_energy_distribution(

reactions = get_reactions_from_fuel(fuel)

if reactions == ['TT']:
if reactions == ["TT"]:
strength_TT = 1.0
dNdE_TT = strength_TT * nst.dNdE_TT(E_pspec, ion_temperature)
tt_source = openmc.stats.Tabular(E_pspec * 1e6, dNdE_TT)
Expand All @@ -186,9 +186,9 @@ def get_neutron_energy_distribution(
dNdE_TT = strength_TT * nst.dNdE_TT(E_pspec, ion_temperature)

# removing any zeros from the end of the array
dNdE_TT = np.trim_zeros(dNdE_TT, 'b')
dNdE_TT = np.trim_zeros(dNdE_TT, "b")
# making array lengths match
E_pspec = E_pspec[:len(dNdE_TT)]
E_pspec = E_pspec[: len(dNdE_TT)]

tt_source = openmc.stats.Tabular(E_pspec, dNdE_TT)

Expand Down
23 changes: 13 additions & 10 deletions src/openmc_plasma_source/tokamak_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def tokamak_source(

fuel_densities = {}
for key, value in fuel.items():
fuel_densities[key] = densities*value
fuel_densities[key] = densities * value

# compute temperatures
temperatures = tokamak_ion_temperature(
Expand All @@ -158,11 +158,12 @@ def tokamak_source(
elongation=elongation,
)

neutron_source_density = tokamak_neutron_source_density(fuel_densities, temperatures, reaction)
neutron_source_density = tokamak_neutron_source_density(
fuel_densities, temperatures, reaction
)

strengths = neutron_source_density / sum(neutron_source_density)


sources = tokamak_make_openmc_sources(
strengths=strengths,
angles=angles,
Expand Down Expand Up @@ -380,18 +381,20 @@ def tokamak_neutron_source_density(ion_density, ion_temperature, reaction):
float, ndarray: Neutron source density (neutron/s/m3)
"""

ion_density = np.asarray(ion_density[reaction[0]]) * np.asarray(ion_density[reaction[1]])
ion_density = np.asarray(ion_density[reaction[0]]) * np.asarray(
ion_density[reaction[1]]
)
ion_temperature = np.asarray(ion_temperature)

if reaction == 'DT':
return ion_density * nst.reac_DT(ion_temperature) # could use _DT_xs instead
if reaction == 'DD':
if reaction == "DT":
return ion_density * nst.reac_DT(ion_temperature) # could use _DT_xs instead
if reaction == "DD":
return ion_density * nst.reac_DD(ion_temperature)
if reaction == 'TT':
if reaction == "TT":
return ion_density * nst.reac_TT(ion_temperature)


#TODO consider replace with NeSST or getting DD version as well
# TODO consider replace with NeSST or getting DD version as well
def _DT_xs(ion_temperature):
"""Sadler–Van Belle formula
Ref : https://doi.org/10.1016/j.fusengdes.2012.02.025
Expand All @@ -400,7 +403,7 @@ def _DT_xs(ion_temperature):
Returns:
float, ndarray: the DT cross section at the given temperature
"""
ion_temperature_kev = np.asarray(ion_temperature/1e3)
ion_temperature_kev = np.asarray(ion_temperature / 1e3)
c = [
2.5663271e-18,
19.983026,
Expand Down

0 comments on commit d1695ef

Please sign in to comment.