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
If you intend to develop the code then it is recommended to work in a virtual environment.
23
21
24
-
In the above example the major_radius, minor_radius, elongation and triangularity while the other varibles are kept as the default values.
22
+
The requirements for developing the code can be installed by running:
25
23
26
-
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)
24
+
```pip install -r requirements-develop.txt```
27
25
28
-
```
29
-
ion_density_pedistal = 1.09e+20
30
-
ion_density_seperatrix = 3e+19
31
-
ion_density_origin = 1.09e+20
32
-
ion_temperature_pedistal = 6.09
33
-
ion_temperature_seperatrix = 0.1
34
-
ion_temperature_origin = 45.9
35
-
pedistal_radius = 0.8
36
-
ion_density_peaking_factor = 1
37
-
ion_temperature_peaking_factor = 8.06
38
-
minor_radius = 1.56
39
-
major_radius = 2.5
40
-
elongation = 2.0
41
-
triangularity = 0.55
42
-
shafranov_shift = 0.0
43
-
number_of_bins = 100
44
-
plasma_type = 1
45
-
```
26
+
The package can be built and installed in editable mode by:
27
+
28
+
```pip install -e .```
29
+
30
+
## Usage
31
+
32
+
The parametric plasma source can be sampled either directly in Python 3 or sampled in an OpenMC simulation.
46
33
47
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.
48
35
49
-
## Building and Running
36
+
### Sampling in Python
37
+
38
+
The parametric plasma source can be imported an used in Python 3 in the following manner:
Note: When building using the `Makefile` you may need to update the `OPENMC_DIR` parameter to select a relevant directory to obtain the OpenMC libraries and includes from.
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.
73
+
74
+
When using the OpenMC sampling the inputs must be provided in meters where applicable (the sampling will convert to cm).
75
+
76
+
```[python]
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()
109
+
```
52
110
53
-
The OpenMC plugin that samples the plasma source is built by running `make` or `make source_sampling` from within the parametric-plasma-source directory. This will generate the `source_sampling.so` shared object library, which can be referenced by the `library` attribute in the `source` element within the settings.xml being used for the run.
111
+
### Sampling using Executable
54
112
55
-
It is also possible to generate a source outside of OpenMC by creating the `source_generator` executable by running `make` or `make source_generator` from within the parameteric-plasma-source directory. The `source_generator` can then be run as below:
113
+
It is also possible to generate a source outside of OpenMC by creating the `source_generator` executable by running `cmake -H. -Bbuild` and then `cmake --build build` or `cmake --build build --target source_generator`. The `source_generator` can then be run as below:
56
114
57
115
```bash
58
116
Usage:
@@ -66,3 +124,7 @@ Options:
66
124
```
67
125
68
126
This will use OpenMC commands to sample the source generated using the specified library with the specified number of particles and output the resulting `initial_source.h5` file in the requested output directory. The `initial_source.h5` can then be analysed to check the properties of the source being generated.
127
+
128
+
## Running Tests
129
+
130
+
The tests are run by executing `pytest tests` from within your virtual environment.
0 commit comments