Modelica v4.0.0 Visualizers are Broken - modelica

I have recently migrated to modelica version 4.0.0, am am having some problems, it turns out that some visualizer settings for the SignalArrow and sensors, such as the absoluteSensor had their diameter settings removed,
Changes in Modelica Version 4
Namely:
WorldForce The parameters diameter and N_to_m have been removed.
AbsoluteSensor The parameter arrowDiameter has been removed.
RelativeSensor The parameter arrowDiameter has been removed.
Distance The parameter arrowDiameter has been removed.
And many other things. This is somewhat frustrating, however I managed to find these missing settings have been moved into the world class,
However these changes do not affect the diameter sizes of these arrows from sensors and visualizers.
For example, in this image, the yellow and pink arrows should be 5mm (the same diameter of the black coordinate arrows), and not whatever modelica has calculated them to be.
I have attempted removing all visualizers and reinserting them, disabling then renabling them and everything else I can think of. Their diameters are being calculated from something somewhere. I however cannot seem to find it.
How can this be fixed or is this just broken in 4.0.0?
Added Code
v 3.2.3
model asdfa
inner Modelica.Mechanics.MultiBody.World world(label2 = "z", label1 = "x", n = {0, 0, -1}) annotation(Placement(visible = true, transformation(origin = {-110, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0, 1, 0}) annotation(Placement(visible = true, transformation(origin = {-50, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation1(r = {0, -1, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {10, 72.396}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.PointMass pointMass1(m = 1) annotation(Placement(visible = true, transformation(origin = {52.304, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Visualizers.SignalArrow signalArrow1(diameter = 0.008) annotation(Placement(visible = true, transformation(origin = {85, 55}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation2(r = {1, 0, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {17.792, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Sensors.AbsoluteSensor absoluteSensor1(get_r = true, resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.world, arrowDiameter = 0.008, arrowColor = {255, 0, 255}) annotation(Placement(visible = true, transformation(origin = {45, -21.932}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(revolute1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-80, 30}, points = {{20, 0}, {-20, -0}}));
connect(revolute1.frame_b, fixedTranslation2.frame_a) annotation(Line(visible = true, origin = {-16.104, 30}, points = {{-23.896, 0}, {23.896, 0}}));
connect(fixedTranslation1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-27.5, 51.198}, points = {{27.5, 21.198}, {22.5, 21.198}, {22.5, -21.198}, {-72.5, -21.198}}));
connect(absoluteSensor1.r, signalArrow1.r_head) annotation(Line(visible = true, origin = {60, -16.449}, points = {{-25, -16.483}, {-25, -21.483}, {25, -21.483}, {25, 59.449}}));
connect(fixedTranslation1.frame_b, signalArrow1.frame_a) annotation(Line(visible = true, origin = {36.25, 63.698}, points = {{-16.25, 8.698}, {-11.25, 8.698}, {-11.25, -8.698}, {38.75, -8.698}}));
connect(fixedTranslation2.frame_b, pointMass1.frame_a) annotation(Line(visible = true, origin = {40.048, 30}, points = {{-12.256, 0}, {12.256, 0}}));
connect(absoluteSensor1.frame_a, pointMass1.frame_a) annotation(Line(visible = true, origin = {39.922, -5.546}, points = {{-4.922, -16.386}, {-9.922, -16.386}, {-9.922, -1.386}, {12.383, -1.386}, {12.383, 35.546}}));
annotation(Diagram(coordinateSystem(extent = {{-150, -90}, {150, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5}), graphics = {Rectangle(visible = true, lineColor = {0, 114, 195}, fillColor = {255, 255, 255}, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(visible = true, textColor = {64, 64, 64}, extent = {{-150, 110}, {150, 150}}, textString = "%name")}));
end asdfa;
Migrated to v4.0.0
model asdfa
inner Modelica.Mechanics.MultiBody.World world(label2 = "z", label1 = "x", n = {0, 0, -1}, defaultArrowDiameter = 0.008) annotation(Placement(visible = true, transformation(origin = {-110, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0, 1, 0}) annotation(Placement(visible = true, transformation(origin = {-50, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation1(r = {0, -1, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {10, 72.396}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.PointMass pointMass1(m = 1) annotation(Placement(visible = true, transformation(origin = {52.304, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Visualizers.SignalArrow signalArrow1 annotation(Placement(visible = true, transformation(origin = {85, 55}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
/*diameter = 0.008*/
Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation2(r = {1, 0, 0}, animation = false) annotation(Placement(visible = true, transformation(origin = {17.792, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Sensors.AbsoluteSensor absoluteSensor1(get_r = true, resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.world, /*arrowDiameter = 0.008,*/ arrowColor = {255, 0, 255}) annotation(Placement(visible = true, transformation(origin = {45, -21.932}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(revolute1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-80, 30}, points = {{20, 0}, {-20, -0}}));
connect(revolute1.frame_b, fixedTranslation2.frame_a) annotation(Line(visible = true, origin = {-16.104, 30}, points = {{-23.896, 0}, {23.896, 0}}));
connect(fixedTranslation1.frame_a, world.frame_b) annotation(Line(visible = true, origin = {-27.5, 51.198}, points = {{27.5, 21.198}, {22.5, 21.198}, {22.5, -21.198}, {-72.5, -21.198}}));
connect(absoluteSensor1.r, signalArrow1.r_head) annotation(Line(visible = true, origin = {60, -16.449}, points = {{-25, -16.483}, {-25, -21.483}, {25, -21.483}, {25, 59.449}}));
connect(fixedTranslation1.frame_b, signalArrow1.frame_a) annotation(Line(visible = true, origin = {36.25, 63.698}, points = {{-16.25, 8.698}, {-11.25, 8.698}, {-11.25, -8.698}, {38.75, -8.698}}));
connect(fixedTranslation2.frame_b, pointMass1.frame_a) annotation(Line(visible = true, origin = {40.048, 30}, points = {{-12.256, 0}, {12.256, 0}}));
connect(absoluteSensor1.frame_a, pointMass1.frame_a) annotation(Line(visible = true, origin = {39.922, -5.546}, points = {{-4.922, -16.386}, {-9.922, -16.386}, {-9.922, -1.386}, {12.383, -1.386}, {12.383, 35.546}}));
annotation(Diagram(coordinateSystem(extent = {{-150, -90}, {150, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5}), graphics = {Rectangle(visible = true, lineColor = {0, 114, 195}, fillColor = {255, 255, 255}, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(visible = true, textColor = {64, 64, 64}, extent = {{-150, 110}, {150, 150}}, textString = "%name")}));
end asdfa;

Related

Modelica Coding Standards / Modelica When Statement

Greeting Everyone,
Happy New Year 2020
I am using Openmodelica 1.14 release version on 64 bit windows 7 system.
I am facing some trouble with ‘when’ statement in OMSimulator. While searching for solution, I came across a closed ticket #2664 in Openmodelica. I can still see the reported issue in the current release version of Openmodelica.
I am including the relevant files of ticket # 2664.
model SimpleTest "just a simple model - Compilation etc."
Modelica.Blocks.Interfaces.IntegerInput u annotation(Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.IntegerOutput y annotation(Placement(visible = true, transformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
when change(u) then
y := y + 2;
end when;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(origin = {-6.15, 2.93}, fillColor = {0, 133, 199}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-77.89, 83.75}, {88.14, -92.53}})}));
end SimpleTest;
Is SimpleTest.mo as per Modelica standards?
While compilation of SimpleTest.mo , it throws a Translation Warning
Assuming fixed start value for the following 1 variables:
y:DISCRETE(flow=false fixed = false ) SimpleTest type: Integer
How to avoid this error?
It is just a warning. When you define a discrete variable like this such that it depends on it's previous value in a when condition, it has to have a fixed start value. Just providing a start value kind of is a guess value for the compiler, when you fix it you tell the compiler that it has to use this value for the initialization.
If you don't provide a start value it is set to zero, if you don't fix it, the compiler fixes it automatically (resulting in the warning).
Simple example:
Integer y(start=0, fixed=true);
Applied on your model:
model SimpleTest "just a simple model - Compilation etc."
Modelica.Blocks.Interfaces.IntegerInput u annotation(Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.IntegerOutput y(start=0, fixed=true) annotation(Placement(visible = true, transformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
when change(u) then
y := y + 2;
end when;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(origin = {-6.15, 2.93}, fillColor = {0, 133, 199}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-77.89, 83.75}, {88.14, -92.53}})}));
end SimpleTest;

How to fix "Model is not globally balanced" with SMPM and inverter

Based on the example Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMPM_VoltageSource, I am trying to use the inverter from Modelica.Electrical.PowerConverters.DCAC.MultiPhase2Level to feed the SMPM.
Unfortunately I get the error
Simulation model is not globally balanced, having 337 variables and
335 equations
but I can't figure out which two equations are missing.
What confuses me even more is that the model is balanced if I remove the signalPWM, inverter and the constantVoltage sources.
model SMPM_VoltageSource_Inverter
import Modelica.Constants.pi;
constant Integer m = 3 "Number of phases";
parameter Modelica.SIunits.Frequency f = 1000 "Switching frequency";
parameter Modelica.SIunits.Frequency f1 = 50 "Fundamental wave AC frequency";
parameter Modelica.SIunits.Current Idq[2] = {-53.5, 84.6} "Desired d- and q-current";
parameter Modelica.SIunits.AngularVelocity wNominal = 2 * pi * smpmData.fsNominal / smpmData.p "Nominal speed";
parameter Modelica.SIunits.Torque TLoad = 181.4 "Nominal load torque";
parameter Modelica.SIunits.Inertia JLoad = 0.29 "Load's moment of inertia";
Modelica.Electrical.Machines.BasicMachines.SynchronousInductionMachines.SM_PermanentMagnet smpm(phiMechanical(start = 0, fixed = true), wMechanical(start = 0, fixed = true), useSupport = false, useThermalPort = false, p = smpmData.p, fsNominal = smpmData.fsNominal, Rs = smpmData.Rs, TsRef = smpmData.TsRef, Lszero = smpmData.Lszero, Lssigma = smpmData.Lssigma, Jr = smpmData.Jr, Js = smpmData.Js, frictionParameters = smpmData.frictionParameters, statorCoreParameters = smpmData.statorCoreParameters, strayLoadParameters = smpmData.strayLoadParameters, VsOpenCircuit = smpmData.VsOpenCircuit, Lmd = smpmData.Lmd, Lmq = smpmData.Lmq, useDamperCage = smpmData.useDamperCage, Lrsigmad = smpmData.Lrsigmad, Lrsigmaq = smpmData.Lrsigmaq, Rrd = smpmData.Rrd, Rrq = smpmData.Rrq, TrRef = smpmData.TrRef, permanentMagnetLossParameters = smpmData.permanentMagnetLossParameters, TsOperational = 293.15, alpha20s = smpmData.alpha20s, TrOperational = 293.15, alpha20r = smpmData.alpha20r) annotation(Placement(transformation(extent = {{-20, -50}, {0, -30}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Blocks.Sources.Constant iq(k = Idq[2]) annotation(Placement(transformation(extent = {{-90, 20}, {-70, 40}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Blocks.Sources.Constant id(k = Idq[1]) annotation(Placement(transformation(extent = {{-90, 60}, {-70, 80}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Electrical.Machines.Utilities.TerminalBox terminalBox(terminalConnection = "Y") annotation(Placement(transformation(extent = {{-20, -34}, {0, -14}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Mechanics.Rotational.Sensors.AngleSensor angleSensor annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {20, -10}), visible = true));
Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(J = JLoad) annotation(Placement(transformation(extent = {{50, -50}, {70, -30}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque quadraticSpeedDependentTorque(tau_nominal = -TLoad, w_nominal(displayUnit = "rad/s") = wNominal) annotation(Placement(transformation(extent = {{100, -50}, {80, -30}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Electrical.MultiPhase.Sensors.CurrentSensor currentSensor(m = m) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {-10, -10}), visible = true));
Modelica.Electrical.Machines.Utilities.VoltageController voltageController(p = smpm.p, Ld = smpm.Lssigma + smpm.Lmd, Lq = smpm.Lssigma + smpm.Lmq, Rs = Modelica.Electrical.Machines.Thermal.convertResistance(smpm.Rs, smpm.TsRef, smpm.alpha20s, smpm.TsOperational), fsNominal = smpm.fsNominal, VsOpenCircuit = smpm.VsOpenCircuit) annotation(Placement(transformation(extent = {{-50, 40}, {-30, 60}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Mechanics.Rotational.Sensors.TorqueSensor torqueSensor annotation(Placement(transformation(extent = {{10, 10}, {-10, -10}}, rotation = 180, origin = {40, -70}), visible = true));
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {50, -10}), visible = true));
Modelica.Electrical.Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p = smpm.p) annotation(Placement(transformation(origin = {20, -50}, extent = {{-10, 10}, {10, -10}}, rotation = 270), visible = true));
Modelica.Electrical.Analog.Basic.Ground groundM annotation(Placement(transformation(origin = {-80, -38}, extent = {{-10, -10}, {10, 10}}, rotation = 270), visible = true));
Modelica.Electrical.MultiPhase.Basic.Star starM(final m = m) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-60, -20}), visible = true));
Modelica.Electrical.Machines.Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor annotation(Placement(transformation(extent = {{-10, 10}, {10, -10}}, rotation = 180, origin = {-30, -20}), visible = true));
parameter Modelica.Electrical.Machines.Utilities.ParameterRecords.SM_PermanentMagnetData smpmData(useDamperCage = false) annotation(Placement(transformation(extent = {{-20, -80}, {0, -60}}, origin = {-0, -10}, rotation = 0), visible = true));
Modelica.Electrical.Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor annotation(Placement(transformation(origin = {-10, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 270), visible = true));
Modelica.Electrical.PowerConverters.DCDC.Control.SignalPWM signalPWM[m](each useConstantDutyCycle = false, each f = f) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, origin = {-4.866, 46.285}, rotation = 0), visible = true));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_n(V = 50) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {87.166, 41.725}), visible = true));
Modelica.Electrical.PowerConverters.DCAC.MultiPhase2Level inverter(useHeatPort = false, m = m) annotation(Placement(transformation(extent = {{50, 20}, {30, 40}}, origin = {-3.885, 35.399}, rotation = 0), visible = true));
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {67.166, 71.725}), visible = true));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_p(V = 50) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {87.166, 81.725}), visible = true));
initial equation
smpm.is[1:2] = zeros(2);
equation
connect(terminalBox.plug_sn, smpm.plug_sn) annotation(Line(points = {{0, 0}, {0, 0}, {0, 0}}, color = {0, 0, 255}, visible = true, origin = {-16, -40}));
connect(terminalBox.plug_sp, smpm.plug_sp) annotation(Line(points = {{0, 0}, {0, 0}, {0, 0}}, color = {0, 0, 255}, visible = true, origin = {-4, -40}));
connect(quadraticSpeedDependentTorque.flange, inertiaLoad.flange_b) annotation(Line(points = {{80, -40}, {70, -40}}, visible = true, origin = {-0, -10}, color = {64, 64, 64}));
connect(smpm.flange, angleSensor.flange) annotation(Line(points = {{-6.667, -10}, {3.333, -10}, {3.333, 20}, {13.333, 20}}, visible = true, origin = {6.667, -40}, color = {64, 64, 64}));
connect(currentSensor.plug_n, terminalBox.plugSupply) annotation(Line(points = {{-10, -10}, {-10, -28}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(id.y, voltageController.id_rms) annotation(Line(points = {{-69, 70}, {-60, 70}, {-60, 56}, {-52, 56}}, color = {1, 37, 163}, visible = true, origin = {-0, -10}));
connect(iq.y, voltageController.iq_rms) annotation(Line(points = {{-69, 30}, {-60, 30}, {-60, 44}, {-52, 44}}, color = {1, 37, 163}, visible = true, origin = {-0, -10}));
connect(angleSensor.phi, voltageController.phi) annotation(Line(points = {{20, 11}, {20, 34}, {-34, 34}, {-34, 38}}, color = {1, 37, 163}, visible = true, origin = {0, -10}));
connect(currentSensor.i, voltageController.iActual) annotation(Line(points = {{-21, 0}, {-46, 0}, {-46, 38}}, color = {1, 37, 163}, visible = true, origin = {-0, -10}));
connect(inertiaLoad.flange_a, torqueSensor.flange_b) annotation(Line(points = {{50, -40}, {50, -60}}, visible = true, origin = {-0, -10}, color = {64, 64, 64}));
connect(torqueSensor.flange_a, smpm.flange) annotation(Line(points = {{30, -60}, {30, -40}, {0, -40}}, visible = true, origin = {-0, -10}, color = {64, 64, 64}));
connect(speedSensor.flange, smpm.flange) annotation(Line(points = {{23.333, 20}, {13.333, 20}, {13.333, -10}, {-26.667, -10}}, visible = true, origin = {26.667, -40}, color = {64, 64, 64}));
connect(rotorDisplacementAngle.flange, smpm.flange) annotation(Line(points = {{10, -40}, {0, -40}}, visible = true, origin = {-0, -10}, color = {64, 64, 64}));
connect(rotorDisplacementAngle.plug_p, smpm.plug_sp) annotation(Line(points = {{14, -30}, {-4, -30}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(rotorDisplacementAngle.plug_n, smpm.plug_sn) annotation(Line(points = {{26, -30}, {26, -20}, {-16, -20}, {-16, -30}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(voltageQuasiRMSSensor.plug_p, currentSensor.plug_n) annotation(Line(points = {{-20, -10}, {-10, -10}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(starM.plug_p, voltageQuasiRMSSensor.plug_n) annotation(Line(points = {{-50, -10}, {-40, -10}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(groundM.p, starM.pin_n) annotation(Line(points = {{-70, -28}, {-70, -10}}, color = {10, 90, 224}, visible = true, origin = {-0, -10}));
connect(currentQuasiRMSSensor.plug_n, currentSensor.plug_p) annotation(Line(points = {{0, 0}, {0, 0}, {0, 0}}, color = {0, 0, 255}, visible = true, origin = {-10, 0}));
connect(signalPWM.fire, inverter.fire_p) annotation(Line(points = {{-24.66, 1.943}, {-24.66, 6.943}, {-3.66, 6.943}, {-3.66, -6.943}, {28.321, -6.943}, {28.321, -1.943}}, color = {190, 52, 178}, visible = true, origin = {13.794, 55.342}));
connect(constantVoltage_n.n, inverter.dc_n) annotation(Line(points = {{-32.834, 6.725}, {-73.885, 6.725}, {-73.885, 30.399}}, color = {10, 90, 224}, visible = true, origin = {120, 25}));
connect(signalPWM.notFire, inverter.fire_n) annotation(Line(points = {{-12.66, 1.943}, {-12.66, 6.943}, {-3.66, 6.943}, {-3.66, -6.943}, {16.321, -6.943}, {16.321, -1.943}}, color = {190, 52, 178}, visible = true, origin = {13.794, 55.342}));
connect(constantVoltage_p.n, constantVoltage_n.p) annotation(Line(points = {{-70, 40}, {-70, 20}}, color = {10, 90, 224}, visible = true, origin = {157.166, 31.725}));
connect(constantVoltage_p.p, inverter.dc_p) annotation(Line(points = {{-70, 60}, {-111.051, 60}, {-111.051, 43.673}}, color = {10, 90, 224}, visible = true, origin = {157.166, 31.725}));
connect(inverter.ac, currentQuasiRMSSensor.plug_p) annotation(Line(visible = true, origin = {2.038, 50.266}, points = {{24.077, 15.133}, {-12.038, 15.133}, {-12.038, -30.266}}, color = {10, 90, 224}));
connect(voltageController.y[1], signalPWM[1].dutyCycle) annotation(Line(visible = true, origin = {-23.467, 43.142}, points = {{-5.533, -3.142}, {-0.533, -3.142}, {-0.533, 3.142}, {6.6, 3.142}}, color = {1, 37, 163}));
connect(ground1.p, constantVoltage_p.n) annotation(Line(points = {{-10, 0}, {-10, -5}, {10, -5}, {10, 10}}, color = {10, 90, 224}, visible = true, origin = {77.166, 61.725}));
annotation(experiment(StopTime = 2.0, Interval = 0.001), Documentation(info = "<html>
<p>
A synchronous induction machine with permanent magnets accelerates a quadratic speed dependent load from standstill.
The rms values of d- and q-current in rotor fixed coordinate system are controlled by the voltageController,
and the output voltages fed to the machine. The result shows that the torque is influenced by the q-current,
whereas the stator voltage is influenced by the d-current.</p>
<p>
Default machine parameters of model SM_PermanentMagnet are used.
</p>
</html>"));
end SMPM_VoltageSource_Inverter;
Does someone may know how to fix the problem so I can make this model run?
Any help would be highly appreciated!
You vectorized the component componentsignalPWM, using m=3 instances. But only the first instance has its input connected.
Change the connection
connect(voltageController.y[1], signalPWM[1].dutyCycle)
to
connect(voltageController.y, signalPWM.dutyCycle)
to connect the three outputs of voltageController to the inputs of the three signalPWM blocks.

How do I resolve an error pertaining to a variable not located within my OpenModelica Model?

I'm currently working on building a heat recovery steam generator and have just started building from the ThermoPower Library and connected an evaporator to the economizer.
When trying to simulate, an error occurs within the OMEdit Simulator:
division by zero at time 0, (a=-458389.9207317767) / (b=0), where divisor b expression is: 8.75988806777792 * Economizer.metalTube.Am * Economizer.metalTube.rhomcm * /Real/(Economizer.metalTube.Nt)
How exactly do I trouble shoot this error if I cannot define or locate the needed variables that are causing b=0?
Please let me know what you think about this. Your time and energy is greatly appreciated.
I'm not the best at debugging my models but I have an idea and I have some confusion trouble shooting this. My initial confusion was to verify which variable resulted in b=0. However, upon inspection I noticed how the variable Economizer.metalTube.Nt, Economizer.metalTube.Am did not exist within my the economizer class. I knew it had to be rooted into my class through extensions and partial classes and tried to define these "missing" variables in the text view of my economizer model, but this simply resulted in an error saying:
[1] 11:46:14 Translation Error
[ThermoPower_HRSG_Econ_Evap: 68:3-92:112]: Variable Economizer: In modifier (Nt = 3), class or component Nt not found in .
If you have any advice and/or recommendations please leave a comment below!
///UPDATE: Moving forward after what I've learned from others and implementing their suggestions.///
After reading what you and others have said about my issue on OpenModelica I have come to a better understanding of the situation. However, I am still confused as to what is the best way to move forward to debug my model.
So my "Economizer" model, or a heat exchanger located in ThermoPower.Examples.RankineCycles.Models.HE, was having the error associated with the divisor "b=0".
When debugging, the error hyperlinked me to the package "thermal" which pointed me towards the line of code that is being flagged:
(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";
This line of code is also being used in the Economizer HE class (ThermoPower.Examples.RankineCycles.Models.HE). Here in the HE.mo, the same flagged line of code from the thermal package that is causing the error is also located here. What's making my model cause the divider "b=0" are the variables: L, Nw, Nt, Am and Tvol. These variables are not defined/found in the model I am using when defining system parameters.
What's confusing for me as a OpenModelica user is that those variables just mentioned above (L, Nw, Nt, Am and Tvol) are coded/defined in the ThermoPower.Examples.RankineCycles.Models.HE text view of the component, but when I try to define/add them into my Economizer.mo belonging to the ThermoPower.Examples.RankineCycles.Models.HE class, errors are triggered claiming:
[ThermoPower_HRSG_Econ_Evap: 69:3-94:112]: Variable Economizer: In modifier
(Nt = 1), class or component Nt not found in
<ThermoPower.Examples.RankineCycle.Models.HE$Economizer>.
Essentially, the errors causing the divider "b=0" are located in the base class of the economizer I am using. However, due to the absence or in-ability to define these needed variables within my Economizer.mo model, the equation:
(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";
Is now being violated. How do I fix this issue properly?
///UPDATE: CODE PROVIDED BELOW///
model ThermoPower_HRSG_Econ_Evap
ThermoPower.Gas.SourceMassFlow Source_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas,
T = 331.59 + 273.15,
p0 = 101325,
w0 = 169.755) annotation(
Placement(visible = true, transformation(origin = {-92, 30}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Water.SourceMassFlow Source_Steam(
T = 46.45 + 273.15,
h = 203.22e3,
p0 = 80e5,
use_T = true,
w0 = 21.5) annotation(
Placement(visible = true, transformation(origin = {-10, 90}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Water.SensT sensT_WaterIn_Econ annotation(
Placement(visible = true, transformation(origin = {4, 60}, extent = {{-10,
-10}, {10, 10}}, rotation = -90)));
ThermoPower.Water.SensT sensT_WaterOut_Econ annotation(
Placement(visible = true, transformation(origin = {4, 0}, extent = {{-10,
-10}, {10, 10}}, rotation = -90)));
ThermoPower.Gas.SensT sensT_ExhaustIn_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas) annotation(
Placement(visible = true, transformation(origin = {-50, 34}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Gas.SensT sensT_ExhaustOut_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas) annotation(
Placement(visible = true, transformation(origin = {50, 34}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
inner ThermoPower.System system annotation(
Placement(visible = true, transformation(origin = {-90, 90}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Gas.SinkPressure Sink_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas,
p0 = 101325) annotation(
Placement(visible = true, transformation(origin = {94, -70}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Water.SinkPressure Sink_Steam(
p0 = 80e5) annotation(
Placement(visible = true, transformation(origin = {10, -90}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Examples.HRB.Models.Evaporator Evaporator(
cm = 480,
exchSurface = 2.752,
fluidNomFlowRate = 21.5,
fluidNomPressure = 8e+06,
fluidVol = 0.01376,
gamma = 85,
gasNomFlowRate = 169.755,
gasNomPressure = 101325,
gasVol = 0.01376,
metalVol = 0.01376,
rhom(displayUnit = "kg/m3") = 8055,
rhonom_G = 1) annotation(
Placement(visible = true, transformation(origin = {0, -50}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Gas.SensT sensT_ExhaustOut_Evap(
redeclare package Medium = ThermoPower.Media.FlueGas) annotation(
Placement(visible = true, transformation(origin = {50, -66}, extent =
{{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Continuous.FirstOrder VoidFractionSensor annotation(
Placement(visible = true, transformation(origin = {53, -43}, extent =
{{-5, -5}, {5, 5}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput VoidFraction annotation(
Placement(visible = true, transformation(origin = {110, -42}, extent =
{{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110,
-42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
ThermoPower.Examples.RankineCycle.Models.HE Economizer(
FFtype_G = ThermoPower.Choices.Flow1D.FFtypes.OpPoint,
FluidPhaseStart = ThermoPower.Choices.FluidPhase.FluidPhases.Liquid,
N_F = 6,
N_G = 6,
Tstart_G = 604.74,
Tstart_M = 573.15, counterCurrent = true,
exchSurface_F = 2.752,
exchSurface_G = 2.752,
extSurfaceTub = 5.504,
fluidNomFlowRate = 21.5,
fluidNomPressure = 8e+06,
fluidVol = 0.01376,
gamma_F = 3000,
gamma_G = 30,
gasNomFlowRate = 169.755,
gasNomPressure = 101325,
gasVol = 0.01376,
lambda = 19.8,
metalVol = 0.01376,
rhomcm = 8055 * 480,
rhonom_F(displayUnit = "kg/m3") = 997,
rhonom_G = 1) annotation(
Placement(visible = true, transformation(origin = {0, 30}, extent = {{-10,
-10}, {10, 10}}, rotation = 0)));
equation
connect(Economizer.gasOut, sensT_ExhaustOut_Econ.inlet) annotation(
Line(points = {{10, 30}, {44, 30}, {44, 30}, {44, 30}}, color = {159, 159,
223}));
connect(sensT_ExhaustIn_Econ.outlet, Economizer.gasIn) annotation(
Line(points = {{-44, 30}, {-10, 30}, {-10, 30}, {-10, 30}}, color = {159,
159, 223}));
connect(Economizer.waterOut, sensT_WaterOut_Econ.inlet) annotation(
Line(points = {{0, 20}, {0, 20}, {0, 6}, {0, 6}}, color = {0, 0, 255}));
connect(sensT_WaterIn_Econ.outlet, Economizer.waterIn) annotation(
Line(points = {{0, 54}, {0, 54}, {0, 40}, {0, 40}}, color = {0, 0, 255}));
connect(VoidFractionSensor.y, VoidFraction) annotation(
Line(points = {{58, -42}, {104, -42}, {104, -42}, {110, -42}}, color = {0,
0, 127}));
connect(Evaporator.voidFraction, VoidFractionSensor.u) annotation(
Line(points = {{10, -44}, {46, -44}, {46, -42}, {46, -42}}, color = {0, 0,
127}));
connect(sensT_ExhaustOut_Evap.outlet, Sink_FlueGas.flange) annotation(
Line(points = {{56, -70}, {70, -70}, {70, -70}, {84, -70}, {84, -70}, {84,
-70}}, color = {159, 159, 223}));
connect(Evaporator.gasOut, sensT_ExhaustOut_Evap.inlet) annotation(
Line(points = {{10, -50}, {26, -50}, {26, -70}, {44, -70}}, color = {159,
159, 223}));
connect(sensT_ExhaustOut_Econ.outlet, Evaporator.gasIn) annotation(
Line(points = {{56, 30}, {68, 30}, {68, -20}, {-50, -20}, {-50, -20},
{-70, -20}, {-70, -50}, {-10, -50}, {-10, -50}}, color = {159, 159,
223}));
connect(sensT_WaterOut_Econ.outlet, Evaporator.waterIn) annotation(
Line(points = {{0, -6}, {0, -40}}, color = {0, 0, 255}));
connect(Evaporator.waterOut, Sink_Steam.flange) annotation(
Line(points = {{0, -60}, {0, -90}}, color = {0, 0, 255}));
connect(Source_FlueGas.flange, sensT_ExhaustIn_Econ.inlet) annotation(
Line(points = {{-82, 30}, {-56, 30}}, color = {159, 159, 223}));
connect(Source_Steam.flange, sensT_WaterIn_Econ.inlet) annotation(
Line(points = {{0, 90}, {0, 66}}, color = {0, 0, 255}));
annotation(
uses(ThermoPower(version = "3.1"), Modelica(version = "3.2.3")));end
ThermoPower_HRSG_Econ_Evap;

How to connect from an output block to an input block in openmodelica?

I have an openmodelica interface.
block InputInterfaceBlock
CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("/pathToSocket/rpcSocket");
Modelica.Blocks.Interfaces.RealOutput y annotation(
Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
while true loop
y := CPSModel.Functions.readFromSocket(con);
print("Message from server : " + String(y) + "\n");
end while;
annotation(
__OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Input\nInterface", fontName = "DejaVu Sans Mono Bold")}));
annotation(
Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end InputInterfaceBlock;
I have an interface block (InputInterfaceBlock) which reads from a socket which is defined in the path. I want this interface block to connect to another block (OutputInterfaceBlock).
block OutputInterfaceBlock
CPSModel.ConnectionObjects.SocketConnection con = CPSModel.ConnectionObjects.SocketConnection("pathToModel/rpcSocket");
Modelica.Blocks.Interfaces.RealInput y annotation(
Placement(visible = true, transformation(origin = {194, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
algorithm
print("Trying to send : " + String(y) + "\n");
CPSModel.Functions.writeToSocket(con, y);
print("Message send to server." + "\n");
annotation(
__OpenModelica_simulationFlags(jacobian = "coloredNumerical", s = "dassl", lv = "LOG_STATS"),
uses(Modelica(version = "3.2.2")),
Icon(graphics = {Text(origin = {4, -1}, extent = {{-62, 73}, {62, -73}}, textString = "Output\nInterface", fontName = "DejaVu Sans Mono")}));
annotation(
Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
end OutputInterfaceBlock;
My model is as follows.
model MechatronicSystem
CPSModel.Models.InputInterfaceBlock Input annotation(
Placement(visible = true, transformation(origin = {-90, 8}, extent = {{-28, -28}, {28, 28}}, rotation = 0)));
CPSModel.Models.OutputInterfaceBlock Output annotation(
Placement(visible = true, transformation(origin = {72, 12}, extent = {{28, 28}, {-28, -28}}, rotation = 0)));
equation
connect(Input.y, Output.y) annotation(
Line(points = {{-60, 8}, {44, 8}, {44, 12}, {42, 12}}, color = {0, 0, 127}));
annotation(
uses(Modelica(version = "3.2.2")));
end MechatronicSystem;
I can receive the data in the InputInterfaceBlock from the socket to the model, but when I try to send that data to OutputInterfaceBlock. It is not getting received in the OutputInterfaceBlock.
How can I fix it ?
You are using a while true loop in InputInterfaceBlock, but the different algorithms in Modelica are not co-routines but normal algorithms.
You could replace that with when sample(0.1,0.1) then ... end when; or similarly, which will run the code every 0.1s seconds.
The while-loop causes the model should be stuck in InputInterfaceBlock and OutputInterfaceBlock not be called.

Modelica spring-pendulum

I want to model a simple "spring-pendulum" in modelica:
model Pendulum
parameter Boolean animation=true "= true, if animation shall be enabled";
inner Modelica.Mechanics.MultiBody.World world(axisLength=0.6)
Modelica.Mechanics.MultiBody.Parts.Body body1(
m=1,
animation=animation,
I_11=1,
I_22=1,
I_33=1,
r_CM={0,0,0},
cylinderDiameter=0.05,
sphereDiameter=0.2)
Modelica.Mechanics.MultiBody.Forces.Spring spring1(
coilWidth=0.01,
numberOfWindings=5,
c=20,
s_unstretched=0.2) ;
Modelica.Mechanics.MultiBody.Joints.Revolute revolute(phi(fixed=true), w(
fixed=true));
equation
connect(world.frame_b, revolute.frame_a)
connect(spring1.frame_a, revolute.frame_a)
connect(spring1.frame_b, body1.frame_a)
connect(revolute.frame_b, body1.frame_a
end Pendulum;
Trying to simulate the simulation fail - no error message.
Do i need a revolulte for a spring-pendulum? Thank you very much for your help!
Not exactly sure of what you're trying to model. If you make a drawing of your system you'll see that it won't represent what you're trying to model (I think).
Here's a pendulum with a spring:
model pendulum2
inner Modelica.Mechanics.MultiBody.World world annotation(Placement(visible = true, transformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute annotation(Placement(visible = true, transformation(origin = {-41.539, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Joints.Prismatic prismatic(s.start = .5) annotation(Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.Body body annotation(Placement(visible = true, transformation(origin = {25, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Forces.Spring spring(c = 100, s_unstretched = .5) annotation(Placement(visible = true, transformation(origin = {-10, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(spring.frame_b, prismatic.frame_b) annotation(Line(visible = true, origin = {0, 10}, points = {{0, 10}, {0, -10}}));
connect(spring.frame_a, prismatic.frame_a) annotation(Line(visible = true, origin = {-20, 10}, points = {{0, 10}, {0, -10}}));
connect(prismatic.frame_b, body.frame_a) annotation(Line(visible = true, origin = {7.5, 0}, points = {{-7.5, -0}, {7.5, 0}}));
connect(revolute.frame_b, prismatic.frame_a) annotation(Line(visible = true, origin = {-25.77, 0}, points = {{-5.77, 0}, {5.77, 0}}));
connect(world.frame_b, revolute.frame_a) annotation(Line(visible = true, origin = {-60.77, 0}, points = {{-9.23, 0}, {9.23, 0}}));
annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end pendulum2;