This notebook shows a method to validate culverts in swmm/xpswmm models using the HY8 results, I will explore more on the theory side in another post, here I am just focusing on the tooling and procedures.
HY-8 Culvert Hydraulic Analysis Program can calculate culvert performance curves uisng the FWHA HDS5 methods. An example is shown below.
I write a few scripts in this notebook to automate the process of comparing the modeling results to the HY8 results.
Major steps are,
Setting up a culvert model in HY8 is farily straight forward.
The model is saved to : ./data/hy8/hds5_example.hy8
A swmm5 model is created:
Model: ./data/swmm5/dg131.inphds5_example2.inp
Import the xpx file into XPSWMM and run the model
Model:./data/xpswmm/dg131.xpx
Export the node stage and link flow to a csv file.
The results are saved in : ./data/xpsmm/dg131.csv
I used the following scripts to,
import os
import pandas as pd
import matplotlib.pyplot as plt
import sys
lib_path = r'C:\Users\Mel.Meng\Documents\GitHub\SewerAnalysis\source'
if lib_path not in sys.path:
sys.path.append(lib_path)
sys.path
import swmm_tools as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
def compare_performance_curve(hy8_curve_csv, swmm5_out, xpswmm_csv):
df = pd.read_csv(hy8_curve_csv)
df_swmm = st.extract_node(swmm5_out, '4')
df_xp = pd.read_csv(xpswmm_csv)
ax = df.plot(x='q', y='inlet', label='Inlet', style='x-', figsize=(10,10))
ax = df.plot(x='q', y='outlet', label='Outlet', style='.-', ax=ax)
ax = df_swmm.plot(x='total_flow', y='depth', label='SWMM5', style='o-', ax=ax)
ax.fill_between(df_swmm['total_flow'], df_swmm['depth']*0.9, df_swmm['depth']*1.1, alpha=0.2)
ax = df_xp.plot(x='q', y='xpswmm', label='XPSWMM', style='o-', ax=ax)
plt.xlabel('Discharge(cfs)')
plt.ylabel('Headwater(ft)')
plt.title('SWMM5 culvert vs HY8')
plt.grid(True)
plt.show()
You need to update the path to each file in the code block below. Run it and it will plot the results.
ws = r'C:\Users\Mel.Meng\Documents\GitHub\SewerAnalysis\references\culvert\data'
swmm5_out = os.path.join(ws, 'swmm5/dg131.out')
hy8_curve_csv = os.path.join(ws, 'hy8/dg131_performance_curve.csv')
xpswmm_csv = os.path.join(ws, 'xpswmm/dg131.csv')
compare_performance_curve(hy8_curve_csv, swmm5_out, xpswmm_csv)
4
The comparison is shown above,
The conclusions,
For design purposes, the results look pretty good for the region around 200 cfs.
In the next post, I'll see how things will work out if it is an outlet control condition.