Skip to content
Open
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
81 changes: 67 additions & 14 deletions process/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from enum import IntEnum, unique

import numpy as np
from tabulate import tabulate

from process.core import constants
from process.core import process_output as po
Expand Down Expand Up @@ -200,7 +201,8 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
),
)
)
vbuild = self.write_obuild(

vbuild, vbuild_top_table = self.create_vbuild_table(
vbuild=vbuild,
entry=[
(
Expand Down Expand Up @@ -268,7 +270,11 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
"(dz_vv_upper)",
bld.dz_vv_upper,
),
("Top radiation shield thickness (m)", "(dz_shld_upper)", bld.dz_shld_upper),
(
"Top radiation shield thickness (m)",
"(dz_shld_upper)",
bld.dz_shld_upper,
),
*top,
(
"Top scrape-off vertical thickness (m)",
Expand All @@ -289,9 +295,10 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
]:
po.ovarre(self.mfile, desc, name, val)

po.obuild(self.outfile, "Midplane", 0.0e0, vbuild)
vbuild_table = [*vbuild_top_table]
vbuild_table.append(("Midplane", 0.0, vbuild, ""))

vbuild = self.write_obuild(
vbuild, vbuild_bottom_table = self.create_vbuild_table(
vbuild=vbuild,
entry=[
(
Expand All @@ -318,6 +325,7 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
],
before=True,
)
vbuild_table.extend(vbuild_bottom_table)
for desc, name, val in [
(
"Plasma lower X-point height (m)",
Expand Down Expand Up @@ -347,6 +355,20 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
]:
po.ovarre(self.mfile, desc, name, val)

po.write(
self.outfile,
tabulate(
vbuild_table,
headers=[
"Description",
"Component height",
"Cumulative height",
"Variable name",
],
floatfmt=".3e",
),
)

# Total height of TF coil
tf_height = tf_top - vbuild + self.data.buildings.dz_tf_cryostat
# Inner vertical dimension of TF coil
Expand All @@ -355,8 +377,9 @@ def _vertical_build_out(self, i_single_null: DivertorNumberModels):
# To calculate vertical offset between TF coil centre and plasma centre
bld.dz_tf_plasma_centre_offset = (vbuile1 + vbuild) / 2.0e0

def write_obuild(
self, vbuild: float, entry: list[tuple[str, float, str]], *, before=False
@staticmethod
def create_vbuild_table(
vbuild: float, entry: list[tuple[str, float, str]], *, before=False
):
"""Write obuild entry

Expand All @@ -371,14 +394,14 @@ def write_obuild(
or after recording the vertical build value.
Top half of the machine set to False, lower half set to True
"""
table = []
for desc, var, name in entry:
if before:
vbuild -= var
po.obuild(self.outfile, desc, var, vbuild, name)
table.append((desc, var, vbuild, name))
if not before:
vbuild -= var

return vbuild
return vbuild, table

def calculate_vertical_build(self, output: bool):
"""Determines the vertical build of the machine.
Expand Down Expand Up @@ -767,7 +790,11 @@ def divertor_geom_output(
("Upper inner plate top, vertical (m)", "(-zplti)", -zplti),
("Upper inner plate bottom, radial (m)", "(rplbi)", rplbi),
("Upper inner plate bottom, vertical (m)", "(-zplbi)", -zplbi),
("Upper outer strike point, radial (m)", "(rspo)", self.data.build.rspo),
(
"Upper outer strike point, radial (m)",
"(rspo)",
self.data.build.rspo,
),
("Upper outer strike point, vertical (m)", "(-zspo)", -zspo),
("Upper outer plate top, radial (m)", "(rplto)", rplto),
("Upper outer plate top, vertical (m)", "(-zplto)", -zplto),
Expand All @@ -779,7 +806,11 @@ def divertor_geom_output(
("Lower inner plate top, vertical (m)", "(zplti)", zplti),
("Lower inner plate bottom, radial (m)", "(rplbi)", rplbi),
("Lower inner plate bottom, vertical (m)", "(zplbi)", zplbi),
("Lower outer strike point, radial (m)", "(rspo)", self.data.build.rspo),
(
"Lower outer strike point, radial (m)",
"(rspo)",
self.data.build.rspo,
),
("Lower outer strike point, vertical (m)", "(zspo)", zspo),
("Lower outer plate top, radial (m)", "(rplto)", rplto),
("Lower outer plate top, vertical (m)", "(zplto)", zplto),
Expand Down Expand Up @@ -1394,7 +1425,11 @@ def radial_build_output(self):
))

radial_build_data.extend((
["TF coil inboard leg insulation gap", "dr_tf_shld_gap", bld.dr_tf_shld_gap],
[
"TF coil inboard leg insulation gap",
"dr_tf_shld_gap",
bld.dr_tf_shld_gap,
],
[
"Thermal shield, inboard",
"dr_shld_thermal_inboard",
Expand Down Expand Up @@ -1427,7 +1462,11 @@ def radial_build_output(self):
["Gap", "dr_shld_blkt_gap", bld.dr_shld_blkt_gap],
["Outer radiation shield", "dr_shld_outboard", bld.dr_shld_outboard],
["Outboard vacuum vessel", "dr_vv_outboard", bld.dr_vv_outboard],
["Vessel to TF gap", "dr_shld_vv_gap_outboard", bld.dr_shld_vv_gap_outboard],
[
"Vessel to TF gap",
"dr_shld_vv_gap_outboard",
bld.dr_shld_vv_gap_outboard,
],
[
"Outboard thermal shield",
"dr_shld_thermal_outboard",
Expand All @@ -1441,14 +1480,15 @@ def radial_build_output(self):
# of a `None` variable component
index = 0
radius = 0.0e0
radial_build_table = []
for description, variable, thickness in radial_build_data:
if variable is None:
continue
index += 1
radius += thickness

var = f"({variable})" if variable else ""
po.obuild(self.outfile, description, thickness, radius, var)
radial_build_table.append((description, thickness, radius, var))

for d, n, v in [
(f"{description} radial thickness (m)", f"({variable})", thickness),
Expand All @@ -1465,6 +1505,19 @@ def radial_build_output(self):
]:
po.ovarre(self.mfile, d, n, v)

po.write(
self.outfile,
tabulate(
radial_build_table,
[
"Description",
"Component thickness",
"Cumulative thickness",
"Variable name",
],
floatfmt=".3e",
),
)
if (
CurrentDriveModel(
self.data.current_drive.i_hcd_primary
Expand Down
Loading