- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Condition giving in Basic valve model
Condition giving in Basic valve model
Condition giving in Basic valve model
Hallo,
I am new to open modelica. I am trying to model an equation based model of a valve system and found this Software useful. Below is the code of the Throttle valve which is a Basic component in model System. Full model consists of many throttle valves in series and parallel connection. Even the Basic throttle valve model Fails when differential pressure(dp) less than zero or equal to Zero. Érror Analysis indicates that the Format of eqúation (Quadratic equation for flow rate) is causing the trouble. I tried to use if else Statement giving conditions of pressure it works fine. But the Simulation stucks in the middle when it id done on combined throttle models(after connecting 3/4 models in parallel/series). Also i remember about Problems with if else Statements in big models. Is there any way to describe conditions other than mentioned method.
model Throttle
extends BasicValve;
Real Hub(unit = "mm")"Stroke of valve cone relative to the position of cone in mm(Hub=0 when D1 closed)";
Real Kv(unit = "m^3/h")"Flow coeffient of valve";
Real Q2"Intermediate flow rate value used in inner calculations";
parameter Real Turn(unit="Nos.") "No of turns on D1 spindle(From close to open state)";
parameter Real Pitch(unit="mm") "Pitch of the screw thread of valve spindle";
equation
Hub=Turn*Pitch;
Kv = 0.0319 * Hub;
outlet.Q = -inlet.Q;
outlet.P = inlet.P - (Q2 ^ 2 / Kv ^ 2);
inlet.Q = Q2;
annotation(
Icon(graphics = {Line(origin = {0, 50}, points = {{0, 50}, {0, 50}, {0, -50}, {0, -50}}, thickness = 1), Rectangle(origin = {6, 99}, fillPattern = FillPattern.Solid, extent = {{-60, 3}, {48, -3}}), Text(origin = {-46, -25}, extent = {{110, -91}, {-14, 13}}, textString = "D2")}, coordinateSystem(initialScale = 0.1)));
end DrozzleD2;
partial model BasicValve
Port inlet annotation(
Placement(visible = true, transformation(origin = {-100, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Port outlet annotation(
Placement(visible = true, transformation(origin = {100, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
annotation(
Diagram,
Icon(graphics = {Polygon(origin = {-50, 1}, points = {{-50, 99}, {-50, -99}, {50, -1}, {50, -1}, {-50, 99}}), Polygon(origin = {50, 0}, points = {{50, 100}, {-50, 0}, {50, -100}, {50, 100}})}));
end BasicValve;
Port used to connect model between an Input and Output fluid source/sink (Pressure (P), Flow rate (Q) variables). I didn't use modelica library models as the equation i use are different. Sorry if the questions are too naive but i really seek advice from experts
Thanks in advance
Joel
Re: Condition giving in Basic valve model
Hi Joel,
The problem might be the quadratic pressure drop equation which has two solutions (positive/negative flow). This can be solved in the first place by multiplying the equation with 'sign(Q2)'. Alternatively, you can use the function 'Modelica.Fluid.Utilities.regSquare()' in the equation. This ensures that the derivative is not zero when the flow is zero. Your pressure drop equation will look like this:
outlet.P = inlet.P - Modelica.Fluid.Utilities.regSquare(Q2) / Kv^2;
Best regards,
Rene Just Nielsen
- justnielsen
-
-
- 40 Posts
Re: Condition giving in Basic valve model
Hi Rene,
Thanks for your kind help. Really it was helpful. Actually i was complete with full model System and i was tricking compiler by interchanging equation format to other forms thereby removing compilation errors. Now I changed the pressure drop equation format on all models as per you mentioned and this works finely. Valve works in forward, no flow and reverse flow conditions. Thanks again for the valuable Information.
Sorry if i am asking this, Now adays i am really ambitious about modelica . I tried some animation models from modelica.mechanics.multibody and Simulation with Animation is awesome. Is it possible to modify library model components to my valve component (moving parts only). So that i can view actual movement of parts after Simulation? The library models for animations seems too complex with too many equations and variables. Is there anywhere i can get more guidance like a tutorial/Manual?
Thanks and regards,
Joel
Re: Condition giving in Basic valve model
Hi Joel,
You're welcome. I'm glad it worked for you.
Regarding animations: I haven't got much experience with the animations from the mechanical domain. But if you'd like to visualise e.g. the valve opening or the operation of a pump in the diagram view during simulation this is indeed possible with graphical annotations.
The company Claytex has an excellent blog with Modelica tips and tricks (http://www.claytex.com/blog) and this post (http://www.claytex.com/blog/how-to-buil … n-dymola/) is probably what you need to look at.
Best regards
Rene Just Nielsen
- justnielsen
-
-
- 40 Posts
Re: Condition giving in Basic valve model
Hi Rene,
That was very quick response with very relevant information. Looks like I need to invest some time for learning graphical annotations and their format. Claytex definitely would be helpful I think.
People like you make modelica a better place to model systems. Kudos.. Thanks again friend.
Regards,
Joel
Re: Condition giving in Basic valve model
Thanks Joel, you're welcome.
BR Rene
- justnielsen
-
-
- 40 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Condition giving in Basic valve model