1

This is my first post here, normally with mathematica I will solve out the PDE using eigen function expansion or separation of variables and then model the solution in mathematica. However this time I have a problem with a changing boundary condition. This question specificly relates to water hammer with a boundary condition that depends on the valve opening $$Q(t)=C_vSqrt\frac{dP}{ρ}$$ The partial differential equations that govern water hammer are: $$\frac{∂^2P}{∂t^2}=c^2\frac{∂^2P}{∂x^2}+k\frac{∂P}{∂x} $$ $$ B.C;P (L,t)=\frac{Q(t)^2 ρ}{C_v(t)^2} +P_2,P(0,t)=0$$ $$I.C;P_1 (0)=0$$

How do I solve for Q(t), the only equation I can think of to solve Q(t) is the valve Cv equation which I am using as the boundary condition in the first place, cant use the same equation to solve for 2 unknown variables.

I looked at this - Water Hammer - Numerically solving system of PDEs But the Pressure BC's don't depend on velocity and the velocity BC's don't depend on pressure and they should in order to satisfy the valve closure equations.

Can I use NDsolve for this in mathematica or solvepde in matlab?

τ := 4 
Subscript[Cv, max] := 20
P0 := 25
L := 31
ρ := 62 
k := 504234 
PDE := {D[P[x, t], {t, 2}] == D[P[x, t], {x, 2}] + k*D[P[x, t], x]}
BC := {P[L, t] == (Q[L, t]^2*ρ)/(-2*t + Subscript[Cv, max])^2 + 
    P0, P[x, 0] == 300}
NDSolve[{PDE, BC}, {P, Q}, {x, 0, 30}, {t, 0, 5}, 
 StartingStepSize -> τ/100 ]
Q[L, t] := sqrt[(P[L, t]*(-2*t + Subscript[Cv, max])^2)/(ρ - P0)]
Q[L, 0] == sqrt[(300*(Subscript[Cv, max])^2)/(ρ - P0)]
  • 3
    Welcome! If possible, please add Mathematica code to set up your problem. Formatting help can be found here: http://mathematica.stackexchange.com/editing-help – Yves Klett May 24 '16 at 07:34
  • How is "P_new calculated from the subsequence solution of the PDE"? – bbgodfrey May 24 '16 at 17:52
  • The initial boundary conditions could be calculated using the initial conditions but then after the first time step the new P(x,t) at x=L from the PDE would have to be used to feed the new boundary condition. This is for water hammer in a pipe with a valve that is slowly closing. I will try my hand at the ND solve and try to edit the equations using the above post. – Ron Pearson May 25 '16 at 00:38
  • Also the cv is changing with each time step until it is closed. I will have to develop a curve fit for the function and then set the time step to be 1% of travel so the time steps would change depending on total closure time so that the same function could be used regardless of the ultimate closure time. – Ron Pearson May 25 '16 at 02:39
  • I wonder if another way to do this is to do a loop and just store the loop values in an array and annimate the array? So that each column of the array contains pressures at each length segment for a given snap shot in time and then another set of pressures for the next one and so on? – Ron Pearson May 29 '16 at 09:29
  • As mentioned by @YvesKlett, please post the code text rather than a screenshot of the code. Then, a simple mistake can be found by staring at the picture is, it should be Sqrt rather than sqrt. – xzczd Jun 16 '16 at 03:01
  • Hello xzczd, I added the raw code and removed the screen shot, however I still think there is an issue with my boundary condition, there is no way for Q(t) to be solved without using its own equation to solve it which is circular logic. They have a very similar boundary condition here - http://www.lmnoeng.com/WaterHammer/WaterHammer.php – Ron Pearson Jun 16 '16 at 06:06
  • You need to add something like @xzczd in your comment or I won't get reminder. Then, to be honest, your problem statement is unclear in my view. Are you actually asking 2 separate questions? (There seem to be 2 different equation sets, and you've only coded the second set at the end of the question?) BTW, since you've mentioned water hammer, Does this post help? – xzczd Jun 16 '16 at 06:50

0 Answers0