Calculating Vessel Capacity in Volume and Time
Calculates the total amount of liquid remaining in a square/rectangular tank, and the amount of time it will last given the current level and outlet flow speed.
@mdl.part("Water Tank",host) def WaterTankCapacity(mod): Fill = mod.AddInput("Level",0,"Main Water Tank.Level") Speed = mod.AddInput("Speed",0,"Main Water Pump.Flow Rate") Width = mod.AddConstant("Width",5) Length = mod.AddConstant("Length",5) Height = mod.AddConstant("Effective Height",6) #The total capacity of the tank in litres MaxCapacity = mod.AddOutput("Maximum Capacity",lambda: float(Width) * float(Length) * float(Height),[Width,Length,Height]) #The total amount actually in the tank CurrentlyHolding = mod.AddOutput("Current Volume",lambda: float(MaxCapacity) * (float(Fill)/100),[Fill,MaxCapacity]) #The time remaining, given the flow mod.AddOutput("Time Remaining",lambda: float(CurrentlyHolding) / float(Speed),[CurrentlyHolding,Speed])