Skip to content

Commit

Permalink
Merge pull request #216 from rl-institut/feature/report_max_flex_energy
Browse files Browse the repository at this point in the history
report timeseries: add max_flex_energy
  • Loading branch information
j-brendel authored Sep 11, 2024
2 parents 81f6329 + 6cb3821 commit 07093fc
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 121 deletions.
196 changes: 98 additions & 98 deletions examples/output/simulation.csv
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
timestep,time,price [EUR/kWh],grid supply [kW],fixed load [kW],flex band min [kW],flex band base [kW],flex band max [kW],sum CS power [kW],# occupied CS [-],# CS in use [-],C1 [kW],C2 [kW],C3 [kW]
0,2020-01-01 00:00:00,2.0,0,0,0,0,7,0,1,0,0,0,0
1,2020-01-01 00:15:00,42,0,0,0,0,7,0,1,0,0,0,0
2,2020-01-01 00:30:00,42,0,0,0,0,7,0,1,0,0,0,0
3,2020-01-01 00:45:00,42,0,0,0,0,7,0,1,0,0,0,0
4,2020-01-01 01:00:00,42,0,0,0,0,7,0,1,0,0,0,0
5,2020-01-01 01:15:00,42,0,0,0,0,7,0,1,0,0,0,0
6,2020-01-01 01:30:00,42,0,0,0,0,7,0,1,0,0,0,0
7,2020-01-01 01:45:00,42,0,0,0,0,7,0,1,0,0,0,0
8,2020-01-01 02:00:00,42,0,0,0,0,7,0,1,0,0,0,0
9,2020-01-01 02:15:00,42,0,0,0,0,7,0,1,0,0,0,0
10,2020-01-01 02:30:00,42,0,0,0,0,7,0,1,0,0,0,0
11,2020-01-01 02:45:00,42,0,0,0,0,7,0,1,0,0,0,0
12,2020-01-01 03:00:00,42,0,0,0,0,7,0,1,0,0,0,0
13,2020-01-01 03:15:00,42,0,0,0,0,7,0,1,0,0,0,0
14,2020-01-01 03:30:00,42,0,0,0,0,7,0,1,0,0,0,0
15,2020-01-01 03:45:00,42,0,0,0,0,7,0,1,0,0,0,0
16,2020-01-01 04:00:00,42,0,0,0,0,7,0,1,0,0,0,0
17,2020-01-01 04:15:00,42,0,0,0,0,7,0,1,0,0,0,0
18,2020-01-01 04:30:00,42,0,0,0,0,7,0,1,0,0,0,0
19,2020-01-01 04:45:00,42,0,0,0,0,7,0,1,0,0,0,0
20,2020-01-01 05:00:00,42,0,0,0,0,7,0,1,0,0,0,0
21,2020-01-01 05:15:00,42,0,0,0,0,7,0,1,0,0,0,0
22,2020-01-01 05:30:00,42,0,0,0,0,7,0,1,0,0,0,0
23,2020-01-01 05:45:00,42,0,0,0,0,7,0,1,0,0,0,0
24,2020-01-01 06:00:00,42,0,0,0,0,7,0,1,0,0,0,0
25,2020-01-01 06:15:00,42,0,0,0,0,7,0,1,0,0,0,0
26,2020-01-01 06:30:00,42,0,0,0,0,7,0,1,0,0,0,0
27,2020-01-01 06:45:00,42,0,0,0,0,7,0,1,0,0,0,0
28,2020-01-01 07:00:00,42,0,0,0,0,7,0,1,0,0,0,0
29,2020-01-01 07:15:00,42,0,0,0,0,7,0,1,0,0,0,0
30,2020-01-01 07:30:00,42,0,0,0,0,7,0,1,0,0,0,0
31,2020-01-01 07:45:00,42,0,0,0,0,7,0,1,0,0,0,0
32,2020-01-01 08:00:00,42,0,0,0,0,0,0,0,0,0,0,0
33,2020-01-01 08:15:00,42,0,0,0,0,0,0,0,0,0,0,0
34,2020-01-01 08:30:00,42,0,0,0,0,0,0,0,0,0,0,0
35,2020-01-01 08:45:00,42,0,0,0,0,0,0,0,0,0,0,0
36,2020-01-01 09:00:00,42,0,0,0,0,0,0,0,0,0,0,0
37,2020-01-01 09:15:00,42,0,0,0,0,0,0,0,0,0,0,0
38,2020-01-01 09:30:00,42,0,0,0,0,0,0,0,0,0,0,0
39,2020-01-01 09:45:00,42,0,0,0,0,0,0,0,0,0,0,0
40,2020-01-01 10:00:00,42,0,0,0,0,0,0,0,0,0,0,0
41,2020-01-01 10:15:00,42,0,0,0,0,0,0,0,0,0,0,0
42,2020-01-01 10:30:00,42,0,0,0,0,0,0,0,0,0,0,0
43,2020-01-01 10:45:00,42,0,0,0,0,0,0,0,0,0,0,0
44,2020-01-01 11:00:00,42,0,0,0,0,0,0,0,0,0,0,0
45,2020-01-01 11:15:00,42,0,0,0,0,0,0,0,0,0,0,0
46,2020-01-01 11:30:00,42,0,0,0,0,0,0,0,0,0,0,0
47,2020-01-01 11:45:00,42,0,0,0,0,0,0,0,0,0,0,0
48,2020-01-01 12:00:00,42,0,0,0,0,0,0,0,0,0,0,0
49,2020-01-01 12:15:00,42,0,0,0,0,0,0,0,0,0,0,0
50,2020-01-01 12:30:00,42,0,0,0,0,0,0,0,0,0,0,0
51,2020-01-01 12:45:00,42,0,0,0,0,0,0,0,0,0,0,0
52,2020-01-01 13:00:00,42,0,0,0,0,0,0,0,0,0,0,0
53,2020-01-01 13:15:00,42,0,0,0,0,0,0,0,0,0,0,0
54,2020-01-01 13:30:00,42,0,0,0,0,0,0,0,0,0,0,0
55,2020-01-01 13:45:00,42,0,0,0,0,0,0,0,0,0,0,0
56,2020-01-01 14:00:00,42,0,0,0,0,0,0,0,0,0,0,0
57,2020-01-01 14:15:00,42,0,0,0,0,0,0,0,0,0,0,0
58,2020-01-01 14:30:00,42,0,0,0,0,0,0,0,0,0,0,0
59,2020-01-01 14:45:00,42,0,0,0,0,0,0,0,0,0,0,0
60,2020-01-01 15:00:00,42,0,0,0,0,0,0,0,0,0,0,0
61,2020-01-01 15:15:00,42,0,0,0,0,0,0,0,0,0,0,0
62,2020-01-01 15:30:00,42,0,0,0,0,0,0,0,0,0,0,0
63,2020-01-01 15:45:00,42,0,0,0,0,0,0,0,0,0,0,0
64,2020-01-01 16:00:00,42,0,0,0,0,0,0,0,0,0,0,0
65,2020-01-01 16:15:00,42,0,0,0,0,0,0,0,0,0,0,0
66,2020-01-01 16:30:00,42,0,0,0,0,0,0,0,0,0,0,0
67,2020-01-01 16:45:00,42,0,0,0,0,0,0,0,0,0,0,0
68,2020-01-01 17:00:00,42,-3.96,0,0,0,7,3.96,1,1,3.96,0,0
69,2020-01-01 17:15:00,42,-1.935,0,0,0,7,1.935,1,1,1.935,0,0
70,2020-01-01 17:30:00,42,0,0,0,0,7,0,1,0,0,0,0
71,2020-01-01 17:45:00,42,0,0,0,0,7,0,1,0,0,0,0
72,2020-01-01 18:00:00,42,0,0,0,0,7,0,1,0,0,0,0
73,2020-01-01 18:15:00,42,0,0,0,0,7,0,1,0,0,0,0
74,2020-01-01 18:30:00,42,0,0,0,0,7,0,1,0,0,0,0
75,2020-01-01 18:45:00,42,0,0,0,0,7,0,1,0,0,0,0
76,2020-01-01 19:00:00,42,0,0,0,0,7,0,1,0,0,0,0
77,2020-01-01 19:15:00,42,0,0,0,0,7,0,1,0,0,0,0
78,2020-01-01 19:30:00,42,0,0,0,0,7,0,1,0,0,0,0
79,2020-01-01 19:45:00,42,0,0,0,0,7,0,1,0,0,0,0
80,2020-01-01 20:00:00,42,0,0,0,0,7,0,1,0,0,0,0
81,2020-01-01 20:15:00,42,0,0,0,0,7,0,1,0,0,0,0
82,2020-01-01 20:30:00,42,0,0,0,0,7,0,1,0,0,0,0
83,2020-01-01 20:45:00,42,0,0,0,0,7,0,1,0,0,0,0
84,2020-01-01 21:00:00,42,0,0,0,0,7,0,1,0,0,0,0
85,2020-01-01 21:15:00,42,0,0,0,0,7,0,1,0,0,0,0
86,2020-01-01 21:30:00,42,0,0,0,0,7,0,1,0,0,0,0
87,2020-01-01 21:45:00,42,0,0,0,0,7,0,1,0,0,0,0
88,2020-01-01 22:00:00,42,0,0,0,0,7,0,1,0,0,0,0
89,2020-01-01 22:15:00,42,0,0,0,0,7,0,1,0,0,0,0
90,2020-01-01 22:30:00,42,0,0,0,0,7,0,1,0,0,0,0
91,2020-01-01 22:45:00,42,0,0,0,0,7,0,1,0,0,0,0
92,2020-01-01 23:00:00,42,0,0,0,0,7,0,1,0,0,0,0
93,2020-01-01 23:15:00,42,0,0,0,0,7,0,1,0,0,0,0
94,2020-01-01 23:30:00,42,0,0,0,0,7,0,1,0,0,0,0
95,2020-01-01 23:45:00,42,0,0,0,0,7,0,1,0,0,0,0
96,2020-01-02 00:00:00,42,0,0,0,0,7,0,1,0,0,0,0
timestep,time,price [EUR/kWh],grid supply [kW],fixed load [kW],flex band min [kW],flex band base [kW],flex band max [kW],max energy flex [kWh],sum CS power [kW],# occupied CS [-],# CS in use [-],C1 [kW],C2 [kW],C3 [kW]
0,2020-01-01 00:00:00,2.0,0,0,0,0,7,0.0,0,1,0,0,0,0
1,2020-01-01 00:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
2,2020-01-01 00:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
3,2020-01-01 00:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
4,2020-01-01 01:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
5,2020-01-01 01:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
6,2020-01-01 01:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
7,2020-01-01 01:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
8,2020-01-01 02:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
9,2020-01-01 02:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
10,2020-01-01 02:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
11,2020-01-01 02:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
12,2020-01-01 03:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
13,2020-01-01 03:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
14,2020-01-01 03:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
15,2020-01-01 03:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
16,2020-01-01 04:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
17,2020-01-01 04:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
18,2020-01-01 04:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
19,2020-01-01 04:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
20,2020-01-01 05:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
21,2020-01-01 05:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
22,2020-01-01 05:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
23,2020-01-01 05:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
24,2020-01-01 06:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
25,2020-01-01 06:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
26,2020-01-01 06:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
27,2020-01-01 06:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
28,2020-01-01 07:00:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
29,2020-01-01 07:15:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
30,2020-01-01 07:30:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
31,2020-01-01 07:45:00,42,0,0,0,0,7,0.0,0,1,0,0,0,0
32,2020-01-01 08:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
33,2020-01-01 08:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
34,2020-01-01 08:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
35,2020-01-01 08:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
36,2020-01-01 09:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
37,2020-01-01 09:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
38,2020-01-01 09:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
39,2020-01-01 09:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
40,2020-01-01 10:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
41,2020-01-01 10:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
42,2020-01-01 10:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
43,2020-01-01 10:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
44,2020-01-01 11:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
45,2020-01-01 11:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
46,2020-01-01 11:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
47,2020-01-01 11:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
48,2020-01-01 12:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
49,2020-01-01 12:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
50,2020-01-01 12:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
51,2020-01-01 12:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
52,2020-01-01 13:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
53,2020-01-01 13:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
54,2020-01-01 13:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
55,2020-01-01 13:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
56,2020-01-01 14:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
57,2020-01-01 14:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
58,2020-01-01 14:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
59,2020-01-01 14:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
60,2020-01-01 15:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
61,2020-01-01 15:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
62,2020-01-01 15:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
63,2020-01-01 15:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
64,2020-01-01 16:00:00,42,0,0,0,0,0,0,0,0,0,0,0,0
65,2020-01-01 16:15:00,42,0,0,0,0,0,0,0,0,0,0,0,0
66,2020-01-01 16:30:00,42,0,0,0,0,0,0,0,0,0,0,0,0
67,2020-01-01 16:45:00,42,0,0,0,0,0,0,0,0,0,0,0,0
68,2020-01-01 17:00:00,42,-3.96,0,0,0,7,8.4,3.96,1,1,3.96,0,0
69,2020-01-01 17:15:00,42,-1.935,0,0,0,7,7.459,1.935,1,1,1.935,0,0
70,2020-01-01 17:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
71,2020-01-01 17:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
72,2020-01-01 18:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
73,2020-01-01 18:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
74,2020-01-01 18:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
75,2020-01-01 18:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
76,2020-01-01 19:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
77,2020-01-01 19:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
78,2020-01-01 19:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
79,2020-01-01 19:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
80,2020-01-01 20:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
81,2020-01-01 20:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
82,2020-01-01 20:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
83,2020-01-01 20:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
84,2020-01-01 21:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
85,2020-01-01 21:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
86,2020-01-01 21:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
87,2020-01-01 21:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
88,2020-01-01 22:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
89,2020-01-01 22:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
90,2020-01-01 22:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
91,2020-01-01 22:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
92,2020-01-01 23:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
93,2020-01-01 23:15:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
94,2020-01-01 23:30:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
95,2020-01-01 23:45:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
96,2020-01-02 00:00:00,42,0,0,0,0,7,7.0,0,1,0,0,0,0
22 changes: 20 additions & 2 deletions spice_ev/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ def aggregate_timeseries(scenario, gcID):
header += ["battery power [kW]", "bat. stored energy [kWh]"]
# flex
if scenario.flex_bands is not None:
header += ["flex band min [kW]", "flex band base [kW]", "flex band max [kW]"]
header += [
"flex band min [kW]", "flex band base [kW]",
"flex band max [kW]", "max energy flex [kWh]"]
# schedule & window
if hasSchedule:
header.append("schedule [kW]")
Expand Down Expand Up @@ -550,14 +552,30 @@ def aggregate_timeseries(scenario, gcID):

# flex, might not exist
if scenario.flex_bands is not None:
# max flex energy: (1-soc) * capacity for all connected vehicles
max_flex_energy = 0
vids = sorted(scenario.components.vehicles.keys())
connected = scenario.connected[idx]
for vidx, vid in enumerate(vids):
if vid not in connected:
# vehicle not connected
continue
cs = scenario.components.charging_stations.get(connected[vid])
if cs is None or cs.parent != gcID:
# CS not found or CS not at this GC
continue
vehicle = scenario.components.vehicles[vid]
soc = scenario.socs[idx][vidx]
max_flex_energy += max(1-soc, 0) * vehicle.battery.capacity
try:
row += [
round(scenario.flex_bands[gcID]["min"][idx], round_to_places),
round(scenario.flex_bands[gcID]["base"][idx], round_to_places),
round(scenario.flex_bands[gcID]["max"][idx], round_to_places),
round(max_flex_energy, round_to_places),
]
except TypeError:
row += [0, 0, 0]
row += [0, 0, 0, 0]

# schedule + window schedule
if hasSchedule:
Expand Down
47 changes: 26 additions & 21 deletions spice_ev/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ def run(self, strategy_name, options):

gc_ids = self.components.grid_connectors.keys()

socs = []
prices = {gcID: [] for gcID in gc_ids}
results = []
totalLoad = {gcID: [] for gcID in gc_ids}
disconnect = []
fixedLoads = {gcID: [] for gcID in gc_ids}
stepsPerHour = datetime.timedelta(hours=1) / self.interval
batteryLevels = {k: [] for k in self.components.batteries.keys()}
connChargeByTS = {gcID: [] for gcID in gc_ids}
gcPowerSchedule = {gcID: [] for gcID in gc_ids}
gcWindowSchedule = {gcID: [] for gcID in gc_ids}
departed_vehicles = {}
gcWithinPowerLimit = True
localGenerationPower = {gcID: [] for gcID in gc_ids}
socs = [] # for each ts: list of vehicle soc in order of vehicle keys
prices = {gcID: [] for gcID in gc_ids} # for each GC: list of price
results = [] # for each ts: time and commands for each GC
totalLoad = {gcID: [] for gcID in gc_ids} # for each GC: list of loads
connected = [] # for each ts: charging station for each vehicle at start of ts
disconnect = [] # for each ts: interpolated soc for all unconnected vehicles
fixedLoads = {gcID: [] for gcID in gc_ids} # for each GC: list of fixed loads
batteryLevels = {k: [] for k in self.components.batteries.keys()} # stat. bats: list of soc
connChargeByTS = {gcID: [] for gcID in gc_ids} # for each GC: list of summed CS power
gcPowerSchedule = {gcID: [] for gcID in gc_ids} # for each GC: schedule
gcWindowSchedule = {gcID: [] for gcID in gc_ids} # for each GC: time windows (bool/None)
departed_vehicles = {} # vehicle id -> (index when left, soc when left)
gcWithinPowerLimit = True # flag: all GC are within their limit
localGenerationPower = {gcID: [] for gcID in gc_ids} # for each GC: list of generated power

begin = datetime.datetime.now()
error = None
Expand Down Expand Up @@ -131,17 +131,19 @@ def run(self, strategy_name, options):

# get vehicle SoC at start of timestep
cur_dis = []
cur_conn = {}
cur_socs = []
for vidx, vid in enumerate(sorted(strat.world_state.vehicles.keys())):
vehicle = strat.world_state.vehicles[vid]
cur_socs.append(None)
cur_dis.append(None)
connected = vehicle.connected_charging_station is not None
is_connected = vehicle.connected_charging_station is not None
departed = (vehicle.estimated_time_of_departure is None
or vehicle.estimated_time_of_departure <= strat.current_time)

if connected:
if is_connected:
cur_socs[-1] = vehicle.battery.soc
cur_conn[vid] = vehicle.connected_charging_station
else:
if departed:
if vid not in departed_vehicles:
Expand All @@ -155,7 +157,7 @@ def run(self, strategy_name, options):
# not driving,just standing disconnected
cur_dis[-1] = vehicle.battery.soc

if (connected or not departed) and vid in departed_vehicles:
if (is_connected or not departed) and vid in departed_vehicles:
# newly arrived: update disconnect with linear interpolation
start_idx, start_soc = departed_vehicles[vid]
# compute linear equation
Expand All @@ -168,6 +170,7 @@ def run(self, strategy_name, options):
del departed_vehicles[vid]

socs.append(cur_socs)
connected.append(cur_conn)
disconnect.append(cur_dis)

# get battery levels at start of timestep
Expand Down Expand Up @@ -225,7 +228,7 @@ def run(self, strategy_name, options):
# compute cost: price in ct/kWh -> get price in EUR
if gc.cost:
power = max(gc_load, 0)
energy = power / stepsPerHour
energy = power / strat.ts_per_hour
cost += util.get_cost(energy, gc.cost) / 100
price = util.get_cost(1, gc.cost)

Expand Down Expand Up @@ -283,11 +286,12 @@ def run(self, strategy_name, options):

# end of simulation: increase step_i one last time (no error: step_i == n_intervals)
step_i += 1
self.stepsPerHour = strat.ts_per_hour

# make variable members of Scenario class to access them in report
for var in ["batteryLevels", "connChargeByTS", "disconnect",
for var in ["batteryLevels", "connChargeByTS", "connected", "disconnect",
"fixedLoads", "localGenerationPower", "gcPowerSchedule", "gcWindowSchedule",
"prices", "results", "socs", "step_i", "stepsPerHour", "strat",
"prices", "results", "socs", "step_i", "strat",
"strategy_name", "totalLoad"]:
setattr(self, var, locals()[var])

Expand All @@ -300,6 +304,7 @@ def run(self, strategy_name, options):
f"(with margin of {strat.margin * 100}%: {strat.margin_counter} cases)")

for gcID in gc_ids:
print(f"Energy drawn from {gcID}: {round((sum(totalLoad[gcID])/stepsPerHour), 3)} kWh")
print(f"Energy drawn from {gcID}: "
f"{round((sum(totalLoad[gcID])/strat.ts_per_hour), 3)} kWh")

report.generate_reports(self, options)

0 comments on commit 07093fc

Please sign in to comment.