Skip to content
Closed
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
22 changes: 11 additions & 11 deletions process/sctfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def supercon_croco(self, aturn, bmax, iop, thelium, output: bool):
po.ovarre(self.outfile, "Critical current (A)", "(icrit)", icrit, "OP ")
po.ovarre(
self.outfile,
"Actual current (A)",
"TF coil leg current per turn (A)",
"(cpttf)",
tfcoil_variables.cpttf,
"OP ",
Expand Down Expand Up @@ -3932,7 +3932,7 @@ def stresscl(

# WP effective insulation thickness (SC only) [m]
# include groundwall insulation + insertion gap in tfcoil_variables.thicndut
# inertion gap is tfcoil_variables.tfinsgap on 4 sides
# insertion gap is tfcoil_variables.tfinsgap on 4 sides
t_ins_eff = thicndut + (tfinsgap + tinstf) / n_tf_turn

# Effective WP young modulus in the toroidal direction [Pa]
Expand Down Expand Up @@ -4793,16 +4793,22 @@ def outtf(self, peaktfflag):
po.osubhd(self.outfile, "TF winding pack (WP) geometry:")
po.ovarre(
self.outfile,
"WP cross section area with insulation and insertion (per coil) (m2)",
"WP cross section area with insulation and insertion gap (m2)",
"(awpc)",
sctfcoil_module.awpc,
)
po.ovarre(
self.outfile,
"WP cross section area (per coil) (m2)",
"(aswp)",
"WP cross section area without insulation and insertion gap (m2)",
"(awptf)",
sctfcoil_module.awptf,
)
po.ovarre(
self.outfile,
"WP structure area (m2)",
"(aswp)",
tfcoil_variables.aswp,
)
po.ovarre(
self.outfile,
"Winding pack radial thickness (m)",
Expand Down Expand Up @@ -4861,12 +4867,6 @@ def outtf(self, peaktfflag):
"(aswp/awpc)",
tfcoil_variables.aswp / sctfcoil_module.awpc,
)
po.ovarre(
self.outfile,
"Insulation WP fraction",
"(aiwp/awpc)",
tfcoil_variables.aiwp / sctfcoil_module.awpc,
)
po.ovarre(
self.outfile,
"Cable WP fraction",
Expand Down
107 changes: 107 additions & 0 deletions process/uncertainties/hdf_to_scatter_plot1.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be included in this pull request.

Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"""
script for reading and display HDF5 files as pdf scatter plots

Alexander J Pearce
05/03/22
CCFE

"""

import argparse
import pandas as pd
import matplotlib.pyplot as plt
from pylab import figure, savefig


def parse_args(args):
"""Parse supplied arguments.

:param args: arguments to parse
:type args: list, None
:return: parsed arguments
:rtype: Namespace
"""
parser = argparse.ArgumentParser(
description="Program to read and " "plot PROCESS hdf5 output."
)

parser.add_argument(
"-i",
"--inputfile",
default="uncertainties_data.h5",
help="input hdf5 file (default=uncertainties_data.h5)",
)

parser.add_argument(
"-v",
"--vars",
default="None",
nargs="*",
help="Select the output variables (default = None) \n More than one output can be plotted eg: -v 'var1 var2'\n A separate plot will be created in matrix for each inputs combination",
)

parser.add_argument(
"-sf",
"--save_format",
nargs="?",
default="pdf",
help="Output format (default='pdf') ",
)

parser.add_argument(
"-p",
"--print",
action="store_true",
help="(print the PROCESS data to comannd line. default=False) ",
)

return parser.parse_args(args)


def main(args=None):
"""reads inputfile and creats figure as outputfile

:param args: None
:return: None
"""
args = parse_args(args)

data_set = pd.read_hdf(args.inputfile)
if args.print:
print(data_set)

output_names = args.vars

# Select only the converged runs for creating KDF plots
# see if we can only use if ifail = 1 for the KDF

# TO DO make separate list of converged and failed runs
# find way to display both to look at margins
# we want to colour red for ifail = 2-6 and blue for ifail = 1
ioptimz = data_set["ioptimz"][0]
if ioptimz == -2:
data_set_converge = data_set
else:
data_set_converge = data_set[data_set["ifail"] == 1.0]

figsize = (8, 8)
figure(figsize=figsize)
# kde or hist (hs) in the diagonal below
Axes = pd.plotting.scatter_matrix(
data_set_converge[output_names], alpha=0.19, diagonal="kde"
)

# y ticklabels
[plt.setp(item.yaxis.get_majorticklabels(), "size", 6) for item in Axes.ravel()]
# x ticklabels
[plt.setp(item.xaxis.get_majorticklabels(), "size", 6) for item in Axes.ravel()]
# y labels
[plt.setp(item.yaxis.get_label(), "size", 6) for item in Axes.ravel()]
# x labels
[plt.setp(item.xaxis.get_label(), "size", 6) for item in Axes.ravel()]

savefig("uncertainties." + args.save_format)


if __name__ == "__main__":
main()
29 changes: 27 additions & 2 deletions process/utilities/errorlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"comment2": [
"Increment n_errortypes if an error is added to this list"
],
"n_errortypes": 281,
"n_errortypes": 286,
"errors": [
{
"no": 1,
Expand Down Expand Up @@ -1353,7 +1353,7 @@
{
"no": 269,
"level": 3,
"message": "CHECK: Impossible to set the TF turn/cable size with the integer turn option (i_tf_turns_integer: 1) "
"message": "CHECK: Impossible to set the TF turn/cable size with the integer turn option (i_tf_turns_integer: 1)"
},
{
"no": 270,
Expand Down Expand Up @@ -1414,6 +1414,31 @@
"no": 281,
"level": 3,
"message": "CHECK: Cannot have i_tf_bucking >= 2 when tf_in_cs = 1"
},
{
"no": 282,
"level": 3,
"message": "CONSTRAINTS: Cannot have constraint icc == 77 fcpttf with iteration value ixc == 60 cpttf"
},
{
"no": 283,
"level": 3,
"message": "CHECK: Cannot have iterated itv ixc == 60 cpttf with i_tf_turns_integer == 1"
},
{
"no": 284,
"level": 3,
"message": "CHECK: Cannot have iterated itv ixc == 60 cpttf with t_turn_tf input or t_cable_tf is input"
},
{
"no": 285,
"level": 2,
"message": "WARNING: cpttf is calculated when t_turn_tf or t_cable_tf is input when i_tf_turns_integer == 0"
},
{
"no": 286,
"level": 2,
"message": "WARNING: default value of cpttf used which is 70000.0 (A) "
}
]
}
2 changes: 1 addition & 1 deletion source/fortran/constraint_equations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ subroutine constraint_eqns(m,ieqn,cc,con,err,symbol,units)
case (76); call constraint_eqn_076(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units)
! Equation for maximum TF current per turn upper limit
case (77); call constraint_eqn_077(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units)
! Equation for Reinke criterion, divertor impurity fraction lower limit
! Equation for Reinke criterion, divertor impurity fraction lower limit
case (78); call constraint_eqn_078(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units)
! Equation for maximum CS field
case (79); call constraint_eqn_079(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units)
Expand Down
83 changes: 55 additions & 28 deletions source/fortran/initial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ subroutine check
tfinsgap, rcool, dhecoil, thicndut, i_cp_joints, t_turn_tf_is_input, &
t_turn_tf, tftmp, t_cable_tf, t_cable_tf_is_input, tftmp, tmpcry, &
i_tf_cond_eyoung_axial, eyoung_cond_axial, eyoung_cond_trans, &
i_tf_cond_eyoung_trans, i_str_wp
i_tf_cond_eyoung_trans, i_str_wp, cpttf_max, cpttf,cpttf_max_is_input
use stellarator_variables, only: istell
use constraint_variables, only: fcpttf
use sctfcoil_module, only: initialise_cables
use vacuum_variables, only: vacuum_model
use, intrinsic :: iso_fortran_env, only: dp=>real64
Expand Down Expand Up @@ -439,6 +440,59 @@ subroutine check
! ---------------


! exclusions for constraint O77 fcpttf
if (any(icc == 77)) then
! If constraint O77 fcpttf has been selected it cannot be an iteration value as well
if (any(ixc == 60)) then
! ITV == 60 iteration value cpttf TF coil leg current per turn (A)
call report_error(282)
endif
endif

! exclusions for iteration itv 66 cpttf
if (any(ixc == 60)) then
! cpttf is calculated if i_tf_turns_integer == 1 so cannot be iterated.
! any value of cpttf will be overwritten by the calculated value.
if (i_tf_turns_integer == 1) then
call report_error(283)
endif
! if cpttf is being iterated then t_turn_tf or t_cable_tf can not be selected
if (t_turn_tf_is_input .eqv. .true. .or. t_cable_tf_is_input .eqv. .true. ) then
call report_error(284)
endif
endif

!
if (i_tf_turns_integer == 0) then
! if cpttf has been input then t_turn_tf or t_cable_tf cannot be used as cpttf is
! calculated with these options which will just overwrite cpttf. Warn that this has happened.
if ( cpttf >0 .and. ((t_turn_tf_is_input .eqv. .true.) .or. (t_cable_tf_is_input .eqv. .true.))) then
call report_error(285)

! cpttf = 70000 is the default value and warn that the default value has been used for cpttf
! a default variable might be better to be use i.e. cpttf_default = 70000.0
else if (cpttf == 70000.0 .and. ((t_turn_tf_is_input .eqv. .false.) .or. (t_cable_tf_is_input .eqv. .false.))) then
call report_error(286)
endif
end if


! Impossible to set the turn size of integer turn option
if ( t_turn_tf_is_input .and. i_tf_turns_integer == 1 ) then
call report_error(269)
end if

! Impossible to set the cable size of integer turn option
if ( t_cable_tf_is_input .and. i_tf_turns_integer == 1 ) then
call report_error(269)
end if

! Impossible to set both the TF coil turn and the cable dimension
if ( t_turn_tf_is_input .and. t_cable_tf_is_input ) then
call report_error(271)
end if


! Cannot use Psep/R and PsepB/qAR limits at the same time
if(any(icc == 68) .and. any(icc == 56)) then
call report_error(178)
Expand Down Expand Up @@ -820,34 +874,7 @@ subroutine check
end if
end if

! Setting t_turn_tf_is_input to true if t_turn_tf is an input
if ( abs(t_turn_tf) < epsilon(t_turn_tf) ) then
t_turn_tf_is_input = .false.
else
t_turn_tf_is_input = .true.
end if

! Impossible to set the turn size of integer turn option
if ( t_turn_tf_is_input .and. i_tf_turns_integer == 1 ) then
call report_error(269)
end if

! Setting t_cable_tf_is_input to true if t_cable_tf is an input
if ( abs(t_cable_tf) < epsilon(t_cable_tf) ) then
t_cable_tf_is_input = .false.
else
t_cable_tf_is_input = .true.
end if

! Impossible to set the cable size of integer turn option
if ( t_cable_tf_is_input .and. i_tf_turns_integer == 1 ) then
call report_error(269)
end if

! Impossible to set both the TF coil turn and the cable dimension
if ( t_turn_tf_is_input .and. t_cable_tf_is_input ) then
call report_error(271)
end if

! Checking the SC temperature for LTS
if ( ( i_tf_sc_mat == 1 .or. &
Expand Down
18 changes: 17 additions & 1 deletion source/fortran/input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ subroutine parse_input_file(in_file,out_file,show_changes)
i_tf_turns_integer, n_rad_per_layer, b_crit_upper_nbti, t_crit_nbti, &
i_cp_joints, n_tf_turn, f_t_turn_tf, t_turn_tf_max, t_cable_tf, &
sig_tf_wp_max, eyoung_cond_trans, i_tf_cond_eyoung_axial, i_tf_cond_eyoung_trans, &
str_wp_max, str_tf_con_res, i_str_wp, max_vv_stress, theta1_coil, theta1_vv
str_wp_max, str_tf_con_res, i_str_wp, max_vv_stress, theta1_coil, theta1_vv, &
t_turn_tf_is_input, t_cable_tf_is_input, cpttf_max_is_input

use times_variables, only: tohs, pulsetimings, tqnch, t_fusion_ramp, tramp, tburn, &
tdwell, tohsin
Expand Down Expand Up @@ -1520,6 +1521,11 @@ subroutine parse_input_file(in_file,out_file,show_changes)
case ('cpttf_max')
call parse_real_variable('cpttf_max', cpttf_max, 1.0D0, 1.0D6, &
'Maximum allowable TF coil leg current per turn (A) (constraint equation 77)')
if (cpttf_max == 0.0D0) then
cpttf_max_is_input = .false.
else if (cpttf_max > 0.0D0) then
cpttf_max_is_input = .true.
end if

case ('sig_tf_case_max')
call parse_real_variable('sig_tf_case_max', sig_tf_case_max, 1.0D6, 1.0D11, &
Expand Down Expand Up @@ -1752,6 +1758,11 @@ subroutine parse_input_file(in_file,out_file,show_changes)
case ('t_turn_tf')
call parse_real_variable('t_turn_tf', t_turn_tf, 0.0D0, 0.1D0, &
'TF turn square dimensions (m)')
if (t_turn_tf == 0.0D0) then
t_turn_tf_is_input = .false.
else if (t_turn_tf > 0.0D0) then
t_turn_tf_is_input = .true.
end if
case ('f_t_turn_tf')
call parse_real_variable('f_t_turn_tf', f_t_turn_tf, 0.0D0, 1.D0, &
'f-value for TF coils WP trurn squared dimension constraint')
Expand All @@ -1761,6 +1772,11 @@ subroutine parse_input_file(in_file,out_file,show_changes)
case ('t_cable_tf')
call parse_real_variable('t_cable_tf', t_cable_tf, 0.0D0, 0.1D0, &
'TF coil cable square/rounded dimensions (m)')
if (t_cable_tf == 0.0D0) then
t_cable_tf_is_input = .false.
else if (t_cable_tf > 0.0D0) then
t_cable_tf_is_input = .true.
end if
case ('thicndut')
call parse_real_variable('thicndut', thicndut, 0.0D0, 0.1D0, &
'Conduit insulation thickness (m)')
Expand Down
Loading