Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"PROJ_DIR = Path.cwd().parent\n",
"\n",
"\n",
"def copy_to_temp_dir(input_rel):\n",
"def copy_to_temp_dir(input_rel, config=None):\n",
" \"\"\"Copy an input file to a new temp dir and return its new path.\n",
"\n",
" The new TemporaryDirectory object is returned to avoid destruction of the\n",
Expand Down Expand Up @@ -61,6 +61,19 @@
" copy(input_abs_path, temp_dir_path)\n",
" temp_input_path = temp_dir_path / input_abs_path.name\n",
"\n",
" if config is not None:\n",
" config_rel_path = Path(config)\n",
" config_abs_path = PROJ_DIR / config_rel_path\n",
" try:\n",
" assert config_abs_path.exists()\n",
" except AssertionError as err:\n",
" raise FileNotFoundError(\"Config file doesn't exist.\") from err\n",
"\n",
" copy(config_abs_path, temp_dir_path)\n",
" temp_config_path = temp_dir_path / config_abs_path.name\n",
"\n",
" return temp_dir, temp_input_path, temp_config_path\n",
"\n",
" return temp_dir, temp_input_path"
]
},
Expand All @@ -86,10 +99,19 @@
"\n",
"# Define input file name relative to project dir, then copy to temp dir\n",
"script_dir = Path(\"__file__\").parent.resolve()\n",
"# standard run of conventional tokamak from data files\n",
"input_rel = script_dir / \"data/large_tokamak_IN.DAT\"\n",
"\n",
"temp_dir, temp_input_path = copy_to_temp_dir(input_rel)\n",
"\n",
"# # alternative run of ST from regression files\n",
"# input_rel = script_dir / \"../tests/regression/input_files/st_regression.IN.DAT\"\n",
"# temp_dir, temp_input_path = copy_to_temp_dir(input_rel)\n",
"\n",
"# # alternative run of stellarator from regression files with associated config\n",
"# input_rel = script_dir / \"../tests/regression/input_files/stellarator_helias_eval.IN.DAT\"\n",
"# config = script_dir / \"../tests/regression/input_files/stellarator_helias_eval.stella_conf.json\"\n",
"# temp_dir, temp_input_path, temp_config = copy_to_temp_dir(input_rel, config)\n",
"\n",
"# Run process on an input file in a temporary directory\n",
"single_run = SingleRun(str(temp_input_path))\n",
"single_run.run()"
Expand Down Expand Up @@ -253,7 +275,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "env",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -270,5 +292,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
10 changes: 8 additions & 2 deletions process/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ def calculate_vertical_build(self, output: bool) -> None:
self.outfile,
"\n*Cryostat roof allowance includes uppermost PF coil and outer thermal shield.\n*Cryostat floor allowance includes lowermost PF coil, outer thermal shield and gravity support.",
)

# Output the cdivertor geometry
divht = self.divgeom(output)
# Issue #481 Remove build_variables.vgaptf
Expand Down Expand Up @@ -864,6 +863,14 @@ def divgeom(self, output: bool):
TART option: Peng SOFT paper
"""
if physics_variables.itart == 1:
if output:
po.ovarrf(
self.outfile,
"TF coil vertical offset (m)",
"(dz_tf_plasma_centre_offset)",
build_variables.dz_tf_plasma_centre_offset,
"OP ",
)
return 1.75e0 * physics_variables.rminor
# Conventional tokamak divertor model
# options for seperate upper and lower physics_variables.triangularity
Expand Down Expand Up @@ -985,7 +992,6 @@ def divgeom(self, output: bool):
)

divht = max(zplti, zplto) - min(zplbo, zplbi)

if output:
if physics_variables.n_divertors == 1:
po.oheadr(self.outfile, "Divertor build and plasma position")
Expand Down
31 changes: 19 additions & 12 deletions process/geometry/pfcoil_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def pfcoil_geometry(
coils_z: list[float],
coils_dr: list[float],
coils_dz: list[float],
dr_bore: float,
dr_cs: float,
ohdz: float,
) -> tuple[np.ndarray, np.ndarray, RectangleGeometry]:
"""Calculates radial and vertical distances for the geometry of the pf coils and central coil

Expand All @@ -26,12 +23,6 @@ def pfcoil_geometry(
:type coils_dr: List[float]
:param coils_dz: list of pf coil vertical thicknesses
:type coils_dz: List[float]
:param dr_bore: central solenoid inboard radius
:type dr_bore: float
:param dr_cs: central solenoid thickness
:type dr_cs: float
:param ohdz: central solenoid vertical thickness
:type ohdz: float
:return: tuple containing radial and vertical coordinates for pf coils, and dataclass returning coordinates representing a rectangular geometry used to plot the central coil
:rtype: Tuple[np.ndarray, np.ndarray, RectangleGeometry]
"""
Expand All @@ -44,9 +35,25 @@ def pfcoil_geometry(
r_2 = float(coils_r[i]) + 0.5 * float(coils_dr[i])
r_points.append([r_1, r_1, r_2, r_2, r_1])
z_points.append([z_1, z_2, z_2, z_1, z_1])
return r_points, z_points


def cs_geometry(
dr_bore: float,
dr_cs: float,
ohdz: float,
) -> RectangleGeometry:
"""Calculates radial and vertical distances for the geometry of the central coil

central_coil = RectangleGeometry(
:param dr_bore: central solenoid inboard radius
:type dr_bore: float
:param dr_cs: central solenoid thickness
:type dr_cs: float
:param ohdz: central solenoid vertical thickness
:type ohdz: float
:return: Dataclass returning coordinates representing a rectangular geometry used to plot the central coil
:rtype: RectangleGeometry
"""
return RectangleGeometry(
anchor_x=dr_bore, anchor_z=(-ohdz / 2), width=dr_cs, height=ohdz
)

return r_points, z_points, central_coil
Loading
Loading