scls
scls

Reputation: 17627

Inversing a model with OpenModelica raises an error when compiling

I'm studying the motorization of the trolley of a boat loading gantry.

The gantry consists of a frame that moves on rails on the port quay. The frame supports an M=32 ton overhead crane carriage moving perpendicular to the quay.

The truck can lift or lower loads of mass m=50 tonnes.

From a mechanical point of view we are in the presence of three independent translation movements, along the three axes. However, in the problem, we are only interested in the movement of the cart (along the x axis).

enter image description here

The kinematic profile (speed profile) of the carriage movement is given below:

enter image description here

The movement is ensured by a motor driving the wheels of the cart by a reduction gear. The motor runs at 1450 rpm when the carriage moves at 3 m/s. The torque of the machine is constant during the acceleration and deceleration phase. The efficiency of the wheels is 100%.

The efficiency of the reducer is η = 80% in both directions of energy transfer:

From the engine to the wheels: in the traction phase, driven load From the wheels towards the engine: during braking, driving load.

I did the following (forward) model

enter image description here

model chariot_portique
  constant Real rpm_max = 1450.0;
  constant Real v_max = 3.0;
  
  Modelica.Mechanics.Rotational.Components.IdealGearR2T idealGearR2T(ratio = (rpm_max*2*Modelica.Constants.pi/60)/v_max)  annotation(
    Placement(visible = true, transformation(origin = {28, -36}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.Rotational.Components.LossyGear lossyGear(lossTable = [0, 0.8, 0.8, 0, 0], ratio = 1)  annotation(
    Placement(visible = true, transformation(origin = {-6, -36}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Mass mass(m = 82000)  annotation(
    Placement(transformation(origin = {98, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint, table = [0, 0; 0, 1520; 4, 1520; 4, 0; 8, 0; 8, -974; 12, -974; 12, 0; 16, 0; 16, -1520; 20, -1520; 20, 0; 24, 0; 24, 974; 28, 974; 28, 0; 32, 0], tableOnFile = false) annotation(
    Placement(transformation(origin = {-40, -66}, extent = {{-80, 20}, {-60, 40}})));
  Modelica.Mechanics.Rotational.Sources.Torque torque annotation(
    Placement(transformation(origin = {-74, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Rotational.Sensors.MultiSensor multiSensor_moteur annotation(
    Placement(transformation(origin = {-38, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Translational.Sensors.MultiSensor multiSensor_chariot annotation(
    Placement(transformation(origin = {64, -36}, extent = {{-10, -10}, {10, 10}})));
equation
  connect(lossyGear.flange_b, idealGearR2T.flangeR) annotation(
    Line(points = {{4, -36}, {18, -36}}));
  connect(combiTimeTable.y[1], torque.tau) annotation(
    Line(points = {{-99, -36}, {-86, -36}}, color = {0, 0, 127}));
  connect(torque.flange, multiSensor_moteur.flange_a) annotation(
    Line(points = {{-64, -36}, {-48, -36}}));
  connect(multiSensor_moteur.flange_b, lossyGear.flange_a) annotation(
    Line(points = {{-28, -36}, {-16, -36}}));
  connect(idealGearR2T.flangeT, multiSensor_chariot.flange_a) annotation(
    Line(points = {{38, -36}, {54, -36}}, color = {0, 127, 0}));
  connect(mass.flange_a, multiSensor_chariot.flange_b) annotation(
    Line(points = {{88, -36}, {74, -36}}, color = {0, 127, 0}));
  annotation(
    experiment(StopTime = 32),
    uses(Modelica(version = "4.0.0")),
  Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
  Icon(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
  version = "",
  __OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*"));
end chariot_portique;

but when I'm trying to inverse such a model ie having speed profile as input to get motor speed as output simulation raises an error.

I did the following inverse model

enter image description here

with

model chariot_portique_inverse
  constant Real rpm_max = 1450.0;
  constant Real v_max = 3.0;
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable( table = [0, 0; 4, 3; 8, 3; 12, 0; 16, 0; 20, -3; 24, -3; 28, 0; 32, 0], tableOnFile = false) annotation(
    Placement(transformation(origin = {92, -66}, extent = {{80, 20}, {60, 40}}, rotation = -0)));
  Modelica.Mechanics.Translational.Sensors.MultiSensor multiSensor_chariot annotation(
    Placement(transformation(origin = {60, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Rotational.Components.IdealGearR2T idealGearR2T(ratio = (rpm_max*2*Modelica.Constants.pi/60)/v_max) annotation(
    Placement(transformation(origin = {28, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Rotational.Components.LossyGear lossyGear(lossTable = [0, 0.8, 0.8, 0, 0], ratio = 1) annotation(
    Placement(transformation(origin = {-6, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Translational.Sources.Speed speed(exact = true)  annotation(
    Placement(transformation(origin = {126, -36}, extent = {{10, -10}, {-10, 10}})));
  Modelica.Mechanics.Rotational.Sensors.MultiSensor multiSensor_moteur annotation(
    Placement(transformation(origin = {-44, -36}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Translational.Components.Mass mass(m = 82000, s(start = 0), v(start = 0), a(start = 0))  annotation(
    Placement(transformation(origin = {90, -36}, extent = {{-10, -10}, {10, 10}})));
equation
  connect(lossyGear.flange_b, idealGearR2T.flangeR) annotation(
    Line(points = {{4, -36}, {18, -36}}));
  connect(multiSensor_moteur.flange_b, lossyGear.flange_a) annotation(
    Line(points = {{-34, -36}, {-16, -36}}));
  connect(idealGearR2T.flangeT, multiSensor_chariot.flange_a) annotation(
    Line(points = {{38, -36}, {50, -36}}, color = {0, 127, 0}));
  connect(combiTimeTable.y[1], speed.v_ref) annotation(
    Line(points = {{152, -36}, {138, -36}}, color = {0, 0, 127}));
  connect(mass.flange_a, multiSensor_chariot.flange_b) annotation(
    Line(points = {{80, -36}, {70, -36}}, color = {0, 127, 0}));
  connect(mass.flange_b, speed.flange) annotation(
    Line(points = {{100, -36}, {116, -36}}, color = {0, 127, 0}));
  annotation(
    experiment(StopTime = 32),
    uses(Modelica(version = "4.0.0")),
    Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
    Icon(coordinateSystem(extent = {{-200, -100}, {200, 100}})),
    version = "",
  __OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*"));
end chariot_portique_inverse;

but compiling returns this

Le processus de simulation a échoué. Quitté avec le code 0xffffffffffffffff.
Solving non-linear system 47 failed at time=0. For more information please use -lv LOG_NLS.
simulation terminated by an assertion at initialization
Homotopy solver total pivot: Matrix (nearly) singular at initialization.
Continuing anyway. For more information please use -lv LOG_NLS_V.
under-determined linear system not solvable!
Homotopy solver total pivot: Matrix (nearly) singular at initialization.
under-determined linear system not solvable!
Homotopy solver total pivot: Matrix (nearly) singular at initialization.
under-determined linear system not solvable!
nonlinear system 47 fails: at t=0
proper start-values for some of the following iteration variables might help

I can't understand what is wrong with my inverse problem.

And discussion in OpenModelica GitHub didn't helped https://github.com/OpenModelica/OpenModelica/discussions/11197

Any idea?

Upvotes: 1

Views: 161

Answers (1)

Maximilian K.
Maximilian K.

Reputation: 88

The LossyGear model cannot cope with zero-velocities precribed by a speed input. If you want to get this model running without using a different gear model, increase the zero values in your table by something small like 1e-5.

edit: A nicer way to invert the system is by using inverseBlockConstraits:

model chariot_portique_inverse
    model chariot_portique
        extends Modelica.Blocks.Interfaces.SISO;
        constant Real rpm_max = 1450.0;
        constant Real v_max = 3.0;

        Modelica.Mechanics.Rotational.Components.IdealGearR2T idealGearR2T(ratio = (rpm_max*2*Modelica.Constants.pi/60)/v_max)  annotation (
            Placement(visible = true, transformation(origin={14,0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        Modelica.Mechanics.Rotational.Components.LossyGear lossyGear(lossTable=[0,0.8,0.8,0,0], ratio = 1)  annotation (
            Placement(visible = true, transformation(origin={-20,0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
        Modelica.Mechanics.Translational.Components.Mass mass(m = 82000)    annotation (
            Placement(transformation(origin={72,0}, extent = {{-10, -10}, {10, 10}})));
        Modelica.Mechanics.Rotational.Sources.Torque torque annotation (
            Placement(transformation(origin={-80,0}, extent = {{-10, -10}, {10, 10}})));
        Modelica.Mechanics.Rotational.Sensors.MultiSensor multiSensor_moteur annotation (
            Placement(transformation(origin={-52,0}, extent = {{-10, -10}, {10, 10}})));
        Modelica.Mechanics.Translational.Sensors.MultiSensor multiSensor_chariot annotation (
            Placement(transformation(origin={44,0}, extent = {{-10, -10}, {10, 10}})));
    equation 
        connect(lossyGear.flange_b, idealGearR2T.flangeR) annotation (
            Line(points={{-10,0},{4,0}}));
        connect(torque.flange, multiSensor_moteur.flange_a) annotation (
            Line(points={{-70,0},{-62,0}}));
        connect(multiSensor_moteur.flange_b, lossyGear.flange_a) annotation (
            Line(points={{-42,0},{-30,0}}));
        connect(idealGearR2T.flangeT, multiSensor_chariot.flange_a) annotation (
            Line(points={{24,0},{34,0}}, color = {0, 127, 0}));
        connect(mass.flange_a, multiSensor_chariot.flange_b) annotation (
            Line(points={{62,0},{54,0}}, color = {0, 127, 0}));
        connect(u, torque.tau) annotation (Line(points={{-120,0},{-92,0}}, color={0,0,127}));
        connect(multiSensor_chariot.v, y) annotation (Line(points={{50,-11},{50,-20},{90,-20},{90,0},{110,0}}, color={0,0,127}));
    end chariot_portique;

    constant Real rpm_max = 1450.0;
    constant Real v_max = 3.0;
    Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(table=[0,1e-5; 4,3; 8,3; 12,1e-5; 16,1e-5; 20,-3; 24,-3; 28,-1e-5; 32,-1e-5],
        tableOnFile = false) annotation (
        Placement(transformation(origin={14,-30}, extent = {{80, 20}, {60, 40}}, rotation = -0)));
    Modelica.Blocks.Math.InverseBlockConstraints inverseBlockConstraints
        annotation (Placement(transformation(extent={{-20,-12},{20,12}}, rotation=180)));
    chariot_portique chariot_portique1 annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation 
    connect(inverseBlockConstraints.u2, chariot_portique1.y) annotation (Line(points={{16,0},{11,0}}, color={0,0,127}));
    connect(inverseBlockConstraints.y2, chariot_portique1.u) annotation (Line(points={{-17,0},{-12,0}}, color={0,0,127}));
    connect(combiTimeTable.y[1], inverseBlockConstraints.u1) annotation (Line(points={{73,0},{22,0}}, color={0,0,127}));
    annotation (
        experiment(StopTime = 32),
        uses(Modelica(version = "4.0.0")));
end chariot_portique_inverse;

Upvotes: 4

Related Questions