Skip to content

Commit

Permalink
Merge branch 'develop' into wind2024updates
Browse files Browse the repository at this point in the history
  • Loading branch information
janinefreeman committed Oct 12, 2024
2 parents 26c584c + 6010edc commit 90fe1c8
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 9 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SSC (SAM Simulation Core)
![Build](https://github.com/NREL/ssc/actions/workflows/ci.yml/badge.svg)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FNREL%2Fssc.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FNREL%2Fssc?ref=badge_shield)

The SSC Open Source Project repository contains the source code for the technology and financial models contained within the National Renewable Energy Laboratory's System Advisor Model™ (SAM™). For more details about SAM's capabilities, see the SAM website at [https://sam.nrel.gov/](https://sam.nrel.gov).

Expand Down
3 changes: 3 additions & 0 deletions shared/lib_battery_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ battery_metrics_t::battery_metrics_t(double dt_hour)
_average_efficiency = 100.;
_average_roundtrip_efficiency = 100.;
_pv_charge_percent = 0.;
_grid_charge_percent = 0.;

// annual metrics
_e_charge_from_pv_annual = 0.;
Expand All @@ -938,6 +939,7 @@ battery_metrics_t::battery_metrics_t(double dt_hour)
double battery_metrics_t::average_battery_conversion_efficiency() { return _average_efficiency; }
double battery_metrics_t::average_battery_roundtrip_efficiency() { return _average_roundtrip_efficiency; }
double battery_metrics_t::pv_charge_percent() { return _pv_charge_percent; }
double battery_metrics_t::grid_charge_percent() { return _grid_charge_percent; }
double battery_metrics_t::energy_pv_charge_annual() { return _e_charge_from_pv_annual; }
double battery_metrics_t::energy_grid_charge_annual() { return _e_charge_from_grid_annual; }
double battery_metrics_t::energy_charge_annual() { return _e_charge_annual; }
Expand Down Expand Up @@ -996,6 +998,7 @@ void battery_metrics_t::accumulate_battery_charge_components(double P_tofrom_bat
_average_efficiency = 100. * (_e_discharge_accumulated / _e_charge_accumulated);
_average_roundtrip_efficiency = 100. * (_e_discharge_accumulated / (_e_charge_accumulated + _e_loss_system));
_pv_charge_percent = 100. * (_e_charge_from_pv / _e_charge_accumulated);
_grid_charge_percent = 100. * (_e_charge_from_grid / _e_charge_accumulated);
}
void battery_metrics_t::accumulate_grid_annual(double P_tofrom_grid)
{
Expand Down
2 changes: 2 additions & 0 deletions shared/lib_battery_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ class battery_metrics_t
double average_battery_conversion_efficiency();
double average_battery_roundtrip_efficiency();
double pv_charge_percent();
double grid_charge_percent();

protected:

Expand All @@ -492,6 +493,7 @@ class battery_metrics_t

/*! This is the percentage of energy charge from the PV system [%] */
double _pv_charge_percent;
double _grid_charge_percent;

// annual metrics
double _e_charge_from_pv_annual; // [Kwh]
Expand Down
17 changes: 17 additions & 0 deletions ssc/cmod_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,14 @@ var_info vtab_battery_outputs[] = {
{ SSC_OUTPUT, SSC_NUMBER, "average_battery_conversion_efficiency", "Battery average cycle conversion efficiency", "%", "", "Annual", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "average_battery_roundtrip_efficiency", "Battery average roundtrip efficiency", "%", "", "Annual", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "batt_system_charge_percent", "Battery charge energy charged from system", "%", "", "Annual", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "batt_grid_charge_percent", "Battery charge energy charged from grid", "%", "", "Annual", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "batt_bank_installed_capacity", "Battery bank installed capacity", "kWh", "", "Annual", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "annual_crit_load", "Critical load energy (year 1)", "kWh", "", "Battery", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "annual_crit_load_unmet", "Critical load energy unmet (year 1)", "kWh", "", "Battery", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "annual_crit_load_unmet_percentage", "Critical load unmet percentage (year 1)", "%", "", "Battery", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "annual_outage_losses_unmet", "Battery and system losses unmet energy (year 1)", "kWh", "", "Battery", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "batt_year1_charge_from_system", "Battery annual energy charged from system (year 1)", "kWh", "", "Battery", "", "", "" },
{ SSC_OUTPUT, SSC_NUMBER, "batt_year1_charge_from_grid", "Battery annual energy charged from grid (year 1)", "kWh", "", "Battery", "", "", "" },

// test matrix output
{ SSC_OUTPUT, SSC_MATRIX, "batt_dispatch_sched", "Battery dispatch schedule", "", "", "Battery", "", "", "ROW_LABEL=MONTHS,COL_LABEL=HOURS_OF_DAY" },
Expand Down Expand Up @@ -924,6 +927,7 @@ battstor::battstor(var_table& vt, bool setup_model, size_t nrec, double dt_hr, c
outUnmetLosses = 0;
outAverageCycleEfficiency = 0;
outSystemChargePercent = 0;
outGridChargePercent = 0;
outAnnualSystemChargeEnergy = 0;
outAnnualGridChargeEnergy = 0;
outAnnualChargeEnergy = 0;
Expand Down Expand Up @@ -1729,6 +1733,7 @@ battstor::battstor(const battstor& orig) {
outAverageCycleEfficiency = orig.outAverageCycleEfficiency;
outAverageRoundtripEfficiency = orig.outAverageRoundtripEfficiency;
outSystemChargePercent = orig.outSystemChargePercent;
outGridChargePercent = orig.outGridChargePercent;

// copy models
if (orig.batt_vars) batt_vars = orig.batt_vars;
Expand Down Expand Up @@ -1995,6 +2000,14 @@ void battstor::metrics()
outSystemChargePercent = 100;
else if (outSystemChargePercent < 0)
outSystemChargePercent = 0;

// Grid charge ratio
outGridChargePercent = (ssc_number_t)battery_metrics->grid_charge_percent();
if (outGridChargePercent > 100)
outGridChargePercent = 100;
else if (outGridChargePercent < 0)
outGridChargePercent = 0;

}

// function needed to correctly calculate P_grid due to additional losses in P_gen post battery like wiring, curtailment, availablity
Expand Down Expand Up @@ -2068,8 +2081,12 @@ void battstor::calculate_monthly_and_annual_outputs(compute_module& cm)
cm.assign("average_battery_conversion_efficiency", var_data((ssc_number_t)outAverageCycleEfficiency));
cm.assign("average_battery_roundtrip_efficiency", var_data((ssc_number_t)outAverageRoundtripEfficiency));
cm.assign("batt_system_charge_percent", var_data((ssc_number_t)outSystemChargePercent));
cm.assign("batt_grid_charge_percent", var_data((ssc_number_t)outGridChargePercent));
cm.assign("batt_bank_installed_capacity", (ssc_number_t)batt_vars->batt_kwh);

cm.assign("batt_year1_charge_from_grid", var_data((ssc_number_t)outAnnualGridChargeEnergy[0]));
cm.assign("batt_year1_charge_from_system", var_data((ssc_number_t)outAnnualSystemChargeEnergy[0]));

// monthly outputs
cm.accumulate_monthly_for_year("system_to_batt", "monthly_system_to_batt", _dt_hour, step_per_hour);
cm.accumulate_monthly_for_year("grid_to_batt", "monthly_grid_to_batt", _dt_hour, step_per_hour);
Expand Down
1 change: 1 addition & 0 deletions ssc/cmod_battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ struct battstor
double outAverageCycleEfficiency;
double outAverageRoundtripEfficiency;
double outSystemChargePercent;
double outGridChargePercent;

//output variables for self-consumption dispatch
double outTimestepsLoadMetBySystemYear1;
Expand Down
20 changes: 14 additions & 6 deletions ssc/cmod_pvsamv1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static var_info _cm_vtab_pvsamv1[] = {
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_ss_reflected_derate", "Subarray 1 Self-shading non-linear ground diffuse irradiance factor", "frac", "", "Time Series (Subarray 1)", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_ss_derate", "Subarray 1 Self-shading non-linear DC factor", "frac", "", "Time Series (Subarray 1)", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "shadedb_subarray1_shade_frac", "Subarray 1 Partial external shading DC factor", "frac", "", "Time Series (Subarray 1)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_snow_coverage", "Subarray 1 Snow cover", "0..1", "", "Time Series (Subarray 1)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_snow_coverage", "Subarray 1 Fraction of row covered by snow", "0..1", "", "Time Series (Subarray 1)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_snow_loss", "Subarray 1 Snow cover DC power loss", "kW", "", "Time Series (Subarray 1)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_modeff", "Subarray 1 Module efficiency", "%", "", "Time Series (Subarray 1)", "*", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray1_celltemp", "Subarray 1 Cell temperature", "C", "", "Time Series (Subarray 1)", "*", "", "" },
Expand Down Expand Up @@ -693,7 +693,7 @@ static var_info _cm_vtab_pvsamv1[] = {
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_ss_reflected_derate", "Subarray 2 Self-shading non-linear ground diffuse irradiance factor", "frac", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_ss_derate", "Subarray 2 Self-shading non-linear DC factor", "frac", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "shadedb_subarray2_shade_frac", "Subarray 2 Partial shading DC factor", "frac", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_snow_coverage", "Subarray 2 Snow cover", "0..1", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_snow_coverage", "Subarray 2 Fraction of row covered by snow", "0..1", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_snow_loss", "Subarray 2 Snow cover DC power loss", "kW", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_modeff", "Subarray 2 Module efficiency", "%", "", "Time Series (Subarray 2)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray2_celltemp", "Subarray 2 Cell temperature", "C", "", "Time Series (Subarray 2)", "", "", "" },
Expand Down Expand Up @@ -730,7 +730,7 @@ static var_info _cm_vtab_pvsamv1[] = {
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_ss_reflected_derate", "Subarray 3 Self-shading non-linear ground diffuse irradiance factor", "frac", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_ss_derate", "Subarray 3 Self-shading non-linear DC factor", "frac", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "shadedb_subarray3_shade_frac", "Subarray 3 Partial external shading DC factor", "frac", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_snow_coverage", "Subarray 3 Snow cover", "0..1", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_snow_coverage", "Subarray 3 Fraction of row covered by snow", "0..1", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_snow_loss", "Subarray 3 Snow cover DC power loss", "kW", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_modeff", "Subarray 3 Module efficiency", "%", "", "Time Series (Subarray 3)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray3_celltemp", "Subarray 3 Cell temperature", "C", "", "Time Series (Subarray 3)", "", "", "" },
Expand Down Expand Up @@ -767,7 +767,7 @@ static var_info _cm_vtab_pvsamv1[] = {
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_ss_reflected_derate", "Subarray 4 Self-shading non-linear ground diffuse irradiance factor", "frac", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_ss_derate", "Subarray 4 Self-shading non-linear DC factor", "frac", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "shadedb_subarray4_shade_frac", "Subarray 4 Partial external shading DC factor", "frac", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_snow_coverage", "Subarray 4 Snow cover", "0..1", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_snow_coverage", "Subarray 4 Fraction of row covered by snow", "0..1", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_snow_loss", "Subarray 4 Snow cover DC power loss", "kW", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_modeff", "Subarray 4 Module efficiency", "%", "", "Time Series (Subarray 4)", "", "", "" },
{ SSC_OUTPUT, SSC_ARRAY, "subarray4_celltemp", "Subarray 4 Cell temperature", "C", "", "Time Series (Subarray 4)", "", "", "" },
Expand Down Expand Up @@ -2425,13 +2425,19 @@ void cm_pvsamv1::exec()
{
float smLoss = 0.0f;

if (!Subarrays[nn]->snowModel.getLoss((float)(Subarrays[nn]->poa.poaBeamFront + Subarrays[nn]->poa.poaDiffuseFront + Subarrays[nn]->poa.poaGroundFront),
if (!Subarrays[nn]->snowModel.getLoss((float)(Subarrays[nn]->poa.poaBeamFront + Subarrays[nn]->poa.poaDiffuseFront + Subarrays[nn]->poa.poaGroundFront + ipoa_rear_after_losses[nn]),
(float)Subarrays[nn]->poa.surfaceTiltDegrees, (float)wf.wspd, (float)wf.tdry, (float)wf.snow, sunup, 1.0f / step_per_hour, smLoss))
{
if (!Subarrays[nn]->snowModel.good)
throw exec_error("pvsamv1", Subarrays[nn]->snowModel.msg);
}
float poa_front = Subarrays[nn]->poa.poaBeamFront + Subarrays[nn]->poa.poaDiffuseFront + Subarrays[nn]->poa.poaGroundFront;
float poa = poa_front + Subarrays[nn]->poa.poaRear * bifaciality;

if (poa != 0) {
smLoss *= poa_front / poa;
}

if (iyear == 0 || save_full_lifetime_variables == 1)
{
PVSystem->p_snowLoss[nn][idx] = (ssc_number_t)(util::watt_to_kilowatt * Subarrays[nn]->dcPowerSubarray * smLoss);
Expand All @@ -2440,9 +2446,11 @@ void cm_pvsamv1::exec()
if (iyear == 0) annual_snow_loss += (ssc_number_t)(util::watt_to_kilowatt * Subarrays[nn]->dcPowerSubarray * smLoss);
Subarrays[nn]->dcPowerSubarray *= (1 - smLoss);
Subarrays[nn]->dcPowerSubarrayCS *= (1 - smLoss);

}

Subarrays[nn]->Module->dcPowerW *= (1 - smLoss);

Subarrays[nn]->Module->dcPowerWCS *= (1 - smLoss);
if (iyear == 0 || save_full_lifetime_variables == 1) mpptVoltageClipping[nn] *= (1 - smLoss);
}
Expand Down
Loading

0 comments on commit 90fe1c8

Please sign in to comment.