Adding New View Variables To the SWMM 5 Delphi and C Code
Subject: Adding New View Variables To SWMM 5 for Villemonte Correction for Downstream Submergence. A simple seven step procedure to modify the SWMM 5 GUI Delphi Code and the SWMM 5 C code.
Step 1: Add a new View Variable to the SWMM 5 GUI Delphi code UGLOBAL.PAS
You need to add a new variable name (LINKVILLEMONTE) and increase the index number of LINKVIEWS
LINKVILLEMONTE = 48; //Output // (5.0.022 - RED)
LINKQUAL = 49; //Output // (5.0.022 - RED)
LINKVIEWS = 48; //Max. display variable index // (5.0.022 - RED)
Step 2: Add a new BaseLinkUnits description to the SWMM 5 GUI Delphi code UGLOBAL.PAS
('',''), // Villemonte Correction // (5.0.022 - RED)
('mg/L','mg/L')); // Quality
Step 3: Add a new Link View Variable SourceIndex description to the SWMM 5 GUI Delphi code Viewvars.txt
(Name: 'Villemonte Correction';
SourceIndex: 43;
DefIntervals: (25,50,75,100)),
(Name:'Quality';
SourceIndex: 44;
DefIntervals:(0.25,0.5,0.75,1.0))
);
Step 4: Add a new Link View Variable LINK_VILLEMONTE to the SWMM 5 C code in enums.h
You also need to increase the number of Link Results in enums.h for the increased number of view variables
#define MAX_LINK_RESULTS 45 // (5.0.022 - RED)
LINK_VILLEMONTE, // Villemonte Correction // (5.0.022 - RED)
LINK_QUAL}; // concentration of each pollutant
Step 5: Add a new variable to objects.h for the structure Tlink to remember the Villemonte correction at each iteration for each Weir and Orifice
double Villemonte; //(5.0.022 - RED)
} TLink;
Step 6: In the SWMM 5 LINK.C code in procedure weir_getInflow save the current iteration value of the Villemonte correction to the new structure variable
// --- apply Villemonte eqn. to correct for submergence
Link[j].Villemonte = 1.0; //(5.0.022 - RED)
Link[j].head = head; //(5.0.022 - RED)
if ( h2 > hcrest )
{
ratio = (h2 - hcrest) / (h1 - hcrest);
q1 *= pow( (1.0 - pow(ratio, weirPower[Weir[k].type])), 0.385);
if ( q2 > 0.0 )
q2 *= pow( (1.0 - pow(ratio, weirPower[VNOTCH_WEIR])), 0.385);
Link[j].Villemonte = pow( (1.0 - pow(ratio, weirPower[Weir[k].type])), 0.385); //(5.0.022 - RED)
}
Step 7: Save the value of the saved Villemonte correction in LINK.C in the procedure link_getResults so it can be read and seen in the Delphi interface
x[LINK_VILLEMONTE] = (float)Link[j].Villemonte; // (5.0.022 - RED)
Comments
Post a Comment