@@ -77,6 +77,56 @@ def self_consumption_ac_battery(generation, load, battery, model):
77
77
return final_state , df
78
78
79
79
80
+ def self_consumption_dc_battery (
81
+ ac_generation ,
82
+ ac_clipping ,
83
+ inverter_efficiency ,
84
+ inverter_max_output_power_w ,
85
+ load ,
86
+ battery ,
87
+ model ,
88
+ ):
89
+ """
90
+ Calculate the power flow for a self-consumption use case with an
91
+ AC-connected battery. It assumes the system is connected to the grid.
92
+
93
+ Parameters
94
+ ----------
95
+ generation : Series
96
+ The input generation profile. [W]
97
+ load : Series
98
+ The input load profile. [W]
99
+ battery : dict
100
+ The battery parameters.
101
+ model : str
102
+ The battery model to use.
103
+
104
+ Returns
105
+ -------
106
+ DataFrame
107
+ The resulting power flow provided by the system, the grid and the
108
+ battery into the system, grid, battery and load. [W]
109
+ """
110
+ df = self_consumption (ac_generation , load )
111
+ charging = (df ["System to grid" ] + ac_clipping ) / inverter_efficiency
112
+ discharging = df ["Grid to load" ]
113
+ discharging = min (discharging , inverter_max_output_power_w - ac_generation )
114
+ discharging /= inverter_efficiency
115
+ dispatch = discharging - charging
116
+ final_state , results = model (battery , dispatch )
117
+ df ["System to battery" ] = - results ["Power" ].loc [results ["Power" ] < 0 ]
118
+ df ["System to battery" ] = df ["System to battery" ].fillna (0.0 )
119
+ df ["System to grid" ] -= df ["System to battery" ] * inverter_efficiency
120
+ df ["Battery to load" ] = results ["Power" ].loc [results ["Power" ] > 0 ]
121
+ df ["Battery to load" ] = df ["Battery to load" ].fillna (0.0 )
122
+ df ["Battery to load" ] *= inverter_efficiency
123
+ df ["Grid to load" ] -= df ["Battery to load" ]
124
+ df ["Grid" ] = df [["Grid to system" , "Grid to load" ]].sum (
125
+ axis = 1 , skipna = False
126
+ )
127
+ return final_state , df
128
+
129
+
80
130
def self_consumption_ac_battery_custom_dispatch (
81
131
df , dispatch , battery , model , ac_dc_loss = 4 , dc_ac_loss = 4
82
132
):
@@ -122,3 +172,50 @@ def self_consumption_ac_battery_custom_dispatch(
122
172
axis = 1 , skipna = False
123
173
)
124
174
return final_state , df
175
+
176
+
177
+ def self_consumption_dc_battery_custom_dispatch (
178
+ df , dispatch , battery , model , ac_dc_loss = 4 , dc_ac_loss = 4
179
+ ):
180
+ """
181
+ Calculate the power flow for a self-consumption use case with an
182
+ AC-connected battery and a custom dispatch series. It assumes the system is
183
+ connected to the grid.
184
+
185
+ Parameters
186
+ ----------
187
+ df : DataFrame
188
+ The self-consumption power flow solution. [W]
189
+ dispatch : Series
190
+ The battery model to use.
191
+ battery : dict
192
+ The battery parameters.
193
+ model : str
194
+ The battery model to use.
195
+ ac_dc_loss : float
196
+ The fixed loss when converting AC to DC (i.e.: charging). [%]
197
+ dc_ac_loss : float
198
+ The fixed loss when converting DC to AC (i.e.: discharging). [%]
199
+
200
+ Returns
201
+ -------
202
+ DataFrame
203
+ The resulting power flow provided by the system, the grid and the
204
+ battery into the system, grid, battery and load. [W]
205
+ """
206
+ final_state , results = model (battery , dispatch )
207
+ df = df .copy ()
208
+ df ["System to battery" ] = - results ["Power" ]
209
+ df ["System to battery" ].loc [df ["System to battery" ] < 0 ] = 0.0
210
+ df ["System to battery" ] = df [["System to battery" , "System to grid" ]].min (
211
+ axis = 1
212
+ )
213
+ df ["System to grid" ] -= df ["System to battery" ]
214
+ df ["Battery to load" ] = results ["Power" ]
215
+ df ["Battery to load" ].loc [df ["Battery to load" ] < 0 ] = 0.0
216
+ df ["Battery to load" ] = df [["Battery to load" , "Grid to load" ]].min (axis = 1 )
217
+ df ["Grid to load" ] -= df ["Battery to load" ]
218
+ df ["Grid" ] = df [["Grid to system" , "Grid to load" ]].sum (
219
+ axis = 1 , skipna = False
220
+ )
221
+ return final_state , df
0 commit comments