Breakthrough-Energy / Breakthrough-Energy/PreREISE
test: correct_cumsum values for all demand outputs
- Dominant language
- Jupyter Notebook
- Stars
- 22
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
We currently have an integration test for the LDV Smart Charging function which has following assertion:
``` python
correct_cumsum = np.array(
[
0.0,
9796092.83844097,
19198735.09458018,
27636677.75177433,
36032644.7281563,
44112809.4024421,
52256940.31259822,
61077768.57472202,
]
)
np.testing.assert_allclose(demand.cumsum()[::1095], correct_cumsum)
```
which checks the cumulative sum of the demand values every 1095 hours within the year. Ideally these values would come from the Matlab code...
There are potentially 16 categories to test, for both immediate and smart charging cases:
1. LDV, urban, for ranges of 100, 200, and 300 miles
2. LDV, rural, for ranges of 100, 200, and 300 miles
3. LDT, urban, for ranges of 100, 200, and 300 miles
4. LDT, rural, for ranges of 100, 200, and 300 miles
5. MDV, urban
6. MDV, rural
7. HDV, urban
8. HDV, rural
Should we test for all 9 census divisions? That would mean an additional 8*12 = 96 tests, or 112 total. This seems excessive…
Really we just need to test the code for each type. Might be able to just do:
Immediate and smart charging:
1. LDV, urban, pick one of the ranges
2. LDV, rural, pick one of the ranges
3. HDV, urban
4. HDV, rural
Existing test parameters for immediate charging LDV:
```python
immediate_charging(
census_region=1,
model_year=2017,
veh_range=100,
kwhmi=0.242,
power=6.6,
location_strategy=2,
veh_type="LDV",
filepath=path_to_file,
)
```
Existing test parameters for smart charging LDV:
``` python
result = smart_charging.smart_charging(
census_region=1,
model_year=2017,
veh_range=100,
kwhmi=0.242,
power=6.6,
location_strategy=2,
veh_type="LDV",
filepath=path_to_file,
daily_values=daily_values,
load_demand=load_demand,
trip_strategy=1,
)
```
Example code for immediate case 3:
``` python
result = immediate_charging_HDV.immediate_charging(
model_year=2050,
veh_range=200,
power=80,
location_strategy=1,
veh_type="HDV",
filepath=path_to_file,
trip_strategy=1,
)
bev_vmt = load_urbanized_scaling_factor(
model_year=2050,
veh_type="HDV",
veh_range=200,
urbanized_area="Antioch",
state="CA",
filepath= path_to_file,
)
final_result = immediate_charging_HDV.adjust_bev(
model_year=2050,
veh_type="HDV",
veh_range=200,
model_year_profile=result,
bev_vmt=bev_vmt,
charging_efficiency=0.95,
)
correct_cumsum = np.array(
[
10.8255287099344,
10458.16992,
20964.88916,
31443.09284,
41900.81189,
52407.05727,
62866.27995,
73352.53979,
],
)
np.testing.assert_allclose(final_result.cumsum()[::1095], correct_cumsum)
```
Example code for smart charging case 3:
``` python
bev_vmt = data_helper.load_urbanized_scaling_factor(
model_year=2050,
veh_type="HDV",
veh_range=200,
urbanized_area="Antioch",
state="CA",
filepath=path_to_file,
)
result = smart_charging_HDV.smart_charging(
model_year=2050,
veh_range=200,
power=80,
location_strategy=1,
veh_type="HDV",
filepath=path_to_file,
initial_load=load_demand,
bev_vmt=bev_vmt,
trip_strategy=1,
)
correct_cumsum = np.array(
[
1.22854177233283,
4729.417063,
9456.028814,
14087.49171,
18817.56654,
23521.75604,
28175.75066,
32904.52077,
]
)
np.testing.assert_allclose(result.cumsum()[::1095], correct_cumsum)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.