NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Information about this web site => Request for physics Simulations => Topic started by: pavwell on March 17, 2010, 03:10:03 pm



Title: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 17, 2010, 03:10:03 pm
Hello ! Could anyone help me with creating EJS aplication of Hydrosystem with two tanks connected one after another ?
Thanks a lot !!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 17, 2010, 04:17:57 pm
Please describe the whole system in detail!
If I can not understand the system and the physics model involved, there is no way I can create a simulation.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 17, 2010, 04:52:27 pm
I will send you email where i subcribe my problem.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 17, 2010, 09:35:42 pm
The information received :

$s_1 \frac{dh_1}{dt}=q_1 -\alpha_1 \sqrt{h_1-h_2}$

$s_2 \frac{dh_2}{dt}=\alpha_1 \sqrt{h_1-h_2}-\alpha_2\sqrt{h_2}$

You did provide me information about:
$\alpha_1=0.0000208, s1=0.002025m^2, 0.0000163, s2=0.002025m^2$

However, you did not provide range for $q_1, h_1,h_2$ and maximum height for both tank.



Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 17, 2010, 11:07:38 pm
Thanks a lot for these solution.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 18, 2010, 03:04:51 pm
Please, if it possible, could you modify this project to change open loop system to close loop system with simple PID controller ?
And one more task :) is possible modify system to turn off automaticly inflow when liquid levels of tank1 and tank 2 get maximum range ?
Maximum range both of tanks set to 0,14


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 18, 2010, 05:18:30 pm
Please explain in detail what it mean to be a close loop with simple PID controller?
It will be easier for me to design the simulation if you can provide me detail information as possible.
You can add picture as attached file.

I will try to modify it when I have more information.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 18, 2010, 05:47:01 pm
I will send you more informations about PID controller.

Please, could you modify system as I write in next two tasks ??

1.is possible modify system to turn off automaticly inflow when liquid levels of tank1 and tank 2 get maximum range ?
2.Please set maximum range both of tanks set to 0,14 and please, reconfigure range of visualization to better see line of h1 . it is too high :)


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 18, 2010, 05:57:08 pm
I can modify it according to your request.
However, you never give me information about the height , and q1 for the system.
The default value are the best I can guest.
It will  be better if you give me detail information about your system.
Height and range of possible q1 values.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 18, 2010, 06:24:15 pm
O.k. I try to discribe Controlled close loop system . I set in input value box some value of level h2 and by heigh of level h2 I can control value of inflow. h2 is in feedback to inflow. Is this clearle to you ????


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 18, 2010, 08:36:12 pm
I do not understand what you just described???

Quote
2.Please set maximum range both of tanks set to 0,14 and please, reconfigure range of visualization to better see line of h1 . it is too high
You said that h1 is too high. Would you please provide a suitable value for h1?
And please provide me a suitable value for maximum height!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 18, 2010, 08:40:02 pm
Meaning too high i think not value of h1 but value of plot window where is shown h1. This plot window i would like to see larger :)

And please, set the maximum value of h1 on 0,14 and maximum of h2 also on 0,14.

Just another question for you..Do you have any experience with cooperating EJS and MATLAB ??


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 18, 2010, 11:29:52 pm
Quote

Meaning too high i think not value of h1 but value of plot window where is shown h1. This plot window i would like to see larger Smiley
I did not changed it because I do not know how much larger you need. ??? ???
I can not guest what you want in your mind.  ??? Please describe it in detail.
However, I did change the way it was displayed (scale).

Quote
And please, set the maximum value of h1 on 0,14 and maximum of h2 also on 0,14.
I just modified the code so that q1 will be turn off when h1>0.140
And q1 will be tuen on when h1
Quote
Just another question for you..Do you have any experience with cooperating EJS and MATLAB ??
I do not have MATLAB so I have never use that feature.
However, it is only available for EJS version 3.47 or earlier.
I have heard that some users from swissland did use MATLAB with EJS for their research work.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 19, 2010, 12:00:43 am
Thanks for your very good work :) Dont have by the way any contact on swissland studnets ??


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 19, 2010, 01:19:48 pm
Sorry! I do not know.
You might want to check out http://www.um.es/fem/Download/Ejs/EjsAndMatlab.pdf


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 19, 2010, 01:24:57 pm
Hello :)
Please, I have big appeal on you. If it possible, could you write this hydro system in EJS version 3.4 especialy for me ??? But I need one version of system at EJS able to communicate with MATLAB. And as you wrote to me, EJS 4.2 have not this option.
THANKS A LOT !!!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 19, 2010, 01:37:09 pm
Because you have to write code to connect to MATLAB with EJS.
So you need to learn to use EJS.

I would suggest you install latest version of EJS, download the above jar file and double click to run it in your computer.
Right click and select open ejs model to open EJS and learn how it was created.
And you can do similar thing with EJS 3.4 or earlier EJS version (which support MATHLAB).

I do not have any experience with EJS connect to MATHLAB, so you should learn EJS in order to do it.
And you can use the version I created as an example to learn it.
I will try to help when you learn to use EJS. But I would not be able to help when EJS need to communicate with MATHLAB. So you better learn to create it with EJS 3.4 by yourself. I think this is the best for you to do it by yourself.  ;D


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 19, 2010, 01:43:34 pm
Of course :) I tried do this yesterday, but for i have problem with creating both of tanks and inflow at EJS old version. I have EJS 4.2 as new version and EJS 3.4 as old version. And i tried to do this yesterday at EJS 3.4. But in this version is not options like in 4.2 version for building polygon and other model parts :( Therefore i appeal you for help. Ploting is o.k. This part of project I built in old version without problems. But with creating tanks i have problem :(


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 19, 2010, 02:07:51 pm
I do not have EJS 3.4 but I do have EJS3.45
The latest version which support mathlab/simulink is EJS 3.47

The tank created in the above simulations was using polygon element.
The height h1/h2 was change by changing y coordinate for 4 points belongs to polygon.
You should be able to do it with EJS 3.45 and above.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 19, 2010, 02:16:57 pm
...EJS 3.45 is also o.k :) could you make in this version ??? thank you so much !!!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 19, 2010, 02:45:21 pm
I think you should learn how to use it if you really want to connect to MathLAB.
Please upload what you have done with EJS (xml file) and I will try to help you.




Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 19, 2010, 02:47:28 pm
O.K. I will upload my xml file couple of hours later because now I am at work and on this project i work at home.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 20, 2010, 02:36:54 am
Hello...I found simple example on PI controller of level tank...I attach you a xml file..If it possible just like that use it for my model , please add similiar PI controller to my model..Thanks !


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 20, 2010, 09:22:03 am
 You did a nice job with the EJS view. I am impressed.
 I move two tab pages in evolution to constrain page.

Normally, we only put relations which will changed with time in evolution page.
like the rate equation. And the solver will use suitable to calculate the best value for next time step.
I also change the solver from midpoint method to Runge-Kutta 4th order method.
You should use this one for most of the simulation. Midpoint method is only good for constant acceleration or similar relations. It is not good for other cases (numerical error will accumulate).

I also change code so that the "play" button will toggle between "play" and "pause".

You sould be albe to create a two level system from this one.

Add one more equation in evolution page and rearrange GUI elements to model two level tanks!
Good job! Keep going!  :D


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 20, 2010, 01:34:14 pm
No no :( This is not my job...I found this model at directory _examples in EJS install directory...I am not good enough in EJS :( I am very beginer...So could you change your two tanks model by this one tank model, please ??? Thanks a lot !! 


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 20, 2010, 03:10:45 pm
I can do it easily. However, I am not going to do it. Because it should be your job. (It is not my job).

If you are a beginer, then you should try to do it by yourself. And I will try to help.
I will feel sorry if I did the homework for you.  

Adding a view element is not difficult. Just select an element(click it) from right hand side element list,
then click it inside the drawingPanel. Then assign proper value to it's property (coordinate...etc)
Please check out EJS tutorial (How to create simulation with EJS) (http://www.phy.ntnu.edu.tw/ntnujava/index.php?board=34.0) (there are step by step examples).
or check out  SWF movie show step by step instructions to create java simulation with EJS. (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=656.0)

I will try to help if you try to lean to use it. Otherwise, there is no way you can learn to use it to communicate with MATHLAB. If you learn to do it by yourself, then you can do it for other problems, too! That is the way student learn and gain ability. I should not do all the work for you.

Do you feel if fair, if I did all the work for your classmate and he get better grade because someone did all the homework for him? (Actually, for long time effect, the classmate will be loss in the job market, because he did not learn the require ability).

I promise to help if you try to learn it. ;) However, I should not do all the work for you. otherwise, you would learn nothing. >:(

Try to modified from the above examples and you will find it is not really so difficult as you thought.
If you do find problem, write it down and attached the xml file and I will try to help.
This is the best I can do! O.K!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 20, 2010, 03:15:45 pm
Thanks a lot !!!! :) I will try :) Have a nice day :)


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on March 21, 2010, 03:18:57 am
I attach my xml file which I created at EJS 3.47. Please check it because it is not exactly as in your model created at EJS 4.2. I dont know how set to fill tank with blue color and another options. Thanks.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on March 21, 2010, 09:27:05 am
Those two polygons did not show up because you did not set "number of points"
It was different from current, which you need to set it.
The current version use all the number of elements from x,y array.

I also remove marker property, unless you really want those markers.
Please check out the version I have moified.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 16, 2010, 04:09:17 am
Hi,
I am a french student and I think I am doing the same project as you. But I am blocked I don't how to link the view and the equations... Could you help me please ?
Here is my work...


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 16, 2010, 06:24:16 pm
I do not know what you really want? How can I help?

Please explain in detail what you really want to do? How you did it! and where it went wrong?
So I can check out the part which it was not working and try to find a solution for you.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 16, 2010, 06:57:44 pm
I need to make a representation of two tanks, show how that works with EJS. But I have some errors at the end and I don't understand why that didn't works. When I play the simulation, Nothing change and I don't know why. I found some errors in my precedent works so I send you the new.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 17, 2010, 10:10:02 am
The problems I have found so far:
1. You did not provide initial value for H1 (in the Variables page). How can the EJS know what is the initial condition for H1?
2. Qi was not assigned with an initial value, either.

Computer can do what you tell it to do, but computer can not guess what you want to do (it is dangenous).
Unless there are some rule provided.



Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 18, 2010, 11:23:42 pm
I already changed that but I can show you because I am not in my workplace. If you want I send you tomorrow my work. Thanks for everything, that help me so much.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 19, 2010, 09:40:48 pm
Hi,
I send you my work.
I just want that my representation do the same things than yours, when I increase Qi, the speed increase, and when we arrived on the max, the system stop. But I don't know what I should take in the variables to do that. Could you help me please ?


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 19, 2010, 09:43:31 pm
Sorry, I forgot to give you my work  ;D


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 20, 2010, 12:40:56 am
Hi,
I send you my work.
I just want that my representation do the same things than yours, when I increase Qi, the speed increase, and when we arrived on the max, the system stop. But I don't know what I should take in the variables to do that. Could you help me please ?

I do not know what do you mean by "do the same things than yours"???
the speed increase :the speed of what ???
arrived on the max: what reach maximum???

Would you explain what you want to do in detail? I do not know how to help if I can not understand what you want. ???


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 20, 2010, 03:57:54 am
When I say when the speed increased, I just want to say that when you increased Qi, H1 and H2 increased faster, like the representation that you did on this topic for the other man !
For the max, I speak about the height maximum of H1 which is 36cm.
My problem is that I don't understand why my representation doesn't want to work. When I play the simulation, that doesn't work like I want (like yours simulation), and I don't understand why ???


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 20, 2010, 11:06:22 am
You GUI in the EJS is so complicated that I do not really understand it.
I saw the whole system is expanding when I run it.
I do not know what is going on.

You should re-assign those property value if it's background is not white.

You did not provide detail information about your system, size/shape ...
The GUI you have is not the same as the one I have created.
I do not know how it should look like. There is no way I can help if I do not know what it should be look like.
Sorry!


PS:
You do not need to add a new tube element for each segment,
if you define
px={0,0,0.5}
py={0.,0.5,0.5}
in variable tabs.

and assign px to Pos X and py to Pos Y for tube element, you will create two connected tube.
You can add more if you define px,py with more dimensions .

Why there are so many arrows in the GUI, you should be able to use a polygon to draw all connected segments.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 20, 2010, 08:55:23 pm
Hi,
Sorry but I don't know how to use really good EJS and so I don't know how to use polygone and how to reduce my number of tubes.
I told you that my GUI is like yours because I think it is. If you took yours, I just connected the out to the in. We don't care about the third reserve of water. It's just to better understand how works the project in real.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 20, 2010, 10:39:04 pm
The original simulation was created due to request from pavwell (http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=profile;u=42639)

I did check out your code. You said you want connect the output back to the input.
But I did not find such relation in your ejs model. I really do understand what you want in detail.

I can creat another one for you if you can provide me : at least a diagram with all dimension of the system
and all the related equations/ constrains.
There is no way that I can create a simulation without know detail information of the system to be simulated.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 21, 2010, 09:09:21 pm
But you have already this. There are in my work all the variables. And the equations related are here too. But I can't just take your work because I have some problems to understand what you did with the work for pavwell. I need to understand all because after will do a presentation of my work.
I give you all here.

(Qi-Cd1*alpha1*Math.sqrt(2*g*(H1-H2)))/A1=dH1/dt

(Cd1*alpha1*Math.sqrt(2*g*(H1-H2))-Cd2*alpha2*Math.sqrt(2*g*H2))/A2=dH2/dt

H1 max = 36cm
H2 max = 36cm

A1 = 256 cm2
A2 = 256 cm2

Cd1 = 0.15
Cd2 = 0.15

Alpha1 = 0.0008
Alpha2 = 0.0008

Could you do this representation with a 3.47 of EJS please.
Thank you ever so mutch.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 21, 2010, 09:34:00 pm
Hi,
Sorry but I don't know how to use really good EJS and so I don't know how to use polygone and how to reduce my number of tubes.
I told you that my GUI is like yours because I think it is. If you took yours, I just connected the out to the in. We don't care about the third reserve of water. It's just to better understand how works the project in real.

It seems that the only differences are dimension of the tube... etc.
Those two equations are the same form.
It seems that what you need is just change the value of variables in the original version.

Why the equations are the same if the output is connected to the input?
I believe the above equations should be modified if the output is connected to the input (a feedback loop).
That is the part which I do not understood!
Do you need the height as function of time graph h(t)?


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 22, 2010, 09:21:06 pm
Yes please,
I need another thing. I need to could move tree flows, the first Qi, the enter, the second, to pass from the first to the second tank, and the third, to empty the second tank...
Sorry my teacher just told me that this morning.
But I think I don't need to change the level of the tanks...
Thanks


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 22, 2010, 09:31:58 pm
You did not answer the information I need:
Quote
Why the equations are the same if the output is connected to the input?
I believe the above equations should be modified if the output is connected to the input (a feedback loop).
That is the part which I do not understood!

And I do not understand what you said:
Quote
need another thing. I need to could move tree flows, the first Qi, the enter, the second, to pass from the first to the second tank, and the third, to empty the second tank...

I need to could move tree flows ??? ??? ???, the first Qi, the enter???
to pass from the first to the second tank ??? ??? ???
to empty the second tank ??? ??? ??? Do you mean a control to empty the second tank? ???




Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 23, 2010, 03:44:20 am
Don't care about the equations, their good I'm sure. There is a third tank of water which is here to fill the first tank and to take the water from the second tank. So it's like your representation. It's independant.

For the next, in your representation, you could change the number of q1 with a bar. q1 represents the enter flux in the first tank. I just want the same thing but not only on the first tank, but on the second too. That mean tree bar like yours. The first exactly like q1, the second to increase or decrease the flux between the first tank and the second and the third to increase or decrease the flux to empty the second tank. The flux is representing by valves like on my representation, if you open more the valve, the flux increase and if you shut more the valve, the flux decrease.

I'm sorry if it was not clear before. I hope that is better now.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 23, 2010, 09:44:13 am
I did some work for you.

1. You did not set the boundary of drawingPanel properly.
 I changed it to x: -1 t0 1 and y:0 to 2
2. There is something wrong with your code
Code:
if ( H1 >= H1max ) Qi = 0 ;
else if (Qi==0&& H1< 0.2)Qi=Qis;

It seems to work now. However, you should change variable values to fit with your case.

You use 12 arrows to represent pipes. It will be better if can use tube elements.

The 3.47 xml file is attached.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 23, 2010, 10:16:34 pm
Thanks ever so much... I think I have finished.
A final thing, I want to do like you in your first representation for pavwel. When H1 is on the max, Q1 stop and the tube of water disapear from the representation. I searched but I didn't found how do that. Could you explain me please ?


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 24, 2010, 10:06:29 am
There is a "Visible" property for all the EJS GUI elements.

You can define a variable (e.g. show) and assign either "true" or "false" under different condition in your code to make the element visible or hidden.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: maxxb on April 28, 2010, 03:34:55 am
I found easier, you just need to write contraint directly in the Visible of the elements and that works. Thank you ever so much. My project is finish.


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on April 28, 2010, 10:59:49 am
Yes. You can add java statement which return "true/false" value in the Visible property field.
I hope EJS(Easy Java Simulation) really help you create simulation you need easily. :-)


Title: Re: Hydrosystem with two tanks connected one after another
Post by: pavwell on May 10, 2010, 03:10:04 pm
Hello my friend
You helped me a few weeks ago with my two tanks system. I tried to add to this project control of hight of level H2. I added some new parameters and i modified eqautions. Please, could you review my EJS application and help me with this :

Please, could you help me witih adding 2D Drawables element which is valve for control over a fllow. This element will be with cooperation with high of level of TANK H2. On the bottom of my application pannel it could be new elementy with setting of H2 level. And then valve for control over the flow will be controling inflow so level of H2 tank will be stable.

Thanks a lot for helping me !!


Title: Re: Hydrosystem with two tanks connected one after another
Post by: arafat0850 on July 06, 2011, 07:53:41 pm
thanks for your innovative solution.I want to do like you in your first representation for pavwel. When H1 is on the max, Q1 stop and the tube of water disapear from the representation. I searched but I didn't found how do that. Could you explain me please ?-*-  


Title: Re: Hydrosystem with two tanks connected one after another
Post by: Fu-Kwun Hwang on July 08, 2011, 04:38:51 pm
I do not understand what is your question.
Could you explain it in more detail?


Title: Re: Hydrosystem with two tanks connected one after another
Post by: fennyq on August 23, 2011, 08:43:12 pm
i aslo need these info,many thanks


Title: Re: Hydrosystem with two tanks connected one after another
Post by: perezpau1 on September 07, 2011, 02:02:01 am
Furthermore, i take away gun residence, if you don't want people guns.
Just sign up for your variation I've moified.