@@ -35,6 +35,16 @@ def get_fundamental_variables(self):
35
35
36
36
return variables
37
37
38
+ def get_coupled_variables (self , variables ):
39
+ # Update terminal voltage
40
+ phi_s_cp_dim = variables ["Positive current collector potential [V]" ]
41
+ phi_s_cp = variables ["Positive current collector potential" ]
42
+
43
+ V = pybamm .boundary_value (phi_s_cp , "positive tab" )
44
+ V_dim = pybamm .boundary_value (phi_s_cp_dim , "positive tab" )
45
+ variables ["Terminal voltage" ] = V
46
+ variables ["Terminal voltage [V]" ] = V_dim
47
+
38
48
def set_initial_conditions (self , variables ):
39
49
# Initial condition as a guess for consistent initial conditions
40
50
i_cell = variables ["Total current density" ]
@@ -46,3 +56,37 @@ def set_algebraic(self, variables):
46
56
# or a combination (e.g. I*V for power control)
47
57
i_cell = variables ["Total current density" ]
48
58
self .algebraic [i_cell ] = self .external_circuit_class (variables )
59
+
60
+
61
+ class VoltageFunctionControl (FunctionControl ):
62
+ """
63
+ External circuit with voltage control, implemented as an extra algebraic equation.
64
+ """
65
+
66
+ def __init__ (self , param ):
67
+ super ().__init__ (param , ConstantVoltage ())
68
+
69
+
70
+ class ConstantVoltage :
71
+ num_switches = 0
72
+
73
+ def __call__ (self , variables ):
74
+ V = variables ["Terminal voltage [V]" ]
75
+ return V - pybamm .FunctionParameter ("Voltage function" , pybamm .t )
76
+
77
+
78
+ class PowerFunctionControl (FunctionControl ):
79
+ """External circuit with power control. """
80
+
81
+ def __init__ (self , param ):
82
+ super ().__init__ (param , ConstantPower ())
83
+
84
+
85
+ class ConstantPower :
86
+ num_switches = 0
87
+
88
+ def __call__ (self , variables ):
89
+ I = variables ["Current [A]" ]
90
+ V = variables ["Terminal voltage [V]" ]
91
+ return I * V - pybamm .FunctionParameter ("Power function" , pybamm .t )
92
+
0 commit comments