Skip to content

Commit

Permalink
add updc option for no interpolation correction at max output
Browse files Browse the repository at this point in the history
  • Loading branch information
tyneises committed Dec 3, 2024
1 parent dd1fe7e commit 0256953
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
3 changes: 2 additions & 1 deletion ssc/cmod_test_ud_power_cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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,
Expand Down
6 changes: 4 additions & 2 deletions ssc/cmod_ui_udpc_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ class cm_ui_udpc_checks : public compute_module
{
std::vector<double> 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,
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tcs/csp_solver_pc_Rankine_indirect_224.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,10 @@ void C_pc_Rankine_indirect_224::init(C_csp_power_cycle::S_solved_params &solved_
}

std::vector<double> 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<C_ud_power_cycle::E_udpc_max_output_correction_mode>(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,
Expand Down
26 changes: 15 additions & 11 deletions tcs/ud_power_cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::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*/)
Expand All @@ -63,15 +63,16 @@ 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<double>& 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<double>& 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*/,
double& m_dot_htf_ND_ref_calc, double& m_dot_htf_ND_low_calc /*-*/, double& m_dot_htf_ND_high_calc /*-*/,
std::vector<double>& Y_at_T_htf_ref, std::vector<double>& Y_at_T_amb_ref,
std::vector<double>& Y_at_m_dot_htf_ND_ref, std::vector<double>& 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<double> T_htf_ind_table, m_dot_htf_ND_ind_table, T_amb_ind_table;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -517,15 +518,15 @@ 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<double>::quiet_NaN();
get_sco2_regr_max_ND_q_dot(T_htf_hot /*C*/, T_amb /*C*/, max_frac /*-*/,
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

Expand All @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions tcs/ud_power_cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -143,15 +151,16 @@ class C_ud_power_cycle

~C_ud_power_cycle(){};

void init(bool is_sco2_regr, const util::matrix_t<double>& udpc_table,
void init(C_ud_power_cycle::E_udpc_max_output_correction_mode udpc_max_output_correction_mode,
const util::matrix_t<double>& 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*/,
double& m_dot_htf_ND_ref_calc, double& m_dot_htf_ND_low_calc /*-*/, double& m_dot_htf_ND_high_calc /*-*/,
std::vector<double>& Y_at_T_htf_ref, std::vector<double>& Y_at_T_amb_ref,
std::vector<double>& Y_at_m_dot_htf_ND_ref, std::vector<double>& 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*/);

Expand Down

0 comments on commit 0256953

Please sign in to comment.