1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| begin ''HAMMER: Water hammer analysis
INTEGER Number!Of!Nodes;
REAL PROCEDURE Regula!Falsi(REAL X0,X1,Accuracy; REAL PROCEDURE F);
begin "Regula Falsi According to Firouztale, Spencer & Wright"
Real X2;
While (abs(f(x2)-f(x1)) geq accuracy) do
x0:=((x2:=x1)-(x1:=x0))*f(x1)/(f(x1)-f(x2))+x1;
Return(x0);
End"Regula Falsi According to Firouztale, Spencer & Wright";
REAL PROCEDURE Redlich!Kwong(REAL Pressure!Reduced, Temperature!Reduced,
Accuracy);
begin "Redlich!Kwong"
REAL h,k,z;
COMMENT : Z is Compressibility Factor, Z=PV/R/T, ie correction
factor leading to Redlich & Kwong Equation of State.
Smith & Van Ness, Introduction to Chemical
Engineering Thermodynamics;
z:=1;
While (abs(z-k) > Accuracy) do
z:=1/(1-(h:=.0867*Pressure!Reduced/Temperature!Reduced
/(k:=z)))-4.93*h*Temperature!Reduced^-1.5/(1+h);
Return(z);
END "Redlich!Kwong";
Real Procedure Bulk!Modulus (REAL Pressure, Critical!Pressure,
Temperature, Critical!Temperature,
Small!Number, R!Ideal!Constant);
begin "Bulk Modulus from Thermodynamics"
REAL Z, dZ!dP;
COMMENT : k=rho(0)*dP/d.rho, P=Z*rho*r*T,rho dP/dZ=-Z(dZ/dP)=K;
Z:=Redlich!Kwong(Pressure/Critical!Pressure,
Temperature/Critical!Temperature,
Small!Number);
dZ!dP:=(Redlich!Kwong(Pressure/Critical!Pressure
*(1+Small!Number),
Temperature/Critical!Temperature,
Small/Number)
-Redlich!Kwong(Pressure/Critical!Pressure
*(1-Small!Number),
Temperature/Critical!Temperature,
Small/Number)
)/2/Small!Number*Critical!Pressure;
RETURN(-Z/dZ!dP);
END "Bulk Modulus from Thermodynamics";
Real Procedure Speed!Of!Wave(REAL Pressure, Critical!Pressure,
Temperature, Critical!Temperature,
Small!Number, R!Ideal!Constant,
Pipe!Diameter,Pipe!Thickness,Young!Modulus,
Pipe!Poisson!Ratio;
BOOLEAN Free!Pipe, Anchored!Pipe,
Expanding!Joints);
begin "Speed of wave from thermodynamic and elastic pipe theories"
REAL Density,K,Poisson!Effect;
Density:=Pressure/R!Ideal!Constant/Temperature/
Redlich!Kwong(Pressure/Critical!Pressure,
Temperature/Critical!Temperature,
Small!Number);
K:=Bulk!Modulus( Pressure, Critical!Pressure,
Temperature, Critical!Temperature,
Small!Number,R!Ideal!Constant);
Poisson!Effect:= if Free!Pipe then (1.25-Pipe!Poisson!Ratio)
else if Anchored!Pipe then (1-Pipe!Poisson!Ratio^2)
else if Expanding!Joints then (1);
RETURN((Density*(1/K+Pipe!Diameter/Pipe!Thickness/Young!Modulus
*Poisson!Effect))^-.5);
END "Speed of wave from thermodynamic and elastic pipe theories"; |
Partager