From bf01e8e1eb425a9edd919466c1ea3c0c0cfcf965 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 3 May 2021 23:44:28 +0100 Subject: [PATCH 01/21] removed py examples --- .../heating_on_unstructured_mesh_shape.py | 24 + .../make_all_parametric_components.ipynb | 440 +++++++++++++++++ .../make_all_parametric_components.py | 445 ------------------ ...l_parametric_components_images_for_docs.py | 19 - .../make_demo_style_blankets.ipynb | 128 +++++ .../make_demo_style_blankets.py | 93 ---- ...e_firstwall_for_neutron_wall_loading.ipynb | 74 +++ ...make_firstwall_for_neutron_wall_loading.py | 37 -- .../make_magnet_set.ipynb | 117 +++++ .../make_magnet_set.py | 77 --- .../make_plasmas.ipynb | 141 ++++++ .../make_plasmas.py | 254 ---------- .../make_vacuum_vessel_with_ports.ipynb | 92 ++++ .../make_vacuum_vessel_with_ports.py | 57 --- .../make_varible_offset_firstwall.ipynb | 88 ++++ .../ball_reactor.py | 51 -- .../ball_reactor_single_null.ipynb | 83 ++++ .../ball_reactor_single_null.py | 51 -- .../center_column_study_reactor.py | 60 --- .../make_all_reactors.py | 24 - .../make_animation.py | 114 ----- .../make_animiation.ipynb | 178 +++++++ .../segmented_blanket_ball_reactor.ipynb | 98 ++++ .../segmented_blanket_ball_reactor.py | 70 --- .../submersion_reactor.ipynb | 13 +- .../submersion_reactor.py | 50 -- .../submersion_reactor_single_null.py | 56 --- .../make_CAD_from_points.py | 233 --------- .../make_blanket_from_parameters.py | 31 -- .../make_blanket_from_points.py | 25 - .../make_can_reactor_from_parameters.py | 135 ------ .../make_can_reactor_from_points.py | 128 ----- .../make_html_diagram_from_stp_file.py | 75 --- tests/notebook_testing.py | 2 +- tests/test_example_components.py | 109 +---- tests/test_example_reactors.py | 80 ---- tests/test_example_shapes.py | 146 ------ 37 files changed, 1478 insertions(+), 2420 deletions(-) create mode 100644 examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py create mode 100644 examples/example_parametric_components/make_all_parametric_components.ipynb delete mode 100644 examples/example_parametric_components/make_all_parametric_components.py delete mode 100644 examples/example_parametric_components/make_all_parametric_components_images_for_docs.py create mode 100644 examples/example_parametric_components/make_demo_style_blankets.ipynb delete mode 100644 examples/example_parametric_components/make_demo_style_blankets.py create mode 100644 examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.ipynb delete mode 100644 examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.py create mode 100644 examples/example_parametric_components/make_magnet_set.ipynb delete mode 100644 examples/example_parametric_components/make_magnet_set.py create mode 100644 examples/example_parametric_components/make_plasmas.ipynb delete mode 100644 examples/example_parametric_components/make_plasmas.py create mode 100644 examples/example_parametric_components/make_vacuum_vessel_with_ports.ipynb delete mode 100644 examples/example_parametric_components/make_vacuum_vessel_with_ports.py create mode 100644 examples/example_parametric_components/make_varible_offset_firstwall.ipynb delete mode 100644 examples/example_parametric_reactors/ball_reactor.py create mode 100644 examples/example_parametric_reactors/ball_reactor_single_null.ipynb delete mode 100644 examples/example_parametric_reactors/ball_reactor_single_null.py delete mode 100644 examples/example_parametric_reactors/center_column_study_reactor.py delete mode 100644 examples/example_parametric_reactors/make_all_reactors.py delete mode 100644 examples/example_parametric_reactors/make_animation.py create mode 100644 examples/example_parametric_reactors/make_animiation.ipynb create mode 100644 examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb delete mode 100644 examples/example_parametric_reactors/segmented_blanket_ball_reactor.py delete mode 100644 examples/example_parametric_reactors/submersion_reactor.py delete mode 100644 examples/example_parametric_reactors/submersion_reactor_single_null.py delete mode 100644 examples/example_parametric_shapes/make_CAD_from_points.py delete mode 100644 examples/example_parametric_shapes/make_blanket_from_parameters.py delete mode 100644 examples/example_parametric_shapes/make_blanket_from_points.py delete mode 100644 examples/example_parametric_shapes/make_can_reactor_from_parameters.py delete mode 100644 examples/example_parametric_shapes/make_can_reactor_from_points.py delete mode 100644 examples/example_parametric_shapes/make_html_diagram_from_stp_file.py diff --git a/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py b/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py new file mode 100644 index 000000000..a897d0991 --- /dev/null +++ b/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py @@ -0,0 +1,24 @@ + +import paramak + + +rotated_spline = paramak.RotateSplineShape( + rotation_angle=180, + method='trelis', + points=[ + (500, 0), + (500, -20), + (400, -300), + (300, -300), + (400, 0), + (300, 300), + (400, 300), + (500, 20), + ], + tet_mesh= +) + +rotated_spline.export_h5m( + # merge_tolerance, + # faceting_tolerance=, +) \ No newline at end of file diff --git a/examples/example_parametric_components/make_all_parametric_components.ipynb b/examples/example_parametric_components/make_all_parametric_components.ipynb new file mode 100644 index 000000000..750505d44 --- /dev/null +++ b/examples/example_parametric_components/make_all_parametric_components.ipynb @@ -0,0 +1,440 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"\n", + "This python script demonstrates the creation of all parametric shapes available\n", + "in the paramak tool\n", + "\"\"\"\n", + "\n", + "import paramak\n", + "\n", + "\n", + "\n", + "rot_angle = 180\n", + "all_components = []\n", + "\n", + "plasma = paramak.Plasma(\n", + " # default parameters\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"plasma_shape.stp\",\n", + ")\n", + "plasma.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=-90,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_outboard_plasma.stp\",\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "component = paramak.BlanketCutterStar(\n", + " height=2000,\n", + " width=2000,\n", + " distance=100\n", + ")\n", + "\n", + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=250,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_inboard_plasma.stp\",\n", + ")\n", + "\n", + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=250,\n", + " start_angle=-90,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_plasma.stp\",\n", + ")\n", + "\n", + "CenterColumnShieldCylinder = paramak.CenterColumnShieldCylinder(\n", + " inner_radius=80,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_cylinder.stp\",\n", + ")\n", + "all_components.append(CenterColumnShieldCylinder)\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldCylinder,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_cylinder.stp\",\n", + ")\n", + "\n", + "CenterColumnShieldHyperbola = paramak.CenterColumnShieldHyperbola(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_hyperbola.stp\",\n", + ")\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_hyperbola.stp\",\n", + ")\n", + "\n", + "CenterColumnShieldCircular = paramak.CenterColumnShieldCircular(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_circular.stp\",\n", + ")\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldCircular,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_circular.stp\",\n", + ")\n", + "\n", + "\n", + "CenterColumnShieldFlatTopHyperbola = paramak.CenterColumnShieldFlatTopHyperbola(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " arc_height=220,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_flat_top_hyperbola.stp\",\n", + ")\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldFlatTopHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_flat_top_hyperbola.stp\",\n", + ")\n", + "\n", + "CenterColumnShieldFlatTopCircular = paramak.CenterColumnShieldFlatTopCircular(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " arc_height=220,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_flat_top_Circular.stp\",\n", + ")\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldFlatTopCircular,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_flat_top_Circular.stp\",\n", + ")\n", + "\n", + "CenterColumnShieldPlasmaHyperbola = paramak.CenterColumnShieldPlasmaHyperbola(\n", + " inner_radius=150,\n", + " mid_offset=50,\n", + " edge_offset=40,\n", + " height=800,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_plasma_hyperbola.stp\",\n", + ")\n", + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldPlasmaHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_plasma_hyperbola.stp\",\n", + ")\n", + "\n", + "component = paramak.InnerTfCoilsCircular(\n", + " inner_radius=25,\n", + " outer_radius=100,\n", + " number_of_coils=10,\n", + " gap_size=5,\n", + " height=300,\n", + " stp_filename=\"inner_tf_coils_circular.stp\",\n", + ")\n", + "\n", + "component = paramak.InnerTfCoilsFlat(\n", + " inner_radius=25,\n", + " outer_radius=100,\n", + " number_of_coils=10,\n", + " gap_size=5,\n", + " height=300,\n", + " stp_filename=\"inner_tf_coils_flat.stp\",\n", + ")\n", + "\n", + "# this makes 4 pf coil cases\n", + "pf_coil_set = paramak.PoloidalFieldCoilCaseSet(\n", + " heights=[10, 10, 20, 20],\n", + " widths=[10, 10, 20, 40],\n", + " casing_thicknesses=[5, 5, 10, 10],\n", + " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_case_set.stp\"\n", + ")\n", + "\n", + "# this makes 4 pf coils\n", + "pf_coil_set = paramak.PoloidalFieldCoilSet(\n", + " heights=[10, 10, 20, 20],\n", + " widths=[10, 10, 20, 40],\n", + " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_set.stp\"\n", + ")\n", + "\n", + "# this makes 4 pf coil cases for the 4 pf coils made above\n", + "component = paramak.PoloidalFieldCoilCaseSetFC(\n", + " pf_coils=pf_coil_set,\n", + " casing_thicknesses=[5, 5, 10, 10],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_cases_set.stp\"\n", + ")\n", + "\n", + "# this makes 1 pf coils\n", + "pf_coil = paramak.PoloidalFieldCoil(\n", + " center_point=(100, 100),\n", + " height=20,\n", + " width=20,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil.stp\"\n", + ")\n", + "\n", + "# this makes one PF coil case for the provided pf coil\n", + "component = paramak.PoloidalFieldCoilCaseSetFC(\n", + " pf_coils=[pf_coil],\n", + " casing_thicknesses=[10],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_cases_set_fc.stp\"\n", + ")\n", + "\n", + "component = paramak.PoloidalFieldCoilCaseFC(\n", + " pf_coil=pf_coil,\n", + " casing_thickness=10,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil_case_fc.stp\",\n", + ")\n", + "\n", + "component = paramak.PoloidalFieldCoilCase(\n", + " center_point=(100, 100),\n", + " coil_height=20,\n", + " coil_width=20,\n", + " casing_thickness=10,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil_case.stp\",\n", + ")\n", + "\n", + "component = paramak.BlanketConstantThicknessArcV(\n", + " inner_lower_point=(300, -200),\n", + " inner_mid_point=(500, 0),\n", + " inner_upper_point=(300, 200),\n", + " thickness=100,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_arc_v.stp\",\n", + ")\n", + "\n", + "component = paramak.BlanketConstantThicknessArcH(\n", + " inner_lower_point=(300, -200),\n", + " inner_mid_point=(400, 0),\n", + " inner_upper_point=(300, 200),\n", + " thickness=100,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_arc_h.stp\",\n", + ")\n", + "\n", + "component = paramak.ToroidalFieldCoilRectangle(\n", + " horizontal_start_point=(100, 700),\n", + " vertical_mid_point=(800, 0),\n", + " thickness=150,\n", + " distance=60,\n", + " stp_filename=\"tf_coil_rectangle.stp\",\n", + " number_of_coils=1,\n", + ")\n", + "\n", + "component = paramak.ToroidalFieldCoilCoatHanger(\n", + " horizontal_start_point=(200, 500),\n", + " horizontal_length=400,\n", + " vertical_mid_point=(700, 50),\n", + " vertical_length=500,\n", + " thickness=50,\n", + " distance=50,\n", + " stp_filename=\"toroidal_field_coil_coat_hanger.stp\",\n", + " number_of_coils=1,\n", + ")\n", + "\n", + "component = paramak.ToroidalFieldCoilTripleArc(\n", + " R1=80,\n", + " h=200,\n", + " radii=(70, 100),\n", + " coverages=(60, 60),\n", + " thickness=30,\n", + " distance=30,\n", + " number_of_coils=1,\n", + " stp_filename=\"toroidal_field_coil_triple_arc.stp\"\n", + ")\n", + "\n", + "magnet = paramak.ToroidalFieldCoilPrincetonD(\n", + " R1=80,\n", + " R2=300,\n", + " thickness=30,\n", + " distance=30,\n", + " number_of_coils=1,\n", + " stp_filename=\"toroidal_field_coil_princeton_d.stp\"\n", + ")\n", + "\n", + "component = paramak.ITERtypeDivertor(\n", + " # default parameters\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"ITER_type_divertor.stp\",\n", + ")\n", + "\n", + "component = paramak.PortCutterRotated(\n", + " center_point=(450, 0),\n", + " polar_coverage_angle=20,\n", + " rotation_angle=10,\n", + " polar_placement_angle=45,\n", + " azimuth_placement_angle=0\n", + ")\n", + "\n", + "component = paramak.PortCutterRectangular(\n", + " distance=3,\n", + " center_point=(0, 0),\n", + " height=0.2,\n", + " width=0.4,\n", + " fillet_radius=0.02,\n", + " azimuth_placement_angle=[0, 45, 90, 180]\n", + ")\n", + "\n", + "component = paramak.PortCutterCircular(\n", + " distance=3,\n", + " center_point=(0.25, 0),\n", + " radius=0.1,\n", + " # azimuth_placement_angle=[0, 45, 90, 180], # TODO: fix issue #548\n", + " azimuth_placement_angle=[0, 45, 90],\n", + ")\n", + "\n", + "component = paramak.VacuumVessel(\n", + " height=2, inner_radius=1, thickness=0.2, rotation_angle=270\n", + ")\n", + "\n", + "component = paramak.CoolantChannelRingStraight(\n", + " height=200,\n", + " channel_radius=10,\n", + " ring_radius=70,\n", + " number_of_coolant_channels=8,\n", + " workplane=\"XY\",\n", + " rotation_axis=\"Z\",\n", + " stp_filename=\"coolant_channel_ring_straight.stp\",\n", + ")\n", + "\n", + "component = paramak.CoolantChannelRingCurved(\n", + " height=200,\n", + " channel_radius=10,\n", + " ring_radius=70,\n", + " mid_offset=-20,\n", + " number_of_coolant_channels=8,\n", + " workplane=\"XY\",\n", + " path_workplane=\"XZ\",\n", + " stp_filename=\"coolant_channel_ring_curved.stp\",\n", + " force_cross_section=True\n", + ")\n", + "\n", + "component = paramak.RotatedIsoscelesTriangle(\n", + " height=20,\n", + " base_length=15,\n", + " pivot_angle=0,\n", + " pivot_point=(100, 50),\n", + " rotation_angle=70,\n", + " workplane='XY',\n", + " stp_filename='rotated_isosceles_triangle.stp'\n", + ")\n", + "\n", + "component = paramak.RotatedTrapezoid(\n", + " length_1=10,\n", + " length_2=20,\n", + " length_3=30,\n", + " pivot_angle=0,\n", + " pivot_point=(100, 50),\n", + " rotation_angle=45,\n", + " stp_filename='rotated_trapezoid.stp'\n", + ")\n", + "\n", + "component = paramak.PoloidalSegments(\n", + " number_of_segments=5,\n", + " center_point=(400, 50)\n", + ")\n", + "\n", + "component = paramak.TFCoilCasing(\n", + " magnet=magnet,\n", + " inner_offset=10,\n", + " outer_offset=15,\n", + " vertical_section_offset=20,\n", + " distance=40\n", + ")\n", + "\n", + "component = paramak.HexagonPin(\n", + " length_of_side=5,\n", + " distance=10,\n", + " center_point=(10, 20)\n", + ")\n", + "\n", + "component = paramak.VacuumVesselInnerLeg(\n", + " inner_height=760,\n", + " inner_radius=400,\n", + " inner_leg_radius=250,\n", + " thickness=20\n", + ")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_all_parametric_components.py b/examples/example_parametric_components/make_all_parametric_components.py deleted file mode 100644 index d1d5ac533..000000000 --- a/examples/example_parametric_components/make_all_parametric_components.py +++ /dev/null @@ -1,445 +0,0 @@ -""" -This python script demonstrates the creation of all parametric shapes available -in the paramak tool -""" - -import paramak - - -def main(): - - rot_angle = 180 - all_components = [] - - plasma = paramak.Plasma( - # default parameters - rotation_angle=rot_angle, - stp_filename="plasma_shape.stp", - ) - all_components.append(plasma) - - component = paramak.BlanketFP( - plasma=plasma, - thickness=100, - stop_angle=90, - start_angle=-90, - offset_from_plasma=30, - rotation_angle=rot_angle, - stp_filename="blanket_constant_thickness_outboard_plasma.stp", - ) - all_components.append(component) - - component = paramak.BlanketCutterStar( - height=2000, - width=2000, - distance=100) - all_components.append(component) - - component = paramak.BlanketFP( - plasma=plasma, - thickness=100, - stop_angle=90, - start_angle=250, - offset_from_plasma=30, - rotation_angle=rot_angle, - stp_filename="blanket_constant_thickness_inboard_plasma.stp", - ) - all_components.append(component) - - component = paramak.BlanketFP( - plasma=plasma, - thickness=100, - stop_angle=250, - start_angle=-90, - offset_from_plasma=30, - rotation_angle=rot_angle, - stp_filename="blanket_constant_thickness_plasma.stp", - ) - all_components.append(component) - - CenterColumnShieldCylinder = paramak.CenterColumnShieldCylinder( - inner_radius=80, - outer_radius=100, - height=300, - rotation_angle=rot_angle, - stp_filename="center_column_shield_cylinder.stp", - ) - all_components.append(CenterColumnShieldCylinder) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldCylinder, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_cylinder.stp", - ) - all_components.append(component) - - CenterColumnShieldHyperbola = paramak.CenterColumnShieldHyperbola( - inner_radius=50, - mid_radius=75, - outer_radius=100, - height=300, - rotation_angle=rot_angle, - stp_filename="center_column_shield_hyperbola.stp", - ) - all_components.append(CenterColumnShieldHyperbola) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldHyperbola, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_hyperbola.stp", - ) - all_components.append(component) - - CenterColumnShieldCircular = paramak.CenterColumnShieldCircular( - inner_radius=50, - mid_radius=75, - outer_radius=100, - height=300, - rotation_angle=rot_angle, - stp_filename="center_column_shield_circular.stp", - ) - all_components.append(CenterColumnShieldCircular) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldCircular, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_circular.stp", - ) - all_components.append(component) - - CenterColumnShieldFlatTopHyperbola = paramak.CenterColumnShieldFlatTopHyperbola( - inner_radius=50, - mid_radius=75, - outer_radius=100, - arc_height=220, - height=300, - rotation_angle=rot_angle, - stp_filename="center_column_shield_flat_top_hyperbola.stp", - ) - all_components.append(CenterColumnShieldFlatTopHyperbola) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldFlatTopHyperbola, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_flat_top_hyperbola.stp", - ) - all_components.append(component) - - CenterColumnShieldFlatTopCircular = paramak.CenterColumnShieldFlatTopCircular( - inner_radius=50, - mid_radius=75, - outer_radius=100, - arc_height=220, - height=300, - rotation_angle=rot_angle, - stp_filename="center_column_shield_flat_top_Circular.stp", - ) - all_components.append(CenterColumnShieldFlatTopCircular) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldFlatTopCircular, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_flat_top_Circular.stp", - ) - all_components.append(component) - - CenterColumnShieldPlasmaHyperbola = paramak.CenterColumnShieldPlasmaHyperbola( - inner_radius=150, - mid_offset=50, - edge_offset=40, - height=800, - rotation_angle=rot_angle, - stp_filename="center_column_shield_plasma_hyperbola.stp", - ) - all_components.append(CenterColumnShieldPlasmaHyperbola) - - component = paramak.InboardFirstwallFCCS( - central_column_shield=CenterColumnShieldPlasmaHyperbola, - thickness=50, - rotation_angle=rot_angle, - stp_filename="firstwall_from_center_column_shield_plasma_hyperbola.stp", - ) - all_components.append(component) - - component = paramak.InnerTfCoilsCircular( - inner_radius=25, - outer_radius=100, - number_of_coils=10, - gap_size=5, - height=300, - stp_filename="inner_tf_coils_circular.stp", - ) - all_components.append(component) - - component = paramak.InnerTfCoilsFlat( - inner_radius=25, - outer_radius=100, - number_of_coils=10, - gap_size=5, - height=300, - stp_filename="inner_tf_coils_flat.stp", - ) - all_components.append(component) - - # this makes 4 pf coil cases - pf_coil_set = paramak.PoloidalFieldCoilCaseSet( - heights=[10, 10, 20, 20], - widths=[10, 10, 20, 40], - casing_thicknesses=[5, 5, 10, 10], - center_points=[(100, 100), (100, 150), (50, 200), (50, 50)], - rotation_angle=rot_angle, - stp_filename="pf_coil_case_set.stp" - ) - all_components.append(pf_coil_set) - - # this makes 4 pf coils - pf_coil_set = paramak.PoloidalFieldCoilSet( - heights=[10, 10, 20, 20], - widths=[10, 10, 20, 40], - center_points=[(100, 100), (100, 150), (50, 200), (50, 50)], - rotation_angle=rot_angle, - stp_filename="pf_coil_set.stp" - ) - all_components.append(pf_coil_set) - - # this makes 4 pf coil cases for the 4 pf coils made above - component = paramak.PoloidalFieldCoilCaseSetFC( - pf_coils=pf_coil_set, - casing_thicknesses=[5, 5, 10, 10], - rotation_angle=rot_angle, - stp_filename="pf_coil_cases_set.stp" - ) - all_components.append(component) - - # this makes 1 pf coils - pf_coil = paramak.PoloidalFieldCoil( - center_point=(100, 100), - height=20, - width=20, - rotation_angle=rot_angle, - stp_filename="poloidal_field_coil.stp" - ) - all_components.append(pf_coil) - - # this makes one PF coil case for the provided pf coil - component = paramak.PoloidalFieldCoilCaseSetFC( - pf_coils=[pf_coil], - casing_thicknesses=[10], - rotation_angle=rot_angle, - stp_filename="pf_coil_cases_set_fc.stp") - all_components.append(component) - - component = paramak.PoloidalFieldCoilCaseFC( - pf_coil=pf_coil, - casing_thickness=10, - rotation_angle=rot_angle, - stp_filename="poloidal_field_coil_case_fc.stp", - ) - all_components.append(component) - - component = paramak.PoloidalFieldCoilCase( - center_point=(100, 100), - coil_height=20, - coil_width=20, - casing_thickness=10, - rotation_angle=rot_angle, - stp_filename="poloidal_field_coil_case.stp", - ) - all_components.append(component) - - component = paramak.BlanketConstantThicknessArcV( - inner_lower_point=(300, -200), - inner_mid_point=(500, 0), - inner_upper_point=(300, 200), - thickness=100, - rotation_angle=rot_angle, - stp_filename="blanket_arc_v.stp", - ) - all_components.append(component) - - component = paramak.BlanketConstantThicknessArcH( - inner_lower_point=(300, -200), - inner_mid_point=(400, 0), - inner_upper_point=(300, 200), - thickness=100, - rotation_angle=rot_angle, - stp_filename="blanket_arc_h.stp", - ) - all_components.append(component) - - component = paramak.ToroidalFieldCoilRectangle( - horizontal_start_point=(100, 700), - vertical_mid_point=(800, 0), - thickness=150, - distance=60, - stp_filename="tf_coil_rectangle.stp", - number_of_coils=1, - ) - all_components.append(component) - - component = paramak.ToroidalFieldCoilCoatHanger( - horizontal_start_point=(200, 500), - horizontal_length=400, - vertical_mid_point=(700, 50), - vertical_length=500, - thickness=50, - distance=50, - stp_filename="toroidal_field_coil_coat_hanger.stp", - number_of_coils=1, - ) - all_components.append(component) - - component = paramak.ToroidalFieldCoilTripleArc( - R1=80, - h=200, - radii=(70, 100), - coverages=(60, 60), - thickness=30, - distance=30, - number_of_coils=1, - stp_filename="toroidal_field_coil_triple_arc.stp" - ) - all_components.append(component) - - 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(magnet) - - component = paramak.ITERtypeDivertor( - # default parameters - rotation_angle=rot_angle, - stp_filename="ITER_type_divertor.stp", - ) - all_components.append(component) - - component = paramak.PortCutterRotated( - center_point=(450, 0), - polar_coverage_angle=20, - rotation_angle=10, - polar_placement_angle=45, - azimuth_placement_angle=0 - ) - all_components.append(component) - - component = paramak.PortCutterRectangular( - distance=3, - center_point=(0, 0), - height=0.2, - width=0.4, - fillet_radius=0.02, - azimuth_placement_angle=[0, 45, 90, 180] - ) - all_components.append(component) - - component = paramak.PortCutterCircular( - distance=3, - center_point=(0.25, 0), - radius=0.1, - # azimuth_placement_angle=[0, 45, 90, 180], # TODO: fix issue #548 - azimuth_placement_angle=[0, 45, 90], - ) - all_components.append(component) - - component = paramak.VacuumVessel( - height=2, inner_radius=1, thickness=0.2, rotation_angle=270 - ) - all_components.append(component) - - component = paramak.CoolantChannelRingStraight( - height=200, - channel_radius=10, - ring_radius=70, - number_of_coolant_channels=8, - workplane="XY", - rotation_axis="Z", - stp_filename="coolant_channel_ring_straight.stp", - ) - all_components.append(component) - - component = paramak.CoolantChannelRingCurved( - height=200, - channel_radius=10, - ring_radius=70, - mid_offset=-20, - number_of_coolant_channels=8, - workplane="XY", - path_workplane="XZ", - stp_filename="coolant_channel_ring_curved.stp", - force_cross_section=True - ) - all_components.append(component) - - component = paramak.RotatedIsoscelesTriangle( - height=20, - base_length=15, - pivot_angle=0, - pivot_point=(100, 50), - rotation_angle=70, - workplane='XY', - stp_filename='rotated_isosceles_triangle.stp' - ) - all_components.append(component) - - component = paramak.RotatedTrapezoid( - length_1=10, - length_2=20, - length_3=30, - pivot_angle=0, - pivot_point=(100, 50), - rotation_angle=45, - stp_filename='rotated_trapezoid.stp' - ) - 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) - - component = paramak.VacuumVesselInnerLeg( - inner_height=760, - inner_radius=400, - inner_leg_radius=250, - thickness=20 - ) - all_components.append(component) - - return all_components - - -if __name__ == "__main__": - all_components = 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) diff --git a/examples/example_parametric_components/make_all_parametric_components_images_for_docs.py b/examples/example_parametric_components/make_all_parametric_components_images_for_docs.py deleted file mode 100644 index 02d2fd66b..000000000 --- a/examples/example_parametric_components/make_all_parametric_components_images_for_docs.py +++ /dev/null @@ -1,19 +0,0 @@ -""" -This python script demonstrates the creation of all parametric shapes available -in the paramak tool -""" - -from make_all_parametric_components import main - - -def export_images(): - - all_componets = main() - - for componet in all_componets: - componet.workplane = "XY" - componet.export_svg(componet.stp_filename[:-3] + "svg") - - -if __name__ == "__main__": - export_images() diff --git a/examples/example_parametric_components/make_demo_style_blankets.ipynb b/examples/example_parametric_components/make_demo_style_blankets.ipynb new file mode 100644 index 000000000..d2e47efa0 --- /dev/null +++ b/examples/example_parametric_components/make_demo_style_blankets.ipynb @@ -0,0 +1,128 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"\n", + "This script makes a blanket and then segments it in a similar\n", + "manner to the EU DEMO segmentation for remote maintenance.\n", + "\"\"\"\n", + "\n", + "import math\n", + "\n", + "import numpy as np\n", + "import paramak\n", + "\n", + "\n", + "number_of_segments = 8\n", + "gap_size = 15.\n", + "central_block_width = 200\n", + "\n", + "offset = (360 / number_of_segments) / 2\n", + "\n", + "# a plasma shape is made and used by the BlanketFP, which builds around\n", + "# the plasma\n", + "plasma = paramak.Plasma(\n", + " elongation=1.59,\n", + " triangularity=0.33,\n", + " major_radius=910,\n", + " minor_radius=290)\n", + "plasma.solid\n", + "\n", + "# this makes a cutter shape that is used to make the blanket bananna\n", + "# segment that has parallel sides\n", + "parallel_outboard_gaps_outer = paramak.BlanketCutterParallels(\n", + " thickness=gap_size, azimuth_placement_angle=np.linspace(\n", + " 0, 360, number_of_segments, endpoint=False),\n", + " gap_size=central_block_width)\n", + "\n", + "# this makes a gap that seperates the inboard and outboard blanket\n", + "inboard_to_outboard_gaps = paramak.ExtrudeStraightShape(\n", + " points=[(plasma.high_point[0] - (0.5 * gap_size), plasma.high_point[1]),\n", + " (plasma.high_point[0] - (0.5 * gap_size), plasma.high_point[1] + 1000),\n", + " (plasma.high_point[0] + (0.5 * gap_size), plasma.high_point[1] + 1000),\n", + " (plasma.high_point[0] + (0.5 * gap_size), plasma.high_point[1]),\n", + " ],\n", + " distance=math.tan(math.radians(360 / (2 * number_of_segments))) * plasma.high_point[0] * 2,\n", + " azimuth_placement_angle=np.linspace(0, 360, number_of_segments, endpoint=False)\n", + ")\n", + "\n", + "# this makes the regular gaps (non parallel) gaps on the outboard blanket\n", + "outboard_gaps = paramak.BlanketCutterStar(\n", + " distance=gap_size,\n", + " azimuth_placement_angle=np.linspace(\n", + " 0 + offset,\n", + " 360 + offset,\n", + " number_of_segments,\n", + " endpoint=False)\n", + ")\n", + "\n", + "# makes the outboard blanket with cuts for all the segmentation\n", + "outboard_blanket = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=-60,\n", + " offset_from_plasma=30,\n", + " rotation_angle=360,\n", + " cut=[\n", + " outboard_gaps,\n", + " parallel_outboard_gaps_outer,\n", + " inboard_to_outboard_gaps])\n", + "\n", + "# this makes the regular gaps on the outboard blanket\n", + "inboard_gaps = paramak.BlanketCutterStar(\n", + " distance=gap_size, azimuth_placement_angle=np.linspace(\n", + " 0, 360, number_of_segments * 2, endpoint=False))\n", + "\n", + "# makes the inboard blanket with cuts for all the segmentation\n", + "inboard_blanket = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=260,\n", + " offset_from_plasma=30,\n", + " rotation_angle=360,\n", + " cut=[inboard_gaps, inboard_to_outboard_gaps],\n", + " union=outboard_blanket\n", + ")\n", + "\n", + "inboard_blanket.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# saves the blanket as an stp file\n", + "inboard_blanket.export_stp('blanket.stp')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_demo_style_blankets.py b/examples/example_parametric_components/make_demo_style_blankets.py deleted file mode 100644 index ebad2f705..000000000 --- a/examples/example_parametric_components/make_demo_style_blankets.py +++ /dev/null @@ -1,93 +0,0 @@ - -""" -This script makes a blanket and then segments it in a similar -manner to the EU DEMO segmentation for remote maintenance. -""" - -import math - -import numpy as np -import paramak - - -def main(number_of_sections=8, gap_size=15, central_block_width=200): - - number_of_segments = 8 - gap_size = 15. - central_block_width = 200 - - offset = (360 / number_of_segments) / 2 - - # a plasma shape is made and used by the BlanketFP, which builds around - # the plasma - plasma = paramak.Plasma( - elongation=1.59, - triangularity=0.33, - major_radius=910, - minor_radius=290) - plasma.solid - - # this makes a cutter shape that is used to make the blanket bananna - # segment that has parallel sides - parallel_outboard_gaps_outer = paramak.BlanketCutterParallels( - thickness=gap_size, azimuth_placement_angle=np.linspace( - 0, 360, number_of_segments, endpoint=False), - gap_size=central_block_width) - - # this makes a gap that seperates the inboard and outboard blanket - inboard_to_outboard_gaps = paramak.ExtrudeStraightShape( - points=[(plasma.high_point[0] - (0.5 * gap_size), plasma.high_point[1]), - (plasma.high_point[0] - (0.5 * gap_size), plasma.high_point[1] + 1000), - (plasma.high_point[0] + (0.5 * gap_size), plasma.high_point[1] + 1000), - (plasma.high_point[0] + (0.5 * gap_size), plasma.high_point[1]), - ], - distance=math.tan(math.radians(360 / (2 * number_of_segments))) * plasma.high_point[0] * 2, - azimuth_placement_angle=np.linspace(0, 360, number_of_segments, endpoint=False) - ) - - # this makes the regular gaps (non parallel) gaps on the outboard blanket - outboard_gaps = paramak.BlanketCutterStar( - distance=gap_size, - azimuth_placement_angle=np.linspace( - 0 + offset, - 360 + offset, - number_of_segments, - endpoint=False) - ) - - # makes the outboard blanket with cuts for all the segmentation - outboard_blanket = paramak.BlanketFP( - plasma=plasma, - thickness=100, - stop_angle=90, - start_angle=-60, - offset_from_plasma=30, - rotation_angle=360, - cut=[ - outboard_gaps, - parallel_outboard_gaps_outer, - inboard_to_outboard_gaps]) - - # this makes the regular gaps on the outboard blanket - inboard_gaps = paramak.BlanketCutterStar( - distance=gap_size, azimuth_placement_angle=np.linspace( - 0, 360, number_of_segments * 2, endpoint=False)) - - # makes the inboard blanket with cuts for all the segmentation - inboard_blanket = paramak.BlanketFP( - plasma=plasma, - thickness=100, - stop_angle=90, - start_angle=260, - offset_from_plasma=30, - rotation_angle=360, - cut=[inboard_gaps, inboard_to_outboard_gaps], - union=outboard_blanket - ) - - # saves the blanket as an stp file - inboard_blanket.export_stp('blanket.stp') - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.ipynb b/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.ipynb new file mode 100644 index 000000000..f30037c07 --- /dev/null +++ b/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.ipynb @@ -0,0 +1,74 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"\n", + "For some neutronics tallies such as neutron wall loading it is necessary to\n", + "segment the geometry so that individual neutronics tallies can be recorded\n", + "for each face. This can be done using the PoloidalSegments(). With this\n", + "segmented geometry it is then easier to find neutron wall loading as a function\n", + "of poloidal angle.\n", + "\"\"\"\n", + "\n", + "import paramak\n", + "\n", + "\n", + "# makes the firstwall\n", + "firstwall = paramak.BlanketFP(\n", + " minor_radius=150,\n", + " major_radius=450,\n", + " triangularity=0.55,\n", + " elongation=2.0,\n", + " thickness=2,\n", + " start_angle=270,\n", + " stop_angle=-90,\n", + " rotation_angle=10\n", + ")\n", + "\n", + "# segments the firstwall poloidally into 40 equal angle segments\n", + "segmented_firstwall = paramak.PoloidalSegments(\n", + " shape_to_segment=firstwall,\n", + " center_point=(450, 0), # this is the middle of the plasma\n", + " number_of_segments=40,\n", + ")\n", + "\n", + "segmented_firstwall.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# saves the segmented firstwall as an stp file\n", + "segmented_firstwall.export_stp('segmented_firstwall.stp')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.py b/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.py deleted file mode 100644 index 841a95edf..000000000 --- a/examples/example_parametric_components/make_firstwall_for_neutron_wall_loading.py +++ /dev/null @@ -1,37 +0,0 @@ - -""" -For some neutronics tallies such as neutron wall loading it is necessary to -segment the geometry so that individual neutronics tallies can be recorded -for each face. This can be done using the PoloidalSegments(). With this -segmented geometry it is then easier to find neutron wall loading as a function -of poloidal angle. -""" - -import paramak - - -def main(): - - # makes the firstwall - firstwall = paramak.BlanketFP(minor_radius=150, - major_radius=450, - triangularity=0.55, - elongation=2.0, - thickness=2, - start_angle=270, - stop_angle=-90, - rotation_angle=10) - - # segments the firstwall poloidally into 40 equal angle segments - segmented_firstwall = paramak.PoloidalSegments( - shape_to_segment=firstwall, - center_point=(450, 0), # this is the middle of the plasma - number_of_segments=40, - ) - - # saves the segmented firstwall as an stp file - segmented_firstwall.export_stp('segmented_firstwall.stp') - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_magnet_set.ipynb b/examples/example_parametric_components/make_magnet_set.ipynb new file mode 100644 index 000000000..653e77373 --- /dev/null +++ b/examples/example_parametric_components/make_magnet_set.ipynb @@ -0,0 +1,117 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\"\"\"\n", + "This script makes a set of toroidal and poloidal field coils. Including PF\n", + "coils, PF coil cases, TF coils, TF coil cases and inboard TF coil supports.\n", + "\"\"\"\n", + "\n", + "import paramak\n", + "\n", + "\n", + "number_of_toroidal_field_coils = 8\n", + "angle_offset = (360 / number_of_toroidal_field_coils) / 2.\n", + "tf_coil_thickness = 50\n", + "tf_coil_distance = 130\n", + "\n", + "tf_coil_casing_distance = tf_coil_distance + 40\n", + "tf_coil_casing_thickness = 20\n", + "\n", + "inner_tf_case = paramak.InnerTfCoilsFlat(\n", + " height=1800,\n", + " inner_radius=330,\n", + " outer_radius=430,\n", + " number_of_coils=number_of_toroidal_field_coils,\n", + " gap_size=5,\n", + " rotation_angle=180,\n", + " azimuth_start_angle=angle_offset\n", + ")\n", + "\n", + "tf_coils = paramak.ToroidalFieldCoilPrincetonD(\n", + " R1=400,\n", + " R2=1500, # height\n", + " thickness=tf_coil_thickness,\n", + " distance=tf_coil_distance,\n", + " number_of_coils=number_of_toroidal_field_coils,\n", + " rotation_angle=180,\n", + ")\n", + "\n", + "tf_coil_casing = paramak.TFCoilCasing(\n", + " magnet=tf_coils,\n", + " distance=tf_coil_casing_distance,\n", + " inner_offset=tf_coil_casing_thickness,\n", + " outer_offset=tf_coil_casing_thickness,\n", + " vertical_section_offset=tf_coil_casing_thickness,\n", + " # rotation_angle=180, # producing occational errors with this arg\n", + ")\n", + "\n", + "pf_coils = paramak.PoloidalFieldCoilSet(\n", + " heights=[100, 120, 80, 80, 120, 180],\n", + " widths=[100, 120, 80, 80, 120, 180],\n", + " center_points=[\n", + " (530, 1030),\n", + " (1370, 790),\n", + " (1740, 250),\n", + " (1750, -250),\n", + " (1360, -780),\n", + " (680, -1050)\n", + " ],\n", + " rotation_angle=180\n", + ")\n", + "\n", + "pf_coils_casing = paramak.PoloidalFieldCoilCaseSetFC(\n", + " pf_coils=pf_coils,\n", + " casing_thicknesses=[10] * 6,\n", + " rotation_angle=180\n", + ")\n", + "\n", + "my_magnets = paramak.Reactor([pf_coils, tf_coils, tf_coil_casing, inner_tf_case])\n", + "my_magnets.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pf_coils.export_stp('pf_coils.stp')\n", + "\n", + "pf_coils_casing.export_stp('pf_coils_case.stp')\n", + "\n", + "tf_coils.export_stp('tf_coil.stp')\n", + "\n", + "tf_coil_casing.export_stp('tf_coil_casing.stp')\n", + "\n", + "inner_tf_case.export_stp('inner_tf_case.stp')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_magnet_set.py b/examples/example_parametric_components/make_magnet_set.py deleted file mode 100644 index 3bf050054..000000000 --- a/examples/example_parametric_components/make_magnet_set.py +++ /dev/null @@ -1,77 +0,0 @@ - -""" -This script makes a set of toroidal and poloidal field coils. Including PF -coils, PF coil cases, TF coils, TF coil cases and inboard TF coil supports. -""" - -import paramak - - -def main(): - - number_of_toroidal_field_coils = 8 - angle_offset = (360 / number_of_toroidal_field_coils) / 2. - tf_coil_thickness = 50 - tf_coil_distance = 130 - - tf_coil_casing_distance = tf_coil_distance + 40 - tf_coil_casing_thickness = 20 - - inner_tf_case = paramak.InnerTfCoilsFlat( - height=1800, - inner_radius=330, - outer_radius=430, - number_of_coils=number_of_toroidal_field_coils, - gap_size=5, - rotation_angle=180, - azimuth_start_angle=angle_offset - ) - - tf_coils = paramak.ToroidalFieldCoilPrincetonD( - R1=400, - R2=1500, # height - thickness=tf_coil_thickness, - distance=tf_coil_distance, - number_of_coils=number_of_toroidal_field_coils, - rotation_angle=180, - ) - - tf_coil_casing = paramak.TFCoilCasing( - magnet=tf_coils, - distance=tf_coil_casing_distance, - inner_offset=tf_coil_casing_thickness, - outer_offset=tf_coil_casing_thickness, - vertical_section_offset=tf_coil_casing_thickness, - # rotation_angle=180, # producing occational errors with this arg - ) - - pf_coils = paramak.PoloidalFieldCoilSet( - heights=[100, 120, 80, 80, 120, 180], - widths=[100, 120, 80, 80, 120, 180], - center_points=[ - (530, 1030), - (1370, 790), - (1740, 250), - (1750, -250), - (1360, -780), - (680, -1050) - ], - rotation_angle=180 - ) - - pf_coils_casing = paramak.PoloidalFieldCoilCaseSetFC( - pf_coils=pf_coils, - casing_thicknesses=[10] * 6, - rotation_angle=180 - ) - - pf_coils.export_stp('pf_coils.stp') - pf_coils_casing.export_stp('pf_coils_case.stp') - - tf_coils.export_stp('tf_coil.stp') - tf_coil_casing.export_stp('tf_coil_casing.stp') - inner_tf_case.export_stp('inner_tf_case.stp') - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_plasmas.ipynb b/examples/example_parametric_components/make_plasmas.ipynb new file mode 100644 index 000000000..b0c634988 --- /dev/null +++ b/examples/example_parametric_components/make_plasmas.ipynb @@ -0,0 +1,141 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"\n", + "This python script demonstrates the creation of plasmas\n", + "\"\"\"\n", + "\n", + "import paramak\n", + "\n", + " \n", + "ITER_simple = paramak.Plasma(\n", + " major_radius=620,\n", + " minor_radius=210,\n", + " triangularity=0.33,\n", + " elongation=1.85,\n", + " name=\"ITER_plasma\",\n", + " rotation_angle=1,\n", + " color=(0,1,0)\n", + ")\n", + "\n", + "ITER = paramak.PlasmaBoundaries(\n", + " A=-0.155,\n", + " major_radius=620,\n", + " minor_radius=210,\n", + " triangularity=0.33,\n", + " elongation=1.85,\n", + " name=\"ITER_plasma_plasmaboundaries\",\n", + " rotation_angle=1,\n", + " color=(1,0,0),\n", + " azimuth_placement_angle=(360/7)\n", + ")\n", + "\n", + "EU_DEMO = paramak.Plasma(\n", + " name=\"EU_DEMO_plasma\",\n", + " major_radius=910,\n", + " minor_radius=290,\n", + " triangularity=0.33,\n", + " elongation=1.59,\n", + " rotation_angle=1,\n", + " color=(0.9, 0.1, 0.1),\n", + " azimuth_placement_angle=(360/7)*2\n", + ")\n", + "\n", + "ST = paramak.Plasma(\n", + " name=\"ST_plasma\",\n", + " major_radius=170,\n", + " minor_radius=129,\n", + " triangularity=0.55,\n", + " elongation=2.3,\n", + " rotation_angle=1,\n", + " color=(0.2, 0.6, 0.2),\n", + " azimuth_placement_angle=(360/7)*3\n", + ")\n", + "\n", + "AST = paramak.Plasma(\n", + " name=\"AST_plasma\",\n", + " major_radius=170,\n", + " minor_radius=129,\n", + " triangularity=-0.55,\n", + " elongation=2.3,\n", + " rotation_angle=1,\n", + " color=(0, 0, 0),\n", + " azimuth_placement_angle=(360/7)*4\n", + ")\n", + "\n", + "NSTX_double_null = paramak.PlasmaBoundaries(\n", + " name=\"NSTX_double_null_plasma_plasmaboundaries\",\n", + " A=0,\n", + " major_radius=850,\n", + " minor_radius=680,\n", + " triangularity=0.35,\n", + " elongation=2,\n", + " color=(1, 1, 0),\n", + " rotation_angle=1,\n", + " configuration=\"double-null\",\n", + " azimuth_placement_angle=(360/7)*5\n", + ")\n", + "\n", + "NSTX_single_null = paramak.PlasmaBoundaries(\n", + " name=\"NSTX_single_null_plasma_plasmaboundaries\",\n", + " A=-0.05,\n", + " major_radius=850,\n", + " minor_radius=680,\n", + " triangularity=0.35,\n", + " elongation=2,\n", + " color=(0.6, 0.3, 0.6),\n", + " rotation_angle=1,\n", + " configuration=\"single-null\",\n", + " azimuth_placement_angle=(360/7)*6\n", + ")\n", + "\n", + "# combines all the plasma into a single object\n", + "all_plasmas = paramak.Reactor([ITER_simple, ITER, EU_DEMO, ST, AST, NSTX_double_null, NSTX_single_null])\n", + "\n", + "all_plasmas.show() " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "all_plasmas.export_html()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_plasmas.py b/examples/example_parametric_components/make_plasmas.py deleted file mode 100644 index b2c80fe83..000000000 --- a/examples/example_parametric_components/make_plasmas.py +++ /dev/null @@ -1,254 +0,0 @@ -""" -This python script demonstrates the creation of plasmas -""" - -import paramak -import plotly.graph_objects as go - - -def plot_plasma(plasma, name=""): - """Extracts points that make up the plasma and creates a Plotly trace""" - - if name.endswith("plasmaboundaries"): - major_radius = plasma.major_radius - low_point = plasma.low_point - high_point = plasma.high_point - inner_equatorial_point = plasma.inner_equatorial_point - outer_equatorial_point = plasma.outer_equatorial_point - x_points = [row[0] for row in plasma.points] - y_points = [row[1] for row in plasma.points] - - else: - major_radius = plasma.major_radius * -1 - low_point = (plasma.low_point[0] * -1, plasma.low_point[1]) - high_point = (plasma.high_point[0] * -1, plasma.high_point[1]) - inner_equatorial_point = ( - plasma.inner_equatorial_point[0] * -1, - plasma.inner_equatorial_point[1]) - outer_equatorial_point = ( - plasma.outer_equatorial_point[0] * -1, - plasma.outer_equatorial_point[1]) - x_points = [row[0] * -1 for row in plasma.points] - y_points = [row[1] for row in plasma.points] - - traces = [] - - color_list = [i * 255 for i in plasma.color] - color = "rgb(" + str(color_list).strip("[]") + ")" - - traces.append( - go.Scatter( - x=[major_radius], - y=[0], - mode="markers", - name="major_radius", - marker={"color": color}, - ) - ) - - traces.append( - go.Scatter( - x=x_points, - y=y_points, - mode="markers", - name="points", - marker={"color": color}, - ) - ) - - traces.append( - go.Scatter( - x=[low_point[0]], - y=[low_point[1]], - mode="markers", - name="low_point", - marker={"color": color}, - ) - ) - - traces.append( - go.Scatter( - x=[high_point[0]], - y=[high_point[1]], - mode="markers", - name="high_point", - marker={"color": color}, - ) - ) - - traces.append( - go.Scatter( - x=[inner_equatorial_point[0]], - y=[inner_equatorial_point[1]], - mode="markers", - name="inner_equatorial_point", - marker={"color": color}, - ) - ) - - traces.append( - go.Scatter( - x=[outer_equatorial_point[0]], - y=[outer_equatorial_point[1]], - mode="markers", - name="outer_equatorial_point", - marker={"color": color}, - ) - ) - - return traces - - -def make_plasma( - major_radius, - minor_radius, - triangularity, - elongation, - name, - color): - """Creates a plasma object from argument inputs""" - - plasma = paramak.Plasma( - major_radius=major_radius, - minor_radius=minor_radius, - triangularity=triangularity, - elongation=elongation, - ) - plasma.name = "plasma" - plasma.stp_filename = name + ".stp" - plasma.single_null = True - plasma.color = color - plasma.rotation_angle = 180 - plasma.find_points() - plasma.export_2d_image(name + ".png") - plasma.export_html(name + ".html") - plasma.export_stp(name + ".stp") - plasma.create_solid() - - return plasma - - -def make_plasma_plasmaboundaries( - A, - major_radius, - minor_radius, - triangularity, - elongation, - name, - color, - config="single-null", -): - """Creates a plasma object from argument inputs""" - - plasma = paramak.PlasmaBoundaries( - A=A, - major_radius=major_radius, - minor_radius=minor_radius, - triangularity=triangularity, - elongation=elongation, - configuration=config, - rotation_angle=180, - color=color - ) - plasma.name = "plasma" - plasma.export_2d_image(name + ".png") - plasma.export_html(name + ".html") - plasma.export_stp(name + ".stp") - plasma.create_solid() - - return plasma - - -def main(): - - ITER_plasma = make_plasma( - name="ITER_plasma", - major_radius=620, - minor_radius=210, - triangularity=0.33, - elongation=1.85, - color=(0.1, 0.5, 0.7) - ) - - ITER_plasma_plasmaboundaries = make_plasma_plasmaboundaries( - name="ITER_plasma_plasmaboundaries", - A=-0.155, - major_radius=620, - minor_radius=210, - triangularity=0.33, - elongation=1.85, - color=(1, 0.5, 0) - ) - - EU_DEMO_plasma = make_plasma( - name="EU_DEMO_plasma", - major_radius=910, - minor_radius=290, - triangularity=0.33, - elongation=1.59, - color=(0.9, 0.1, 0.1) - ) - - ST_plasma = make_plasma( - name="ST_plasma", - major_radius=170, - minor_radius=129, - triangularity=0.55, - elongation=2.3, - color=(0.2, 0.6, 0.2) - ) - - AST_plasma = make_plasma( - name="AST_plasma", - major_radius=170, - minor_radius=129, - triangularity=-0.55, - elongation=2.3, - color=(0, 0, 0) - ) - - NSTX_double_null_plasma_plasmaboundaries = make_plasma_plasmaboundaries( - name="NSTX_double_null_plasma_plasmaboundaries", - A=0, - major_radius=850, - minor_radius=680, - triangularity=0.35, - elongation=2, - color=(1, 1, 0), - config="double-null" - ) - - NSTX_single_null_plasma_plasmaboundaries = make_plasma_plasmaboundaries( - name="NSTX_single_null_plasma_plasmaboundaries", - A=-0.05, - major_radius=850, - minor_radius=680, - triangularity=0.35, - elongation=2, - color=(0.6, 0.3, 0.6), - config="single-null" - ) - - fig = go.Figure() - fig.add_traces(plot_plasma(plasma=ITER_plasma, name="ITER_plasma")) - fig.add_traces( - plot_plasma( - plasma=ITER_plasma_plasmaboundaries, - name="ITER_plasma_plasmaboundaries")) - fig.add_traces(plot_plasma(plasma=EU_DEMO_plasma, name="EU_DEMO_plasma")) - fig.add_traces(plot_plasma(plasma=ST_plasma, name="ST_plasma")) - fig.add_traces(plot_plasma(plasma=AST_plasma, name="AST_plasma")) - fig.add_traces( - plot_plasma( - plasma=NSTX_double_null_plasma_plasmaboundaries, - name="NSTX_double_null_plasma_plasmaboundaries")) - fig.add_traces( - plot_plasma( - plasma=NSTX_single_null_plasma_plasmaboundaries, - name="NSTX_single_null_plasma_plasmaboundaries")) - fig.show() - fig.write_html("all_plasma_and_points.html") - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_vacuum_vessel_with_ports.ipynb b/examples/example_parametric_components/make_vacuum_vessel_with_ports.ipynb new file mode 100644 index 000000000..2e52f1f8c --- /dev/null +++ b/examples/example_parametric_components/make_vacuum_vessel_with_ports.ipynb @@ -0,0 +1,92 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"\n", + "This python script demonstrates the creation of a vacuum vessel with shaped\n", + "different ports cut out.\n", + "\"\"\"\n", + "\n", + "import numpy as np\n", + "import paramak\n", + "\n", + "\n", + "number_of_ports_in_360_degrees = 12\n", + "angles_for_ports = np.linspace(0, 360, number_of_ports_in_360_degrees)\n", + "\n", + "# makes the upper row of ports\n", + "rotated_ports = paramak.PortCutterRotated(\n", + " center_point=(0, 0),\n", + " polar_coverage_angle=10,\n", + " rotation_angle=10,\n", + " polar_placement_angle=25,\n", + " azimuth_placement_angle=angles_for_ports\n", + ")\n", + "\n", + "# makes the middle row of ports\n", + "circular_ports = paramak.PortCutterCircular(\n", + " distance=5,\n", + " center_point=(0, 0),\n", + " radius=0.2,\n", + " azimuth_placement_angle=angles_for_ports\n", + ")\n", + "\n", + "# makes the lower row of ports\n", + "rectangular_ports = paramak.PortCutterRectangular(\n", + " distance=5,\n", + " center_point=(-1, 0),\n", + " height=0.3,\n", + " width=0.4,\n", + " fillet_radius=0.08,\n", + " azimuth_placement_angle=angles_for_ports\n", + ")\n", + "\n", + "# creates the hollow cylinder vacuum vessel and cuts away the ports\n", + "vacuum_vessel = paramak.VacuumVessel(\n", + " height=4,\n", + " inner_radius=2,\n", + " thickness=0.2,\n", + " cut=[rotated_ports, rectangular_ports, circular_ports]\n", + ")\n", + "\n", + "vacuum_vessel.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# eports images and 3D CAD\n", + "vacuum_vessel.export_svg('vacuum_vessel_with_ports.svg')\n", + "vacuum_vessel.export_stp('vacuum_vessel_with_ports.stp')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py b/examples/example_parametric_components/make_vacuum_vessel_with_ports.py deleted file mode 100644 index 16b3d2b61..000000000 --- a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py +++ /dev/null @@ -1,57 +0,0 @@ - -""" -This python script demonstrates the creation of a vacuum vessel with shaped -different ports cut out. -""" - -import numpy as np -import paramak - - -def main(): - - number_of_ports_in_360_degrees = 12 - angles_for_ports = np.linspace(0, 360, number_of_ports_in_360_degrees) - - # makes the upper row of ports - rotated_ports = paramak.PortCutterRotated( - center_point=(0, 0), - polar_coverage_angle=10, - rotation_angle=10, - polar_placement_angle=25, - azimuth_placement_angle=angles_for_ports - ) - - # makes the middle row of ports - circular_ports = paramak.PortCutterCircular( - distance=5, - center_point=(0, 0), - radius=0.2, - azimuth_placement_angle=angles_for_ports - ) - - # makes the lower row of ports - rectangular_ports = paramak.PortCutterRectangular( - distance=5, - center_point=(-1, 0), - height=0.3, - width=0.4, - fillet_radius=0.08, - azimuth_placement_angle=angles_for_ports - ) - - # creates the hollow cylinder vacuum vessel and cuts away the ports - vacuum_vessel = paramak.VacuumVessel( - height=4, - inner_radius=2, - thickness=0.2, - cut=[rotated_ports, rectangular_ports, circular_ports] - ) - - # eports images and 3D CAD - vacuum_vessel.export_svg('vacuum_vessel_with_ports.svg') - vacuum_vessel.export_stp('vacuum_vessel_with_ports.stp') - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_varible_offset_firstwall.ipynb b/examples/example_parametric_components/make_varible_offset_firstwall.ipynb new file mode 100644 index 000000000..65447a946 --- /dev/null +++ b/examples/example_parametric_components/make_varible_offset_firstwall.ipynb @@ -0,0 +1,88 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "from matplotlib.pyplot import plasma\n", + "from numpy.lib.function_base import angle\n", + "import paramak\n", + "import random\n", + "import subprocess\n", + "\n", + "\n", + "subprocess.call(['rm', 'random_offset_.svg'])\n", + "\n", + "for counter in range(10):\n", + " offset_1 = random.uniform(10, 80)\n", + " offset_2 = random.uniform(10, 80)\n", + " offset_3 = random.uniform(10, 80)\n", + " offset_4 = random.uniform(10, 80)\n", + " offset_5 = random.uniform(10, 80)\n", + "\n", + " offests = [offset_1, offset_2, offset_3, offset_4, offset_5, offset_1]\n", + "\n", + " plasma = paramak.Plasma(\n", + " rotation_angle=35,\n", + " minor_radius=150.0,\n", + " major_radius=450.0,\n", + " triangularity=0.55,\n", + " elongation=2.0,\n", + " )\n", + "\n", + " firstwall = paramak.BlanketFP(\n", + " rotation_angle=35,\n", + " thickness=1,\n", + " start_angle=0,\n", + " stop_angle=360,\n", + " offset_from_plasma=offests\n", + " )\n", + "\n", + " both_shapes = paramak.Reactor([plasma, firstwall])\n", + "\n", + " filename = 'random_offset_'+str(counter).zfill(3)+'.svg'\n", + "\n", + " # saves 3d geomery as svg image, could also be saved as html, stl, or stp\n", + " both_shapes.export_svg(\n", + " filename=filename,\n", + " projectionDir=(5,-5,0),\n", + " showHidden=True,\n", + " )\n", + "\n", + "subprocess.check_call(\n", + " [\"convert\", \"-delay\", \"40\", \"random_offset_*.svg\", \"random_offsets.gif\"])\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_reactors/ball_reactor.py b/examples/example_parametric_reactors/ball_reactor.py deleted file mode 100644 index f10d0ac06..000000000 --- a/examples/example_parametric_reactors/ball_reactor.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -This example creates a ball reactor using the BallReactor parametric reactor. -By default the script saves stp, stl, html and svg files. -""" - -from pathlib import Path - -import paramak - - -def make_ball_reactor(outputs=('stp', 'neutronics', 'svg', 'stl', 'html'), - output_folder='BallReactor'): - - my_reactor = paramak.BallReactor( - inner_bore_radial_thickness=10, - inboard_tf_leg_radial_thickness=30, - center_column_shield_radial_thickness=60, - divertor_radial_thickness=150, - inner_plasma_gap_radial_thickness=30, - plasma_radial_thickness=300, - outer_plasma_gap_radial_thickness=30, - firstwall_radial_thickness=30, - blanket_radial_thickness=50, - blanket_rear_wall_radial_thickness=30, - elongation=2, - triangularity=0.55, - 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, - pf_coil_to_tf_coil_radial_gap=50, - outboard_tf_coil_radial_thickness=100, - outboard_tf_coil_poloidal_thickness=50 - ) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder=output_folder) - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - Path(output_folder) / 'manifest.json') - if 'svg' in outputs: - my_reactor.export_svg(Path(output_folder) / 'reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder=output_folder) - if 'html' in outputs: - my_reactor.export_html(Path(output_folder) / 'reactor.html') - - -if __name__ == "__main__": - make_ball_reactor(('stp', 'neutronics', 'svg', 'stl', 'html')) diff --git a/examples/example_parametric_reactors/ball_reactor_single_null.ipynb b/examples/example_parametric_reactors/ball_reactor_single_null.ipynb new file mode 100644 index 000000000..343372139 --- /dev/null +++ b/examples/example_parametric_reactors/ball_reactor_single_null.ipynb @@ -0,0 +1,83 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak\n", + "\n", + "my_reactor = paramak.SingleNullBallReactor(\n", + " inner_bore_radial_thickness=50,\n", + " inboard_tf_leg_radial_thickness=50,\n", + " center_column_shield_radial_thickness=50,\n", + " divertor_radial_thickness=90,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=200,\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=50,\n", + " blanket_radial_thickness=100,\n", + " blanket_rear_wall_radial_thickness=50,\n", + " elongation=2,\n", + " triangularity=0.55,\n", + " number_of_tf_coils=16,\n", + " rotation_angle=180,\n", + " pf_coil_radial_thicknesses=[50, 50, 50, 50],\n", + " pf_coil_vertical_thicknesses=[50, 50, 50, 50],\n", + " rear_blanket_to_tf_gap=50,\n", + " outboard_tf_coil_radial_thickness=100,\n", + " outboard_tf_coil_poloidal_thickness=50,\n", + " divertor_position=\"lower\"\n", + ")\n", + "\n", + "my_reactor.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "my_reactor.export_stp(filenamee)\n", + "\n", + "my_reactor.export_neutronics_description('manifest.json')\n", + "\n", + "my_reactor.export_svg('reactor.svg')\n", + "\n", + "my_reactor.export_stl()\n", + "\n", + "my_reactor.export_html('reactor.html')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_reactors/ball_reactor_single_null.py b/examples/example_parametric_reactors/ball_reactor_single_null.py deleted file mode 100644 index 258ff7e20..000000000 --- a/examples/example_parametric_reactors/ball_reactor_single_null.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -This example creates a single null ball reactor using the SingleNullBallReactor -parametric reactor. By default the script saves stp, stl, html and svg files. -""" - -from pathlib import Path - -import paramak - - -def make_ball_reactor_sn(outputs=['stp', 'neutronics', 'svg', 'stl', 'html'], - output_folder='BallReactor_sn'): - - my_reactor = paramak.SingleNullBallReactor( - inner_bore_radial_thickness=50, - inboard_tf_leg_radial_thickness=50, - center_column_shield_radial_thickness=50, - divertor_radial_thickness=90, - inner_plasma_gap_radial_thickness=50, - plasma_radial_thickness=200, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=50, - blanket_radial_thickness=100, - blanket_rear_wall_radial_thickness=50, - elongation=2, - triangularity=0.55, - number_of_tf_coils=16, - rotation_angle=180, - pf_coil_radial_thicknesses=[50, 50, 50, 50], - pf_coil_vertical_thicknesses=[50, 50, 50, 50], - rear_blanket_to_tf_gap=50, - outboard_tf_coil_radial_thickness=100, - outboard_tf_coil_poloidal_thickness=50, - divertor_position="lower" - ) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder=output_folder) - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - Path(output_folder) / 'manifest.json') - if 'svg' in outputs: - my_reactor.export_svg(Path(output_folder) / 'reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder=output_folder) - if 'html' in outputs: - my_reactor.export_html(Path(output_folder) / 'reactor.html') - - -if __name__ == "__main__": - make_ball_reactor_sn(['stp', 'neutronics', 'svg', 'stl', 'html']) diff --git a/examples/example_parametric_reactors/center_column_study_reactor.py b/examples/example_parametric_reactors/center_column_study_reactor.py deleted file mode 100644 index 79a010c20..000000000 --- a/examples/example_parametric_reactors/center_column_study_reactor.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -This example creates a center column study reactor using a parametric reactor. -Adds some TF coils to the reactor. By default the script saves stp, stl, -html and svg files. -""" - -import paramak - - -def make_center_column_study_reactor( - outputs=[ - 'stp', - 'neutronics', - 'svg', - 'stl', - 'html']): - - my_reactor = paramak.CenterColumnStudyReactor( - inner_bore_radial_thickness=20, - inboard_tf_leg_radial_thickness=50, - center_column_shield_radial_thickness_mid=50, - center_column_shield_radial_thickness_upper=100, - inboard_firstwall_radial_thickness=20, - divertor_radial_thickness=100, - inner_plasma_gap_radial_thickness=80, - plasma_radial_thickness=200, - outer_plasma_gap_radial_thickness=90, - elongation=2.3, - triangularity=0.45, - plasma_gap_vertical_thickness=40, - center_column_arc_vertical_thickness=520, - rotation_angle=180) - - # adding in some TF coils - tf_magnet = paramak.ToroidalFieldCoilPrincetonD( - R1=20 + 50, - R2=20 + 50 + 50 + 80 + 200 + 90 + 100 + 20, - thickness=50, - distance=50, - number_of_coils=12, - rotation_angle=180 - ) - - my_reactor.shapes_and_components.append(tf_magnet) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder='CenterColumnStudyReactor') - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - 'CenterColumnStudyReactor/manifest.json') - if 'svg' in outputs: - my_reactor.export_svg('CenterColumnStudyReactor/reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder='CenterColumnStudyReactor') - if 'html' in outputs: - my_reactor.export_html('CenterColumnStudyReactor/reactor.html') - - -if __name__ == "__main__": - make_center_column_study_reactor() diff --git a/examples/example_parametric_reactors/make_all_reactors.py b/examples/example_parametric_reactors/make_all_reactors.py deleted file mode 100644 index 346c2090e..000000000 --- a/examples/example_parametric_reactors/make_all_reactors.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -This python script creates all parametric reactors available and saves stp files -""" - -from ball_reactor import make_ball_reactor -from ball_reactor_single_null import make_ball_reactor_sn -from center_column_study_reactor import make_center_column_study_reactor -from segmented_blanket_ball_reactor import make_ball_reactor_seg -from submersion_reactor import make_submersion -from submersion_reactor_single_null import make_submersion_sn - - -def main(outputs=['stp', 'svg', 'html']): - - make_submersion(outputs=outputs) - make_submersion_sn(outputs=outputs) - make_center_column_study_reactor(outputs=outputs) - make_ball_reactor(outputs=outputs) - make_ball_reactor_sn(outputs=outputs) - make_ball_reactor_seg(outputs=outputs) - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_reactors/make_animation.py b/examples/example_parametric_reactors/make_animation.py deleted file mode 100644 index 562388ca3..000000000 --- a/examples/example_parametric_reactors/make_animation.py +++ /dev/null @@ -1,114 +0,0 @@ -__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 subprocess - -import numpy as np -import paramak -from scipy.interpolate import interp1d - - -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.""" - - # 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=200, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=30, - blanket_rear_wall_radial_thickness=30, - number_of_tf_coils=16, - rotation_angle=180, - 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=30, - outboard_tf_coil_poloidal_thickness=30, - tf_coil_to_rear_blanket_radial_gap=20, - ) - - 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("made", str(i + 1), "models out of", str(number_of_images)) - - subprocess.check_call( - ["convert", "-delay", "40", "random_*.svg", "randoms.gif"]) - - print("animation file made as saved as randoms.gif") - - -if __name__ == "__main__": - rotate_single_reactor() - # make_random_reactors() diff --git a/examples/example_parametric_reactors/make_animiation.ipynb b/examples/example_parametric_reactors/make_animiation.ipynb new file mode 100644 index 000000000..bfc2930a8 --- /dev/null +++ b/examples/example_parametric_reactors/make_animiation.ipynb @@ -0,0 +1,178 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Creates a series of images of a ball reactor images and combines\n", + "them into gif animations using the command line tool convert, you will need to\n", + "have imagemagick installed to convert the svg images to a gif animation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Makes a single reactor and exports and svg image with different view angles. Combines the svg images into a gif animation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import subprocess\n", + "\n", + "import numpy as np\n", + "import paramak\n", + "from scipy.interpolate import interp1d\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# allows the projection angle for the svg to be found via interpolation\n", + "\n", + "number_of_images = 10\n", + "\n", + "angle_finder = interp1d([0, number_of_images], [2.4021, 6.])\n", + "\n", + "my_reactor = paramak.SubmersionTokamak(\n", + " inner_bore_radial_thickness=30,\n", + " inboard_tf_leg_radial_thickness=30,\n", + " center_column_shield_radial_thickness=30,\n", + " divertor_radial_thickness=80,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=200,\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=30,\n", + " blanket_rear_wall_radial_thickness=30,\n", + " number_of_tf_coils=16,\n", + " rotation_angle=180,\n", + " support_radial_thickness=90,\n", + " inboard_blanket_radial_thickness=30,\n", + " outboard_blanket_radial_thickness=30,\n", + " elongation=2.00,\n", + " triangularity=0.50,\n", + " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", + " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_radial_position=[500, 550, 550, 500],\n", + " pf_coil_vertical_position=[270, 100, -100, -270],\n", + " rear_blanket_to_tf_gap=50,\n", + " outboard_tf_coil_radial_thickness=30,\n", + " outboard_tf_coil_poloidal_thickness=30,\n", + ")\n", + "\n", + "for i in range(number_of_images):\n", + "\n", + " # uses the rotation angle (in radians) to find new x, y points\n", + " x_vec, y_vec = paramak.utils.rotate([0, 0], [1, 0], angle_finder(i))\n", + " projectionDir = (x_vec, y_vec, 0)\n", + "\n", + " my_reactor.export_svg(\n", + " filename=\"rotation_\" + str(i).zfill(4) + \".svg\",\n", + " projectionDir=projectionDir,\n", + " showHidden=False,\n", + " height=200,\n", + " width=300,\n", + " marginTop=27,\n", + " marginLeft=35,\n", + " strokeWidth=3.5\n", + " )\n", + "\n", + " print(\"made\", str(i + 1), \"models out of\", str(number_of_images))\n", + "\n", + "subprocess.check_call(\n", + " [\"convert\", \"-delay\", \"15\", \"rotation_*.svg\", \"rotated.gif\"])\n", + "\n", + "print(\"animation file made as saved as rotated.gif\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Makes a series of random sized reactors and exports an svg image for each one. Combines the svg images into a gif animation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# makes a series of reactor models\n", + "for i in range(number_of_images):\n", + "\n", + " my_reactor = paramak.BallReactor(\n", + " inner_bore_radial_thickness=50,\n", + " inboard_tf_leg_radial_thickness=np.random.uniform(20, 50),\n", + " center_column_shield_radial_thickness=np.random.uniform(20, 60),\n", + " divertor_radial_thickness=50,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=np.random.uniform(20, 200),\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=5,\n", + " blanket_radial_thickness=np.random.uniform(10, 200),\n", + " blanket_rear_wall_radial_thickness=10,\n", + " elongation=np.random.uniform(1.3, 1.7),\n", + " triangularity=np.random.uniform(0.3, 0.55),\n", + " number_of_tf_coils=16,\n", + " rotation_angle=180,\n", + " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", + " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_radial_position=[500, 550, 550, 500],\n", + " pf_coil_vertical_position=[270, 100, -100, -270],\n", + " outboard_tf_coil_radial_thickness=100,\n", + " outboard_tf_coil_poloidal_thickness=50,\n", + " )\n", + "\n", + " my_reactor.export_svg(\n", + " filename=\"random_\" + str(i).zfill(4) + \".svg\",\n", + " showHidden=False\n", + " )\n", + "\n", + " print(\"made\", str(i + 1), \"models out of\", str(number_of_images))\n", + "\n", + "subprocess.check_call(\n", + " [\"convert\", \"-delay\", \"40\", \"random_*.svg\", \"randoms.gif\"])\n", + "\n", + "print(\"animation file made as saved as randoms.gif\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb b/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb new file mode 100644 index 000000000..916cf0234 --- /dev/null +++ b/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb @@ -0,0 +1,98 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This example creates a ball reactor with segmented blankets using the\n", + "SegmentedBlanketBallReactor parametric reactor. By default the script saves\n", + "stp, stl, html and svg files." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak\n", + "\n", + "\n", + "my_reactor = paramak.SegmentedBlanketBallReactor(\n", + " inner_bore_radial_thickness=5,\n", + " inboard_tf_leg_radial_thickness=25,\n", + " center_column_shield_radial_thickness=45,\n", + " divertor_radial_thickness=150,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=300,\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=15,\n", + " blanket_radial_thickness=50,\n", + " blanket_rear_wall_radial_thickness=30,\n", + " elongation=2,\n", + " triangularity=0.55,\n", + " number_of_tf_coils=16,\n", + " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", + " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_radial_position=[500, 550, 550, 500],\n", + " pf_coil_vertical_position=[270, 100, -100, -270],\n", + " rear_blanket_to_tf_gap=50,\n", + " rotation_angle=180,\n", + " outboard_tf_coil_radial_thickness=100,\n", + " outboard_tf_coil_poloidal_thickness=50,\n", + " gap_between_blankets=30,\n", + " number_of_blanket_segments=15,\n", + " blanket_fillet_radius=15,\n", + ")\n", + "\n", + "my_reactor.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "my_reactor.export_stp()\n", + "\n", + "my_reactor.export_neutronics_description('manifest.json')\n", + "\n", + "my_reactor.export_svg('reactor.svg')\n", + "\n", + "my_reactor.export_stl(output_folder='SegmentedBlanketBallReactor')\n", + "\n", + "# my_reactor.export_html('reactor.html')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_reactors/segmented_blanket_ball_reactor.py b/examples/example_parametric_reactors/segmented_blanket_ball_reactor.py deleted file mode 100644 index e0c3f5e10..000000000 --- a/examples/example_parametric_reactors/segmented_blanket_ball_reactor.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -This example creates a ball reactor with segmented blankets using the -SegmentedBlanketBallReactor parametric reactor. By default the script saves -stp, stl, html and svg files. Fillets the firstwall as this is not currently -done in the SegmentedBlanketBallReactor reactor class. -""" - -import cadquery as cq -import paramak - - -def make_ball_reactor_seg(outputs=['stp', 'neutronics', 'svg', 'stl', 'html']): - - my_reactor = paramak.SegmentedBlanketBallReactor( - inner_bore_radial_thickness=5, - inboard_tf_leg_radial_thickness=25, - center_column_shield_radial_thickness=45, - divertor_radial_thickness=150, - inner_plasma_gap_radial_thickness=50, - plasma_radial_thickness=300, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=15, - blanket_radial_thickness=50, - blanket_rear_wall_radial_thickness=30, - elongation=2, - triangularity=0.55, - 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, - pf_coil_to_tf_coil_radial_gap=50, - outboard_tf_coil_radial_thickness=100, - outboard_tf_coil_poloidal_thickness=50, - gap_between_blankets=30, - number_of_blanket_segments=15, - blanket_fillet_radius=15, - ) - - my_reactor.solid # triggers the construction of the reactor model - - # finds the correct edges to fillet - x_coord = my_reactor.major_radius - front_face = my_reactor._blanket.solid.faces( - cq.NearestToPointSelector((x_coord, 0, 0))) - front_edge = front_face.edges(cq.NearestToPointSelector((x_coord, 0, 0))) - front_edge_length = front_edge.val().Length() - my_reactor._blanket.solid = my_reactor._blanket.solid.edges( - paramak.EdgeLengthSelector(front_edge_length)).fillet( - my_reactor.blanket_fillet_radius) - - # cuts away the breeder zone - my_reactor._blanket.solid = my_reactor._blanket.solid.cut( - my_reactor._blanket.solid) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder='SegmentedBlanketBallReactor') - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - 'SegmentedBlanketBallReactor/manifest.json') - if 'svg' in outputs: - my_reactor.export_svg('SegmentedBlanketBallReactor/reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder='SegmentedBlanketBallReactor') - if 'html' in outputs: - my_reactor.export_html('SegmentedBlanketBallReactor/reactor.html') - - -if __name__ == "__main__": - make_ball_reactor_seg(['stp', 'neutronics', 'svg', 'stl', 'html']) diff --git a/examples/example_parametric_reactors/submersion_reactor.ipynb b/examples/example_parametric_reactors/submersion_reactor.ipynb index de589f861..33bdfb6da 100644 --- a/examples/example_parametric_reactors/submersion_reactor.ipynb +++ b/examples/example_parametric_reactors/submersion_reactor.ipynb @@ -1,16 +1,19 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This example creates a submersion reactor using the SubmersionTokamak\n", + "parametric reactor. By default the script saves stp, stl, html and svg files." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "\"\"\"\n", - "This example creates a submersion reactor using the SubmersionTokamak\n", - "parametric reactor. By default the script saves stp, stl, html and svg files.\n", - "\"\"\"\n", - "\n", "import paramak\n", "\n", "\n", diff --git a/examples/example_parametric_reactors/submersion_reactor.py b/examples/example_parametric_reactors/submersion_reactor.py deleted file mode 100644 index b87f5b032..000000000 --- a/examples/example_parametric_reactors/submersion_reactor.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -This example creates a submersion reactor using the SubmersionTokamak -parametric reactor. By default the script saves stp, stl, html and svg files. -""" - -import paramak - - -def make_submersion(outputs=['stp', 'neutronics', 'svg', 'stl', 'html']): - - 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=200, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=30, - blanket_rear_wall_radial_thickness=30, - number_of_tf_coils=16, - rotation_angle=180, - 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=30, - outboard_tf_coil_poloidal_thickness=30, - tf_coil_to_rear_blanket_radial_gap=20, - ) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder='SubmersionTokamak') - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - 'SubmersionTokamak/manifest.json') - if 'svg' in outputs: - my_reactor.export_svg('SubmersionTokamak/reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder='SubmersionTokamak') - if 'html' in outputs: - my_reactor.export_html('SubmersionTokamak/reactor.html') - - -if __name__ == "__main__": - make_submersion(['stp', 'neutronics', 'svg', 'stl', 'html']) diff --git a/examples/example_parametric_reactors/submersion_reactor_single_null.py b/examples/example_parametric_reactors/submersion_reactor_single_null.py deleted file mode 100644 index 88bef870f..000000000 --- a/examples/example_parametric_reactors/submersion_reactor_single_null.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -This example creates a single null submersion reactor using the -SubmersionTokamak parametric reactor. By default the script saves stp, stl, -html and svg files. -""" - -from pathlib import Path - -import paramak - - -def make_submersion_sn(outputs=['stp', 'neutronics', 'svg', 'stl', 'html'], - output_folder='SubmersionTokamak_sn'): - - my_reactor = paramak.SingleNullSubmersionTokamak( - 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=200, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=30, - blanket_rear_wall_radial_thickness=30, - number_of_tf_coils=16, - rotation_angle=180, - 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=30, - outboard_tf_coil_poloidal_thickness=30, - tf_coil_to_rear_blanket_radial_gap=20, - divertor_position="lower", - support_position="lower" - ) - - if 'stp' in outputs: - my_reactor.export_stp(output_folder=output_folder) - if 'neutronics' in outputs: - my_reactor.export_neutronics_description( - Path(output_folder) / 'manifest.json') - if 'svg' in outputs: - my_reactor.export_svg(Path(output_folder) / 'reactor.svg') - if 'stl' in outputs: - my_reactor.export_stl(output_folder=output_folder) - if 'html' in outputs: - my_reactor.export_html(Path(output_folder) / 'reactor.html') - - -if __name__ == "__main__": - make_submersion_sn(['stp', 'neutronics', 'svg', 'stl', 'html']) diff --git a/examples/example_parametric_shapes/make_CAD_from_points.py b/examples/example_parametric_shapes/make_CAD_from_points.py deleted file mode 100644 index 5c394c6d6..000000000 --- a/examples/example_parametric_shapes/make_CAD_from_points.py +++ /dev/null @@ -1,233 +0,0 @@ -""" -This python script demonstrates the creation of 3D volumes from points using -extrude and rotate methods -""" - -import paramak - - -def main(): - - # rotate examples - - # this makes a rectangle and rotates it to make a solid - rotated_straights = paramak.RotateStraightShape( - rotation_angle=180, - points=[(400, 100), (400, 200), (600, 200), (600, 100)] - ) - rotated_straights.export_stp("rotated_straights.stp") - rotated_straights.export_svg("rotated_straights.svg") - rotated_straights.export_html("rotated_straights.html") - - # this makes a banana shape and rotates it to make a solid - rotated_spline = paramak.RotateSplineShape( - rotation_angle=180, - points=[ - (500, 0), - (500, -20), - (400, -300), - (300, -300), - (400, 0), - (300, 300), - (400, 300), - (500, 20), - ] - ) - rotated_spline.export_stp("rotated_spline.stp") - rotated_spline.export_svg("rotated_spline.svg") - rotated_spline.export_html("rotated_spline.html") - - # this makes a shape with straight, spline and circular edges and rotates - # it to make a solid - rotated_mixed = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (100, 0, "straight"), - (200, 0, "circle"), - (250, 50, "circle"), - (200, 100, "straight"), - (150, 100, "spline"), - (140, 75, "spline"), - (110, 45, "spline"), - ] - ) - rotated_mixed.export_stp("rotated_mixed.stp") - rotated_mixed.export_svg("rotated_mixed.svg") - rotated_mixed.export_html("rotated_mixed.html") - - # this makes a circular shape and rotates it to make a solid - rotated_circle = paramak.RotateCircleShape( - rotation_angle=180, - points=[(50, 0)], - radius=5, - workplane="XZ" - ) - rotated_circle.export_stp("rotated_circle.stp") - rotated_circle.export_svg("rotated_circle.svg") - rotated_circle.export_html("rotated_circle.html") - - # extrude examples - - # this makes a banana shape with straight edges and rotates it to make a - # solid - extruded_straight = paramak.ExtrudeStraightShape( - distance=200, - points=[ - (300, -300), - (400, 0), - (300, 300), - (400, 300), - (500, 0), - (400, -300), - ] - ) - extruded_straight.export_stp("extruded_straight.stp") - extruded_straight.export_svg("extruded_straight.svg") - extruded_straight.export_html("extruded_straight.html") - - # this makes a banana shape and rotates it to make a solid - extruded_spline = paramak.ExtrudeSplineShape( - distance=200, - points=[ - (500, 0), - (500, -20), - (400, -300), - (300, -300), - (400, 0), - (300, 300), - (400, 300), - (500, 20), - ] - ) - extruded_spline.export_stp("extruded_spline.stp") - extruded_spline.export_svg("extruded_spline.svg") - extruded_spline.export_html("extruded_spline.html") - - # this makes a banana shape straight top and bottom edges and extrudes it - # to make a solid - extruded_mixed = paramak.ExtrudeMixedShape( - distance=100, - points=[ - (100, 0, "straight"), - (200, 0, "circle"), - (250, 50, "circle"), - (200, 100, "straight"), - (150, 100, "spline"), - (140, 75, "spline"), - (110, 45, "spline"), - ], - ) - extruded_mixed.export_stp("extruded_mixed.stp") - extruded_mixed.export_svg("extruded_mixed.svg") - extruded_mixed.export_html("extruded_mixed.html") - - # this makes a circular shape and extrudes it to make a solid - extruded_circle = paramak.ExtrudeCircleShape( - points=[(20, 0)], - radius=20, - distance=200 - ) - extruded_circle.export_stp("extruded_circle.stp") - extruded_circle.export_svg("extruded_circle.svg") - extruded_circle.export_html("extruded_circle.html") - - # sweep examples - - # this makes a banana shape with straight edges and sweeps it along a - # spline to make a solid - sweep_straight = paramak.SweepStraightShape( - points=[ - (-150, 300), - (-50, 300), - (50, 0), - (-50, -300), - (-150, -300), - (-50, 0) - ], - path_points=[ - (50, 0), - (150, 400), - (400, 500), - (650, 600), - (750, 1000) - ], - workplane="XY", - path_workplane="XZ" - ) - sweep_straight.export_stp("sweep_straight.stp") - sweep_straight.export_svg("sweep_straight.svg") - sweep_straight.export_html("sweep_straight.html") - - # this makes a banana shape with spline edges and sweeps it along a spline - # to make a solid - sweep_spline = paramak.SweepSplineShape( - points=[ - (50, 0), - (50, -20), - (-50, -300), - (-150, -300), - (-50, 0), - (-150, 300), - (-50, 300), - (50, 20) - ], - path_points=[ - (50, 0), - (150, 400), - (400, 500), - (650, 600), - (750, 1000) - ], - workplane="XY", - path_workplane="XZ" - ) - sweep_spline.export_stp("sweep_spline.stp") - sweep_spline.export_svg("sweep_spline.svg") - sweep_spline.export_html("sweep_spline.html") - - # this makes a shape with straight, spline and circular edges and sweeps - # it along a spline to make a solid - sweep_mixed = paramak.SweepMixedShape( - points=[ - (-80, -50, "straight"), - (20, -50, "circle"), - (70, 0, "circle"), - (20, 50, "straight"), - (-30, 50, "spline"), - (-40, 25, "spline"), - (-70, -5, "spline") - ], - path_points=[ - (50, 0), - (150, 400), - (400, 500), - (650, 600), - (750, 1000) - ], - workplane="XY", - path_workplane="XZ" - ) - sweep_mixed.export_stp("sweep_mixed.stp") - sweep_mixed.export_svg("sweep_mixed.svg") - sweep_mixed.export_html("sweep_mixed.html") - - # this makes a circular shape and sweeps it to make a solid - sweep_circle = paramak.SweepCircleShape( - radius=40, - path_points=[ - (50, 0), - (150, 400), - (400, 500), - (650, 600), - (750, 1000) - ], - workplane="XY", - path_workplane="XZ" - ) - sweep_circle.export_stp("sweep_circle.stp") - sweep_circle.export_svg("sweep_circle.svg") - sweep_circle.export_html("sweep_circle.html") - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_shapes/make_blanket_from_parameters.py b/examples/example_parametric_shapes/make_blanket_from_parameters.py deleted file mode 100644 index a3de71b95..000000000 --- a/examples/example_parametric_shapes/make_blanket_from_parameters.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -This python script demonstrates the parametric creation of a shape similar to -a breeder blanket. -""" - -import paramak - - -def main(filename="blanket_from_parameters.stp"): - - height = 700 - blanket_rear = 400 - blanket_front = 300 - blanket_mid_point = 350 - - blanket = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (blanket_rear, height / 2.0, "straight"), - (blanket_rear, -height / 2.0, "straight"), - (blanket_front, -height / 2.0, "spline"), - (blanket_mid_point, 0, "spline"), - (blanket_front, height / 2.0, "straight"), - ] - ) - - blanket.export_stp(filename=filename) - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_shapes/make_blanket_from_points.py b/examples/example_parametric_shapes/make_blanket_from_points.py deleted file mode 100644 index 7001a5081..000000000 --- a/examples/example_parametric_shapes/make_blanket_from_points.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -This python script demonstrates the creation of a breeder blanket from points -""" - -import paramak - - -def main(filename="blanket_from_points.stp"): - - blanket = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (538, 305, "straight"), - (538, -305, "straight"), - (322, -305, "spline"), - (470, 0, "spline"), - (322, 305, "straight"), - ] - ) - - blanket.export_stp(filename=filename) - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_shapes/make_can_reactor_from_parameters.py b/examples/example_parametric_shapes/make_can_reactor_from_parameters.py deleted file mode 100644 index 7f9e96b37..000000000 --- a/examples/example_parametric_shapes/make_can_reactor_from_parameters.py +++ /dev/null @@ -1,135 +0,0 @@ -""" -This script creates a can shaped reactor with plasma, center column, blanket, firstwall, divertor and core -""" - -import paramak - - -def main(): - - outer_most_x = 900 - blanket_height = 300 - - plasma = paramak.Plasma( - major_radius=250, - minor_radius=100, - triangularity=0.5, - elongation=2.5, - rotation_angle=180 - ) - - centre_column = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (74.6, 687.0, "straight"), - (171.0, 687.0, "straight"), - (171.0, 459.9232, "spline"), - (108.001, 249.9402, "spline"), - (92.8995, 0, "spline"), - (108.001, -249.9402, "spline"), - (171.0, -459.9232, "straight"), - (171.0, -687.0, "straight"), - (74.6, -687.0, "straight"), - ] - ) - centre_column.stp_filename = "centre_column.stp" - centre_column.stl_filename = "centre_column.stl" - - blanket = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (325.4528, blanket_height, "straight"), - (outer_most_x, blanket_height, "straight"), - (outer_most_x, -blanket_height, "straight"), - (325.4528, -blanket_height, "spline"), - (389.9263, -138.1335, "spline"), - (404.5108, 0, "spline"), - (389.9263, 138.1335, "spline"), - ] - ) - blanket.stp_filename = "blanket.stp" - blanket.stl_filename = "blanket.stl" - - firstwall = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (322.9528, blanket_height, "straight"), - (325.4528, blanket_height, "spline"), - (389.9263, 138.1335, "spline"), - (404.5108, 0, "spline"), - (389.9263, -138.1335, "spline"), - (325.4528, -blanket_height, "straight"), - (322.9528, -blanket_height, "spline"), - (387.4263, -138.1335, "spline"), - (402.0108, 0, "spline"), - (387.4263, 138.1335, "spline"), - ] - ) - firstwall.stp_filename = "firstwall.stp" - firstwall.stl_filename = "firstwall.stl" - - divertor_bottom = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (192.4782, -447.204, "spline"), - (272.4957, -370.5, "spline"), - (322.9528, -blanket_height, "straight"), - (outer_most_x, -blanket_height, "straight"), - (outer_most_x, -687.0, "straight"), - (171.0, -687.0, "straight"), - (171.0, -459.9232, "spline"), - (218.8746, -513.3484, "spline"), - (362.4986, -602.3905, "straight"), - (372.5012, -580.5742, "spline"), - (237.48395, -497.21782, "spline"), - ] - ) - divertor_bottom.stp_filename = "divertor_bottom.stp" - divertor_bottom.stl_filename = "divertor_bottom.stl" - - divertor_top = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (192.4782, 447.204, "spline"), - (272.4957, 370.5, "spline"), - (322.9528, blanket_height, "straight"), - (outer_most_x, blanket_height, "straight"), - (outer_most_x, 687.0, "straight"), - (171.0, 687.0, "straight"), - (171.0, 459.9232, "spline"), - (218.8746, 513.3484, "spline"), - (362.4986, 602.3905, "straight"), - (372.5012, 580.5742, "spline"), - (237.48395, 497.21782, "spline"), - ] - ) - divertor_top.stp_filename = "divertor_top.stp" - divertor_top.stl_filename = "divertor_top.stl" - - core = paramak.RotateStraightShape( - rotation_angle=180, - points=[ - (0, 687.0), - (74.6, 687.0), - (74.6, -687.0), - (0, -687.0)] - ) - core.stp_filename = "core.stp" - core.stl_filename = "core.stl" - - # initiates a reactor object - myreactor = paramak.Reactor([plasma, - blanket, - core, - divertor_top, - divertor_bottom, - firstwall, - centre_column]) - - myreactor.export_stp(output_folder="can_reactor_from_parameters") - myreactor.export_stl(output_folder="can_reactor_from_parameters") - myreactor.export_html(filename="can_reactor_from_parameters/reactor.html") - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_shapes/make_can_reactor_from_points.py b/examples/example_parametric_shapes/make_can_reactor_from_points.py deleted file mode 100644 index 7f4a8d3fd..000000000 --- a/examples/example_parametric_shapes/make_can_reactor_from_points.py +++ /dev/null @@ -1,128 +0,0 @@ -""" -This python script demonstrates the creation of 3D volumes -from points to create an example reactor -""" - -import paramak - - -def main(): - - plasma = paramak.Plasma( - major_radius=250, - minor_radius=100, - triangularity=0.5, - elongation=2.5, - rotation_angle=180, - ) - - centre_column = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (74.6, 687.0, "straight"), - (171.0, 687.0, "straight"), - (171.0, 459.9232, "spline"), - (108.001, 249.9402, "spline"), - (92.8995, 0, "spline"), - (108.001, -249.9402, "spline"), - (171.0, -459.9232, "straight"), - (171.0, -687.0, "straight"), - (74.6, -687.0, "straight"), - ] - ) - centre_column.stp_filename = "centre_column.stp" - centre_column.stl_filename = "centre_column.stl" - - blanket = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (325.4886, 300.5, "straight"), - (538.4886, 300.5, "straight"), - (538.4886, -300.5, "straight"), - (325.4528, -300.5, "spline"), - (389.9263, -138.1335, "spline"), - (404.5108, 0, "spline"), - (389.9263, 138.1335, "spline"), - ] - ) - blanket.stp_filename = "blanket.stp" - blanket.stl_filename = "blanket.stl" - - firstwall = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (322.9528, 300.5, "straight"), - (325.4528, 300.5, "spline"), - (389.9263, 138.1335, "spline"), - (404.5108, 0, "spline"), - (389.9263, -138.1335, "spline"), - (325.4528, -300.5, "straight"), - (322.9528, -300.5, "spline"), - (387.4263, -138.1335, "spline"), - (402.0108, 0, "spline"), - (387.4263, 138.1335, "spline"), - ] - ) - firstwall.stp_filename = "firstwall.stp" - firstwall.stl_filename = "firstwall.stl" - - divertor_bottom = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (192.4782, -447.204, "spline"), - (272.4957, -370.5, "spline"), - (322.9528, -300.5, "straight"), - (538.4886, -300.5, "straight"), - (538.4886, -687.0, "straight"), - (171.0, -687.0, "straight"), - (171.0, -459.9232, "spline"), - (218.8746, -513.3484, "spline"), - (362.4986, -602.3905, "straight"), - (372.5012, -580.5742, "spline"), - (237.48395, -497.21782, "spline"), - ] - ) - divertor_bottom.stp_filename = "divertor_bottom.stp" - divertor_bottom.stl_filename = "divertor_bottom.stl" - - divertor_top = paramak.RotateMixedShape( - rotation_angle=180, - points=[ - (192.4782, 447.204, "spline"), - (272.4957, 370.5, "spline"), - (322.9528, 300.5, "straight"), - (538.4886, 300.5, "straight"), - (538.4886, 687.0, "straight"), - (171.0, 687.0, "straight"), - (171.0, 459.9232, "spline"), - (218.8746, 513.3484, "spline"), - (362.4986, 602.3905, "straight"), - (372.5012, 580.5742, "spline"), - (237.48395, 497.21782, "spline"), - ] - ) - divertor_top.stp_filename = "divertor_top.stp" - divertor_top.stl_filename = "divertor_top.stl" - - core = paramak.RotateStraightShape( - rotation_angle=180, - points=[(0, 687.0), (74.6, 687.0), (74.6, -687.0), (0, -687.0)] - ) - core.stp_filename = "core.stp" - core.stl_filename = "core.stl" - - myreactor = paramak.Reactor([plasma, - blanket, - core, - divertor_top, - divertor_bottom, - firstwall, - centre_column]) - - myreactor.export_stp(output_folder="can_reactor_from_points") - myreactor.export_stl(output_folder="can_reactor_from_points") - myreactor.export_html("can_reactor_from_points/reactor.html") - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_shapes/make_html_diagram_from_stp_file.py b/examples/example_parametric_shapes/make_html_diagram_from_stp_file.py deleted file mode 100644 index e2efffdb0..000000000 --- a/examples/example_parametric_shapes/make_html_diagram_from_stp_file.py +++ /dev/null @@ -1,75 +0,0 @@ -"""Creates a stp file and then loads up the stp file and then facets the wires -(edges) of the geometry and plots the faceted eges along with the vertices -within the stp file.""" - -import paramak - - -def make_stp_file(): - """Creates an example stp file for plotting html point graphs""" - - # this creates a Shape object - example_shape = paramak.ExtrudeMixedShape( - distance=1, - points=[ - (100, 0, "straight"), - (200, 0, "circle"), - (250, 50, "circle"), - (200, 100, "straight"), - (150, 100, "spline"), - (140, 75, "spline"), - (110, 45, "spline"), - ] - ) - - # this exports the shape as a html image with a few different view planes - example_shape.export_html("example_shape_RZ.html") - example_shape.export_html("example_shape_XYZ.html", view_plane='XYZ') - example_shape.export_html("example_shape_XZ.html", view_plane='XZ') - - # This exports the Shape object as an stp file that will be imported later - example_shape.export_stp("example_shape.stp") - - -def load_stp_file_and_plot(): - """Loads an stp file and plots html point graphs""" - - # loads the stp file and obtains the solid shape and list of wires / edges - solid, wires = paramak.utils.load_stp_file( - filename="example_shape.stp", - ) - - # produces a plot on the R (radius) Z axis and saves the html file - paramak.utils.export_wire_to_html( - wires=wires, - tolerance=0.1, - view_plane="RZ", - facet_splines=True, - facet_circles=True, - filename="example_shape_from_stp_RZ.html", - ) - - # produces a plot on the XZ axis and saves the html file - paramak.utils.export_wire_to_html( - wires=wires, - tolerance=0.1, - view_plane="XZ", - facet_splines=True, - facet_circles=True, - filename="example_shape_from_stp_XZ.html", - ) - - # produces a 3D plot with XYZ axis and saves the html file - paramak.utils.export_wire_to_html( - wires=wires, - tolerance=0.1, - view_plane="XYZ", - facet_splines=True, - facet_circles=True, - filename="example_shape_from_stp_XYZ.html", - ) - - -if __name__ == "__main__": - make_stp_file() - load_stp_file_and_plot() diff --git a/tests/notebook_testing.py b/tests/notebook_testing.py index 68e7546a5..c8f9f7139 100644 --- a/tests/notebook_testing.py +++ b/tests/notebook_testing.py @@ -21,7 +21,7 @@ def notebook_run(path): note_book.metadata.get('kernelspec', {})['name'] = kernel_name ep = ExecutePreprocessor( kernel_name=kernel_name, - timeout=300) + timeout=600) try: ep.preprocess( diff --git a/tests/test_example_components.py b/tests/test_example_components.py index adf4c267a..333f5c5b7 100644 --- a/tests/test_example_components.py +++ b/tests/test_example_components.py @@ -4,115 +4,18 @@ import unittest from pathlib import Path -from examples.example_parametric_components import ( - make_all_parametric_components, make_demo_style_blankets, - make_firstwall_for_neutron_wall_loading, make_plasmas, - make_vacuum_vessel_with_ports) +from .notebook_testing import notebook_run sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples')) class TestExampleComponents(unittest.TestCase): - def test_make_all_parametric_components(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - 'plasma_shape.stp', - 'blanket_constant_thickness_outboard_plasma.stp', - 'blanket_constant_thickness_inboard_plasma.stp', - 'blanket_constant_thickness_plasma.stp', - 'center_column_shield_cylinder.stp', - 'firstwall_from_center_column_shield_cylinder.stp', - 'center_column_shield_hyperbola.stp', - 'firstwall_from_center_column_shield_hyperbola.stp', - 'center_column_shield_circular.stp', - 'firstwall_from_center_column_shield_circular.stp', - 'center_column_shield_flat_top_hyperbola.stp', - 'firstwall_from_center_column_shield_flat_top_hyperbola.stp', - 'center_column_shield_flat_top_Circular.stp', - 'firstwall_from_center_column_shield_flat_top_Circular.stp', - 'center_column_shield_plasma_hyperbola.stp', - 'firstwall_from_center_column_shield_plasma_hyperbola.stp', - 'inner_tf_coils_circular.stp', - 'inner_tf_coils_flat.stp', - 'pf_coil_case_set.stp', - 'pf_coil_set.stp', - 'pf_coil_cases_set.stp', - 'poloidal_field_coil.stp', - 'pf_coil_cases_set_fc.stp', - 'poloidal_field_coil_case_fc.stp', - 'poloidal_field_coil_case.stp', - 'blanket_arc_v.stp', - 'blanket_arc_h.stp', - 'tf_coil_rectangle.stp', - 'toroidal_field_coil_coat_hanger.stp', - 'toroidal_field_coil_triple_arc.stp', - 'toroidal_field_coil_princeton_d.stp', - 'ITER_type_divertor.stp'] - for output_filename in output_filenames: - os.system("rm " + output_filename) - all_components = make_all_parametric_components.main() - filenames = [] - for components in all_components: - components.export_stp() - filenames.append(components.stp_filename) - - for output_filename in output_filenames: - assert Path(output_filename).exists() - os.system("rm " + output_filename) - - def test_make_plasma(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "ITER_plasma.html", - "EU_DEMO_plasma.html", - "ST_plasma.html", - "AST_plasma.html", - "ITER_plasma.stp", - "EU_DEMO_plasma.stp", - "ST_plasma.stp", - "AST_plasma.stp", - "ITER_plasma.png", - "EU_DEMO_plasma.png", - "ST_plasma.png", - "AST_plasma.png", - "all_plasma_and_points.html", - ] - for output_filename in output_filenames: - os.system("rm " + output_filename) - make_plasmas.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() - os.system("rm " + output_filename) - - def test_make_demo_style_blanket(self): - """Runs the example and checks the output files are produced""" - output_filename = "blanket.stp" - os.system("rm " + output_filename) - make_demo_style_blankets.main() - assert Path(output_filename).exists() - os.system("rm " + output_filename) - - def test_make_segmented_firstwall(self): - """Runs the example and checks the output files are produced""" - output_filename = "segmented_firstwall.stp" - os.system("rm " + output_filename) - make_firstwall_for_neutron_wall_loading.main() - assert Path(output_filename).exists() - os.system("rm " + output_filename) - - def test_make_vacuum_vessel(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "vacuum_vessel_with_ports.stp", - "vacuum_vessel_with_ports.svg", - ] - for output_filename in output_filenames: - os.system("rm " + output_filename) - make_vacuum_vessel_with_ports.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() - os.system("rm " + output_filename) + def test_jupyter_notebooks_example_parametric_components(self): + for notebook in Path().rglob("examples/example_parametric_components/*.ipynb"): + print(notebook) + nb, errors = notebook_run(notebook) + assert errors == [] if __name__ == "__main__": diff --git a/tests/test_example_reactors.py b/tests/test_example_reactors.py index 29affd182..7c5be7297 100644 --- a/tests/test_example_reactors.py +++ b/tests/test_example_reactors.py @@ -4,10 +4,6 @@ import unittest from pathlib import Path -from examples.example_parametric_reactors import ( - ball_reactor, ball_reactor_single_null, make_animation, - submersion_reactor_single_null) - from .notebook_testing import notebook_run sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples')) @@ -21,82 +17,6 @@ def test_jupyter_notebooks_example_parametric_reactors(self): nb, errors = notebook_run(notebook) assert errors == [] - def test_make_animations(self): - """Runs the example to check the output files are produced""" - output_filenames = [ - "random_0000.svg", - "random_0001.svg", - "rotation_0000.svg", - "rotation_0001.svg", - ] - os.system("rm *.svg") - make_animation.rotate_single_reactor(2) - make_animation.make_random_reactors(2) - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_make_parametric_ball_rector(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "plasma.stp", - "inboard_tf_coils.stp", - "center_column_shield.stp", - "divertor.stp", - "firstwall.stp", - "blanket.stp", - "blanket_rear_wall.stp", - "graveyard.stp", - ] - for output_filename in output_filenames: - os.system("rm " + output_filename) - ball_reactor.make_ball_reactor(output_folder='') - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - os.system("rm " + output_filename) - - def test_make_parametric_single_null_ball_reactor(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "blanket_rear_wall.stp", - "blanket.stp", - "center_column_shield.stp", - "divertor.stp", - "firstwall.stp", - "graveyard.stp", - "inboard_tf_coils.stp", - "pf_coils.stp", - "plasma.stp", - "tf_coil.stp" - ] - for output_filename in output_filenames: - os.system("rm " + output_filename) - ball_reactor_single_null.make_ball_reactor_sn(output_folder='') - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - os.system("rm " + output_filename) - - def test_make_parametric_single_null_submersion_reactor(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - 'inboard_tf_coils.stp', - 'center_column_shield.stp', - 'plasma.stp', - 'divertor.stp', - 'supports.stp', - 'outboard_firstwall.stp', - 'blanket.stp', - 'outboard_rear_blanket_wall.stp', - 'outboard_tf_coil.stp', - 'pf_coils.stp', - 'graveyard.stp' - ] - for output_filename in output_filenames: - os.system("rm " + output_filename) - submersion_reactor_single_null.make_submersion_sn(output_folder='') - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - os.system("rm " + output_filename) - if __name__ == "__main__": unittest.main() diff --git a/tests/test_example_shapes.py b/tests/test_example_shapes.py index dc8c7e48d..c6477ec23 100644 --- a/tests/test_example_shapes.py +++ b/tests/test_example_shapes.py @@ -4,12 +4,6 @@ import unittest from pathlib import Path -import paramak -from examples.example_parametric_shapes import ( - make_blanket_from_parameters, make_blanket_from_points, - make_CAD_from_points, make_can_reactor_from_parameters, - make_can_reactor_from_points, make_html_diagram_from_stp_file) - from .notebook_testing import notebook_run sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples')) @@ -23,146 +17,6 @@ def test_jupyter_notebooks_example_parametric_shapes(self): nb, errors = notebook_run(notebook) assert errors == [] - def test_make_blanket_from_points(self): - """Runs the example and checks the output files are produced""" - filename = "blanket_from_points.stp" - os.system("rm *.stp") - make_blanket_from_points.main(filename=filename) - assert Path(filename).exists() is True - os.system("rm *.stp") - - def test_make_blanket_parametrically(self): - """Runs the example and checks the output files are produced""" - filename = "blanket_from_parameters.stp" - os.system("rm *.stp") - make_blanket_from_parameters.main(filename=filename) - assert Path(filename).exists() is True - os.system("rm *.stp") - - def test_make_cad_from_points(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "extruded_mixed.stp", - "extruded_straight.stp", - "extruded_spline.stp", - "rotated_mixed.stp", - "rotated_spline.stp", - "rotated_straights.stp", - ] - os.system("rm *.stp") - make_CAD_from_points.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_make_can_reactor_from_parameters(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "can_reactor_from_parameters/plasma.stp", - "can_reactor_from_parameters/centre_column.stp", - "can_reactor_from_parameters/blanket.stp", - "can_reactor_from_parameters/firstwall.stp", - "can_reactor_from_parameters/divertor_bottom.stp", - "can_reactor_from_parameters/divertor_top.stp", - "can_reactor_from_parameters/core.stp", - "can_reactor_from_parameters/reactor.html", - ] - os.system("rm *.stp") - os.system("rm *.html") - make_can_reactor_from_parameters.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_make_can_reactor_from_points(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "can_reactor_from_points/plasma.stp", - "can_reactor_from_points/centre_column.stp", - "can_reactor_from_points/blanket.stp", - "can_reactor_from_points/firstwall.stp", - "can_reactor_from_points/divertor_bottom.stp", - "can_reactor_from_points/divertor_top.stp", - "can_reactor_from_points/core.stp", - "can_reactor_from_points/reactor.html", - ] - os.system("rm *.stp") - os.system("rm *.html") - make_can_reactor_from_points.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_make_html_diagram_from_stp_file(self): - """Runs the example and checks the output files are produced""" - output_filenames = [ - "example_shape.stp", - "example_shape_RZ.html", - "example_shape_XYZ.html", - "example_shape_XZ.html", - "example_shape_from_stp_RZ.html", - "example_shape_from_stp_XZ.html", - "example_shape_from_stp_XYZ.html", - ] - os.system("rm *.stp") - os.system("rm *.html") - make_html_diagram_from_stp_file.make_stp_file() - make_html_diagram_from_stp_file.load_stp_file_and_plot() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_list_of_wires_can_be_exported(self): - """Checks than a list of wires is an acceptable input - for export_wire_to_html wires argument. - """ - - example_shape = paramak.ExtrudeMixedShape( - distance=1, - points=[ - (150, 100, "spline"), - (140, 75, "spline"), - (110, 45, "spline"), - ] - ) - - fig = paramak.utils.export_wire_to_html( - wires=[example_shape.wire], - tolerance=0.1, - view_plane="XY", - facet_splines=True, - facet_circles=True, - filename="example_shape_from_stp.html", - ) - - assert fig is not None - - def test_incorrect_view_plane(self): - """Checks than an error is raised when incorrect values of the - view_plane is set - """ - - def set_value(): - example_shape = paramak.ExtrudeMixedShape( - distance=1, - points=[ - (100, 0, "straight"), - (200, 0, "circle"), - (250, 50, "circle"), - (200, 100, "straight"), - (150, 100, "spline"), - (140, 75, "spline"), - (110, 45, "spline"), - ] - ) - - paramak.utils.export_wire_to_html( - wires=example_shape.wire, - tolerance=0.1, - view_plane="coucou", - facet_splines=True, - facet_circles=True, - filename="example_shape_from_stp.html", - ) - - self.assertRaises(ValueError, set_value) - if __name__ == "__main__": unittest.main() From 239f3d0bf13e4683e0a5fca35ab04c47daa4c98d Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 3 May 2021 23:01:15 +0000 Subject: [PATCH 02/21] Automated autopep8 fixes --- .../heating_on_unstructured_mesh_shape.py | 5 ++--- .../vacuum_vessel_inner_leg.py | 6 ++++-- tests/test_Reactor.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py b/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py index a897d0991..85fe8a368 100644 --- a/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py +++ b/examples/example_neutronics_simulations/heating_on_unstructured_mesh_shape.py @@ -15,10 +15,9 @@ (400, 300), (500, 20), ], - tet_mesh= -) + tet_mesh=) rotated_spline.export_h5m( # merge_tolerance, # faceting_tolerance=, -) \ No newline at end of file +) diff --git a/paramak/parametric_components/vacuum_vessel_inner_leg.py b/paramak/parametric_components/vacuum_vessel_inner_leg.py index ba5917e75..e20ca8b29 100644 --- a/paramak/parametric_components/vacuum_vessel_inner_leg.py +++ b/paramak/parametric_components/vacuum_vessel_inner_leg.py @@ -51,7 +51,8 @@ def inner_height(self, value): 'VacuumVesselInnerLeg.inner_height must be a number. Not', value) if value <= 0: raise ValueError( - 'VacuumVesselInnerLeg.inner_height must be a positive number above 0. Not', value) + 'VacuumVesselInnerLeg.inner_height must be a positive number above 0. Not', + value) self._inner_height = value @property @@ -65,7 +66,8 @@ def inner_radius(self, value): 'VacuumVesselInnerLeg.inner_radius must be a number. Not', value) if value <= 0: raise ValueError( - 'VacuumVesselInnerLeg.inner_radius must be a positive number above 0. Not', value) + 'VacuumVesselInnerLeg.inner_radius must be a positive number above 0. Not', + value) self._inner_radius = value def find_points(self): diff --git a/tests/test_Reactor.py b/tests/test_Reactor.py index d90125197..5400272eb 100644 --- a/tests/test_Reactor.py +++ b/tests/test_Reactor.py @@ -1224,15 +1224,17 @@ def test_export_h5m_with_pymoab_without_plasma(self): ) my_reactor = paramak.Reactor([test_shape1, test_shape2]) - my_reactor.export_h5m_with_pymoab(include_plasma=False, filename='no_plasma.h5m') + my_reactor.export_h5m_with_pymoab( + include_plasma=False, filename='no_plasma.h5m') assert Path('RotateStraightShape.stl').is_file() assert Path('plasma.stl').is_file() is False - my_reactor.export_h5m_with_pymoab(include_plasma=True, filename='with_plasma.h5m') + my_reactor.export_h5m_with_pymoab( + include_plasma=True, filename='with_plasma.h5m') assert Path('plasma.stl').is_file() - assert Path('with_plasma.h5m').stat().st_size > Path('no_plasma.h5m').stat().st_size - + assert Path('with_plasma.h5m').stat().st_size > Path( + 'no_plasma.h5m').stat().st_size def test_export_h5m_with_pymoab_from_manifest_file(self): """exports a h5m file when shapes_and_components is set to a string""" @@ -1259,7 +1261,9 @@ def test_export_vtk(self): self.test_reactor.export_vtk() assert Path('dagmc.h5m').is_file() assert Path('dagmc.vtk').is_file() - self.test_reactor.export_vtk(include_graveyard=False, filename='dagmc_no_graveyard.vtk') + self.test_reactor.export_vtk( + include_graveyard=False, + filename='dagmc_no_graveyard.vtk') assert Path('dagmc_no_graveyard.vtk').is_file() assert self.test_reactor.h5m_filename == 'dagmc.h5m' From 927b0ff51ef7b4635baa8668caad65aec4144db9 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 4 May 2021 16:04:25 +0100 Subject: [PATCH 03/21] split up large example --- .../make_all_parametric_components.ipynb | 440 ------------------ .../make_components_blankets.ipynb | 151 ++++++ .../make_components_center_column.ipynb | 223 +++++++++ .../make_components_magnets.ipynb | 274 +++++++++++ .../make_components_other.ipynb | 243 ++++++++++ 5 files changed, 891 insertions(+), 440 deletions(-) delete mode 100644 examples/example_parametric_components/make_all_parametric_components.ipynb create mode 100644 examples/example_parametric_components/make_components_blankets.ipynb create mode 100644 examples/example_parametric_components/make_components_center_column.ipynb create mode 100644 examples/example_parametric_components/make_components_magnets.ipynb create mode 100644 examples/example_parametric_components/make_components_other.ipynb diff --git a/examples/example_parametric_components/make_all_parametric_components.ipynb b/examples/example_parametric_components/make_all_parametric_components.ipynb deleted file mode 100644 index 750505d44..000000000 --- a/examples/example_parametric_components/make_all_parametric_components.ipynb +++ /dev/null @@ -1,440 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\"\"\"\n", - "This python script demonstrates the creation of all parametric shapes available\n", - "in the paramak tool\n", - "\"\"\"\n", - "\n", - "import paramak\n", - "\n", - "\n", - "\n", - "rot_angle = 180\n", - "all_components = []\n", - "\n", - "plasma = paramak.Plasma(\n", - " # default parameters\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"plasma_shape.stp\",\n", - ")\n", - "plasma.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "component = paramak.BlanketFP(\n", - " plasma=plasma,\n", - " thickness=100,\n", - " stop_angle=90,\n", - " start_angle=-90,\n", - " offset_from_plasma=30,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"blanket_constant_thickness_outboard_plasma.stp\",\n", - ")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "component = paramak.BlanketCutterStar(\n", - " height=2000,\n", - " width=2000,\n", - " distance=100\n", - ")\n", - "\n", - "component = paramak.BlanketFP(\n", - " plasma=plasma,\n", - " thickness=100,\n", - " stop_angle=90,\n", - " start_angle=250,\n", - " offset_from_plasma=30,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"blanket_constant_thickness_inboard_plasma.stp\",\n", - ")\n", - "\n", - "component = paramak.BlanketFP(\n", - " plasma=plasma,\n", - " thickness=100,\n", - " stop_angle=250,\n", - " start_angle=-90,\n", - " offset_from_plasma=30,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"blanket_constant_thickness_plasma.stp\",\n", - ")\n", - "\n", - "CenterColumnShieldCylinder = paramak.CenterColumnShieldCylinder(\n", - " inner_radius=80,\n", - " outer_radius=100,\n", - " height=300,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_cylinder.stp\",\n", - ")\n", - "all_components.append(CenterColumnShieldCylinder)\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldCylinder,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_cylinder.stp\",\n", - ")\n", - "\n", - "CenterColumnShieldHyperbola = paramak.CenterColumnShieldHyperbola(\n", - " inner_radius=50,\n", - " mid_radius=75,\n", - " outer_radius=100,\n", - " height=300,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_hyperbola.stp\",\n", - ")\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldHyperbola,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_hyperbola.stp\",\n", - ")\n", - "\n", - "CenterColumnShieldCircular = paramak.CenterColumnShieldCircular(\n", - " inner_radius=50,\n", - " mid_radius=75,\n", - " outer_radius=100,\n", - " height=300,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_circular.stp\",\n", - ")\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldCircular,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_circular.stp\",\n", - ")\n", - "\n", - "\n", - "CenterColumnShieldFlatTopHyperbola = paramak.CenterColumnShieldFlatTopHyperbola(\n", - " inner_radius=50,\n", - " mid_radius=75,\n", - " outer_radius=100,\n", - " arc_height=220,\n", - " height=300,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_flat_top_hyperbola.stp\",\n", - ")\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldFlatTopHyperbola,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_flat_top_hyperbola.stp\",\n", - ")\n", - "\n", - "CenterColumnShieldFlatTopCircular = paramak.CenterColumnShieldFlatTopCircular(\n", - " inner_radius=50,\n", - " mid_radius=75,\n", - " outer_radius=100,\n", - " arc_height=220,\n", - " height=300,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_flat_top_Circular.stp\",\n", - ")\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldFlatTopCircular,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_flat_top_Circular.stp\",\n", - ")\n", - "\n", - "CenterColumnShieldPlasmaHyperbola = paramak.CenterColumnShieldPlasmaHyperbola(\n", - " inner_radius=150,\n", - " mid_offset=50,\n", - " edge_offset=40,\n", - " height=800,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"center_column_shield_plasma_hyperbola.stp\",\n", - ")\n", - "\n", - "component = paramak.InboardFirstwallFCCS(\n", - " central_column_shield=CenterColumnShieldPlasmaHyperbola,\n", - " thickness=50,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"firstwall_from_center_column_shield_plasma_hyperbola.stp\",\n", - ")\n", - "\n", - "component = paramak.InnerTfCoilsCircular(\n", - " inner_radius=25,\n", - " outer_radius=100,\n", - " number_of_coils=10,\n", - " gap_size=5,\n", - " height=300,\n", - " stp_filename=\"inner_tf_coils_circular.stp\",\n", - ")\n", - "\n", - "component = paramak.InnerTfCoilsFlat(\n", - " inner_radius=25,\n", - " outer_radius=100,\n", - " number_of_coils=10,\n", - " gap_size=5,\n", - " height=300,\n", - " stp_filename=\"inner_tf_coils_flat.stp\",\n", - ")\n", - "\n", - "# this makes 4 pf coil cases\n", - "pf_coil_set = paramak.PoloidalFieldCoilCaseSet(\n", - " heights=[10, 10, 20, 20],\n", - " widths=[10, 10, 20, 40],\n", - " casing_thicknesses=[5, 5, 10, 10],\n", - " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"pf_coil_case_set.stp\"\n", - ")\n", - "\n", - "# this makes 4 pf coils\n", - "pf_coil_set = paramak.PoloidalFieldCoilSet(\n", - " heights=[10, 10, 20, 20],\n", - " widths=[10, 10, 20, 40],\n", - " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"pf_coil_set.stp\"\n", - ")\n", - "\n", - "# this makes 4 pf coil cases for the 4 pf coils made above\n", - "component = paramak.PoloidalFieldCoilCaseSetFC(\n", - " pf_coils=pf_coil_set,\n", - " casing_thicknesses=[5, 5, 10, 10],\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"pf_coil_cases_set.stp\"\n", - ")\n", - "\n", - "# this makes 1 pf coils\n", - "pf_coil = paramak.PoloidalFieldCoil(\n", - " center_point=(100, 100),\n", - " height=20,\n", - " width=20,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"poloidal_field_coil.stp\"\n", - ")\n", - "\n", - "# this makes one PF coil case for the provided pf coil\n", - "component = paramak.PoloidalFieldCoilCaseSetFC(\n", - " pf_coils=[pf_coil],\n", - " casing_thicknesses=[10],\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"pf_coil_cases_set_fc.stp\"\n", - ")\n", - "\n", - "component = paramak.PoloidalFieldCoilCaseFC(\n", - " pf_coil=pf_coil,\n", - " casing_thickness=10,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"poloidal_field_coil_case_fc.stp\",\n", - ")\n", - "\n", - "component = paramak.PoloidalFieldCoilCase(\n", - " center_point=(100, 100),\n", - " coil_height=20,\n", - " coil_width=20,\n", - " casing_thickness=10,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"poloidal_field_coil_case.stp\",\n", - ")\n", - "\n", - "component = paramak.BlanketConstantThicknessArcV(\n", - " inner_lower_point=(300, -200),\n", - " inner_mid_point=(500, 0),\n", - " inner_upper_point=(300, 200),\n", - " thickness=100,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"blanket_arc_v.stp\",\n", - ")\n", - "\n", - "component = paramak.BlanketConstantThicknessArcH(\n", - " inner_lower_point=(300, -200),\n", - " inner_mid_point=(400, 0),\n", - " inner_upper_point=(300, 200),\n", - " thickness=100,\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"blanket_arc_h.stp\",\n", - ")\n", - "\n", - "component = paramak.ToroidalFieldCoilRectangle(\n", - " horizontal_start_point=(100, 700),\n", - " vertical_mid_point=(800, 0),\n", - " thickness=150,\n", - " distance=60,\n", - " stp_filename=\"tf_coil_rectangle.stp\",\n", - " number_of_coils=1,\n", - ")\n", - "\n", - "component = paramak.ToroidalFieldCoilCoatHanger(\n", - " horizontal_start_point=(200, 500),\n", - " horizontal_length=400,\n", - " vertical_mid_point=(700, 50),\n", - " vertical_length=500,\n", - " thickness=50,\n", - " distance=50,\n", - " stp_filename=\"toroidal_field_coil_coat_hanger.stp\",\n", - " number_of_coils=1,\n", - ")\n", - "\n", - "component = paramak.ToroidalFieldCoilTripleArc(\n", - " R1=80,\n", - " h=200,\n", - " radii=(70, 100),\n", - " coverages=(60, 60),\n", - " thickness=30,\n", - " distance=30,\n", - " number_of_coils=1,\n", - " stp_filename=\"toroidal_field_coil_triple_arc.stp\"\n", - ")\n", - "\n", - "magnet = paramak.ToroidalFieldCoilPrincetonD(\n", - " R1=80,\n", - " R2=300,\n", - " thickness=30,\n", - " distance=30,\n", - " number_of_coils=1,\n", - " stp_filename=\"toroidal_field_coil_princeton_d.stp\"\n", - ")\n", - "\n", - "component = paramak.ITERtypeDivertor(\n", - " # default parameters\n", - " rotation_angle=rot_angle,\n", - " stp_filename=\"ITER_type_divertor.stp\",\n", - ")\n", - "\n", - "component = paramak.PortCutterRotated(\n", - " center_point=(450, 0),\n", - " polar_coverage_angle=20,\n", - " rotation_angle=10,\n", - " polar_placement_angle=45,\n", - " azimuth_placement_angle=0\n", - ")\n", - "\n", - "component = paramak.PortCutterRectangular(\n", - " distance=3,\n", - " center_point=(0, 0),\n", - " height=0.2,\n", - " width=0.4,\n", - " fillet_radius=0.02,\n", - " azimuth_placement_angle=[0, 45, 90, 180]\n", - ")\n", - "\n", - "component = paramak.PortCutterCircular(\n", - " distance=3,\n", - " center_point=(0.25, 0),\n", - " radius=0.1,\n", - " # azimuth_placement_angle=[0, 45, 90, 180], # TODO: fix issue #548\n", - " azimuth_placement_angle=[0, 45, 90],\n", - ")\n", - "\n", - "component = paramak.VacuumVessel(\n", - " height=2, inner_radius=1, thickness=0.2, rotation_angle=270\n", - ")\n", - "\n", - "component = paramak.CoolantChannelRingStraight(\n", - " height=200,\n", - " channel_radius=10,\n", - " ring_radius=70,\n", - " number_of_coolant_channels=8,\n", - " workplane=\"XY\",\n", - " rotation_axis=\"Z\",\n", - " stp_filename=\"coolant_channel_ring_straight.stp\",\n", - ")\n", - "\n", - "component = paramak.CoolantChannelRingCurved(\n", - " height=200,\n", - " channel_radius=10,\n", - " ring_radius=70,\n", - " mid_offset=-20,\n", - " number_of_coolant_channels=8,\n", - " workplane=\"XY\",\n", - " path_workplane=\"XZ\",\n", - " stp_filename=\"coolant_channel_ring_curved.stp\",\n", - " force_cross_section=True\n", - ")\n", - "\n", - "component = paramak.RotatedIsoscelesTriangle(\n", - " height=20,\n", - " base_length=15,\n", - " pivot_angle=0,\n", - " pivot_point=(100, 50),\n", - " rotation_angle=70,\n", - " workplane='XY',\n", - " stp_filename='rotated_isosceles_triangle.stp'\n", - ")\n", - "\n", - "component = paramak.RotatedTrapezoid(\n", - " length_1=10,\n", - " length_2=20,\n", - " length_3=30,\n", - " pivot_angle=0,\n", - " pivot_point=(100, 50),\n", - " rotation_angle=45,\n", - " stp_filename='rotated_trapezoid.stp'\n", - ")\n", - "\n", - "component = paramak.PoloidalSegments(\n", - " number_of_segments=5,\n", - " center_point=(400, 50)\n", - ")\n", - "\n", - "component = paramak.TFCoilCasing(\n", - " magnet=magnet,\n", - " inner_offset=10,\n", - " outer_offset=15,\n", - " vertical_section_offset=20,\n", - " distance=40\n", - ")\n", - "\n", - "component = paramak.HexagonPin(\n", - " length_of_side=5,\n", - " distance=10,\n", - " center_point=(10, 20)\n", - ")\n", - "\n", - "component = paramak.VacuumVesselInnerLeg(\n", - " inner_height=760,\n", - " inner_radius=400,\n", - " inner_leg_radius=250,\n", - " thickness=20\n", - ")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.3" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/examples/example_parametric_components/make_components_blankets.ipynb b/examples/example_parametric_components/make_components_blankets.ipynb new file mode 100644 index 000000000..67cd69b34 --- /dev/null +++ b/examples/example_parametric_components/make_components_blankets.ipynb @@ -0,0 +1,151 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak\n", + "\n", + "rot_angle = 90\n", + "\n", + "plasma = paramak.Plasma(\n", + " # default parameters\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"plasma_shape.stp\",\n", + ")\n", + "plasma.show()\n", + "\n", + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=-90,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_outboard_plasma.stp\",\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketCutterStar(\n", + " height=2000,\n", + " width=2000,\n", + " distance=100\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=90,\n", + " start_angle=250,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_inboard_plasma.stp\",\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketFP(\n", + " plasma=plasma,\n", + " thickness=100,\n", + " stop_angle=250,\n", + " start_angle=-90,\n", + " offset_from_plasma=30,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_constant_thickness_plasma.stp\",\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketConstantThicknessArcH(\n", + " inner_lower_point=(300, -200),\n", + " inner_mid_point=(400, 0),\n", + " inner_upper_point=(300, 200),\n", + " thickness=100,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_arc_h.stp\",\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.BlanketConstantThicknessArcV(\n", + " inner_lower_point=(300, -200),\n", + " inner_mid_point=(500, 0),\n", + " inner_upper_point=(300, 200),\n", + " thickness=100,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"blanket_arc_v.stp\",\n", + ")\n", + "\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_components_center_column.ipynb b/examples/example_parametric_components/make_components_center_column.ipynb new file mode 100644 index 000000000..c82cb42c5 --- /dev/null +++ b/examples/example_parametric_components/make_components_center_column.ipynb @@ -0,0 +1,223 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak\n", + "\n", + "rot_angle = 90\n", + "\n", + "CenterColumnShieldCylinder = paramak.CenterColumnShieldCylinder(\n", + " inner_radius=80,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_cylinder.stp\",\n", + ")\n", + "CenterColumnShieldCylinder.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldCylinder,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_cylinder.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CenterColumnShieldHyperbola = paramak.CenterColumnShieldHyperbola(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_hyperbola.stp\",\n", + ")\n", + "CenterColumnShieldHyperbola.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_hyperbola.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CenterColumnShieldCircular = paramak.CenterColumnShieldCircular(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_circular.stp\",\n", + ")\n", + "CenterColumnShieldCircular.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldCircular,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_circular.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CenterColumnShieldFlatTopHyperbola = paramak.CenterColumnShieldFlatTopHyperbola(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " arc_height=220,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_flat_top_hyperbola.stp\",\n", + ")\n", + "CenterColumnShieldFlatTopHyperbola.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldFlatTopHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_flat_top_hyperbola.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CenterColumnShieldFlatTopCircular = paramak.CenterColumnShieldFlatTopCircular(\n", + " inner_radius=50,\n", + " mid_radius=75,\n", + " outer_radius=100,\n", + " arc_height=220,\n", + " height=300,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_flat_top_Circular.stp\",\n", + ")\n", + "CenterColumnShieldFlatTopCircular.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldFlatTopCircular,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_flat_top_Circular.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CenterColumnShieldPlasmaHyperbola = paramak.CenterColumnShieldPlasmaHyperbola(\n", + " inner_radius=150,\n", + " mid_offset=50,\n", + " edge_offset=40,\n", + " height=800,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"center_column_shield_plasma_hyperbola.stp\",\n", + ")\n", + "CenterColumnShieldPlasmaHyperbola.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "component = paramak.InboardFirstwallFCCS(\n", + " central_column_shield=CenterColumnShieldPlasmaHyperbola,\n", + " thickness=50,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"firstwall_from_center_column_shield_plasma_hyperbola.stp\",\n", + ")\n", + "component.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_components_magnets.ipynb b/examples/example_parametric_components/make_components_magnets.ipynb new file mode 100644 index 000000000..dd2ab3421 --- /dev/null +++ b/examples/example_parametric_components/make_components_magnets.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InnerTfCoilsCircular(\n", + " inner_radius=25,\n", + " outer_radius=100,\n", + " number_of_coils=10,\n", + " gap_size=5,\n", + " height=300,\n", + " stp_filename=\"inner_tf_coils_circular.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.InnerTfCoilsFlat(\n", + " inner_radius=25,\n", + " outer_radius=100,\n", + " number_of_coils=10,\n", + " gap_size=5,\n", + " height=300,\n", + " stp_filename=\"inner_tf_coils_flat.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rot_angle = 180\n", + "\n", + "# this makes 4 pf coil cases\n", + "pf_coil_set = paramak.PoloidalFieldCoilCaseSet(\n", + " heights=[10, 10, 20, 20],\n", + " widths=[10, 10, 20, 40],\n", + " casing_thicknesses=[5, 5, 10, 10],\n", + " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_case_set.stp\"\n", + ")\n", + "pf_coil_set.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this makes 4 pf coils\n", + "pf_coil_set = paramak.PoloidalFieldCoilSet(\n", + " heights=[10, 10, 20, 20],\n", + " widths=[10, 10, 20, 40],\n", + " center_points=[(100, 100), (100, 150), (50, 200), (50, 50)],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_set.stp\"\n", + ")\n", + "pf_coil_set.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this makes 4 pf coil cases for the 4 pf coils made above\n", + "component = paramak.PoloidalFieldCoilCaseSetFC(\n", + " pf_coils=pf_coil_set,\n", + " casing_thicknesses=[5, 5, 10, 10],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_cases_set.stp\"\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this makes 1 pf coils\n", + "pf_coil = paramak.PoloidalFieldCoil(\n", + " center_point=(100, 100),\n", + " height=20,\n", + " width=20,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil.stp\"\n", + ")\n", + "pf_coil.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# this makes one PF coil case for the provided pf coil\n", + "component = paramak.PoloidalFieldCoilCaseSetFC(\n", + " pf_coils=[pf_coil],\n", + " casing_thicknesses=[10],\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"pf_coil_cases_set_fc.stp\"\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PoloidalFieldCoilCaseFC(\n", + " pf_coil=pf_coil,\n", + " casing_thickness=10,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil_case_fc.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PoloidalFieldCoilCase(\n", + " center_point=(100, 100),\n", + " coil_height=20,\n", + " coil_width=20,\n", + " casing_thickness=10,\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"poloidal_field_coil_case.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.ToroidalFieldCoilRectangle(\n", + " horizontal_start_point=(100, 700),\n", + " vertical_mid_point=(800, 0),\n", + " thickness=150,\n", + " distance=60,\n", + " stp_filename=\"tf_coil_rectangle.stp\",\n", + " number_of_coils=1,\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.ToroidalFieldCoilCoatHanger(\n", + " horizontal_start_point=(200, 500),\n", + " horizontal_length=400,\n", + " vertical_mid_point=(700, 50),\n", + " vertical_length=500,\n", + " thickness=50,\n", + " distance=50,\n", + " stp_filename=\"toroidal_field_coil_coat_hanger.stp\",\n", + " number_of_coils=1,\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.ToroidalFieldCoilTripleArc(\n", + " R1=80,\n", + " h=200,\n", + " radii=(70, 100),\n", + " coverages=(60, 60),\n", + " thickness=30,\n", + " distance=30,\n", + " number_of_coils=1,\n", + " stp_filename=\"toroidal_field_coil_triple_arc.stp\"\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "magnet = paramak.ToroidalFieldCoilPrincetonD(\n", + " R1=80,\n", + " R2=300,\n", + " thickness=30,\n", + " distance=30,\n", + " number_of_coils=1,\n", + " stp_filename=\"toroidal_field_coil_princeton_d.stp\"\n", + ")\n", + "magnet.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.TFCoilCasing(\n", + " magnet=magnet,\n", + " inner_offset=10,\n", + " outer_offset=15,\n", + " vertical_section_offset=20,\n", + " distance=40\n", + ")\n", + "component.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_parametric_components/make_components_other.ipynb b/examples/example_parametric_components/make_components_other.ipynb new file mode 100644 index 000000000..304ef3d0d --- /dev/null +++ b/examples/example_parametric_components/make_components_other.ipynb @@ -0,0 +1,243 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This python script demonstrates the creation of all parametric shapes available\n", + "in the paramak tool" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import paramak\n", + "\n", + "rot_angle = 180\n", + "all_components = []\n", + "\n", + "plasma = paramak.Plasma(\n", + " # default parameters\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"plasma_shape.stp\",\n", + ")\n", + "plasma.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.ITERtypeDivertor(\n", + " # default parameters\n", + " rotation_angle=rot_angle,\n", + " stp_filename=\"ITER_type_divertor.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PortCutterRotated(\n", + " center_point=(450, 0),\n", + " polar_coverage_angle=20,\n", + " rotation_angle=10,\n", + " polar_placement_angle=45,\n", + " azimuth_placement_angle=0\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PortCutterRectangular(\n", + " distance=3,\n", + " center_point=(0, 0),\n", + " height=0.2,\n", + " width=0.4,\n", + " fillet_radius=0.02,\n", + " azimuth_placement_angle=[0, 45, 90, 180]\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PortCutterCircular(\n", + " distance=3,\n", + " center_point=(0.25, 0),\n", + " radius=0.1,\n", + " # azimuth_placement_angle=[0, 45, 90, 180], # TODO: fix issue #548\n", + " azimuth_placement_angle=[0, 45, 90],\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.VacuumVessel(\n", + " height=2, inner_radius=1, thickness=0.2, rotation_angle=270\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.CoolantChannelRingStraight(\n", + " height=200,\n", + " channel_radius=10,\n", + " ring_radius=70,\n", + " number_of_coolant_channels=8,\n", + " workplane=\"XY\",\n", + " rotation_axis=\"Z\",\n", + " stp_filename=\"coolant_channel_ring_straight.stp\",\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.CoolantChannelRingCurved(\n", + " height=200,\n", + " channel_radius=10,\n", + " ring_radius=70,\n", + " mid_offset=-20,\n", + " number_of_coolant_channels=8,\n", + " workplane=\"XY\",\n", + " path_workplane=\"XZ\",\n", + " stp_filename=\"coolant_channel_ring_curved.stp\",\n", + " force_cross_section=True\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.RotatedIsoscelesTriangle(\n", + " height=20,\n", + " base_length=15,\n", + " pivot_angle=0,\n", + " pivot_point=(100, 50),\n", + " rotation_angle=70,\n", + " workplane='XY',\n", + " stp_filename='rotated_isosceles_triangle.stp'\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.RotatedTrapezoid(\n", + " length_1=10,\n", + " length_2=20,\n", + " length_3=30,\n", + " pivot_angle=0,\n", + " pivot_point=(100, 50),\n", + " rotation_angle=45,\n", + " stp_filename='rotated_trapezoid.stp'\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.PoloidalSegments(\n", + " number_of_segments=5,\n", + " center_point=(400, 50)\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.HexagonPin(\n", + " length_of_side=5,\n", + " distance=10,\n", + " center_point=(10, 20)\n", + ")\n", + "component.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "component = paramak.VacuumVesselInnerLeg(\n", + " inner_height=760,\n", + " inner_radius=400,\n", + " inner_leg_radius=250,\n", + " thickness=20\n", + ")\n", + "component.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From fab4dad330d29d545d10cbafb7b442c7a3a2e231 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 4 May 2021 23:57:27 +0100 Subject: [PATCH 04/21] using pymoab instead of trelis for example --- examples/example_neutronics_simulations/ball_reactor.ipynb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/example_neutronics_simulations/ball_reactor.ipynb b/examples/example_neutronics_simulations/ball_reactor.ipynb index bc1244c20..8049201c1 100644 --- a/examples/example_neutronics_simulations/ball_reactor.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor.ipynb @@ -36,6 +36,9 @@ " rotation_angle=360,\n", ")\n", "\n", + "# If you have Trelis or Cubit installed then the below line can be commented out \n", + "my_reactor.method = 'pymoab'\n", + "\n", "# makes a homogenised material for the blanket from lithium lead and\n", "# eurofer\n", "blanket_material = nmm.Material.from_mixture(\n", @@ -101,4 +104,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file From 5a94eebe90bd999ea8a12989057762155bad4ba5 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 5 May 2021 00:11:28 +0100 Subject: [PATCH 05/21] converted py exampels to ipynb --- .../ball_reactor.ipynb | 8 +- .../ball_reactor.py | 71 ----------- .../ball_reactor_minimal.ipynb | 102 ++++++++++++++++ .../ball_reactor_minimal.py | 59 --------- .../ball_reactor_source_plot.ipynb | 43 ++++--- .../ball_reactor_source_plot.py | 94 --------------- .../center_column_study_reactor.ipynb | 113 ++++++++++++++++++ .../center_column_study_reactor.py | 82 ------------- .../center_column_study_reactor_minimal.ipynb | 98 +++++++++++++++ .../center_column_study_reactor_minimal.py | 60 ---------- 10 files changed, 339 insertions(+), 391 deletions(-) delete mode 100644 examples/example_neutronics_simulations/ball_reactor.py create mode 100644 examples/example_neutronics_simulations/ball_reactor_minimal.ipynb delete mode 100644 examples/example_neutronics_simulations/ball_reactor_minimal.py delete mode 100644 examples/example_neutronics_simulations/ball_reactor_source_plot.py create mode 100644 examples/example_neutronics_simulations/center_column_study_reactor.ipynb delete mode 100644 examples/example_neutronics_simulations/center_column_study_reactor.py create mode 100644 examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb delete mode 100644 examples/example_neutronics_simulations/center_column_study_reactor_minimal.py diff --git a/examples/example_neutronics_simulations/ball_reactor.ipynb b/examples/example_neutronics_simulations/ball_reactor.ipynb index 8049201c1..4d37d9aab 100644 --- a/examples/example_neutronics_simulations/ball_reactor.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor.ipynb @@ -36,8 +36,10 @@ " rotation_angle=360,\n", ")\n", "\n", - "# If you have Trelis or Cubit installed then the below line can be commented out \n", - "my_reactor.method = 'pymoab'\n", + "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", + "# pymoab is used as it is open source and can be tested in the CI\n", + "# if you have Trelis or Cubit then this line can be deleted\n", + "my_reactor.method='pymoab'\n", "\n", "# makes a homogenised material for the blanket from lithium lead and\n", "# eurofer\n", @@ -104,4 +106,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/examples/example_neutronics_simulations/ball_reactor.py b/examples/example_neutronics_simulations/ball_reactor.py deleted file mode 100644 index ef0edae6e..000000000 --- a/examples/example_neutronics_simulations/ball_reactor.py +++ /dev/null @@ -1,71 +0,0 @@ -"""This example makes a reactor geometry and a neutronics model. A homogenised -material made of enriched lithium lead and eurofer is being used as the blanket -material for this simulation in order to demonstrate the use of more complex -materials.""" - -import neutronics_material_maker as nmm -import openmc -import paramak - - -"""Makes a neutronics Reactor model and simulates the TBR""" - -# makes the 3d geometry -my_reactor = paramak.BallReactor( - inner_bore_radial_thickness=1, - inboard_tf_leg_radial_thickness=30, - center_column_shield_radial_thickness=60, - divertor_radial_thickness=50, - inner_plasma_gap_radial_thickness=30, - plasma_radial_thickness=300, - outer_plasma_gap_radial_thickness=30, - firstwall_radial_thickness=3, - blanket_radial_thickness=100, - blanket_rear_wall_radial_thickness=3, - elongation=2.75, - triangularity=0.5, - number_of_tf_coils=16, - rotation_angle=360, -) - -# makes a homogenised material for the blanket from lithium lead and -# eurofer -blanket_material = nmm.Material.from_mixture( - fracs=[0.8, 0.2], - materials=[ - nmm.Material.from_library( - name='Pb842Li158', - enrichment=90, - temperature=500), - nmm.Material.from_library(name='eurofer') - ]) - -source = openmc.Source() -# sets the location of the source to x=0 y=0 z=0 -source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) -# sets the direction to isotropic -source.angle = openmc.stats.Isotropic() -# sets the energy distribution to 100% 14MeV neutrons -source.energy = openmc.stats.Discrete([14e6], [1]) - -# makes the neutronics material -neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'inboard_tf_coils_mat': 'copper', - 'center_column_shield_mat': 'WC', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_mat': blanket_material, # use of homogenised material - 'blanket_rear_wall_mat': 'eurofer'}, - cell_tallies=['TBR'], - simulation_batches=5, - simulation_particles_per_batch=1e4, -) - -# starts the neutronics simulation -neutronics_model.simulate() - -# prints the results to screen -print('TBR', neutronics_model.results['TBR']) diff --git a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb new file mode 100644 index 000000000..5e9971127 --- /dev/null +++ b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb @@ -0,0 +1,102 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is a minimal example that obtains the TBR (Tritium Breeding Ratio)\n", + "for a parametric ball reactor\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "import paramak\n", + "\n", + "\n", + "# makes the 3d geometry from input parameters\n", + "my_reactor = paramak.BallReactor(\n", + " inner_bore_radial_thickness=50,\n", + " inboard_tf_leg_radial_thickness=200,\n", + " center_column_shield_radial_thickness=50,\n", + " divertor_radial_thickness=50,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=100,\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=1,\n", + " blanket_radial_thickness=100,\n", + " blanket_rear_wall_radial_thickness=10,\n", + " elongation=2,\n", + " triangularity=0.55,\n", + " number_of_tf_coils=16,\n", + " rotation_angle=360,\n", + ")\n", + "\n", + "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", + "# pymoab is used as it is open source and can be tested in the CI\n", + "# if you have Trelis or Cubit then this line can be deleted\n", + "my_reactor.method='pymoab'\n", + "\n", + "source = openmc.Source()\n", + "# sets the location of the source to x=0 y=0 z=0\n", + "source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n", + "# sets the direction to isotropic\n", + "source.angle = openmc.stats.Isotropic()\n", + "# sets the energy distribution to 100% 14MeV neutrons\n", + "source.energy = openmc.stats.Discrete([14e6], [1])\n", + "\n", + "# makes the neutronics model from the geometry and material allocations\n", + "neutronics_model = paramak.NeutronicsModel(\n", + " geometry=my_reactor,\n", + " source=source,\n", + " materials={\n", + " 'inboard_tf_coils_mat': 'eurofer',\n", + " 'center_column_shield_mat': 'eurofer',\n", + " 'divertor_mat': 'eurofer',\n", + " 'firstwall_mat': 'eurofer',\n", + " 'blanket_rear_wall_mat': 'eurofer',\n", + " 'blanket_mat': 'Li4SiO4'},\n", + " cell_tallies=['TBR', 'heating'],\n", + " simulation_batches=5,\n", + " simulation_particles_per_batch=1e4,\n", + ")\n", + "\n", + "# simulate the neutronics model\n", + "neutronics_model.simulate()\n", + "print(neutronics_model.results)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_neutronics_simulations/ball_reactor_minimal.py b/examples/example_neutronics_simulations/ball_reactor_minimal.py deleted file mode 100644 index b24968d6f..000000000 --- a/examples/example_neutronics_simulations/ball_reactor_minimal.py +++ /dev/null @@ -1,59 +0,0 @@ -"""This is a minimal example that obtains the TBR (Tritium Breeding Ratio) -for a parametric ball reactor""" - -import openmc -import paramak - - -def make_model_and_simulate(): - """Makes a neutronics Reactor model and simulates the TBR""" - - # makes the 3d geometry from input parameters - my_reactor = paramak.BallReactor( - inner_bore_radial_thickness=50, - inboard_tf_leg_radial_thickness=200, - center_column_shield_radial_thickness=50, - divertor_radial_thickness=50, - inner_plasma_gap_radial_thickness=50, - plasma_radial_thickness=100, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=1, - blanket_radial_thickness=100, - blanket_rear_wall_radial_thickness=10, - elongation=2, - triangularity=0.55, - number_of_tf_coils=16, - rotation_angle=360, - ) - - source = openmc.Source() - # sets the location of the source to x=0 y=0 z=0 - source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) - # sets the direction to isotropic - source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - source.energy = openmc.stats.Discrete([14e6], [1]) - - # makes the neutronics model from the geometry and material allocations - neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'inboard_tf_coils_mat': 'eurofer', - 'center_column_shield_mat': 'eurofer', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_rear_wall_mat': 'eurofer', - 'blanket_mat': 'Li4SiO4'}, - cell_tallies=['TBR', 'heating'], - simulation_batches=5, - simulation_particles_per_batch=1e4, - ) - - # simulate the neutronics model - neutronics_model.simulate() - print(neutronics_model.results) - - -if __name__ == "__main__": - make_model_and_simulate() diff --git a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb index 9e7946180..e4780a47a 100644 --- a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb @@ -12,24 +12,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d60463a4756748d8bed08ef7d5f1d524", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "HBox(children=(VBox(children=(HBox(children=(Checkbox(value=False, description='Axes', indent=False, _dom_clas…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "import neutronics_material_maker as nmm\n", "import openmc\n", @@ -52,21 +37,28 @@ " elongation=2,\n", " triangularity=0.55,\n", " number_of_tf_coils=16,\n", - " pf_coil_radial_thicknesses=[50, 50, 50, 50],\n", - " pf_coil_vertical_thicknesses=[50, 50, 50, 50],\n", - " pf_coil_to_rear_blanket_radial_gap=50,\n", - " pf_coil_to_tf_coil_radial_gap=50,\n", + " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", + " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", + " pf_coil_radial_position=[500, 575, 575, 500],\n", + " pf_coil_vertical_position=[300, 100, -100, -300],\n", + " rear_blanket_to_tf_gap=50,\n", " outboard_tf_coil_radial_thickness=100,\n", " outboard_tf_coil_poloidal_thickness=50,\n", " rotation_angle=180,\n", ")\n", "\n", + "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", + "# pymoab is used as it is open source and can be tested in the CI\n", + "# if you have Trelis or Cubit then this line can be deleted\n", + "my_reactor.method='pymoab'\n", + "\n", "my_reactor.show()" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -137,6 +129,13 @@ " number_of_source_particles=1000\n", ")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/examples/example_neutronics_simulations/ball_reactor_source_plot.py b/examples/example_neutronics_simulations/ball_reactor_source_plot.py deleted file mode 100644 index 5433b728e..000000000 --- a/examples/example_neutronics_simulations/ball_reactor_source_plot.py +++ /dev/null @@ -1,94 +0,0 @@ -"""This example makes a reactor geometry and a neutronics model. A homogenised -material made of enriched lithium lead and eurofer is being used as the blanket -material for this simulation in order to demonstrate the use of more complex -materials.""" - -import neutronics_material_maker as nmm -import openmc -import paramak -from parametric_plasma_source import SOURCE_SAMPLING_PATH, PlasmaSource - - -def make_model_and_simulate(): - """Makes a neutronics Reactor model and simulates the TBR""" - - # makes the 3d geometry - my_reactor = paramak.BallReactor( - inner_bore_radial_thickness=10, - inboard_tf_leg_radial_thickness=30, - center_column_shield_radial_thickness=60, - divertor_radial_thickness=150, - inner_plasma_gap_radial_thickness=30, - plasma_radial_thickness=300, - outer_plasma_gap_radial_thickness=30, - firstwall_radial_thickness=30, - blanket_radial_thickness=50, - blanket_rear_wall_radial_thickness=30, - elongation=2, - triangularity=0.55, - number_of_tf_coils=16, - pf_coil_radial_thicknesses=[50, 50, 50, 50], - pf_coil_vertical_thicknesses=[50, 50, 50, 50], - pf_coil_to_rear_blanket_radial_gap=50, - pf_coil_to_tf_coil_radial_gap=50, - outboard_tf_coil_radial_thickness=100, - outboard_tf_coil_poloidal_thickness=50, - rotation_angle=180, - ) - - # creates a parametric plasma source, more details - # https://github.com/open-radiation-sources/parametric-plasma-source - my_plasma = PlasmaSource( - ion_density_origin=1.09e20, - ion_density_peaking_factor=1, - ion_density_pedestal=1.09e20, - ion_density_separatrix=3e19, - ion_temperature_origin=45.9, - ion_temperature_peaking_factor=8.06, - ion_temperature_pedestal=6.09, - ion_temperature_separatrix=0.1, - elongation=2, - triangularity=0.55, - major_radius=2.5, # note the source takes m arguments - minor_radius=1., # note the source takes m arguments - pedestal_radius=0.8 * 100, # note the source takes m arguments - plasma_id=1, - shafranov_shift=0.44789, - ion_temperature_beta=6 - ) - - # assigns parametric plasma source as source - source = openmc.Source() - source.library = SOURCE_SAMPLING_PATH - source.parameters = str(my_plasma) - - # makes the neutronics material - neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'inboard_tf_coils_mat': 'copper', - 'center_column_shield_mat': 'WC', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_mat': 'eurofer', - 'blanket_rear_wall_mat': 'eurofer'}, - ) - - # exports the geometry and source in 2d (RZ) viewplane where R stands for - # radius - neutronics_model.export_html( - filename='2d_source.html', - view_plane='RZ' - ) - - # exports the geometry and source in 3d (XYZ) viewplane - neutronics_model.export_html( - filename='3d_source.html', - view_plane='XYZ', - number_of_source_particles=1000 - ) - - -if __name__ == "__main__": - make_model_and_simulate() diff --git a/examples/example_neutronics_simulations/center_column_study_reactor.ipynb b/examples/example_neutronics_simulations/center_column_study_reactor.ipynb new file mode 100644 index 000000000..2454fdc59 --- /dev/null +++ b/examples/example_neutronics_simulations/center_column_study_reactor.ipynb @@ -0,0 +1,113 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"This example makes a reactor geometry and a neutronics model, the addition\n", + "of a Python for loop allow a parameter sweep of the neutronics results for\n", + "different geometries. The distance between the plasma and center column is\n", + "varried while simulating the impact on the heat depositied in the center\n", + "column.\"\"\"\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import openmc\n", + "import paramak\n", + "\n", + "\n", + "total_heats_in_MW = []\n", + "plasma_to_center_column_gaps = []\n", + "\n", + "# this will take a few mins to perform 3 simulations at\n", + "for plasma_to_center_column_gap in [50, 100, 150]:\n", + "\n", + " # makes the 3d geometry\n", + " my_reactor = paramak.CenterColumnStudyReactor(\n", + " inner_bore_radial_thickness=20,\n", + " inboard_tf_leg_radial_thickness=50,\n", + " center_column_shield_radial_thickness_mid=50,\n", + " center_column_shield_radial_thickness_upper=100,\n", + " inboard_firstwall_radial_thickness=2,\n", + " divertor_radial_thickness=100,\n", + " inner_plasma_gap_radial_thickness=plasma_to_center_column_gap,\n", + " plasma_radial_thickness=200,\n", + " outer_plasma_gap_radial_thickness=90,\n", + " elongation=2.75,\n", + " triangularity=0.5,\n", + " plasma_gap_vertical_thickness=40,\n", + " center_column_arc_vertical_thickness=520,\n", + " rotation_angle=360\n", + " )\n", + " \n", + " # method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", + " # pymoab is used as it is open source and can be tested in the CI\n", + " # if you have Trelis or Cubit then this line can be deleted\n", + " my_reactor.method='pymoab'\n", + "\n", + " source = openmc.Source()\n", + " # sets the location of the source to x=0 y=0 z=0\n", + " source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n", + " # sets the direction to isotropic\n", + " source.angle = openmc.stats.Isotropic()\n", + " # sets the energy distribution to 100% 14MeV neutrons\n", + " source.energy = openmc.stats.Discrete([14e6], [1])\n", + "\n", + " # makes the neutronics model and assigns basic materials to each\n", + " # component\n", + " neutronics_model = paramak.NeutronicsModel(\n", + " geometry=my_reactor,\n", + " source=source,\n", + " materials={\n", + " 'DT_plasma': 'DT_plasma',\n", + " 'inboard_tf_coils_mat': 'eurofer',\n", + " 'center_column_shield_mat': 'eurofer',\n", + " 'divertor_mat': 'eurofer',\n", + " 'firstwall_mat': 'eurofer',\n", + " 'blanket_mat': 'Li4SiO4'},\n", + " cell_tallies=['heating'],\n", + " simulation_batches=5,\n", + " simulation_particles_per_batch=1e4,\n", + " )\n", + "\n", + " # starts the neutronics simulation\n", + " neutronics_model.simulate()\n", + "\n", + " # converts the results to mega watts\n", + " total_heat_in_MW = neutronics_model.results['firstwall_mat_heating']['Watts']['result'] / 1e6\n", + "\n", + " # adds the results and inputs to a list\n", + " total_heats_in_MW.append(total_heat_in_MW)\n", + " plasma_to_center_column_gaps.append(plasma_to_center_column_gap)\n", + "\n", + "# plots the results\n", + "plt.scatter(plasma_to_center_column_gaps, total_heats_in_MW)\n", + "plt.xlabel('plasma_to_center_column_gap (cm)')\n", + "plt.ylabel('Heat on the inboard (MW)')\n", + "plt.show()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_neutronics_simulations/center_column_study_reactor.py b/examples/example_neutronics_simulations/center_column_study_reactor.py deleted file mode 100644 index cd145078e..000000000 --- a/examples/example_neutronics_simulations/center_column_study_reactor.py +++ /dev/null @@ -1,82 +0,0 @@ -"""This example makes a reactor geometry and a neutronics model, the addition -of a Python for loop allow a parameter sweep of the neutronics results for -different geometries. The distance between the plasma and center column is -varried while simulating the impact on the heat depositied in the center -column.""" - -import matplotlib.pyplot as plt -import openmc -import paramak - - -def make_model_and_simulate(): - """Makes a neutronics Reactor model and simulates the TBR""" - - total_heats_in_MW = [] - plasma_to_center_column_gaps = [] - - # this will take a few mins to perform 3 simulations at - for plasma_to_center_column_gap in [50, 100, 150]: - - # makes the 3d geometry - my_reactor = paramak.CenterColumnStudyReactor( - inner_bore_radial_thickness=20, - inboard_tf_leg_radial_thickness=50, - center_column_shield_radial_thickness_mid=50, - center_column_shield_radial_thickness_upper=100, - inboard_firstwall_radial_thickness=2, - divertor_radial_thickness=100, - inner_plasma_gap_radial_thickness=plasma_to_center_column_gap, - plasma_radial_thickness=200, - outer_plasma_gap_radial_thickness=90, - elongation=2.75, - triangularity=0.5, - plasma_gap_vertical_thickness=40, - center_column_arc_vertical_thickness=520, - rotation_angle=360 - ) - - source = openmc.Source() - # sets the location of the source to x=0 y=0 z=0 - source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) - # sets the direction to isotropic - source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - source.energy = openmc.stats.Discrete([14e6], [1]) - - # makes the neutronics model and assigns basic materials to each - # component - neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'DT_plasma': 'DT_plasma', - 'inboard_tf_coils_mat': 'eurofer', - 'center_column_shield_mat': 'eurofer', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_mat': 'Li4SiO4'}, - cell_tallies=['heating'], - simulation_batches=5, - simulation_particles_per_batch=1e4, - ) - - # starts the neutronics simulation - neutronics_model.simulate() - - # converts the results to mega watts - total_heat_in_MW = neutronics_model.results['firstwall_mat_heating']['Watts']['result'] / 1e6 - - # adds the results and inputs to a list - total_heats_in_MW.append(total_heat_in_MW) - plasma_to_center_column_gaps.append(plasma_to_center_column_gap) - - # plots the results - plt.scatter(plasma_to_center_column_gaps, total_heats_in_MW) - plt.xlabel('plasma_to_center_column_gap (cm)') - plt.ylabel('Heat on the inboard (MW)') - plt.show() - - -if __name__ == "__main__": - make_model_and_simulate() diff --git a/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb b/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb new file mode 100644 index 000000000..bea0ccab2 --- /dev/null +++ b/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb @@ -0,0 +1,98 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\"\"\"This is a minimal example that obtains the center column heating for a\n", + "parametric reactor.\"\"\"\n", + "\n", + "import openmc\n", + "import paramak\n", + "\n", + "\n", + "# makes the 3d geometry\n", + "my_reactor = paramak.CenterColumnStudyReactor(\n", + " inner_bore_radial_thickness=20,\n", + " inboard_tf_leg_radial_thickness=50,\n", + " center_column_shield_radial_thickness_mid=50,\n", + " center_column_shield_radial_thickness_upper=100,\n", + " inboard_firstwall_radial_thickness=20,\n", + " divertor_radial_thickness=100,\n", + " inner_plasma_gap_radial_thickness=80,\n", + " plasma_radial_thickness=200,\n", + " outer_plasma_gap_radial_thickness=90,\n", + " elongation=2.75,\n", + " triangularity=0.5,\n", + " plasma_gap_vertical_thickness=40,\n", + " center_column_arc_vertical_thickness=520,\n", + " rotation_angle=360\n", + ")\n", + "\n", + "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", + "# pymoab is used as it is open source and can be tested in the CI\n", + "# if you have Trelis or Cubit then this line can be deleted\n", + "my_reactor.method='pymoab'\n", + "\n", + "source = openmc.Source()\n", + "# sets the location of the source to x=0 y=0 z=0\n", + "source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n", + "# sets the direction to isotropic\n", + "source.angle = openmc.stats.Isotropic()\n", + "# sets the energy distribution to 100% 14MeV neutrons\n", + "source.energy = openmc.stats.Discrete([14e6], [1])\n", + "\n", + "# creates a neutronics model from the geometry and assigned materials\n", + "neutronics_model = paramak.NeutronicsModel(\n", + " geometry=my_reactor,\n", + " source=source,\n", + " materials={\n", + " 'inboard_tf_coils_mat': 'eurofer',\n", + " 'center_column_shield_mat': 'eurofer',\n", + " 'divertor_mat': 'eurofer',\n", + " 'firstwall_mat': 'eurofer',\n", + " 'blanket_mat': 'Li4SiO4'},\n", + " cell_tallies=['heating'],\n", + " simulation_batches=5,\n", + " simulation_particles_per_batch=1e4,\n", + ")\n", + "\n", + "# starts the neutronics simulation\n", + "neutronics_model.simulate()\n", + "\n", + "# prints the results\n", + "print(neutronics_model.results)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_neutronics_simulations/center_column_study_reactor_minimal.py b/examples/example_neutronics_simulations/center_column_study_reactor_minimal.py deleted file mode 100644 index 47b6f8abb..000000000 --- a/examples/example_neutronics_simulations/center_column_study_reactor_minimal.py +++ /dev/null @@ -1,60 +0,0 @@ -"""This is a minimal example that obtains the center column heating for a -parametric reactor.""" - -import openmc -import paramak - - -def make_model_and_simulate(): - """Makes a neutronics Reactor model and simulates the heat deposition""" - - # makes the 3d geometry - my_reactor = paramak.CenterColumnStudyReactor( - inner_bore_radial_thickness=20, - inboard_tf_leg_radial_thickness=50, - center_column_shield_radial_thickness_mid=50, - center_column_shield_radial_thickness_upper=100, - inboard_firstwall_radial_thickness=20, - divertor_radial_thickness=100, - inner_plasma_gap_radial_thickness=80, - plasma_radial_thickness=200, - outer_plasma_gap_radial_thickness=90, - elongation=2.75, - triangularity=0.5, - plasma_gap_vertical_thickness=40, - center_column_arc_vertical_thickness=520, - rotation_angle=360 - ) - - source = openmc.Source() - # sets the location of the source to x=0 y=0 z=0 - source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) - # sets the direction to isotropic - source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - source.energy = openmc.stats.Discrete([14e6], [1]) - - # creates a neutronics model from the geometry and assigned materials - neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'inboard_tf_coils_mat': 'eurofer', - 'center_column_shield_mat': 'eurofer', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_mat': 'Li4SiO4'}, - cell_tallies=['heating'], - simulation_batches=5, - simulation_particles_per_batch=1e4, - ) - - # starts the neutronics simulation - neutronics_model.simulate() - - # prints the results - print(neutronics_model.results) - - -if __name__ == "__main__": - make_model_and_simulate() From 6be58df61eadd06abf1e9e665ada26cbe281b9fe Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 5 May 2021 00:18:44 +0100 Subject: [PATCH 06/21] trying to fix str to ascii conversion error --- .../ball_reactor.ipynb | 15 ++-- .../ball_reactor_minimal.ipynb | 3 +- .../ball_reactor_source_plot.ipynb | 5 +- tests/test_example_neutronics_simulations.py | 74 +------------------ 4 files changed, 10 insertions(+), 87 deletions(-) diff --git a/examples/example_neutronics_simulations/ball_reactor.ipynb b/examples/example_neutronics_simulations/ball_reactor.ipynb index 4d37d9aab..704e1af82 100644 --- a/examples/example_neutronics_simulations/ball_reactor.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor.ipynb @@ -1,23 +1,22 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This example makes a reactor geometry and a neutronics model. A homogenised material made of enriched lithium lead and eurofer is being used as the blanket material for this simulation in order to demonstrate the use of more complex materials." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "\"\"\"This example makes a reactor geometry and a neutronics model. A homogenised\n", - "material made of enriched lithium lead and eurofer is being used as the blanket\n", - "material for this simulation in order to demonstrate the use of more complex\n", - "materials.\"\"\"\n", - "\n", "import neutronics_material_maker as nmm\n", "import openmc\n", "import paramak\n", "\n", - "\n", - "\"\"\"Makes a neutronics Reactor model and simulates the TBR\"\"\"\n", - "\n", "# makes the 3d geometry\n", "my_reactor = paramak.BallReactor(\n", " inner_bore_radial_thickness=1,\n", diff --git a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb index 5e9971127..05d4e6fee 100644 --- a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb @@ -4,8 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This is a minimal example that obtains the TBR (Tritium Breeding Ratio)\n", - "for a parametric ball reactor\n" + "This is a minimal example that obtains the TBR (Tritium Breeding Ratio) for a parametric ball reactor" ] }, { diff --git a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb index e4780a47a..a3b76f095 100644 --- a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb @@ -4,10 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This example makes a reactor geometry and a neutronics model. A homogenised\n", - "material made of enriched lithium lead and eurofer is being used as the blanket\n", - "material for this simulation in order to demonstrate the use of more complex\n", - "materials." + "This example makes a reactor geometry and a neutronics model. A homogenised material made of enriched lithium lead and eurofer is being used as the blanket material for this simulation in order to demonstrate the use of more complex materials." ] }, { diff --git a/tests/test_example_neutronics_simulations.py b/tests/test_example_neutronics_simulations.py index 3ba7e4c40..1adca5d6f 100644 --- a/tests/test_example_neutronics_simulations.py +++ b/tests/test_example_neutronics_simulations.py @@ -18,83 +18,11 @@ class TestExampleNeutronics(unittest.TestCase): def test_jupyter_notebooks_example_neutronics_simulations(self): - for notebook in Path().rglob("examples/example_neutronics_simulations//*.ipynb"): + for notebook in Path().rglob("examples/example_neutronics_simulations/*.ipynb"): print(notebook) nb, errors = notebook_run(notebook) assert errors == [] - def test_shape_with_gas_production(self): - """Runs the example and checks the output files are produced""" - os.system("rm *.png *.vtk *.json *.h5") - output_filenames = [ - "results.json", - "n-Xp_on_2D_mesh_yz.png", - "n-Xp_on_2D_mesh_xy.png", - "n-Xp_on_2D_mesh_xz.png", - "n-Xt_on_2D_mesh_yz.png", - "n-Xt_on_2D_mesh_xy.png", - "n-Xt_on_2D_mesh_xz.png", - "n-Xa_on_2D_mesh_yz.png", - "n-Xa_on_2D_mesh_xy.png", - "n-Xa_on_2D_mesh_xz.png", - "n-Xp_on_3D_mesh.vtk", - "n-Xt_on_3D_mesh.vtk", - "n-Xa_on_3D_mesh.vtk", - "summary.h5", - ] - - shape_with_gas_production.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_component_based_mesh_simulation(self): - """Runs the example and checks the output files are produced""" - os.system("rm *.png *.vtk *.json *.h5 *.stp") - output_filenames = [ - "results.json", - "statepoint.10.h5", - "summary.h5", - "my_shape.stp", - "heating_on_2D_mesh_yz.png", - "heating_on_2D_mesh_yz.png", - "heating_on_2D_mesh_xz.png", - "heating_on_3D_mesh.vtk", - ] - - component_based_mesh_simulation.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_component_based_parameter_study(self): - """Runs the example and checks the output files are produced""" - os.system("rm *.png *.vtk *.json *.h5 *.stp") - output_filenames = [ - "my_shape60.stp", - "my_shape70.stp", - "my_shape80.stp", - "results.json", - "heating_vs_thickness.svg", - "statepoint.10.h5", - "summary.h5", - ] - - component_based_parameter_study.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - - def test_shape_with_spectra_cell_tally(self): - """Runs the example and checks the output files are produced""" - os.system("rm *.png *.vtk *.json *.h5") - output_filenames = [ - "results.json", - "statepoint.2.h5", - "summary.h5", - ] - - shape_with_spectra_cell_tally.main() - for output_filename in output_filenames: - assert Path(output_filename).exists() is True - if __name__ == "__main__": unittest.main() From 7378c71ece19d4b7bb211691d38fdeb18068854c Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 5 May 2021 12:02:09 +0100 Subject: [PATCH 07/21] reduced complexity --- .../ball_reactor_source_plot.ipynb | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb index a3b76f095..484b48b5f 100644 --- a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb @@ -16,7 +16,6 @@ "import neutronics_material_maker as nmm\n", "import openmc\n", "import paramak\n", - "from parametric_plasma_source import SOURCE_SAMPLING_PATH, PlasmaSource\n", "\n", "\n", "# makes the 3d geometry\n", @@ -33,16 +32,9 @@ " blanket_rear_wall_radial_thickness=30,\n", " elongation=2,\n", " triangularity=0.55,\n", - " number_of_tf_coils=16,\n", - " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", - " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_radial_position=[500, 575, 575, 500],\n", - " pf_coil_vertical_position=[300, 100, -100, -300],\n", - " rear_blanket_to_tf_gap=50,\n", " outboard_tf_coil_radial_thickness=100,\n", " outboard_tf_coil_poloidal_thickness=50,\n", - " rotation_angle=180,\n", + " rotation_angle=90,\n", ")\n", "\n", "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", @@ -53,37 +45,31 @@ "my_reactor.show()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# creates a parametric plasma source, more details\n", - "# https://github.com/open-radiation-sources/parametric-plasma-source\n", - "my_plasma = PlasmaSource(\n", - " ion_density_origin=1.09e20,\n", - " ion_density_peaking_factor=1,\n", - " ion_density_pedestal=1.09e20,\n", - " ion_density_separatrix=3e19,\n", - " ion_temperature_origin=45.9,\n", - " ion_temperature_peaking_factor=8.06,\n", - " ion_temperature_pedestal=6.09,\n", - " ion_temperature_separatrix=0.1,\n", - " elongation=2,\n", - " triangularity=0.55,\n", - " major_radius=2.5, # note the source takes m arguments\n", - " minor_radius=1., # note the source takes m arguments\n", - " pedestal_radius=0.8 * 100, # note the source takes m arguments\n", - " plasma_id=1,\n", - " shafranov_shift=0.44789,\n", - " ion_temperature_beta=6\n", - ")\n", - "\n", - "# assigns parametric plasma source as source\n", "source = openmc.Source()\n", - "source.library = SOURCE_SAMPLING_PATH\n", - "source.parameters = str(my_plasma)" + "radius = openmc.stats.Discrete([300], [1]) # at the major radius\n", + "z_values = openmc.stats.Discrete([0], [1]) # middle of the plasma (vertically)\n", + "angle = openmc.stats.Uniform(a=0., b=2 * 3.14159265359) # 360 degrees\n", + "source.space = openmc.stats.CylindricalIndependent(\n", + " r=radius,\n", + " phi=angle,\n", + " z=z_values,\n", + " origin=(0.0, 0.0, 0.0)\n", + ")\n", + "source.angle = openmc.stats.Isotropic()\n", + "source.energy = openmc.stats.Discrete([14_060_000], [1])" ] }, { @@ -117,13 +103,21 @@ "neutronics_model.export_html(\n", " filename='2d_source.html',\n", " view_plane='RZ'\n", - ")\n", - "\n", + " number_of_source_particles=100\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# exports the geometry and source in 3d (XYZ) viewplane\n", "neutronics_model.export_html(\n", " filename='3d_source.html',\n", " view_plane='XYZ',\n", - " number_of_source_particles=1000\n", + " number_of_source_particles=100\n", ")" ] }, From 916fb245ce3011577341b23a16caa86be106ee33 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 5 May 2021 12:14:09 +0100 Subject: [PATCH 08/21] added missing , --- .../ball_reactor_source_plot.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb index 484b48b5f..0226bafcb 100644 --- a/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_source_plot.ipynb @@ -102,7 +102,7 @@ "# radius\n", "neutronics_model.export_html(\n", " filename='2d_source.html',\n", - " view_plane='RZ'\n", + " view_plane='RZ',\n", " number_of_source_particles=100\n", ")" ] From 0299d41e1f6694c9d0223f2b9fd7b9567cb384a0 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 5 May 2021 20:52:34 +0100 Subject: [PATCH 09/21] added text to neutronics example --- .../text_example.ipynb | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 examples/example_neutronics_simulations/text_example.ipynb diff --git a/examples/example_neutronics_simulations/text_example.ipynb b/examples/example_neutronics_simulations/text_example.ipynb new file mode 100644 index 000000000..629801a63 --- /dev/null +++ b/examples/example_neutronics_simulations/text_example.ipynb @@ -0,0 +1,84 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A simple example of text being " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import cadquery as cq\n", + "import openmc\n", + "import paramak\n", + "\n", + "text = cq.Workplane().text( \n", + " txt=\"The Paramak can easily convert CAD\\nto neutronics models for simulations.\",\n", + " fontsize=0.5,\n", + " distance=-1,\n", + " cut=True,\n", + " halign=\"left\",\n", + " valign=\"bottom\",\n", + " font=\"Sans\"\n", + ")\n", + "\n", + "# this creates an empty Shape and populates it with the CQ object\n", + "my_shape = paramak.Shape()\n", + "my_shape.solid = text\n", + "my_shape.method = 'pymoab'\n", + "my_shape.stl_filename = 'text.stl'\n", + "my_shape.material_tag = 'my_material'\n", + "my_shape.export_stp('text_cad.stp')\n", + "\n", + "coords = openmc.stats.Point((4, 1, 0.5))\n", + "energy = openmc.stats.Discrete([1.41E7], [1.0])\n", + "source = openmc.Source(space=coords, energy=energy)\n", + "\n", + "my_model = paramak.NeutronicsModel(\n", + " geometry=my_shape,\n", + " source=source,\n", + " materials={'my_material': 'Li4SiO4'},\n", + " mesh_tally_3d=['heating', '(n,Xt)'],\n", + " simulation_batches=2, # to get a good mesh tally result with will need increasing\n", + " mesh_3d_resolution=(850, 350, 10),\n", + " mesh_3d_corners=[(0, -1, -1), (8.5, 2.5, 0.5)],\n", + ")\n", + "\n", + "my_model.simulate()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From f08ba412f59ab1b24ceb5170af87893c5f9b2088 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 6 May 2021 17:19:49 +0100 Subject: [PATCH 10/21] changed examples rotation angles to work with pymoab --- .../example_neutronics_simulations/ball_reactor.ipynb | 8 ++++---- .../ball_reactor_minimal.ipynb | 8 ++++---- .../ball_reactor_single_null.ipynb | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/example_neutronics_simulations/ball_reactor.ipynb b/examples/example_neutronics_simulations/ball_reactor.ipynb index 704e1af82..46c3bcb6c 100644 --- a/examples/example_neutronics_simulations/ball_reactor.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor.ipynb @@ -32,7 +32,7 @@ " elongation=2.75,\n", " triangularity=0.5,\n", " number_of_tf_coils=16,\n", - " rotation_angle=360,\n", + " rotation_angle=359.9, # when using trelis method this can be set to 360\n", ")\n", "\n", "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", @@ -72,8 +72,8 @@ " 'blanket_mat': blanket_material, # use of homogenised material\n", " 'blanket_rear_wall_mat': 'eurofer'},\n", " cell_tallies=['TBR'],\n", - " simulation_batches=5,\n", - " simulation_particles_per_batch=1e4,\n", + " simulation_batches=2,\n", + " simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n", ")\n", "\n", "# starts the neutronics simulation\n", @@ -105,4 +105,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb index 05d4e6fee..99d31d9c3 100644 --- a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb @@ -32,7 +32,7 @@ " elongation=2,\n", " triangularity=0.55,\n", " number_of_tf_coils=16,\n", - " rotation_angle=360,\n", + " rotation_angle=359.9, # when using trelis method this can be set to 360\n", ")\n", "\n", "# method is set to Trelis or Cubit by default to avoid overlaps in the geometry\n", @@ -60,8 +60,8 @@ " 'blanket_rear_wall_mat': 'eurofer',\n", " 'blanket_mat': 'Li4SiO4'},\n", " cell_tallies=['TBR', 'heating'],\n", - " simulation_batches=5,\n", - " simulation_particles_per_batch=1e4,\n", + " simulation_batches=2,\n", + " simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n", ")\n", "\n", "# simulate the neutronics model\n", @@ -98,4 +98,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/examples/example_parametric_reactors/ball_reactor_single_null.ipynb b/examples/example_parametric_reactors/ball_reactor_single_null.ipynb index 343372139..a88b0de0f 100644 --- a/examples/example_parametric_reactors/ball_reactor_single_null.ipynb +++ b/examples/example_parametric_reactors/ball_reactor_single_null.ipynb @@ -40,7 +40,7 @@ "metadata": {}, "outputs": [], "source": [ - "my_reactor.export_stp(filenamee)\n", + "my_reactor.export_stp('single_null_ball_reactor.stp')\n", "\n", "my_reactor.export_neutronics_description('manifest.json')\n", "\n", @@ -80,4 +80,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file From 70b70c95e8ba309db5963795aaf2e19118f5ab81 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 6 May 2021 17:47:46 +0100 Subject: [PATCH 11/21] reduced particles to speed up ci testing --- examples/example_neutronics_simulations/ball_reactor.ipynb | 2 +- .../example_neutronics_simulations/ball_reactor_minimal.ipynb | 2 +- .../center_column_study_reactor.ipynb | 4 ++-- .../center_column_study_reactor_minimal.ipynb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/example_neutronics_simulations/ball_reactor.ipynb b/examples/example_neutronics_simulations/ball_reactor.ipynb index 46c3bcb6c..be32cff5d 100644 --- a/examples/example_neutronics_simulations/ball_reactor.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor.ipynb @@ -105,4 +105,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb index 99d31d9c3..e3da51869 100644 --- a/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb +++ b/examples/example_neutronics_simulations/ball_reactor_minimal.ipynb @@ -98,4 +98,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/examples/example_neutronics_simulations/center_column_study_reactor.ipynb b/examples/example_neutronics_simulations/center_column_study_reactor.ipynb index 2454fdc59..d5b3af0ff 100644 --- a/examples/example_neutronics_simulations/center_column_study_reactor.ipynb +++ b/examples/example_neutronics_simulations/center_column_study_reactor.ipynb @@ -67,8 +67,8 @@ " 'firstwall_mat': 'eurofer',\n", " 'blanket_mat': 'Li4SiO4'},\n", " cell_tallies=['heating'],\n", - " simulation_batches=5,\n", - " simulation_particles_per_batch=1e4,\n", + " simulation_batches=2,\n", + " simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n", " )\n", "\n", " # starts the neutronics simulation\n", diff --git a/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb b/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb index bea0ccab2..ac5a14c28 100644 --- a/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb +++ b/examples/example_neutronics_simulations/center_column_study_reactor_minimal.ipynb @@ -55,8 +55,8 @@ " 'firstwall_mat': 'eurofer',\n", " 'blanket_mat': 'Li4SiO4'},\n", " cell_tallies=['heating'],\n", - " simulation_batches=5,\n", - " simulation_particles_per_batch=1e4,\n", + " simulation_batches=2,\n", + " simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n", ")\n", "\n", "# starts the neutronics simulation\n", From 512cc29ef264b8f1b4e7970c6dfaa6228e68924f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 6 May 2021 18:53:18 +0100 Subject: [PATCH 12/21] simplified notebook and longer test allowance --- .../component_based_parameter_study.ipynb | 110 ++++++++++++++++++ .../component_based_parameter_study.py | 70 ----------- .../make_demo_style_blankets.ipynb | 13 ++- tests/notebook_testing.py | 2 +- 4 files changed, 121 insertions(+), 74 deletions(-) create mode 100644 examples/example_neutronics_simulations/component_based_parameter_study.ipynb delete mode 100644 examples/example_neutronics_simulations/component_based_parameter_study.py diff --git a/examples/example_neutronics_simulations/component_based_parameter_study.ipynb b/examples/example_neutronics_simulations/component_based_parameter_study.ipynb new file mode 100644 index 000000000..0e35c0b66 --- /dev/null +++ b/examples/example_neutronics_simulations/component_based_parameter_study.ipynb @@ -0,0 +1,110 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This example creates a curved center column with a few different sizes.\n", + "The shape is then converted into a neutronics geometry and the heat deposited\n", + "is simulated for a few different sizes of ceter column." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import openmc\n", + "import paramak\n", + "\n", + "\n", + "simulation_values = []\n", + "for mid_radius in [60, 70, 80]:\n", + "\n", + " # makes the component with a few different size mid radius values\n", + " my_shape = paramak.CenterColumnShieldHyperbola(\n", + " height=500,\n", + " inner_radius=50,\n", + " mid_radius=mid_radius,\n", + " outer_radius=100,\n", + " material_tag='center_column_shield_mat',\n", + " method='pymoab',\n", + " )\n", + "\n", + " my_shape.export_stp('my_shape' + str(mid_radius) + '.stp')\n", + "\n", + " # makes the openmc neutron source at x,y,z 0, 0, 0 with isotropic\n", + " # diections\n", + " source = openmc.Source()\n", + " source.space = openmc.stats.Point((0, 0, 0))\n", + " source.angle = openmc.stats.Isotropic()\n", + "\n", + " # converts the geometry into a neutronics geometry\n", + " my_model = paramak.NeutronicsModel(\n", + " geometry=my_shape,\n", + " source=source,\n", + " materials={\n", + " 'center_column_shield_mat': 'WB'},\n", + " # WB is tungsten boride\n", + " cell_tallies=['heating'],\n", + " simulation_batches=10, # should be increased for more accurate result\n", + " simulation_particles_per_batch=10, # settings are low to reduce time required\n", + " )\n", + "\n", + " # performs an openmc simulation on the model\n", + " my_model.simulate()\n", + "\n", + " # extracts the heat from the results dictionary\n", + " heat = my_model.results['center_column_shield_mat_heating']['Watts']['result']\n", + "\n", + " # adds the heat and the mid radius value to a list\n", + " simulation_values.append((mid_radius, heat))\n", + "\n", + "# plots the simualtion results vs the mid_radius used for the simulation\n", + "plt.plot(\n", + " [i[0] for i in simulation_values],\n", + " [i[1] for i in simulation_values],\n", + " '-p'\n", + ")\n", + "\n", + "# adds labels to the graph\n", + "plt.title(\"heating vs thickness\")\n", + "plt.xlabel(\"thickness (cm)\")\n", + "plt.ylabel(\"heating (watts)\")\n", + "\n", + "plt.savefig('heating_vs_thickness.svg')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_neutronics_simulations/component_based_parameter_study.py b/examples/example_neutronics_simulations/component_based_parameter_study.py deleted file mode 100644 index 82cdfcd1c..000000000 --- a/examples/example_neutronics_simulations/component_based_parameter_study.py +++ /dev/null @@ -1,70 +0,0 @@ -"""This example creates a curved center column with a few different sizes. -The shape is then converted into a neutronics geometry and the heat deposited -is simulated for a few different sizes of ceter column""" - -import matplotlib.pyplot as plt -import openmc -import paramak - - -def main(): - simulation_values = [] - for mid_radius in [60, 70, 80]: - - # makes the component with a few different size mid radius values - my_shape = paramak.CenterColumnShieldHyperbola( - height=500, - inner_radius=50, - mid_radius=mid_radius, - outer_radius=100, - material_tag='center_column_shield_mat', - method='pymoab', - ) - - my_shape.export_stp('my_shape' + str(mid_radius) + '.stp') - - # makes the openmc neutron source at x,y,z 0, 0, 0 with isotropic - # diections - source = openmc.Source() - source.space = openmc.stats.Point((0, 0, 0)) - 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': 'WB'}, - # WB is tungsten boride - cell_tallies=['heating'], - simulation_batches=10, # should be increased for more accurate result - simulation_particles_per_batch=10, # settings are low to reduce time required - ) - - # performs an openmc simulation on the model - my_model.simulate() - - # extracts the heat from the results dictionary - heat = my_model.results['center_column_shield_mat_heating']['Watts']['result'] - - # adds the heat and the mid radius value to a list - simulation_values.append((mid_radius, heat)) - - # plots the simualtion results vs the mid_radius used for the simulation - plt.plot( - [i[0] for i in simulation_values], - [i[1] for i in simulation_values], - '-p' - ) - - # adds labels to the graph - plt.title("heating vs thickness") - plt.xlabel("thickness (cm)") - plt.ylabel("heating (watts)") - - plt.savefig('heating_vs_thickness.svg') - plt.show() - - -if __name__ == "__main__": - main() diff --git a/examples/example_parametric_components/make_demo_style_blankets.ipynb b/examples/example_parametric_components/make_demo_style_blankets.ipynb index d2e47efa0..35c77d319 100644 --- a/examples/example_parametric_components/make_demo_style_blankets.ipynb +++ b/examples/example_parametric_components/make_demo_style_blankets.ipynb @@ -17,7 +17,7 @@ "import paramak\n", "\n", "\n", - "number_of_segments = 8\n", + "number_of_segments = 5\n", "gap_size = 15.\n", "central_block_width = 200\n", "\n", @@ -88,8 +88,15 @@ " rotation_angle=360,\n", " cut=[inboard_gaps, inboard_to_outboard_gaps],\n", " union=outboard_blanket\n", - ")\n", - "\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "inboard_blanket.show()" ] }, diff --git a/tests/notebook_testing.py b/tests/notebook_testing.py index c8f9f7139..450b13403 100644 --- a/tests/notebook_testing.py +++ b/tests/notebook_testing.py @@ -21,7 +21,7 @@ def notebook_run(path): note_book.metadata.get('kernelspec', {})['name'] = kernel_name ep = ExecutePreprocessor( kernel_name=kernel_name, - timeout=600) + timeout=800) try: ep.preprocess( From 280617032af5978b0439ab3b66409bebb11c18cc Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 6 May 2021 19:17:37 +0100 Subject: [PATCH 13/21] removed py file imports --- tests/test_example_neutronics_simulations.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test_example_neutronics_simulations.py b/tests/test_example_neutronics_simulations.py index 1adca5d6f..985d79e78 100644 --- a/tests/test_example_neutronics_simulations.py +++ b/tests/test_example_neutronics_simulations.py @@ -4,12 +4,6 @@ import unittest from pathlib import Path -from examples.example_neutronics_simulations import ( - shape_with_gas_production, - component_based_mesh_simulation, - component_based_parameter_study, - shape_with_spectra_cell_tally) - from .notebook_testing import notebook_run sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples')) From 85bf3085dcf7a3bfa05443969efe956312f8c031 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 6 May 2021 19:41:46 +0100 Subject: [PATCH 14/21] converted submersion reactor example to ipynb --- .../submersion_reactor.ipynb | 152 ++++++++++++++++++ .../submersion_reactor.py | 82 ---------- 2 files changed, 152 insertions(+), 82 deletions(-) create mode 100644 examples/example_neutronics_simulations/submersion_reactor.ipynb delete mode 100644 examples/example_neutronics_simulations/submersion_reactor.py diff --git a/examples/example_neutronics_simulations/submersion_reactor.ipynb b/examples/example_neutronics_simulations/submersion_reactor.ipynb new file mode 100644 index 000000000..09f280cb5 --- /dev/null +++ b/examples/example_neutronics_simulations/submersion_reactor.ipynb @@ -0,0 +1,152 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is a example that obtains the tritium breeding ratio (TBR)\n", + "for a parametric submersion reactor and specified the faceting and merge\n", + "tolerance when creating the dagmc model." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import neutronics_material_maker as nmm\n", + "import openmc\n", + "import paramak\n", + "\n", + "\n", + "# makes the 3d geometry from input parameters\n", + "my_reactor = paramak.SubmersionTokamak(\n", + " inner_bore_radial_thickness=30,\n", + " inboard_tf_leg_radial_thickness=30,\n", + " center_column_shield_radial_thickness=30,\n", + " divertor_radial_thickness=80,\n", + " inner_plasma_gap_radial_thickness=50,\n", + " plasma_radial_thickness=200,\n", + " outer_plasma_gap_radial_thickness=50,\n", + " firstwall_radial_thickness=30,\n", + " blanket_rear_wall_radial_thickness=30,\n", + " rotation_angle=359.9, # if method is changed to Trelis then this can be changed to 360\n", + " support_radial_thickness=50,\n", + " inboard_blanket_radial_thickness=30,\n", + " outboard_blanket_radial_thickness=30,\n", + " elongation=2.75,\n", + " triangularity=0.5,\n", + ")\n", + "\n", + "# pymoab is used as it is open source and can be tested in the CI\n", + "# if you have Trelis or Cubit then this line can be changed\n", + "my_reactor.export_h5m(method='pymoab')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section remakes the blankt material (FLiBe) for a range of temperatures and obtains the TBR for each one." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def make_model_and_simulate(temperature):\n", + " \"\"\"Makes a neutronics Reactor model and simulates the flux\n", + "\n", + " Arguments:\n", + " temperature: the temperature of the submersion blanket in Kelivin\n", + " \"\"\"\n", + "\n", + " # this can just be set as a string as temperature is needed for this\n", + " # material\n", + " flibe = nmm.Material.from_library(name='FLiBe', temperature=temperature, temperature_to_neutronics_code=False)\n", + "\n", + " source = openmc.Source()\n", + " # sets the location of the source to x=0 y=0 z=0\n", + " source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n", + " # sets the direction to isotropic\n", + " source.angle = openmc.stats.Isotropic()\n", + " # sets the energy distribution to 100% 14MeV neutrons\n", + " source.energy = openmc.stats.Discrete([14e6], [1])\n", + "\n", + " # makes the neutronics model from the geometry and material allocations\n", + " neutronics_model = paramak.NeutronicsModel(\n", + " geometry=my_reactor,\n", + " source=source,\n", + " materials={\n", + " 'inboard_tf_coils_mat': 'eurofer',\n", + " 'center_column_shield_mat': 'eurofer',\n", + " 'divertor_mat': 'eurofer',\n", + " 'firstwall_mat': 'eurofer',\n", + " 'blanket_rear_wall_mat': 'eurofer',\n", + " 'blanket_mat': flibe,\n", + " 'supports_mat': 'eurofer'},\n", + " cell_tallies=['TBR'],\n", + " simulation_batches=2,\n", + " simulation_particles_per_batch=10, # to get more accurate results this will need increasing\n", + " )\n", + "\n", + " # simulate the neutronics model\n", + " neutronics_model.simulate(export_h5m=False) # uising dagmc.h5m previous created\n", + " return neutronics_model.results['TBR']['result']\n", + "\n", + "\n", + "# loops through different temperatures finding the TBR value at each one\n", + "tbr_values = []\n", + "temperature_values = [32, 100, 300, 500]\n", + "for temperature in temperature_values:\n", + " tbr = make_model_and_simulate(temperature)\n", + " tbr_values.append(tbr)\n", + "\n", + "# plots the results\n", + "plt.scatter(temperature_values, tbr_values)\n", + "plt.xlabel('FLiBe Temperature (degrees C)')\n", + "plt.ylabel('TBR')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/example_neutronics_simulations/submersion_reactor.py b/examples/example_neutronics_simulations/submersion_reactor.py deleted file mode 100644 index 23b0f3c98..000000000 --- a/examples/example_neutronics_simulations/submersion_reactor.py +++ /dev/null @@ -1,82 +0,0 @@ -"""This is a example that obtains the tritium breeding ratio (TBR) -for a parametric submersion reactor and specified the faceting and merge -tolerance when creating the dagmc model""" - -import matplotlib.pyplot as plt -import neutronics_material_maker as nmm -import openmc -import paramak - - -def make_model_and_simulate(temperature): - """Makes a neutronics Reactor model and simulates the flux - - Arguments: - temperature: the temperature of the submersion blanket in Kelivin - """ - - # makes the 3d geometry from input parameters - 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=200, - outer_plasma_gap_radial_thickness=50, - firstwall_radial_thickness=30, - blanket_rear_wall_radial_thickness=30, - rotation_angle=180, - support_radial_thickness=50, - inboard_blanket_radial_thickness=30, - outboard_blanket_radial_thickness=30, - elongation=2.75, - triangularity=0.5, - ) - - # this can just be set as a string as temperature is needed for this - # material - flibe = nmm.Material.from_library(name='FLiBe', temperature=temperature) - - source = openmc.Source() - # sets the location of the source to x=0 y=0 z=0 - source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) - # sets the direction to isotropic - source.angle = openmc.stats.Isotropic() - # sets the energy distribution to 100% 14MeV neutrons - source.energy = openmc.stats.Discrete([14e6], [1]) - - # makes the neutronics model from the geometry and material allocations - neutronics_model = paramak.NeutronicsModel( - geometry=my_reactor, - source=source, - materials={ - 'inboard_tf_coils_mat': 'eurofer', - 'center_column_shield_mat': 'eurofer', - 'divertor_mat': 'eurofer', - 'firstwall_mat': 'eurofer', - 'blanket_rear_wall_mat': 'eurofer', - 'blanket_mat': flibe, - 'supports_mat': 'eurofer'}, - cell_tallies=['TBR'], - simulation_batches=5, - simulation_particles_per_batch=1e4, - ) - - # simulate the neutronics model - neutronics_model.simulate() - return neutronics_model.results['TBR'] - - -if __name__ == "__main__": - tbr_values = [] - temperature_values = [32, 100, 200, 300, 400, 500] - for temperature in temperature_values: - tbr = make_model_and_simulate(temperature) - tbr_values.append(tbr) - - # plots the results - plt.scatter(temperature_values, tbr_values) - plt.xlabel('FLiBe Temperature (degrees C)') - plt.ylabel('TBR') - plt.show() From 0a3f4cd7c713f43812203218aba1fdb5a4047205 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 7 May 2021 11:17:21 +0100 Subject: [PATCH 15/21] reduced complexity and commented out show() --- .../example_parametric_components/make_magnet_set.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/example_parametric_components/make_magnet_set.ipynb b/examples/example_parametric_components/make_magnet_set.ipynb index 653e77373..f106d3a8e 100644 --- a/examples/example_parametric_components/make_magnet_set.ipynb +++ b/examples/example_parametric_components/make_magnet_set.ipynb @@ -15,7 +15,7 @@ "import paramak\n", "\n", "\n", - "number_of_toroidal_field_coils = 8\n", + "number_of_toroidal_field_coils = 6\n", "angle_offset = (360 / number_of_toroidal_field_coils) / 2.\n", "tf_coil_thickness = 50\n", "tf_coil_distance = 130\n", @@ -72,7 +72,9 @@ ")\n", "\n", "my_magnets = paramak.Reactor([pf_coils, tf_coils, tf_coil_casing, inner_tf_case])\n", - "my_magnets.show()" + "\n", + "# uncomment this line to see the magnets\n", + "# my_magnets.show()" ] }, { From e29e3053856f2be279965802389e5c306eab7dc4 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 7 May 2021 17:10:31 +0100 Subject: [PATCH 16/21] adding times for slow test --- .circleci/config.yml | 2 +- .../make_animiation.ipynb | 55 +++++++++++++++---- tests/test_example_reactors.py | 14 ++++- 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index afbe73c07..9a7ed4f08 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,7 @@ jobs: - run: name: run example reactor tests command: - pytest tests/test_example_reactors.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml + pytest --capture=tee-sys tests/test_example_reactors.py -v --cov=paramak --cov-append --cov-report term --cov-report xml --junitxml=test-reports/junit.xml - store_test_results: path: test-reports diff --git a/examples/example_parametric_reactors/make_animiation.ipynb b/examples/example_parametric_reactors/make_animiation.ipynb index bfc2930a8..49d817d15 100644 --- a/examples/example_parametric_reactors/make_animiation.ipynb +++ b/examples/example_parametric_reactors/make_animiation.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,9 @@ "\n", "import numpy as np\n", "import paramak\n", - "from scipy.interpolate import interp1d\n" + "from scipy.interpolate import interp1d\n", + "\n", + "number_of_images = 5" ] }, { @@ -37,8 +39,6 @@ "source": [ "# allows the projection angle for the svg to be found via interpolation\n", "\n", - "number_of_images = 10\n", - "\n", "angle_finder = interp1d([0, number_of_images], [2.4021, 6.])\n", "\n", "my_reactor = paramak.SubmersionTokamak(\n", @@ -102,9 +102,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pf_coil_vertical_thicknesses, pf_coil_radial_thicknesses, pf_coil_radial_position, pf_coil_vertical_position not so not making pf coils\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jshim/paramak/paramak/parametric_components/blanket_fp.py:226: UserWarning: BlanketFP: Some points with negative R coordinate have been ignored.\n", + " warnings.warn(msg)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Saved file as random_0000.svg\n", + "made 1 models out of 5\n", + "pf_coil_vertical_thicknesses, pf_coil_radial_thicknesses, pf_coil_radial_position, pf_coil_vertical_position not so not making pf coils\n", + "Saved file as random_0001.svg\n", + "made 2 models out of 5\n", + "pf_coil_vertical_thicknesses, pf_coil_radial_thicknesses, pf_coil_radial_position, pf_coil_vertical_position not so not making pf coils\n", + "Saved file as random_0002.svg\n", + "made 3 models out of 5\n", + "pf_coil_vertical_thicknesses, pf_coil_radial_thicknesses, pf_coil_radial_position, pf_coil_vertical_position not so not making pf coils\n", + "Saved file as random_0003.svg\n", + "made 4 models out of 5\n", + "pf_coil_vertical_thicknesses, pf_coil_radial_thicknesses, pf_coil_radial_position, pf_coil_vertical_position not so not making pf coils\n", + "Saved file as random_0004.svg\n", + "made 5 models out of 5\n", + "animation file made as saved as randoms.gif\n" + ] + } + ], "source": [ "# makes a series of reactor models\n", "for i in range(number_of_images):\n", @@ -122,13 +159,7 @@ " blanket_rear_wall_radial_thickness=10,\n", " elongation=np.random.uniform(1.3, 1.7),\n", " triangularity=np.random.uniform(0.3, 0.55),\n", - " number_of_tf_coils=16,\n", " rotation_angle=180,\n", - " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", - " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_radial_position=[500, 550, 550, 500],\n", - " pf_coil_vertical_position=[270, 100, -100, -270],\n", " outboard_tf_coil_radial_thickness=100,\n", " outboard_tf_coil_poloidal_thickness=50,\n", " )\n", diff --git a/tests/test_example_reactors.py b/tests/test_example_reactors.py index 7c5be7297..d319b2227 100644 --- a/tests/test_example_reactors.py +++ b/tests/test_example_reactors.py @@ -3,7 +3,7 @@ import sys import unittest from pathlib import Path - +import time from .notebook_testing import notebook_run sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples')) @@ -12,11 +12,23 @@ class TestExampleReactors(unittest.TestCase): def test_jupyter_notebooks_example_parametric_reactors(self): + timings = [] for notebook in Path().rglob("examples/example_parametric_reactors/*.ipynb"): + start = time.time() + print(notebook) nb, errors = notebook_run(notebook) assert errors == [] + stop = time.time() + duration = stop-start + + print((notebook, duration)) + timings.append((notebook, duration)) + + # to see timings run with pytest --capture=tee-sys + print(timings) + if __name__ == "__main__": unittest.main() From ef83f0f0151020eec60ad63f9a47ec7f0c32b94c Mon Sep 17 00:00:00 2001 From: autopep8 Date: Fri, 7 May 2021 16:11:25 +0000 Subject: [PATCH 17/21] Automated autopep8 fixes --- tests/test_example_reactors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_example_reactors.py b/tests/test_example_reactors.py index d319b2227..ecc4c0069 100644 --- a/tests/test_example_reactors.py +++ b/tests/test_example_reactors.py @@ -21,7 +21,7 @@ def test_jupyter_notebooks_example_parametric_reactors(self): assert errors == [] stop = time.time() - duration = stop-start + duration = stop - start print((notebook, duration)) timings.append((notebook, duration)) From 7eee305ab6a65cc19104814312385111b2e59054 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Fri, 7 May 2021 17:29:28 +0100 Subject: [PATCH 18/21] simplified model --- .../segmented_blanket_ball_reactor.ipynb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb b/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb index 916cf0234..5105929b5 100644 --- a/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb +++ b/examples/example_parametric_reactors/segmented_blanket_ball_reactor.ipynb @@ -31,13 +31,14 @@ " blanket_rear_wall_radial_thickness=30,\n", " elongation=2,\n", " triangularity=0.55,\n", - " number_of_tf_coils=16,\n", - " pf_coil_case_thicknesses=[10, 10, 10, 10],\n", - " pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", - " pf_coil_radial_position=[500, 550, 550, 500],\n", - " pf_coil_vertical_position=[270, 100, -100, -270],\n", - " rear_blanket_to_tf_gap=50,\n", + " number_of_tf_coils=8,\n", + "# Optional magnets are commented out to speed up model creation\n", + "# pf_coil_case_thicknesses=[10, 10, 10, 10],\n", + "# pf_coil_radial_thicknesses=[20, 50, 50, 20],\n", + "# pf_coil_vertical_thicknesses=[20, 50, 50, 20],\n", + "# pf_coil_radial_position=[500, 550, 550, 500],\n", + "# pf_coil_vertical_position=[270, 100, -100, -270],\n", + "# rear_blanket_to_tf_gap=50,\n", " rotation_angle=180,\n", " outboard_tf_coil_radial_thickness=100,\n", " outboard_tf_coil_poloidal_thickness=50,\n", @@ -55,7 +56,7 @@ "metadata": {}, "outputs": [], "source": [ - "my_reactor.export_stp()\n", + "my_reactor.export_stp(filename='segmented_blanket_ball_reactor.stp')\n", "\n", "my_reactor.export_neutronics_description('manifest.json')\n", "\n", From d1d03d202773ca50ed2f471dfa84920f590b8c10 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 8 May 2021 18:30:51 +0100 Subject: [PATCH 19/21] added links to each notebook --- .../source/example_neutronics_simulations.rst | 73 +++++++++-------- docs/source/example_parametric_components.rst | 82 ++++++++++--------- docs/source/example_parametric_reactors.rst | 81 ++++++++---------- docs/source/example_parametric_shapes.rst | 61 ++++++-------- 4 files changed, 147 insertions(+), 150 deletions(-) diff --git a/docs/source/example_neutronics_simulations.rst b/docs/source/example_neutronics_simulations.rst index c42986033..b71c9bc6f 100644 --- a/docs/source/example_neutronics_simulations.rst +++ b/docs/source/example_neutronics_simulations.rst @@ -1,53 +1,62 @@ Examples - Neutronics Simulations ================================= -There are minimal examples of neutronics simulations that just make a single -and there are slightly more involved examples that make more complex models or -a series of models. +These are minimal examples of neutronics simulations that demonstrate the core +functionality of the neutronics features. In general it easy to export geomtry +in h5m format for use in DAGMC enabled simulations. There are two options for +this export. The Trelis method of converting geometry imprints and merges +surfaces while the PyMoab converts the geoemtry without imprinting and merging +surfaces. -OpenMC logo simulation -^^^^^^^^^^^^^^^^^^^^^^ +The resulting h5m files can be used in DAGMC enabled neutronics codes such as +OpenMC and MCNP. There is also a class (NeutronicsModel) that facilitates +adding tallies, materials and a source to the geoemtry to create a complete +OpenMC neutronics model which can be simulated. The simulated results are also +extracted from the statepoint.h5 file that OpenMC produces and converted to +vtk, png and JSON files depending on the tally. -`Link to script `_ -.. raw:: html +ball_reactor.ipynb +^^^^^^^^^^^^^^^^^^ - +`Link to notebook `_ + + +ball_reactor_minimal.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +`Link to notebook `_ -ball_reactor_minimal -^^^^^^^^^^^^^^^^^^^^ +ball_reactor_source_plot.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_neutronics_simulations.ball_reactor_minimal - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ +center_column_study_reactor.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -center_column_study_reactor_minimal -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`Link to notebook `_ -.. automodule:: examples.example_neutronics_simulations.center_column_study_reactor_minimal - :members: - :show-inheritance: -`Link to script `_ +center_column_study_reactor_minimal.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -ball_reactor -^^^^^^^^^^^^ +`Link to notebook `_ -.. automodule:: examples.example_neutronics_simulations.ball_reactor - :members: - :show-inheritance: -`Link to script `_ +OpenMC logo simulation +^^^^^^^^^^^^^^^^^^^^^^ + +`Link to notebook `_ + +.. raw:: html + + -center_column_study_reactor -^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_neutronics_simulations.center_column_study_reactor - :members: - :show-inheritance: +text_example.ipynb +^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ diff --git a/docs/source/example_parametric_components.rst b/docs/source/example_parametric_components.rst index fa7e60912..3b6de7fb9 100644 --- a/docs/source/example_parametric_components.rst +++ b/docs/source/example_parametric_components.rst @@ -1,70 +1,78 @@ Examples - Parametric Components ================================ -make_all_parametric_components.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +make_components_blankets.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. image:: https://user-images.githubusercontent.com/8583900/98823600-387eea00-242a-11eb-9fe3-df65aaa3dd21.png - :width: 713 - :align: center - -.. automodule:: examples.example_parametric_components.make_all_parametric_components - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ -make_plasmas.py -^^^^^^^^^^^^^^^ +make_components_center_column.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. image:: https://user-images.githubusercontent.com/8583900/93624384-2e1b1380-f9d8-11ea-99d1-9bf9e4e5b838.png - :width: 1050 - :height: 700 - :align: center +`Link to notebook `_ -.. automodule:: examples.example_parametric_components.make_plasmas - :members: - :show-inheritance: +make_components_magnets.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ -make_demo_style_blankets.py +make_components_other.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`Link to notebook `_ + + +make_demo_style_blankets.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. image:: https://user-images.githubusercontent.com/8583900/93619812-02e0f600-f9d1-11ea-903c-913c8bcb0f1b.png :width: 1050 :height: 350 :align: center -.. automodule:: examples.example_parametric_components.make_demo_style_blankets - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ -make_firstwall_for_neutron_wall_loading.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +make_firstwall_for_neutron_wall_loading.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/8583900/93807581-bc92cd80-fc42-11ea-8522-7fe14287b3c4.png :width: 437 :height: 807 :align: center -.. automodule:: examples.example_parametric_components.make_firstwall_for_neutron_wall_loading - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ -make_magnet_set -^^^^^^^^^^^^^^^ +make_magnet_set.ipynb +^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/8583900/99276201-5088ac00-2824-11eb-9927-a7ea1094b1e5.png :width: 500 :align: center -.. automodule:: examples.example_parametric_components.make_magnet_set - :members: - :show-inheritance: +`Link to notebook `_ + + +make_plasmas.ipynb +^^^^^^^^^^^^^^^^^^ + +.. image:: https://user-images.githubusercontent.com/8583900/93624384-2e1b1380-f9d8-11ea-99d1-9bf9e4e5b838.png + :width: 1050 + :height: 700 + :align: center + +`Link to notebook `_ + + +make_vacuum_vessel_with_ports.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +`Link to notebook `_ + + +make_varible_offset_firstwall.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ diff --git a/docs/source/example_parametric_reactors.rst b/docs/source/example_parametric_reactors.rst index 04f5e1955..6740e0bd5 100644 --- a/docs/source/example_parametric_reactors.rst +++ b/docs/source/example_parametric_reactors.rst @@ -1,72 +1,61 @@ Examples - Parametric Reactors ============================== -ball_reactor.py -^^^^^^^^^^^^^^^ +ball_reactor.ipynb +^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_parametric_reactors.ball_reactor - :members: - :show-inheritance: +`Link to script `_ -`Link to script `_ -ball_reactor_single_null.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +ball_reactor_single_null.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_parametric_reactors.ball_reactor_single_null - :members: - :show-inheritance: +`Link to script `_ -`Link to script `_ -segmented_blanket_ball_reactor.py +center_column_study_reactor.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_parametric_reactors.segmented_blanket_ball_reactor - :members: - :show-inheritance: +`Link to script `_ -`Link to script `_ +eu_demo_from_2015_paper.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -submersion_reactor.py -^^^^^^^^^^^^^^^^^^^^^ +`Link to script `_ -.. automodule:: examples.example_parametric_reactors.submersion_reactor - :members: - :show-inheritance: -`Link to script `_ +make_animation.ipynb +^^^^^^^^^^^^^^^^^^^^ -submersion_reactor_single_null.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. automodule:: examples.example_parametric_reactors.submersion_reactor_single_null - :members: - :show-inheritance: +|animation1| |animation2| -`Link to script `_ +.. |animation1| image:: https://user-images.githubusercontent.com/8583900/107040396-155ca000-67b7-11eb-8b99-4aa9bf8a8655.gif + :width: 300 +.. |animation2| image:: https://user-images.githubusercontent.com/8583900/107030664-e2131480-67a8-11eb-84bb-59656e9e7722.gif + :width: 300 -center_column_study_reactor.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`Link to script `_ -.. automodule:: examples.example_parametric_reactors.center_column_study_reactor - :members: - :show-inheritance: -`Link to script `_ +segmented_blanket_ball_reactor.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -make_animation.py -^^^^^^^^^^^^^^^^^ +`Link to script `_ -.. automodule:: examples.example_parametric_reactors.make_animation - :members: - :show-inheritance: +sparc_from_2020_paper.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^ -|animation1| |animation2| +`Link to script `_ -.. |animation1| image:: https://user-images.githubusercontent.com/8583900/107040396-155ca000-67b7-11eb-8b99-4aa9bf8a8655.gif - :width: 300 -.. |animation2| image:: https://user-images.githubusercontent.com/8583900/107030664-e2131480-67a8-11eb-84bb-59656e9e7722.gif - :width: 300 -`Link to script `_ +submersion_reactor.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^ + +`Link to script `_ + + +submersion_reactor_single_null.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +`Link to script `_ diff --git a/docs/source/example_parametric_shapes.rst b/docs/source/example_parametric_shapes.rst index 6d1f40efd..632db691c 100644 --- a/docs/source/example_parametric_shapes.rst +++ b/docs/source/example_parametric_shapes.rst @@ -1,75 +1,66 @@ Examples - Parametric Shapes ============================ -make_CAD_from_points.py -^^^^^^^^^^^^^^^^^^^^^^^ +make_CAD_from_points.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/56687624/88064585-641c5280-cb63-11ea-97b1-1b7dcfabc07c.gif :width: 450 :height: 275 :align: center -.. automodule:: examples.example_parametric_shapes.make_CAD_from_points - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ +make_blanket_from_parameters.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -make_blanket_from_points.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. image:: https://user-images.githubusercontent.com/56687624/87058930-998a7d00-c200-11ea-846e-4084dbf82748.png +.. image:: https://user-images.githubusercontent.com/56687624/87058944-9e4f3100-c200-11ea-8bd3-669b3705c179.png :width: 400 :height: 400 :align: center -.. automodule:: examples.example_parametric_shapes.make_blanket_from_points - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ +make_blanket_from_points.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -make_blanket_from_parameters.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. image:: https://user-images.githubusercontent.com/56687624/87058944-9e4f3100-c200-11ea-8bd3-669b3705c179.png +.. image:: https://user-images.githubusercontent.com/56687624/87058930-998a7d00-c200-11ea-846e-4084dbf82748.png :width: 400 :height: 400 :align: center -.. automodule:: examples.example_parametric_shapes.make_blanket_from_parameters - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ -make_can_reactor_from_points.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +make_can_reactor_from_parameters.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/56687624/87060447-74970980-c202-11ea-8720-403c24dbabcc.gif :width: 1300 :height: 450 :align: center -.. automodule:: examples.example_parametric_shapes.make_can_reactor_from_points - :members: - :show-inheritance: +`Link to notebook `_ -`Link to script `_ - -make_can_reactor_from_parameters.py -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +make_can_reactor_from_points.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. image:: https://user-images.githubusercontent.com/56687624/87060447-74970980-c202-11ea-8720-403c24dbabcc.gif :width: 1300 :height: 450 :align: center -.. automodule:: examples.example_parametric_shapes.make_can_reactor_from_parameters - :members: - :show-inheritance: +`Link to notebook `_ + + +make_html_diagram_from_stp_file.ipynb +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. image:: https://user-images.githubusercontent.com/8583900/117488160-fb705c00-af63-11eb-882e-27e284ceb79f.png + :align: center + +`Link to notebook `_ -`Link to script `_ From 96b8a056f88c03165257d466e0af78608b09b266 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 8 May 2021 18:34:31 +0100 Subject: [PATCH 20/21] cleared outputs --- .../make_html_diagram_from_stp_file.ipynb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/example_parametric_shapes/make_html_diagram_from_stp_file.ipynb b/examples/example_parametric_shapes/make_html_diagram_from_stp_file.ipynb index f81656443..0507497dc 100644 --- a/examples/example_parametric_shapes/make_html_diagram_from_stp_file.ipynb +++ b/examples/example_parametric_shapes/make_html_diagram_from_stp_file.ipynb @@ -86,6 +86,13 @@ " filename=\"example_shape_from_stp_XYZ.html\",\n", ")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From d36ba50b028972029295e7314bbdfeb5c04209ad Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Sat, 8 May 2021 20:17:14 +0100 Subject: [PATCH 21/21] changed script to notebook in link title --- docs/source/example_parametric_reactors.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/source/example_parametric_reactors.rst b/docs/source/example_parametric_reactors.rst index 6740e0bd5..7d4fceccf 100644 --- a/docs/source/example_parametric_reactors.rst +++ b/docs/source/example_parametric_reactors.rst @@ -4,24 +4,24 @@ Examples - Parametric Reactors ball_reactor.ipynb ^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ ball_reactor_single_null.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ center_column_study_reactor.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ eu_demo_from_2015_paper.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ make_animation.ipynb @@ -35,27 +35,27 @@ make_animation.ipynb .. |animation2| image:: https://user-images.githubusercontent.com/8583900/107030664-e2131480-67a8-11eb-84bb-59656e9e7722.gif :width: 300 -`Link to script `_ +`Link to notebook `_ segmented_blanket_ball_reactor.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ sparc_from_2020_paper.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ submersion_reactor.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_ submersion_reactor_single_null.ipynb ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`Link to script `_ +`Link to notebook `_