@@ -162,7 +162,12 @@ def options(self, extra_options):
162
162
raise pybamm .OptionError ("option {} not recognised" .format (name ))
163
163
164
164
# Some standard checks to make sure options are compatible
165
- if options ["operating mode" ] not in ["current" , "voltage" ]:
165
+ if options ["operating mode" ] not in [
166
+ "current" ,
167
+ "voltage" ,
168
+ "power" ,
169
+ "arbitrary" ,
170
+ ]:
166
171
raise pybamm .OptionError (
167
172
"operating mode '{}' not recognised" .format (options ["operating mode" ])
168
173
)
@@ -491,14 +496,22 @@ def set_external_circuit_submodel(self):
491
496
e.g. (not necessarily constant-) current, voltage, etc
492
497
"""
493
498
if self .options ["operating mode" ] == "current" :
499
+ self .submodels ["external circuit" ] = pybamm .external_circuit .CurrentControl (
500
+ self .param
501
+ )
502
+ elif self .options ["operating mode" ] == "voltage" :
503
+ self .submodels ["external circuit" ] = pybamm .external_circuit .VoltageControl (
504
+ self .param
505
+ )
506
+ elif self .options ["operating mode" ] == "power" :
507
+ self .submodels ["external circuit" ] = pybamm .external_circuit .PowerControl (
508
+ self .param
509
+ )
510
+ elif self .options ["operating mode" ] == "arbitrary" :
494
511
self .submodels [
495
512
"external circuit"
496
- ] = pybamm .external_circuit .CurrentControl (self .param )
497
- if self .options ["operating mode" ] == "voltage" :
498
- self .submodels [
499
- "external circuit"
500
- ] = pybamm .external_circuit .VoltageControl (self .param )
501
-
513
+ ] = pybamm .external_circuit .FunctionControl (self .param )
514
+
502
515
def set_tortuosity_submodels (self ):
503
516
self .submodels ["electrolyte tortuosity" ] = pybamm .tortuosity .Bruggeman (
504
517
self .param , "Electrolyte"
@@ -732,6 +745,10 @@ def set_voltage_variables(self):
732
745
self .events ["Minimum voltage" ] = voltage - self .param .voltage_low_cut
733
746
self .events ["Maximum voltage" ] = voltage - self .param .voltage_high_cut
734
747
748
+ # Power
749
+ I_dim = self .variables ["Current [A]" ]
750
+ self .variables .update ({"Terminal power [W]" : I_dim * V_dim })
751
+
735
752
def set_soc_variables (self ):
736
753
"""
737
754
Set variables relating to the state of charge.
0 commit comments