diff --git a/ssc/cmod_test_ud_power_cycle.cpp b/ssc/cmod_test_ud_power_cycle.cpp index e2419dab4..95aa82d62 100644 --- a/ssc/cmod_test_ud_power_cycle.cpp +++ b/ssc/cmod_test_ud_power_cycle.cpp @@ -152,7 +152,8 @@ class cm_test_ud_power_cycle : public compute_module double T_amb_ref_udpc_calc, T_amb_low_udpc_calc, T_amb_high_udpc_calc; double m_dot_htf_ref_udpc_calc, m_dot_htf_low_udpc_calc, m_dot_htf_high_udpc_calc; std::vector Y_at_T_htf_ref, Y_at_T_amb_ref, Y_at_m_dot_htf_ND_ref, Y_avg_at_refs; - c_udpc.init(false, udpc_data_full, + C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_mode = C_ud_power_cycle::SIMPLE_HEURISTIC; + c_udpc.init(udpc_mode, udpc_data_full, n_T_htf_udpc_calc, n_T_amb_udpc_calc, n_m_dot_udpc_calc, T_htf_ref_udpc_calc, T_htf_low_udpc_calc, T_htf_high_udpc_calc, T_amb_ref_udpc_calc, T_amb_low_udpc_calc, T_amb_high_udpc_calc, diff --git a/ssc/cmod_ui_udpc_checks.cpp b/ssc/cmod_ui_udpc_checks.cpp index 52478abcd..6e67132f5 100644 --- a/ssc/cmod_ui_udpc_checks.cpp +++ b/ssc/cmod_ui_udpc_checks.cpp @@ -191,7 +191,8 @@ class cm_ui_udpc_checks : public compute_module { std::vector Y_at_T_htf_ref, Y_at_T_amb_ref, Y_at_m_dot_htf_ND_ref, Y_avg_at_refs; - c_udpc.init(false, cmbd_ind, + C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode = C_ud_power_cycle::E_udpc_max_output_correction_mode::SIMPLE_HEURISTIC; + c_udpc.init(udpc_max_output_correction_mode, cmbd_ind, n_T_htf_pars, n_T_amb_pars, n_m_dot_pars, T_htf_des, T_htf_low, T_htf_high, T_amb_des, T_amb_low, T_amb_high, @@ -318,7 +319,8 @@ class cm_ui_udpc_checks : public compute_module // Heuristic / Regression Model double T_htf_des_cold = as_double("T_htf_cold_des"); //[C] c_udpc.set_sco2_design_for_sco2_regr(T_htf_des_in, T_htf_des_cold); - c_udpc.set_is_sco2_regr(true); + C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode = C_ud_power_cycle::E_udpc_max_output_correction_mode::SCO2_HEURISTIC; + c_udpc.set_is_sco2_regr(udpc_max_output_correction_mode); // 1) Get q_dot_ND_max at m_dot_ND = 1 diff --git a/tcs/csp_solver_pc_Rankine_indirect_224.cpp b/tcs/csp_solver_pc_Rankine_indirect_224.cpp index 469b323f6..fc75c892b 100644 --- a/tcs/csp_solver_pc_Rankine_indirect_224.cpp +++ b/tcs/csp_solver_pc_Rankine_indirect_224.cpp @@ -629,7 +629,10 @@ void C_pc_Rankine_indirect_224::init(C_csp_power_cycle::S_solved_params &solved_ } std::vector Y_at_T_htf_ref, Y_at_T_amb_ref, Y_at_m_dot_htf_ND_ref, Y_avg_at_refs; - mc_user_defined_pc.init(ms_params.m_is_udpc_sco2_regr, ms_params.mc_combined_ind, + + C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_mode = static_cast(ms_params.m_is_udpc_sco2_regr); + + mc_user_defined_pc.init(udpc_mode, ms_params.mc_combined_ind, m_n_T_htf_pars, m_n_T_amb_pars, m_n_m_dot_pars, m_T_htf_ref_udpc_calc, m_T_htf_low_udpc_calc, m_T_htf_high_udpc_calc, m_T_amb_ref_udpc_calc, m_T_amb_low_udpc_calc, m_T_amb_high_udpc_calc, diff --git a/tcs/ud_power_cycle.cpp b/tcs/ud_power_cycle.cpp index 16003b697..12e589421 100644 --- a/tcs/ud_power_cycle.cpp +++ b/tcs/ud_power_cycle.cpp @@ -42,15 +42,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C_ud_power_cycle::C_ud_power_cycle() { - m_is_sco2_regr = false; + m_E_udpc_max_output_correction_mode = C_ud_power_cycle::E_udpc_max_output_correction_mode::SIMPLE_HEURISTIC; m_is_sco2_design_set = false; m_T_htf_cold_des_sco2_regr = m_deltaT_HTF_des = std::numeric_limits::quiet_NaN(); } -void C_ud_power_cycle::set_is_sco2_regr(bool is_sco2_regr) +void C_ud_power_cycle::set_is_sco2_regr(C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode) { - m_is_sco2_regr = is_sco2_regr; + m_E_udpc_max_output_correction_mode = udpc_max_output_correction_mode; } void C_ud_power_cycle::set_sco2_design_for_sco2_regr(double T_htf_hot_des /*C*/, double T_htf_cold_des /*C*/) @@ -63,7 +63,8 @@ void C_ud_power_cycle::set_sco2_design_for_sco2_regr(double T_htf_hot_des /*C*/, } } -void C_ud_power_cycle::init(bool is_sco2_regr, const util::matrix_t& udpc_table, +void C_ud_power_cycle::init(C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode, + const util::matrix_t& udpc_table, int& n_T_htf_pars, int& n_T_amb_pars, int& n_m_dot_pars, double& T_htf_ref_calc /*C*/, double& T_htf_low_calc /*C*/, double& T_htf_high_calc /*C*/, double& T_amb_ref_calc /*C*/, double& T_amb_low_calc /*C*/, double& T_amb_high_calc /*C*/, @@ -71,7 +72,7 @@ void C_ud_power_cycle::init(bool is_sco2_regr, const util::matrix_t& udp std::vector& Y_at_T_htf_ref, std::vector& Y_at_T_amb_ref, std::vector& Y_at_m_dot_htf_ND_ref, std::vector& Y_avg_at_refs) { - m_is_sco2_regr = is_sco2_regr; + m_E_udpc_max_output_correction_mode = udpc_max_output_correction_mode; util::matrix_t T_htf_ind_table, m_dot_htf_ND_ind_table, T_amb_ind_table; @@ -373,7 +374,7 @@ double C_ud_power_cycle::get_m_dot_water_ND_interp(double T_htf_hot /*C*/, doubl double C_ud_power_cycle::get_W_dot_gross_nd(double T_htf_hot /*C*/, double T_amb /*C*/, double m_dot_htf_ND /*-*/, double max_frac /*-*/) { - if (m_is_sco2_regr) { + if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SCO2_HEURISTIC) { double W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND; udpc_sco2_regr_off_design(T_htf_hot, T_amb, m_dot_htf_ND, max_frac, W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND); @@ -387,7 +388,7 @@ double C_ud_power_cycle::get_W_dot_gross_nd(double T_htf_hot /*C*/, double T_amb double C_ud_power_cycle::get_Q_dot_HTF_nd(double T_htf_hot /*C*/, double T_amb /*C*/, double m_dot_htf_ND /*-*/, double max_frac /*-*/) { - if (m_is_sco2_regr) { + if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SCO2_HEURISTIC) { double W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND; udpc_sco2_regr_off_design(T_htf_hot, T_amb, m_dot_htf_ND, max_frac, W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND); @@ -401,7 +402,7 @@ double C_ud_power_cycle::get_Q_dot_HTF_nd(double T_htf_hot /*C*/, double T_amb / double C_ud_power_cycle::get_W_dot_cooling_nd(double T_htf_hot /*C*/, double T_amb /*C*/, double m_dot_htf_ND /*-*/, double max_frac /*-*/) { - if (m_is_sco2_regr) { + if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SCO2_HEURISTIC) { double W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND; udpc_sco2_regr_off_design(T_htf_hot, T_amb, m_dot_htf_ND, max_frac, W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND); @@ -415,7 +416,7 @@ double C_ud_power_cycle::get_W_dot_cooling_nd(double T_htf_hot /*C*/, double T_a double C_ud_power_cycle::get_m_dot_water_nd(double T_htf_hot /*C*/, double T_amb /*C*/, double m_dot_htf_ND /*-*/, double max_frac /*-*/) { - if (m_is_sco2_regr) { + if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SCO2_HEURISTIC) { double W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND; udpc_sco2_regr_off_design(T_htf_hot, T_amb, m_dot_htf_ND, max_frac, W_dot_gross_ND, q_dot_ND, W_dot_cooling_ND, m_dot_water_ND); @@ -517,7 +518,7 @@ void C_ud_power_cycle::get_max_m_dot_and_W_dot_ND(double T_htf_hot /*C*/, double // Heuristic sets max ND mass flow to q_dot_ND at global max ND mass flow rate - if (m_is_sco2_regr) { + if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SCO2_HEURISTIC) { double delta_T_HTF_OD, q_dot_htf_ND_max; delta_T_HTF_OD = m_dot_HTF_ND_max = q_dot_htf_ND_max = std::numeric_limits::quiet_NaN(); @@ -525,7 +526,7 @@ void C_ud_power_cycle::get_max_m_dot_and_W_dot_ND(double T_htf_hot /*C*/, double delta_T_HTF_OD, m_dot_HTF_ND_max, q_dot_htf_ND_max); } - else { + else if(m_E_udpc_max_output_correction_mode == C_ud_power_cycle::SIMPLE_HEURISTIC) { // Calculate non-dimensional mass flow rate relative to design point m_dot_HTF_ND_max = max_frac; //[-] Use max mass flow rate @@ -541,6 +542,9 @@ void C_ud_power_cycle::get_max_m_dot_and_W_dot_ND(double T_htf_hot /*C*/, double // set m_dot_ND to q_dot_max m_dot_HTF_ND_max = q_dot_ND_max; } + else if (m_E_udpc_max_output_correction_mode == C_ud_power_cycle::NO_CORRECTION) { + m_dot_HTF_ND_max = max_frac; + } W_dot_gross_ND_max = get_W_dot_gross_nd(T_htf_hot, T_amb, diff --git a/tcs/ud_power_cycle.h b/tcs/ud_power_cycle.h index fa8bac5f9..921ca5c97 100644 --- a/tcs/ud_power_cycle.h +++ b/tcs/ud_power_cycle.h @@ -60,6 +60,14 @@ class C_ud_power_cycle E_COL_M_H2O }; + // Interpolation type? + enum E_udpc_max_output_correction_mode + { + SIMPLE_HEURISTIC = 0, + SCO2_HEURISTIC, + NO_CORRECTION + }; + private: // Each Linear_Interp Table in C_user_defined_pc shares the following column structure: @@ -90,7 +98,7 @@ class C_ud_power_cycle std::string m_error_msg; // does udpc represent sco2 and require regression model? - bool m_is_sco2_regr; + E_udpc_max_output_correction_mode m_E_udpc_max_output_correction_mode; bool m_is_sco2_design_set; double m_T_htf_cold_des_sco2_regr; double m_deltaT_HTF_des; @@ -143,7 +151,8 @@ class C_ud_power_cycle ~C_ud_power_cycle(){}; - void init(bool is_sco2_regr, const util::matrix_t& udpc_table, + void init(C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode, + const util::matrix_t& udpc_table, int& n_T_htf_pars, int& n_T_amb_pars, int& n_m_dot_pars, double& T_htf_ref_calc /*C*/, double& T_htf_low_calc /*C*/, double& T_htf_high_calc /*C*/, double& T_amb_ref_calc /*C*/, double& T_amb_low_calc /*C*/, double& T_amb_high_calc /*C*/, @@ -151,7 +160,7 @@ class C_ud_power_cycle std::vector& Y_at_T_htf_ref, std::vector& Y_at_T_amb_ref, std::vector& Y_at_m_dot_htf_ND_ref, std::vector& Y_avg_at_refs); - void set_is_sco2_regr(bool is_sco2_regr); + void set_is_sco2_regr(C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode); void set_sco2_design_for_sco2_regr(double T_htf_hot_des /*C*/, double T_htf_cold_des /*C*/);