parameters: ()
docstring: Plot off-design results: Performance vs. Ambient Temperature
docstring_summary: Plot off-design results: Performance vs. Ambient Temperature
docstring_tokens: Plot off - design results : Performance vs . Ambient Temperature
function: def run_example_1():
  
      # Instantiate sco2 cycle simulation class
      c_sco2 = sco2_solve.C_sco2_sim(1)           # Initialize as same cycle config as specified above
  
      # Get default design parameters. These are different than the "baseline" default parameters in "sco2_cycle_ssc.py"
      sco2_des_par_default = get_sco2_design_parameters()
      c_sco2.overwrite_default_design_parameters(sco2_des_par_default)
  
      # Setup string for naming files
      des_sim_label_str = "T_amb_des" + '{:.1f}'.format(sco2_des_par_default["T_amb_des"])
  
      # Get design values of off-design inputs for reference
      T_htf_hot_des = sco2_des_par_default["T_htf_hot_des"]   # C
      part_load_des = 1.0   # - (normalized)
      T_amb_des = sco2_des_par_default["T_amb_des"]   # C
      f_N_rc = 1.0    # Use design point shaft speed
      f_N_mc = 1.0    # Use design point shaft speed
      f_N_pc = 1.0    # Use design point shaft speed
  
      # One off-design simulation at design conditions
      T_amb_od_parametric = [[T_htf_hot_des, part_load_des, T_amb_des, f_N_rc, f_N_mc, f_N_pc]]
  
      # Another off-design simulation at a new off-design temperature
      T_amb_OD = T_amb_des - 5.0      # C
      T_amb_od_parametric.append([T_htf_hot_des, part_load_des, T_amb_OD, f_N_rc, f_N_mc, f_N_pc])
  
      # Create a new dictionary the defines only the simulation inputs variables that change versus 'sco2_des_par_default' above
      # Here, only new variable is 'od_cases'
      mod_base_dict = {"od_cases" : T_amb_od_parametric}    #
      # Modify the current baseline inputs with new partial dictionary
      c_sco2.overwrite_des_par_base(mod_base_dict)    # Overwrite baseline input parameters
      # Set flag to not print key design solution metrics
      c_sco2.m_is_print_key_outputs = False
      # Run simulation. First the code will solve the design point, and then it will solve all off-design cases using the design solution
      c_sco2.solve_sco2_case()            # Run design simulation
  
      # Check if the code threw exceptions. This can happen if the code is missing required input or potentially if inputs are significantly different than expected
      print("\nDid the off-design simulation solve without the code throwing exceptions = ",c_sco2.m_solve_success)
  
      # Print some useful outputs
      print_useful_OD_outputs(c_sco2.m_solve_dict)
  
      # Set flag to tell class to save a csv when 'save_m_solve_dict' is called
      c_sco2.m_also_save_csv = True
      # Then call 'save_m_solve_dict' to save results to both a json (default) and csv (optionally set by 'm_also_save_csv')
      c_sco2.save_m_solve_dict(des_sim_label_str + "_OD_T_amb")   # Save design
  
      ###############################################################
      "Plot off-design results: Performance vs. Ambient Temperature"
      ###############################################################
      # Create a list result dictionaries from independent off-design simulations
      # In this example, there is only one off-design parametric analysis
      od_sol_dict_list = [c_sco2.m_solve_dict]
      # Create another list defining string labels for each dictionary in 'od_sol_dict_list'
      od_leg_list = ["part load = " + '{:.2f}'.format(part_load_des)]
      # Instantiate the off-design plot class using the list of result dictionaries
      od_plot = cy_plt.C_OD_stacked_outputs_plot(od_sol_dict_list)
      # Define the independent variable in the off-design simulations
      od_plot.x_var = "T_amb"
      # Set plot legend parameters
      od_plot.list_leg_spec = od_leg_list
      od_plot.n_leg_cols = len(od_leg_list)
      # Set number of rows - ideally this is informed by '.y_vars' to create a full grid of subplots
      od_plot.max_rows = 5
      od_plot.bb_y_max_is_leg = 0.95
      # Optionally save plot during 'create_plot' method
      od_plot.is_save = True
      od_plot.file_name = des_sim_label_str + "__OD_vs_T_amb"
      # Define variables for each subplot
      # See 'get_des_od_label_unit_info__calc_metrics' method in 'sco2_plots.py' in the Core folder for more information
      od_plot.y_vars = ["eta_less_cooling", "W_dot_net_less_cooling", "Q_dot", "f_recomp", "mc_cooler_W_dot_fan",           #system
                        "MC_T_in", "MC_P_in", "MC_T_out", "MC_P_out", "MC_rho_in",   #MC states
                        "MC_m_dot", "MC_W_dot", "MC_eta", "MC_phi", "MC_N_perc",   #MC performance
                        "RC_m_dot", "RC_W_dot", "RC_eta", "RC_phi", "RC_N_perc",   #RC performance
                        "RC_T_in", "RC_P_in", "RC_T_out", "RC_P_out", "mc_cooler_rho_in",  #RC states
                        "t_m_dot", "t_W_dot", "t_eta", "t_nu", "t_tip_speed",         #turbine performance
                        "t_T_in", "t_P_in", "t_T_out", "t_P_out", "t_N",              #turbine states
                        "T_htf_cold", "PHX_T_co2_in", "HTR_HP_T_in", "HTR_LP_T_out", "LTR_HP_T_out", #other temps
                        "LTR_eff", "LTR_q_dot", "LTR_min_dT", "LTR_LP_deltaP", "LTR_HP_deltaP",   #LTR performance
                        "HTR_eff", "HTR_q_dot", "HTR_min_dT", "HTR_LP_deltaP", "HTR_HP_deltaP",   #HTR performance
                        "PHX_eff", "Q_dot", "PHX_co2_deltaP", "m_dot_HTF", "T_HTF"]               #PHX performance
  
      # Create plot. If 'is_save' is True, this should save a png of the plot of the working directory
      od_plot.create_plot()
function_tokens: def run_example_1 ( ) : # Instantiate sco2 cycle simulation class c_sco2 = sco2_solve . C_sco2_sim ( 1 ) # Initialize as same cycle config as specified above # Get default design parameters. These are different than the "baseline" default parameters in "sco2_cycle_ssc.py" sco2_des_par_default = get_sco2_design_parameters ( ) c_sco2 . overwrite_default_design_parameters ( sco2_des_par_default ) # Setup string for naming files des_sim_label_str = "T_amb_des" + '{:.1f}' . format ( sco2_des_par_default [ "T_amb_des" ] ) # Get design values of off-design inputs for reference T_htf_hot_des = sco2_des_par_default [ "T_htf_hot_des" ] # C part_load_des = 1.0 # - (normalized) T_amb_des = sco2_des_par_default [ "T_amb_des" ] # C f_N_rc = 1.0 # Use design point shaft speed f_N_mc = 1.0 # Use design point shaft speed f_N_pc = 1.0 # Use design point shaft speed # One off-design simulation at design conditions T_amb_od_parametric = [ [ T_htf_hot_des , part_load_des , T_amb_des , f_N_rc , f_N_mc , f_N_pc ] ] # Another off-design simulation at a new off-design temperature T_amb_OD = T_amb_des - 5.0 # C T_amb_od_parametric . append ( [ T_htf_hot_des , part_load_des , T_amb_OD , f_N_rc , f_N_mc , f_N_pc ] ) # Create a new dictionary the defines only the simulation inputs variables that change versus 'sco2_des_par_default' above # Here, only new variable is 'od_cases' mod_base_dict = { "od_cases" : T_amb_od_parametric } # # Modify the current baseline inputs with new partial dictionary c_sco2 . overwrite_des_par_base ( mod_base_dict ) # Overwrite baseline input parameters # Set flag to not print key design solution metrics c_sco2 . m_is_print_key_outputs = False # Run simulation. First the code will solve the design point, and then it will solve all off-design cases using the design solution c_sco2 . solve_sco2_case ( ) # Run design simulation # Check if the code threw exceptions. This can happen if the code is missing required input or potentially if inputs are significantly different than expected print ( "\nDid the off-design simulation solve without the code throwing exceptions = " , c_sco2 . m_solve_success ) # Print some useful outputs print_useful_OD_outputs ( c_sco2 . m_solve_dict ) # Set flag to tell class to save a csv when 'save_m_solve_dict' is called c_sco2 . m_also_save_csv = True # Then call 'save_m_solve_dict' to save results to both a json (default) and csv (optionally set by 'm_also_save_csv') c_sco2 . save_m_solve_dict ( des_sim_label_str + "_OD_T_amb" ) # Save design ############################################################### ############################################################### # Create a list result dictionaries from independent off-design simulations # In this example, there is only one off-design parametric analysis od_sol_dict_list = [ c_sco2 . m_solve_dict ] # Create another list defining string labels for each dictionary in 'od_sol_dict_list' od_leg_list = [ "part load = " + '{:.2f}' . format ( part_load_des ) ] # Instantiate the off-design plot class using the list of result dictionaries od_plot = cy_plt . C_OD_stacked_outputs_plot ( od_sol_dict_list ) # Define the independent variable in the off-design simulations od_plot . x_var = "T_amb" # Set plot legend parameters od_plot . list_leg_spec = od_leg_list od_plot . n_leg_cols = len ( od_leg_list ) # Set number of rows - ideally this is informed by '.y_vars' to create a full grid of subplots od_plot . max_rows = 5 od_plot . bb_y_max_is_leg = 0.95 # Optionally save plot during 'create_plot' method od_plot . is_save = True od_plot . file_name = des_sim_label_str + "__OD_vs_T_amb" # Define variables for each subplot # See 'get_des_od_label_unit_info__calc_metrics' method in 'sco2_plots.py' in the Core folder for more information od_plot . y_vars = [ "eta_less_cooling" , "W_dot_net_less_cooling" , "Q_dot" , "f_recomp" , "mc_cooler_W_dot_fan" , #system "MC_T_in" , "MC_P_in" , "MC_T_out" , "MC_P_out" , "MC_rho_in" , #MC states "MC_m_dot" , "MC_W_dot" , "MC_eta" , "MC_phi" , "MC_N_perc" , #MC performance "RC_m_dot" , "RC_W_dot" , "RC_eta" , "RC_phi" , "RC_N_perc" , #RC performance "RC_T_in" , "RC_P_in" , "RC_T_out" , "RC_P_out" , "mc_cooler_rho_in" , #RC states "t_m_dot" , "t_W_dot" , "t_eta" , "t_nu" , "t_tip_speed" , #turbine performance "t_T_in" , "t_P_in" , "t_T_out" , "t_P_out" , "t_N" , #turbine states "T_htf_cold" , "PHX_T_co2_in" , "HTR_HP_T_in" , "HTR_LP_T_out" , "LTR_HP_T_out" , #other temps "LTR_eff" , "LTR_q_dot" , "LTR_min_dT" , "LTR_LP_deltaP" , "LTR_HP_deltaP" , #LTR performance "HTR_eff" , "HTR_q_dot" , "HTR_min_dT" , "HTR_LP_deltaP" , "HTR_HP_deltaP" , #HTR performance "PHX_eff" , "Q_dot" , "PHX_co2_deltaP" , "m_dot_HTF" , "T_HTF" ] #PHX performance # Create plot. If 'is_save' is True, this should save a png of the plot of the working directory od_plot . create_plot ( )