Skip to content

Commit

Permalink
Merge pull request #681 from NREL/SAM_835
Browse files Browse the repository at this point in the history
Fix macOS crashing configurations - SAM issue 835
  • Loading branch information
sjanzou committed Dec 3, 2021
2 parents 2ec74fc + 51b4a1c commit fc550f9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ssc/cmod_cashloan.cpp
Expand Up @@ -1047,7 +1047,7 @@ class cm_cashloan : public compute_module
ssc_number_t* year1_hourly_e_from_grid = as_array("year1_hourly_e_fromgrid", &n_e_fromgrid);
ssc_number_t* monthly_gen_purchases = allocate("monthly_gen_purchases", 12 * nyears);
ssc_number_t* monthly_e_fromgrid = allocate("monthly_e_from_grid", 12);
for (int a = 1; a <= nyears; a++) {
for (size_t a = 1; a <= nyears; a++) {
if (as_integer("system_use_lifetime_output") == 1) {
for (size_t m = 1; m <= 12; m++) {
monthly_hourly_purchases = 0;
Expand All @@ -1056,11 +1056,11 @@ class cm_cashloan : public compute_module
for (size_t h = 0; h < 24; h++) { //monthly iteration for each year
for (size_t n = 0; n < n_steps_per_hour; n++) {
monthly_e_fromgrid[m-1] += year1_hourly_e_from_grid[util::hour_of_year(m, d, h) * n_steps_per_hour + n];
monthly_gen_purchases[(a - 1) * 12 + m-1] += -gen_purchases[(size_t(a) - 1) * 8760 * n_steps_per_hour + n_steps_per_hour * util::hour_of_year(m, d, h) + n];
monthly_gen_purchases[(a - 1) * 12 + m-1] += -gen_purchases[(a - 1) * 8760 * n_steps_per_hour + n_steps_per_hour * util::hour_of_year(m, d, h) + n];
if (year1_hourly_e_from_grid[h] != 0.0) {
cf.at(CF_parasitic_cost, a) += -gen_purchases[(size_t(a) - 1) * 8760 * n_steps_per_hour + n_steps_per_hour * util::hour_of_year(m, d, h) + n] * cf.at(CF_degradation, a) / year1_hourly_e_from_grid[h] * (year1_hourly_ec[h * n_steps_per_hour + n] + year1_hourly_dc[h * n_steps_per_hour + n]) * cf.at(CF_util_escal_rate, a); //use the electricity rate data by year (also trueup) //* charged_grid[a] / charged_grid[1] * cf.at(CF_util_escal_rate, a);
cf.at(CF_parasitic_cost, a) += -gen_purchases[(a - 1) * 8760 * n_steps_per_hour + n_steps_per_hour * util::hour_of_year(m, d, h) + n] * cf.at(CF_degradation, a) / year1_hourly_e_from_grid[h] * (year1_hourly_ec[h * n_steps_per_hour + n] + year1_hourly_dc[h * n_steps_per_hour + n]) * cf.at(CF_util_escal_rate, a); //use the electricity rate data by year (also trueup) //* charged_grid[a] / charged_grid[1] * cf.at(CF_util_escal_rate, a);
}
if (d == util::days_in_month(int(m - 1)) && h == 23 && monthly_e_fromgrid[m - 1] > 0) cf.at(CF_parasitic_cost, a) += -monthly_gen_purchases[(size_t(a) - 1) * 12 + m - 1] / monthly_e_fromgrid[m - 1] * (net_annual_true_up.at(a, m - 1) + net_billing_credit.at(a, m - 1) + net_metering_credit.at(a, m - 1));
if (d == util::days_in_month(int(m - 1)) && h == 23 && monthly_e_fromgrid[m - 1] > 0) cf.at(CF_parasitic_cost, a) += -monthly_gen_purchases[(a - 1) * 12 + m - 1] / monthly_e_fromgrid[m - 1] * (net_annual_true_up.at(a, m - 1) + net_billing_credit.at(a, m - 1) + net_metering_credit.at(a, m - 1));
}
}
}
Expand All @@ -1073,8 +1073,8 @@ class cm_cashloan : public compute_module
for (size_t d = 1; d <= util::days_in_month(int(m - 1)); d++) {
for (size_t h = 0; h < 24; h++) { //monthly iteration for each year
for (size_t n = 0; n < n_steps_per_hour; n++) {
monthly_e_fromgrid[m] += year1_hourly_e_from_grid[util::hour_of_year(m, d, h) * n_steps_per_hour + n];
monthly_gen_purchases[(a - 1) * 12 + m] += -gen_purchases[n_steps_per_hour * util::hour_of_year(m, d, h) + n];
monthly_e_fromgrid[m-1] += year1_hourly_e_from_grid[util::hour_of_year(m, d, h) * n_steps_per_hour + n];
monthly_gen_purchases[(a - 1) * 12 + m-1] += -gen_purchases[n_steps_per_hour * util::hour_of_year(m, d, h) + n];
if (year1_hourly_e_from_grid[h] != 0.0) {
cf.at(CF_parasitic_cost, a) += -gen_purchases[n_steps_per_hour * util::hour_of_year(m, d, h) + n] * cf.at(CF_degradation, a) / year1_hourly_e_from_grid[h] * (year1_hourly_ec[h * n_steps_per_hour + n] + year1_hourly_dc[h * n_steps_per_hour + n]) * cf.at(CF_util_escal_rate, a); //use the electricity rate data by year (also trueup) //* charged_grid[a] / charged_grid[1] * cf.at(CF_util_escal_rate, a);
}
Expand Down

0 comments on commit fc550f9

Please sign in to comment.