You need to be a member of SWMM 5 or SWMM or EPASWMM - (not formally associated with EPA) to add comments!

Join SWMM 5 or SWMM or EPASWMM - (not formally associated with EPA)

You need to be a member of SWMM 5 or SWMM or EPASWMM - (not formally associated with EPA) to add comments!

Join SWMM 5 or SWMM or EPASWMM - (not formally associated with EPA)

This reply was deleted.

## Replies

Hello everybody!, I have encountered the same issue in the last year, and because of this I have developed an open source solution to replicate the SWMM algorithm in Matlab, Python, and LabVIEW easily. I have called it MatSWMM an it is available at: https://github.com/water-systems/MatSWMM

MatSWMM can be useful to model Real-time control for urban drainage systems, extract simulation results and edit systematically a system that has been created with the SWMM platform. I hope this can be useful to fullfil the requirements of the unpleasant batch simulation problems.

Please check it out, and feel free to contact me (ga.riano949@uniandes.edu.co) if any doubt or suggestion appears.

If you want to modify the code further you can alter the SWMM 5 DOS engine to bring in more parameters

Sorry, I forgot

In the DOS version of SWMM 5 you need to modify the code in SWMM5_H for swmm_step so that it passes information from VBA to the engine.

int DLLEXPORT swmm_step(double* elapsedTime, double* Total_Inflow, double* Total_Outflow,double* Total_Flood, double* System_CE, double* System_ST); //(5.0.023 - RED)

change the lengths in SWMM5.DEF

LIBRARY SWMM5.DLL

EXPORTS

swmm_close = _swmm_close@0

swmm_end = _swmm_end@0

swmm_getMassBalErr = _swmm_getMassBalErr@12

swmm_getVersion = _swmm_getVersion@0

swmm_open = _swmm_open@12

swmm_report = _swmm_report@0

swmm_run = _swmm_run@12

swmm_start = _swmm_start@4

swmm_step = _swmm_step@24

and change the code in swmm5.c

int DLLEXPORT swmm_step(DateTime* elapsedTime, double* Total_Inflow, double* Total_Outflow,double* Total_Flood, double* System_CE, double* System_ST)

Here is what it looks like for others in the future

## Parse Strings

## MATLAB Functions

## Examples and How To

int DLLEXPORT swmm_step(DateTime* elapsedTime, double* Total_Inflow, double* Total_WWF,

double* Total_Outflow,double* Initial_Storage,double* Total_Storage,

double* Total_Flooding, double* Total_Rain,

double* Total_Snow,double* Total_Snowdepth, double* BasinTemp,

double* OmegaIn,double* TSIn,

double* percent_flooded, double* percent_surcharged,

double* avg_Iter,double* avg_TS,

double* max_Iter,double* min_TS);

is a longer example

Thank you Robert. I' ll try to use what you 've stated.

Hi, I would read each line as a String and for the lines following the [SUBCATCHMENTS] section tag parse the line to extract the width and then add back your new width estimate. This will just mean you need to parse one type of SWMM 5 data line.

Here is the format of the line you want to parse

Thank you Bob for your valuable help.

Do you know some commands to read inp file in MATLAB?

I roughly wrote a code to read inp file as string using

commands below in MATLAB:

1) fileread('file name')

2) fopen('file name')

3) fgetl('file id')

but this is complex. On the other hand, I can not suitably write new widths values in text file.

Do you know What MATLAB commands I have to use to parse subcatchment section, change the width and add back to subcatchment section?

What language is Matlab written in? is it C or Java? Can Matlab call many DOS programs?

Here is a link to parsing in MATLAB

http://www.mathworks.com/help/matlab/ref/strtok.html

how to manipulate strings in MATLAB

http://www.mathworks.com/help/matlab/string-parsing.html