Skip to content

Commit

Permalink
Merge branch 'develop' into pysam_hybrids
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed Dec 11, 2023
2 parents 6de6421 + 75b4b17 commit ac1f661
Show file tree
Hide file tree
Showing 23 changed files with 9,390 additions and 476 deletions.
21 changes: 18 additions & 3 deletions shared/lib_irradproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2293,9 +2293,24 @@ int irrad::calc() {
directNormal, diffuseHorizontal, globalHorizontal, planeOfArrayIrradianceFront,
diffuseIrradianceFront);
if (enableSubhourlyClipping) {
int errorcode_cs = poaDecomp(weatherFilePOA, surfaceAnglesRadians, sunAnglesRadians, albedo, poaAll,
clearskyIrradiance[1], clearskyIrradiance[2], clearskyIrradiance[0], planeOfArrayIrradianceFrontCS,
diffuseIrradianceFrontCS);
double hextra = sunAnglesRadians[8];
switch (skyModel) {
case 0:
isotropic(hextra, clearskyIrradiance[1], clearskyIrradiance[2], albedo,
surfaceAnglesRadians[0], surfaceAnglesRadians[1], sunAnglesRadians[1],
planeOfArrayIrradianceFrontCS, diffuseIrradianceFrontCS);
break;
case 1:
hdkr(hextra, clearskyIrradiance[1], clearskyIrradiance[2], albedo, surfaceAnglesRadians[0],
surfaceAnglesRadians[1], sunAnglesRadians[1], planeOfArrayIrradianceFrontCS,
diffuseIrradianceFrontCS);
break;
default:
perez(hextra, clearskyIrradiance[1], clearskyIrradiance[2], albedo, surfaceAnglesRadians[0],
surfaceAnglesRadians[1], sunAnglesRadians[1], planeOfArrayIrradianceFrontCS,
diffuseIrradianceFrontCS);
break;
}
}
calculatedDirectNormal = directNormal;
calculatedDiffuseHorizontal = diffuseHorizontal;
Expand Down
5 changes: 4 additions & 1 deletion ssc/cmod_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,10 @@ battstor::battstor(var_table& vt, bool setup_model, size_t nrec, double dt_hr, c
if (batt_vars->ec_rate_defined) {
util_rate_data = new rate_data();
rate_setup::setup(&vt, (int)step_per_year, batt_vars->analysis_period, *util_rate_data, "cmod_battery");
}
}
else if (batt_vars->batt_dispatch == dispatch_t::RETAIL_RATE) {
throw exec_error("Battery", "Cannot select retail rate dispatch without providing utility rate data.");
}
dispatch_model = new dispatch_automatic_behind_the_meter_t(battery_model, dt_hr, batt_vars->batt_minimum_SOC, batt_vars->batt_maximum_SOC,
batt_vars->batt_current_choice, batt_vars->batt_current_charge_max, batt_vars->batt_current_discharge_max,
batt_vars->batt_power_charge_max_kwdc, batt_vars->batt_power_discharge_max_kwdc,
Expand Down
17 changes: 10 additions & 7 deletions ssc/cmod_fresnel_physical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ static var_info _cm_vtab_fresnel_physical[] = {


// Solar Field
{ SSC_OUTPUT, SSC_NUMBER, "q_dot_rec_des", "Receiver thermal output at design", "MWt", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "A_loop", "Aperture of a single loop", "m2", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "loop_opt_eff", "Loop optical efficiency at design", "", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "loop_therm_eff", "Loop thermal efficiency at design", "", "", "Receiver", "*", "", "" },
Expand All @@ -352,7 +351,9 @@ static var_info _cm_vtab_fresnel_physical[] = {
{ SSC_OUTPUT, SSC_NUMBER, "sm1_nLoops", "Required number of loops, SM=1", "", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "total_tracking_power", "Design tracking power", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "A_field", "Total field aperture", "m2", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des", "Design field power output", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des_actual", "Design-point thermal power from the solar field limited by mass flow", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des_ideal", "Design-point thermal power from the solar field with no limit", "MW", "", "Receiver", "*", "", "" },

{ SSC_OUTPUT, SSC_NUMBER, "field_area", "Solar field area", "acres", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "total_land_area", "Total land area", "acres", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "field_htf_min_temp", "Minimum field htf temp", "C", "", "Power Cycle", "*", "", "" },
Expand Down Expand Up @@ -775,7 +776,9 @@ class cm_fresnel_physical : public compute_module
}

// Calculate solar multiple (needed for other component constructors)
c_fresnel.design_solar_mult();
// Need latitude from weather reader
weather_reader.init();
c_fresnel.design_solar_mult(weather_reader.ms_solved_params.m_lat);

// Allocate Outputs
{
Expand Down Expand Up @@ -1414,7 +1417,6 @@ class cm_fresnel_physical : public compute_module
// Solar Field

double W_dot_col_tracking_des = c_fresnel.get_tracking_power(); // [MWe]
double q_dot_rec_des = c_fresnel.m_q_design / 1e6; // [MWt]
double A_loop = c_fresnel.m_A_loop; // [m2]
double loop_opt_eff = c_fresnel.m_loop_opt_eff;
double loop_therm_eff = c_fresnel.m_loop_therm_eff;
Expand All @@ -1423,7 +1425,8 @@ class cm_fresnel_physical : public compute_module
double sm1_nLoops = c_fresnel.m_nLoops_sm1;
double total_tracking_power = c_fresnel.m_W_dot_sca_tracking_nom; // [MW]
double A_field = c_fresnel.m_Ap_tot; // [m2]
double q_field_des = c_fresnel.m_q_design / 1e6; // [MW]
double q_field_des_actual = c_fresnel.m_q_design_actual / 1e6; // [MW]
double q_field_des_ideal = c_fresnel.m_q_design_ideal / 1e6; // [MW]

double field_area = A_field / 4046.85642; // [acres] (convert m2 to acre)
double land_mult = as_double("land_mult");
Expand Down Expand Up @@ -1454,7 +1457,6 @@ class cm_fresnel_physical : public compute_module

// Assign
{
assign("q_dot_rec_des", q_dot_rec_des);
assign("A_loop", A_loop);
assign("loop_opt_eff", loop_opt_eff);
assign("loop_therm_eff", loop_therm_eff);
Expand All @@ -1463,7 +1465,8 @@ class cm_fresnel_physical : public compute_module
assign("sm1_nLoops", sm1_nLoops);
assign("total_tracking_power", total_tracking_power);
assign("A_field", A_field);
assign("q_field_des", q_field_des);
assign("q_field_des_actual", q_field_des_actual);
assign("q_field_des_ideal", q_field_des_ideal);
assign("field_area", field_area);
assign("total_land_area", total_land_area);
assign("field_htf_min_temp", field_htf_min_temp);
Expand Down
30 changes: 19 additions & 11 deletions ssc/cmod_fresnel_physical_iph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ static var_info _cm_vtab_fresnel_physical_iph[] = {


// System Control
/*LK Only*/{ SSC_INPUT, SSC_ARRAY, "timestep_load_fractions", "Turbine load fraction for each timestep, alternative to block dispatch", "", "", "tou", "?", "", "SIMULATION_PARAMETER" },
/*Sys Control*/{ SSC_INPUT, SSC_NUMBER, "is_timestep_load_fractions", "Use turbine load fraction for each timestep instead of block dispatch?", "", "", "tou", "?=0", "", "SIMULATION_PARAMETER" },
/*Sys Control*/{ SSC_INPUT, SSC_ARRAY, "timestep_load_fractions", "Turbine load fraction for each timestep, alternative to block dispatch", "", "", "tou", "?", "", "SIMULATION_PARAMETER" },

/*Sys Control*/{ SSC_INPUT, SSC_NUMBER, "pb_fixed_par", "Fixed parasitic load - runs at all times", "", "", "Sys_Control", "*", "", "" },
/*Sys Control*/{ SSC_INPUT, SSC_ARRAY, "bop_array", "Balance of plant parasitic power fraction", "", "", "Sys_Control", "*", "", "" },
Expand Down Expand Up @@ -288,7 +289,6 @@ static var_info _cm_vtab_fresnel_physical_iph[] = {
{ SSC_OUTPUT, SSC_NUMBER, "nLoops", "Number of loops in the field", "", "", "controller", "*", "", "" },

// Solar Field
{ SSC_OUTPUT, SSC_NUMBER, "q_dot_rec_des", "Receiver thermal output at design", "MWt", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "A_loop", "Aperture of a single loop", "m2", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "loop_opt_eff", "Loop optical efficiency at design", "", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "loop_therm_eff", "Loop thermal efficiency at design", "", "", "Receiver", "*", "", "" },
Expand All @@ -297,7 +297,8 @@ static var_info _cm_vtab_fresnel_physical_iph[] = {
{ SSC_OUTPUT, SSC_NUMBER, "sm1_nLoops", "Required number of loops, SM=1", "", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "total_tracking_power", "Design tracking power", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "A_field", "Total field aperture", "m2", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des", "Design field power output", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des_actual", "Design-point thermal power from the solar field limited by mass flow", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "q_field_des_ideal", "Design-point thermal power from the solar field with no limit", "MW", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "field_area", "Solar field area", "acres", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "total_land_area", "Total land area", "acres", "", "Receiver", "*", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "field_htf_min_temp", "Minimum field htf temp", "C", "", "Power Cycle", "*", "", "" },
Expand Down Expand Up @@ -738,7 +739,9 @@ class cm_fresnel_physical_iph : public compute_module
}

// Calculate solar multiple (needed for other component constructors)
c_fresnel.design_solar_mult();
// Need latitude from weather reader
weather_reader.init();
c_fresnel.design_solar_mult(weather_reader.ms_solved_params.m_lat);

// Allocate Outputs
{
Expand Down Expand Up @@ -873,9 +876,14 @@ class cm_fresnel_physical_iph : public compute_module
tou_params->mc_csp_ops.mvv_tou_arrays[C_block_schedule_csp_ops::TURB_FRAC][i] = (double)p_f_turbine[i];

// Load fraction by time step:
bool is_load_fraction_by_timestep = is_assigned("timestep_load_fractions");
tou_params->mc_csp_ops.mv_is_diurnal = !(is_load_fraction_by_timestep);
if (is_load_fraction_by_timestep) {
//bool is_load_fraction_by_timestep = is_assigned("timestep_load_fractions");
bool is_is_timestep_load_fractions_assigned = is_assigned("is_timestep_load_fractions");
bool is_timestep_load_fractions = false;
if (is_is_timestep_load_fractions_assigned) {
is_timestep_load_fractions = as_boolean("is_timestep_load_fractions");
}
tou_params->mc_csp_ops.mv_is_diurnal = !(is_timestep_load_fractions);
if (is_timestep_load_fractions) {
size_t N_load_fractions;
ssc_number_t* load_fractions = as_array("timestep_load_fractions", &N_load_fractions);
std::copy(load_fractions, load_fractions + N_load_fractions, std::back_inserter(tou_params->mc_csp_ops.timestep_load_fractions));
Expand Down Expand Up @@ -1167,7 +1175,6 @@ class cm_fresnel_physical_iph : public compute_module
// Solar Field

double W_dot_col_tracking_des = c_fresnel.get_tracking_power(); // [MWe]
double q_dot_rec_des = c_fresnel.m_q_design / 1e6; // [MWt]
double A_loop = c_fresnel.m_A_loop; // [m2]
double loop_opt_eff = c_fresnel.m_loop_opt_eff;
double loop_therm_eff = c_fresnel.m_loop_therm_eff;
Expand All @@ -1176,7 +1183,8 @@ class cm_fresnel_physical_iph : public compute_module
double sm1_nLoops = c_fresnel.m_nLoops_sm1;
double total_tracking_power = c_fresnel.m_W_dot_sca_tracking_nom; // [MW]
double A_field = c_fresnel.m_Ap_tot; // [m2]
double q_field_des = c_fresnel.m_q_design / 1e6; // [MW]
double q_field_des = c_fresnel.m_q_design_actual / 1e6; // [MW]
double q_field_des_ideal = c_fresnel.m_q_design_ideal / 1e6; // [MW]

double field_area = A_field / 4046.85642; // [acres] (convert m2 to acre)
double land_mult = as_double("land_mult");
Expand Down Expand Up @@ -1207,7 +1215,6 @@ class cm_fresnel_physical_iph : public compute_module

// Assign
{
assign("q_dot_rec_des", q_dot_rec_des);
assign("A_loop", A_loop);
assign("loop_opt_eff", loop_opt_eff);
assign("loop_therm_eff", loop_therm_eff);
Expand All @@ -1216,7 +1223,8 @@ class cm_fresnel_physical_iph : public compute_module
assign("sm1_nLoops", sm1_nLoops);
assign("total_tracking_power", total_tracking_power);
assign("A_field", A_field);
assign("q_field_des", q_field_des);
assign("q_field_des_actual", q_field_des);
assign("q_field_des_ideal", q_field_des_ideal);
assign("field_area", field_area);
assign("total_land_area", total_land_area);
assign("field_htf_min_temp", field_htf_min_temp);
Expand Down
Loading

0 comments on commit ac1f661

Please sign in to comment.