Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Aug 1, 2024
2 parents 280068a + c4d4e6c commit 9856fc7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/plot_tokamak_neutron_source_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
r=a,
)

neutron_source_density = tokamak_neutron_source_density(densities, temperatures, 'DD')
neutron_source_density = tokamak_neutron_source_density(densities, temperatures, "DD")

RZ = tokamak_convert_a_alpha_to_R_Z(
a=a,
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_tokamak_neutron_source_strengths.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
r=a,
)

neutron_source_density = tokamak_neutron_source_density(densities, temperatures, 'DD')
neutron_source_density = tokamak_neutron_source_density(densities, temperatures, "DD")

strengths = neutron_source_density / sum(neutron_source_density)

Expand Down
2 changes: 1 addition & 1 deletion examples/ring_source_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

plot = plot_source_position(
this=settings,
n_samples = 2000,
n_samples=2000,
)

plot.show()
60 changes: 51 additions & 9 deletions src/openmc_plasma_source/tokamak_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,31 @@ def tokamak_source(
fuel_densities = {}
for key, value in fuel.items():
fuel_densities[key] = densities * value
<<<<<<< HEAD
reactions = get_reactions_from_fuel(fuel)
=======
print("fuel_densities", fuel_densities.keys())
reactions = get_reactions_from_fuel(fuel)
print("freactions", reactions)
>>>>>>> c4d4e6c26f3252e250336743dd43a41d6dbdc80b

neutron_source_density = {}
total_source_density = 0
for reaction in reactions:

if reaction == 'DD':
fuel_density=fuel_densities['D']*0.5
elif reaction == 'TT':
fuel_density=fuel_densities['T']*0.5
elif reaction == 'DT':
fuel_density=fuel_densities['T']*fuel_densities['D']
if reaction == "DD":
fuel_density = fuel_densities["D"] * 0.5
elif reaction == "TT":
fuel_density = fuel_densities["T"] * 0.5
elif reaction == "DT":
fuel_density = fuel_densities["T"] * fuel_densities["D"]

neutron_source_density[reaction] = tokamak_neutron_source_density(
fuel_density, temperatures, reaction
)
if reaction == 'TT':
if reaction == "TT":
# TT reaction emits 2 neutrons
neutron_source_density[reaction]=neutron_source_density[reaction]*2
neutron_source_density[reaction] = neutron_source_density[reaction] * 2

total_source_density += sum(neutron_source_density[reaction])

Expand Down Expand Up @@ -411,4 +417,40 @@ def tokamak_neutron_source_density(ion_density, ion_temperature, reaction):
elif reaction == "DT":
return ion_density * reac_DT(ion_temperature) # could use _DT_xs instead
else:
<<<<<<< HEAD
raise ValueError('Reaction {reaction} not in available options ["DD", "DT", "TT"]')
=======
raise ValueError(
'Reaction {reaction} not in available options ["DD", "DT", "TT"]'
)


# 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
Args:
ion_temperature (float, ndarray): ion temperature in eV
Returns:
float, ndarray: the DT cross section at the given temperature
"""
ion_temperature_kev = np.asarray(ion_temperature / 1e3)
c = [
2.5663271e-18,
19.983026,
2.5077133e-2,
2.5773408e-3,
6.1880463e-5,
6.6024089e-2,
8.1215505e-3,
]
U = 1 - ion_temperature_kev * (
c[2] + ion_temperature_kev * (c[3] - c[4] * ion_temperature_kev)
) / (1.0 + ion_temperature_kev * (c[5] + c[6] * ion_temperature_kev))
val = (
c[0]
* np.exp(-c[1] * (U / ion_temperature_kev) ** (1 / 3))
/ (U ** (5 / 6) * ion_temperature_kev ** (2 / 3))
)
return val
>>>>>>> c4d4e6c26f3252e250336743dd43a41d6dbdc80b

0 comments on commit 9856fc7

Please sign in to comment.