Skip to content

Commit

Permalink
Merge pull request #210 from fusion-energy/neg_tri_tidy_up
Browse files Browse the repository at this point in the history
Neg tri tidy up
  • Loading branch information
shimwell authored Mar 14, 2022
2 parents 29301a4 + d02bb7f commit b778c83
Show file tree
Hide file tree
Showing 35 changed files with 112 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install black
- name: Lint code
run: |
python -m pip install --upgrade pip
pip install flake8
flake8 . --show-source --statistics --max-line-length 120
- name: Install black
run: |
pip install black==22.1.0
- name: Run black
run: |
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

repos:
- repo: https://github.com/psf/black
rev: 22.1.0
Expand Down
12 changes: 6 additions & 6 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Install (conda)

This is the recommended method.

Create a new environment (Python 3.6, 3.7 or 3.8 are supported).
Create a new environment (Python 3.8 and 3.9 are supported).

.. code-block:: bash
Expand All @@ -56,7 +56,7 @@ Now you should be ready to import paramak from your new python environment.
Install (conda + pip)
---------------------

Create a new environment (Python 3.6, 3.7 or 3.8 are supported).
Create a new environment (Python 3.8 and 3.9 are supported).

.. code-block:: bash
Expand Down Expand Up @@ -84,9 +84,9 @@ needed then this stage can be skipped.

.. code-block:: bash
conda install -c conda-forge moab=5.3.1
conda install -c conda-forge gmsh=4.9.4
conda install -c conda-forge python-gmsh=4.9.4
conda install -c conda-forge 'moab>=5.3.0'
Then pip install the Paramak.

Expand Down Expand Up @@ -130,7 +130,7 @@ which includes other packages that might be of interest.

* `OpenMC <https://github.com/openmc-dev/openmc>`_ The OpenMC project, a Monte Carlo particle transport code based on modern methods.

* `DAGMC <https://github.com/svalinn/DAGMC>`_ Direct Accelerated Geometry Monte Carlo Toolkit
* `DAGMC <https://github.com/svalinn/DAGMC>`_ Direct Accelerated Geometry Monte Carlo Toolkit

* `Svalinn Cubit Plugin <https://github.com/svalinn/Cubit-plugin/>`_ A plugin and command extensions for Cubit that allows h5m files to be exported.

Expand All @@ -142,7 +142,7 @@ which includes other packages that might be of interest.
Developer Installation
----------------------

If you want to contribute to the paramak or then you might want to install the
If you want to contribute to the paramak or then you might want to install the
package using setup tools.

Download and install MiniConda, create a new python environment and activate the
Expand All @@ -152,7 +152,7 @@ Then install CadQuery.

.. code-block:: bash
conda install -c conda-forge -c cadquery cadquery=2.1
conda install -c conda-forge -c cadquery cadquery=master
Then clone the repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def create_reactor_renders(

# renders the scene
my_render = pyrender.OffscreenRenderer(1000, 1000)
color, depth = my_render.render(scene)
color, _ = my_render.render(scene)

# adds the render to the plot as a subplot in the correct location
plt.plot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def generate_random_reactor():
]:
try:
input_variables.remove(input_var)
except:
except ValueError:
pass

print(my_reactor.__dict__, "\n\n")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple
from typing import Tuple

from paramak import RotateMixedShape

Expand Down
7 changes: 2 additions & 5 deletions paramak/parametric_components/blanket_fp.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import warnings
from typing import Callable, List, Optional, Union
from typing import Optional, Union

import mpmath
import numpy as np
import sympy as sp
from scipy.interpolate import interp1d

import paramak
from paramak import RotateMixedShape, diff_between_angles
from paramak.parametric_components.tokamak_plasma_plasmaboundaries import (
PlasmaBoundaries,
)
from paramak import RotateMixedShape


class BlanketFP(RotateMixedShape):
Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/center_column_circular.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Union, Tuple
from typing import Optional, Tuple

from paramak import RotateMixedShape

Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/extrude_rectangle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple
from typing import Tuple

from paramak import ExtrudeStraightShape

Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/inboard_firstwall_fccs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterable
from typing import List, Optional, Tuple
from typing import Optional, Tuple

import paramak
from paramak import (
Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/poloidal_field_coil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Tuple
from typing import Tuple

from paramak import RotateStraightShape

Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/port_cutters_rotated.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math

from paramak import RotateStraightShape
from paramak.utils import coefficients_of_line_from_points, rotate
from paramak.utils import rotate


class PortCutterRotated(RotateStraightShape):
Expand Down
2 changes: 1 addition & 1 deletion paramak/parametric_components/shell_fs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cadquery as cq

from paramak import CuttingWedgeFS, Shape
from paramak import Shape


class ShellFS(Shape):
Expand Down
1 change: 0 additions & 1 deletion paramak/parametric_components/tf_coil_casing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warnings
from typing import Optional

from paramak import ExtrudeMixedShape, ExtrudeStraightShape
from paramak.utils import add_thickness, cut_solid, union_solid
Expand Down
2 changes: 0 additions & 2 deletions paramak/parametric_components/toroidal_field_coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy as np

from paramak import ExtrudeMixedShape, ExtrudeStraightShape
from paramak.utils import add_thickness
import cadquery as cq


class ToroidalFieldCoil(ExtrudeMixedShape):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import math
from typing import Optional, Tuple

import cadquery as cq
import numpy as np

from .toroidal_field_coil import ToroidalFieldCoil
from paramak.utils import calculate_wedge_cut, rotate, patch_workplane
from paramak.utils import rotate, patch_workplane

patch_workplane()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import Optional, Tuple

import cadquery as cq
import numpy as np

from .toroidal_field_coil import ToroidalFieldCoil
from paramak.utils import calculate_wedge_cut, patch_workplane
from paramak.utils import patch_workplane

patch_workplane()

Expand Down
2 changes: 0 additions & 2 deletions paramak/parametric_components/vacuum_vessel_inner_leg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import cadquery as cq

from paramak import RotateStraightShape
Expand Down
48 changes: 20 additions & 28 deletions paramak/parametric_reactors/negative_triangularity_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ class NegativeTriangularityReactor(paramak.Reactor):
port_z_pos: List containing the Z position of the ports as Zero in the
centre of the reactor (cm),
outer_tf_coil_thickness: Outer Toroidal Field coil thickness (cm) -
defaults to the inner Toroidal Field coil thickness,
show_plasma: Boolean to include (True) or exlcude (False) plasma from
the model,
defaults to the inner Toroidal Field coil thickness,,
low_aspect: Boolean allowing a swift switch between a lower
aspect-ratio reactor (True) where the inner blanket is cut by the
center column, whereas (False) non-low-aspect will produce a full
Expand All @@ -69,24 +67,23 @@ def __init__(
divertor_height_full: float = 300,
number_of_coils: int = 12,
tf_width: float = 75,
pf_coil_heights: Optional[Union[float, list]] = [75, 75, 150, 75, 75],
pf_coil_widths: Optional[Union[float, list]] = [70, 70, 150, 70, 70],
pf_coil_heights: Optional[Union[float, List[float]]] = [75, 75, 150, 75, 75],
pf_coil_widths: Optional[Union[float, List[float]]] = [70, 70, 150, 70, 70],
pf_coil_center_points: Optional[Union[list, tuple]] = [
(350, 850),
(1350, 650),
(1350, 0),
(1350, -650),
(350, -850),
],
pf_coil_casing_thickness: Optional[float] = [15, 15, 15, 15, 15],
pf_coil_casing_thickness: Optional[List[float]] = [15, 15, 15, 15, 15],
rotation_angle: float = 180,
inner_bore_radius: Optional[float] = 50,
port_side_lengths: Optional[list] = [200, 200, 150],
port_heights: Optional[list] = [200, 100, 400],
port_angles: Optional[list] = [75, 170, 15],
port_z_pos: Optional[list] = [500, -500, 200],
outer_tf_coil_thickness: float = None,
show_plasma: bool = True,
inner_bore_radius: float = 50,
port_side_lengths: Optional[List[float]] = [200, 200, 150],
port_heights: Optional[List[float]] = [200, 100, 400],
port_angles: Optional[List[float]] = [75, 170, 15],
port_z_pos: Optional[List[float]] = [500, -500, 200],
outer_tf_coil_thickness: Optional[float] = None,
low_aspect: bool = False,
):

Expand Down Expand Up @@ -116,7 +113,6 @@ def __init__(
self._pf_casing_thickness = pf_coil_casing_thickness

self._rotation_angle = rotation_angle
self.show_plasma = show_plasma
self._low_aspect = low_aspect
self._number_of_coils = number_of_coils
self._tf_width = tf_width
Expand Down Expand Up @@ -151,7 +147,6 @@ def __init__(
"port_angles",
"port_z_pos",
"outer_tf_coil_thickness",
"show_plasma",
"low_aspect",
]

Expand Down Expand Up @@ -232,9 +227,9 @@ def __init__(
self._tf_end_rad = 0

def _plasma_geometry(self):
"""Calculating plasma geometry from parameters
Adjust a gap between inner TF leg and vacuum vessel to accomodate a
wider range of thicknesses"""
"""Calculating plasma geometry from parameters. Adjust a gap between
inner TF leg and vacuum vessel to accommodate a wider range of
thicknesses"""
core_width = (
self._inner_bore_radius
+ self._inner_tf_coil_thickness
Expand Down Expand Up @@ -568,10 +563,7 @@ def create_solid(self):
self._make_vertical_build()
self._make_radial_build()

if self.show_plasma:
shapes_and_components.append(self._make_plasma())
else:
print("Plasma is excluded from the model.")
shapes_and_components.append(self._make_plasma())

if self._ports_enable:
self._make_ports()
Expand Down Expand Up @@ -600,7 +592,7 @@ def _make_plasma(self):
return self._plasma

def _make_vertical_build(self):
### Above the plasma ###
# Above the plasma
# Inner wall
self._inner_wall_start_height = (
self._plasma.high_point[1] + self._wall_to_plasma_gap
Expand All @@ -624,7 +616,7 @@ def _make_vertical_build(self):
self._divertor_start_height + self._divertor_height_full
)

### Diverter height check ###
# Diverter height check
min_div_h = self._rear_wall_end_height_top - self._divertor_start_height
if min_div_h > self._divertor_height_full:
print(
Expand Down Expand Up @@ -678,7 +670,7 @@ def _make_radial_build(self):
+ self._inner_wall_thickness
)

### Run check for diverter parameters ###
# Run check for diverter parameters
full_outer_blanket_rad = (
self._major_radius
+ self._minor_radius
Expand All @@ -698,7 +690,7 @@ def _make_radial_build(self):
)
self._divertor_radial_thickness = width_parameter_difference

### Divertor parts ###
# Divertor parts
self._divertor_start_rad = self._plasma.high_point[0]
self._divertor_end_rad = (
self._divertor_start_rad + self._divertor_radial_thickness
Expand Down Expand Up @@ -833,7 +825,7 @@ def _make_inner_shield(self):

def _make_blankets(self):

### Cutters ###
# Cutters

self._divertor_cutter_cutter = paramak.CenterColumnShieldCylinder(
height=self._divertor_start_height * 2,
Expand All @@ -854,7 +846,7 @@ def _make_blankets(self):
outer_radius=self._inner_shield_end_rad,
)

### Blanket layers ###
# Blanket layers

self._rear_wall = paramak.BlanketFP(
thickness=self._rear_wall_thickness,
Expand Down
3 changes: 0 additions & 3 deletions paramak/shape.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import json
import numbers
import os
import tempfile
import warnings
from collections.abc import Iterable
from pathlib import Path
from typing import List, Optional, Tuple, Union

import cadquery as cq
import matplotlib.pyplot as plt
from cadquery import Assembly, Color, Compound, Plane, Workplane, exporters, importers
from cadquery.occ_impl import shapes
Expand Down
12 changes: 7 additions & 5 deletions tests/test_parametric_components/test_capsule_vacuum_vessel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import paramak

"""This test evaluates the perimeter of the resultant points and asserts them agaist the known value"""
"""This test evaluates the perimeter of the resultant points and asserts them against the known value"""


def perimeter(outer_start_point, radius, thickness):
Expand All @@ -13,16 +13,16 @@ def perimeter(outer_start_point, radius, thickness):
outer_start_point=outer_start_point, radius=radius, thickness=thickness
)
point1 = test_shape.points[0]
point2 = test_shape.points[1]
# point2 = test_shape.points[1]
point3 = test_shape.points[2]
point4 = test_shape.points[3]
point5 = test_shape.points[4]
# point5 = test_shape.points[4]
point6 = test_shape.points[5]
point7 = test_shape.points[6]
point8 = test_shape.points[7]
# point8 = test_shape.points[7]
point9 = test_shape.points[8]
point10 = test_shape.points[9]
point11 = test_shape.points[10]
# point11 = test_shape.points[10]
point12 = test_shape.points[11]

straightedges = float(
Expand All @@ -34,6 +34,8 @@ def perimeter(outer_start_point, radius, thickness):
curvededges = float((math.pi * radius) + (math.pi * (radius - thickness)))
total = float(straightedges + curvededges)

# TODO add an assert statement to test something here

return total


Expand Down
Loading

0 comments on commit b778c83

Please sign in to comment.