connect power supply (thermo water) to water demand

Former-commit-id: 9789f2d584efd641a39138107c2bb70691499599
This commit is contained in:
Michael T. Kelbaugh
2020-03-19 15:51:44 -04:00
parent 8b2af7659c
commit 7ea44ffa79
3 changed files with 33 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
{
"type": "object",
"properties": {
"co2": {
"type": "object",
"properties":{
"data": {"type": "object"},
"granularity": {"type": "string", "value": "county"}
}
},
"thermo_water": {
"type": "object",
"properties":{
"data": {"type": "object"},
"granularity": {"type": "string", "value": "county"}
}
}
},
"required": ["co2", "thermo_water"]
}

View File

@@ -3,9 +3,9 @@
# Distributed under the terms of the MIT License.
def Water_Demand_Simulation(countypop, rates):
def Water_Demand_Simulation(countypop, rates, thermo_water):
water = {}
for i in rates:
water[i] = countypop.get(i, 0) * rates[i]
water[i] = thermo_water.get(i, 0) + countypop.get(i, 0) * rates[i]
return water

View File

@@ -24,6 +24,11 @@ class InnerWrapper(OuterWrapper):
self.rate = kwargs["rates"]
else:
logging.warning(f"incstep {self.incstep}: rates not found")
if "thermo_water" in kwargs.keys():
self.thermo_water = kwargs["thermo_water"]
else:
logging.warning(f"incstep {self.incstep}: thermo_water not found")
self.thermo_water = {}
if "2016_populations" in kwargs.keys():
self.countypop = kwargs["2016_populations"]
else:
@@ -37,7 +42,12 @@ class InnerWrapper(OuterWrapper):
elif self.incstep > 1:
logging.warning(f"incstep {self.incstep}: population not found")
demand = Water_Demand_Simulation(self.countypop, self.rate)
if "power_supply" in kwargs.keys():
self.thermo_water = kwargs["power_supply"]["thermo_water"]["data"]
elif self.incstep > 1:
logging.warning(f"incstep {self.incstep}: thermo_water not found")
demand = Water_Demand_Simulation(self.countypop, self.rate, self.thermo_water)
results = {
"water_demand": {