Here's a concise summary of how the kinwave.c
file in SWMM is structured and used:
1. Purpose of kinwave.c
kinwave.c
implements the Kinematic Wave flow-routing method for a single conduit, computing the outflow hydrograph at each time step based on the inflow at the upstream end. It solves the finite difference form of the continuity equation for unsteady, 1D flow under the assumptions of negligible inertial and pressure forces.
2. Key Routines in kinwave.c
-
kinwave_execute
- Called each time step for each conduit that is assigned Kinematic Wave routing.
- Inputs: (i) link index
j
; (ii) pointer to inflow/outflow; (iii) time steptStep
. - Outputs: updated outflow (and internally updated flow area) for the conduit.
- Main steps:
- Retrieve the subindex into the Conduit array and relevant cross-section data.
- Normalize flows/areas to dimensionless form (i.e., fraction of full flow/area).
- Form a finite-difference equation of continuity with the kinematic wave relationship, adjusting for infiltration and evaporation losses.
- Solve for the new outlet area (and thus outflow) using
solveContinuity
. - Convert flows/areas back to dimensional units and store them in the SWMM data structures.
-
solveContinuity
- Solves the continuity equation: for the outlet dimensionless area .
- Picks upper/lower bounds on so that crosses zero.
- Calls
findroot_Newton
(a general-purpose Newton-Raphson routine) fromfindroot.c
. - Returns an integer code:
- : number of function evaluations used
- : continuity equation not solved
- : flow above max. flow
- : flow below zero
-
evalContinuity
- The user-supplied function to compute (and derivative ) for
findroot_Newton
. - Combines partial derivatives of Kinematic-Wave formula with partial derivatives of cross-sectional area.
- are module-level variables assigned in
kinwave_execute
.
- The user-supplied function to compute (and derivative ) for
3. Local vs. Shared Variables
Local variables in kinwave_execute
:
q1, q2, qin
: normalized flow states at previous time steps / upstream boundarya1, a2, ain, aout
: normalized cross-section area states
Shared / Module-level variables:
Beta1
,C1
,C2
: constants in the finite difference continuity equationpXsect
: pointer to the conduit’s cross-section objectAfull
,Qfull
: full flow area and full flow rate used to normalize flows
4. Flow Path through the Code
kinwave_execute
is triggered fromflowrout_execute
(inflowrout.c
) for each conduit that uses Kinematic Wave routing.- It sets up dimensionless flows/areas, calls
solveContinuity
to find the new outlet area, and returns the final computed outflow. solveContinuity
callsfindroot_Newton
, passingevalContinuity
for function evaluation and derivative.- The root finder finds the new area .
kinwave_execute
usesa
to find outflow .- SWMM updates the link’s flow/area records.
5. Handling Losses
- A small call is made to
link_getLossRate
with the parameterKW
to handle evaporation and infiltration losses. - The returned value is then subtracted from the flow.
6. Newton-Raphson ODE Approach
- The function
evalContinuity(a, f, df, p)
returns the function and its derivative .- .
- The derivative is .
7. Practical Limitations
- The kinematic wave approach ignores dynamic wave backwater/inertial effects.
- Appropriate for mild or steep open channels with supercritical flows and no significant flooding or surcharging.
8. In Summary
kinwave.c
focuses on one main routine,kinwave_execute
, which implements Kinematic Wave routing for a single conduit.- It uses dimensionless flow/area states, a finite-difference continuity approximation, and a root-finding approach for updated area/outflow.
- The Newton function from
findroot.c
is plugged in withevalContinuity
. - This approach is simpler computationally than the full Dynamic Wave solver, suitable for many open-channel, non-backwater conditions.
No comments:
Post a Comment