Sunday, January 22, 2023

SWMM 5.2.2 LID code for readSurfaceData

This code reads data for a specific LID process from a line of an input file, and assigns the data to variables in an array called "LidProcs". The data includes values for storage height, vegetation volume fraction, roughness, surface slope, and side slope. The code first checks if there are enough tokens in the input file, and then uses a loop to check if each token is a valid number and is greater than or equal to 0. If any of these conditions are not met, an error code is returned. The code then assigns the data to the appropriate variables in the LidProcs array, after converting the units and making sure that some values are set to 0 if other values meet certain conditions. The code returns 0 if there is no error.

int readSurfaceData(int j, char* toks[], int ntoks)
//  Purpose: reads surface layer data for a LID process from line of input
//           data file
//  Input:   j = LID process index 
//           toks = array of string tokens
//           ntoks = number of tokens
//  Output:  returns error code
//  Format of data is:
//  LID_ID  SURFACE  StorageHt  VegVolFrac  Roughness  SurfSlope  SideSlope
    int    i;
    double x[5];

    if ( ntoks < 7 ) return error_setInpError(ERR_ITEMS, "");
    for (i = 2; i < 7; i++)
        if ( ! getDouble(toks[i], &x[i-2]) || x[i-2] < 0.0 )
            return error_setInpError(ERR_NUMBER, toks[i]);
    if ( x[1] >= 1.0 ) return error_setInpError(ERR_NUMBER, toks[3]);           
    if ( x[0] == 0.0 ) x[1] = 0.0;

    LidProcs[j].surface.thickness     = x[0] / UCF(RAINDEPTH);
    LidProcs[j].surface.voidFrac      = 1.0 - x[1];
    LidProcs[j].surface.roughness     = x[2];
    LidProcs[j].surface.surfSlope     = x[3] / 100.0;
    LidProcs[j].surface.sideSlope     = x[4];
    return 0;

No comments:

ChatGPT Version of the SWMM5 Wikipedia Page Introduction

  The EPA Storm Water Management Model (SWMM) is a computer software that simulates the rainfall-runoff-routing process in urban areas. It o...