From 7f51144a6d4cb5cc46ad855ecca761785553972a Mon Sep 17 00:00:00 2001 From: janinefreeman Date: Tue, 22 Aug 2023 12:02:29 -0600 Subject: [PATCH] updated code and tests for carbon-free energy dispatch --- shared/lib_battery_dispatch.h | 2 +- test/ssc_test/cmod_battery_pvsamv1_test.cpp | 52 ++++++++++++--------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/shared/lib_battery_dispatch.h b/shared/lib_battery_dispatch.h index c7d47bfde..2dcc1781f 100644 --- a/shared/lib_battery_dispatch.h +++ b/shared/lib_battery_dispatch.h @@ -182,7 +182,7 @@ class dispatch_t /** The dispatch mode. - For behind-the-meter dispatch: 0 = PEAK_SHAVING, 1 = MAINTAIN_TARGET, 2 = CUSTOM, 3 = MANUAL, 4 = FORECAST + For behind-the-meter dispatch: 0 = PEAK_SHAVING, 1 = MAINTAIN_TARGET, 2 = CUSTOM, 3 = MANUAL, 4 = FORECAST, 5 = CARBON_FREE For front-of-meter dispatch: 0 = FOM_AUTOMATED_ECONOMIC, 1 = FOM_PV_SMOOTHING, 2 = FOM_CUSTOM_DISPATCH, 3 = FOM_MANUAL */ int _mode; diff --git a/test/ssc_test/cmod_battery_pvsamv1_test.cpp b/test/ssc_test/cmod_battery_pvsamv1_test.cpp index 54a68d1f2..f97029aed 100644 --- a/test/ssc_test/cmod_battery_pvsamv1_test.cpp +++ b/test/ssc_test/cmod_battery_pvsamv1_test.cpp @@ -117,17 +117,17 @@ TEST_F(CMPvsamv1BatteryIntegration_cmod_pvsamv1, ResidentialACBatteryModelIntegr pairs["analysis_period"] = 1; set_array(data, "load", load_profile_path, 8760); // Load is required for peak shaving controllers - ssc_number_t expectedEnergy[3] = { 8741, 8741, 8831 }; - ssc_number_t expectedBatteryChargeEnergy[3] = { 1442, 1443, 258 }; - ssc_number_t expectedBatteryDischargeEnergy[3] = { 1321, 1323, 233 }; + ssc_number_t expectedEnergy[4] = { 8741, 8741, 8831, 8719 }; + ssc_number_t expectedBatteryChargeEnergy[4] = { 1442, 1443, 258, 1398 }; + ssc_number_t expectedBatteryDischargeEnergy[4] = { 1321, 1323, 233, 1282 }; - ssc_number_t peakKwCharge[3] = { -2.91, -2.66, -2.25 }; - ssc_number_t peakKwDischarge[3] = { 1.39, 1.73, 0.97 }; - ssc_number_t peakCycles[3] = { 1, 1, 1 }; - ssc_number_t avgCycles[3] = { 1, 1, 0.4904 }; + ssc_number_t peakKwCharge[4] = { -2.91, -2.66, -2.25, -2.87 }; + ssc_number_t peakKwDischarge[4] = { 1.39, 1.73, 0.97, 1.40 }; + ssc_number_t peakCycles[4] = { 1, 1, 1, 1 }; + ssc_number_t avgCycles[4] = { 1, 1, 0.4904, 1 }; - // Test peak shaving look ahead, peak shaving look behind, and automated grid power target. Others require additional input data - for (int i = 0; i < 3; i++) { + // Test peak shaving look ahead, peak shaving look behind, and automated grid power target, and carbon-free energy. Others require additional input data + for (int i = 0; i < 4; i++) { switch (i) { case 0: // Peak shaving, look ahead @@ -147,7 +147,12 @@ TEST_F(CMPvsamv1BatteryIntegration_cmod_pvsamv1, ResidentialACBatteryModelIntegr pairs["batt_dispatch_wf_forecast_choice"] = 0; pairs["batt_dispatch_load_forecast_choice"] = 0; break; - + case 3: + // Carbon-free energy dispatch, which is set internally to grid power targets with a constant target of zero + pairs["batt_dispatch_choice"] = 5; + pairs["batt_dispatch_wf_forecast_choice"] = 0; + pairs["batt_dispatch_load_forecast_choice"] = 0; + break; } int pvsam_errors = modify_ssc_data_and_run_module(data, "pvsamv1", pairs); @@ -350,20 +355,20 @@ TEST_F(CMPvsamv1BatteryIntegration_cmod_pvsamv1, ResidentialDCBatteryModelIntegr pairs["analysis_period"] = 1; set_array(data, "load", load_profile_path, 8760); // Load is required for peak shaving controllers - ssc_number_t expectedEnergy[3] = { 8781, 8784, 8846 }; - ssc_number_t expectedBatteryChargeEnergy[3] = { 1412.75, 1414.89, 253.2 }; - ssc_number_t expectedBatteryDischargeEnergy[3] = { 1283.8, 1285.88, 226.3 }; + ssc_number_t expectedEnergy[4] = { 8781, 8784, 8846, 8757 }; + ssc_number_t expectedBatteryChargeEnergy[4] = { 1412.75, 1414.89, 253.2, 1328.4 }; + ssc_number_t expectedBatteryDischargeEnergy[4] = { 1283.8, 1285.88, 226.3, 1247.2 }; - ssc_number_t peakKwCharge[3] = { -3.06, -2.91, -2.51 }; - ssc_number_t peakKwDischarge[3] = { 1.40, 1.74, 0.967 }; - ssc_number_t peakCycles[3] = { 1, 1, 1 }; - ssc_number_t avgCycles[3] = { 1.0, 1.0, 0.4794 }; + ssc_number_t peakKwCharge[4] = { -3.06, -2.91, -2.51, -3.06 }; + ssc_number_t peakKwDischarge[4] = { 1.40, 1.74, 0.967, 1.41 }; + ssc_number_t peakCycles[4] = { 1, 1, 1, 1 }; + ssc_number_t avgCycles[4] = { 1.0, 1.0, 0.4794, 1.0 }; - ssc_number_t q_rel[3] = { 97.198, 97.204, 97.239 }; - ssc_number_t cyc_avg[3] = { 33.73, 33.80, 12.381 }; + ssc_number_t q_rel[4] = { 97.198, 97.204, 97.239, 97.206 }; + ssc_number_t cyc_avg[4] = { 33.73, 33.80, 12.381, 33.66 }; // Test peak shaving look ahead, peak shaving look behind, and automated grid power target. Others require additional input data - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 4; i++) { switch (i) { case 0: // Peak shaving, look ahead @@ -383,7 +388,12 @@ TEST_F(CMPvsamv1BatteryIntegration_cmod_pvsamv1, ResidentialDCBatteryModelIntegr pairs["batt_dispatch_wf_forecast_choice"] = 0; pairs["batt_dispatch_load_forecast_choice"] = 0; break; - + case 3: + // Input grid power targets + pairs["batt_dispatch_choice"] = 5; + pairs["batt_dispatch_wf_forecast_choice"] = 0; + pairs["batt_dispatch_load_forecast_choice"] = 0; + break; } int pvsam_errors = modify_ssc_data_and_run_module(data, "pvsamv1", pairs);