-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #726 from ukaea/develop
creation of version 0.2.3 develop to main merge
- Loading branch information
Showing
69 changed files
with
1,923 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ coverage.xml | |
*.vtk | ||
*.jpg | ||
*.xcf | ||
*.gif | ||
|
||
# sphinx built documetation | ||
docs/build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
examples/example_neutronics_simulations/shape_with_gas_production.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Demonstrates the use of reaction rates in the cell tally. | ||
(n,Xp) is MT number 203 and scores all proton (hydrogen) production | ||
(n,Xt) is MT number 205 and scores all tritium production | ||
(n,Xa) is MT number 207 and scores all alpha paticle (helium) production | ||
https://docs.openmc.org/en/latest/usersguide/tallies.html#scores | ||
""" | ||
|
||
|
||
import openmc | ||
import paramak | ||
|
||
|
||
def main(): | ||
my_shape = paramak.CenterColumnShieldHyperbola( | ||
height=500, | ||
inner_radius=50, | ||
mid_radius=60, | ||
outer_radius=100, | ||
material_tag='center_column_shield_mat' | ||
) | ||
|
||
# makes the openmc neutron source at x,y,z 0, 0, 0 with isotropic | ||
# directions | ||
source = openmc.Source() | ||
source.space = openmc.stats.Point((0, 0, 0)) | ||
source.energy = openmc.stats.Discrete([14e6], [1]) | ||
source.angle = openmc.stats.Isotropic() | ||
|
||
# converts the geometry into a neutronics geometry | ||
my_model = paramak.NeutronicsModel( | ||
geometry=my_shape, | ||
source=source, | ||
materials={'center_column_shield_mat': 'Be'}, | ||
cell_tallies=['(n,Xa)', '(n,Xt)', '(n,Xp)'], | ||
mesh_tally_3d=['(n,Xa)', '(n,Xt)', '(n,Xp)'], | ||
mesh_tally_2d=['(n,Xa)', '(n,Xt)', '(n,Xp)'], | ||
simulation_batches=10, | ||
simulation_particles_per_batch=200 | ||
) | ||
|
||
# performs an openmc simulation on the model | ||
my_model.simulate(method='pymoab') | ||
|
||
# this extracts the values from the results dictionary | ||
print(my_model.results) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,114 @@ | ||
__doc__ = """ Creates a series of images of a ball reactor images and | ||
combines them into gif animations using the command line tool convert, | ||
part of the imagemagick suite """ | ||
__doc__ = """ Creates a series of images of a ball reactor images and combines | ||
them into gif animations using the command line tool convert, you will need to | ||
have imagemagick installed to convert the svg images to a gif animation """ | ||
|
||
import argparse | ||
import os | ||
import uuid | ||
import subprocess | ||
|
||
import numpy as np | ||
import paramak | ||
from tqdm import tqdm | ||
from scipy.interpolate import interp1d | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-n", "--number_of_models", type=int, default=10) | ||
args = parser.parse_args() | ||
|
||
for i in tqdm(range(args.number_of_models)): | ||
def rotate_single_reactor(number_of_images=100): | ||
"""Makes a single reactor and exports and svg image with different view | ||
angles. Combines the svg images into a gif animation.""" | ||
|
||
my_reactor = paramak.BallReactor( | ||
inner_bore_radial_thickness=50, | ||
inboard_tf_leg_radial_thickness=np.random.uniform(20, 50), | ||
center_column_shield_radial_thickness=np.random.uniform(20, 60), | ||
divertor_radial_thickness=50, | ||
# allows the projection angle for the svg to be found via interpolation | ||
angle_finder = interp1d([0, number_of_images], [2.4021, 6.]) | ||
|
||
my_reactor = paramak.SubmersionTokamak( | ||
inner_bore_radial_thickness=30, | ||
inboard_tf_leg_radial_thickness=30, | ||
center_column_shield_radial_thickness=30, | ||
divertor_radial_thickness=80, | ||
inner_plasma_gap_radial_thickness=50, | ||
plasma_radial_thickness=np.random.uniform(20, 200), | ||
plasma_radial_thickness=200, | ||
outer_plasma_gap_radial_thickness=50, | ||
firstwall_radial_thickness=5, | ||
blanket_radial_thickness=np.random.uniform(10, 200), | ||
blanket_rear_wall_radial_thickness=10, | ||
elongation=np.random.uniform(1.2, 1.7), | ||
triangularity=np.random.uniform(0.3, 0.55), | ||
firstwall_radial_thickness=30, | ||
blanket_rear_wall_radial_thickness=30, | ||
number_of_tf_coils=16, | ||
rotation_angle=180, | ||
pf_coil_radial_thicknesses=[50, 50, 50, 50], | ||
pf_coil_vertical_thicknesses=[50, 50, 50, 50], | ||
pf_coil_to_rear_blanket_radial_gap=50, | ||
support_radial_thickness=90, | ||
inboard_blanket_radial_thickness=30, | ||
outboard_blanket_radial_thickness=30, | ||
elongation=2.00, | ||
triangularity=0.50, | ||
pf_coil_radial_thicknesses=[30, 30, 30, 30], | ||
pf_coil_vertical_thicknesses=[30, 30, 30, 30], | ||
pf_coil_to_tf_coil_radial_gap=50, | ||
outboard_tf_coil_radial_thickness=100, | ||
outboard_tf_coil_poloidal_thickness=50, | ||
outboard_tf_coil_radial_thickness=30, | ||
outboard_tf_coil_poloidal_thickness=30, | ||
tf_coil_to_rear_blanket_radial_gap=20, | ||
) | ||
|
||
my_reactor.export_2d_image( | ||
filename="output_for_animation_2d/" + str(uuid.uuid4()) + ".png" | ||
) | ||
my_reactor.export_svg( | ||
filename="output_for_animation_svg/" + str(uuid.uuid4()) + ".svg" | ||
) | ||
for i in range(number_of_images): | ||
|
||
# uses the rotation angle (in radians) to find new x, y points | ||
x_vec, y_vec = paramak.utils.rotate([0, 0], [1, 0], angle_finder(i)) | ||
projectionDir = (x_vec, y_vec, 0) | ||
|
||
my_reactor.export_svg( | ||
filename="rotation_" + str(i).zfill(4) + ".svg", | ||
projectionDir=projectionDir, | ||
showHidden=False, | ||
height=200, | ||
width=300, | ||
marginTop=27, | ||
marginLeft=35, | ||
strokeWidth=3.5 | ||
) | ||
|
||
print("made", str(i + 1), "models out of", str(number_of_images)) | ||
|
||
subprocess.check_call( | ||
["convert", "-delay", "15", "rotation_*.svg", "rotated.gif"]) | ||
|
||
print("animation file made as saved as rotated.gif") | ||
|
||
|
||
def make_random_reactors(number_of_images=11): | ||
"""Makes a series of random sized reactors and exports an svg image for | ||
each one. Combines the svg images into a gif animation.""" | ||
|
||
# makes a series of reactor models | ||
for i in range(number_of_images): | ||
|
||
my_reactor = paramak.BallReactor( | ||
inner_bore_radial_thickness=50, | ||
inboard_tf_leg_radial_thickness=np.random.uniform(20, 50), | ||
center_column_shield_radial_thickness=np.random.uniform(20, 60), | ||
divertor_radial_thickness=50, | ||
inner_plasma_gap_radial_thickness=50, | ||
plasma_radial_thickness=np.random.uniform(20, 200), | ||
outer_plasma_gap_radial_thickness=50, | ||
firstwall_radial_thickness=5, | ||
blanket_radial_thickness=np.random.uniform(10, 200), | ||
blanket_rear_wall_radial_thickness=10, | ||
elongation=np.random.uniform(1.3, 1.7), | ||
triangularity=np.random.uniform(0.3, 0.55), | ||
number_of_tf_coils=16, | ||
rotation_angle=180, | ||
pf_coil_radial_thicknesses=[50, 50, 50, 50], | ||
pf_coil_vertical_thicknesses=[30, 30, 30, 30], | ||
pf_coil_to_rear_blanket_radial_gap=20, | ||
pf_coil_to_tf_coil_radial_gap=50, | ||
outboard_tf_coil_radial_thickness=100, | ||
outboard_tf_coil_poloidal_thickness=50, | ||
) | ||
|
||
my_reactor.export_svg( | ||
filename="random_" + str(i).zfill(4) + ".svg", | ||
showHidden=False | ||
) | ||
|
||
print(str(args.number_of_models), "models made") | ||
print("made", str(i + 1), "models out of", str(number_of_images)) | ||
|
||
os.system("convert -delay 40 output_for_animation_2d/*.png 2d.gif") | ||
subprocess.check_call( | ||
["convert", "-delay", "40", "random_*.svg", "randoms.gif"]) | ||
|
||
os.system("convert -delay 40 output_for_animation_3d/*.png 3d.gif") | ||
print("animation file made as saved as randoms.gif") | ||
|
||
os.system("convert -delay 40 output_for_animation_svg/*.svg 3d_svg.gif") | ||
|
||
print("animation file made 2d.gif, 3d.gif and 3d_svg.gif") | ||
if __name__ == "__main__": | ||
rotate_single_reactor() | ||
# make_random_reactors() |
Oops, something went wrong.