# Wave equation PDE with changing boundary condition [closed]

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)]


## closed as off-topic by Yves Klett, MarcoB, user9660, m_goldberg, JensJun 16 '16 at 18:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Yves Klett, MarcoB, Community, Jens
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome! If possible, please add Mathematica code to set up your problem. Formatting help can be found here: mathematica.stackexchange.com/editing-help – Yves Klett May 24 '16 at 7:34
• Have a look Second-Order PDEs – user9660 May 24 '16 at 14:30
• 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 0: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 2:39