OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
link.c File Reference

Legacy link configuration and hydraulic property calculations. More...

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "headers.h"
#include "inlet.h"
Include dependency graph for link.c:

Macros

#define _CRT_SECURE_NO_DEPRECATE
 

Functions

int link_readParams (int j, int type, int k, char *tok[], int ntoks)
 Reads parameters for a specific type of link from a tokenized line of input data.
 
int link_readXsectParams (char *tok[], int ntoks)
 Reads a link's cross section parameters from a tokenized line of input data. Formats: Link Shape Geom1 Geom2 Geom3 Geom4 (Barrels Culvert) Link IRREGULAR TransectID Link STREET StreetID.
 
int link_readLossParams (char *tok[], int ntoks)
 Reads local loss parameters for a link from a tokenized line of input data. Format: LinkID cInlet cOutlet cAvg FlapGate(YES/NO) SeepRate.
 
void link_validate (int j)
 Validates a link's properties.
 
void link_initState (int j)
 Initializes a link's state variables at start of simulation.
 
double link_getInflow (int j)
 Finds total flow entering a link during current time step.
 
void link_setOldHydState (int j)
 Replaces link's old hydraulic state values with current ones.
 
void link_setOldQualState (int j)
 Replaces link's old water quality state values with current ones.
 
void link_setTargetSetting (int j)
 Updates a link's target setting.
 
void link_setSetting (int j, double tstep)
 Updates a link's setting as a result of a control action.
 
int link_setFlapGate (int j, int n1, int n2, double q)
 Based on the sign of the flow, determines if a flap gate associated with the link should close or not.
 
void link_getResults (int j, double f, float x[])
 Retrieves time-weighted average of old and new results for a link.
 
void link_setOutfallDepth (int j)
 Sets depth at outfall node connected to link j.
 
double link_getYcrit (int j, double q)
 Computes critical depth for given flow rate.
 
double link_getYnorm (int j, double q)
 Computes normal depth for given flow rate.
 
double link_getLength (int j)
 Finds true length of a link.
 
double link_getVelocity (int j, double flow, double depth)
 Finds flow velocity given flow and depth.
 
double link_getFroude (int j, double v, double y)
 Computes Froude Number for given velocity and flow depth.
 
double link_getPower (int j)
 Computes power consumed by head loss (or head gain) of water flowing through a link.
 
double link_getLossRate (int j, int routeModel, double q, double tstep)
 Computes rate at which flow volume is lost in a link due to evaporation and seepage.
 
char link_getFullState (double a1, double a2, double aFull)
 Determines if a link is upstream, downstream or completely full.
 

Detailed Description

Legacy link configuration and hydraulic property calculations.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com (OpenSWMM maintenance and extensions)
License
Apache-2.0 for OpenSWMM contributions; original EPA SWMM provenance is retained.

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

Function Documentation

◆ link_getFroude()

double link_getFroude ( int j,
double v,
double y )

Computes Froude Number for given velocity and flow depth.

Parameters
[in]jLink index.
[in]vFlow velocity (fps).
[in]yFlow depth (ft).
Returns
Froude Number.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_getFullState()

char link_getFullState ( double a1,
double a2,
double aFull )

Determines if a link is upstream, downstream or completely full.

Parameters
[in]a1Upstream link area (ft2).
[in]a2Downstream link area (ft2).
[in]aFullArea of full conduit.
Returns
Fullness state of a link.
Here is the caller graph for this function:

◆ link_getInflow()

double link_getInflow ( int j)

Finds total flow entering a link during current time step.

Parameters
[in]jLink index.
Returns
Link flow rate (cfs).
Here is the call graph for this function:

◆ link_getLength()

double link_getLength ( int j)

Finds true length of a link.

Parameters
[in]jLink index.
Returns
Length (ft).
Here is the caller graph for this function:

◆ link_getLossRate()

double link_getLossRate ( int j,
int routeModel,
double q,
double tstep )

Computes rate at which flow volume is lost in a link due to evaporation and seepage.

Parameters
[in]jLink index.
[in]routeModelFlow routing model type.
[in]qFlow rate (ft3/sec).
[in]tstepTime step (sec).
Returns
Uniform loss rate in link (ft3/sec).
Here is the caller graph for this function:

◆ link_getPower()

double link_getPower ( int j)

Computes power consumed by head loss (or head gain) of water flowing through a link.

Parameters
[in]jLink index.
Returns
Power consumed by link in kwatts.

◆ link_getResults()

void link_getResults ( int j,
double f,
float x[] )

Retrieves time-weighted average of old and new results for a link.

Parameters
[in]jLink index.
[in]fTime weighting factor.
[out]xArray of weighted results.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_getVelocity()

double link_getVelocity ( int j,
double flow,
double depth )

Finds flow velocity given flow and depth.

Parameters
[in]jLink index.
[in]flowLink flow rate (cfs).
[in]depthLink flow depth (ft).
Returns
Flow velocity (fps).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_getYcrit()

double link_getYcrit ( int j,
double q )

Computes critical depth for given flow rate.

Parameters
[in]jLink index.
[in]qLink flow rate (cfs).
Returns
Critical depth (ft).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_getYnorm()

double link_getYnorm ( int j,
double q )

Computes normal depth for given flow rate.

Parameters
[in]jLink index.
[in]qLink flow rate (cfs).
Returns
Normal depth (ft).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_initState()

void link_initState ( int j)

Initializes a link's state variables at start of simulation.

Parameters
[in]jLink index.
Here is the caller graph for this function:

◆ link_readLossParams()

int link_readLossParams ( char * tok[],
int ntoks )

Reads local loss parameters for a link from a tokenized line of input data. Format: LinkID cInlet cOutlet cAvg FlapGate(YES/NO) SeepRate.

Parameters
tokArray of string tokens.
[in]ntoksNumber of tokens.
Returns
An error code.
Here is the call graph for this function:

◆ link_readParams()

int link_readParams ( int j,
int type,
int k,
char * tok[],
int ntoks )

Reads parameters for a specific type of link from a tokenized line of input data.

Parameters
[in]jLink index.
[in]typeLink type code.
[in]kLink type index.
tokArray of string tokens.
[in]ntoksNumber of tokens.
Returns
An error code.

◆ link_readXsectParams()

int link_readXsectParams ( char * tok[],
int ntoks )

Reads a link's cross section parameters from a tokenized line of input data. Formats: Link Shape Geom1 Geom2 Geom3 Geom4 (Barrels Culvert) Link IRREGULAR TransectID Link STREET StreetID.

Parameters
tokArray of string tokens.
[in]ntoksNumber of tokens.
Returns
An error code.
Here is the call graph for this function:

◆ link_setFlapGate()

int link_setFlapGate ( int j,
int n1,
int n2,
double q )

Based on the sign of the flow, determines if a flap gate associated with the link should close or not.

Parameters
[in]jLink index.
[in]n1Index of node on upstream end of link.
[in]n2Index of node on downstream end of link.
[in]qSigned flow value (value and units don't matter).
Returns
TRUE if there is reverse flow through a flap gate associated with the link.
Here is the caller graph for this function:

◆ link_setOldHydState()

void link_setOldHydState ( int j)

Replaces link's old hydraulic state values with current ones.

Parameters
[in]jLink index.

◆ link_setOldQualState()

void link_setOldQualState ( int j)

Replaces link's old water quality state values with current ones.

Parameters
[in]jLink index.

◆ link_setOutfallDepth()

void link_setOutfallDepth ( int j)

Sets depth at outfall node connected to link j.

Parameters
[in]jLink index.
Here is the call graph for this function:

◆ link_setSetting()

void link_setSetting ( int j,
double tstep )

Updates a link's setting as a result of a control action.

Parameters
[in]jLink index.
[in]tstepTime step over which setting is adjusted.

◆ link_setTargetSetting()

void link_setTargetSetting ( int j)

Updates a link's target setting.

Parameters
[in]jLink index.

◆ link_validate()

void link_validate ( int j)

Validates a link's properties.

Parameters
[in]jLink index.
Here is the call graph for this function:
Here is the caller graph for this function: