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
  • Index
  • » Users
  • » Zwieback
  • » Profile

Posts

Posts

oh............

Thank you very much - that was my mistake.
I first created an instance of the EngineSpeed-Model... I now replaced that by "extends EngineSpeed" and it works fine.

One more litte detail: I'd like to have a quick access to engine's speed. Therefore, I also create an instance of it so that I can change the speed-parameter quite easily. No problem so far. But the EngineSpeed-model has a nice icon to represend the combustion engine. By extending this model, my top-level model (oilcircuit) inherits not just the code but also this icon. Is there a way to suppress this behaviour? 

Cheers, Jan

Thanks a lot for the quick answer.

I just agree to an extent:
In my case, my outer variable was "DefEngineSpeed.rpm". This Approach is similar to the one used in the OpenHydraulics-library

Code:

partial model PartialFluidComponent "Base model for any component involving fluid"

  outer OpenHydraulics.Fluids.BaseClasses.PartialFluid oil "This model must be defined in each circuit; the type must be a subtype of PartialFluid";
  parameter SI.AbsolutePressure p_init = environment.p_ambient "Initial temperature of the component" annotation(Dialog(tab = "Initialization", group = "Fluid"));
protected
  outer OpenHydraulics.Circuits.Environment environment;
  annotation(Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics));
end PartialFluidComponent;

But I now changed my code as you suggested.

Code:


// EngineSpeed model
model EngineSpeed
  inner parameter SI.Conversions.NonSIunits.AngularVelocity_rpm speed = 2000;
end EngineSpeed;

// bearing model
  outer parameter SI.Conversions.NonSIunits.AngularVelocity_rpm speed;

Unfortunately, the warning message still appears (one for every bearing)

Hi guys,
I try to simulate an oilcircuit that consists several bearings each of which needs the same rotational speed input.
For this reason, I wanted to introduce the keywords "inner" and "outer". Here is what I did:

- I added a model "EngineSpeed":
  model EngineSpeed
  parameter SI.Conversions.NonSIunits.AngularVelocity_rpm rpm = 2000;
  annotation(...);
- I added the following code lines to my bearing-model:
  parameter SI.Conversions.NonSIunits.AngularVelocity_rpm speed = DefEngineSpeed.rpm;
  protected
  outer OilCircuit.Components.Engine.Bearings.EngineSpeed DefEngineSpeed;

My circuit-model now consits of several bearing-models (and a pump, pipes etc...) AND an EngineSpeed-model.
Nevertheless, OMEdit plots the following warning message:

[OilCircuit.Components.Engine.Bearings.MainBearing: 25:3-25:73]: No corresponding 'inner' declaration found for component .OilCircuit.Components.Engine.Bearings.EngineSpeed HL5.DefEngineSpeed declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: OilCircuit.Components.Engine.Bearings.MainBearing$HL5.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.

Replacing the EngineSpeed-model by

  model EngineSpeed
  inner parameter SI.Conversions.NonSIunits.AngularVelocity_rpm rpm = 2000;
  annotation(...);

makes no difference.


The simulation runs without any problems, but I would like to eliminate the warning messages. Any ideas?

Thanks a lot.

I am really no pro, but it seems to me that the "acos"-functions causes the Problem.
As the message tells, the argument becomes out of range. I guess that "R" is a fixed (positive) value?! Might it be possible, that "Level" becomes negative?

Dec-23-15 12:30:49
EndOfFile error

Hi,
sorry for the late Response. I guess that you used the components out of the Standard library?
I created the model you have described (mass, spring, fixed), but I don't get an error message. I am using OpenModelica OMEdit with Windows 7.


Sorry that I can't help you.

Regards, Zwieback

Thanks a lot for your response.

It's not a conditional component I was looking for. Let me first try to explain the application a bit more in detail:
Let's consider a whole oil circuit. Now, I'd like to measure several system pressures in order to control a pump.
For this reason, I'd like to create a "control unit" with 4 Input signals where I can connect 4 pressure sensors. But there are also situations where I just need one or two of them. Since I don't want to create one control unit for every situation, I'd like to deactivate the inputs which I don't need. In other words: I was looking for a code like "If the real Input is not connected to a sensor, ignore this input in order to balacne the equation system" (obviously, there are connect-equations missing if some of the inputs are left unconnected).

Until now, I couldn't find such a code. What I did is the following:
I use one more internal variable ("press1_internal") and connect this one to the real Input (which is for the pressure sensor actually).
The value of press1_internal is choosen large enough that the following process runs without complication.
This solution is in the style of the "presribed pump" out of the standard library (Fluid --> Machines).
One disadvantage is that the user has to choose whether a pressure sensor Input shall be used or not (boolean use_p1, ..._p2, ...). I hoped that there is a better solution for this problem...

Here is n extract of my code:

model SensorControl
  parameter Boolean use_p1 = false annotation(Dialog(group = "Pressure Sensor 1"));
  parameter Boolean use_p2 = false annotation(Dialog(group = "Pressure Sensor 2"));
    "..."
  Modelica.Blocks.Interfaces.RealInput press1 annotation(Placement(visible = true, transformation(origin = {-70, -110}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(origin = {-70, -55}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  Modelica.Blocks.Interfaces.RealInput press2 annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10,
      "..."
protected
  Modelica.Blocks.Interfaces.RealInput press1_internal "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput press2_internal "Needed to connect to conditional connector";
    "..."
equation
  connect(press1, press1_internal);
  if not use_p1 then
    press1_internal = 99999999;
  end if;
  connect(press2, press2_internal);
  if not use_p2 then
    press2_internal = 99999999;
  end if;
    "..."
end SensorControl;

Thank you very much. Regards, Zwieback

Hi there,

I want to use a model which has several real Inputs (for several sensor signals). But I don't always need all of them. It would be great if modelica would ignore the Inputs that are not connected. Otherwise, I have more variables than equations.

The "cardinality" command doesn't work (is it just for connectors?) and I would like to avoid creating a bool for every Input that has to be set on "true" by the user if a real Input is needed.

Can anyone help? Thanks a lot
Zwieback

Hi there,

I want to use a model which has several real Inputs (for several sensor signals). But I don't always need all of them. It would be great if modelica would ignore the Inputs that are not connected. Otherwise, I have more variables than equations.

The "cardinality" command doesn't work (is it just for connectors?) and I would like to avoid creating a bool for every Input that has to set on true manually if a real Input is needed.

Can anyone help? Thanks a lot
Zwieback

Dec-18-15 13:14:42
EndOfFile error

Quite few Information. Please post you code.

Hi there,

I try to simulate an oil circuit, consisting of pipes, splits, bearings,...For this purpose, I created my own library.
Of course, my model has one flow inlet (lets call it pump) and several outputs (e. g. bearings, from which the oil flows back to the sump). To prevent illocial boundary conditions, I defined the mass flow in the output component as min=0. Quite easy and works as intended. But as soon as I add a component which uses a lookup-table (= Combi-Tables out of the Modelica Standard Library) in which the lossfactor is stored, OMEdit ignores the min-value and as a result, negative mass flow is possible.

Does anybody know why the definition of min-values doesn't work when using lookup-tables

Thank you very much! Regards, Jan

Dec-14-15 06:20:16
Do you have a clear explane to explain how to use it?
Category: Programming

I use the "within"-statement to define the position of a new model within the model library.
I do not use the function "save in one file" when creating new packages. Instead of this Option, every package is a new file (which prevents data loss). After I created a new model, I first add the within-statement, e.g.
package - Test
model - Test01: first line in code: within Test;
model - Test01a: first line in code: within Test.Test01;
....

Oct-27-15 12:39:22
Category: Programming

Your script seems to be incomplete.
"LimitValue" is a function that receives "minV,maxV,-flowGain*outCtr" as Inputs.
To run your example, you also have to add that function (otherwise, it can be found by the model FlatTank). The code can be found in the same book one paragraph below.

function LimitValue
input Real pMin;
input Real pMax;
input Real p;
output Real pLim;
algorithm
pLim := if p>pMax then pMax
else if p<pMin then pMin
else p;
end LimitValue;

Regards, Jan

Oct-20-15 13:56:50
usage of models with nonlinear equations
Category: Programming

Ok, I think I found the solution by myself.

What I did first:
- I created a new function (FunNonLinear), e.g. the one for the friction factor lambda:  y := 2 * sqrt(lambda) * Modelica.Math.log10(Re * sqrt(lambda) / 2.51) - 1;
- I tried to solve this equation by adding the function call {lambda := Modelica.Math.Nonlinear.solveOneNonlinearEquation(function FunNonLinear(Re = 27000), 0.0001, 0.1, 0.001);} in the pipe model
>>> It didn't work this way.

"Unfortunately", the solution seems to be quite simple:
- I still use the mentioned funcion "FunNonLinear": y := 2 * sqrt(lambda) * Modelica.Math.log10(Re * sqrt(lambda) / 2.51) - 1
- I then created another function (FunCall) which includes the function call: lambda := Modelica.Math.Nonlinear.solveOneNonlinearEquation(function FunNonLinear(Re = a), 0.0001, 0.1, 0.001); where a is a parameter that can be chosen by the user
- to get the wanted value for lambda, I now call the 2nd function (FunCall) out of my model, e.g. by: lambda = FunCall(a=27000);
>>> It is now possible to create an instance of this model

I hope that you can understand my poor English and maybe someone else has a problem similiar to this one...

Regards, Jan

Oct-19-15 13:55:28
usage of models with nonlinear equations
Category: Programming

Hi together,

I am quite new here in the community and just face my first serious problem.

Let me explain the background at first:
I want to create a small library for special fluid applications (lubrication).
For this library, I also need basic components such as pipes. To calculate the pressure drop in a pipe, I need the friction factor. Up to now, I used approximated equations that could be solved easily, since the wanted variable was already separated on the left side. But now, I'd like to use those equations that can be found in literature, e.g. the Prandtl-Karman-equation:

1/sqrt(lambda) = 2 * log10(Re * sqrt(lambda) / 2.51)
lambda: friction factor
Re: Reynoldsnumber

Obviously, this equation has to be solved iteratively. I managed to do so by using the Modelica Standard library: Modelica.Math.Nonlinear.solveOneNonlinearEquation. I get the correct result.

And here's my problem: I now want to use this component (e.g. a pipe) in another model (a network consisting of several pipes and so on), but I get the error message:
Failed to instantiate equation
lambda = Modelica.Math.Nonlinear.solveOneNonlinearEquation(function OilCircuit.Functions.FrictionFactor.Smooth.PrandtlKarman(Re = 27000), 0.0001, 0.1, 0.001);.

Well, it seems that one can't instatiate an equation. But I can't find any other solution to solve this.
Can anyone help?

Thank you very much! Regards, Jan

  • Index
  • » Users
  • » Zwieback
  • » Profile
You are here: