Created
July 2, 2023 13:21
-
-
Save lbutler/48783e61125ad4adf818fa24e8528811 to your computer and use it in GitHub Desktop.
Create an INP with 150,000 disconnections in EPANET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "lib/2.2/epanet2_2.h" | |
int main() { | |
int errcode; | |
int index; | |
EN_Project ph; | |
EN_createproject(&ph); | |
EN_init(ph, "", "", EN_GPM, EN_HW); | |
EN_setstatusreport(ph, EN_NORMAL_REPORT); | |
EN_addnode(ph, "R1", EN_TANK, &index); | |
EN_addnode(ph, "J0", EN_JUNCTION, &index); | |
EN_setjuncdata(ph, index, 600, 1000, ""); | |
EN_addlink(ph, "P0", EN_PIPE, "R1","J0", &index); | |
for (int i = 1; i < 150000; i++) { | |
char jID[8], j2ID[8], pID[8]; | |
sprintf(jID, "J%d", i); | |
sprintf(j2ID,"J%d", i -1); | |
sprintf(pID, "P%d", i); | |
// Add the node and set junction data | |
EN_addnode(ph, jID, EN_JUNCTION, &index); | |
EN_setjuncdata(ph, index, 600, 1000, ""); | |
// Add the link and set pipe data | |
EN_addlink(ph, pID, EN_PIPE, jID, j2ID, &index); | |
EN_setpipedata(ph, index, 100, 12, 100, 0); | |
} | |
// Save or run the input file | |
EN_saveinpfile(ph, "150k-disconnection.inp"); | |
//EN_solveH(ph); | |
EN_deleteproject(ph); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment