From d7844a7c8d5984a9b1955097d16db648eb8ba47c Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:18:58 +0000 Subject: [PATCH 1/2] fix wrongly reporting multiple obsolete vars when only one is present in input file - add missing obsolete variables to obsolete_vars.py - add ValueError to report obsolete variables to replace STOP 1 --- process/io/obsolete_vars.py | 210 ++++++++++++++++++++++-------------- process/main.py | 49 ++++++--- source/fortran/input.f90 | 165 +--------------------------- 3 files changed, 167 insertions(+), 257 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 9c702c7f5d..589fbb2757 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -6,90 +6,136 @@ of that variable, based on this dictionary. This should make migration of old input files easier, and variable renaming less painful. -Each key is an obsolete var, the value is either the new var name or None if the -var is deprecated. +Each key is an obsolete var, the value is a list with first entry being either the new var name or None if the +var is deprecated, and the second entry being an optional helpful message. Note: this is now relied upon by Blueprint, pending implementing a proper API. """ OBS_VARS = { - "snull": "i_single_null", - "tfno": "n_tf", - "itfsup": "i_tf_sup", - "r_tf_inleg_mid": "r_tf_inboard_mid", - "rtot": "r_tf_outboard_mid", - "a_tf_inboard": "tfareain", - "r_tf_inleg_in": "r_tf_inleg_in", - "r_tf_inleg_out": "r_tf_inleg_out", - "a_tf_wp": "awpc", - "sigttf": "sig_tf_t", - "sigtcon": "sig_tf_t", - "sigrtf": "sig_tf_r", - "sigrcon": "sig_tf_r", - "sigvert": "sig_tf_z", - "sig_vmises_case": "sig_tf_vmises", - "sig_vmises_cond": "sig_tf_vmises", - "sig_tresca_case": "sig_tf_treca", - "sig_tresca_cond": "sig_tf_treca", - "sigver": None, - "sigrad": None, - "poisson": "poisson_steel", - "eywp": "eyoung_winding", - "eyins": "eyoung_ins", - "eystl": "eyoung_steel", - "isumattf": "i_tf_sc_mat", - "turnstf": "n_tf_turn", - "awptf": "a_tf_wp", - "dr_tf_case_in": "thkcas", - "f_tf_case_out": "casthi_fraction", - "dr_tf_case_out": "casthi", - "eyoung_reinforced_al": "eyoung_nibron", - "thkwp": "dr_tf_wp", - "leni": "t_cable", - "leno": "t_turn", - "conductor_width": "t_conductor", - "deltf": "tftsgap", - "ddwi": "d_vv_out", - "pnuccp": "pnuc_cp", - "nuc_pow_dep_tot": "pnuc_tot_blk_sector", - "t_turn": "t_turn_tf", - "ratecdol": "discount_rate", - "strtf1": "sig_tf_case", - "strtf2": "sig_tf_wp", - "alstrtf": ["sig_tf_case_max", "sig_tf_wp_max"], - "strtf0": "sig_tf_cs_bucked", - "eyoung_winding": ["eyoung_cond_axial", "eyoung_cond_trans"], - "i_tf_plane_stress": "i_tf_stress_model", - "windstrain": "strncon_tf", - "eyzwp": "eyoung_wp_z_eff", - "strncon_cs": "str_cs_con_res", - "strncon_pf": "str_pf_con_res", - "strncon_tf": "str_tf_con_res", - "i_strain_wp": "i_str_wp", - "strain_wp_max": "str_wp_max", - "strain_wp": "str_wp", - "fstrain_wp": "fstr_wp", - "rad_fraction": "rad_fraction_total", - "pcoreradmw": "pinnerzoneradmw", - "pedgeradmw": "pouterzoneradmw", - "rad_fraction_core": "rad_fraction_LCFS", - "thshield": ["thshield_ib", "thshield_ob", "thshield_vb"], - "igeom": None, - "fgamp": None, - "divleg_profile_inner": None, - "divleg_profile_outer": None, - "iprimnloss": None, - "rho_ecrh": None, - "ifispact": None, - "fmsbc": None, - "fmsbl": None, - "fmsdwe": None, - "fmsdwi": None, - "fmsfw": None, - "fmsoh": None, - "fmssh": None, - "fmstf": None, - "quench_detection_ef": None, - "farc4tf": None, - "impvar": None, - "fimpvar": None, + "snull": ["i_single_null"], + "tfno": ["n_tf"], + "itfsup": ["i_tf_sup"], + "r_tf_inleg_mid": ["r_tf_inboard_mid"], + "rtot": ["r_tf_outboard_mid"], + "a_tf_inboard": ["tfareain"], + "r_tf_inleg_in": ["r_tf_inleg_in"], + "r_tf_inleg_out": ["r_tf_inleg_out"], + "a_tf_wp": ["awpc"], + "sigttf": ["sig_tf_t"], + "sigtcon": ["sig_tf_t"], + "sigrtf": ["sig_tf_r"], + "sigrcon": ["sig_tf_r"], + "sigvert": ["sig_tf_z"], + "sig_vmises_case": ["sig_tf_vmises"], + "sig_vmises_cond": ["sig_tf_vmises"], + "sig_tresca_case": ["sig_tf_treca"], + "sig_tresca_cond": ["sig_tf_treca"], + "sigver": [None], + "sigrad": [None], + "poisson": ["poisson_steel"], + "eywp": ["eyoung_winding"], + "eyins": ["eyoung_ins"], + "eystl": ["eyoung_steel"], + "isumattf": ["i_tf_sc_mat"], + "turnstf": ["n_tf_turn"], + "awptf": ["a_tf_wp"], + "dr_tf_case_in": ["thkcas"], + "f_tf_case_out": ["casthi_fraction"], + "dr_tf_case_out": ["casthi"], + "eyoung_reinforced_al": ["eyoung_nibron"], + "thkwp": ["dr_tf_wp"], + "leni": ["t_cable"], + "leno": ["t_turn"], + "conductor_width": ["t_conductor"], + "deltf": ["tftsgap"], + "ddwi": ["d_vv_out"], + "pnuccp": ["pnuc_cp"], + "nuc_pow_dep_tot": ["pnuc_tot_blk_sector"], + "t_turn": ["t_turn_tf"], + "ratecdol": ["discount_rate"], + "strtf1": ["sig_tf_case"], + "strtf2": ["sig_tf_wp"], + "alstrtf": [["sig_tf_case_max", "sig_tf_wp_max"]], + "strtf0": ["sig_tf_cs_bucked"], + "eyoung_winding": [["eyoung_cond_axial", "eyoung_cond_trans"]], + "i_tf_plane_stress": ["i_tf_stress_model"], + "windstrain": ["strncon_tf"], + "eyzwp": ["eyoung_wp_z_eff"], + "strncon_cs": ["str_cs_con_res"], + "strncon_pf": ["str_pf_con_res"], + "strncon_tf": ["str_tf_con_res"], + "i_strain_wp": ["i_str_wp"], + "strain_wp_max": ["str_wp_max"], + "strain_wp": ["str_wp"], + "fstrain_wp": ["fstr_wp"], + "rad_fraction": ["rad_fraction_total"], + "pcoreradmw": ["pinnerzoneradmw"], + "pedgeradmw": ["pouterzoneradmw"], + "rad_fraction_core": ["rad_fraction_LCFS"], + "thshield": [["thshield_ib", "thshield_ob", "thshield_vb"]], + "igeom": [None], + "fgamp": [None], + "divleg_profile_inner": [None], + "divleg_profile_outer": [None], + "iprimnloss": [None], + "rho_ecrh": [None], + "ifispact": [None], + "fmsbc": [None], + "fmsbl": [None], + "fmsdwe": [None], + "fmsdwi": [None], + "fmsfw": [None], + "fmsoh": [None], + "fmssh": [None], + "fmstf": [None], + "quench_detection_ef": [None], + "farc4tf": [None], + "impvar": [None], + "fimpvar": [None], + "sigvvall": ["max_vv_stress"], + "ftaucq": ["fmaxvvstress"], + "fradmin": [None], + "ftr": ["ftrit"], + "iculdl": ["idensl", "(use IDENSL=3 for equivalent model to ICULDL=0). "], + "iiter": [None], + "ires": [None], + "fjtfc": [None], + "bcylth": [None], + "itfmod": [None], + "jcrit_model": [None], + "jcritsc": [None], + "fcohbof": [None], + "fvolbi": ["fhole"], + "fvolbo": ["fhole"], + "fvolcry": [None], + "idhe3": ["fhe3"], + "blnktth": [ + None, + "WARNING. BLNKTTH is now always calculated rather than input - please remove it from the input file", + ], } +stellarator_list = [ + "target_spread", + "lambda_q_omp", + "lcon_factor", + "netau_sol", + "kallenbach_switch", + "kallenbach_tests", + "kallenbach_test_option", + "kallenbach_scan_switch", + "kallenbach_scan_var", + "kallenbach_scan_start", + "kallenbach_scan_end", + "kallenbach_scan_num", + "targetangle", + "ttarget", + "qtargettotal", + "impurity_enrichment", + "fractionwidesol", + "abserr_sol", + "relerr_sol", + "mach0", + "neratio", +] +stellarator_message = "The Stellarator model is currently not included in PROCESS. See issue #1854 for more information on the use of Stellarators. " +OBS_VARS.update(dict.fromkeys(stellarator_list, [None, stellarator_message])) diff --git a/process/main.py b/process/main.py index daeb38f89c..16212f3c93 100644 --- a/process/main.py +++ b/process/main.py @@ -521,21 +521,44 @@ def validate_input(self): variables = line.strip().split(sep, 1)[0] variables_in_in_dat.append(variables) - obs_vars = [] - replace_hints = [] + obs_vars_in_in_dat = [] + replace_hints = {} for var in variables_in_in_dat: - new_var = obsolete_variables.get(var) - if new_var: - obs_vars.append(var) - replace_hints.append(new_var) - - if len(replace_hints) > 0: - print( - "The IN.DAT file contains obsolete variables from the OBS_VARS dictionary." - ) - print( - f"The obsolete variables in your IN.DAT file are: {obs_vars}. Please change them to the following corresponding new variable(s) before continuing: {replace_hints}." + if var in obsolete_variables: + obs_vars_in_in_dat.append(var) + new_var = obsolete_variables.get(var) + replace_hints[var] = new_var + + if len(obs_vars_in_in_dat) > 0: + message = ( + "The IN.DAT file contains obsolete variables from the OBS_VARS dictionary. The obsolete variables in your IN.DAT file are: " + f"{obs_vars_in_in_dat}. " + "Either remove these or replace them with their updated variable names. " ) + for var in obs_vars_in_in_dat: + if replace_hints[var][0] is None: + message = ( + message + + "\n \n " + + var + + " is an obsolete variable and does not have a replacement. " + ) + if len(replace_hints[var]) == 2: + message = message + str(replace_hints[var][1]) + if replace_hints[var][0] is not None: + message = ( + message + + "\n \n " + + var + + " is an obsolete variable and needs to be replaced by " + + str(replace_hints[var][0]) + + ". " + ) + if len(replace_hints[var]) == 2: + message = message + str(replace_hints[var][1]) + + raise ValueError(message) + else: print("The IN.DAT file does not contain any obsolete variables.") diff --git a/source/fortran/input.f90 b/source/fortran/input.f90 index f7f4eafe08..6a42674e85 100644 --- a/source/fortran/input.f90 +++ b/source/fortran/input.f90 @@ -601,27 +601,9 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('fnesep') call parse_real_variable('fnesep', fnesep, 0.1D0, 2.0D1, & 'f-value for Eich critical separatrix density') - case ('fradmin') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FRADMIN is now obsolete -' - write(outfile,*) 'please remove it from the input file.' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('ftaulimit') call parse_real_variable('ftaulimit', ftaulimit, 0.001D0, 1.0D0, & 'f-value for lower limit on taup/taueff the ratio of alpha particle to energy confinement times') - - case ('ftr') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FTR is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '(use FTRIT instead).' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('ftrit') call parse_real_variable('ftrit', ftrit, 0.0D0, 1.0D0, & 'Tritium fuel fraction') @@ -646,30 +628,12 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('iculbl') call parse_int_variable('iculbl', iculbl, 0, 3, & 'Switch for beta limit scaling') - case ('iculdl') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'ICULDL is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '(use IDENSL=3 for equivalent model to ICULDL=0).' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('icurr') call parse_int_variable('icurr', icurr, 1, 9, & 'Switch for plasma current scaling') case ('idensl') call parse_int_variable('idensl', idensl, 1, 7, & 'Switch for enforced density limit') - case ('idhe3') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'IDHE3 is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '(use fhe3 to adjust 3He fuel fraction).' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('idia') call parse_int_variable('idia', idia, 0, 2, & 'Switch for diamagnetic scaling') @@ -682,14 +646,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('iinvqd') call parse_int_variable('iinvqd', iinvqd, 0, 1, & 'Switch for inverse quadrature') - case ('iiter') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'IITER is now obsolete -' - write(outfile,*) 'please remove it from the input file.' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('ilhthresh') call parse_int_variable('ilhthresh', ilhthresh, 1, 21, & 'Switch for L-H power threshold to enforce') @@ -706,14 +662,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('iradloss') call parse_int_variable('iradloss', iradloss, 0, 2, & 'Switch for radiation loss term inclusion in power balance') - case ('ires') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'IRES is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('isc') call parse_int_variable('isc', isc, 1, ipnlaws, & 'Switch for confinement scaling law') @@ -886,14 +834,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('fjohc0') call parse_real_variable('fjohc0', fjohc0, 0.001D0, 10.0D0, & 'F-value for Central Solenoid current at BOP') - case ('fjtfc') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FJTFC is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('fhldiv') call parse_real_variable('fhldiv', fhldiv, 0.001D0, 10.0D0, & 'F-value for divertor heat load') @@ -984,14 +924,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('fstr_wp') call parse_real_variable('fstr_wp', fstr_wp, 1.0D-9, 10.0D0, & 'F-value for TF coil strain absolute value') - case ('ftaucq') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'ftaucq is now obsolete - (use fmaxvvstress)' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('fmaxvvstress') call parse_real_variable('fmaxvvstress', fmaxvvstress, 0.001D0, 1.0D0, & 'F-value for maximum permitted stress of the VV') @@ -1152,7 +1084,7 @@ subroutine parse_input_file(in_file,out_file,show_changes) 'Cyclotron harmonic frequency number') case ('wave_mode') call parse_int_variable('wave_mode', wave_mode, 0, 1, & - 'Cyclotron wave mode switch') + 'Cyclotron wave mode switch') case ('xi_ebw') call parse_real_variable('xi_ebw', xi_ebw, 0.0D0, 1.0D0, & 'User input EBW scaling for Plasma Heating') @@ -1213,18 +1145,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) ! Divertor settings: 2016 Kallenbach model (2016/07/04) - case ('target_spread', 'lambda_q_omp', 'lcon_factor', 'netau_sol', 'kallenbach_switch', & - 'kallenbach_tests', 'kallenbach_test_option', 'kallenbach_scan_switch', 'kallenbach_scan_var', & - 'kallenbach_scan_start', 'kallenbach_scan_end', 'kallenbach_scan_num', 'targetangle', 'ttarget', & - 'qtargettotal', 'impurity_enrichment', 'fractionwidesol', 'abserr_sol', 'relerr_sol', 'mach0', & - 'neratio') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'The Stellarator model is currently not included in PROCESS.' - write(outfile,*) 'See issue #1853 for more information on the use of Stellarators.' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. ! See HTS coil module for PROCESS.docx !case ('cable_helium_fraction') @@ -1389,22 +1309,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) call parse_real_variable('blnkoth', blnkoth, 0.0D0, 10.0D0, & 'Outboard blanket thickness (m)') end if - case ('blnktth') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'WARNING. BLNKTTH is now always calculated rather than input -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. - case ('bcylth') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'ERROR. BCYLTH is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('bore') call parse_real_variable('bore', bore, 0.0D0, 50.0D0, & 'Machine bore (m)') @@ -1742,15 +1646,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) write(outfile,*) '**********' write(outfile,*) ' ' end if - case ('itfmod') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'ITFMOD is now obsolete -' - write(outfile,*) 'please remove it from the input file' - ! write(outfile,*) 'and replace it with TFC_MODEL' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('i_tf_sup') call parse_int_variable('i_tf_sup', i_tf_sup, 0, 2, & 'Switch for TF coil type') @@ -1769,22 +1664,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('jbus') call parse_real_variable('jbus', jbus, 1.0D4, 1.0D8, & 'TF coil bus current density (A/m2)') - case ('jcrit_model') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'JCRIT_MODEL is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. - case ('jcritsc') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'JCRITSC is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('n_pancake') call parse_int_variable('n_pancake', n_pancake, 1, 100, & 'Number of pancakes in TF coil (i_tf_turns_integer=1)') @@ -1818,14 +1697,7 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('ripmax') call parse_real_variable('ripmax', ripmax, 0.1D0, 100.0D0, & 'Max allowed ripple ampl. at plasma edge (%)') - case ('sigvvall') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'sigvvall is now obsolete - (use max_vv_stress)' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. + case ('theta1_coil') call parse_real_variable('theta1_coil', theta1_coil, 1.0D-1, 6.0D1, & 'The angle of the outboard arc forming the TF coil current center line (deg)') @@ -1969,14 +1841,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('etapsu') call parse_real_variable('etapsu', etapsu, 0.0D0, 1.0D0, & 'Efficiency of ohmic heating') - case ('fcohbof') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FCOHBOF is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('fcohbop') call parse_real_variable('fcohbop', fcohbop, 0.0D0, 1.0D0, & 'Central Solenoid J ratio : BOP/EOF') @@ -2293,30 +2157,6 @@ subroutine parse_input_file(in_file,out_file,show_changes) case ('fhole') call parse_real_variable('fhole', fhole, 0.0D0, 1.0D0, & 'Hole area fraction') - case ('fvolbi') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FVOLBI is now obsolete - (use FHOLE)' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. - case ('fvolbo') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FVOLBO is now obsolete - (use FHOLE)' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. - case ('fvolcry') - write(outfile,*) ' ' - write(outfile,*) '**********' - write(outfile,*) 'FVOLCRY is now obsolete -' - write(outfile,*) 'please remove it from the input file' - write(outfile,*) '**********' - write(outfile,*) ' ' - obsolete_var = .true. case ('fvoldw') call parse_real_variable('fvoldw', fvoldw, 0.0D0, 10.0D0, & 'Fudge factor for vacuum vessel volume') @@ -3676,6 +3516,7 @@ subroutine parse_input_file(in_file,out_file,show_changes) write(*,*) error_message write(*,*) 'Error occurred at this line in the IN.DAT file: ', lineno write(*,*) line + obsolete_var = .false. error = .True. end if From c4ac209124c188b1f4eb824c9fdd1272eb1ad8d5 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Fri, 26 Jan 2024 13:59:31 +0000 Subject: [PATCH 2/2] Add help message dict to obsolete_vars.py, improve logic of validate_input ValueError --- process/io/obsolete_vars.py | 218 ++++++++++++++++++------------------ process/main.py | 31 ++--- 2 files changed, 119 insertions(+), 130 deletions(-) diff --git a/process/io/obsolete_vars.py b/process/io/obsolete_vars.py index 589fbb2757..fce95520d2 100644 --- a/process/io/obsolete_vars.py +++ b/process/io/obsolete_vars.py @@ -1,4 +1,4 @@ -"""Dict of obsolete vars and their new names for the input validator. +"""Dict of obsolete vars and their new names for the input validator, and dict of help messages for certain obsolete vars. This is used by the input_validator module to find any obsolete variables in the input file (which have since been renamed in the current version of the source). @@ -6,115 +6,118 @@ of that variable, based on this dictionary. This should make migration of old input files easier, and variable renaming less painful. -Each key is an obsolete var, the value is a list with first entry being either the new var name or None if the -var is deprecated, and the second entry being an optional helpful message. +Each key is an obsolete var, the value is either the new var name or None if the +var is deprecated. Note: this is now relied upon by Blueprint, pending implementing a proper API. """ OBS_VARS = { - "snull": ["i_single_null"], - "tfno": ["n_tf"], - "itfsup": ["i_tf_sup"], - "r_tf_inleg_mid": ["r_tf_inboard_mid"], - "rtot": ["r_tf_outboard_mid"], - "a_tf_inboard": ["tfareain"], - "r_tf_inleg_in": ["r_tf_inleg_in"], - "r_tf_inleg_out": ["r_tf_inleg_out"], - "a_tf_wp": ["awpc"], - "sigttf": ["sig_tf_t"], - "sigtcon": ["sig_tf_t"], - "sigrtf": ["sig_tf_r"], - "sigrcon": ["sig_tf_r"], - "sigvert": ["sig_tf_z"], - "sig_vmises_case": ["sig_tf_vmises"], - "sig_vmises_cond": ["sig_tf_vmises"], - "sig_tresca_case": ["sig_tf_treca"], - "sig_tresca_cond": ["sig_tf_treca"], - "sigver": [None], - "sigrad": [None], - "poisson": ["poisson_steel"], - "eywp": ["eyoung_winding"], - "eyins": ["eyoung_ins"], - "eystl": ["eyoung_steel"], - "isumattf": ["i_tf_sc_mat"], - "turnstf": ["n_tf_turn"], - "awptf": ["a_tf_wp"], - "dr_tf_case_in": ["thkcas"], - "f_tf_case_out": ["casthi_fraction"], - "dr_tf_case_out": ["casthi"], - "eyoung_reinforced_al": ["eyoung_nibron"], - "thkwp": ["dr_tf_wp"], - "leni": ["t_cable"], - "leno": ["t_turn"], - "conductor_width": ["t_conductor"], - "deltf": ["tftsgap"], - "ddwi": ["d_vv_out"], - "pnuccp": ["pnuc_cp"], - "nuc_pow_dep_tot": ["pnuc_tot_blk_sector"], - "t_turn": ["t_turn_tf"], - "ratecdol": ["discount_rate"], - "strtf1": ["sig_tf_case"], - "strtf2": ["sig_tf_wp"], - "alstrtf": [["sig_tf_case_max", "sig_tf_wp_max"]], - "strtf0": ["sig_tf_cs_bucked"], - "eyoung_winding": [["eyoung_cond_axial", "eyoung_cond_trans"]], - "i_tf_plane_stress": ["i_tf_stress_model"], - "windstrain": ["strncon_tf"], - "eyzwp": ["eyoung_wp_z_eff"], - "strncon_cs": ["str_cs_con_res"], - "strncon_pf": ["str_pf_con_res"], - "strncon_tf": ["str_tf_con_res"], - "i_strain_wp": ["i_str_wp"], - "strain_wp_max": ["str_wp_max"], - "strain_wp": ["str_wp"], - "fstrain_wp": ["fstr_wp"], - "rad_fraction": ["rad_fraction_total"], - "pcoreradmw": ["pinnerzoneradmw"], - "pedgeradmw": ["pouterzoneradmw"], - "rad_fraction_core": ["rad_fraction_LCFS"], - "thshield": [["thshield_ib", "thshield_ob", "thshield_vb"]], - "igeom": [None], - "fgamp": [None], - "divleg_profile_inner": [None], - "divleg_profile_outer": [None], - "iprimnloss": [None], - "rho_ecrh": [None], - "ifispact": [None], - "fmsbc": [None], - "fmsbl": [None], - "fmsdwe": [None], - "fmsdwi": [None], - "fmsfw": [None], - "fmsoh": [None], - "fmssh": [None], - "fmstf": [None], - "quench_detection_ef": [None], - "farc4tf": [None], - "impvar": [None], - "fimpvar": [None], - "sigvvall": ["max_vv_stress"], - "ftaucq": ["fmaxvvstress"], - "fradmin": [None], - "ftr": ["ftrit"], - "iculdl": ["idensl", "(use IDENSL=3 for equivalent model to ICULDL=0). "], - "iiter": [None], - "ires": [None], - "fjtfc": [None], - "bcylth": [None], - "itfmod": [None], - "jcrit_model": [None], - "jcritsc": [None], - "fcohbof": [None], - "fvolbi": ["fhole"], - "fvolbo": ["fhole"], - "fvolcry": [None], - "idhe3": ["fhe3"], - "blnktth": [ - None, - "WARNING. BLNKTTH is now always calculated rather than input - please remove it from the input file", - ], + "snull": "i_single_null", + "tfno": "n_tf", + "itfsup": "i_tf_sup", + "r_tf_inleg_mid": "r_tf_inboard_mid", + "rtot": "r_tf_outboard_mid", + "a_tf_inboard": "tfareain", + "r_tf_inleg_in": "r_tf_inleg_in", + "r_tf_inleg_out": "r_tf_inleg_out", + "a_tf_wp": "awpc", + "sigttf": "sig_tf_t", + "sigtcon": "sig_tf_t", + "sigrtf": "sig_tf_r", + "sigrcon": "sig_tf_r", + "sigvert": "sig_tf_z", + "sig_vmises_case": "sig_tf_vmises", + "sig_vmises_cond": "sig_tf_vmises", + "sig_tresca_case": "sig_tf_treca", + "sig_tresca_cond": "sig_tf_treca", + "sigver": None, + "sigrad": None, + "poisson": "poisson_steel", + "eywp": "eyoung_winding", + "eyins": "eyoung_ins", + "eystl": "eyoung_steel", + "isumattf": "i_tf_sc_mat", + "turnstf": "n_tf_turn", + "awptf": "a_tf_wp", + "dr_tf_case_in": "thkcas", + "f_tf_case_out": "casthi_fraction", + "dr_tf_case_out": "casthi", + "eyoung_reinforced_al": "eyoung_nibron", + "thkwp": "dr_tf_wp", + "leni": "t_cable", + "leno": "t_turn", + "conductor_width": "t_conductor", + "deltf": "tftsgap", + "ddwi": "d_vv_out", + "pnuccp": "pnuc_cp", + "nuc_pow_dep_tot": "pnuc_tot_blk_sector", + "t_turn": "t_turn_tf", + "ratecdol": "discount_rate", + "strtf1": "sig_tf_case", + "strtf2": "sig_tf_wp", + "alstrtf": ["sig_tf_case_max", "sig_tf_wp_max"], + "strtf0": "sig_tf_cs_bucked", + "eyoung_winding": ["eyoung_cond_axial", "eyoung_cond_trans"], + "i_tf_plane_stress": "i_tf_stress_model", + "windstrain": "strncon_tf", + "eyzwp": "eyoung_wp_z_eff", + "strncon_cs": "str_cs_con_res", + "strncon_pf": "str_pf_con_res", + "strncon_tf": "str_tf_con_res", + "i_strain_wp": "i_str_wp", + "strain_wp_max": "str_wp_max", + "strain_wp": "str_wp", + "fstrain_wp": "fstr_wp", + "rad_fraction": "rad_fraction_total", + "pcoreradmw": "pinnerzoneradmw", + "pedgeradmw": "pouterzoneradmw", + "rad_fraction_core": "rad_fraction_LCFS", + "thshield": ["thshield_ib", "thshield_ob", "thshield_vb"], + "igeom": None, + "fgamp": None, + "divleg_profile_inner": None, + "divleg_profile_outer": None, + "iprimnloss": None, + "rho_ecrh": None, + "ifispact": None, + "fmsbc": None, + "fmsbl": None, + "fmsdwe": None, + "fmsdwi": None, + "fmsfw": None, + "fmsoh": None, + "fmssh": None, + "fmstf": None, + "quench_detection_ef": None, + "farc4tf": None, + "impvar": None, + "fimpvar": None, + "sigvvall": "max_vv_stress", + "ftaucq": "fmaxvvstress", + "fradmin": None, + "ftr": "ftrit", + "iculdl": "idensl", + "iiter": None, + "ires": None, + "fjtfc": None, + "bcylth": None, + "itfmod": None, + "jcrit_model": None, + "jcritsc": None, + "fcohbof": None, + "fvolbi": "fhole", + "fvolbo": "fhole", + "fvolcry": None, + "idhe3": "fhe3", + "blnktth": None, } -stellarator_list = [ + +OBS_VARS_HELP = { + "iculdl": "(use IDENSL=3 for equivalent model to ICULDL=0). ", + "blnktth": "WARNING. BLNKTTH is now always calculated rather than input - please remove it from the input file. ", +} + +kallenbach_list = [ "target_spread", "lambda_q_omp", "lcon_factor", @@ -137,5 +140,6 @@ "mach0", "neratio", ] -stellarator_message = "The Stellarator model is currently not included in PROCESS. See issue #1854 for more information on the use of Stellarators. " -OBS_VARS.update(dict.fromkeys(stellarator_list, [None, stellarator_message])) +kallenbach_message = "The Kallenbach model is currently not included in PROCESS. See issue #1886 for more information on the use of the Kallenbach model. " +OBS_VARS.update(dict.fromkeys(kallenbach_list, None)) +OBS_VARS_HELP.update(dict.fromkeys(kallenbach_list, kallenbach_message)) diff --git a/process/main.py b/process/main.py index 16212f3c93..f508c8fdc8 100644 --- a/process/main.py +++ b/process/main.py @@ -507,6 +507,7 @@ def validate_input(self): """ obsolete_variables = ov.OBS_VARS + obsolete_vars_help_message = ov.OBS_VARS_HELP filename = self.input_file @@ -526,8 +527,7 @@ def validate_input(self): for var in variables_in_in_dat: if var in obsolete_variables: obs_vars_in_in_dat.append(var) - new_var = obsolete_variables.get(var) - replace_hints[var] = new_var + replace_hints[var] = obsolete_variables.get(var) if len(obs_vars_in_in_dat) > 0: message = ( @@ -535,27 +535,12 @@ def validate_input(self): f"{obs_vars_in_in_dat}. " "Either remove these or replace them with their updated variable names. " ) - for var in obs_vars_in_in_dat: - if replace_hints[var][0] is None: - message = ( - message - + "\n \n " - + var - + " is an obsolete variable and does not have a replacement. " - ) - if len(replace_hints[var]) == 2: - message = message + str(replace_hints[var][1]) - if replace_hints[var][0] is not None: - message = ( - message - + "\n \n " - + var - + " is an obsolete variable and needs to be replaced by " - + str(replace_hints[var][0]) - + ". " - ) - if len(replace_hints[var]) == 2: - message = message + str(replace_hints[var][1]) + for obs_var in obs_vars_in_in_dat: + if replace_hints[obs_var] is None: + message += f"\n\n {obs_var} is an obsolete variable and needs to be removed. " + else: + message += f"\n \n {obs_var} is an obsolete variable and needs to be replaced by {str(replace_hints[obs_var])}. " + message += f"{obsolete_vars_help_message.get(obs_var, '')}" raise ValueError(message)