File tree 3 files changed +44
-5
lines changed
pybamm/models/full_battery_models/lead_acid
tests/unit/test_models/test_full_battery_models
3 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,24 @@ def set_external_circuit_submodel(self):
57
57
Define how the external circuit defines the boundary conditions for the model,
58
58
e.g. (not necessarily constant-) current, voltage, etc
59
59
"""
60
- super ().set_external_circuit_submodel ()
61
- # replace 'external circuit' with 'leading-order external circuit'
62
- self .submodels ["leading order external circuit" ] = self .submodels .pop (
63
- "external circuit"
64
- )
60
+ if self .options ["operating mode" ] == "current" :
61
+ self .submodels [
62
+ "leading order external circuit"
63
+ ] = pybamm .external_circuit .LeadingOrderCurrentControl (self .param )
64
+ elif self .options ["operating mode" ] == "voltage" :
65
+ self .submodels [
66
+ "leading order external circuit"
67
+ ] = pybamm .external_circuit .LeadingOrderVoltageFunctionControl (self .param )
68
+ elif self .options ["operating mode" ] == "power" :
69
+ self .submodels [
70
+ "leading order external circuit"
71
+ ] = pybamm .external_circuit .LeadingOrderPowerFunctionControl (self .param )
72
+ elif callable (self .options ["operating mode" ]):
73
+ self .submodels [
74
+ "leading order external circuit"
75
+ ] = pybamm .external_circuit .LeadingOrderFunctionControl (
76
+ self .param , self .options ["operating mode" ]
77
+ )
65
78
66
79
def set_current_collector_submodel (self ):
67
80
Original file line number Diff line number Diff line change @@ -166,6 +166,19 @@ def test_well_posed_power(self):
166
166
model = pybamm .lead_acid .LOQS (options )
167
167
model .check_well_posedness ()
168
168
169
+ def test_well_posed_function (self ):
170
+ class ExternalCircuitFunction :
171
+ num_switches = 0
172
+
173
+ def __call__ (self , variables ):
174
+ I = variables ["Current [A]" ]
175
+ V = variables ["Terminal voltage [V]" ]
176
+ return V + I - pybamm .FunctionParameter ("Function" , pybamm .t )
177
+
178
+ options = {"operating mode" : ExternalCircuitFunction ()}
179
+ model = pybamm .lead_acid .LOQS (options )
180
+ model .check_well_posedness ()
181
+
169
182
170
183
if __name__ == "__main__" :
171
184
print ("Add -v for more debug output" )
Original file line number Diff line number Diff line change @@ -189,6 +189,19 @@ def test_well_posed_power(self):
189
189
model = pybamm .lithium_ion .SPM (options )
190
190
model .check_well_posedness ()
191
191
192
+ def test_well_posed_function (self ):
193
+ class ExternalCircuitFunction :
194
+ num_switches = 0
195
+
196
+ def __call__ (self , variables ):
197
+ I = variables ["Current [A]" ]
198
+ V = variables ["Terminal voltage [V]" ]
199
+ return V + I - pybamm .FunctionParameter ("Function" , pybamm .t )
200
+
201
+ options = {"operating mode" : ExternalCircuitFunction ()}
202
+ model = pybamm .lead_acid .LOQS (options )
203
+ model .check_well_posedness ()
204
+
192
205
193
206
if __name__ == "__main__" :
194
207
print ("Add -v for more debug output" )
You can’t perform that action at this time.
0 commit comments