Tank Source for TankCar. A tank receives a flow of water given by a function FEntry(TIME) and has an outflow proportional to the Level of the tank. This is expressed in the differential equation for the Level. When the Level exceeds 3m the SendTankCar subsystem is activated. Further sending is inhibited until the TankCar completes its work. The SendTankCar subsystem sends the TankCar to Travel. When the Travel (to the place in which the Tank is) finishes the Level is lowered in a quantity corresponding to the volume of the TankCar. The TankCar is eliminated and the SendTankCar system may be activated again if Level > 3. There is an hourly Inspection that puts Alarm to TRUE when it finds the Level less than 2. Then the Recovering process begins by decreasing the rate of outflow until the Level 3.2 is reached. NETWORK Tank (C) :: Level' := KQLevel * FEntry(TIME) - KOLevel * Level; IF Alarm OR Recovering THEN KOLevel := 0.0018 ELSE KOLevel := 0.0030; IF (Level > 3.0) AND Send THEN BEGIN ACT(SendTankCar, 0); Send := FALSE END; SendTankCar (A) Travel :: CREATE(TankCar) BEGIN VTankCar := UNIF(15.3, 18.0); SENDTO(Travel); END; Inspection (A) :: Tank(0); (*Update Level*) IF Level < 2.0 THEN BEGIN Alarm := TRUE; Recovering := TRUE END; IF Level > 3.2 THEN Recovering := FALSE; ACT(Inspection, 3600); Travel (R) :: RELEASE BEGIN Level := Level - VTankCar * KQLevel; SENDTO(Exit); Send := TRUE; END; STAY := TravelTime; Exit :: Gra (A) :: IT := 15; GRAPH(0, 86900, BLACK; TIME: 6: 1, WHITE; Level: 6: 0, Alt, 0, 10, GREEN); INIT ACT(Tank, 0); ACT(Inspection, 0); ACT(Gra, 0); TSIM := 86400; TravelTime := 240; Travel := MAXREAL; DT_Tank := 1.0; Level := 2.0; KQLevel := 0.03; (* 1/M*M *) KOLevel := 0.0035; (* 1/Seg *) FEntry := 0.0, 0.4 / 14000.0, 0.6 / 27000.0, 0.3 / 52000.0, 0.2 / 86900.0, 0.4; Alarm := FALSE; Recovering := FALSE; Send := TRUE; DECL VAR KQLevel, KOLevel, TravelTime: REAL; Level: CONT; Alarm, Send, Recovering: BOOLEAN; MESSAGES TankCar(VTankCar: REAL); GFUNCTIONS FEntry POLYG (REAL): REAL: 6; STATISTICS ALLNODES; END.
TEST OF DIFFERENTIAL EQUATIONS Computed known solutions of some systems of differential equations. NETWORK C1 :: Y' := R; (*Y := SIN(T)*) X'[1] := 0.1; (*X[1] LINEAR SLOPE 0.1*) X'[2] := 0.2; (*X[1] LINEAR SLOPE 0.2*) R' := -Y; (*R := COS(T)*) X'[3] := X[1]; (*X[3] PARABOLA*) Z' := -R; (*Z := -SEN(T)*) C2 :: Z' := 0.15; (*X[1] LINEAR SLOPE 0.01*) X'[1] := -X[3]; (*X[1] COS(T)*) X'[3] := X[1]; (*X[3] -SIN(T)*) S' := Z - 2; (*X[1] PARABOLA*) Gra1(A) :: IT := 0.0625; GRAPH(0, 100, BLACK; TIME: 6: 1, WHITE; Y: 6: 2, SEN, -1, 1, RED; R: 6: 2, COS, -1, 1, GREEN; X[1]: 6: 2, Lp01, -10, 10, YELLOW; X[2]: 6: 2, Lp02, -10, 10, MAGENTA; X[3]: 6: 2, Parab1, -10, 10, LIGHTGREEN; Z: 6: 2, MSen, -2, 2, BLUE); Gra2(A) :: IT := 0.0625; GRAPH(0, 100, BLACK; TIME: 6: 1, WHITE; X[1]: 6: 2, Lp01, -10, 10, YELLOW; X[3]: 6: 2, Parab1, -10, 10, LIGHTGREEN; Z: 6: 2, MSen, -2, 2, BLUE; S: 6: 2, Parab2, -10, 10, BROWN); INIT TSIM := 100; Tc := 0; INTI Tc: 3: Tc (0 FOR C1, 1 FOR C2) ; IF Tc = 0 THEN BEGIN ACT(C1, 0); ACT(Gra1, 0) END ELSE BEGIN ACT(C2, 0); ACT(Gra2, 0) END; DT_C1 := 0.0625; DT_C2 := 0.0625; Y := 0; R := 1; X[1] := 0; X[2] := 0; X[3] := 1; Z := 0; S := 1; DECL VAR X: ARRAY[1 .. 3] OF CONT; Z, S, Y, R: CONT; Tc: INTEGER; END.