Skip to content

Commit 7eb60ec

Browse files
#492 fix composite
1 parent 55c5e88 commit 7eb60ec

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

pybamm/models/full_battery_models/lead_acid/loqs.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,24 @@ def set_external_circuit_submodel(self):
5757
Define how the external circuit defines the boundary conditions for the model,
5858
e.g. (not necessarily constant-) current, voltage, etc
5959
"""
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+
)
6578

6679
def set_current_collector_submodel(self):
6780

tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py

+13
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ def test_well_posed_power(self):
166166
model = pybamm.lead_acid.LOQS(options)
167167
model.check_well_posedness()
168168

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+
169182

170183
if __name__ == "__main__":
171184
print("Add -v for more debug output")

tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py

+13
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ def test_well_posed_power(self):
189189
model = pybamm.lithium_ion.SPM(options)
190190
model.check_well_posedness()
191191

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+
192205

193206
if __name__ == "__main__":
194207
print("Add -v for more debug output")

0 commit comments

Comments
 (0)