Skip to content

Commit 8308580

Browse files
authored
Merge pull request #564 from EnergySystemsModellingLab/multiple-year-region-for-demand
Refactor tests for demand code
2 parents e6a158c + 37a4bfc commit 8308580

7 files changed

Lines changed: 445 additions & 337 deletions

File tree

examples/simple/agents.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
id,description,regions,decision_rule,decision_lexico_tolerance
2-
A0_GEX,Gas extractors,GBR,single,
3-
A0_GPR,Gas processors,GBR,single,
4-
A0_ELC,Electricity generators,GBR,single,
5-
A0_RES,Residential consumer,GBR,single,
2+
A0_GEX,Gas extractors,all,single,
3+
A0_GPR,Gas processors,all,single,
4+
A0_ELC,Electricity generators,all,single,
5+
A0_RES,Residential consumer,all,single,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
commodity_id,regions,years,time_slice,balance_type,value
2-
CO2EMT,GBR,all,annual,net,0.04
2+
CO2EMT,all,all,annual,net,0.04
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
process_id,regions,years,capital_cost,fixed_operating_cost,variable_operating_cost,lifetime,discount_rate,capacity_to_activity
2-
GASDRV,GBR,all,10.0,0.3,2.0,25,0.1,1.0
3-
GASPRC,GBR,all,7.0,0.21,0.5,25,0.1,1.0
4-
WNDFRM,GBR,all,1000.0,30.0,0.4,25,0.1,31.54
5-
GASCGT,GBR,all,700.0,21.0,0.55,30,0.1,31.54
6-
RGASBR,GBR,all,55.56,1.6668,0.16,15,0.1,1.0
7-
RELCHP,GBR,all,138.9,4.167,0.17,15,0.1,1.0
2+
GASDRV,all,all,10.0,0.3,2.0,25,0.1,1.0
3+
GASPRC,all,all,7.0,0.21,0.5,25,0.1,1.0
4+
WNDFRM,all,all,1000.0,30.0,0.4,25,0.1,31.54
5+
GASCGT,all,all,700.0,21.0,0.55,30,0.1,31.54
6+
RGASBR,all,all,55.56,1.6668,0.16,15,0.1,1.0
7+
RELCHP,all,all,138.9,4.167,0.17,15,0.1,1.0

examples/simple/processes.csv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id,description,regions,start_year,end_year
2-
GASDRV,Dry gas extraction,GBR,2020,2030
3-
GASPRC,Gas processing,GBR,2020,2030
4-
WNDFRM,Wind farm,GBR,2020,2030
5-
GASCGT,Gas combined cycle turbine,GBR,2020,2030
6-
RGASBR,Gas boiler,GBR,2020,2030
7-
RELCHP,Heat pump,GBR,2020,2030
2+
GASDRV,Dry gas extraction,all,2020,2030
3+
GASPRC,Gas processing,all,2020,2030
4+
WNDFRM,Wind farm,all,2020,2030
5+
GASCGT,Gas combined cycle turbine,all,2020,2030
6+
RGASBR,Gas boiler,all,2020,2030
7+
RELCHP,Heat pump,all,2020,2030

src/fixture.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ use crate::agent::{
44
Agent, AgentCommodityPortionsMap, AgentCostLimitsMap, AgentMap, AgentObjectiveMap,
55
AgentSearchSpaceMap, DecisionRule,
66
};
7+
use crate::commodity::CommodityID;
78
use crate::process::{
89
Process, ProcessEnergyLimitsMap, ProcessFlowsMap, ProcessMap, ProcessParameter,
910
ProcessParameterMap,
1011
};
1112
use crate::region::RegionID;
12-
use crate::time_slice::TimeSliceID;
13+
use crate::time_slice::{TimeSliceID, TimeSliceInfo};
1314
use indexmap::indexmap;
1415
use itertools::Itertools;
1516
use rstest::fixture;
@@ -28,6 +29,11 @@ macro_rules! assert_error {
2829
}
2930
pub(crate) use assert_error;
3031

32+
#[fixture]
33+
pub fn commodity_ids() -> HashSet<CommodityID> {
34+
iter::once("commodity1".into()).collect()
35+
}
36+
3137
#[fixture]
3238
pub fn region_ids() -> HashSet<RegionID> {
3339
["GBR".into(), "USA".into()].into_iter().collect()
@@ -97,3 +103,20 @@ pub fn time_slice() -> TimeSliceID {
97103
time_of_day: "day".into(),
98104
}
99105
}
106+
107+
#[fixture]
108+
pub fn time_slice_info() -> TimeSliceInfo {
109+
TimeSliceInfo {
110+
seasons: iter::once("winter".into()).collect(),
111+
times_of_day: iter::once("day".into()).collect(),
112+
fractions: [(
113+
TimeSliceID {
114+
season: "winter".into(),
115+
time_of_day: "day".into(),
116+
},
117+
1.0,
118+
)]
119+
.into_iter()
120+
.collect(),
121+
}
122+
}

0 commit comments

Comments
 (0)