Posts

Showing posts with the label Annotated PID Controller in SWMM5 and InfoSWMM

Annotated PID Controller in SWMM5 and InfoSWMM

Image
How does a PID controller work in  InfoSWMM  and SWMMM 5 - this also applies to H2OMap SWMM?? double getPIDSetting(struct TAction* a, double dt)   //  at each time  step find  the PID control  changes for the  current  time step dt // Input: a = an action object // dt = current time step (days) // Output: returns a new link setting // Purpose: computes a new setting for a link subject to a PID controller. // Note: a->kp = gain coefficient, // a->ki = integral time (minutes) // a->k2 = derivative time (minutes) // a->e1 = error from previous time step // a->e2 = error from two time steps ago { double e0, setting; double p, i, d, update; double tolerance = 0.0001; // --- convert time step from days to minutes dt *= 1440.0; // --- determine relative error in achieving controller set point // Or how close are we to the set point? e0 = SetPoint - ControlValue; if ( fabs(e0) > TINY ) { if ( SetPoint != 0.0 ) e0 = e0/SetPoint; // n...