Message Boards Message Boards

0
|
7894 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

Two tank simulation help

Posted 9 years ago

Hello

I was struggling to understand how WSM works (To be honest, how Modelica language and extensions work - Perhaps I am too used to the simulink way of simulating systems). I am trying to reproduce a two tank system with a valve between them (the equation of the valve was determined from experimental data and the valve is connected to the bottom of the tanks). Although I can, up to a certain point, follow the same approach I did for creating the simulink model, I would like to use the block components available on WSM.

a) I know there is a tank block but the input is on the top of it. How can I change the input to the bottom for the second tank? Since the flow on the valve can be on both directions, how to accommodate such behavior since it seems that the connections are only unidirectional?

b) How to implement that valve with the experimental curve using blocks? Or how to modify an existing one?

c) I have noticed that the modelica library on WSM is missing Fluid and Media. How can I add them to Modelica-WSM?

d) How about animation?

Perhaps my questions do not make any sense. If that is the case, I do apologize.

Many thanks.

Ed

POSTED BY: Eduardo Mendes
4 Replies

Hi Ed!

a) Which tank block is it that you are referring to? Is it the one found under IntroductoryExamples.Hierarchial.Components.Tank and used in the TankSystem model?

tanksystem

That block and package is used to demonstrate the principles of hierarchical modeling rather than being an accurate description of a tank. The outflow from the tank in the model is controlled by a real valued input signal (red arrow) and is not dependent on the actual volume of the tank.

Could you expand on what you mean by "How can I change the input to the bottom for the second tank?". In the block I am assuming that you are referring to (correct me if I am wrong) the ports are not defined as being on the top or the bottom. That is only how they are displayed in the icon.

b) These experimental curves that you are referring to, what is it that they measure?

c) Media and Fluid are not supported in the current version of SystemModeler, but work is being done to support them in the future.

d) What kind of animation are you interested in? Something like the video here: http://www.wolfram.com/system-modeler/examples/more/chemical-engineering/pi-controlled-tank-system can be accomplished using Dynamic Graphics in SystemModeler and then visualized in Mathematica.

See Dynamics Graphics here: http://reference.wolfram.com/system-modeler/UserGuide/ModelCenterGraphicalViews.html to see how these can be set up.

After simulating the model in Mathematica, the following function will yield the diagram with the dynamic graphics at time t:

sim = WSMSimulate[model]
sim["Diagram",t]

Regards, Patrik

POSTED BY: Patrik Ekenberg

b) If you have a function for the flow versus valve opening, you can create a new component and write it into the text view. (Ctrl+3 hotkey). It could look something like this:

model ValveCurve
    IntroductoryExamples.Hierarchical.Interfaces.ActSignalOutput q;
    Modelica.Blocks.Interfaces.RealInput u;
 equation
    q = ((-1) + (-2) * u + (-3) * u ^ 2) * (3 + (-1) * u ^ 3) ^ (-1);
 end ValveCurve;

That model would take the input in the form of a real-valued signal an output a flowrate that you could connect to the tank in the introductory example, like this:

valve curve function in diagram

I attached the model so you can explore it yourself.

Alternatively, if you have the equation in Mathematica, you can create the component from there:

Needs["WSMLink`"]
flowVsOpening = {q[t] == -(1 + 2 u[t] + 3 u[t]^2)/(3 - u[t]^3)};
WSMCreateModel["ValveCurve", 
    flowVsOpening, t, {
    u[t] \[Element] "Modelica.Blocks.Interfaces.RealInput",
    q[t] \[Element] "IntroductoryExamples.Hierarchical.Interfaces.ActSignalOutput"}
]

This also works with discontinuous functions, like:

flowVsOpening = {q[t] == 
     If[u[t] > 0.1, -(1 + 2 u[t] + 3 u[t]^2)/(3 - u[t]^3), 0]};   

c) The Hydraulic library does indeed contain many of the components that deals with fluid flows, such as tanks, valves and pumps. As the whether it would help you in your case, I am still unsure what it is you are trying to do, so that I cannot answer. You can view and read about all the components that are part of the Hydraulic library in the reference page:

http://reference.wolfram.com/system-modeler/libraries/Hydraulic/Hydraulic.html

d) 3D animations can be created using the MultiBody library. There are multiple visualizer shapes that will generate automatic 3D animations. The reference can be found here:

http://reference.wolfram.com/system-modeler/libraries/Modelica/Modelica.Mechanics.MultiBody.Visualizers.html

Cylinders of course come to mind when we are talking about tanks. If none of the built in visualizer shape types cut it, you can import your own CAD-models, like it is done here:

https://www.wolfram.com/system-modeler/examples/heavy-equipment/construction-equipment-simulation.html

Note that you will have to convert the output signals from your model into something that meaningful in a 3-dimensional space.

Attachments:
POSTED BY: Patrik Ekenberg
Posted 9 years ago

Hello Patrick

Many thanks for the reply.

a) Yes, I have used the block under IntroductoryExamples.Hierarchial.Components.Tank.

I just need to change the location of the ports to give a more "real" feeling of the actual system.

b) I was referring to the curve "Flow versus % Opening of the Valve". In our case it is not a typical curve but a ratio of polynomials.

c) Any plans to release a new version of WSM this year? Would the Hydraulic library help me in this case?

d) I was thinking of something like the animation for the pendulum example. I will look into the info you have listed.

Many thanks

Regards

Ed

POSTED BY: Updating Name
Posted 9 years ago

Dear Patrick

Sorry for my late reply.

Thank you ever so much.

regards

Ed

POSTED BY: Eduardo Mendes
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract