Skip to content

Commit

Permalink
[skip ci] ring source example working
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Mar 6, 2024
1 parent a70b018 commit 01d326b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions examples/ring_source_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import openmc

from openmc_plasma_source import FusionRingSource
from openmc_plasma_source import fusion_ring_source

# just making use of a local cross section xml file, replace with your own cross sections or comment out
openmc.config["cross_sections"] = Path(__file__).parent.resolve() / "cross_sections.xml"
Expand All @@ -14,7 +14,7 @@
geometry = openmc.Geometry([cell])

# define the source
my_source = FusionRingSource(
my_source = fusion_ring_source(
radius=700,
angles=(0.0, 2 * math.pi), # 360deg source
temperature=20000.0,
Expand Down
2 changes: 1 addition & 1 deletion src/openmc_plasma_source/point_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fusion_point_source(

# else:
for energy_distribution, strength in zip(energy_distributions, strengths):
source = openmc.Source()
source = openmc.IndependentSource()
source.energy = energy_distribution
source.space = openmc.stats.Point(coordinate)
source.angle = openmc.stats.Isotropic()
Expand Down
34 changes: 22 additions & 12 deletions src/openmc_plasma_source/ring_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,28 @@ def fusion_ring_source(
else:
raise ValueError("Temperature must be a float strictly greater than 0.")

source = openmc.IndependentSource()

# performed after the super init as these are Source attributes
source.space = openmc.stats.CylindricalIndependent(
r=openmc.stats.Discrete([radius], [1]),
phi=openmc.stats.Uniform(a=angles[0], b=angles[1]),
z=openmc.stats.Discrete([z_placement], [1]),
origin=(0.0, 0.0, 0.0),
)
source.angle = openmc.stats.Isotropic()
source.energy = get_neutron_energy_distribution(

sources = []

energy_distributions, strengths = get_neutron_energy_distribution(
ion_temperature=temperature, fuel=fuel
)

return source
for energy_distribution, strength in zip(energy_distributions, strengths):

source = openmc.IndependentSource()

source.space = openmc.stats.CylindricalIndependent(
r=openmc.stats.Discrete([radius], [1]),
phi=openmc.stats.Uniform(a=angles[0], b=angles[1]),
z=openmc.stats.Discrete([z_placement], [1]),
origin=(0.0, 0.0, 0.0),
)

source.energy = energy_distribution
source.angle = openmc.stats.Isotropic()
source.strength = strength
sources.append(source)

return sources

0 comments on commit 01d326b

Please sign in to comment.