You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-26Lines changed: 90 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,42 +8,106 @@ The plasma source is based on a paper by [C. Fausser et al](https://www.scienced
8
8
9
9
## Installation
10
10
11
+
### Installing from PyPI
12
+
11
13
```pip install parametric_plasma_source```
12
14
15
+
### Installing from source
16
+
17
+
Installation of the parametric plasma source from source requires cmake to build the underlying C++ code. This can be obtained from
18
+
your OS's package manager by e.g. `sudo apt-get install cmake` or from cmake source.
19
+
20
+
If you intend to develop the code then it is recommended to work in a virtual environment.
21
+
22
+
The requirements for developing the code can be installed by running:
23
+
24
+
```pip install -r requirements-develop.txt```
25
+
26
+
The package can be built and installed in editable mode by:
27
+
28
+
```pip install -e .```
29
+
13
30
## Usage
14
31
15
-
The parametric plasma source can be imported an used in Python 3 in the following manner.
32
+
The parametric plasma source can be sampled either directly in Python 3 or sampled in an OpenMC simulation.
33
+
34
+
For a better understanding of the varibles take a look at the [C. Fausser et al](https://www.sciencedirect.com/science/article/pii/S0920379612000853) paper.
35
+
36
+
### Sampling in Python
37
+
38
+
The parametric plasma source can be imported an used in Python 3 in the following manner:
In the above example the major_radius, minor_radius, elongation and triangularity while the other varibles are kept as the default values.
70
+
### Sampling in OpenMC
71
+
72
+
The parametric plasma source also contains a plugin library for OpenMC to allow the source to be sampled in an OpenMC simulation.
27
73
28
-
There are a number of additional arguments that can be passed to the Plasma class on construction. Units are in SI (e.g. meters not cm)
74
+
When using the OpenMC sampling the inputs must be provided in meters where applicable (the sampling will convert to cm).
29
75
30
76
```[python]
31
-
ion_density_pedistal = 1.09e+20
32
-
ion_density_seperatrix = 3e+19
33
-
ion_density_origin = 1.09e+20
34
-
ion_temperature_pedistal = 6.09
35
-
ion_temperature_seperatrix = 0.1
36
-
ion_temperature_origin = 45.9
37
-
pedistal_radius = 0.8
38
-
ion_density_peaking_factor = 1
39
-
ion_temperature_peaking_factor = 8.06
40
-
minor_radius = 1.56
41
-
major_radius = 2.5
42
-
elongation = 2.0
43
-
triangularity = 0.55
44
-
shafranov_shift = 0.0
45
-
number_of_bins = 100
46
-
plasma_type = 1
77
+
from parametric_plasma_source import PlasmaSource, SOURCE_SAMPLING_PATH
78
+
import openmc
79
+
80
+
plasma_params = {
81
+
"elongation": 1.557,
82
+
"ion_density_origin": 1.09e20,
83
+
"ion_density_peaking_factor": 1,
84
+
"ion_density_pedestal": 1.09e20,
85
+
"ion_density_separatrix": 3e19,
86
+
"ion_temperature_origin": 45.9,
87
+
"ion_temperature_peaking_factor": 8.06,
88
+
"ion_temperature_pedestal": 6.09,
89
+
"ion_temperature_separatrix": 0.1,
90
+
"major_radius": 9.06,
91
+
"minor_radius": 2.92258,
92
+
"pedestal_radius": 0.8 * 2.92258,
93
+
"plasma_id": 1,
94
+
"shafranov_shift": 0.44789,
95
+
"triangularity": 0.270,
96
+
"ion_temperature_beta": 6,
97
+
}
98
+
99
+
my_plasma = PlasmaSource(**plasma_params)
100
+
settings = openmc.Settings()
101
+
settings.run_mode = "fixed source"
102
+
settings.batches = 10
103
+
settings.particles = 1000
104
+
source = openmc.Source()
105
+
source.library = SOURCE_SAMPLING_PATH
106
+
source.parameters = str(my_plasma)
107
+
settings.source = source
108
+
settings.export_to_xml()
47
109
```
48
110
49
-
For a better understanding of the varibles take a look at the [C. Fausser et al](https://www.sciencedirect.com/science/article/pii/S0920379612000853) paper.
111
+
## Running Tests
112
+
113
+
The tests are run by executing `pytest tests` from within your virtual environment.
0 commit comments