Skip to content

Commit bae0f6c

Browse files
committed
Merge branch 'develop' of https://github.com/NREL/ssc into update_test_times
2 parents 5e18c65 + 5a0d03f commit bae0f6c

28 files changed

+1505
-15
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
set -e
7777
exec 3>&1 1>> ${SSCDIR}/build/test/gtest.log 2>&1
7878
${SSCDIR}/build/test/Test | tee /dev/fd/3
79+
exit ${PIPESTATUS[0]}
7980
8081
- name: Compare Test Times
8182
run: |
@@ -165,7 +166,8 @@ jobs:
165166
set -e
166167
exec 3>&1 1>> ${SSCDIR}/build/test/gtest.log 2>&1
167168
${SSCDIR}/build/test/Test | tee /dev/fd/3
168-
169+
exit ${PIPESTATUS[0]}
170+
169171
- name: Compare Test Times
170172
run: |
171173
pip install pandas requests

.github/workflows/coverage.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
env:
88
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
99
BUILD_TYPE: Debug
10-
GTEST_REF: b85864c64758dec007208e56af933fc3f52044ee
10+
GTEST_REF: b85864c64758dec007208e56af933fc3f52044dd
1111

1212
jobs:
1313
coveralls-on-ubuntu:
@@ -81,7 +81,6 @@ jobs:
8181
make -j4
8282
8383
- name: Test
84-
# Turn off fast fail for when the landbosse tests write to cerr
8584
shell: bash
8685
run: |
8786
set -e

shared/lib_battery_dispatch_automatic_fom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void dispatch_automatic_front_of_meter_t::update_dispatch(size_t year, size_t ho
281281
}
282282
}
283283
pv_hours_on = revenueToPVChargeForecast.size() / _steps_per_hour;
284-
revenueToPVChargeMax = pv_hours_on >= t_duration ? *std::max_element(std::begin(revenueToPVChargeForecast), std::end(revenueToPVChargeForecast)): 0;
284+
revenueToPVChargeMax = (!revenueToPVChargeForecast.empty() && pv_hours_on >= t_duration) ? *std::max_element(std::begin(revenueToPVChargeForecast), std::end(revenueToPVChargeForecast)): 0;
285285
}
286286

287287
/*! Economic benefit of charging from clipped PV in current time step to discharge sometime in the next X hours (clipped PV is free) ($/kWh) */

shared/lib_pv_io_manager.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,41 @@ Irradiance_IO::Irradiance_IO(compute_module* cm, std::string cmName)
206206
throw exec_error(cmName, "Albedos must be greater than zero and less than one in the monthly uniform albedo matrix.");
207207
}
208208
}
209+
// read in the user entered snow data
210+
211+
std::vector<double> orig_snow_array = cm->as_vector_double("snow_array");
212+
// align the user entered snow data with the weather file data
213+
std::vector<double> aligned_snow_array;
214+
aligned_snow_array.reserve(numberOfWeatherFileRecords);
215+
if (orig_snow_array.size() == 1) {
216+
aligned_snow_array.resize(numberOfWeatherFileRecords);
217+
std::fill(aligned_snow_array.begin(), aligned_snow_array.end(), orig_snow_array[0]);
218+
}
219+
else if (orig_snow_array.size() < numberOfWeatherFileRecords) {
220+
if (numberOfWeatherFileRecords % orig_snow_array.size() != 0) {
221+
throw exec_error(cmName, "Snow depth array and weather file must have divisible periods.");
222+
}
223+
size_t mult = numberOfWeatherFileRecords / orig_snow_array.size();
224+
for (double depth : orig_snow_array) {
225+
for (size_t j = 0; j < mult; j++) {
226+
aligned_snow_array.push_back(depth);
227+
}
228+
}
229+
}
230+
else if (orig_snow_array.size() == numberOfWeatherFileRecords) {
231+
aligned_snow_array = orig_snow_array;
232+
}
233+
else {
234+
if (orig_snow_array.size() % numberOfWeatherFileRecords != 0) {
235+
throw exec_error(cmName, "Snow depth array and weather file must have divisible periods.");
236+
}
237+
size_t mult = orig_snow_array.size() / numberOfWeatherFileRecords;
238+
for (size_t i = 0; i < orig_snow_array.size(); i += mult) {
239+
aligned_snow_array.push_back(orig_snow_array[i]);
240+
}
241+
}
242+
userSpecifiedSnowDepth = aligned_snow_array;
243+
209244

210245
checkWeatherFile(cm, cmName);
211246
}
@@ -307,7 +342,7 @@ void Irradiance_IO::AllocateOutputs(compute_module* cm)
307342
else {
308343
p_weatherFileAlbedo = cm->allocate("alb", numberOfWeatherFileRecords);
309344
}
310-
p_weatherFileSnowDepth = cm->allocate("snowdepth", numberOfWeatherFileRecords);
345+
p_snowDepth = cm->allocate("snowdepth", numberOfWeatherFileRecords);
311346

312347
// If using input POA, must have POA for every subarray or assume POA applies to each subarray
313348
for (size_t subarray = 0; subarray != numberOfSubarrays; subarray++) {
@@ -725,6 +760,7 @@ PVSystem_IO::PVSystem_IO(compute_module* cm, std::string cmName, Simulation_IO*
725760
enableDCLifetimeLosses = cm->as_boolean("en_dc_lifetime_losses");
726761
enableACLifetimeLosses = cm->as_boolean("en_ac_lifetime_losses");
727762
enableSnowModel = cm->as_boolean("en_snow_model");
763+
useWeatherFileSnow = cm->as_boolean("use_snow_weather_file");
728764

729765
// The shared inverter of the PV array and a tightly-coupled DC connected battery
730766
std::unique_ptr<SharedInverter> tmpSharedInverter(new SharedInverter(Inverter->inverterType, numberOfInverters, &Inverter->sandiaInverter, &Inverter->partloadInverter, &Inverter->ondInverter, numberOfInvertersClipping));

shared/lib_pv_io_manager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ struct Irradiance_IO
234234
flag useSpatialAlbedos; /// Specify whether to use spatial albedos
235235
std::vector<double> userSpecifiedMonthlyAlbedo; /// User can provide monthly uniform ground albedo values (0-1)
236236
util::matrix_t<double> userSpecifiedMonthlySpatialAlbedos; /// User can provide monthly spatial ground albedo values (0-1), [month, location]
237+
std::vector<double> userSpecifiedSnowDepth; /// User can provide hourly snow depth data (cm)
237238

238239
// Irradiance data Outputs (p_ is just a convention to organize all pointer outputs)
239240
ssc_number_t * p_weatherFileGHI; /// The Global Horizonal Irradiance from the weather file [W/m2]
@@ -245,7 +246,7 @@ struct Irradiance_IO
245246
ssc_number_t * p_weatherFileAmbientTemp; /// The ambient temperature from the weather file [C]
246247
ssc_number_t * p_weatherFileAlbedo; /// The ground albedo from the weather file
247248
ssc_number_t* p_weatherFileAlbedoSpatial; /// The ground albedo from the weather file and spatial matrix input
248-
ssc_number_t * p_weatherFileSnowDepth; /// The snow depth from the weather file
249+
ssc_number_t * p_snowDepth; /// The snow depth from the weather file or user input array
249250
ssc_number_t * p_IrradianceCalculated[3]; /// The calculated components of the irradiance [W/m2]
250251
ssc_number_t * p_sunZenithAngle; /// The calculate sun zenith angle [degrees]
251252
ssc_number_t * p_sunAltitudeAngle; /// The calculated sun altitude angle [degrees]
@@ -297,6 +298,7 @@ struct PVSystem_IO
297298
flag enableDCLifetimeLosses;
298299
flag enableACLifetimeLosses;
299300
flag enableSnowModel;
301+
flag useWeatherFileSnow;
300302

301303
int stringsInParallel;
302304
double ratedACOutput; ///< AC Power rating for whole system (all inverters)

ssc/cmod_pvsamv1.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static var_info _cm_vtab_pvsamv1[] = {
6464
// misc inputs
6565
{SSC_INPUT, SSC_NUMBER, "en_snow_model", "Toggle snow loss estimation", "0/1", "", "Losses", "?=0", "BOOLEAN", "" },
6666
{ SSC_INPUT, SSC_NUMBER, "snow_slide_coefficient", "Snow Slide Coefficient", "", "", "Losses", "?=1.97", "", "" },
67-
67+
{SSC_INPUT, SSC_ARRAY, "snow_array", "Hourly snow depth ", "cm", "", "Losses", "?", "", ""},
68+
{SSC_INPUT, SSC_NUMBER, "use_snow_weather_file", "Use the snow depth from the weather file", "0/1", "0=user-specified,1=weatherfile", "Losses", "*", "", ""},
6869
{SSC_INPUT, SSC_NUMBER, "system_capacity", "DC Nameplate capacity", "kWdc", "", "System Design", "*", "", "" },
6970
{SSC_INPUT, SSC_NUMBER, "use_wf_albedo", "Use albedo in weather file if provided", "0/1", "0=user-specified,1=weatherfile", "Solar Resource", "?=1", "BOOLEAN", "" },
7071
{SSC_INPUT, SSC_NUMBER, "use_spatial_albedos", "Use spatial albedo values", "0/1", "0=no,1=yes", "Solar Resource", "?=0", "BOOLEAN", "" },
@@ -620,7 +621,7 @@ static var_info _cm_vtab_pvsamv1[] = {
620621
{ SSC_OUTPUT, SSC_ARRAY, "tdry", "Weather file ambient temperature", "C", "", "Time Series", "*", "", "" },
621622
{ SSC_OUTPUT, SSC_ARRAY, "alb", "Albedo", "", "", "Time Series", "", "", "" },
622623
{ SSC_OUTPUT, SSC_MATRIX, "alb_spatial", "Albedo spatial", "", "", "Time Series", "", "", "" },
623-
{ SSC_OUTPUT, SSC_ARRAY, "snowdepth", "Weather file snow depth", "cm", "", "Time Series", "", "", "" },
624+
{ SSC_OUTPUT, SSC_ARRAY, "snowdepth", "Snow depth", "cm", "", "Time Series", "", "", "" },
624625

625626
// calculated sun position data
626627
{ SSC_OUTPUT, SSC_ARRAY, "sol_zen", "Sun zenith angle", "degrees", "", "Time Series", "*", "", "" },
@@ -2465,9 +2466,20 @@ void cm_pvsamv1::exec()
24652466
if (PVSystem->enableSnowModel)
24662467
{
24672468
float smLoss = 0.0f;
2468-
2469+
float snowDep = 0.0f;
2470+
// Now we have the option to either use weather file snow data or user input snow data
2471+
if (PVSystem->useWeatherFileSnow)
2472+
{
2473+
// Use weather file snow data
2474+
snowDep = (float)wf.snow;
2475+
}
2476+
else
2477+
{
2478+
// Use user input snow data
2479+
snowDep = Irradiance->userSpecifiedSnowDepth[idx % nrec];
2480+
}
24692481
if (!Subarrays[nn]->snowModel.getLoss((float)(Subarrays[nn]->poa.poaBeamFront + Subarrays[nn]->poa.poaDiffuseFront + Subarrays[nn]->poa.poaGroundFront + ipoa_rear_after_losses[nn]),
2470-
(float)Subarrays[nn]->poa.surfaceTiltDegrees, (float)wf.wspd, (float)wf.tdry, (float)wf.snow, sunup, 1.0f / step_per_hour, smLoss))
2482+
(float)Subarrays[nn]->poa.surfaceTiltDegrees, (float)wf.wspd, (float)wf.tdry, snowDep, sunup, 1.0f / step_per_hour, smLoss))
24712483
{
24722484
if (!Subarrays[nn]->snowModel.good)
24732485
throw exec_error("pvsamv1", Subarrays[nn]->snowModel.msg);
@@ -2564,7 +2576,14 @@ void cm_pvsamv1::exec()
25642576
{
25652577
Irradiance->p_weatherFileWindSpeed[idx] = (ssc_number_t)wf.wspd;
25662578
Irradiance->p_weatherFileAmbientTemp[idx] = (ssc_number_t)wf.tdry;
2567-
Irradiance->p_weatherFileSnowDepth[idx] = (ssc_number_t)wf.snow;
2579+
double snoDep;
2580+
if (PVSystem->useWeatherFileSnow) {
2581+
snoDep = (ssc_number_t)wf.snow;
2582+
}
2583+
else {
2584+
snoDep = Irradiance->userSpecifiedSnowDepth[idx % nrec];
2585+
}
2586+
Irradiance->p_snowDepth[idx] = snoDep;
25682587
Irradiance->p_sunZenithAngle[idx] = (ssc_number_t)solzen;
25692588
Irradiance->p_sunAltitudeAngle[idx] = (ssc_number_t)solalt;
25702589
Irradiance->p_sunAzimuthAngle[idx] = (ssc_number_t)solazi;

ssc/cmod_tcsmolten_salt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ static var_info _cm_vtab_tcsmolten_salt[] = {
316316
{ SSC_INPUT, SSC_NUMBER, "bop_par_2", "Balance of plant parasitic power fraction - quadratic coeff", "", "", "System Control", "*", "", "" },
317317

318318
// System Control
319+
{ SSC_INPUT, SSC_NUMBER, "is_timestep_load_fractions", "Use turbine load fraction for each timestep instead of block dispatch?", "", "", "Time of Delivery Factors", "?=0", "", "SIMULATION_PARAMETER" },
319320
{ SSC_INPUT, SSC_ARRAY, "timestep_load_fractions", "Turbine load fraction for each timestep, alternative to block dispatch", "", "", "System Control", "", "", ""},
320321
{ SSC_INPUT, SSC_ARRAY, "f_turb_tou_periods", "Dispatch logic for turbine load fraction", "", "", "System Control", "*", "", ""},
321322
{ SSC_INPUT, SSC_MATRIX, "weekday_schedule", "12x24 CSP operation Time-of-Use Weekday schedule", "", "", "System Control", "*", "", ""},
@@ -689,7 +690,7 @@ static var_info _cm_vtab_tcsmolten_salt[] = {
689690
{ SSC_OUTPUT, SSC_ARRAY, "P_out_net", "System net electrical power", "MWe", "", "", "sim_type=1", "", ""},
690691

691692
// Controller outputs
692-
{ SSC_OUTPUT, SSC_ARRAY, "tou_value", "CSP operating time-of-use value", "", "", "", "sim_type=1", "", ""},
693+
{ SSC_OUTPUT, SSC_ARRAY, "tou_value", "CSP operating time-of-use period", "", "", "", "sim_type=1", "", ""},
693694
{ SSC_OUTPUT, SSC_ARRAY, "pricing_mult", "PPA price multiplier", "", "", "", "sim_type=1", "", ""},
694695
{ SSC_OUTPUT, SSC_ARRAY, "n_op_modes", "Operating modes in reporting timestep", "", "", "", "sim_type=1", "", ""},
695696
{ SSC_OUTPUT, SSC_ARRAY, "op_mode_1", "1st operating mode", "", "", "", "sim_type=1", "", ""},

ssc/vartab.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class var_data
182182
class general_error : public std::exception
183183
{
184184
public:
185-
explicit general_error(std::string s, float t=-1.0) : err_text(move(s)), time(t) { }
185+
explicit general_error(std::string s, float t=-1.0) : err_text(std::move(s)), time(t) { }
186186
std::string err_text;
187187
float time;
188188
};

test/input_cases/general_data/pvsmoothing_Phoenix_Validation_alloptions.json

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

test/input_cases/pvsamv1_common_data.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ void pvsamv_nofinancial_default(ssc_data_t& data)
6868
ssc_data_set_number(data, "transformer_no_load_loss", 0);
6969
ssc_data_set_number(data, "transformer_load_loss", 0);
7070
ssc_data_set_number(data, "en_snow_model", 0);
71+
ssc_data_set_number(data, "use_snow_weather_file", 1);
72+
ssc_number_t snow_array[1] = { 0 };
73+
ssc_data_set_array(data, "snow_array", snow_array, 1);
7174
ssc_data_set_number(data, "system_capacity", 4.6928696632385254);
7275
ssc_data_set_number(data, "use_wf_albedo", 0);
7376
ssc_number_t p_albedo[12] = { 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224 };
@@ -568,6 +571,9 @@ void pvsamv1_with_residential_default(ssc_data_t& data)
568571
ssc_data_set_number(data, "use_wf_albedo", 0);
569572
ssc_number_t p_albedo[12] = { 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 0.20000000298023224 };
570573
ssc_data_set_array(data, "albedo", p_albedo, 12);
574+
ssc_data_set_number(data, "use_snow_weather_file", 1);
575+
ssc_number_t snow_array[1] = { 0 };
576+
ssc_data_set_array(data, "snow_array", snow_array, 1);
571577
ssc_data_set_number(data, "irrad_mode", 0);
572578
ssc_data_set_number(data, "sky_model", 2);
573579
ssc_data_set_number(data, "inverter_count", 1);

0 commit comments

Comments
 (0)