1- """
2- This file is part of PARAMAK which is a design tool capable
3- of creating 3D CAD models compatible with automated neutronics
4- analysis.
5-
6- PARAMAK is released under GNU General Public License v3.0.
7- Go to https://github.com/Shimwell/paramak/blob/master/LICENSE
8- for full license details.
9-
10- This program is free software: you can redistribute it and/or modify
11- it under the terms of the GNU General Public License as published by
12- the Free Software Foundation, either version 3 of the License, or
13- (at your option) any later version.
14-
15- Copyright (C) 2019 UKAEA
16-
17- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
18- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
19- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
20- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
21- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
23- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
24- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
25- """
26- import math
1+
272import os
283from pathlib import Path
294import tempfile
305import shutil
316
32- import numpy as np
33- import scipy
34-
357
368class Plasma ():
379
@@ -294,10 +266,10 @@ def export_plasma_source(self, output_filename):
294266 raise ValueError ('directory must be set to create .so file' )
295267
296268 temp_folder = Path (tempfile .mkdtemp ())
297- print ( temp_folder )
269+
298270 Path (output_filename ).parent .mkdir (parents = True , exist_ok = True )
299271
300- editted_plasma_make_file = self .plasma_make_file .replace ('$ openmc$ ' , self .openmc_install_directory )
272+ editted_plasma_make_file = self .plasma_make_file .replace ('OPENMC_DIR = /opt/ openmc' , 'OPENMC_DIR = ' + self .openmc_install_directory )
301273 with open (temp_folder / 'Makefile' , "w" ) as text_file :
302274 text_file .write (editted_plasma_make_file )
303275
@@ -308,22 +280,22 @@ def export_plasma_source(self, output_filename):
308280 text_file .write (self .plasma_source_hpp_file )
309281
310282 plasma_varibles = [
311- ('$ ion_density_pedistal$' , str (self .ion_density_pedistal )),
312- ('$ ion_density_seperatrix$' , str (self .ion_density_seperatrix )),
313- ('$ ion_density_origin$' , str (self .ion_density_origin )),
314- ('$ ion_temperature_pedistal$' , str (self .ion_temperature_pedistal )),
315- ('$ ion_temperature_seperatrix$' , str (self .ion_temperature_seperatrix )),
316- ('$ ion_temperature_origin$' , str (self .ion_temperature_origin )),
317- ('$ pedistal_radius$' , str (self .pedistal_radius )),
318- ('$ ion_density_peaking_factor$' , str (self .ion_density_peaking_factor )),
319- ('$ ion_temperature_peaking_factor$' , str (self .ion_temperature_peaking_factor )),
320- ('$ minor_radius$' , str (self .minor_radius / 100. )),
321- ('$ major_radius$' , str (self .major_radius / 100. )),
322- ('$ elongation$' , str (self .elongation )),
323- ('$ triangularity$' , str (self .triangularity )),
324- ('$ shafranov_shift$' , str (self .shafranov_shift / 100. )),
325- ('$ number_of_bins$' , str (self .number_of_bins )),
326- ('$ plasma_type$' , str (self .plasma_type ))
283+ ('const double ion_density_pedistal = 1.09e+20' , 'const double ion_density_pedistal = ' + str (self .ion_density_pedistal )),
284+ ('const double ion_density_seperatrix = 3e+19' , 'const double ion_density_seperatrix = ' + str (self .ion_density_seperatrix )),
285+ ('const double ion_density_origin = 1.09e+20' , 'const double ion_density_origin = ' + str (self .ion_density_origin )),
286+ ('const double ion_temperature_pedistal = 6.09' , 'const double ion_temperature_pedistal = ' + str (self .ion_temperature_pedistal )),
287+ ('const double ion_temperature_seperatrix = 0.1' , 'const double ion_temperature_seperatrix = ' + str (self .ion_temperature_seperatrix )),
288+ ('const double ion_temperature_origin = 45.9' , 'const double ion_temperature_origin = ' + str (self .ion_temperature_origin )),
289+ ('const double pedistal_radius = 0.8' , 'const double pedistal_radius = ' + str (self .pedistal_radius )),
290+ ('const double ion_density_peaking_factor = 1' , 'const double ion_density_peaking_factor = ' + str (self .ion_density_peaking_factor )),
291+ ('const double ion_temperature_peaking_factor = 8.06' , 'const double ion_temperature_peaking_factor = ' + str (self .ion_temperature_peaking_factor )),
292+ ('const double minor_radius = 1.56' , 'const double minor_radius = ' + str (self .minor_radius / 100. )),
293+ ('const double major_radius = 2.5' , 'const double major_radius = ' + str (self .major_radius / 100. )),
294+ ('const double elongation = 2.0' , 'const double elongation = ' + str (self .elongation )),
295+ ('const double triangularity = 0.55' , 'const double triangularity = ' + str (self .triangularity )),
296+ ('const double shafranov_shift = 0.0' , 'const double shafranov_shift = ' + str (self .shafranov_shift / 100. )),
297+ ('const int number_of_bins = 100' , 'const int number_of_bins = ' + str (self .number_of_bins )),
298+ ('const int plasma_type = 1' , 'const int plasma_type = 1' + str (self .plasma_type ))
327299 ]
328300
329301 editted_source_sampling_cpp_file = self .source_sampling_cpp_file
@@ -343,8 +315,6 @@ def export_plasma_source(self, output_filename):
343315 os .system ('make clean' )
344316 os .system ('make' )
345317
346-
347-
348318 os .chdir (cwd )
349319 shutil .move (temp_folder / 'source_sampling.so' , output_filename )
350320 print ('parametric plasma source compiled and saved to ' , output_filename )
0 commit comments