@@ -214,7 +214,7 @@ def get_parameters(self):
214214 }
215215
216216 def get_mandatory_constraints (self ):
217- return {
217+ constraints = {
218218 'mass_flow_constraints' : dc_cmc (** {
219219 'func' : self .reactor_mass_flow_func ,
220220 'deriv' : self .reactor_mass_flow_deriv ,
@@ -247,6 +247,14 @@ def get_mandatory_constraints(self):
247247 "description" : "reactor pressure equality equations"
248248 })
249249 }
250+ if len (self .power_outl ) > 0 :
251+ constraints ["energy_connector_balance" ] = dc_cmc (** {
252+ "func" : self .energy_connector_balance_func ,
253+ "dependents" : self .energy_connector_dependents ,
254+ "num_eq_sets" : 1
255+ })
256+
257+ return constraints
250258
251259 @staticmethod
252260 def get_bypass_constraints ():
@@ -260,6 +268,10 @@ def inlets():
260268 def outlets ():
261269 return ['out1' , 'out2' ]
262270
271+ @staticmethod
272+ def poweroutlets ():
273+ return ["power" ]
274+
263275 def _add_missing_fluids (self , connections ):
264276 if self .inl [1 ] in connections :
265277 return ["O2" ]
@@ -325,6 +337,28 @@ def calc_e0(self):
325337
326338 return e0
327339
340+ def energy_connector_balance_func (self ):
341+ r"""
342+ (optional) energy balance equation connecting the power connector to
343+ the component's power. Since the power of the FuelCell is negative by
344+ definition of the system, the two quantities are added in the residual
345+ so the power on the PowerConnection is positive again.
346+
347+ Returns
348+ -------
349+ residual : float
350+ Residual value of equation
351+
352+ .. math::
353+
354+ 0=\dot E + P
355+ """
356+ return self .power_outl [0 ].E .val_SI + self .P .val_SI
357+
358+ def energy_connector_dependents (self ):
359+ return [self .power_outl [0 ].E , self .P ]
360+
361+
328362 def eta_func (self ):
329363 r"""
330364 Equation for efficiency.
@@ -454,7 +488,7 @@ def energy_balance_deriv(self, increment_filter, k, dependents=None):
454488
455489 # derivatives for variable P
456490 if self .P .is_var :
457- self .jacobian [k , self .p .J_col ] = 1
491+ self .jacobian [k , self .P .J_col ] = 1
458492
459493 def energy_balance_dependents (self ):
460494 return [
0 commit comments