-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtokamak_source_example.py
57 lines (42 loc) · 1.56 KB
/
tokamak_source_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pathlib import Path
import openmc
from openmc_plasma_source import tokamak_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"
# minimal geometry
sphere_surface = openmc.Sphere(r=100000.0, boundary_type="vacuum")
cell = openmc.Cell(region=-sphere_surface)
geometry = openmc.Geometry([cell])
# create a plasma source
my_sources = tokamak_source(
elongation=1.557,
ion_density_centre=1.09e20,
ion_density_pedestal=1.09e20,
ion_density_peaking_factor=1,
ion_density_separatrix=3e19,
ion_temperature_centre=45.9e3,
ion_temperature_pedestal=6.09e3,
ion_temperature_separatrix=0.1e3,
ion_temperature_peaking_factor=8.06,
ion_temperature_beta=6,
major_radius=906,
minor_radius=292.258,
pedestal_radius=0.8 * 292.258,
mode="H",
shafranov_factor=0.44789,
triangularity=0.270,
fuel={"D": 0.5, "T": 0.5},
)
# Tell OpenMC we're going to use our custom source
settings = openmc.Settings()
settings.run_mode = "fixed source"
settings.batches = 10
settings.particles = 1000
settings.source = my_sources
model = openmc.model.Model(materials=None, geometry=geometry, settings=settings)
model.run()
# optionally if you would like to plot the direction of particles then another package can be used
# https://github.com/fusion-energy/openmc_source_plotter
from openmc_source_plotter import plot_source_position
plot = plot_source_position(this=settings, n_samples=200)
plot.show()