Search code examples
modelica

Trouble balancing a simple power flow model in modelica


I try to set up a simple model with electrical or thermal power flows between sources and sinks. I seem to have the same problem as treated in this topic although I used only one pair of flow and potential variables in my connector:

connector PowerPortE
  flow SI.Power P;
  SI.Voltage v "Dummy potential-variable to balance flow-variable P";
end PowerPortE;

A simple example with a signal responsed power sink looks like this:

model PowerSinkE
  SimplePowerSystem.PowerPortE Port;
  Modelica.Blocks.Interfaces.RealInput P(unit = "W");
  SI.Voltage v(start = 230);
equation
  Port.P = P;
  Port.v = v;
end PowerSinkE;

model Test
  SimplePowerSystem.PowerSinkE Verbraucher ;
  Modelica.Blocks.Sources.Sine sine1(freqHz = 50) ;
equation
  connect(sine1.y,Verbraucher.P);
end Test;

Checking PowerSinkE goes well, but when trying to simulate, I get the following errors:

Internal error pre-optimization module removeSimpleEquations failed.

Internal error Found Equation without time dependent variables Verbraucher.Port.P = const.k

An independent subset of the model has imbalanced number of equations (1) and variables (2).
variables:
Verbraucher.v
Verbraucher.Port.v
equations:
1 : Verbraucher.Port.v = Verbraucher.v

An independent subset of the model has imbalanced number of equations (4) and variables (3).
variables:
sine1.y
Verbraucher.P
Verbraucher.Port.P
equations:
1 : Verbraucher.Port.P = Verbraucher.P
2 : sine1.y = sine1.offset + (if time < sine1.startTime then 0.0 else sine1.amplitude * sin(6.283185307179586 * sine1.freqHz * (time - sine1.startTime) + sine1.phase))
3 : Verbraucher.Port.P = 0.0
4 : Verbraucher.P = sine1.y

Initially I wanted to leave the variable v completely out of the model (though I had to leave it in the connector to be balanced) but this didn't work out either:

Model is structurally singular, error found sorting equations
 1: 0.0 = sine1.offset + (if time < sine1.startTime then 0.0 else sine1.amplitude * sin(6.283185307179586 * sine1.freqHz * (time - sine1.startTime) + sine1.phase));
 for variables
 Verbraucher.Port.v(1)

The problem seems to be that I need the flow variable power but don't have a corresponding potential variable. I am running out of ideas how to fix this, so thanks for the help.


Solution

  • My initial thought is that port in the consumer is unconnected. This adds the equation consumer.port.P = 0.0. But what you really need is an equation for the voltage in the port.