Showing posts with label How to add a volume variable to SWMM 5. Show all posts
Showing posts with label How to add a volume variable to SWMM 5. Show all posts

Wednesday, December 25, 2024

How to Add a Volume Variable to SWMM 5

How to Add a Volume Variable to SWMM 5

This guide explains how to add a volume variable to the DOS version of SWMM 5, enabling it to save volume data in the text output file (after recompiling the modified C code). These modifications only affect the SWMM 5 engine; they do not impact the SWMM 5 GUI or DLL.

Adding a new report variable involves a straightforward five-step process:


Step 1: Add the LINK_VOLUME Variable in enums.h

  1. Navigate to the enums.h file.
  2. Add a new variable, LINK_VOLUME, to the LinkResultType enum. Ensure this variable is added before the water quality variables.
#define MAX_LINK_RESULTS 7  // Increment this value by 1
enum LinkResultType {
    LINK_FLOW,          // Flow rate
    LINK_DEPTH,         // Flow depth
    LINK_VELOCITY,      // Flow velocity
    LINK_FROUDE,        // Froude number
    LINK_CAPACITY,      // Depth to full-depth ratio
    LINK_VOLUME,        // Current volume of the conduit (e.g., added August 2007)
    LINK_QUAL           // Concentration of each pollutant
};

Step 2: Update output_open in output.c

  1. Add the report index for LINK_VOLUME to the output_open procedure in output.c.
  2. Write the index for LINK_VOLUME to the binary output file.
k = LINK_VOLUME; 
fwrite(&k, sizeof(int), 1, Fout.file);
for (j = 0; j < nPolluts; j++) {
    // Existing pollutant index writing logic remains here
}

Step 3: Save LINK_VOLUME to the Binary Output File

  1. Open the link.c file.
  2. Locate the procedure link_get_results. Save the newVolume value from the Link structure into the binary output array.
x[LINK_CAPACITY] = (float)c;
x[LINK_VOLUME]   = (float)Link[j].newVolume;  // Save the current volume of the link

Step 4: Update report_links in report.c

  1. Modify the report_links procedure to include LINK_VOLUME in the report output.
  2. Append the new variable to the formatted output string.
fprintf(Frpt.file, "\n  %11s %8s  %9.3f %9.3f %9.3f %9.1f %9.1f",
    theDate, theTime, 
    LinkResults[LINK_FLOW], 
    LinkResults[LINK_VELOCITY], 
    LinkResults[LINK_DEPTH], 
    LinkResults[LINK_CAPACITY] * 100.0,
    LinkResults[LINK_VOLUME]  // Include volume in the output
);

Step 5: Update the Link Header in report_LinkHeader

  1. Modify the report_LinkHeader procedure in report.c to reflect the new volume variable.
  2. Add a column header for Volume to the output.
fprintf(Frpt.file,
"\n                             Flow  Velocity     Depth   Percent      Volume");

Final Steps:

  1. Recompile the SWMM 5 engine to apply these changes.
  2. Run a simulation and verify that the LINK_VOLUME data is correctly output to the text file.

Summary

By following these steps, you can seamlessly add a new volume variable to SWMM 5. This allows the model to store and report conduit volumes in the binary and text outputs, enhancing its analytical capabilities without affecting the GUI or DLL functionality. Let me know if further clarification is needed!

Tuesday, January 4, 2011

How to add a volume variable to SWMM 5

Subject:  How to add a volume variable to SWMM 5


The purpose of this email is to explain how to add another print variable to the DOS version of SWMM 5 so that it can saved in a table in the text output file (after you recompile the modified C code).  The changes have no impact on the SWMM 5 GUI or the SWMM 5 DLL engine.

It is relatively simple five step procedure:

Step 1:  Add a new variable LINK_VOLUME at the end of the link variables in enums.h This is much easier if you just add a report variable that already is part of the link or node structure in objects.h  Your only restriction is that is should be added before the water quality variables.
 // increase by 1 the value of Max  Results in enums.h 
#define MAX_LINK_RESULTS
 7    
enum LinkResultType {
      LINK_FLOW,              // flow rate
      LINK_DEPTH,             // flow depth
      LINK_VELOCITY,          // flow velocity
      LINK_FROUDE,            // Froude number
      LINK_CAPACITY,          // ratio of depth to full depth
      
LINK_VOLUME, // current volume of the conduit - august 2007
      LINK_QUAL};             // concentration of each pollutant
 
Step 2:  Add the report index for LINK_VOLUME to procedure output_open in ouput.c

k = LINK_VOLUME; 
fwrite(&k, sizeof(int), 1, Fout.file);
for (j=0; j<nPolluts; j++)


Step 3: Save the link new volume to the binary output file in procedure link_get_results in link.c.  The new volume of the link has already been saved in the already existing variable newVolume in the Link Structure.

x[LINK_CAPACITY] = (float)c;
x[
LINK_VOLUME]   = (float)Link[j].newVolume;

Step 4. Modify report.c to include the new report variable in procedure report_links

fprintf(Frpt.file, "\n  %11s %8s  %9.3f %9.3f %9.3f %9.1f %9.1f",                          theDate, theTime, LinkResults[LINK_FLOW], LinkResults[LINK_VELOCITY], LinkResults[LINK_DEPTH]  LinkResults[LINK_CAPACITY]* 100.0,
LinkResults[LINK_VOLUME]);
Step 5.  Modify procedure report_LinkHeader in report.c to show the new variable volume:

fprintf(Frpt.file,
"\n                             Flow  Velocity     Depth   Percent   
   Volume");
");
 

LinkedIn algorithm prioritizes content based on several factors for SWMM5 Enablement

 The LinkedIn algorithm prioritizes content based on several factors: 1. Initial Engagement (First Hour) Your post is shown to a small ...