Skip to content

Commit

Permalink
Merge pull request #726 from ukaea/develop
Browse files Browse the repository at this point in the history
creation of version 0.2.3 develop to main merge
  • Loading branch information
shimwell authored Feb 10, 2021
2 parents 8188fb5 + 7648421 commit 785c3ed
Show file tree
Hide file tree
Showing 69 changed files with 1,923 additions and 599 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
command:
pytest tests/test_neutronics_utils.py -v --cov=paramak --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- run:
name: run neutronics_example tests
command:
pytest tests/test_example_neutronics_simulations.py -v --cov=paramak --cov-report term --cov-report xml --junitxml=test-reports/junit.xml

- run:
name: run utils tests
command:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- uses: actions/checkout@v1
- name: Build and test with Docker
run: |
docker build -t paramak --build-arg include_neutronics=true --build-arg cq_version=master --build-arg compile_cores=2 .
docker run --rm paramak /bin/bash -c "cd .. && bash run_tests.sh && curl -s https://codecov.io/bash | bash"
docker build -t paramak --build-arg include_neutronics=true --build-arg cq_version=2.1 --build-arg compile_cores=2 .
docker run --rm paramak /bin/bash -c "bash run_tests.sh && curl -s https://codecov.io/bash | bash"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ coverage.xml
*.vtk
*.jpg
*.xcf
*.gif

# sphinx built documetation
docs/build/
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# docker run --rm ukaea/paramak pytest /tests
# docker run --rm ukaea/paramak /bin/bash -c "cd .. && bash run_tests.sh"

FROM continuumio/miniconda3
FROM continuumio/miniconda3:4.9.2

# By default this Dockerfile builds with the latest release of CadQuery 2
ARG cq_version=2
Expand Down Expand Up @@ -164,9 +164,11 @@ RUN if [ "$include_neutronics" = "true" ] ; \
cd build ; \
cmake ../DAGMC -DBUILD_TALLY=ON \
-DMOAB_DIR=/MOAB \
-DDOUBLE_DOWN=ON \
-DBUILD_STATIC_EXE=OFF \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=/DAGMC/ ; \
-DCMAKE_INSTALL_PREFIX=/DAGMC/ \
-DDOUBLE_DOWN_DIR=/double-down ; \
make -j"$compile_cores" install ; \
rm -rf /DAGMC/DAGMC /DAGMC/build ; \
fi
Expand Down Expand Up @@ -211,5 +213,3 @@ COPY README.md README.md

# using setup.py instead of pip due to https://github.com/pypa/pip/issues/5816
RUN python setup.py install

WORKDIR examples
6 changes: 4 additions & 2 deletions DockerfileDependencies
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# docker run --rm ukaea/paramak pytest /tests
# docker run --rm ukaea/paramak /bin/bash -c "cd .. && bash run_tests.sh"

FROM continuumio/miniconda3
FROM continuumio/miniconda3:4.9.2

# By default this Dockerfile builds with the latest release of CadQuery 2
ARG cq_version=2
Expand Down Expand Up @@ -164,9 +164,11 @@ RUN if [ "$include_neutronics" = "true" ] ; \
cd build ; \
cmake ../DAGMC -DBUILD_TALLY=ON \
-DMOAB_DIR=/MOAB \
-DDOUBLE_DOWN=ON \
-DBUILD_STATIC_EXE=OFF \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=/DAGMC/ ; \
-DCMAKE_INSTALL_PREFIX=/DAGMC/ \
-DDOUBLE_DOWN_DIR=/double-down ; \
make -j"$compile_cores" install ; \
rm -rf /DAGMC/DAGMC /DAGMC/build ; \
fi
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ common reactor components.
</p>

<p align="center">
<img src="https://user-images.githubusercontent.com/8583900/88866536-e57a8180-d202-11ea-8e3f-2662973c6f69.gif" width="600">
<img src="https://user-images.githubusercontent.com/8583900/86237379-90136c00-bb93-11ea-80fb-54e2dab74819.gif" width="150">
<img src="https://user-images.githubusercontent.com/8583900/107040396-155ca000-67b7-11eb-8b99-4aa9bf8a8655.gif" width="300">
<img src="https://user-images.githubusercontent.com/8583900/107030664-e2131480-67a8-11eb-84bb-59656e9e7722.gif" width="300">
</p>

## Selection Of Parametric Components
Expand Down
14 changes: 14 additions & 0 deletions docs/source/paramak.parametric_components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ CuttingWedgeFS()
:members:
:show-inheritance:

HexagonPin()
^^^^^^^^^^^^

|HexagonPinstp| |HexagonPinsvg|

.. |HexagonPinstp| image:: https://user-images.githubusercontent.com/8583900/107092190-07307300-67fb-11eb-995c-b5622de717ee.png
:width: 300px
.. |HexagonPinsvg| image:: https://user-images.githubusercontent.com/8583900/107092487-9c336c00-67fb-11eb-8eb1-755462493140.png
:width: 300px

.. automodule:: paramak.parametric_components.hexagon_pin
:members:
:show-inheritance:

InboardFirstwallFCCS()
^^^^^^^^^^^^^^^^^^^^^^

Expand Down
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()
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ def main():
)
all_components.append(component)

component = paramak.ToroidalFieldCoilPrincetonD(
magnet = paramak.ToroidalFieldCoilPrincetonD(
R1=80,
R2=300,
thickness=30,
distance=30,
number_of_coils=1,
stp_filename="toroidal_field_coil_princeton_d.stp"
)
all_components.append(component)
all_components.append(magnet)

component = paramak.ITERtypeDivertor(
# default parameters
Expand Down Expand Up @@ -402,6 +402,28 @@ def main():
)
all_components.append(component)

component = paramak.PoloidalSegments(
number_of_segments=5,
center_point=(400, 50)
)
all_components.append(component)

component = paramak.TFCoilCasing(
magnet=magnet,
inner_offset=10,
outer_offset=15,
vertical_section_offset=20,
distance=40
)
all_components.append(component)

component = paramak.HexagonPin(
length_of_side=5,
distance=10,
center_point=(10, 20)
)
all_components.append(component)

return all_components


Expand All @@ -410,5 +432,6 @@ def main():
filenames = []
for components in all_components:
components.export_stp()
components.export_html(components.stp_filename[:-4] + '.html')
filenames.append(components.stp_filename)
print(filenames)
3 changes: 2 additions & 1 deletion examples/example_parametric_reactors/htc_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def main(rotation_angle=180):
stp_filename='vacvessel.stp'
)

inner_vessel = paramak.RotateStraightShape(
inner_vessel = paramak.RotateMixedShape(
points=[
(269.7459584295612, -46.54377880184336, 'straight'),
(231.87066974595842, -46.5437788018433, 'spline'),
Expand Down Expand Up @@ -258,6 +258,7 @@ def main(rotation_angle=180):

sparc.export_stp()
sparc.export_svg('htc_reactor.svg')
sparc.export_html('htc_reactor.html')


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/example_parametric_reactors/make_all_reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from submersion_reactor_single_null import make_submersion_sn


def main(outputs=['stp', 'svg']):
def main(outputs=['stp', 'svg', 'html']):

make_submersion(outputs=outputs)
make_submersion_sn(outputs=outputs)
Expand Down
133 changes: 95 additions & 38 deletions examples/example_parametric_reactors/make_animation.py
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()
Loading

0 comments on commit 785c3ed

Please sign in to comment.