USEPA / WNTR

An EPANET compatible python package to simulate and analyze water distribution networks under disaster scenarios.
Other
315 stars 183 forks source link

leak model #263

Closed uthmankareem closed 2 years ago

uthmankareem commented 2 years ago

Hello, I am running a network scenario that involves both breaks and leaks. I am testing the leak to see what the pressure * demand output will look like compared to when there is no leak. I used epanet as my simulator but did not get any difference from the two. I changed the simulator to wntr and the difference I got for a leak of 8 pipes out of over 300 was over 80% using the default setting of area = 0.05. For example, the default network gives around 10 but the leak mode output was giving around 2. I tried to play around the leak value but when I increased it, the simulation did not terminate. I believe the output is wrong but I do not know what I am not doing right yet. I will appreciate any help please. Thank you. I could share my code if needed.

uthmankareem commented 2 years ago

Hello, I resolved this a;ready. Thank you.

uthmankareem commented 2 years ago

Hello, After running the simulation, the demand for the leak nodes were zero. I also modelled pipe break by adding leak node with area of about 90% of the pipe area to ensure the pipe is drained. When I checked the demand on that node too, it was zero. Is this normal?

kaklise commented 2 years ago

Could you provide an example of your code?

uthmankareem commented 2 years ago

Thank you for your response> The code below: leak is a list of leaking pipe while break is a list of broken pipe. wn2 = wntr.network.WaterNetworkModel('MOD.inp')

wn.options.hydraulic.demand_model = 'DD' #demand-driven simulation

for pipe in leak: k = str(pipe) + 'leak_node' wn2 = wntr.morph.split_pipe(wn2, str(pipe), str(pipe)+'B', k) leak_node = wn2.get_node(k) leak_node.add_leak(wn2, area=0.0003, start_time=0, end_time=243600) for j in brk: p = str(j) + 'leak_node' wn2 = wntr.morph.split_pipe(wn2, str(j), str(j)+'B', p) leak_node = wn2.get_node(p) leak_node.add_leak(wn2, area=0.007, start_time=0, end_time=243600) x = wntr.graphics.plot_network(wn2, link_attribute=['93B','107B','159B', '163B', '188B', '193B', '202B', '243B', '262B', '290B', '295B'], node_colorbar_label='Elevation (m)') wn2.options.hydraulic.demand_model = 'PDD' #pressure-driven simulation sim1 = wntr.sim.WNTRSimulator(wn2) wn2.options.time.duration = sim_time_seconds #Simulation duration (seconds) results1 = sim1.run_sim() pressure_m_df1 = results1.node['pressure'].iloc[3] demand_df1 = results1.node['demand'].iloc[3]
denominator_df1 = demand_df1 * pressure_m_df1 denom_SSI1 = denominator_df1.values.sum() threshold = 14.0649 # 20 psi is the same as a head of about 14.06499 m pressure_above_threshold1 = wntr.metrics.query(pressure_m_df1, np.greater,threshold) pressure_above_threshold1 = pressure_above_threshold1.T pressure_below_threshold_lst1 = pressure_above_threshold1.index[pressure_above_threshold1[0] == False].tolist() sum_to_subtract_from_denom1 = denominator_df1[pressure_below_threshold_lst1].values.sum() num_SSI1 = denom_SSI1 - sum_to_subtract_from_denom1

print(pressure_below_threshold_lst1) print(num_SSI1) print(denom_SSI1) print(sum_to_subtract_from_denom1)

kaklise commented 2 years ago

It looks like you created a new junction by splitting a pipe and added a leak to that junction, which is fine. That new junction has no demand, it only has a leak. I would expect results1.node['demand'] for all junctions named *leak_node to be 0 and results1.node['leak_demand'] to have values between the start and end time of the leak.

uthmankareem commented 2 years ago

Thank you for this. I ran results1.node['leak_demand'] but it kept giving me 'leak_demand' as key error

kaklise commented 2 years ago

Are you using the WNTRSimulator? Which version of WNTR are you running?

uthmankareem commented 2 years ago

I am using wntr simulator. I thought the version 2.2 is ran automatically? How do I check the version or update it to the latest version?

dbhart commented 2 years ago

So, there is the WNTR version, which applies to the WaterNetworkModel and WNTRSimulator classes. You can find this at wntr.version

There is also the EPANET version, which applies to the EpanetSimulator class. This is, by default, EPANET2.2 assuming that the overall WNTR package is current


From: Uthman Kareem @.> Sent: Friday, May 20, 2022 12:26:48 PM To: USEPA/WNTR @.> Cc: Subscribed @.***> Subject: [EXTERNAL] Re: [USEPA/WNTR] leak model (Issue #263)

I am using wntr simulator. I thought the version 2.2 is ran automatically? How do I check the version or update it to the latest version?

— Reply to this email directly, view it on GitHubhttps://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FUSEPA%2FWNTR%2Fissues%2F263%23issuecomment-1133192808&data=05%7C01%7Cdbhart%40sandia.gov%7C46f08b120065469f792108da3a8e5239%7C7ccb5a20a303498cb0c129007381b574%7C1%7C0%7C637886680181766885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xwJO%2Fo5yqMlOh%2FRc6Vp5xNHgJSl4hJjSbXpXDw2mmCY%3D&reserved=0, or unsubscribehttps://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABKDSSK232EQIEWBOUEK7YDVK7KORANCNFSM5WGMR5MQ&data=05%7C01%7Cdbhart%40sandia.gov%7C46f08b120065469f792108da3a8e5239%7C7ccb5a20a303498cb0c129007381b574%7C1%7C0%7C637886680181766885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PVDv%2FrDMa7ETEBx8QcKJ%2Fw%2BStYX%2Bs6XUs2IXH8DYPp0%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>

kaklise commented 2 years ago

You can check the version of wntr with the following

wntr.__version__

the current release is 0.4.1.

WNTR's EpanetSimualtor can run EPANET 2.00.12 and EPANET 2.2.0, but when modeling leaks you need to use WNTR's internal hydraulic simulator WNTRSimulator.

uthmankareem commented 2 years ago

Thank you. I just checked now. The version I am using is '0.4.0' and my leak model simulator is wntr

kaklise commented 2 years ago

Are you able to access demand and leak demand results using the following example? This example adds a junction to Net1, adds a leak to that junction, and uses the WNTRSimulator.

inp_file = 'networks/Net1.inp'
wn = wntr.network.WaterNetworkModel(inp_file)

wn = wntr.morph.split_pipe(wn, '11', '11_B', '11_leak_node')
leak_node = wn.get_node('11_leak_node')
leak_node.add_leak(wn, area=0.0005, start_time=4*3600, end_time=18*3600)

sim = wntr.sim.WNTRSimulator(wn)
results = sim.run_sim()

leak_demand = results.node['leak_demand']
leak_demand.plot()

demand = results.node['demand']
demand.plot()
uthmankareem commented 2 years ago

Thank you for this. I was able to run this ad it worked. So there must be a bug with the earlier code I wrote because it eventually worked with the later code I wrote.

kaklise commented 2 years ago

Great! Glad that worked.