diff --git a/src/openmc_plasma_source/fuel_types.py b/src/openmc_plasma_source/fuel_types.py index e270446..1ca478a 100644 --- a/src/openmc_plasma_source/fuel_types.py +++ b/src/openmc_plasma_source/fuel_types.py @@ -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, @@ -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) @@ -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) diff --git a/src/openmc_plasma_source/tokamak_source.py b/src/openmc_plasma_source/tokamak_source.py index 338b121..033a2b8 100644 --- a/src/openmc_plasma_source/tokamak_source.py +++ b/src/openmc_plasma_source/tokamak_source.py @@ -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( @@ -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, @@ -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 @@ -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,