Local balance

Definition

According to the modelica specification :

A model or block class is locally balanced if the local number of unknowns is identical to the local equation size for all legal values of constants and parameters.

Example

Since that definition does not make it much clearer, here is an example model :

model HeightVarPressureLoss
	extends IsoHFlowModel;
	import MetroscopeModelingLibrary.Constants;
	
  Units.DifferentialHeight delta_z "Height difference between outlet and inlet";
  Units.DifferentialPressure DP_z "pressure loss due to height variation";

equation
  DP_z = -rho * Constants.g * delta_z;
end HeightVarPressureLoss;

In this example, one can clearly see that we have 2 local unknowns (delta_z and DP_z) and only 1 local equation.

It means that this HeightVarPressureLoss is not locally balanced : some variables declared in this model must be defined from the top-level model that will instantiate this HeightVarPressureLoss.

Connector inputs

To explicitly declare which variables should be defined in the top level model, the modelica language defines an object called connector input. A connector input is a variable type (such as Real, Boolean, etc.) which says : “this variable must be defined in an upper level model”.

This connector input is defined that way :

connector InputUnit = input Unit; // Where 'Unit' is any type of variable unit

And then, you can declare a new variable as a local input of your model :

model HeightVarPressureLoss
	extends IsoHFlowModel;
	import MetroscopeModelingLibrary.Constants;
	connector InputDifferentialHeight = input Units.DifferentialHeight;
	
  InputDifferentialHeight delta_z "Height difference between outlet and inlet";
  Units.DifferentialPressure DP_z "pressure loss due to height variation";

equation
  DP_z = -rho * Constants.g * delta_z;
end HeightVarPressureLoss;

That way, this model has now :

⇒ This model is locally balanced.