redistribute the demands

This commit is contained in:
xinzish
2024-04-12 23:59:09 +08:00
parent 330248041f
commit e8fddfb71a
3 changed files with 24 additions and 4 deletions

View File

@@ -91,3 +91,14 @@ def distribute_demand_to_nodes(name: str, demand: float, nodes: list[str], type:
def distribute_demand_to_region(name: str, demand: float, region: str, type: str = DISTRIBUTION_TYPE_ADD) -> ChangeSet:
nodes = get_nodes_in_region(name, region)
return distribute_demand_to_nodes(name, demand, nodes, type)
def get_total_base_demand(name:str,region:str)->float:
nodes = get_nodes_in_region(name, region)
t_demands=0.0
for node in nodes:
if not is_junction(name, node):
continue
ds = get_demand(name, node)['demands']
t_demands= t_demands+ds[0]['demand']
return t_demands

View File

@@ -2,6 +2,7 @@ from tjnetwork import *
from get_realValue import *
from get_hist_data import *
import datetime
from api.s36_wda_cal import *
ids=['2498','3854','3853','2510','2514','4780','4854']
@@ -54,7 +55,12 @@ def get_l_tank_leve()->float:
# test interface
if __name__ == '__main__':
if get_current_data()==True:
tQ=get_current_total_Q()
print(f"the current tQ is {tQ}\n")
data=get_hist_data(ids,conver_beingtime_to_ucttime('2024-04-10 15:05:00'),conver_beingtime_to_ucttime('2024-04-10 15:10:00'))
# if get_current_data()==True:
# tQ=get_current_total_Q()
# print(f"the current tQ is {tQ}\n")
# data=get_hist_data(ids,conver_beingtime_to_ucttime('2024-04-10 15:05:00'),conver_beingtime_to_ucttime('2024-04-10 15:10:00'))
open_project("beibeizone")
regions=get_all_service_area_ids("beibeizone")
for region in regions:
t_basedmds=api.s36_wda_cal.get_total_base_demand("beibeizone",region)
print(f"{region}:{t_basedmds}")

View File

@@ -2,4 +2,7 @@ from tjnetwork import *
from get_current_status import *
def run_simulation(cur_datetime:str=None)->str:
open_project('beibei_skeleton')
return