Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LIT301 basic dynamics #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/swat-s1/physical_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

from minicps.devices import Tank

from utils import PUMP_FLOWRATE_IN, PUMP_FLOWRATE_OUT
from utils import PUMP_FLOWRATE_IN, PUMP_FLOWRATE_OUT, TANK2_INFLOW, TANK2_OUTFLOW
from utils import TANK_HEIGHT, TANK_SECTION, TANK_DIAMETER
from utils import LIT_101_M, RWT_INIT_LEVEL
from utils import LIT_101_M, RWT_INIT_LEVEL, LIT_301_M
from utils import STATE, PP_PERIOD_SEC, PP_PERIOD_HOURS, PP_SAMPLES
import pandas as pd

Expand All @@ -39,6 +39,7 @@ def pre_loop(self):
self.set(MV101, 1)
self.set(P101, 0)
self.level = self.set(LIT101, 0.800)
self.level2 = self.set(LIT301,0.850)
# SPHINX_SWAT_TUTORIAL STATE INIT)

# test underflow
Expand All @@ -55,6 +56,7 @@ def main_loop(self):
while(count <= PP_SAMPLES):

new_level = self.level
tank2_level = self.level2

# compute water volume
water_volume = self.section * new_level
Expand All @@ -76,7 +78,9 @@ def main_loop(self):
outflow = PUMP_FLOWRATE_OUT * PP_PERIOD_HOURS
# print("DEBUG RawWaterTank outflow: ", outflow)
water_volume -= outflow
tank2_level += TANK2_INFLOW
else:
tank2_level -= TANK2_OUTFLOW
self.set(FIT201, 0.00)

# compute new water_level
Expand All @@ -90,11 +94,16 @@ def main_loop(self):
print("DEBUG new_level: %.5f \t delta: %.5f" % (
new_level, new_level - self.level))
self.level = self.set(LIT101, new_level)
self.level2 = self.set(LIT301, tank2_level)

# 988 sec starting from 0.500 m
if new_level >= LIT_101_M['HH']:
print('DEBUG RawWaterTank above HH count: ', count)
break

if tank2_level >= LIT_301_M['HH']:
print('DEBUG WaterTank2 above HH count: ', count)
break

# 367 sec starting from 0.500 m
elif new_level <= LIT_101_M['LL']:
Expand Down
2 changes: 2 additions & 0 deletions examples/swat-s1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
TANK_SECTION = 1.5 # m^2
PUMP_FLOWRATE_IN = 2.55 # m^3/h spec say btw 2.2 and 2.4
PUMP_FLOWRATE_OUT = 2.45 # m^3/h spec say btw 2.2 and 2.4
TANK2_INFLOW = 0.45/1000 # Simplification from Hybrid model
TANK2_OUTFLOW = 0.15/1000

# periods in msec
# R/W = Read or Write
Expand Down