Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

OMC and Corba - Error in initialization. System of initial equations

OMC and Corba - Error in initialization. System of initial equations

Dear all,
I created a model for a double mass-damper-spring system with PI controllers using OpenModelica.
I would like to use the Corba interface in order to optimize it using an homemade Java application or using the JMetal one (in the future).

I started with simple proportional controllers. It works fine.
But when I add the integrator part (the PI controller from the Modelica library) I get the following error :

Code:


Sending expression:runScript("Systeme_MRA.mos")
Got reply:"true
true
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 10.0, numberOfIntervals = 1000, tolerance = 0.0001, method = 'dassl', fileNamePrefix = 'Systeme_MRA', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = ''\",
    messages = \"Simulation execution failed for model: Systeme_MRA
Error in initialization. System of initial equations are not consistent.
(Least Square function value is 0.07)
Error in initialization. Solver iterated 100 times without finding a solution
residual[0] = 0.1
residual[7] = 0.1
residual[8] = -0.2
residual[9] = -0.1
Initialization of the current initial set of equations and initial guesses fails!
Try with better Initial guesses for the states.
Error in initialization. Storing results and exiting.

Simulation terminated while the initialization. Could not find suitable initial values.\",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;
false

My MOS file is :

Code:

loadModel(Modelica);

loadFile("Systeme_MRA.mo");
simulate(Systeme_MRA,startTime=0.0,stopTime=10.0,numberOfIntervals = 1000,tolerance = 1e-04);
plot({const.y,const1.y,positionSensor.s,positionSensor1.s});

where "Systeme_MRA" is my double mass-spring-damper modelica model, created using OMEdit.

My modelica model:

Code:

model Systeme_MRA

  annotation(Diagram(graphics), uses(Modelica(version = "3.2")), Diagram(graphics));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper(stateSelect = StateSelect.default, s_nominal = 0.1, s_rel(fixed = true, start = 0), v_rel(fixed = true, start = 0), c = 5, d = 1300, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {88,50}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Components.Fixed fixed annotation(Placement(visible = true, transformation(origin = {88,82}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Components.Mass mass(m = 120, s(fixed = true), L = 0.2, v(fixed = true), a(fixed = true), stateSelect = StateSelect.default) annotation(Placement(visible = true, transformation(origin = {88,10}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sources.Force force1(useSupport = true) annotation(Placement(visible = true, transformation(origin = {32,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(stateSelect = StateSelect.default, s_nominal = 0.1, s_rel(fixed = true, start = 0), v_rel(fixed = true, start = 0), c = 3, d = 1000, s_rel0 = 0) annotation(Placement(visible = true, transformation(origin = {88,-28}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor(s(start = 0, fixed = true)) annotation(Placement(visible = true, transformation(origin = {-4,-16}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Mechanics.Translational.Components.Mass mass1(m = 70, s(fixed = true), L = 0.2, v(fixed = true), a(fixed = true), stateSelect = StateSelect.default) annotation(Placement(visible = true, transformation(origin = {88,-62}, extent = {{-10,10},{10,-10}}, rotation = 270)));
  Modelica.Mechanics.Translational.Sources.Force force(useSupport = true) annotation(Placement(visible = true, transformation(origin = {32,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Continuous.PI PIctrl1(k = 1, T = 0.01) annotation(Placement(visible = true, transformation(origin = {-20,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Continuous.PI PIctrl(k = 1, T = 0.01) annotation(Placement(visible = true, transformation(origin = {-32,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Math.Feedback feedback1 annotation(Placement(visible = true, transformation(origin = {-62,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Math.Feedback feedback annotation(Placement(visible = true, transformation(origin = {-68,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor1(s(start = 0, fixed = true)) annotation(Placement(visible = true, transformation(origin = {58,-92}, extent = {{10,10},{-10,-10}}, rotation = 180)));
  Modelica.Blocks.Sources.Constant const1(k = 2) annotation(Placement(visible = true, transformation(origin = {-100,-72}, extent = {{-10,-10},{10,10}}, rotation = 0)));
  Modelica.Blocks.Sources.Constant const(k = 1) annotation(Placement(visible = true, transformation(origin = {-104,0}, extent = {{-10,-10},{10,10}}, rotation = 0)));

equation
  connect(const.y,feedback.u1) annotation(Line(points = {{-93,0},{-76,0}}));
  connect(feedback1.u1,const1.y) annotation(Line(points = {{-70,-72},{-89,-72}}));
  connect(feedback1.u2,positionSensor1.s) annotation(Line(points = {{-62,-80},{-62,-91.9},{47,-91.9}}));
  connect(positionSensor1.flange,mass1.flange_b) annotation(Line(points = {{68,-92},{104,-92},{112,-72},{88,-72}}));
  connect(PIctrl.u,feedback.y) annotation(Line(points = {{-44,0},{-59,0}}));
  connect(feedback.u2,positionSensor.s) annotation(Line(points = {{-68,-8},{-68,-15.9},{-15,-15.9}}));
  connect(PIctrl1.u,feedback1.y) annotation(Line(points = {{-32,-72},{-53,-72}}));
  connect(PIctrl.y,force1.f) annotation(Line(points = {{-21,0},{20,0}}));
  connect(PIctrl1.y,force.f) annotation(Line(points = {{-9,-72},{20,-72}}));
  connect(force.support,springDamper1.flange_a) annotation(Line(points = {{32,-82},{32,-18},{88,-18}}));
  connect(force.flange,mass1.flange_b) annotation(Line(points = {{42,-72},{88,-72}}));
  connect(mass1.flange_a,springDamper1.flange_b) annotation(Line(points = {{88,-52},{88,-38}}));
  connect(positionSensor.flange,mass.flange_b) annotation(Line(points = {{6,-16},{108,-16},{108,-5.55112e-16},{88,-5.55112e-16}}));
  connect(mass.flange_b,springDamper1.flange_a) annotation(Line(points = {{88,-5.55112e-16},{88,-18}}));
  connect(force1.support,springDamper.flange_a) annotation(Line(points = {{32,-10},{32,60},{88,60}}));
  connect(force1.flange,mass.flange_b) annotation(Line(points = {{42,0},{88,0}}));
  connect(springDamper.flange_b,mass.flange_a) annotation(Line(points = {{88,40},{88,20}}));
  connect(fixed.flange,springDamper.flange_a) annotation(Line(points = {{88,82},{88,60}}));
end Systeme_MRA;

It seems to be an issue with the initialisation of my PI controllers.

Could you please tell me how I can solve it?

Thanks in advance for your kindly reply.
Best,

Re: OMC and Corba - Error in initialization. System of initial equations

Hi,

the problem in your model are not PI controllers, but rather the modifier for the positionSensors. The initialisation problem is overdetermined if you set a  "fixed" start value for the positionSensors and for the SpringDamper. Just change the properties of the positionSensor.
Form


Code:


Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor(s(start = 0, fixed = true))
Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor1(s(start = 0, fixed = true))

to

Code:


Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor
Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor1

then the model works fine.

so long.
Willi

Re: OMC and Corba - Error in initialization. System of initial equations

Hi,
Thanks for your kindly answer.
I edited the model as you suggested and it works perfectly.
Best,

Re: OMC and Corba - Error in initialization. System of initial equations

Hi,
I just have an another question regarding OMC and Corba.
How can I set parameters to my modelica model using the corba interface and how can I get the simulation results?

In my model, I would like to optimize parameters from the PI controllers by minimizing the sum of quadratic errors:
I'm currently using the JMetal package (I may develop my own algorithm in the future) and I would like to do this as my optimization problem:
- Setting PI parameters (calculated by my optimization algorithm)
- Simulate the model with those parameters
- Get the values from the feedback.y and feedback1.y variables that are containing the error values.
- Calculate the sum of errors using a java function

I would like to know how I can set the parameters that are calculated by my algorithm to my Modelica model (PIctrl.k, PIctrl.T, Pictrl1.k and PIctrl1.T variables) and get simulation results.


Is it possible ?
Best,

There are 0 guests and 0 other users also viewing this topic
You are here: