From 8119dfb1e5e6ba2eecdc95c563834eee4c097081 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Fri, 28 Feb 2025 14:44:07 +0000 Subject: [PATCH 01/12] Removed tresca from some variable names, swapped for s_shear --- process/io/obsolete_vars.py | 4 ++ process/io/plot_proc.py | 4 +- process/pfcoil.py | 8 +-- process/sctfcoil.py | 66 ++++++++++++------------- source/fortran/constraint_equations.f90 | 12 ++--- source/fortran/pfcoil_variables.f90 | 4 +- source/fortran/tfcoil_variables.f90 | 4 +- tests/integration/ref_dicts.json | 13 +++-- tests/integration/test_pfcoil_int.py | 2 +- 9 files changed, 60 insertions(+), 57 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 5a5c7a4cc5..9c3c05a800 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -214,6 +214,10 @@ "tfwmatmax": "temp_fw_max", "fw_channel_length": "len_fw_channel", "denw": None, + "s_tresca_oh": "s_shear_max_cs", + "sig_tf_tresca_max": "s_shear_max_tf", + "s_tresca_cond_cear": "s_shear_cea_tf_cond", + "sig_tf_tresca": "s_shear_tf", } OBS_VARS_HELP = { diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 2bc73259af..8bd0c89928 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2625,11 +2625,11 @@ def plot_magnetics_info(axis, mfile_data, scan): "vs_plasma_ind_ramp" ].get_scan(scan) - sig_case = 1.0e-6 * mfile_data.data[f"sig_tf_tresca_max({i_tf_bucking})"].get_scan( + sig_case = 1.0e-6 * mfile_data.data[f"s_shear_max_tf({i_tf_bucking})"].get_scan( scan ) sig_cond = 1.0e-6 * mfile_data.data[ - f"sig_tf_tresca_max({i_tf_bucking + 1})" + f"s_shear_max_tf({i_tf_bucking + 1})" ].get_scan(scan) if i_tf_sup == 1: diff --git a/process/pfcoil.py b/process/pfcoil.py index a15ac3553a..13782808d1 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -1111,13 +1111,13 @@ def ohcalc(self): areaspf = pfv.oh_steel_frac * pfv.areaoh if pfv.i_cs_stress == 1: - pfv.s_tresca_oh = max( + pfv.s_shear_max_cs = max( abs(pf.sig_hoop - pf.sig_axial), abs(pf.sig_axial - 0.0e0), abs(0.0e0 - pf.sig_hoop), ) else: - pfv.s_tresca_oh = max( + pfv.s_shear_max_cs = max( abs(pf.sig_hoop - 0.0e0), abs(0.0e0 - 0.0e0), abs(0.0e0 - pf.sig_hoop), @@ -2036,8 +2036,8 @@ def outpf(self): op.ovarre( self.outfile, "Maximum shear stress in CS steel for the Tresca criterion (Pa)", - "(s_tresca_oh)", - pfv.s_tresca_oh, + "(s_shear_max_cs)", + pfv.s_shear_max_cs, "OP ", ) op.ovarre( diff --git a/process/sctfcoil.py b/process/sctfcoil.py index e96ac06c30..95a7ae54d2 100644 --- a/process/sctfcoil.py +++ b/process/sctfcoil.py @@ -1228,7 +1228,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - sig_tf_tresca_max, + s_shear_max_tf, deflect, eyoung_axial, eyoung_trans, @@ -1236,14 +1236,14 @@ def sctfcoil(self, output: bool): eyoung_wp_trans, poisson_wp_trans, radial_array, - s_tresca_cond_cea, + s_shear_cea_tf_cond, poisson_wp_axial, sig_tf_r, sig_tf_smeared_r, sig_tf_smeared_t, sig_tf_smeared_z, sig_tf_t, - sig_tf_tresca, + s_shear_tf, sig_tf_vmises, sig_tf_z, str_tf_r, @@ -1362,7 +1362,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - sig_tf_tresca_max, + s_shear_max_tf, deflect, eyoung_axial, eyoung_trans, @@ -1370,14 +1370,14 @@ def sctfcoil(self, output: bool): eyoung_wp_trans, poisson_wp_trans, radial_array, - s_tresca_cond_cea, + s_shear_cea_tf_cond, poisson_wp_axial, sig_tf_r, sig_tf_smeared_r, sig_tf_smeared_t, sig_tf_smeared_z, sig_tf_t, - sig_tf_tresca, + s_shear_tf, sig_tf_vmises, sig_tf_z, str_tf_r, @@ -3711,7 +3711,7 @@ def stresscl( sig_tf_vmises_max = np.zeros((n_tf_layer,)) # Von-Mises stress of the point of maximum shear stress of each layer [Pa] - sig_tf_tresca_max = np.zeros((n_tf_layer,)) + s_shear_max_tf = np.zeros((n_tf_layer,)) # Maximum shear stress, for the Tresca yield criterion of each layer [Pa] # If the CEA correction is addopted, the CEA corrected value is used @@ -4325,7 +4325,7 @@ def stresscl( # Tresca / Von Mises yield criteria calculations # ----------------------------- # Array equation - sig_tf_tresca = np.maximum( + s_shear_tf = np.maximum( np.absolute(sig_tf_r - sig_tf_z), np.absolute(sig_tf_z - sig_tf_t) ) @@ -4341,7 +4341,7 @@ def stresscl( ) # Array equation - s_tresca_cond_cea = sig_tf_tresca.copy() + s_shear_cea_tf_cond = s_shear_tf.copy() # SC conducting layer stress distribution corrections # --- @@ -4359,7 +4359,7 @@ def stresscl( sig_tf_vmises[ii] = max(svmxz, svmyz) # Maximum shear stress for the Tresca yield criterion using CEA calculation [Pa] - s_tresca_cond_cea[ii] = ( + s_shear_cea_tf_cond[ii] = ( 1.02e0 * abs(sig_tf_r[ii]) + 1.6e0 * sig_tf_z[ii] ) @@ -4375,14 +4375,14 @@ def stresscl( for jj in range(ii * n_radial_array, (ii + 1) * n_radial_array): # CEA out of plane approximation if i_tf_tresca == 1 and i_tf_sup == 1 and ii >= i_tf_bucking + 1: - if sig_max < s_tresca_cond_cea[jj]: - sig_max = s_tresca_cond_cea[jj] + if sig_max < s_shear_cea_tf_cond[jj]: + sig_max = s_shear_cea_tf_cond[jj] ii_max = jj # Conventional Tresca else: - if sig_max < sig_tf_tresca[jj]: - sig_max = sig_tf_tresca[jj] + if sig_max < s_shear_tf[jj]: + sig_max = s_shear_tf[jj] ii_max = jj # OUT.DAT output @@ -4395,19 +4395,19 @@ def stresscl( # Maximum shear stress for the Tresca yield criterion (or CEA OOP correction) if i_tf_tresca == 1 and i_tf_sup == 1 and ii >= i_tf_bucking + 1: - sig_tf_tresca_max[ii] = s_tresca_cond_cea[ii_max] + s_shear_max_tf[ii] = s_shear_cea_tf_cond[ii_max] else: - sig_tf_tresca_max[ii] = sig_tf_tresca[ii_max] + s_shear_max_tf[ii] = s_shear_tf[ii_max] # Constraint equation for the Tresca yield criterion - sig_tf_wp = sig_tf_tresca_max[n_tf_bucking] + sig_tf_wp = s_shear_max_tf[n_tf_bucking] # Maximum assumed in the first graded layer if i_tf_bucking >= 1: - sig_tf_case = sig_tf_tresca_max[n_tf_bucking - 1] + sig_tf_case = s_shear_max_tf[n_tf_bucking - 1] if i_tf_bucking >= 2: - sig_tf_cs_bucked = sig_tf_tresca_max[0] + sig_tf_cs_bucked = s_shear_max_tf[0] # ---------------- return ( @@ -4415,7 +4415,7 @@ def stresscl( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - sig_tf_tresca_max, + s_shear_max_tf, deflect, eyoung_axial, eyoung_trans, @@ -4423,14 +4423,14 @@ def stresscl( eyoung_wp_trans, poisson_wp_trans, radial_array, - s_tresca_cond_cea, + s_shear_cea_tf_cond, poisson_wp_axial, sig_tf_r, sig_tf_smeared_r, sig_tf_smeared_t, sig_tf_smeared_z, sig_tf_t, - sig_tf_tresca, + s_shear_tf, sig_tf_vmises, sig_tf_z, str_tf_r, @@ -5837,7 +5837,7 @@ def out_stress( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - sig_tf_tresca_max, + s_shear_max_tf, deflect, eyoung_axial, eyoung_trans, @@ -5845,14 +5845,14 @@ def out_stress( eyoung_wp_trans, poisson_wp_trans, radial_array, - s_tresca_cond_cea, + s_shear_cea_tf_cond, poisson_wp_axial, sig_tf_r, sig_tf_smeared_r, sig_tf_smeared_t, sig_tf_smeared_z, sig_tf_t, - sig_tf_tresca, + s_shear_tf, sig_tf_vmises, sig_tf_z, str_tf_r, @@ -5978,12 +5978,12 @@ def table_format_arrays(a, mult=1, delim="\t\t"): if tfcoil_variables.i_tf_tresca == 1 and tfcoil_variables.i_tf_sup == 1: po.write( self.outfile, - f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(sig_tf_tresca_max, 1e-6)}", + f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_max_tf, 1e-6)}", ) else: po.write( self.outfile, - f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(sig_tf_tresca_max, 1e-6)}", + f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_max_tf, 1e-6)}", ) po.write(self.outfile, "") @@ -6055,15 +6055,15 @@ def table_format_arrays(a, mult=1, delim="\t\t"): po.ovarre( constants.mfile, f"Maximum shear stress for CEA Tresca yield criterion {ii + 1} (Pa)", - f"(sig_tf_tresca_max({ii + 1}))", - sig_tf_tresca_max[ii], + f"(s_shear_max_tf({ii + 1}))", + s_shear_max_tf[ii], ) else: po.ovarre( constants.mfile, f"Maximum shear stress for the Tresca yield criterion {ii + 1} (Pa)", - f"(sig_tf_tresca_max({ii + 1}))", - sig_tf_tresca_max[ii], + f"(s_shear_max_tf({ii + 1}))", + s_shear_max_tf[ii], ) # SIG_TF.json storage @@ -6078,9 +6078,9 @@ def table_format_arrays(a, mult=1, delim="\t\t"): "Vertical smear stress (MPa)": sig_tf_smeared_z * 1e-6, "Von-Mises stress (MPa)": sig_tf_vmises * 1e-6, "CEA Tresca stress (MPa)": ( - s_tresca_cond_cea * 1e-6 + s_shear_cea_tf_cond * 1e-6 if tfcoil_variables.i_tf_sup == 1 - else sig_tf_tresca * 1e-6 + else s_shear_tf * 1e-6 ), "rad. displacement (mm)": deflect * 1e3, } diff --git a/source/fortran/constraint_equations.f90 b/source/fortran/constraint_equations.f90 index 5cf3816860..d0795620de 100755 --- a/source/fortran/constraint_equations.f90 +++ b/source/fortran/constraint_equations.f90 @@ -2755,12 +2755,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) !! Logic change during pre-factoring: err, symbol, units will be assigned only if present. !! foh_stress : input real : f-value for Tresca yield criterion in Central Solenoid !! alstroh : input real : allowable hoop stress in Central Solenoid structural material (Pa) - !! s_tresca_oh : input real : Maximum shear stress coils/central solenoid (Pa) + !! s_shear_max_cs : input real : Maximum shear stress coils/central solenoid (Pa) !! sig_tf_cs_bucked : input real : Maximum shear stress in CS case at flux swing (no current in CS) !! can be significant for the bucked and weged design !! i_tf_bucking : input integer : switch for TF structure design use constraint_variables, only: foh_stress - use pfcoil_variables, only: alstroh, s_tresca_oh + use pfcoil_variables, only: alstroh, s_shear_max_cs use tfcoil_variables, only: sig_tf_cs_bucked, i_tf_bucking use build_variables, only: tf_in_cs implicit none @@ -2772,12 +2772,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) ! bucked and wedged desing (see subroutine comment) if ( i_tf_bucking >= 2 .and. tf_in_cs == 0 ) then - tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_tresca_oh, sig_tf_cs_bucked) - tmp_err = alstroh - max(s_tresca_oh, sig_tf_cs_bucked) + tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_shear_max_cs, sig_tf_cs_bucked) + tmp_err = alstroh - max(s_shear_max_cs, sig_tf_cs_bucked) ! Free standing CS else - tmp_cc = 1.0d0 - foh_stress * alstroh / s_tresca_oh - tmp_err = alstroh - s_tresca_oh + tmp_cc = 1.0d0 - foh_stress * alstroh / s_shear_max_cs + tmp_err = alstroh - s_shear_max_cs end if tmp_con = alstroh diff --git a/source/fortran/pfcoil_variables.f90 b/source/fortran/pfcoil_variables.f90 index 8dc543b8ee..a0c2558b88 100644 --- a/source/fortran/pfcoil_variables.f90 +++ b/source/fortran/pfcoil_variables.f90 @@ -298,7 +298,7 @@ module pfcoil_variables !! the coil in units of minor radii from the major radius !! (r = rmajor + rref*rminor) - real(dp) :: s_tresca_oh + real(dp) :: s_shear_max_cs !! Maximum shear stress (Tresca criterion) coils/central solenoid [MPa] real(dp) :: sigpfcalw @@ -489,7 +489,7 @@ subroutine init_pfcoil_variables rpf2 = -1.63D0 rref = (/7.0D0, 7.0D0, 7.0D0, & 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0/) - s_tresca_oh = 0.0D0 + s_shear_max_cs = 0.0D0 sigpfcalw = 500.0D0 sigpfcf = 1.0D0 sxlg = 0.0D0 diff --git a/source/fortran/tfcoil_variables.f90 b/source/fortran/tfcoil_variables.f90 index 7a081cb487..ead6f66267 100644 --- a/source/fortran/tfcoil_variables.f90 +++ b/source/fortran/tfcoil_variables.f90 @@ -421,7 +421,7 @@ module tfcoil_variables real(dp), dimension(2*n_radial_array) :: sig_tf_vmises !! TF Inboard leg Von-Mises stress in steel r distribution at mid-plane [Pa] - real(dp), dimension(2*n_radial_array) :: sig_tf_tresca + real(dp), dimension(2*n_radial_array) :: s_shear_tf !! TF Inboard leg maximum shear stress (Tresca criterion) in steel r distribution at mid-plane [Pa] real(dp) :: sig_tf_cs_bucked @@ -941,7 +941,7 @@ subroutine init_tfcoil_variables deflect = 0.0D0 sig_tf_z = 0.0D0 sig_tf_vmises = 0.0D0 - sig_tf_tresca = 0.0D0 + s_shear_tf = 0.0D0 sig_tf_cs_bucked = 0.0D0 sig_tf_case = 0.0D0 sig_tf_wp = 0.0D0 diff --git a/tests/integration/ref_dicts.json b/tests/integration/ref_dicts.json index cceb2981a6..e3c9deb7b0 100644 --- a/tests/integration/ref_dicts.json +++ b/tests/integration/ref_dicts.json @@ -4897,7 +4897,7 @@ "'not used'", "'not used'" ], - "s_tresca_oh": 0.0, + "s_shear_max_cs": 0.0, "a_plasma_surface": 0.0, "a_plasma_surface_outboard": 0.0, "scafc": [ @@ -5327,7 +5327,7 @@ "sig_tf_cs_bucked": 0.0, "sig_tf_r": 0.0, "sig_tf_t": 0.0, - "sig_tf_tresca": 0.0, + "s_shear_tf": 0.0, "sig_tf_vmises": 0.0, "sig_tf_wp": 0.0, "sig_tf_wp_max": 600000000.0, @@ -10587,7 +10587,7 @@ "s_k": "", "s_kref": "", "s_label": "", - "s_tresca_oh": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", + "s_shear_max_cs": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", "a_plasma_surface": "plasma surface area", "a_plasma_surface_outboard": "outboard plasma surface area", "scafc": "", @@ -10633,7 +10633,7 @@ "sig_tf_cs_bucked": "Maximum shear stress (Tresca criterion) in CS structures at CS flux swing [Pa]:\n\nQuantity only computed for bucked and wedged design (`i_tf_bucking >= 2`)\n Def : CS Flux swing, instant when the current changes sign in CS (null current)", "sig_tf_r": "TF Inboard leg radial stress in steel r distribution at mid-plane [Pa]", "sig_tf_t": "TF Inboard leg tangential stress in steel r distribution at mid-plane [Pa]", - "sig_tf_tresca": "TF Inboard leg maximum shear stress (Tresca criterion) in steel r distribution at mid-plane [Pa]", + "s_shear_tf": "TF Inboard leg maximum shear stress (Tresca criterion) in steel r distribution at mid-plane [Pa]", "sig_tf_vmises": "TF Inboard leg Von-Mises stress in steel r distribution at mid-plane [Pa]", "sig_tf_wp": "", "sig_tf_wp_max": "Allowable maximum shear stress (Tresca criterion) in TF coil conduit (Pa)\nAllowable Tresca stress in TF coil structural material (Pa)", @@ -18986,7 +18986,7 @@ "rpf1", "rpf2", "rref", - "s_tresca_oh", + "s_shear_max_cs", "sigpfcalw", "sigpfcf", "sxlg", @@ -19152,7 +19152,6 @@ "iwalld", "kappa", "kappa95", - "kappa_ipb", "ne0", "ni0", @@ -19603,7 +19602,7 @@ "deflect", "sig_tf_z", "sig_tf_vmises", - "sig_tf_tresca", + "s_shear_tf", "sig_tf_cs_bucked", "sig_tf_case", "sig_tf_wp", diff --git a/tests/integration/test_pfcoil_int.py b/tests/integration/test_pfcoil_int.py index 4717e313c4..5405cf0b80 100644 --- a/tests/integration/test_pfcoil_int.py +++ b/tests/integration/test_pfcoil_int.py @@ -204,7 +204,7 @@ def test_ohcalc(monkeypatch, reinitialise_error_module, pfcoil): monkeypatch.setattr(pfv, "jcableoh_eof", 1.427e8) monkeypatch.setattr(pfv, "powohres", 0.0) monkeypatch.setattr(pfv, "rjohc0", 3.048e7) - monkeypatch.setattr(pfv, "s_tresca_oh", 5.718e8) + monkeypatch.setattr(pfv, "s_shear_max_cs", 5.718e8) monkeypatch.setattr(pfv, "awpoh", 4.232) monkeypatch.setattr(pfv, "oh_steel_frac", 5.926e-1) monkeypatch.setattr(pfv, "bmaxoh0", 1.4e1) From 134573b96a8b3bc3452728004a0bb05bb944e293 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Wed, 5 Mar 2025 10:27:41 +0000 Subject: [PATCH 02/12] Remove trailing whitespace --- process/io/obsolete_vars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 9c3c05a800..e112e2c8a4 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -217,8 +217,8 @@ "s_tresca_oh": "s_shear_max_cs", "sig_tf_tresca_max": "s_shear_max_tf", "s_tresca_cond_cear": "s_shear_cea_tf_cond", - "sig_tf_tresca": "s_shear_tf", -} + "sig_tf_tresca": "s_shear_tf", + } OBS_VARS_HELP = { "iculdl": "(use IDENSL=3 for equivalent model to ICULDL=0). ", From b3b1756f923bab78f3eb70c609a5374be4870a24 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Wed, 5 Mar 2025 10:53:42 +0000 Subject: [PATCH 03/12] quality checks --- process/io/obsolete_vars.py | 2 +- process/io/plot_proc.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index e112e2c8a4..90a8e6f12e 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -218,7 +218,7 @@ "sig_tf_tresca_max": "s_shear_max_tf", "s_tresca_cond_cear": "s_shear_cea_tf_cond", "sig_tf_tresca": "s_shear_tf", - } +} OBS_VARS_HELP = { "iculdl": "(use IDENSL=3 for equivalent model to ICULDL=0). ", diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 8bd0c89928..9b9180f551 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2628,9 +2628,9 @@ def plot_magnetics_info(axis, mfile_data, scan): sig_case = 1.0e-6 * mfile_data.data[f"s_shear_max_tf({i_tf_bucking})"].get_scan( scan ) - sig_cond = 1.0e-6 * mfile_data.data[ - f"s_shear_max_tf({i_tf_bucking + 1})" - ].get_scan(scan) + sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_max_tf({i_tf_bucking + 1})"].get_scan( + scan + ) if i_tf_sup == 1: data = [ From 2af88d14e95b5e0d04e78d04cfa6e493ff1ba18e Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 09:23:56 +0000 Subject: [PATCH 04/12] added missing hash to length, in line with other subtitles --- .../proc-pages/development/standards.md | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/documentation/proc-pages/development/standards.md b/documentation/proc-pages/development/standards.md index c6021d706b..b635af6880 100644 --- a/documentation/proc-pages/development/standards.md +++ b/documentation/proc-pages/development/standards.md @@ -4,7 +4,7 @@ -------------------- -## Line Length +##  Line Length For optimal readability, a limit of 79 characters for maximum line length has been encouraged, as recommended in [PEP8](https://peps.python.org/pep-0008/). This is below the maximum line length of 132 characters for Fortran (to prevent compilation errors) and prevents long lines that run on past the edge of the screen wasting programmers time with scrolling. @@ -13,7 +13,7 @@ For optimal readability, a limit of 79 characters for maximum line length has be ## Double declarations PROCESS uses the Fortran 2008+ intrinsic precision module as shown in the example below. The -use statement will need to be at the module level. See the +use statement will need to be at the module level. See the [fortran wiki](http://fortranwiki.org/fortran/show/Real+precision) for more information. ```fortran @@ -102,7 +102,6 @@ $$ This means the variable represents the fraction of the TF coil area taken up by the winding pack. - -------------- #### System designations @@ -118,10 +117,10 @@ Below are a few shorthand designations for different systems that should be used - Shield: `_shld_` - Central Solenoid: `_cs_` - Heating & Current Drive: `_hcd_` - - Electron cyclotron current drive: `_eccd_` - - Ion cyclotron current drive: `_iccd_` - - Electron Bernstein Wave: `_ebw_` - - Neutral Beam: `_nb_` + - Electron cyclotron current drive: `_eccd_` + - Ion cyclotron current drive: `_iccd_` + - Electron Bernstein Wave: `_ebw_` + - Neutral Beam: `_nb_` - Centre post: `_cp_` Should only be used for ST's If the variables are physics variables and do not belong to a system then: @@ -221,7 +220,6 @@ This should be used for units of $\text{kg} \cdot \text{m}^{-2}\text{s}^{-1}$ --------------------- - ##### Densities - Densities should start with the `den_` prefix @@ -348,7 +346,6 @@ The unit declaration `_fpy` can be used to specify that it is the full-power yea --------------------- - ##### Variables representing fractions If a variable is intended to demonstrate a fraction of a value or distribution etc. Then it should start with the `f_` prefix. @@ -365,7 +362,7 @@ Variables used within constraint equations to scale iteration variables (f-value --------------------- -### Length +#### Length Try to keep names to a sensible length while also keeping the name explicit and descriptive. @@ -408,7 +405,7 @@ fusion_power_MW = 1000.0d0 With `f2py` you may encounter a Fortran error where the variable with units at the end in capital letters is not recognised. If so for the meantime put the units in their lowercase form. This problem will be solved in the future by full Pythonisation. ---------------------- +--------------------- ### Coordinates and dimensions @@ -557,15 +554,14 @@ class ExampleClass: - Comments above apply to code below. - ## Code Documentation Using FORD -PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments -in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well +PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments +in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well as picking up "docmarked" comments in the source to create the documentation. -Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into -the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up +Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into +the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up by FORD and go into the documentation. The "!!" docmark goes after the statement it documents. For example, to document variables: @@ -582,6 +578,7 @@ real(kind(1.0D0)) :: alpha_rate_density = 0.0D0 ``` ...and to document modules: + ```fortran module global_variables !! Module containing miscellaneous global variables @@ -589,13 +586,13 @@ module global_variables !! well-suited to any of the other 'variables' modules. ``` -This documentation will appear in the -[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the -left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar -provides variable descriptions in the same manner as the original "vardes" page. +This documentation will appear in the +[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the +left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar +provides variable descriptions in the same manner as the original "vardes" page. -To document a statement before it occurs in the source, use "!>". However, it is encouraged to -use "!!" for consistency. The rationale behind this and further information is included on the +To document a statement before it occurs in the source, use "!>". However, it is encouraged to +use "!!" for consistency. The rationale behind this and further information is included on the [FORD wiki](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Writing-Documentation). The FORD project on github can be found [here](https://github.com/Fortran-FOSS-Programmers/ford). From 72f53b8cb7a06ec1e9a95f375b1de43cc1e55e9d Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 09:25:23 +0000 Subject: [PATCH 05/12] Revert "added missing hash to length, in line with other subtitles" This reverts commit 5e0e1f657be77d7c5fc6b981ba351e9d0b2ffc0a. --- .../proc-pages/development/standards.md | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/documentation/proc-pages/development/standards.md b/documentation/proc-pages/development/standards.md index b635af6880..c6021d706b 100644 --- a/documentation/proc-pages/development/standards.md +++ b/documentation/proc-pages/development/standards.md @@ -4,7 +4,7 @@ -------------------- -##  Line Length +## Line Length For optimal readability, a limit of 79 characters for maximum line length has been encouraged, as recommended in [PEP8](https://peps.python.org/pep-0008/). This is below the maximum line length of 132 characters for Fortran (to prevent compilation errors) and prevents long lines that run on past the edge of the screen wasting programmers time with scrolling. @@ -13,7 +13,7 @@ For optimal readability, a limit of 79 characters for maximum line length has be ## Double declarations PROCESS uses the Fortran 2008+ intrinsic precision module as shown in the example below. The -use statement will need to be at the module level. See the +use statement will need to be at the module level. See the [fortran wiki](http://fortranwiki.org/fortran/show/Real+precision) for more information. ```fortran @@ -102,6 +102,7 @@ $$ This means the variable represents the fraction of the TF coil area taken up by the winding pack. + -------------- #### System designations @@ -117,10 +118,10 @@ Below are a few shorthand designations for different systems that should be used - Shield: `_shld_` - Central Solenoid: `_cs_` - Heating & Current Drive: `_hcd_` - - Electron cyclotron current drive: `_eccd_` - - Ion cyclotron current drive: `_iccd_` - - Electron Bernstein Wave: `_ebw_` - - Neutral Beam: `_nb_` + - Electron cyclotron current drive: `_eccd_` + - Ion cyclotron current drive: `_iccd_` + - Electron Bernstein Wave: `_ebw_` + - Neutral Beam: `_nb_` - Centre post: `_cp_` Should only be used for ST's If the variables are physics variables and do not belong to a system then: @@ -220,6 +221,7 @@ This should be used for units of $\text{kg} \cdot \text{m}^{-2}\text{s}^{-1}$ --------------------- + ##### Densities - Densities should start with the `den_` prefix @@ -346,6 +348,7 @@ The unit declaration `_fpy` can be used to specify that it is the full-power yea --------------------- + ##### Variables representing fractions If a variable is intended to demonstrate a fraction of a value or distribution etc. Then it should start with the `f_` prefix. @@ -362,7 +365,7 @@ Variables used within constraint equations to scale iteration variables (f-value --------------------- -#### Length +### Length Try to keep names to a sensible length while also keeping the name explicit and descriptive. @@ -405,7 +408,7 @@ fusion_power_MW = 1000.0d0 With `f2py` you may encounter a Fortran error where the variable with units at the end in capital letters is not recognised. If so for the meantime put the units in their lowercase form. This problem will be solved in the future by full Pythonisation. ---------------------- +--------------------- ### Coordinates and dimensions @@ -554,14 +557,15 @@ class ExampleClass: - Comments above apply to code below. + ## Code Documentation Using FORD -PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments -in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well +PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments +in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well as picking up "docmarked" comments in the source to create the documentation. -Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into -the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up +Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into +the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up by FORD and go into the documentation. The "!!" docmark goes after the statement it documents. For example, to document variables: @@ -578,7 +582,6 @@ real(kind(1.0D0)) :: alpha_rate_density = 0.0D0 ``` ...and to document modules: - ```fortran module global_variables !! Module containing miscellaneous global variables @@ -586,13 +589,13 @@ module global_variables !! well-suited to any of the other 'variables' modules. ``` -This documentation will appear in the -[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the -left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar -provides variable descriptions in the same manner as the original "vardes" page. +This documentation will appear in the +[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the +left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar +provides variable descriptions in the same manner as the original "vardes" page. -To document a statement before it occurs in the source, use "!>". However, it is encouraged to -use "!!" for consistency. The rationale behind this and further information is included on the +To document a statement before it occurs in the source, use "!>". However, it is encouraged to +use "!!" for consistency. The rationale behind this and further information is included on the [FORD wiki](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Writing-Documentation). The FORD project on github can be found [here](https://github.com/Fortran-FOSS-Programmers/ford). From 4fbd09dadf8b8f5c878f34e32546d47cba39f772 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 09:43:26 +0000 Subject: [PATCH 06/12] added missing hash to length, in line with other subtitles --- .../proc-pages/development/standards.md | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/documentation/proc-pages/development/standards.md b/documentation/proc-pages/development/standards.md index c6021d706b..c2fda7b5a4 100644 --- a/documentation/proc-pages/development/standards.md +++ b/documentation/proc-pages/development/standards.md @@ -4,7 +4,7 @@ -------------------- -## Line Length +##  Line Length For optimal readability, a limit of 79 characters for maximum line length has been encouraged, as recommended in [PEP8](https://peps.python.org/pep-0008/). This is below the maximum line length of 132 characters for Fortran (to prevent compilation errors) and prevents long lines that run on past the edge of the screen wasting programmers time with scrolling. @@ -13,7 +13,7 @@ For optimal readability, a limit of 79 characters for maximum line length has be ## Double declarations PROCESS uses the Fortran 2008+ intrinsic precision module as shown in the example below. The -use statement will need to be at the module level. See the +use statement will need to be at the module level. See the [fortran wiki](http://fortranwiki.org/fortran/show/Real+precision) for more information. ```fortran @@ -102,7 +102,6 @@ $$ This means the variable represents the fraction of the TF coil area taken up by the winding pack. - -------------- #### System designations @@ -118,10 +117,10 @@ Below are a few shorthand designations for different systems that should be used - Shield: `_shld_` - Central Solenoid: `_cs_` - Heating & Current Drive: `_hcd_` - - Electron cyclotron current drive: `_eccd_` - - Ion cyclotron current drive: `_iccd_` - - Electron Bernstein Wave: `_ebw_` - - Neutral Beam: `_nb_` + - Electron cyclotron current drive: `_eccd_` + - Ion cyclotron current drive: `_iccd_` + - Electron Bernstein Wave: `_ebw_` + - Neutral Beam: `_nb_` - Centre post: `_cp_` Should only be used for ST's If the variables are physics variables and do not belong to a system then: @@ -221,7 +220,6 @@ This should be used for units of $\text{kg} \cdot \text{m}^{-2}\text{s}^{-1}$ --------------------- - ##### Densities - Densities should start with the `den_` prefix @@ -348,7 +346,6 @@ The unit declaration `_fpy` can be used to specify that it is the full-power yea --------------------- - ##### Variables representing fractions If a variable is intended to demonstrate a fraction of a value or distribution etc. Then it should start with the `f_` prefix. @@ -365,7 +362,7 @@ Variables used within constraint equations to scale iteration variables (f-value --------------------- -### Length +##### Length Try to keep names to a sensible length while also keeping the name explicit and descriptive. @@ -408,7 +405,7 @@ fusion_power_MW = 1000.0d0 With `f2py` you may encounter a Fortran error where the variable with units at the end in capital letters is not recognised. If so for the meantime put the units in their lowercase form. This problem will be solved in the future by full Pythonisation. ---------------------- +--------------------- ### Coordinates and dimensions @@ -557,15 +554,14 @@ class ExampleClass: - Comments above apply to code below. - ## Code Documentation Using FORD -PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments -in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well +PROCESS uses FORD (FORtran Documentation) to automatically generate documentation from comments +in the FORTRAN code. FORD parses FORTRAN source to understand the structure of the project as well as picking up "docmarked" comments in the source to create the documentation. -Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into -the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up +Regular Fortran comments are prefixed with a "!"; these are ignored by FORD and don't go into +the documentation. FORD comments are prefixed by a "!!", called a docmark; these are picked up by FORD and go into the documentation. The "!!" docmark goes after the statement it documents. For example, to document variables: @@ -582,6 +578,7 @@ real(kind(1.0D0)) :: alpha_rate_density = 0.0D0 ``` ...and to document modules: + ```fortran module global_variables !! Module containing miscellaneous global variables @@ -589,13 +586,13 @@ module global_variables !! well-suited to any of the other 'variables' modules. ``` -This documentation will appear in the -[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the -left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar -provides variable descriptions in the same manner as the original "vardes" page. +This documentation will appear in the +[FORD docs](http://process.gitpages.ccfe.ac.uk/process/ford_site/index.html) section in the +left-hand navigation bar. Within this site, the "Variables" section in the top navigation bar +provides variable descriptions in the same manner as the original "vardes" page. -To document a statement before it occurs in the source, use "!>". However, it is encouraged to -use "!!" for consistency. The rationale behind this and further information is included on the +To document a statement before it occurs in the source, use "!>". However, it is encouraged to +use "!!" for consistency. The rationale behind this and further information is included on the [FORD wiki](https://github.com/Fortran-FOSS-Programmers/ford/wiki/Writing-Documentation). The FORD project on github can be found [here](https://github.com/Fortran-FOSS-Programmers/ford). From e840df37e37d72b61557537fc1d5e1261fce14e4 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 09:48:57 +0000 Subject: [PATCH 07/12] Added stress subsection, updated stress example in table --- documentation/proc-pages/development/standards.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/documentation/proc-pages/development/standards.md b/documentation/proc-pages/development/standards.md index c2fda7b5a4..bf5f22582d 100644 --- a/documentation/proc-pages/development/standards.md +++ b/documentation/proc-pages/development/standards.md @@ -368,6 +368,12 @@ Try to keep names to a sensible length while also keeping the name explicit and --------------------- +##### Stress + +- Stresses should start with the `s_` prefix followed by the type of stress, for example `s_shear_`. + +--------------------- + ### Physical Type The physical type of the variable should form the first part of the variable name, e.g. for plasma resistance the variable should be named: @@ -468,7 +474,7 @@ ii | `a_plasma` | Plasma area | m2 | | `rad_div_target` | Divertor target angle | radians | | `deg_div_target` | Divertor target angle | deg | -| `sig_tf_r` | TF radial stress | Pa | +| `s_shear_tf` | TF shear stress | Pa | | `` | | | Please see issue [#940](https://github.com/ukaea/PROCESS/issues/940) to discuss new conventions. From 2afc8ee8485f0364aedffde3acff596e2d452c45 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 09:53:50 +0000 Subject: [PATCH 08/12] Updated shear_tf variable name, with correct order according to style guide --- process/io/obsolete_vars.py | 2 +- process/io/plot_proc.py | 4 ++-- process/sctfcoil.py | 32 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 90a8e6f12e..d046da3581 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -215,7 +215,7 @@ "fw_channel_length": "len_fw_channel", "denw": None, "s_tresca_oh": "s_shear_max_cs", - "sig_tf_tresca_max": "s_shear_max_tf", + "sig_tf_tresca_max": "s_shear_tf_max", "s_tresca_cond_cear": "s_shear_cea_tf_cond", "sig_tf_tresca": "s_shear_tf", } diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 9b9180f551..3c332c2fec 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2625,10 +2625,10 @@ def plot_magnetics_info(axis, mfile_data, scan): "vs_plasma_ind_ramp" ].get_scan(scan) - sig_case = 1.0e-6 * mfile_data.data[f"s_shear_max_tf({i_tf_bucking})"].get_scan( + sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_max({i_tf_bucking})"].get_scan( scan ) - sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_max_tf({i_tf_bucking + 1})"].get_scan( + sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_tf_max({i_tf_bucking + 1})"].get_scan( scan ) diff --git a/process/sctfcoil.py b/process/sctfcoil.py index 95a7ae54d2..0c0627dc2e 100644 --- a/process/sctfcoil.py +++ b/process/sctfcoil.py @@ -1228,7 +1228,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_max_tf, + s_shear_tf_max, deflect, eyoung_axial, eyoung_trans, @@ -1362,7 +1362,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_max_tf, + s_shear_tf_max, deflect, eyoung_axial, eyoung_trans, @@ -3711,7 +3711,7 @@ def stresscl( sig_tf_vmises_max = np.zeros((n_tf_layer,)) # Von-Mises stress of the point of maximum shear stress of each layer [Pa] - s_shear_max_tf = np.zeros((n_tf_layer,)) + s_shear_tf_max = np.zeros((n_tf_layer,)) # Maximum shear stress, for the Tresca yield criterion of each layer [Pa] # If the CEA correction is addopted, the CEA corrected value is used @@ -4395,19 +4395,19 @@ def stresscl( # Maximum shear stress for the Tresca yield criterion (or CEA OOP correction) if i_tf_tresca == 1 and i_tf_sup == 1 and ii >= i_tf_bucking + 1: - s_shear_max_tf[ii] = s_shear_cea_tf_cond[ii_max] + s_shear_tf_max[ii] = s_shear_cea_tf_cond[ii_max] else: - s_shear_max_tf[ii] = s_shear_tf[ii_max] + s_shear_tf_max[ii] = s_shear_tf[ii_max] # Constraint equation for the Tresca yield criterion - sig_tf_wp = s_shear_max_tf[n_tf_bucking] + sig_tf_wp = s_shear_tf_max[n_tf_bucking] # Maximum assumed in the first graded layer if i_tf_bucking >= 1: - sig_tf_case = s_shear_max_tf[n_tf_bucking - 1] + sig_tf_case = s_shear_tf_max[n_tf_bucking - 1] if i_tf_bucking >= 2: - sig_tf_cs_bucked = s_shear_max_tf[0] + sig_tf_cs_bucked = s_shear_tf_max[0] # ---------------- return ( @@ -4415,7 +4415,7 @@ def stresscl( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_max_tf, + s_shear_tf_max, deflect, eyoung_axial, eyoung_trans, @@ -5837,7 +5837,7 @@ def out_stress( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_max_tf, + s_shear_tf_max, deflect, eyoung_axial, eyoung_trans, @@ -5978,12 +5978,12 @@ def table_format_arrays(a, mult=1, delim="\t\t"): if tfcoil_variables.i_tf_tresca == 1 and tfcoil_variables.i_tf_sup == 1: po.write( self.outfile, - f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_max_tf, 1e-6)}", + f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_max, 1e-6)}", ) else: po.write( self.outfile, - f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_max_tf, 1e-6)}", + f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_max, 1e-6)}", ) po.write(self.outfile, "") @@ -6055,15 +6055,15 @@ def table_format_arrays(a, mult=1, delim="\t\t"): po.ovarre( constants.mfile, f"Maximum shear stress for CEA Tresca yield criterion {ii + 1} (Pa)", - f"(s_shear_max_tf({ii + 1}))", - s_shear_max_tf[ii], + f"(s_shear_tf_max({ii + 1}))", + s_shear_tf_max[ii], ) else: po.ovarre( constants.mfile, f"Maximum shear stress for the Tresca yield criterion {ii + 1} (Pa)", - f"(s_shear_max_tf({ii + 1}))", - s_shear_max_tf[ii], + f"(s_shear_tf_max({ii + 1}))", + s_shear_tf_max[ii], ) # SIG_TF.json storage From d00a6265945584e785b4b7ce17eeecb72501b0c6 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 10:47:38 +0000 Subject: [PATCH 09/12] Modified s_shear on cs var name to fit naming convention better --- process/io/obsolete_vars.py | 2 +- process/pfcoil.py | 8 ++++---- source/fortran/constraint_equations.f90 | 12 ++++++------ source/fortran/pfcoil_variables.f90 | 4 ++-- tests/integration/ref_dicts.json | 6 +++--- tests/integration/test_pfcoil_int.py | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index d046da3581..14106c705b 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -214,7 +214,7 @@ "tfwmatmax": "temp_fw_max", "fw_channel_length": "len_fw_channel", "denw": None, - "s_tresca_oh": "s_shear_max_cs", + "s_tresca_oh": "s_shear_cs_max", "sig_tf_tresca_max": "s_shear_tf_max", "s_tresca_cond_cear": "s_shear_cea_tf_cond", "sig_tf_tresca": "s_shear_tf", diff --git a/process/pfcoil.py b/process/pfcoil.py index 13782808d1..d4420e4050 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -1111,13 +1111,13 @@ def ohcalc(self): areaspf = pfv.oh_steel_frac * pfv.areaoh if pfv.i_cs_stress == 1: - pfv.s_shear_max_cs = max( + pfv.s_shear_cs_max = max( abs(pf.sig_hoop - pf.sig_axial), abs(pf.sig_axial - 0.0e0), abs(0.0e0 - pf.sig_hoop), ) else: - pfv.s_shear_max_cs = max( + pfv.s_shear_cs_max = max( abs(pf.sig_hoop - 0.0e0), abs(0.0e0 - 0.0e0), abs(0.0e0 - pf.sig_hoop), @@ -2036,8 +2036,8 @@ def outpf(self): op.ovarre( self.outfile, "Maximum shear stress in CS steel for the Tresca criterion (Pa)", - "(s_shear_max_cs)", - pfv.s_shear_max_cs, + "(s_shear_cs_max)", + pfv.s_shear_cs_max, "OP ", ) op.ovarre( diff --git a/source/fortran/constraint_equations.f90 b/source/fortran/constraint_equations.f90 index d0795620de..05d60fa2e0 100755 --- a/source/fortran/constraint_equations.f90 +++ b/source/fortran/constraint_equations.f90 @@ -2755,12 +2755,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) !! Logic change during pre-factoring: err, symbol, units will be assigned only if present. !! foh_stress : input real : f-value for Tresca yield criterion in Central Solenoid !! alstroh : input real : allowable hoop stress in Central Solenoid structural material (Pa) - !! s_shear_max_cs : input real : Maximum shear stress coils/central solenoid (Pa) + !! s_shear_cs_max : input real : Maximum shear stress coils/central solenoid (Pa) !! sig_tf_cs_bucked : input real : Maximum shear stress in CS case at flux swing (no current in CS) !! can be significant for the bucked and weged design !! i_tf_bucking : input integer : switch for TF structure design use constraint_variables, only: foh_stress - use pfcoil_variables, only: alstroh, s_shear_max_cs + use pfcoil_variables, only: alstroh, s_shear_cs_max use tfcoil_variables, only: sig_tf_cs_bucked, i_tf_bucking use build_variables, only: tf_in_cs implicit none @@ -2772,12 +2772,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) ! bucked and wedged desing (see subroutine comment) if ( i_tf_bucking >= 2 .and. tf_in_cs == 0 ) then - tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_shear_max_cs, sig_tf_cs_bucked) - tmp_err = alstroh - max(s_shear_max_cs, sig_tf_cs_bucked) + tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_shear_cs_max, sig_tf_cs_bucked) + tmp_err = alstroh - max(s_shear_cs_max, sig_tf_cs_bucked) ! Free standing CS else - tmp_cc = 1.0d0 - foh_stress * alstroh / s_shear_max_cs - tmp_err = alstroh - s_shear_max_cs + tmp_cc = 1.0d0 - foh_stress * alstroh / s_shear_cs_max + tmp_err = alstroh - s_shear_cs_max end if tmp_con = alstroh diff --git a/source/fortran/pfcoil_variables.f90 b/source/fortran/pfcoil_variables.f90 index a0c2558b88..9c22920203 100644 --- a/source/fortran/pfcoil_variables.f90 +++ b/source/fortran/pfcoil_variables.f90 @@ -298,7 +298,7 @@ module pfcoil_variables !! the coil in units of minor radii from the major radius !! (r = rmajor + rref*rminor) - real(dp) :: s_shear_max_cs + real(dp) :: s_shear_cs_max !! Maximum shear stress (Tresca criterion) coils/central solenoid [MPa] real(dp) :: sigpfcalw @@ -489,7 +489,7 @@ subroutine init_pfcoil_variables rpf2 = -1.63D0 rref = (/7.0D0, 7.0D0, 7.0D0, & 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0/) - s_shear_max_cs = 0.0D0 + s_shear_cs_max = 0.0D0 sigpfcalw = 500.0D0 sigpfcf = 1.0D0 sxlg = 0.0D0 diff --git a/tests/integration/ref_dicts.json b/tests/integration/ref_dicts.json index e3c9deb7b0..1712fa43c4 100644 --- a/tests/integration/ref_dicts.json +++ b/tests/integration/ref_dicts.json @@ -4897,7 +4897,7 @@ "'not used'", "'not used'" ], - "s_shear_max_cs": 0.0, + "s_shear_cs_max": 0.0, "a_plasma_surface": 0.0, "a_plasma_surface_outboard": 0.0, "scafc": [ @@ -10587,7 +10587,7 @@ "s_k": "", "s_kref": "", "s_label": "", - "s_shear_max_cs": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", + "s_shear_cs_max": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", "a_plasma_surface": "plasma surface area", "a_plasma_surface_outboard": "outboard plasma surface area", "scafc": "", @@ -18986,7 +18986,7 @@ "rpf1", "rpf2", "rref", - "s_shear_max_cs", + "s_shear_cs_max", "sigpfcalw", "sigpfcf", "sxlg", diff --git a/tests/integration/test_pfcoil_int.py b/tests/integration/test_pfcoil_int.py index 5405cf0b80..84afc8eaa8 100644 --- a/tests/integration/test_pfcoil_int.py +++ b/tests/integration/test_pfcoil_int.py @@ -204,7 +204,7 @@ def test_ohcalc(monkeypatch, reinitialise_error_module, pfcoil): monkeypatch.setattr(pfv, "jcableoh_eof", 1.427e8) monkeypatch.setattr(pfv, "powohres", 0.0) monkeypatch.setattr(pfv, "rjohc0", 3.048e7) - monkeypatch.setattr(pfv, "s_shear_max_cs", 5.718e8) + monkeypatch.setattr(pfv, "s_shear_cs_max", 5.718e8) monkeypatch.setattr(pfv, "awpoh", 4.232) monkeypatch.setattr(pfv, "oh_steel_frac", 5.926e-1) monkeypatch.setattr(pfv, "bmaxoh0", 1.4e1) From 24aba4e6a3a4e2590e322430de8b3d7e78b66f21 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Thu, 6 Mar 2025 11:18:13 +0000 Subject: [PATCH 10/12] :art: Refactor stress section in standards.md for clarity and consistency --- documentation/proc-pages/development/standards.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/documentation/proc-pages/development/standards.md b/documentation/proc-pages/development/standards.md index bf5f22582d..2468eafc18 100644 --- a/documentation/proc-pages/development/standards.md +++ b/documentation/proc-pages/development/standards.md @@ -346,6 +346,12 @@ The unit declaration `_fpy` can be used to specify that it is the full-power yea --------------------- +##### Stress + +- Stresses should start with the `s_` prefix followed by the type of stress, for example `s_shear_`. + +--------------------- + ##### Variables representing fractions If a variable is intended to demonstrate a fraction of a value or distribution etc. Then it should start with the `f_` prefix. @@ -362,17 +368,12 @@ Variables used within constraint equations to scale iteration variables (f-value --------------------- -##### Length +### Variable Length Try to keep names to a sensible length while also keeping the name explicit and descriptive. --------------------- -##### Stress - -- Stresses should start with the `s_` prefix followed by the type of stress, for example `s_shear_`. - ---------------------- ### Physical Type From 44af0b437b27c40bc4732b816d0f96a696b84c4e Mon Sep 17 00:00:00 2001 From: ym1906 Date: Thu, 6 Mar 2025 16:50:25 +0000 Subject: [PATCH 11/12] Updated max to peak --- process/io/obsolete_vars.py | 4 ++-- process/io/plot_proc.py | 4 ++-- process/pfcoil.py | 8 +++---- process/sctfcoil.py | 32 ++++++++++++------------- source/fortran/constraint_equations.f90 | 12 +++++----- source/fortran/pfcoil_variables.f90 | 4 ++-- tests/integration/ref_dicts.json | 6 ++--- tests/integration/test_pfcoil_int.py | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 14106c705b..2458adc8ce 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -214,8 +214,8 @@ "tfwmatmax": "temp_fw_max", "fw_channel_length": "len_fw_channel", "denw": None, - "s_tresca_oh": "s_shear_cs_max", - "sig_tf_tresca_max": "s_shear_tf_max", + "s_tresca_oh": "s_shear_cs_peak", + "sig_tf_tresca_max": "s_shear_tf_peak", "s_tresca_cond_cear": "s_shear_cea_tf_cond", "sig_tf_tresca": "s_shear_tf", } diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 3c332c2fec..eeeeb9e4e0 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2625,10 +2625,10 @@ def plot_magnetics_info(axis, mfile_data, scan): "vs_plasma_ind_ramp" ].get_scan(scan) - sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_max({i_tf_bucking})"].get_scan( + sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking})"].get_scan( scan ) - sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_tf_max({i_tf_bucking + 1})"].get_scan( + sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking + 1})"].get_scan( scan ) diff --git a/process/pfcoil.py b/process/pfcoil.py index d4420e4050..651b7fab4e 100644 --- a/process/pfcoil.py +++ b/process/pfcoil.py @@ -1111,13 +1111,13 @@ def ohcalc(self): areaspf = pfv.oh_steel_frac * pfv.areaoh if pfv.i_cs_stress == 1: - pfv.s_shear_cs_max = max( + pfv.s_shear_cs_peak = max( abs(pf.sig_hoop - pf.sig_axial), abs(pf.sig_axial - 0.0e0), abs(0.0e0 - pf.sig_hoop), ) else: - pfv.s_shear_cs_max = max( + pfv.s_shear_cs_peak = max( abs(pf.sig_hoop - 0.0e0), abs(0.0e0 - 0.0e0), abs(0.0e0 - pf.sig_hoop), @@ -2036,8 +2036,8 @@ def outpf(self): op.ovarre( self.outfile, "Maximum shear stress in CS steel for the Tresca criterion (Pa)", - "(s_shear_cs_max)", - pfv.s_shear_cs_max, + "(s_shear_cs_peak)", + pfv.s_shear_cs_peak, "OP ", ) op.ovarre( diff --git a/process/sctfcoil.py b/process/sctfcoil.py index 0c0627dc2e..81f0c1e42e 100644 --- a/process/sctfcoil.py +++ b/process/sctfcoil.py @@ -1228,7 +1228,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_tf_max, + s_shear_tf_peak, deflect, eyoung_axial, eyoung_trans, @@ -1362,7 +1362,7 @@ def sctfcoil(self, output: bool): sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_tf_max, + s_shear_tf_peak, deflect, eyoung_axial, eyoung_trans, @@ -3711,7 +3711,7 @@ def stresscl( sig_tf_vmises_max = np.zeros((n_tf_layer,)) # Von-Mises stress of the point of maximum shear stress of each layer [Pa] - s_shear_tf_max = np.zeros((n_tf_layer,)) + s_shear_tf_peak = np.zeros((n_tf_layer,)) # Maximum shear stress, for the Tresca yield criterion of each layer [Pa] # If the CEA correction is addopted, the CEA corrected value is used @@ -4395,19 +4395,19 @@ def stresscl( # Maximum shear stress for the Tresca yield criterion (or CEA OOP correction) if i_tf_tresca == 1 and i_tf_sup == 1 and ii >= i_tf_bucking + 1: - s_shear_tf_max[ii] = s_shear_cea_tf_cond[ii_max] + s_shear_tf_peak[ii] = s_shear_cea_tf_cond[ii_max] else: - s_shear_tf_max[ii] = s_shear_tf[ii_max] + s_shear_tf_peak[ii] = s_shear_tf[ii_max] # Constraint equation for the Tresca yield criterion - sig_tf_wp = s_shear_tf_max[n_tf_bucking] + sig_tf_wp = s_shear_tf_peak[n_tf_bucking] # Maximum assumed in the first graded layer if i_tf_bucking >= 1: - sig_tf_case = s_shear_tf_max[n_tf_bucking - 1] + sig_tf_case = s_shear_tf_peak[n_tf_bucking - 1] if i_tf_bucking >= 2: - sig_tf_cs_bucked = s_shear_tf_max[0] + sig_tf_cs_bucked = s_shear_tf_peak[0] # ---------------- return ( @@ -4415,7 +4415,7 @@ def stresscl( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_tf_max, + s_shear_tf_peak, deflect, eyoung_axial, eyoung_trans, @@ -5837,7 +5837,7 @@ def out_stress( sig_tf_t_max, sig_tf_z_max, sig_tf_vmises_max, - s_shear_tf_max, + s_shear_tf_peak, deflect, eyoung_axial, eyoung_trans, @@ -5978,12 +5978,12 @@ def table_format_arrays(a, mult=1, delim="\t\t"): if tfcoil_variables.i_tf_tresca == 1 and tfcoil_variables.i_tf_sup == 1: po.write( self.outfile, - f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_max, 1e-6)}", + f" Shear (CEA Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_peak, 1e-6)}", ) else: po.write( self.outfile, - f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_max, 1e-6)}", + f" Shear (Tresca) \t\t\t (MPa) \t\t {table_format_arrays(s_shear_tf_peak, 1e-6)}", ) po.write(self.outfile, "") @@ -6055,15 +6055,15 @@ def table_format_arrays(a, mult=1, delim="\t\t"): po.ovarre( constants.mfile, f"Maximum shear stress for CEA Tresca yield criterion {ii + 1} (Pa)", - f"(s_shear_tf_max({ii + 1}))", - s_shear_tf_max[ii], + f"(s_shear_tf_peak({ii + 1}))", + s_shear_tf_peak[ii], ) else: po.ovarre( constants.mfile, f"Maximum shear stress for the Tresca yield criterion {ii + 1} (Pa)", - f"(s_shear_tf_max({ii + 1}))", - s_shear_tf_max[ii], + f"(s_shear_tf_peak({ii + 1}))", + s_shear_tf_peak[ii], ) # SIG_TF.json storage diff --git a/source/fortran/constraint_equations.f90 b/source/fortran/constraint_equations.f90 index 05d60fa2e0..db0d360329 100755 --- a/source/fortran/constraint_equations.f90 +++ b/source/fortran/constraint_equations.f90 @@ -2755,12 +2755,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) !! Logic change during pre-factoring: err, symbol, units will be assigned only if present. !! foh_stress : input real : f-value for Tresca yield criterion in Central Solenoid !! alstroh : input real : allowable hoop stress in Central Solenoid structural material (Pa) - !! s_shear_cs_max : input real : Maximum shear stress coils/central solenoid (Pa) + !! s_shear_cs_peak : input real : Maximum shear stress coils/central solenoid (Pa) !! sig_tf_cs_bucked : input real : Maximum shear stress in CS case at flux swing (no current in CS) !! can be significant for the bucked and weged design !! i_tf_bucking : input integer : switch for TF structure design use constraint_variables, only: foh_stress - use pfcoil_variables, only: alstroh, s_shear_cs_max + use pfcoil_variables, only: alstroh, s_shear_cs_peak use tfcoil_variables, only: sig_tf_cs_bucked, i_tf_bucking use build_variables, only: tf_in_cs implicit none @@ -2772,12 +2772,12 @@ subroutine constraint_eqn_072(tmp_cc, tmp_con, tmp_err, tmp_symbol, tmp_units) ! bucked and wedged desing (see subroutine comment) if ( i_tf_bucking >= 2 .and. tf_in_cs == 0 ) then - tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_shear_cs_max, sig_tf_cs_bucked) - tmp_err = alstroh - max(s_shear_cs_max, sig_tf_cs_bucked) + tmp_cc = 1.0d0 - foh_stress * alstroh / max(s_shear_cs_peak, sig_tf_cs_bucked) + tmp_err = alstroh - max(s_shear_cs_peak, sig_tf_cs_bucked) ! Free standing CS else - tmp_cc = 1.0d0 - foh_stress * alstroh / s_shear_cs_max - tmp_err = alstroh - s_shear_cs_max + tmp_cc = 1.0d0 - foh_stress * alstroh / s_shear_cs_peak + tmp_err = alstroh - s_shear_cs_peak end if tmp_con = alstroh diff --git a/source/fortran/pfcoil_variables.f90 b/source/fortran/pfcoil_variables.f90 index 9c22920203..c45397e930 100644 --- a/source/fortran/pfcoil_variables.f90 +++ b/source/fortran/pfcoil_variables.f90 @@ -298,7 +298,7 @@ module pfcoil_variables !! the coil in units of minor radii from the major radius !! (r = rmajor + rref*rminor) - real(dp) :: s_shear_cs_max + real(dp) :: s_shear_cs_peak !! Maximum shear stress (Tresca criterion) coils/central solenoid [MPa] real(dp) :: sigpfcalw @@ -489,7 +489,7 @@ subroutine init_pfcoil_variables rpf2 = -1.63D0 rref = (/7.0D0, 7.0D0, 7.0D0, & 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0, 7.0D0/) - s_shear_cs_max = 0.0D0 + s_shear_cs_peak = 0.0D0 sigpfcalw = 500.0D0 sigpfcf = 1.0D0 sxlg = 0.0D0 diff --git a/tests/integration/ref_dicts.json b/tests/integration/ref_dicts.json index 1712fa43c4..a97ec48667 100644 --- a/tests/integration/ref_dicts.json +++ b/tests/integration/ref_dicts.json @@ -4897,7 +4897,7 @@ "'not used'", "'not used'" ], - "s_shear_cs_max": 0.0, + "s_shear_cs_peak": 0.0, "a_plasma_surface": 0.0, "a_plasma_surface_outboard": 0.0, "scafc": [ @@ -10587,7 +10587,7 @@ "s_k": "", "s_kref": "", "s_label": "", - "s_shear_cs_max": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", + "s_shear_cs_peak": "Maximum shear stress (Tresca criterion) coils/central solenoid [MPa]", "a_plasma_surface": "plasma surface area", "a_plasma_surface_outboard": "outboard plasma surface area", "scafc": "", @@ -18986,7 +18986,7 @@ "rpf1", "rpf2", "rref", - "s_shear_cs_max", + "s_shear_cs_peak", "sigpfcalw", "sigpfcf", "sxlg", diff --git a/tests/integration/test_pfcoil_int.py b/tests/integration/test_pfcoil_int.py index 84afc8eaa8..393bf4d073 100644 --- a/tests/integration/test_pfcoil_int.py +++ b/tests/integration/test_pfcoil_int.py @@ -204,7 +204,7 @@ def test_ohcalc(monkeypatch, reinitialise_error_module, pfcoil): monkeypatch.setattr(pfv, "jcableoh_eof", 1.427e8) monkeypatch.setattr(pfv, "powohres", 0.0) monkeypatch.setattr(pfv, "rjohc0", 3.048e7) - monkeypatch.setattr(pfv, "s_shear_cs_max", 5.718e8) + monkeypatch.setattr(pfv, "s_shear_cs_peak", 5.718e8) monkeypatch.setattr(pfv, "awpoh", 4.232) monkeypatch.setattr(pfv, "oh_steel_frac", 5.926e-1) monkeypatch.setattr(pfv, "bmaxoh0", 1.4e1) From e050985fe6151fab0e00d79e3f770219cbba9671 Mon Sep 17 00:00:00 2001 From: ym1906 Date: Fri, 7 Mar 2025 17:10:46 +0000 Subject: [PATCH 12/12] ruff fix --- process/io/plot_proc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index eeeeb9e4e0..68c3558e06 100644 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -2628,9 +2628,9 @@ def plot_magnetics_info(axis, mfile_data, scan): sig_case = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking})"].get_scan( scan ) - sig_cond = 1.0e-6 * mfile_data.data[f"s_shear_tf_peak({i_tf_bucking + 1})"].get_scan( - scan - ) + sig_cond = 1.0e-6 * mfile_data.data[ + f"s_shear_tf_peak({i_tf_bucking + 1})" + ].get_scan(scan) if i_tf_sup == 1: data = [