The Story of LOOP, BRANCH and SEWER


In 1980, I wrote a letter to Prof Daniel Okun at the University of North Carolina (UNC) at Chapel Hill expressing some of my research ideas on design of water distribution networks. Professor Okun offered me admission to the PhD program. He suggested that I work with Prof Donald Lauria.

Prof Lauria was working as a Consultant to the World Bank to develop software for looped and branched water distribution systems and sewer networks. He and his Ph D student Paul Hebert prepared codes called LOOP, BRANCH and SEWER. These computer programs were written in IBM BASIC and had to be run from a BASIC interpreter. LOOP used Hardy Cross method for “balancing” the flows and BRANCH used basic Simplex algorithm to optimize the costs of gravity fed branched networks.

Prof Donald Lauria (extreme right)

For reasons of my father’s ill health, I did not join Ph D Program at UNC at Chapel Hill. Instead, I took admission for Doctor of Engg at the Asian Institute of Technology (AIT) in Bangkok. I wanted to be closer. (This didnt help anyway. I lost my father due to a massive heart attack while I was studying. I learnt  about his passing two days later as there was a storm in the Bay of Bengal. The storm disrupted the international telephone lines for 48 hours!)

My interest on LOOP, BRANCH and SEWER however continued.  I worked with Prof H M Orth at AIT on these programs and did a publication in American Society of Civil Engineers with my colleague Wasim Rabbani on branched network optimization.

I returned to India in 1984 and started teaching at the Centre for Environmental Science and Engg at IIT Bombay. In 1986, I was invited to Bangkok by the Water and Sanitation Project (WSP) of the World Bank/UNDP, courtesy Shyamal Sarkar. Shyamal had joined the WSP on lien from the Central Public Health and Environmental Engineering Organization (CPHEEO) of the Ministry of Urban Development (MoUD). Terry Hall was the Task Manager at WSP.

Terry Hall wanted to improve LOOP, BRANCH and SEWER. He called for a workshop in Bangkok to discuss with potential developers. I met Dr Paul Hebert at the workshop. I also met Daniel del Puerto of the LUWA in the Philippines. Paul and Dan had come up by then a version of LOOP based on Turbo Pascal 5.0. The code still used Hardy Cross and had no feature of optimization.

I made propositions on how these codes could be redeveloped citing various areas of possible technical improvements. Terry liked my propositions. He asked if I could take this as a project and I was delighted to accept.  I took a 8 months break from IIT Bombay.

The World Bank offered USD 10,000 if my name was to appear on the title screens. An option was also given of USD 20,000 where the name would not be acknowledged. I chose the former option.

The project was essentially a rewrite of the old IBM BASIC codes. I chose Microsoft QuickBasic 4.5 (QB). QB had advantages of structured programming like C/Pascal, a compiler feature for speed and security and an ability to do good graphics and easy “painting” of data entry screens.

In LOOP, I decided to move to Newton-Raphson solver and add a feature of cost optimization. Original LOOP could not handle multiple reservoirs, pumps and valves and so I decided to include these important features in the new code.

At that time, the World Bank had negotiated with Prof A G Fowler of Univ of British Columbia to include his famous FORTRAN code “FLOW” in the package of tools along with LOOP, BRANCH and SEWER. I decided to embed Prof Fowler’s logic of FLOW in the new version of LOOP. It required understanding of the code in its logical sequence and not simply attempt a “translation” of the FORTRAN code into QuickBasic! This was not easy.

In 1970, Prof Fowler had published a paper called  “Efficient Code for Steady-State Flows in Networks” in the Journal of Sanitary Engg Division in the American Society of Civil Engineers.  This paper was coauthored with Robert Epp, an Undergrad. Summer Student at the  Computing Centre. The paper presented logic of FLOW. This paper is perhaps one of the best in the literature on analyses of looped water distribution networks. Its presentation is  complex to understand but most creative in terms of the logic of finding “natural set of loops” and ordering them to construct a positive and banded  Jacobian matrix as required in Newton Raphson method.

Prof A G Fowler

Mirroring FLOW in the new LOOP helped me to address the interest of handling large networks as well while guaranteeing rapid convergence in balancing. The code included multiple reservoirs, pumps and valves following procedure suggested by Jepson in 1976. I could handle networks of 1000 pipes as against 250 pipes in the old version  The next challenge was to include cost optimization.

At that time, there was a considerable research published on optimization of water distribution networks notably by Pitchai, Khanna, Swamee, Uri Shamir, Walski, Bhave and others. Amongst all these researchers, work by Professor P R Bhave of VRCE, Nagpur stood out.

I however realized that the problem of optimization of looped water distribution network was NP-Hard and perhaps a solution using heuristic could be more appropriate rather than using a classical optimization technique.

At that time, Medha Dixit (three years senior to me in my IIT undergraduate days) was researching with Prof B V Rao of Civil Engg Department at IIT Bombay. Her research used “a close form solution” for optimum pipe diameter using Non-Linear Programming. She had got pretty good results and the optimums found were close to solutions from classical optimization techniques and in some cases did even better!  I crafted Medha’s algorithm in my new LOOP with further improvements.

For BRANCH, I could make the data structure used in the Simplex better to allow handling of 125 pipes as against 50 in the old version. This required efficient handling of the arrays. SEWER was entirely re-written following heuristic optimization that I had developed with my master’s student S Venkateswarulu or Venkat. Venkat, post his Masters with me got admission at UNC at Chapel Hill and worked with Prof Don Lauria and Dale Whittington.

I needed a ardent and skilled civil engineer and a programmer par excellence to work with me for the new avatara of LOOP, BRANCH and SEWER. This was Juzer Dhondia, my Masters student from IIT. Juzer worked with me over the 8 months period, coding the programs meticulously, discovering QB’s features and embedding assembler routines that we procured from MicroHelp Inc. These assembler routines performed several “low level functions” e.g. detecting “error” if the floppy drive was open etc.

Juzer Dhondia

All the three programs once developed were thoroughly tested on networks in Pakistan (Quetta was one of the complex systems where we tested LOOP), Nepal (especially to check role of Pressure Reducing Valves in the hilly terrain) and of course in the Philippines where Del Puerto took the lead. User manuals were then written and training was conducted at several institutions in India and South Asia.

I remember Shyamal asked me why did I put Juzer Dhondia’s name on the title screen when the contract was only on my name. “You can always acknowledge him in the manual” he said. But I insisted that his name be placed prominently right next to me. And I am so glad that I did it. I was also grateful that the World Bank agreed to my request and did not bring in the bureaucracy.

The three programs were released in December 1991. It then became a hit! It was cited as one of the most used computer programs for water supply and sewerage across the World – courtesy the World Bank. By 2000, it was estimated that there were more than 5000 users across the world of these three programs.

LOOP, BRANCH and SEWER were programs that ran on the Disk Operating System (DOS). When MS Windows took over, the programs had to be run through a “DOS Shell”. That was not effective. Users wanted the Windows versions.

I did several attempts to revisit the codes and re-write them in Visual BASIC and Visual C. Two Masters students of mine at IIT Bombay (Arun Sharma and Sanjay Lathkar) did conversion to Visual C++ of LOOP and SEWER. I spent quite some money by contracting a software development company that continued building the codes with VC++. Unfortunately, these conversions could not result into a product that could be distributed. The work lacked a rigorous testing. More recently, BRANCH was rewritten in VB with several new features by programmers at AIT. Juzer also assisted. Once again, this effort too did not fructify.

Today, Dr Paul Hebert is a Visiting Professor, Centre for Leadership and Ethics in Virginia and has nothing to do with water distribution networks. Daniel Del Puerto is still with LUWA in the Philippines. Shyamal Sarkar left CPHEEO and joined the World Bank and after more than 25 years of work in the water and sanitation sector, retired. Juzer Dhoondia spent several years in the Netherlands before moving to Alabama in the United States. He now works on water quality modelling.

Dr Paul Hebert

Few months back I was in Bangkok with the Metro Waterworks Authority. During the lunch break, one of the senior water engineers walked up to me and asked, “By any chance are you the same Prasad Modak, who wrote LOOP 4.0 for the World Bank?” When I said Yes, he spoke to his team in Thai with animated gestures. I saw that all were looking at me with some admiration.

I decided not to request for a translation! You feel nice when you are remembered for something good you did in the past – and with a passion and conviction. The only sad part is that till date I could not produce MS Windows versions of the three programs.

Simply a pity – isn’t it!

If you like this post then follow me or circulate to your colleagues


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s