/* ** tanks.eu : A program to solve the Tank leackage problem ** Assumptions: inner_tank has a leaking point higher than the outer ** tank overflow level ** ** To solve user query ** ?- solve_problem(H,Hi,Sl,Ri,Ro,Ho,G,DVi,Hfi,Hfo). ** Or just ** ?- solve_problem. ** ** Needs cleaning up ** ** Copyright (C) 1995 K J Dryllerakis - ALL RIGHTS RESERVED ** ** $Id: tanks.eu,v 1.3 1995/03/24 15:43:29 kd Exp kd $ */ /* ** inner_tank(?[Leakage_Height,Leackage_Surface,LiqHeight,Radius_of_tank], ** ?Liquid_height_function,dV/dt_out) ** If we are losing ** liquid from the tank of radius R from a leaking point of ** height Hl and surface Sl, then Hf is the height function of ** the liquid in the tank and dV/dt_out is the amount of liquid ** wasted through the leakage */ inner_tank(Hl,Sl,H,R,G,Hf,DVout):- formulae([F1,F2]), Hl < H, EndTime=(sqrt(H-Hl)*pi*R^2)/(2*sqrt(2*G)*Sl), F01=sqrt(2*G)*Sl, F02=sqrt(H-Hl)/4, F03=(Sl*sqrt(G/2))/(pi*R^2), F2 = ( F01*( F02 - F03*T2 ))//T2 , F1 = ( F02- F03*T )//T , DVout={[ cc(0,EndTime):F1, oo(EndTime,infinity):0//LL ]}, Hf={[ cc(0,EndTime):F2, oo(EndTime,infinity):(Hl)//LL ]}. /* ** outer_tank_type_A(?dV/dt_in,[?Height,?Radius,?InnerRadius],?Hf) ** if the input of liquid is dV/dt and the geometric ** characteristics are as described the height of the ** liquid in the outer vessel is given by Hf. ** */ outer_tank_type_A(DV,H,R,R0,Hf):- % reals([H,R,R0]), % functions([DV,Hf]), Hf@0=0, Hf= (1/(pi*(R^2-R0^2))) * integral(DV), continuous(Hf). /* ** outer_tank_type_B(?dV/dt_in,[?Height,?Radius,?InnerRadius],?Hf) ** if the input of liquid is dV/dt and the geometric ** characteristics are as described, the height of the ** liquid in the outer vessel is given by Hf. ** Type B has overflow problems if Hf becomes Higher than ** Height. ** */ outer_tank_type_B(DV,H,R,R0,Hf):- % reals([H,R,R0]), % functions([DV,Hf,DVout]), Hf@0=0, Hf@T1=H, DVout={[ cc(0,T1):0//LL, oo(T1,infinity):(DV@T)//T ]}, Hf= (1/(pi*(R^2-R0^2))) * integral(DV-DVout), continuous(Hf). /* the height is a continuous function */ /* ** solve_problem ** solve the problem and print the answer ** change the type of the outer tank accordingly ** */ solve_problem:- reals([Hl,Hi,Sl,Ri,Ro,Ho,G]), functions([DVi,Hfi,Hfo]), inner_tank(Hl,Sl,Hi,Ri,G,Hfi,DVi), outer_tank_type_A(DVi,Ho,Ro,Ri,Hfo), dump(['Hfi'=Hfi,'Hfo'=Hfo]). solve_problem(H,Hi,Sl,Ri,Ro,Ho,G,DVi,Hfi,Hfo):- reals([Hl,Hi,Sl,Ri,Ro,Ho,G]), functions([DVi,Hfi,Hfo]), inner_tank(Hl,Sl,Hi,Ri,G,Hfi,DVi), outer_tank_type_A(DVi,Ho,Ro,Ri,Hfo). /* EOF */