├── .gitignore ├── .travis.yml ├── Dockerfile ├── Dockerfile_beta ├── LICENCE ├── ReadMe.rst ├── build.gradle ├── doc └── ReadMe │ └── ReadMe.md ├── lib ├── inpparser-all.jar └── oms-all.jar ├── settings.gradle └── src ├── main ├── META-INF │ └── MANIFEST.MF └── java │ └── com │ └── github │ └── geoframecomponents │ └── jswmm │ ├── dataStructure │ ├── Coordinates.java │ ├── DataTypes.java │ ├── INPlocator.java │ ├── SWMMobject.java │ ├── hydraulics │ │ ├── linkObjects │ │ │ ├── AbstractLink.java │ │ │ ├── Conduit.java │ │ │ ├── OutsideSetup.java │ │ │ ├── Pump.java │ │ │ └── crossSections │ │ │ │ ├── Circular.java │ │ │ │ ├── CrossSectionType.java │ │ │ │ └── pipeSize │ │ │ │ ├── CommercialPipeSize.java │ │ │ │ ├── Lucchese_ca.java │ │ │ │ └── Oppo_pvc.java │ │ └── nodeObject │ │ │ ├── AbstractNode.java │ │ │ ├── Divider.java │ │ │ ├── ExternalInflow.java │ │ │ ├── Junction.java │ │ │ ├── Outfall.java │ │ │ ├── RainfallDependentInfiltrationInflow.java │ │ │ └── Storage.java │ ├── hydrology │ │ └── subcatchment │ │ │ ├── AbstractSubcatchment.java │ │ │ ├── Area.java │ │ │ ├── ImperviousWithStorage.java │ │ │ ├── ImperviousWithoutStorage.java │ │ │ ├── Pervious.java │ │ │ ├── Subarea.java │ │ │ └── SubareaReceiver.java │ ├── infiltration │ │ └── InfiltrationSetup.java │ ├── options │ │ ├── ReportSetup.java │ │ ├── SWMMtimeAndUnits.java │ │ ├── SteadyStateSetup.java │ │ ├── datetime │ │ │ ├── AvailableDateTypes.java │ │ │ ├── Datetimeable.java │ │ │ ├── Period.java │ │ │ ├── PeriodStep.java │ │ │ └── PeriodStepTolerance.java │ │ └── units │ │ │ ├── AvailableUnits.java │ │ │ ├── SWMMunits.java │ │ │ └── Unitable.java │ ├── routingDS │ │ ├── DynamicWaveOptions.java │ │ ├── KinematicWaveOptions.java │ │ ├── RoutedFlow.java │ │ ├── RoutingDateTime.java │ │ ├── RoutingSolver.java │ │ ├── SWMMroutingTools.java │ │ └── SteadyOptions.java │ └── runoffDS │ │ ├── AvailableODEmethods.java │ │ ├── DormandPrince54.java │ │ ├── ReceiverRunoff │ │ ├── AbstractReceiver.java │ │ ├── NodeReceiver.java │ │ ├── ReceiverRunoff.java │ │ └── SubcatchmentReceiver.java │ │ ├── RunoffODE.java │ │ └── RunoffSolver.java │ ├── routing │ ├── FlowRateDispatcher.java │ └── Routing.java │ └── runoff │ ├── PreRunoff.java │ └── Runoff.java └── test ├── java ├── base │ ├── SourceSetTest.java │ └── SourceSetTestINP.java ├── routing │ ├── RoutingINP.java │ ├── RoutingINPfossolo.java │ └── RoutingMain.java └── runoff │ ├── RunoffINP.java │ ├── RunoffINPfossolo.java │ └── RunoffMain.java └── resources ├── fossolo.inp └── network12.inp /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | gradle/* 4 | gradlew 5 | gradlew.bat 6 | 7 | out/ 8 | build/ 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | language: java 3 | services: 4 | - docker 5 | jdk: 6 | - oraclejdk8 7 | before_cache: 8 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 9 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 10 | cache: 11 | directories: 12 | - "$HOME/.gradle/caches/" 13 | - "$HOME/.gradle/wrapper/" 14 | before_deploy: 15 | - export GRADLE_BUILD_DIR="build/libs" 16 | - export TAG=$(git describe --abbrev=0 --tags) 17 | - export MOD_TAG=${TAG#"v"} 18 | - export RELEASE_PKG_FILE="${GRADLE_BUILD_DIR}/jswmm-${MOD_TAG}.jar" 19 | - export FAT_PKG_FILE="${GRADLE_BUILD_DIR}/jswmm-${MOD_TAG}-all.jar" 20 | - echo "building $FAT_PKG_FILE fat jar" 21 | - gradle shadowJar 22 | - echo "Building Docker jsmm:$MOD_TAG" 23 | - docker build -t "ftt01/jswmm:$MOD_TAG" . 24 | - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 25 | - docker push ftt01/jswmm:$MOD_TAG 26 | - echo "Building Docker jsmm:beta" 27 | - docker build -f Dockerfile_beta -t "ftt01/jswmm:beta" . 28 | - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 29 | - docker push ftt01/jswmm:beta 30 | - echo "deploying $RELEASE_PKG_FILE to GitHub releases" 31 | - gradle -PprojVersion=$MOD_TAG -PnexusUsername="${SONATYPE_USERNAME}" -PnexusPassword="${SONATYPE_PASSWORD}" 32 | -PbintrayUsername="${BINTRAY_USERNAME}" -PbintrayApiKey="${BINTRAY_KEY}" -PbintrayPassphrase="${PASSPHRASE}" 33 | bintrayUpload 34 | deploy: 35 | provider: releases 36 | api_key: 37 | secure: AZ3Ym1toWiI//pO4L9o2zria6op27mRxEwu/VRZv+AVT3dBpqhZM0yaeuA70ky0NSobIK4d+Utu3JkyuflWt+Kz4oNn7U06SIxfuz/wHdqy0zwtLqAIWIdcMWGGVGuiivhXde1cQil+wL4Jbhd12PrrE5H6BIf3HYTL+9QFRL5lH3f9puUAsSpat6WHuQFgLkg9PPPAj5J3oYmS5+cn0CHa4QiT0sYvGU2L+LuXVfBz64elVQ+yG2+3ChWXL/1z+9ygUlnQ127G6WMFYjOt0Qt2QYXH26OzujOTp1o6RYdhOorRP65QyXc0JBvl5eZahHW13EJ7Au+IUCqUoVfrHrZTlQDWyCklyRr1thwcKCl0u8VUGhe8AeEiz359n+Tf57jxi0F/Yf3y2GSpUxzIKL5cwzzEde6xwk2Hwi5m7U1vijCcnBVwGU6cwZeel5ttxp76L8162Tf5s945h9Z7d+81KujPwnts/FlwcaFXomX8FvneTPwcGKuWc7BRgghZoyUYyzQuzmzFsK543HpB1ntwY0bbROD8HrhwRGuvlID4JCOFBJ5wyZndvbfuQMr4I7HPnmNN94C2wqg9xD8jDcAC5C+fsvJ5e4Ywyj84d86qgXBRPwm1CyttUdkUunkB6JUpMNK+TR9gaXPPPGMfzQE3kz2nd3wArWcn/uvHRtv8= 38 | file: "${RELEASE_PKG_FILE}" 39 | skip_cleanup: true 40 | on: 41 | tags: true 42 | all_branches: true 43 | repo: geoframecomponents/jswmm 44 | env: 45 | global: 46 | - secure: UCod+azhFiWYQaK/YD7RM0APrlnMs59WUGF7GUCANlbH/DWTkYGIQYwJp5bmOb2c8tleyzmcjmFouYqP75edxCuEm+AgsGyp3JU9Cazpz6Stvdtb+0sGV6/Jktfeym7G6QofmPRV2nuJOOT/hL+MpYuBD5g4kPvoX6cCv9kY9yHKhQsSFheP+JkKJbpxypIQSC3dFJItT2mA6FpABFANaOcKjlC+cYGRyZDxh7ojaOjelX5VAk4LolZ7zpyrX1iF047d0M9/GekhnbB1N9tWkXyaR4FgcIG2aHgf2WPj0joSkpSTlc9DxN8DF7+LqiB9HF/sv4YNzMEJCsHzwGJkZgWhlBsRkE0fMTFYYaGqUXJL0A9TKmitvB6JwtHo8Gb8JhWgugszg6pZ+I2Ax7KMT0j8MrEVqaV40WVp+oGvagC31CRRMd3ZGP3GJxD1bN+C0eZGdz9AtN+J6hkYYK7FuSly2CLz1BvbKsPyjF8r8axfmM9LQeTvlLioqzu3JoAJv7MFxYmMDOvb109q3u6ANnIodtm3D3MyM0KhRrBAVdqZC3RWjtTJbfGtZXdHz4ydZE046ou0ES8E5S61kmR2L+Ui9YyhllMgFA13GlBoERxO3AdVtpGtZol3G2Qp6jt6iDiDe63LIQJctOfLET/QJjJPSTTYMVEKU7m2kqENUiQ= 47 | - secure: Vi6XwGktt4GOIRQOOMNgxlG0oZYY99J0iFEUz0R6XUoqeC1RVxr+0t3Zdtkf40bps4ODWAP/zlwMHbTBU9LbtomwSZN7HxAiWIxf3rAPcSfk9Y7l3NjKOXf6JO0KgDuuW5RmbQ1Ts4CoF0OwUf8vkTUaGMj1NpnOxML/ZKnnpLa3iIWY+r4/y3mefG5xkpBcJotrTt8LuMMQl2ssat0ssqsmdyfmhcnEOiLbvUEZDhv//rTAnyv57TaNRUwpgIpTGqVhqpQT052WqhgAIqOEZbYvx/67R7r7UPQe+8M+jud5lZ1LyV17Af2pVNdftP8ex+AhAb5oGJFeoxVlfvw9XSqHzhqkk779DSOuqM7mHeUTlOFM+4O9bLS7fsap35pIkZ2t51MbvfJRyzQ336U73N2tcLSnfTqMm+HMIsic8GG9chEWE787m1LsO3/dWxyC1V6Sogp5w2JDITUZ75y1MstOlxMawAMs57ol/+hjXkamuhVdcvoXhBo/cTw3iysMot1ah+/yMdBc5piXGVh2wMcdZwBoFEDMHZk3O0vsbw7FIXOSw5Jw3TWyoXmZzmUZwXU1pelsdwG07zVYAbyh0Cibi7mGfq1XILGlIrACf0+qeBU2HaYZWpGYxG5nrNXWRFaQ1Zk7fTxWfK38mdL2jpaQTdsKiVur/3iyKU6fAMU= 48 | - secure: LnDuQvJwuQ3ZLdjDfdehCKFJIX1U6JhpWk9coTfg2+cAxe5yKTVmODPSB5GCXVujT8W9/gyZtovq/WL61IMiK8kbAGZ0noqHM77dapP0cx0OM9wuzCAnchOIzmaU6c0ogj6PxX5pooWsDIscxg3KLpL6032Z9epVTfx8lbftpiqd+ztY5WZM9/pHaSueonbvZW0PNV9q+R1lYYE2YjLA+wYk06M8Wo/VkFuMb4KaTpFcVGj0hcTm98QVFhpjbmopdyKJaAQ5qJgiR1n+RY6TO/Ks2BKiwPmo3OHvkc9WgNp6l+dt9nmrOS5VUbXeo5sfrxfrHV/YtXRWpo1P13ppBA+caiIXb9TFWVE/iJkINONHBvmK+sY0eQbUnIqupaOomb0R3Ys5hyBWKU611O7try/34OFxuCnFN6jdkpoe8o4ZF4ayGWrNne1Di3mq2sRihVJgBvLGOJ6rctfTQXhvfxI91FCRKwsZNAoOVyhdIKyudgovTS2ROqYedcO4mCZH+K9QPWKZ2pDdIhllj/ONQlXNZ7i/744rlAFz49mOkeXmUNsL/d5Z6xN5CJtCguo1PCwZEm+TN2cnuN/iqPx+f4A1wR0X6D16kflCR+Y8gqcGZ0yDVG9qpuWh0Ll7frPWasWfTecQAlNMtFv3BXKX3/8e+aaFfPiLWuTNPQT5ldc= 49 | - secure: S7bdV+6x2sP0Y39y39KhhOkmTP5kGwzyYsFX2LpXx8Wh6A9bWNUGXuK9W55anyGKqmw9Qtuyp9S9fQC4Okw1sNmIOuJo5v9bI4LB69cH9lITpP/cMyTCP5CZeaGN6LHh1+uaL0E+y2bOAiwWDb5brw6kvyRxZsARaUBpdAPTHiwO/yqm7sTtwrQxOT/93eyJBfPnhYvePEhD4Jyn58o0vZmsfNuJ4PEBNtmkYUFG5BG2FSxFx6FxG9ERy+fjojAL3rtQzBF9n79WfHfdHswx6L6Yuwty1QO0Tk3bl6Fi+JyNVyIgLd/uD7PAfwt02FqbfkE4ZKkb149KSynbW+zEw5z+lZWR0GLJpqz1A902b5ML3HpDj/1tDJG5EiHIuKvuGQinK+TYWjgZlO2K0KOqfkZSeskAGBzQLZF+DjrpuuVsXaBtV1H5o7+7127Av7hmcaw6clJENnB6l0ekWrUsufZUwYRTotS1DsLMeGXpfPxqLZ7Y+2H1w/myCZfQR8FVhHjqZnx+m38du0BAGUWufXCtxV4nsN20KynrjVV3EriU9iGlqow8atGl2uB3+DgzbvxoZZDNct/yKEgswiLplMXZdX+6+8HIQcTVQV+TpUeNuWCPZzBhWYkMPc7bVWfSkBErHSq/32BDdDhuCzc8uw1iflsYQp4zEgf3eW7VJDQ= 50 | - secure: jGLdRDRqN0BUPiJj+axDLvizrsOlYJQFgl3cNqdlVwZsbdJ3UFvdvIsKC+7VB3MxJ/ydrcvt53029zev2x3kpB309fJOmGDbcOS6uW4PIDV41Qos3mItNOHlZzEy7jCE4OCdgvyJR56TRLk/RvhGKT18sM3DSDO6Gcdexkf4UZG7lK5uZ62n8ozYjjq/w2e+znLqae7HuH9+qX9aVuzAJafYjeHqvOUQDh4WekvSnLavK+uLCwQoHrVpjDoGhkbJlpu8tfvWw2PgetxXzUGEs2P3JcBwfHmSIVIXEoWOQdej4NKZhdV0eQWJp7DO3ohR1rTtUq8Pex2TBnzzf/BMbxWd1OYpwTd6zhamiHK8hyzDpJtzjBtho2nPTdsvuNisuFrV6ovdxji0oL3P01cTNP12IED6cKAbiSEsnt39i/T+QdhWgYi8f+abMH2GjuJVR+CXoeu6tWIfzPRIE2noX8iWI1VnpaOfdmZIdrL6bb3XxG1MHm74Njkf7VI26Eu4WccvXLPTkK4dq6sTTfG9uiFhsftnHqrPGRBv/pj6Pq2/v0oZJ7yRTIgnmpWZaCJ+BgE2aQWr+E8L5Pq6LfruU+aKnE+j/gmyPUkwxS3t2JrH2sWiQnJ4vXKPwdr86K1jiB9QsfDcqI4kmNv7lHWMDYbmqwOUbXcQ80hq8xBFUZY= 51 | - secure: i6a171mWN+0aXpimiEEAUv1Tu8ZGfGf1yvocFIZ3BtDU9pHahB/NOmRJBLR7LlXnZH4lNaXjhz3pg3MiUTw9Az/kJbMuU5yYASmAjU/dARCVVSmnGYsnh6JlqNo9ALOt3Tb44nuYAuXTmqx1R7GlKjkNkzlhGvn0U995oiziQxSmuzbx4DNdRuu/zfKt5+kWbCm8Z3pQvws3Nue0d1JqL3Br3BNW0wMImWSGT2zIPpkADG9ejmbCazjLyyCgvDRKvexpHMs3I2PoIoqcgpS1mo+wVPVV5CDq4bT9nFlZw8cyehi0budtFskRqXrCiqS1yYxRkkkvJq4hFzp1yO4GOTgpjpZY9k3sH16iI+y+6Pbv4YyL4c3wn7lOPD5QDXoH1dEtwfXK948HqlFQ7M1SE7Zqw/6+VETmY1K28ke58wGbmdTyTTK0E7Ng0VFE1VCFBXmK2vEV42ZJkR/8h/IYBzfvlyBtb2AgGR4Nsv1csW2qT4WamiNp0PU8gTRA1DyiH6RwUa37GkWLf/Mg+Fjlcq55QckrrSUVXtNO9zsedCqFL3a+YGIwaK0BPOZJ5G+9AvIF5e7r4cKvJG3c2ec0H6UhwBpQhz8vy56rjbCu7HCqNe6TUVToCPf10xcWP9itimZ3OcKrW6UOf7lpetdUtPDrSpxF/dBoSnA/Qep4TFQ= 52 | - secure: Ecd8REZe6kRUPWoCmcSXkQJ9pAOA73oY/EFhAsYlHXFYtvcp6kAh4tESn0s2myX8fb6odJScfdavXyTUgYS7n05IyswJkqdf4ldfHtfIt5scpPWo7MPFvcOPy2fIZHl6KfGXHBco3OE33NhXxlSlnUVzG7GzsEgBuHzgQUje+Kyj9rapJmXcUSGl2K2z+P4pIp55Bwx+XFOstxT6NbVq0QfXcgfyZW9q8S+Wdwdo1CNIWVUHpbzQdzrPKw5W0uLVmAN/nDMd4zkw3OhcxEk9KT2zWs/1ndELsdCnT8b9n2KZuMjWUv5PghtDi7fBqbRboecrYliTeXGNj8eFVwti09vgEnktJxe+xeNNuXorhPPLBBEeN67bBMIQmiLO+lph6PDxdB6UTEiV0L2ymFSAe9eTrJjstUKXWXRRJwnSDzbxTIFZjKu2MTWlbVHGpZEyWaf5vtBibYQ3j6P9fLcEJgUWRbV7s5n2Bca4rmCQkL6+N+SwDvoI2qbePn1+S6tTw3WK3/WmOzgPWe3DEy78QVcyUwORVZ5xrbttzIkYyshnvuuUIC4AWZpZ+NB56kRQtUviQuoIGEFWKXanuLsuJb0kl9c1k7kiiAFHiccQBGXQmL+uykrQzdggHJDH9M7oHrxB810MBxvA0TePl0oePT70YdWreKFHxuO4iJx/xfk= 53 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM omslab/oms:0.2_py3 2 | 3 | MAINTAINER Daniele Dalla Torre , Francesco Serafin 4 | 5 | COPY build/libs/jswmm-*-all* /root/.oms/$OMS_VERSION/ 6 | 7 | ENTRYPOINT ["/entrypoint.sh"] 8 | -------------------------------------------------------------------------------- /Dockerfile_beta: -------------------------------------------------------------------------------- 1 | FROM omslab/oms:beta 2 | 3 | MAINTAINER Daniele Dalla Torre , Francesco Serafin 4 | 5 | COPY build/libs/jswmm-*-all* /root/.oms/$OMS_VERSION/ 6 | 7 | ENTRYPOINT ["/entrypoint.sh"] 8 | -------------------------------------------------------------------------------- /ReadMe.rst: -------------------------------------------------------------------------------- 1 | JSWMM 2 | ===== 3 | 4 | |Build Status| |Maven Central| |License (GPL version 3)| 5 | 6 | ``@author`` Francesco Serafin (sidereus3), francesco.serafin.3@gmail.com 7 | |sidereus3| 8 | 9 | ``@author`` Daniele Dalla Torre (ftt01), dallatorre.daniele@gmail.com 10 | |ftt01| 11 | 12 | Description 13 | ----------- 14 | 15 | To build the ReadMe file from the markdown one in the doc/ReadMe folder 16 | 17 | :: 18 | 19 | pandoc doc/ReadMe/ReadMe.md -o ReadMe.rst --bibliography=doc/ReadMe/biblio.bib 20 | 21 | Implementation 22 | ~~~~~~~~~~~~~~ 23 | 24 | .. raw:: html 25 | 26 | 29 | 30 | Documentation 31 | ------------- 32 | 33 | Developers’ documentation 34 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 35 | 36 | Linkers’ documentation 37 | ~~~~~~~~~~~~~~~~~~~~~~ 38 | 39 | Users’ documentation 40 | ~~~~~~~~~~~~~~~~~~~~ 41 | 42 | References 43 | ---------- 44 | 45 | .. |Build Status| image:: https://travis-ci.org/geoframecomponents/jswmm.svg 46 | :target: https://travis-ci.org/geoframecomponents/jswmm 47 | .. |Maven Central| image:: https://img.shields.io/maven-central/v/com.github.geoframecomponents/jswmm.svg?label=Maven%20Central 48 | :target: https://search.maven.org/search?q=g:%22com.github.geoframecomponents%22%20AND%20a:%22jswmm%22 49 | .. |License (GPL version 3)| image:: https://img.shields.io/badge/license-GNU%20GPL%20version%203-blue.svg 50 | :target: http://opensource.org/licenses/GPL-3.0 51 | .. |sidereus3| image:: https://github.com/GrowWorkingHard/logos/blob/master/sidereus/sidereus3_50X50.png 52 | .. |ftt01| image:: https://github.com/GrowWorkingHard/logos/blob/master/ftt01/ftt01_50X50.png 53 | 54 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // include the BinTray repository 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | maven { url "http://dl.bintray.com/palantir/releases" } 6 | } 7 | 8 | dependencies { 9 | classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' 10 | classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.1' 11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' 12 | classpath 'com.palantir:gradle-gitsemver:0.7.0' 13 | } 14 | 15 | } 16 | 17 | plugins { 18 | id 'com.palantir.git-version' version '0.11.0' 19 | } 20 | 21 | apply plugin: 'java' 22 | apply plugin: 'java-library' 23 | apply plugin: 'eclipse' 24 | apply plugin: 'maven-publish' 25 | apply plugin: 'com.bmuschko.nexus' 26 | apply plugin: 'com.jfrog.bintray' 27 | apply plugin: 'gitsemver' 28 | apply plugin: 'maven' 29 | apply plugin: 'com.github.johnrengelman.shadow' 30 | 31 | group = 'com.github.geoframecomponents' 32 | archivesBaseName = 'jswmm' 33 | 34 | def projectName = "jswmm" 35 | def projectDescription = "java version of jswmm" 36 | 37 | // artifactId is taken by default, from folder name 38 | version = '0.1-SNAPSHOT' 39 | 40 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 41 | sourceCompatibility = '1.8' 42 | 43 | // Warning! IJ has a bug here..https://youtrack.jetbrains.com/issue/IDEA-141750 44 | sourceSets { 45 | main{ 46 | } 47 | test { 48 | } 49 | } 50 | 51 | // to get project version from command line, just type 52 | // $ gradle -PprojVersion= build 53 | // default is na 54 | if (project.hasProperty('projVersion')) { 55 | project.version = project.projVersion 56 | } else { 57 | project.version = gitVersion() 58 | } 59 | 60 | // name with versioning of the jar file 61 | jar { 62 | baseName = projectName 63 | manifest { 64 | attributes 'Implementation-Title' : projectName, 65 | 'Implementation-Version': version 66 | } 67 | } 68 | 69 | repositories { 70 | maven { 71 | // geotools 72 | url 'http://download.osgeo.org/webdav/geotools/' 73 | } 74 | 75 | mavenCentral() 76 | jcenter() 77 | 78 | flatDir { 79 | dirs 'lib' 80 | } 81 | } 82 | 83 | dependencies { 84 | compile name: 'oms-all' 85 | compile name: 'inpparser-all' 86 | 87 | compile 'com.github.geoframecomponents:GEOframeUtils:0.4' 88 | compile 'commons-lang:commons-lang:2.3' 89 | compile 'org.apache.commons:commons-math3:3.6.1' 90 | 91 | compile group: 'org.apache.commons', name: 'commons-configuration2', version: '2.0' 92 | 93 | compile 'junit:junit:4.12' 94 | testCompile group: 'junit', name: 'junit', version: '4.12' 95 | } 96 | 97 | shadowJar { 98 | mergeServiceFiles() 99 | archiveName = project.name + "-" + project.version + "-all.jar" 100 | } 101 | 102 | // custom tasks for creating source/javadoc jars 103 | task sJar(type: Jar, dependsOn: classes) { 104 | classifier = 'sources' 105 | from sourceSets.main.allSource 106 | } 107 | 108 | task jJar(type: Jar, dependsOn: javadoc) { 109 | classifier = 'javadoc' 110 | from javadoc.destinationDir 111 | } 112 | 113 | // add javadoc/source jar tasks as artifacts 114 | artifacts { 115 | archives sJar, jJar 116 | } 117 | 118 | def pomConfig = { 119 | scm { 120 | connection 'scm:git:https://github.com/geoframecomponents/jswmm.git' 121 | developerConnection 'scm:git:https://github.com/geoframecomponents/jswmm.git' 122 | url 'https://github.com/geoframecomponents/jswmm' 123 | } 124 | 125 | licenses { 126 | license { 127 | name 'General Public License V.3 (GPL3)' 128 | url 'http://www.gnu.org/licenses/gpl.html' 129 | } 130 | } 131 | 132 | developers { 133 | developer { 134 | id 'ftt01' 135 | name 'Daniele Dalla Torre' 136 | email 'dallatorre.daniele@gmail.com' 137 | } 138 | } 139 | } 140 | 141 | nexus { 142 | sign = false 143 | } 144 | 145 | publishing { 146 | publications { 147 | MyPublication(MavenPublication) { 148 | from components.java 149 | artifact sJar 150 | artifact jJar 151 | groupId 'com.github.geoframecomponents' 152 | artifactId 'jswmm' 153 | version project.version 154 | pom.withXml { 155 | def root = asNode() 156 | root.appendNode('description', 'Java version of SWMM') 157 | root.appendNode('name', 'jswmm') 158 | root.appendNode('url', 'https://github.com/geoframecomponents/jswmm') 159 | root.children().last() + pomConfig 160 | } 161 | } 162 | } 163 | } 164 | 165 | // bintray sync 166 | if (hasProperty('bintrayUsername') || 167 | System.getenv().containsKey('BINTRAY_USER')) { 168 | // Used by the bintray plugin 169 | bintray { 170 | user = System.getenv().getOrDefault('BINTRAY_USER', bintrayUsername) 171 | key = System.getenv().getOrDefault('BINTRAY_KEY', bintrayApiKey) 172 | publish = true 173 | publications = ['MyPublication'] 174 | 175 | pkg { 176 | repo = 'geoframecomponents' 177 | name = projectName 178 | licenses = ['GPL-3.0'] 179 | vcsUrl = 'https://github.com/geoframecomponents/jswmm.git' 180 | 181 | version { 182 | name = project.version 183 | desc = projectDescription 184 | released = new Date() 185 | 186 | gpg { 187 | sign = true 188 | passphrase = System.getenv().getOrDefault('PASSPHRASE', 189 | bintrayPassphrase) 190 | } 191 | 192 | mavenCentralSync { 193 | user = System.getenv().getOrDefault('SONATYPE_USER', 194 | nexusUsername) 195 | password = System.getenv().getOrDefault('SONATYPE_PASSWORD', 196 | nexusPassword) 197 | } 198 | } 199 | } 200 | 201 | configurations = ['archives'] 202 | } 203 | } -------------------------------------------------------------------------------- /doc/ReadMe/ReadMe.md: -------------------------------------------------------------------------------- 1 | # JSWMM 2 | 3 | [![Build Status](https://travis-ci.org/geoframecomponents/jswmm.svg)](https://travis-ci.org/geoframecomponents/jswmm) 4 | [![Maven Central](https://img.shields.io/maven-central/v/com.github.geoframecomponents/jswmm.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.geoframecomponents%22%20AND%20a:%22jswmm%22) 5 | [![License (GPL version 3)](https://img.shields.io/badge/license-GNU%20GPL%20version%203-blue.svg)](http://opensource.org/licenses/GPL-3.0) 6 | 7 | `@author` Francesco Serafin (sidereus3), francesco.serafin.3@gmail.com ![sidereus3](https://github.com/GrowWorkingHard/logos/blob/master/sidereus/sidereus3_50X50.png "sidereus3") 8 | 9 | `@author` Daniele Dalla Torre (ftt01), dallatorre.daniele@gmail.com ![ftt01](https://github.com/GrowWorkingHard/logos/blob/master/ftt01/ftt01_50X50.png "ftt01") 10 | 11 | ## Description 12 | 13 | To build the ReadMe file from the markdown one in the doc/ReadMe folder 14 | 15 | pandoc doc/ReadMe/ReadMe.md -o ReadMe.rst --bibliography=doc/ReadMe/biblio.bib 16 | 17 | ### Implementation 18 | 19 | 22 | 23 | ## Documentation 24 | 25 | ### Developers' documentation 26 | 27 | ### Linkers' documentation 28 | 29 | ### Users' documentation 30 | 31 | ## References 32 | -------------------------------------------------------------------------------- /lib/inpparser-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geoframecomponents/jswmm/84500a5cf83e2f963a786d7abe7c0f8f5d712997/lib/inpparser-all.jar -------------------------------------------------------------------------------- /lib/oms-all.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geoframecomponents/jswmm/84500a5cf83e2f963a786d7abe7c0f8f5d712997/lib/oms-all.jar -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'jswmm' 2 | 3 | -------------------------------------------------------------------------------- /src/main/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/Coordinates.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure; 19 | 20 | public class Coordinates { 21 | public double x; 22 | public double y; 23 | public double z; 24 | 25 | public Coordinates(double x, double y) { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public Coordinates(double x, double y, double z) { 31 | this(x,y); 32 | this.z = z; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/DataTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure; 19 | 20 | /** 21 | * Define the data types used to setup the dataStructure 22 | */ 23 | 24 | public enum DataTypes { 25 | STRING, INT, DOUBLE 26 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/INPlocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure; 19 | 20 | /** 21 | * Link the object instance into the right position in the .inp file 22 | */ 23 | public interface INPlocator { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/AbstractLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize.CommercialPipeSize; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 23 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 24 | import com.github.geoframecomponents.jswmm.dataStructure.routingDS.RoutingSolver; 25 | import org.altervista.growworkinghard.jswmm.inpparser.DataFromFile; 26 | import org.altervista.growworkinghard.jswmm.inpparser.INPparser; 27 | 28 | import java.time.Instant; 29 | import java.util.HashMap; 30 | import java.util.LinkedHashMap; 31 | 32 | /** 33 | * Generic link object 34 | */ 35 | public abstract class AbstractLink extends INPparser { 36 | 37 | protected String name; 38 | 39 | protected Unitable linksUnits; 40 | protected Datetimeable linksTime; 41 | 42 | RoutingSolver routingSolver; 43 | 44 | OutsideSetup upstreamOutside; 45 | OutsideSetup downstreamOutside; 46 | 47 | DataFromFile interfaceINP; 48 | 49 | public AbstractLink(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getName() { 54 | return this.name; 55 | } 56 | 57 | public void setLinksUnits(Unitable linksUnits) { 58 | this.linksUnits = linksUnits; 59 | } 60 | 61 | public void setLinksTime(Datetimeable linksTime) { 62 | this.linksTime = linksTime; 63 | } 64 | 65 | public Unitable getLinksUnits() { 66 | if (linksUnits!=null) { 67 | return linksUnits; 68 | } 69 | else { 70 | throw new NullPointerException("linksUnits null"); 71 | } 72 | } 73 | 74 | public Datetimeable getLinksTime() { 75 | if (linksTime !=null) { 76 | return linksTime; 77 | } 78 | else { 79 | throw new NullPointerException("linksTime null"); 80 | } 81 | } 82 | 83 | public HashMap> getDownstreamFlowRate() { 84 | if (downstreamOutside.streamFlowRate !=null) { 85 | return downstreamOutside.streamFlowRate; 86 | } 87 | else { 88 | throw new NullPointerException("downstreamOutside.streamFlowRate null"); 89 | } 90 | } 91 | 92 | public HashMap> getUpstreamFlowRate() { 93 | if (upstreamOutside.streamFlowRate !=null) { 94 | return upstreamOutside.streamFlowRate; 95 | } 96 | else { 97 | throw new NullPointerException("upstreamOutside.streamFlowRate null"); 98 | } 99 | } 100 | 101 | public abstract OutsideSetup getUpstreamOutside(); 102 | 103 | public abstract OutsideSetup getDownstreamOutside(); 104 | 105 | public abstract void evaluateFlowRate(); 106 | 107 | public abstract double evaluateMaxDischarge(); 108 | 109 | public abstract void evaluateDimension(Double discharge, CommercialPipeSize pipeCompany); 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/OutsideSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects; 20 | 21 | import java.time.Instant; 22 | import java.util.HashMap; 23 | import java.util.LinkedHashMap; 24 | 25 | import com.github.geoframecomponents.jswmm.dataStructure.Coordinates; 26 | import it.blogspot.geoframe.utils.GEOconstants; 27 | 28 | public class OutsideSetup { 29 | 30 | String nodeName; 31 | private Coordinates nodeCoordinates; 32 | private double terrainElevation; 33 | private double baseElevation; 34 | private double offset; 35 | private double height; 36 | private double excavation; 37 | private double fillCoeff; 38 | private double waterDepth; 39 | 40 | HashMap> streamWetArea = new HashMap<>(); 41 | HashMap> streamFlowRate = new HashMap<>(); 42 | 43 | public OutsideSetup(String nodeName, Double downOffset, Double fillCoeff, 44 | Double x, Double y, double terrainElevation) { 45 | this.nodeName = nodeName; 46 | this.offset = downOffset; 47 | this.fillCoeff = fillCoeff; 48 | this.nodeCoordinates = new Coordinates(x, y); 49 | this.terrainElevation = terrainElevation; 50 | } 51 | 52 | public HashMap> getStreamWetArea() { 53 | return streamWetArea; 54 | } 55 | 56 | public HashMap> getStreamFlowRate() { 57 | return streamFlowRate; 58 | } 59 | 60 | public void setWetArea(Integer id, Instant time, Double wetArea) { 61 | if (!streamWetArea.containsKey(id)) { 62 | streamWetArea.put(id, new LinkedHashMap<>()); 63 | } 64 | Double oldWetArea = streamWetArea.get(id).get(time); 65 | if (oldWetArea == null) { 66 | LinkedHashMap newLHM = new LinkedHashMap<>(); 67 | newLHM.put(time, wetArea); 68 | streamWetArea.put(id, newLHM); 69 | } 70 | else { 71 | LinkedHashMap oldLHM = streamWetArea.get(id); 72 | oldLHM.put(time, wetArea); 73 | streamWetArea.put(id, oldLHM); 74 | } 75 | } 76 | 77 | public void setFlowRate(Integer id, Instant time, Double flowRate) { 78 | if (!streamFlowRate.containsKey(id)) { 79 | streamFlowRate.put(id, new LinkedHashMap<>()); 80 | } 81 | LinkedHashMap oldLHM = streamFlowRate.get(id); 82 | oldLHM.put(time, flowRate); 83 | streamFlowRate.put(id, oldLHM); 84 | } 85 | 86 | public void sumStreamFlowRate(HashMap> newFlowRate) { 87 | for (Integer id : newFlowRate.keySet()) { 88 | if (!streamFlowRate.containsKey(id)) { 89 | streamFlowRate.put(id, new LinkedHashMap<>()); 90 | } 91 | for (Instant time : newFlowRate.get(id).keySet()) { 92 | Double oldFLowRate = streamFlowRate.get(id).get(time); 93 | double value; 94 | if (oldFLowRate == null) { 95 | value = newFlowRate.get(id).get(time); 96 | } else { 97 | value = newFlowRate.get(id).get(time) + oldFLowRate; 98 | } 99 | LinkedHashMap oldLHM = streamFlowRate.get(id); 100 | oldLHM.put(time, value); 101 | streamFlowRate.put(id, oldLHM); 102 | } 103 | } 104 | } 105 | 106 | public Double getFillCoeff() { 107 | return fillCoeff; 108 | } 109 | 110 | public Coordinates getNodeCoordinates() { 111 | return nodeCoordinates; 112 | } 113 | 114 | public Double getTerrainElevation() { 115 | return terrainElevation; 116 | } 117 | 118 | public Double getBaseElevation() { 119 | return baseElevation; 120 | } 121 | 122 | public double getWaterDepth() { 123 | return waterDepth; 124 | } 125 | 126 | public String getNodeName() { 127 | return nodeName; 128 | } 129 | 130 | public void setWaterDepth(double waterDepth) { 131 | this.waterDepth = waterDepth; 132 | } 133 | 134 | public void upgradeOffset(double delta) { 135 | if (this.offset < Math.abs(delta)) { 136 | this.offset = 0.0; 137 | this.height += delta; 138 | this.baseElevation -= delta; 139 | checkMaxExcavation(height); 140 | } 141 | else{ 142 | this.offset -= delta; 143 | } 144 | } 145 | 146 | private void checkMaxExcavation(double escavation) { 147 | if (escavation > GEOconstants.MAXIMUMEXCAVATION) { 148 | System.out.println("over MAXIMUMEXCAVATION"); 149 | } 150 | } 151 | 152 | /** 153 | * Set the heights for the node inlet/outlet changing the offset 154 | * @param excavation excavation choose 155 | * @param offset offset choose 156 | */ 157 | public void setHeights(double excavation, double offset) { 158 | this.offset = offset; 159 | this.height = excavation + this.offset; 160 | this.baseElevation = terrainElevation - height; 161 | this.excavation = excavation; 162 | checkMaxExcavation(excavation); 163 | } 164 | 165 | /** 166 | * Set the heights for the node inlet/outlet without changing the offset 167 | * @param excavation excavation choose 168 | */ 169 | public void setHeights(double excavation) { 170 | this.height = excavation + this.offset; 171 | this.baseElevation = terrainElevation - height; 172 | this.excavation = excavation; 173 | checkMaxExcavation(excavation); 174 | } 175 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/Pump.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize.CommercialPipeSize; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 23 | 24 | import java.time.Instant; 25 | 26 | class Pump extends AbstractLink { 27 | 28 | 29 | public Pump(String name) { 30 | super(name); 31 | } 32 | 33 | @Override 34 | public OutsideSetup getUpstreamOutside() { 35 | throw new NullPointerException("Nothing implemented yet"); 36 | 37 | } 38 | 39 | @Override 40 | public OutsideSetup getDownstreamOutside() { 41 | throw new NullPointerException("Nothing implemented yet"); 42 | } 43 | 44 | @Override 45 | public void evaluateFlowRate() { 46 | throw new NullPointerException("Nothing implemented yet"); 47 | } 48 | 49 | @Override 50 | public double evaluateMaxDischarge() { 51 | throw new NullPointerException("Nothing implemented yet"); 52 | } 53 | 54 | @Override 55 | public void evaluateDimension(Double discharge, CommercialPipeSize pipeCompany) { 56 | throw new NullPointerException("Nothing implemented yet"); 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/crossSections/Circular.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections; 20 | 21 | public class Circular implements CrossSectionType { 22 | 23 | private double[] diameters; 24 | private Boolean alwaysIncrease = false; 25 | 26 | private Double depthFull; 27 | private Double areaFull; 28 | private Double areaMax; 29 | private Double hydraulicRadiousFull; 30 | private Double sectionFactorFull; 31 | 32 | public Circular(double innerDiameter, double outerDiameter) { 33 | this.diameters = new double[]{innerDiameter, outerDiameter}; 34 | this.depthFull = 0.938 * innerDiameter; 35 | this.areaFull = Math.PI * innerDiameter * innerDiameter / 4; 36 | this.areaMax = 0.7854 * Math.pow(getDepthFull(), 2); 37 | this.hydraulicRadiousFull = 0.25 * getDepthFull(); 38 | this.sectionFactorFull = getAreaFull() * Math.pow(getHydraulicRadiusFull(), 2.0 / 3.0); 39 | } 40 | 41 | public Circular(double innerDiameter) { 42 | this(innerDiameter, innerDiameter); 43 | } 44 | 45 | @Override 46 | public void setDimensions(double innerDiameter, double outerDiameter) { 47 | if (this.diameters == null) { 48 | this.diameters = new double[]{innerDiameter, outerDiameter}; 49 | } 50 | else{ 51 | this.diameters[0] = innerDiameter; 52 | this.diameters[1] = outerDiameter; 53 | } 54 | this.depthFull = 0.938 * innerDiameter; 55 | this.areaFull = Math.PI * innerDiameter * innerDiameter / 4; 56 | this.areaMax = 0.7854 * Math.pow(getDepthFull(), 2); 57 | this.hydraulicRadiousFull = 0.25 * getDepthFull(); 58 | this.sectionFactorFull = getAreaFull() * Math.pow(getHydraulicRadiusFull(), 2.0 / 3.0); 59 | } 60 | 61 | @Override 62 | public Double getDepthFull() { 63 | return depthFull; 64 | } 65 | 66 | @Override 67 | public Double getAreaFull() { 68 | return areaFull; 69 | } 70 | 71 | @Override 72 | public Double computeHydraulicRadious(Double diameter, Double fillAngle) { 73 | return (diameter / 4.0) / ( 1 - Math.sin(fillAngle)/fillAngle ); 74 | } 75 | 76 | @Override 77 | public Double getHydraulicRadiusFull() { 78 | return hydraulicRadiousFull; 79 | } 80 | 81 | @Override 82 | public Double getDischargeFull(double roughnessCoefficient, double slope) { 83 | return areaFull * Math.pow(hydraulicRadiousFull, 2.0 / 3) * roughnessCoefficient * Math.pow(slope, 0.5); 84 | } 85 | 86 | @Override 87 | public Double getAreaMax() { 88 | return areaMax; 89 | } 90 | 91 | @Override 92 | public Boolean getAlwaysIncrease() { 93 | return alwaysIncrease; 94 | } 95 | 96 | public Double derivatedSectionFactor(Double theta) { 97 | Double area = areaFull * (theta - Math.sin(theta)) / (2 * Math.PI); 98 | Double wetPerimeter = theta * depthFull / 2; 99 | return (5.0 / 3 - 2.0 / 3 * derivatedWetPerimeter(theta) * getHydraulicRadious(area, wetPerimeter)) * 100 | Math.pow(getHydraulicRadious(area, wetPerimeter), 2.0 / 3) / sectionFactorFull; 101 | } 102 | 103 | private Double getHydraulicRadious(Double area, Double wetPerimeter) { 104 | return area / wetPerimeter; 105 | } 106 | 107 | private Double derivatedWetPerimeter(Double theta) { 108 | return 4.0 / depthFull / (1 - Math.cos(theta)); 109 | } 110 | 111 | public Double computeFillAngle(Double fillCoefficient) { 112 | return 2 * Math.acos( 1 - 2 * fillCoefficient ); 113 | } 114 | 115 | public double getMainDimension() { 116 | return diameters[0]; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/crossSections/CrossSectionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections; 20 | 21 | /** 22 | * Class that defines the properties of the pipe. 23 | * 24 | * Extending this abstract class is possible to define personalized cross section type of pipe. 25 | * @author ftt01 (dallatorre.daniele@gmail.com) 26 | */ 27 | public interface CrossSectionType { 28 | 29 | /** 30 | * Defines if the cross section defined always increase its capacity increasing the discharge. 31 | * @return true id the capacity always increase. 32 | */ 33 | public Boolean getAlwaysIncrease(); 34 | 35 | /** 36 | * @param theta fill angle 37 | * @return derivative section factor 38 | */ 39 | public Double derivatedSectionFactor(Double theta); 40 | 41 | Double getDepthFull(); 42 | 43 | Double getAreaFull(); 44 | 45 | Double getHydraulicRadiusFull(); 46 | 47 | Double getDischargeFull(double roughnessCoefficient, double slope); 48 | 49 | Double getAreaMax(); 50 | 51 | Double computeHydraulicRadious(Double diameter, Double fillAngle); 52 | 53 | Double computeFillAngle(Double fillCoeff); 54 | 55 | void setDimensions(double innerDiameter, double outerDiameter); 56 | 57 | double getMainDimension(); 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/crossSections/pipeSize/CommercialPipeSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize; 20 | 21 | import it.blogspot.geoframe.utils.GEOunitsTransform; 22 | 23 | import java.util.Map; 24 | 25 | /** 26 | * Class that defines the commercial dimensions of pipe. 27 | * 28 | * Extending this abstract class is possible to define personalized dimensions of pipe. 29 | * @author sidereus3 (francesco.serafin.3@gmail.com) 30 | */ 31 | public abstract class CommercialPipeSize { 32 | 33 | Map pipe; 34 | 35 | /** 36 | * Method that return closer right diameter in meters. 37 | * @param designedDiameter The diameter obtained from the model. 38 | * @return Best diameter that satisfy the designedDiameter. In meters. 39 | */ 40 | // returns commercial size in meters 41 | // expects designed size in meters 42 | public double[] getCommercialDiameter(Double designedDiameter) { 43 | designedDiameter = GEOunitsTransform.meters2millimiters(designedDiameter); 44 | double[] commercialSize = null; 45 | for(Map.Entry diameter : pipe.entrySet()) { 46 | double innerSize = diameter.getKey(); 47 | if (innerSize > designedDiameter) { 48 | double outerSize = GEOunitsTransform.millimiters2meters(diameter.getValue()); 49 | innerSize = GEOunitsTransform.millimiters2meters(innerSize); 50 | commercialSize = new double[]{innerSize, outerSize}; 51 | break; 52 | } 53 | } 54 | if (commercialSize == null) { 55 | String msg = "Designed diameter " + designedDiameter; 56 | msg += " is bigger than the biggest diameter available."; 57 | throw new NullPointerException(msg); 58 | } 59 | return commercialSize; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/crossSections/pipeSize/Lucchese_ca.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize; 20 | 21 | import java.util.LinkedHashMap; 22 | 23 | public class Lucchese_ca extends CommercialPipeSize { 24 | 25 | public Lucchese_ca() { 26 | pipe = new LinkedHashMap() {{ 27 | put(400.0, 510.0); 28 | put(500.0, 620.0); 29 | put(600.0, 740.0); 30 | put(700.0, 850.0); 31 | put(800.0, 970.0); 32 | put(1000.0, 1200.0); 33 | put(1200.0, 1440.0); 34 | }}; 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/linkObjects/crossSections/pipeSize/Oppo_pvc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize; 20 | 21 | import java.util.LinkedHashMap; 22 | 23 | public class Oppo_pvc extends CommercialPipeSize { 24 | 25 | public Oppo_pvc() { 26 | pipe = new LinkedHashMap() {{ 27 | put(153.6,160.0); 28 | put(192.2,200.0); 29 | put(240.2,250.0); 30 | put(302.6,315.0); 31 | put(384.2,400.0); 32 | put(480.4,500.0); 33 | put(605.4,630.0); 34 | put(1005.4,1000.0); 35 | }}; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/AbstractNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 22 | import org.altervista.growworkinghard.jswmm.inpparser.DataFromFile; 23 | 24 | import java.time.Instant; 25 | import java.util.HashMap; 26 | import java.util.LinkedHashMap; 27 | 28 | public abstract class AbstractNode { 29 | 30 | protected String name; 31 | 32 | protected Unitable nodeUnits; 33 | Double nodeElevation; 34 | 35 | ExternalInflow dryWeatherInflow; 36 | ExternalInflow rainfallDependentInfiltrationInflow; 37 | 38 | HashMap> nodeFlowRate = new HashMap<>(); 39 | LinkedHashMap nodeDepth; 40 | 41 | DataFromFile interfaceINP; 42 | 43 | public AbstractNode(String name) { 44 | this.name = name; 45 | } 46 | 47 | public String getName() { 48 | return this.name; 49 | } 50 | 51 | public abstract void sumFlowRate(HashMap> newFlowRate); 52 | 53 | public abstract HashMap> getFlowRate(); 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/Divider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | import org.altervista.growworkinghard.jswmm.inpparser.objects.DividerINP; 22 | import org.apache.commons.configuration2.ex.ConfigurationException; 23 | 24 | import java.time.Instant; 25 | import java.util.HashMap; 26 | import java.util.LinkedHashMap; 27 | 28 | public class Divider extends AbstractNode { 29 | 30 | public Divider(String name, String INPfile) throws ConfigurationException { 31 | super(name); 32 | interfaceINP = new DividerINP(INPfile); 33 | } 34 | 35 | @Override 36 | public void sumFlowRate(HashMap> newFlowRate) { 37 | throw new NullPointerException("Nothing implemented yet"); 38 | } 39 | 40 | @Override 41 | public HashMap> getFlowRate() { 42 | throw new NullPointerException("Nothing implemented yet"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/ExternalInflow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | public interface ExternalInflow { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/Junction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 21 | import org.altervista.growworkinghard.jswmm.inpparser.objects.JunctionINP; 22 | import org.altervista.growworkinghard.jswmm.inpparser.objects.OutfallINP; 23 | import org.apache.commons.configuration2.ex.ConfigurationException; 24 | 25 | import java.time.Instant; 26 | import java.util.HashMap; 27 | import java.util.LinkedHashMap; 28 | 29 | public class Junction extends AbstractNode { 30 | 31 | Double maximumDepthNode; 32 | Double initialDepthnode; 33 | Double maximumDepthSurcharge; 34 | Double pondingArea; 35 | 36 | public Junction(String name, Unitable units, Double nodeElevation, Double maximumDepthNode, 37 | Double initialDepthnode, Double maximumDepthSurcharge, Double pondingArea) { 38 | 39 | super(name); 40 | this.nodeUnits = units; 41 | this.nodeElevation = nodeElevation; 42 | 43 | this.maximumDepthNode = maximumDepthNode; 44 | this.initialDepthnode = initialDepthnode; 45 | this.maximumDepthSurcharge = maximumDepthSurcharge; 46 | this.pondingArea = pondingArea; 47 | } 48 | 49 | public Junction(String name, Unitable units, String INPfile) throws ConfigurationException { 50 | 51 | super(name); 52 | interfaceINP = new JunctionINP(INPfile); 53 | this.nodeUnits = units; 54 | 55 | this.nodeElevation = Double.valueOf( ((JunctionINP) interfaceINP).nodeElev(INPfile, name) ); 56 | this.maximumDepthNode = Double.valueOf( ((JunctionINP) interfaceINP).maxDepth(INPfile, name) ); 57 | this.initialDepthnode = Double.valueOf( ((JunctionINP) interfaceINP).initDepth(INPfile, name) ); 58 | this.maximumDepthSurcharge = Double.valueOf( ((JunctionINP) interfaceINP).maxDepthSur(INPfile, name) ); 59 | this.pondingArea = Double.valueOf( ((JunctionINP) interfaceINP).pondArea(INPfile, name) ); 60 | } 61 | 62 | public Junction(String name, Unitable units, String INPfile, boolean outfall) throws ConfigurationException { 63 | super(name); 64 | 65 | interfaceINP = new OutfallINP(INPfile); 66 | this.nodeUnits = units; 67 | 68 | this.nodeElevation = Double.valueOf( ((OutfallINP) interfaceINP).nodeElev(INPfile, name) ); 69 | this.maximumDepthNode = Double.valueOf( ((OutfallINP) interfaceINP).maxDepth(INPfile, name) ); 70 | this.initialDepthnode = Double.valueOf( ((OutfallINP) interfaceINP).initDepth(INPfile, name) ); 71 | this.maximumDepthSurcharge = Double.valueOf( ((OutfallINP) interfaceINP).maxDepthSur(INPfile, name) ); 72 | this.pondingArea = Double.valueOf( ((OutfallINP) interfaceINP).pondArea(INPfile, name) ); 73 | } 74 | 75 | @Override 76 | public void sumFlowRate(HashMap> newFlowRate) { 77 | 78 | for (Integer id : newFlowRate.keySet()) { 79 | if (!nodeFlowRate.containsKey(id)) { 80 | nodeFlowRate.put(id, new LinkedHashMap<>()); 81 | } 82 | for (Instant time : newFlowRate.get(id).keySet()) { 83 | Double oldFLowRate = nodeFlowRate.get(id).get(time); 84 | double value; 85 | if (oldFLowRate == null) { 86 | value = newFlowRate.get(id).get(time); 87 | } else { 88 | value = newFlowRate.get(id).get(time) + oldFLowRate; 89 | } 90 | LinkedHashMap oldLHM = nodeFlowRate.get(id); 91 | oldLHM.put(time, value); 92 | nodeFlowRate.put(id, oldLHM); 93 | } 94 | } 95 | } 96 | 97 | @Override 98 | public HashMap> getFlowRate() { 99 | return this.nodeFlowRate; 100 | } 101 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/Outfall.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 22 | import org.altervista.growworkinghard.jswmm.inpparser.objects.OutfallINP; 23 | import org.apache.commons.configuration2.ex.ConfigurationException; 24 | 25 | import java.time.Instant; 26 | import java.util.HashMap; 27 | import java.util.LinkedHashMap; 28 | 29 | public class Outfall extends AbstractNode { 30 | 31 | Double fixedStage; 32 | LinkedHashMap tidalCurve; 33 | LinkedHashMap stageTimeseries; 34 | boolean gated; 35 | String routeTo; 36 | 37 | //TODO solve the conflict with tidal/timeseries 38 | 39 | public Outfall(String name, Unitable units, Double nodeElevation, Double fixedStage, 40 | LinkedHashMap tidalCurve, LinkedHashMap stageTimeseries, 41 | boolean gated, String routeTo) { 42 | 43 | super(name); 44 | this.nodeUnits = units; 45 | this.nodeElevation = nodeElevation; 46 | 47 | this.fixedStage = fixedStage; 48 | this.tidalCurve = tidalCurve; 49 | this.stageTimeseries = stageTimeseries; 50 | this.gated = gated; 51 | this.routeTo = routeTo; 52 | } 53 | 54 | public Outfall(String name, Unitable units, String INPfile) throws ConfigurationException { 55 | 56 | super(name); 57 | interfaceINP = new OutfallINP(INPfile); 58 | 59 | this.nodeUnits = units; 60 | this.nodeElevation = Double.valueOf( ((OutfallINP) interfaceINP).nodeElev(INPfile, name) ); 61 | 62 | this.fixedStage = Double.valueOf( ((OutfallINP) interfaceINP).fixedStage(INPfile, name) ); 63 | this.tidalCurve = null; 64 | this.stageTimeseries = null; 65 | this.gated = Boolean.parseBoolean( ((OutfallINP) interfaceINP).fixedStage(INPfile, name) ); 66 | this.routeTo = ((OutfallINP) interfaceINP).fixedStage(INPfile, name); 67 | } 68 | 69 | @Override 70 | public void sumFlowRate(HashMap> newFlowRate) { 71 | throw new NullPointerException("Nothing implemented yet"); 72 | } 73 | 74 | @Override 75 | public HashMap> getFlowRate() { 76 | throw new NullPointerException("Nothing implemented yet"); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/RainfallDependentInfiltrationInflow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | public class RainfallDependentInfiltrationInflow implements ExternalInflow { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydraulics/nodeObject/Storage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject; 20 | 21 | import java.time.Instant; 22 | import java.util.HashMap; 23 | import java.util.LinkedHashMap; 24 | 25 | public class Storage extends AbstractNode { 26 | 27 | public Storage(String name) { 28 | super(name); 29 | } 30 | 31 | @Override 32 | public void sumFlowRate(HashMap> newFlowRate) { 33 | throw new NullPointerException("Nothing implemented yet"); 34 | } 35 | 36 | @Override 37 | public HashMap> getFlowRate() { 38 | throw new NullPointerException("Nothing implemented yet"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/AbstractSubcatchment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 23 | import org.altervista.growworkinghard.jswmm.inpparser.DataFromFile; 24 | import org.altervista.growworkinghard.jswmm.inpparser.INPparser; 25 | 26 | public abstract class AbstractSubcatchment extends INPparser { 27 | 28 | protected String name; 29 | 30 | Unitable subcatchmentUnits; 31 | Datetimeable subcatchmentTime; 32 | 33 | DataFromFile interfaceINP; 34 | 35 | public AbstractSubcatchment(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getName() { 40 | return this.name; 41 | } 42 | 43 | public void setSubcatchmentUnits(Unitable subcatchmentUnits) { 44 | this.subcatchmentUnits = subcatchmentUnits; 45 | } 46 | 47 | public void setSubcatchmentTime(Datetimeable subcatchmentTime) { 48 | this.subcatchmentTime = subcatchmentTime; 49 | } 50 | 51 | public Unitable getSubcatchmentUnits() { 52 | return subcatchmentUnits; 53 | } 54 | 55 | public Datetimeable getSubcatchmentTime() { 56 | return subcatchmentTime; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/Area.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.ReceiverRunoff.ReceiverRunoff; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 23 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 24 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 25 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 26 | import org.altervista.growworkinghard.jswmm.inpparser.objects.AreaINP; 27 | import org.apache.commons.configuration2.ex.ConfigurationException; 28 | 29 | import java.time.Instant; 30 | import java.util.HashMap; 31 | import java.util.LinkedHashMap; 32 | import java.util.LinkedList; 33 | import java.util.List; 34 | 35 | public class Area extends AbstractSubcatchment { 36 | 37 | List receivers; 38 | 39 | RunoffSolver runoffSolver; 40 | 41 | Double characteristicWidth; 42 | Double areaSlope; 43 | //Double curbLength; 44 | 45 | HashMap> subareas; 46 | HashMap> totalAreaFlowRate; 47 | 48 | public Area(String areaName, Integer curveId, Unitable units, Datetimeable dateTime, RunoffSolver runoffSolver, 49 | Double characteristicWidth, Double areaSlope, HashMap> subareas, boolean report) { 50 | 51 | super(areaName); 52 | this.setSubcatchmentUnits(units); 53 | this.setSubcatchmentTime(dateTime); 54 | 55 | this.runoffSolver = runoffSolver; 56 | 57 | this.characteristicWidth = characteristicWidth; 58 | this.areaSlope = areaSlope; 59 | this.subareas = new HashMap<>(subareas); 60 | this.totalAreaFlowRate = new LinkedHashMap<>(); 61 | 62 | Instant startSimDate = this.getSubcatchmentTime().getDateTime(AvailableDateTypes.startDate); 63 | for (Subarea subarea : this.subareas.get(curveId)) { 64 | subarea.setAreaFlowRate(curveId, startSimDate, 0.0); 65 | subarea.setRunoffDepth(curveId, startSimDate, 0.0); 66 | subarea.setTotalDepth(curveId, startSimDate, 0.0); 67 | } 68 | } 69 | 70 | public Area(String areaName, Integer numberOfCurves, Unitable units, Datetimeable dateTime, 71 | RunoffSolver runoffSolver, String INPfile) throws ConfigurationException { 72 | 73 | super(areaName); 74 | 75 | interfaceINP = new AreaINP(INPfile); 76 | 77 | this.setSubcatchmentUnits(units); 78 | this.setSubcatchmentTime(dateTime); 79 | 80 | this.runoffSolver = runoffSolver; 81 | 82 | this.characteristicWidth = Double.parseDouble( ((AreaINP) interfaceINP).width(INPfile, name) ); 83 | this.areaSlope = Double.parseDouble( ((AreaINP) interfaceINP).slope(INPfile, name) ); 84 | 85 | double subcatchmentArea = Double.parseDouble( ((AreaINP) interfaceINP).subcatchArea(INPfile, name) ); 86 | double imperviousPercentage = Double.parseDouble( ((AreaINP) interfaceINP).impPerc(INPfile, name) ); 87 | double imperviousWOstoragePercentage = Double.parseDouble( ((AreaINP) interfaceINP).impWOstoPerc(INPfile, name) ); 88 | double depressionStoragePervious = Double.parseDouble( ((AreaINP) interfaceINP).dsPerv(INPfile, name) ); 89 | double depressionStorageImpervious = Double.parseDouble( ((AreaINP) interfaceINP).dsImperv(INPfile, name) ); 90 | double roughnessCoefficientPervious = Double.parseDouble( ((AreaINP) interfaceINP).roughPerv(INPfile, name) ); 91 | double roughnessCoefficientImpervious = Double.parseDouble( ((AreaINP) interfaceINP).roughImperv(INPfile, name) ); 92 | 93 | String routeTo = ((AreaINP) interfaceINP).routeTo(INPfile, name); 94 | String perviousTo; 95 | String imperviousTo; 96 | double percentageFromPervious; 97 | double percentageFromImpervious; 98 | 99 | switch (routeTo) { 100 | case "IMPERVIOUS": 101 | perviousTo = "IMPERVIOUS"; 102 | imperviousTo = "OUTLET"; 103 | percentageFromPervious = Double.parseDouble( ((AreaINP) interfaceINP).routeToPerc(name, INPfile) ); 104 | percentageFromImpervious = 1.0; 105 | break; 106 | case "PERVIOUS": 107 | perviousTo = "OUTLET"; 108 | imperviousTo = "PERVIOUS"; 109 | percentageFromImpervious = Double.parseDouble( ((AreaINP) interfaceINP).routeToPerc(name, INPfile) ); 110 | percentageFromPervious = 1.0; 111 | break; 112 | default: 113 | perviousTo = "OUTLET"; 114 | imperviousTo = "OUTLET"; 115 | percentageFromPervious = 1.0; 116 | percentageFromImpervious = 1.0; 117 | } 118 | 119 | this.subareas = new HashMap<>(); 120 | for (int curveId = 1; curveId<=numberOfCurves; curveId++) { 121 | this.subareas.put(curveId, divideAreas(imperviousPercentage, subcatchmentArea, 122 | imperviousWOstoragePercentage, depressionStoragePervious, depressionStorageImpervious, 123 | roughnessCoefficientPervious, roughnessCoefficientImpervious, 124 | perviousTo, imperviousTo, percentageFromPervious, percentageFromImpervious)); 125 | 126 | Instant startSimDate = this.getSubcatchmentTime().getDateTime(AvailableDateTypes.startDate); 127 | for (Subarea subarea : this.subareas.get(curveId)) { 128 | subarea.setAreaFlowRate(curveId, startSimDate, 0.0); 129 | subarea.setRunoffDepth(curveId, startSimDate, 0.0); 130 | subarea.setTotalDepth(curveId, startSimDate, 0.0); 131 | } 132 | } 133 | this.totalAreaFlowRate = new LinkedHashMap<>(); 134 | } 135 | 136 | public LinkedHashMap evaluateTotalFlowRate(Integer id) { 137 | //check if totalArea contain the rainfallTimeId 138 | if (!totalAreaFlowRate.containsKey(id)) { 139 | totalAreaFlowRate.put(id, new LinkedHashMap<>()); 140 | } 141 | //sum the volume of each subarea as product of the flowRate and the subarea's area 142 | for(Subarea subarea : subareas.get(id)) { 143 | 144 | LinkedHashMap subareaFlowRate = subarea.getFlowRate().get(id); 145 | for (Instant time : subareaFlowRate.keySet()) { 146 | Double oldFLowRate = totalAreaFlowRate.get(id).get(time); 147 | double value; 148 | if (oldFLowRate == null) { 149 | value = subareaFlowRate.get(time) * subarea.subareaArea * 10.0;// [m^3/s] 150 | } else { 151 | value = oldFLowRate + subareaFlowRate.get(time) * subarea.subareaArea * 10.0;// [m^3/s] 152 | } 153 | LinkedHashMap upgradedLHM = totalAreaFlowRate.get(id); 154 | upgradedLHM.put(time, value); 155 | totalAreaFlowRate.put(id, upgradedLHM); 156 | } 157 | } 158 | return totalAreaFlowRate.get(id); 159 | } 160 | 161 | public HashMap> getSubareas() { 162 | return subareas; 163 | } 164 | 165 | public void evaluateRunoffFlowRate(HashMap> adaptedRainfallData) { 166 | 167 | Instant startTime = getSubcatchmentTime().getDateTime(AvailableDateTypes.startDate); 168 | Instant totalTime = getSubcatchmentTime().getDateTime(AvailableDateTypes.endDate); 169 | long runoffStep = getSubcatchmentTime().getDateTime(AvailableDateTypes.stepSize); 170 | 171 | for ( Instant currentTime = startTime; currentTime.isBefore(totalTime); currentTime = currentTime.plusSeconds(runoffStep)) { 172 | 173 | for (Integer identifier : adaptedRainfallData.keySet()) { 174 | 175 | double rainfall = adaptedRainfallData.get(identifier).get(currentTime); 176 | for (Subarea subarea : subareas.get(identifier)) { 177 | subarea.setDepthFactor(areaSlope, characteristicWidth); 178 | subarea.evaluateFlowRate(identifier, rainfall, 0.0, 179 | currentTime, runoffSolver, areaSlope, characteristicWidth); //TODO evaporation!! 180 | } 181 | } 182 | } 183 | } 184 | 185 | private List divideAreas(Double imperviousPercentage, Double subcatchmentArea, 186 | Double imperviousWOstoragePercentage, Double depressionStoragePervious, Double depressionStorageImpervious, 187 | Double roughnessCoefficientPervious, Double roughnessCoefficientImpervious, 188 | String perviousTo, String imperviousTo, Double percentageFromPervious, Double percentageFromImpervious) { 189 | 190 | Double imperviousWOStorageArea = subcatchmentArea * imperviousPercentage * imperviousWOstoragePercentage; 191 | Double imperviousWStorageArea = subcatchmentArea * imperviousPercentage - imperviousWOStorageArea; 192 | double perviousArea = subcatchmentArea * (1-imperviousPercentage); 193 | 194 | List tmpSubareas = new LinkedList<>(); 195 | if(imperviousPercentage == 0.0) { 196 | tmpSubareas.add(new Pervious(name, subcatchmentUnits, subcatchmentTime, perviousArea, depressionStoragePervious, 197 | roughnessCoefficientImpervious, null, null, null)); 198 | } 199 | else if(imperviousPercentage == 1.0) { 200 | if (imperviousWOstoragePercentage != 0.0) { 201 | tmpSubareas.add(new ImperviousWithoutStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 202 | roughnessCoefficientImpervious, null, null)); 203 | } 204 | if (imperviousWOstoragePercentage != 1.0) { 205 | tmpSubareas.add(new ImperviousWithStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 206 | depressionStorageImpervious, roughnessCoefficientImpervious, null, null)); 207 | } 208 | 209 | } 210 | else { 211 | if (perviousTo.equals("IMPERVIOUS")) { 212 | tmpSubareas.add(new ImperviousWithoutStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 213 | roughnessCoefficientImpervious, null, null)); 214 | 215 | List tmpConnections = null; 216 | tmpConnections.add(new Pervious(name, subcatchmentUnits, subcatchmentTime, perviousArea, depressionStoragePervious, 217 | roughnessCoefficientPervious, null, null, null)); 218 | 219 | tmpSubareas.add(new ImperviousWithStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 220 | depressionStorageImpervious, roughnessCoefficientImpervious, percentageFromPervious, 221 | tmpConnections)); 222 | } 223 | else if(perviousTo.equals("OUTLET")) { 224 | tmpSubareas.add(new Pervious(name, subcatchmentUnits, subcatchmentTime, perviousArea, depressionStoragePervious, 225 | roughnessCoefficientPervious, null, null, null)); 226 | } 227 | 228 | if (imperviousTo.equals("PERVIOUS")) { 229 | 230 | List tmpConnections = null; 231 | tmpConnections.add(new ImperviousWithoutStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 232 | roughnessCoefficientImpervious, null, null)); 233 | tmpConnections.add(new ImperviousWithStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 234 | depressionStorageImpervious, roughnessCoefficientImpervious, percentageFromPervious, 235 | tmpConnections)); 236 | 237 | tmpSubareas.add(new Pervious(name, subcatchmentUnits, subcatchmentTime, perviousArea, depressionStoragePervious, roughnessCoefficientPervious, 238 | percentageFromImpervious, tmpConnections, null)); 239 | } 240 | else if (imperviousTo.equals("OUTLET")) { 241 | tmpSubareas.add(new ImperviousWithStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 242 | depressionStorageImpervious, roughnessCoefficientImpervious, null, null)); 243 | tmpSubareas.add(new ImperviousWithoutStorage(name, subcatchmentUnits, subcatchmentTime, imperviousWStorageArea, imperviousWOStorageArea, 244 | roughnessCoefficientImpervious, null, null)); 245 | } 246 | } 247 | return tmpSubareas; 248 | } 249 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/ImperviousWithStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 23 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 24 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 25 | 26 | import java.time.Instant; 27 | import java.util.HashMap; 28 | import java.util.List; 29 | 30 | public class ImperviousWithStorage extends Subarea { 31 | 32 | Double totalImperviousArea; 33 | 34 | public ImperviousWithStorage(String name, Unitable units, Datetimeable time, Double imperviousWStorageArea, 35 | Double imperviousWOStorageArea, Double depressionStorageImpervious, 36 | Double roughnessCoefficient, Double percentageRouted, List connections) { 37 | 38 | super(name, units, time, imperviousWStorageArea, depressionStorageImpervious, roughnessCoefficient, percentageRouted, connections); 39 | this.totalImperviousArea = imperviousWStorageArea + imperviousWOStorageArea; 40 | } 41 | 42 | @Override 43 | public void setDepthFactor(Double subareaSlope, Double characteristicWidth) { 44 | double depthFactor = 1.0; 45 | 46 | if (subareaConnections != null) { 47 | for (Subarea connections : subareaConnections) { 48 | connections.setDepthFactor(subareaSlope, characteristicWidth); 49 | depthFactor = ( Math.sqrt(subareaSlope) * characteristicWidth ) / 50 | (roughnessCoefficient * totalImperviousArea); 51 | } 52 | } 53 | else { 54 | depthFactor = (Math.sqrt(subareaSlope) * characteristicWidth) / (roughnessCoefficient * totalImperviousArea); 55 | } 56 | 57 | this.depthFactor = 1E-6 * depthFactor; // [ mm^(-2/3)/s ] 58 | } 59 | 60 | @Override 61 | Double getWeightedFlowRate(Integer identifier, Instant currentTime) { 62 | 63 | double weightedFlowRate = flowRate.get(identifier).get(currentTime) * subareaArea * percentageRouted; 64 | return weightedFlowRate; 65 | } 66 | 67 | @Override 68 | void evaluateNextStep(Integer id, Instant currentTime, RunoffSolver runoffSolver, Double rainfall, 69 | Double evaporation, Double subareaSlope, Double characteristicWidth) { 70 | 71 | Long runoffStepSize =getSubcatchmentTime().getDateTime(AvailableDateTypes.stepSize); 72 | Instant nextTime = currentTime.plusSeconds(runoffStepSize); 73 | 74 | double totalDepthCurrent = totalDepth.get(id).get(currentTime); 75 | double runoffDepthCurrent = runoffDepth.get(id).get(currentTime); 76 | double areaFlowRateCurrent = getFlowRate().get(id).get(currentTime); 77 | 78 | Double moistureVolume = rainfall * runoffStepSize + totalDepthCurrent; 79 | 80 | if(evaporation != 0.0) { 81 | evaporation = Math.max(evaporation, totalDepthCurrent/runoffStepSize); 82 | } 83 | 84 | setExcessRainfall(id, rainfall - evaporation); 85 | 86 | if(evaporation * runoffStepSize >= moistureVolume) { 87 | setTotalDepth(id, nextTime, totalDepthCurrent); 88 | setRunoffDepth(id, nextTime, runoffDepthCurrent); 89 | setAreaFlowRate(id, nextTime, areaFlowRateCurrent); 90 | } 91 | else { 92 | if (getExcessRainfall(id) * runoffStepSize <= depressionStorage - totalDepthCurrent) { 93 | 94 | setTotalDepth(id, nextTime, totalDepth.get(id).get(currentTime) + 95 | getExcessRainfall(id) * runoffStepSize); 96 | setRunoffDepth(id, nextTime, runoffDepth.get(id).get(currentTime) + 0.0); 97 | setAreaFlowRate(id, nextTime, getFlowRate().get(id).get(currentTime) + 0.0); 98 | } else { 99 | runoffODEsolver(id, currentTime, nextTime, getExcessRainfall(id), runoffSolver); 100 | setAreaFlowRate(id, nextTime, evaluateNextFlowRate(subareaSlope, characteristicWidth, 101 | runoffDepth.get(id).get(nextTime))); 102 | } 103 | } 104 | } 105 | 106 | @Override 107 | Double evaluateNextFlowRate(Double subareaSlope, Double characteristicWidth, Double currentDepth) { 108 | double unitsFactor = 1E-6; //[mm/s] 109 | 110 | return unitsFactor * ( Math.sqrt(subareaSlope) * characteristicWidth * 111 | Math.pow(currentDepth, 5.0/3.0) ) / (totalImperviousArea * roughnessCoefficient); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/ImperviousWithoutStorage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 23 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 24 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 25 | 26 | import java.time.Instant; 27 | import java.util.HashMap; 28 | import java.util.List; 29 | 30 | public class ImperviousWithoutStorage extends Subarea { 31 | 32 | Double totalImperviousArea; 33 | 34 | public ImperviousWithoutStorage(String name, Unitable units, Datetimeable time, Double imperviousWStorageArea, 35 | Double imperviousWOStorageArea, Double roughnessCoefficient, 36 | Double percentageRouted, List connections) { 37 | 38 | super(name, units, time, imperviousWOStorageArea, null, roughnessCoefficient, percentageRouted, connections); 39 | this.totalImperviousArea = imperviousWStorageArea + imperviousWOStorageArea; 40 | } 41 | 42 | @Override 43 | public void setDepthFactor(Double subareaSlope, Double characteristicWidth) { 44 | double depthFactor = 0.0; 45 | if (subareaConnections != null) { 46 | 47 | for (Subarea connections : subareaConnections) { 48 | connections.setDepthFactor(subareaSlope, characteristicWidth); 49 | 50 | depthFactor = Math.pow(subareaSlope, 0.5) * 51 | characteristicWidth / (roughnessCoefficient * totalImperviousArea); 52 | } 53 | } 54 | else { 55 | depthFactor = (Math.pow(subareaSlope, 0.5) * characteristicWidth) / (roughnessCoefficient * totalImperviousArea); 56 | } 57 | 58 | //if ( super.getUnits().equals(UnitsSWMM.CMS) ){ 59 | double CMSdepthFactor = 1E-6; 60 | this.depthFactor = CMSdepthFactor * depthFactor; // [ mm^(-2/3)/s ] 61 | //} 62 | } 63 | 64 | @Override 65 | Double getWeightedFlowRate(Integer identifier, Instant currentTime) { 66 | double weightedFlowRate = flowRate.get(identifier).get(currentTime) * subareaArea * percentageRouted; 67 | /*if (projectUnits.getProjectUnits() == CMS) { 68 | weightedFlowRate = weightedFlowRate * 1E10; // [mm^3/s] 69 | }*/ 70 | return weightedFlowRate; 71 | } 72 | 73 | @Override 74 | void evaluateNextStep(Integer id, Instant currentTime, RunoffSolver runoffSolver, Double rainfall, Double evaporation, 75 | Double subareaSlope, Double characteristicWidth) { 76 | 77 | Long runoffStepSize = getSubcatchmentTime().getDateTime(AvailableDateTypes.stepSize); 78 | Instant nextTime = currentTime.plusSeconds(runoffStepSize); 79 | Double moistureVolume = rainfall * runoffStepSize + runoffDepth.get(id).get(currentTime); 80 | 81 | if(evaporation != 0.0) { 82 | evaporation = Math.max(evaporation, totalDepth.get(id).get(currentTime) / runoffStepSize); 83 | } 84 | 85 | setExcessRainfall(id, rainfall - evaporation); 86 | 87 | if(evaporation * runoffStepSize >= moistureVolume) { 88 | setTotalDepth(id, nextTime, totalDepth.get(id).get(currentTime)); 89 | setRunoffDepth(id, nextTime, runoffDepth.get(id).get(currentTime)); 90 | setAreaFlowRate(id, nextTime, getFlowRate().get(id).get(currentTime)); 91 | } 92 | else { 93 | runoffODEsolver(id, currentTime, nextTime, getExcessRainfall(id), runoffSolver); 94 | setAreaFlowRate( id, nextTime, evaluateNextFlowRate(subareaSlope, characteristicWidth, 95 | runoffDepth.get(id).get(nextTime)) ); 96 | } 97 | } 98 | 99 | Double evaluateNextFlowRate(Double subareaSlope, Double characteristicWidth, Double currentDepth) { 100 | double unitsFactor = 1.0; 101 | //if (super.getUnits().equals(UnitsSWMM.CMS) ){ 102 | unitsFactor = 1E-6; //[mm/s] 103 | //} 104 | return unitsFactor * Math.pow(subareaSlope, 0.5) * characteristicWidth * 105 | Math.pow(currentDepth, 5.0/3.0) / (totalImperviousArea * roughnessCoefficient); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/Pervious.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 23 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 24 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 25 | 26 | import java.time.Instant; 27 | import java.util.HashMap; 28 | import java.util.List; 29 | 30 | public class Pervious extends Subarea { 31 | 32 | Double infiltration = 0.0; 33 | 34 | public Pervious(String name, Unitable units, Datetimeable time, Double area, Double depressionStorage, Double roughnessCoefficient, 35 | Double percentageRouted, List connections, Double infiltration) { 36 | 37 | super(name, units, time, area, depressionStorage, roughnessCoefficient, percentageRouted, connections); 38 | this.infiltration = infiltration; 39 | } 40 | 41 | @Override 42 | public void setDepthFactor(Double subareaSlope, Double characteristicWidth) { 43 | double depthFactor = 0.0; 44 | if (subareaConnections != null) { 45 | for (Subarea connections : subareaConnections) { 46 | connections.setDepthFactor(subareaSlope, characteristicWidth); 47 | depthFactor = Math.pow(subareaSlope, 0.5) * 48 | characteristicWidth / (roughnessCoefficient * subareaArea); 49 | } 50 | } 51 | else { 52 | depthFactor = (Math.pow(subareaSlope, 0.5) * characteristicWidth) / (roughnessCoefficient * subareaArea); 53 | } 54 | 55 | //if ( super.getUnits().equals(UnitsSWMM.CMS) ) { 56 | this.depthFactor = 1E-6 * depthFactor; // [ mm^(-2/3)/s ] 57 | //} 58 | } 59 | 60 | @Override 61 | Double getWeightedFlowRate(Integer identifier, Instant currentTime) { 62 | double weightedFlowRate = flowRate.get(identifier).get(currentTime) * subareaArea * percentageRouted; 63 | // if (projectUnits.getProjectUnits() == CMS) { 64 | // weightedFlowRate = weightedFlowRate * 1E10; // [mm/s] 65 | // } 66 | return weightedFlowRate; 67 | } 68 | 69 | @Override 70 | void evaluateNextStep(Integer id, Instant currentTime, RunoffSolver runoffSolver, Double rainfall, Double evaporation, 71 | Double subareaSlope, Double characteristicWidth) { 72 | 73 | Long runoffStepSize = getSubcatchmentTime().getDateTime(AvailableDateTypes.stepSize); 74 | Instant nextTime = currentTime.plusSeconds(runoffStepSize); 75 | 76 | double totalDepthCurrent = totalDepth.get(id).get(currentTime); 77 | double runoffDepthCurrent = runoffDepth.get(id).get(currentTime); 78 | double areaFlowRateCurrent = getFlowRate().get(id).get(currentTime); 79 | 80 | Double moistureVolume = rainfall * runoffStepSize + totalDepthCurrent; 81 | 82 | if(evaporation != 0.0) { 83 | evaporation = Math.max(evaporation, totalDepthCurrent/runoffStepSize); 84 | } 85 | //infiltration 86 | //excessRainfall = rainfall - evaporation - infiltration; 87 | 88 | setExcessRainfall(id, rainfall - evaporation); 89 | 90 | if(evaporation * runoffStepSize >= moistureVolume) { 91 | setTotalDepth(id, nextTime, totalDepthCurrent); 92 | setRunoffDepth(id, nextTime, runoffDepthCurrent); 93 | setAreaFlowRate(id, nextTime, areaFlowRateCurrent); 94 | } 95 | else { 96 | if (excessRainfall.get(id) * runoffStepSize <= depressionStorage - totalDepth.get(id).get(currentTime)) { 97 | setTotalDepth(id, nextTime, totalDepthCurrent + getExcessRainfall(id) * runoffStepSize); 98 | setRunoffDepth(id, nextTime, runoffDepthCurrent); 99 | setAreaFlowRate(id, nextTime, areaFlowRateCurrent); 100 | } else { 101 | runoffODEsolver(id, currentTime, nextTime, getExcessRainfall(id), runoffSolver); 102 | setAreaFlowRate(id, nextTime, evaluateNextFlowRate(subareaSlope, characteristicWidth, 103 | runoffDepth.get(id).get(nextTime))); 104 | 105 | } 106 | } 107 | } 108 | 109 | Double evaluateNextFlowRate(Double subareaSlope, Double characteristicWidth, Double currentDepth) { 110 | double unitsFactor = 1.0; 111 | //if (super.getUnits().equals(UnitsSWMM.CMS) ) { 112 | unitsFactor = 1E-6; //[mm/s] 113 | //} 114 | return unitsFactor * Math.pow(subareaSlope, 0.5) * characteristicWidth * 115 | Math.pow(currentDepth, 5.0/3.0) / (subareaArea * roughnessCoefficient); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/Subarea.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.units.Unitable; 23 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 24 | 25 | import java.time.Instant; 26 | import java.util.*; 27 | 28 | public abstract class Subarea extends AbstractSubcatchment { 29 | 30 | Double subareaArea; 31 | Double depthFactor; 32 | Double roughnessCoefficient; 33 | Double percentageRouted; 34 | Double depressionStorage; 35 | 36 | List subareaConnections; 37 | 38 | HashMap> totalDepth; //[mm] 39 | HashMap> runoffDepth; //[mm] 40 | 41 | HashMap> flowRate; //[mm/s] 42 | HashMap excessRainfall; 43 | 44 | public Subarea(String areaName, Unitable units, Datetimeable time, Double subareaArea, Double depressionStorage, Double roughnessCoefficient, 45 | Double percentageRouted, List subareaConnections) { 46 | 47 | super(areaName); 48 | this.subcatchmentUnits = units; 49 | this.subcatchmentTime = time; 50 | 51 | this.subareaArea = subareaArea; 52 | this.depressionStorage = depressionStorage; 53 | this.roughnessCoefficient = roughnessCoefficient; 54 | this.percentageRouted = percentageRouted; 55 | this.subareaConnections = subareaConnections; 56 | 57 | this.totalDepth = new HashMap<>(); 58 | this.runoffDepth = new HashMap<>(); 59 | this.flowRate = new HashMap<>(); 60 | } 61 | 62 | public HashMap> getFlowRate() { 63 | return flowRate; 64 | } 65 | 66 | public void setTotalDepth(Integer id, Instant time, Double depthValue) { 67 | if (!totalDepth.containsKey(id)) { 68 | totalDepth.put(id, new LinkedHashMap<>()); 69 | } 70 | LinkedHashMap oldLHM = totalDepth.get(id); 71 | oldLHM.put(time, depthValue); 72 | totalDepth.put(id, oldLHM); 73 | } 74 | 75 | public void setRunoffDepth(Integer id, Instant time, Double depthValue) { 76 | if (!runoffDepth.containsKey(id)) { 77 | runoffDepth.put(id, new LinkedHashMap<>()); 78 | } 79 | LinkedHashMap oldLHM = runoffDepth.get(id); 80 | oldLHM.put(time, depthValue); 81 | runoffDepth.put(id, oldLHM); 82 | } 83 | 84 | public void setAreaFlowRate(Integer id, Instant time, Double flowValue) { //[mm/s] 85 | double unitsFactor = 1.0; 86 | // if ( projectUnits.getProjectUnits() == CMS ) { 87 | // unitsFactor = 1.0E-5; 88 | // } 89 | if (!flowRate.containsKey(id)) { 90 | flowRate.put(id, new LinkedHashMap<>()); 91 | } 92 | LinkedHashMap oldLHM = flowRate.get(id); 93 | oldLHM.put(time, flowValue * unitsFactor); 94 | flowRate.put(id, oldLHM); 95 | } 96 | 97 | public void setExcessRainfall(Integer id, Double value) { 98 | if (excessRainfall == null) { 99 | this.excessRainfall = new HashMap<>(); 100 | } 101 | this.excessRainfall.put(id, value); 102 | } 103 | 104 | public Double getExcessRainfall(Integer id) { 105 | return this.excessRainfall.get(id); 106 | } 107 | 108 | public abstract void setDepthFactor(Double subareaSlope, Double characteristicWidth); 109 | 110 | abstract Double getWeightedFlowRate(Integer identifier, Instant currentTime); 111 | 112 | public void evaluateFlowRate(Integer identifier, Double rainfall, Double evaporation, Instant currentTime, 113 | RunoffSolver runoffSolver, Double subareaSlope, Double characteristicWidth) { 114 | Double tempPrecipitation = rainfall; 115 | if (subareaConnections != null) { 116 | tempPrecipitation = null; 117 | for (Subarea connections : subareaConnections) { 118 | connections.evaluateFlowRate(identifier, rainfall, evaporation, currentTime, 119 | runoffSolver, subareaSlope, characteristicWidth); 120 | tempPrecipitation += connections.getWeightedFlowRate(identifier, currentTime); 121 | //infiltration 122 | } 123 | tempPrecipitation /= subareaArea; 124 | } 125 | evaluateNextStep(identifier, currentTime, runoffSolver, tempPrecipitation, evaporation, 126 | subareaSlope, characteristicWidth); 127 | } 128 | 129 | 130 | /** 131 | * Method to evaluate the totalDepth, the runoffDepth and the flowRate at the node. 132 | * It takes into account the type of Subarea through override. 133 | */ 134 | abstract void evaluateNextStep(Integer identifier, Instant currentTime, RunoffSolver runoffSolver, Double rainfall, 135 | Double evaporation, Double subareaArea, Double characteristicWidth); 136 | 137 | /** 138 | * Evaluate the flowrate into the node from currentDepth and area properties 139 | * 140 | * @param subareaSlope 141 | * @param characteristicWidth 142 | * @param currentDepth 143 | * @return the evaluated flow rate 144 | */ 145 | abstract Double evaluateNextFlowRate(Double subareaSlope, Double characteristicWidth, Double currentDepth); 146 | 147 | void runoffODEsolver(Integer id, Instant currentTime, Instant nextTime, Double rainfall, RunoffSolver runoffSolver) { 148 | double[] inputValues = new double[1]; 149 | inputValues[0] = runoffDepth.get(id).get(currentTime); 150 | double[] outputValues = new double[1]; 151 | 152 | Double initialTime = (double) currentTime.getEpochSecond(); 153 | Double finalTime = (double) nextTime.getEpochSecond(); 154 | 155 | runoffSolver.setOde(rainfall, depthFactor); 156 | 157 | runoffSolver.getFirstOrderIntegrator().integrate(runoffSolver.getOde(), initialTime, inputValues, 158 | finalTime, outputValues); 159 | 160 | setRunoffDepth(id, nextTime, outputValues[0]); 161 | setTotalDepth(id, nextTime, totalDepth.get(id).get(currentTime) + (outputValues[0] - inputValues[0])); 162 | } 163 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/hydrology/subcatchment/SubareaReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment; 20 | 21 | public class SubareaReceiver { 22 | 23 | public enum SubareaReceiverRunoff { 24 | OUTLET, 25 | PERVIOUS, 26 | IMPERVIOUS 27 | } 28 | SubareaReceiverRunoff subareaReceiverRunoff; 29 | 30 | Double percentageSubareaReceiver; 31 | 32 | public SubareaReceiver(SubareaReceiverRunoff subareaReceiverRunoff, Double percentageSubareaReceiver) { 33 | this.subareaReceiverRunoff = subareaReceiverRunoff; 34 | this.percentageSubareaReceiver = percentageSubareaReceiver; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/infiltration/InfiltrationSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.infiltration; 20 | 21 | public interface InfiltrationSetup { 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/ReportSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options; 19 | 20 | import java.util.List; 21 | 22 | public class ReportSetup { 23 | 24 | boolean reportInput; 25 | boolean reportContinuity; 26 | boolean reportFlowStats; 27 | boolean reportControls; 28 | List reportSubcatchments; 29 | List reportNodes; 30 | List reportLinks; 31 | 32 | public ReportSetup(boolean reportInput, boolean reportContinuity, boolean reportFlowStats, boolean reportControls, 33 | List reportSubcatchments, List reportNodes, 34 | List reportLinks) { 35 | 36 | this.reportInput = reportInput; 37 | this.reportContinuity = reportContinuity; 38 | this.reportFlowStats = reportFlowStats; 39 | this.reportControls = reportControls; 40 | this.reportSubcatchments = reportSubcatchments; 41 | this.reportNodes = reportNodes; 42 | this.reportLinks = reportLinks; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/SWMMtimeAndUnits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Period; 21 | 22 | import java.time.Instant; 23 | 24 | public abstract class SWMMtimeAndUnits extends Period { 25 | public SWMMtimeAndUnits(Instant startDate, Instant endDate) { 26 | super(startDate, endDate); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/SteadyStateSetup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options; 19 | 20 | public interface SteadyStateSetup { 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/datetime/AvailableDateTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.datetime; 19 | 20 | public enum AvailableDateTypes { 21 | startDate, 22 | endDate, 23 | stepSize, 24 | minStep, 25 | maxStep, 26 | absoluteTolerance, 27 | relativeTolerance 28 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/datetime/Datetimeable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.options.datetime; 20 | 21 | public interface Datetimeable { 22 | 23 | void setDateTime(AvailableDateTypes type, T field); 24 | T getDateTime(AvailableDateTypes type); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/datetime/Period.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.datetime; 19 | 20 | import java.time.Instant; 21 | 22 | public class Period implements Datetimeable { 23 | 24 | private Instant startDate; 25 | private Instant endDate; 26 | 27 | public Period(Instant startDate, Instant endDate) { 28 | this.startDate = startDate; 29 | this.endDate = endDate; 30 | } 31 | 32 | public void setDateTime(AvailableDateTypes type, T field) { 33 | switch (type) { 34 | case startDate: 35 | this.startDate = (Instant) field; 36 | break; 37 | case endDate: 38 | this.endDate = (Instant) field; 39 | break; 40 | default: 41 | throw new NullPointerException("Not a defined DateType"); 42 | } 43 | } 44 | 45 | public T getDateTime(AvailableDateTypes type) { 46 | switch (type) { 47 | case startDate: 48 | return (T) this.startDate; 49 | case endDate: 50 | return (T) this.endDate; 51 | default: 52 | throw new IllegalArgumentException("Not a defined DateType"); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/datetime/PeriodStep.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.datetime; 19 | 20 | import java.time.Instant; 21 | 22 | public class PeriodStep extends Period { 23 | 24 | private Long stepSize; 25 | 26 | public PeriodStep(Instant startDate, Instant endDate, Long stepSize) { 27 | super(startDate, endDate); 28 | this.stepSize = stepSize; 29 | } 30 | 31 | public void setDateTime(AvailableDateTypes type, T field) { 32 | switch (type) { 33 | case stepSize: 34 | this.stepSize = (Long) field; 35 | break; 36 | default: 37 | super.setDateTime(type, field); 38 | } 39 | } 40 | 41 | public T getDateTime(AvailableDateTypes type) { 42 | switch ( type) { 43 | case stepSize: 44 | return (T) (Long) this.stepSize; 45 | default: 46 | return super.getDateTime(type); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/datetime/PeriodStepTolerance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.datetime; 19 | 20 | import java.time.Instant; 21 | 22 | public abstract class PeriodStepTolerance extends PeriodStep { 23 | 24 | private double minStep; 25 | private double maxStep; 26 | private double absoluteTolerance; 27 | private double relativeTolerance; 28 | 29 | public PeriodStepTolerance(Instant startDate, Instant endDate, Long stepSize) { 30 | super(startDate, endDate, stepSize); 31 | } 32 | 33 | public void setDateTime(AvailableDateTypes type, T field) { 34 | switch (type) { 35 | case minStep: 36 | this.minStep = (Double) field; 37 | break; 38 | case maxStep: 39 | this.maxStep = (Double) field; 40 | break; 41 | case absoluteTolerance: 42 | this.absoluteTolerance = (Double) field; 43 | break; 44 | case relativeTolerance: 45 | this.relativeTolerance = (Double) field; 46 | break; 47 | default: 48 | super.setDateTime(type, field); 49 | } 50 | } 51 | 52 | public T getDateTime(AvailableDateTypes type) { 53 | switch ( type) { 54 | case minStep: 55 | return (T) (Double) this.minStep; 56 | case maxStep: 57 | return (T) (Double) this.maxStep; 58 | case absoluteTolerance: 59 | return (T) (Double) this.absoluteTolerance; 60 | case relativeTolerance: 61 | return (T) (Double) this.relativeTolerance; 62 | default: 63 | return super.getDateTime(type); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/units/AvailableUnits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.units; 19 | 20 | public enum AvailableUnits { 21 | CMS, 22 | CFS; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/units/SWMMunits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.units; 19 | 20 | public class SWMMunits implements Unitable { 21 | 22 | private AvailableUnits projectUnits; 23 | 24 | public SWMMunits(AvailableUnits projectUnits) { 25 | setUnits(projectUnits); 26 | } 27 | 28 | public SWMMunits(String projectUnits) { 29 | setUnits(projectUnits); 30 | } 31 | 32 | @Override 33 | public void setUnits(T units) { 34 | if (units instanceof AvailableUnits) { 35 | setUnits((AvailableUnits) units); 36 | } 37 | else if (units instanceof String) { 38 | setUnits((String) units); 39 | } 40 | else { 41 | throw new IllegalArgumentException("Not a recognized units"); 42 | } 43 | 44 | } 45 | 46 | public void setUnits(AvailableUnits units) { 47 | switch (units) { 48 | case CMS: 49 | this.projectUnits = AvailableUnits.CMS; 50 | break; 51 | case CFS: 52 | this.projectUnits = AvailableUnits.CFS; 53 | break; 54 | default: 55 | throw new IllegalArgumentException("Not a recognized units"); 56 | } 57 | } 58 | 59 | public void setUnits(String units) { 60 | switch (units) { 61 | case "CMS": 62 | this.projectUnits = AvailableUnits.CMS; 63 | break; 64 | case "CFS": 65 | this.projectUnits = AvailableUnits.CFS; 66 | break; 67 | default: 68 | throw new IllegalArgumentException("Not a recognized units"); 69 | } 70 | } 71 | 72 | @Override 73 | public AvailableUnits getUnits() { 74 | if (projectUnits != null) { 75 | switch (projectUnits) { 76 | case CMS: 77 | return AvailableUnits.CMS; 78 | case CFS: 79 | return AvailableUnits.CFS; 80 | default: 81 | throw new IllegalArgumentException("Wrong definition of units"); 82 | } 83 | } else { 84 | throw new NullPointerException("Units not defined."); 85 | } 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/options/units/Unitable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.options.units; 19 | 20 | public interface Unitable { 21 | 22 | AvailableUnits getUnits(); 23 | void setUnits(T units); 24 | 25 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/DynamicWaveOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.OutsideSetup; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.CrossSectionType; 22 | 23 | import java.time.Instant; 24 | import java.util.HashMap; 25 | import java.util.LinkedHashMap; 26 | 27 | public class DynamicWaveOptions implements RoutingSolver { 28 | 29 | @Override 30 | public RoutedFlow routeFlowRate(Integer id, Instant currentTime, HashMap> upstreamFlow, 31 | OutsideSetup downstreamOutside, Double linkLength, Double linkRoughness, Double linkSlope, 32 | CrossSectionType crossSectionType, double routingStep) { 33 | throw new NullPointerException("Nothing implemented yet."); 34 | } 35 | 36 | @Override 37 | public double adaptTimeDelay(double routingStepSize, double timeDelay) { 38 | throw new NullPointerException("Nothing implemented yet."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/KinematicWaveOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.OutsideSetup; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.CrossSectionType; 22 | 23 | import java.time.Instant; 24 | import java.util.HashMap; 25 | import java.util.LinkedHashMap; 26 | 27 | public class KinematicWaveOptions implements RoutingSolver { 28 | 29 | @Override 30 | public RoutedFlow routeFlowRate(Integer id, Instant currentTime, HashMap> upstreamFlow, 31 | OutsideSetup downstreamOutside, Double linkLength, Double linkRoughness, Double linkSlope, 32 | CrossSectionType crossSectionType, double routingStep) { 33 | throw new NullPointerException("Work in progress."); 34 | } 35 | 36 | @Override 37 | public double adaptTimeDelay(double routingStepSize, double timeDelay) { 38 | throw new NullPointerException("Work in progress."); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/RoutedFlow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import java.time.Instant; 21 | 22 | public class RoutedFlow { 23 | Instant time; 24 | double value; 25 | 26 | public RoutedFlow(Instant time, double value) { 27 | this.time = time; 28 | this.value = value; 29 | } 30 | 31 | public Instant getTime() { 32 | return time; 33 | } 34 | 35 | public double getValue() { 36 | return value; 37 | } 38 | 39 | public void setTime(Instant time) { 40 | this.time = time; 41 | } 42 | 43 | public void setValue(double value) { 44 | this.value = value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/RoutingDateTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.PeriodStepTolerance; 22 | 23 | import java.time.Instant; 24 | 25 | public class RoutingDateTime extends PeriodStepTolerance { 26 | 27 | public RoutingDateTime(Instant startDate, Instant endDate, Long stepSize, double absTol) { 28 | super(startDate, endDate, stepSize); 29 | setDateTime(AvailableDateTypes.absoluteTolerance, absTol); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/RoutingSolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.OutsideSetup; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.CrossSectionType; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.PeriodStepTolerance; 23 | 24 | import java.time.Instant; 25 | import java.util.HashMap; 26 | import java.util.LinkedHashMap; 27 | 28 | public interface RoutingSolver { 29 | 30 | RoutedFlow routeFlowRate(Integer id, Instant currentTime, HashMap> upstreamFlow, 31 | OutsideSetup downstreamOutside, Double linkLength, Double linkRoughness, 32 | Double linkSlope, CrossSectionType crossSectionType, double routingStep); 33 | 34 | public double adaptTimeDelay(double routingStepSize, double timeDelay); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/SWMMroutingTools.java: -------------------------------------------------------------------------------- 1 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 2 | 3 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.CrossSectionType; 4 | import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; 5 | import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction; 6 | 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | class ChowTable { 11 | Double adimensionalArea; 12 | Double adimensionalSectionFactor; 13 | 14 | ChowTable(Double adimensionalArea, Double adimensionalSectionFactor) { 15 | this.adimensionalArea = adimensionalArea; 16 | this.adimensionalSectionFactor = adimensionalSectionFactor; 17 | } 18 | 19 | public Double getAdimensionalArea() { 20 | return adimensionalArea; 21 | } 22 | 23 | public Double getAdimensionalSectionFactor() { 24 | return adimensionalSectionFactor; 25 | } 26 | } 27 | 28 | public class SWMMroutingTools { 29 | 30 | private final Integer referenceTableLength; 31 | private final List relationsTable = new LinkedList<>(); 32 | 33 | public SWMMroutingTools(Integer referenceTableLength) { 34 | this.referenceTableLength = referenceTableLength; 35 | fillTables(); 36 | } 37 | 38 | private void fillTables() { 39 | for(int i = 0; i <= referenceTableLength; i++) { 40 | Double theta = 2*i*Math.PI/180; 41 | if (theta == 0.0) { 42 | relationsTable.add(new ChowTable(0.0,0.0)); 43 | } 44 | else { 45 | relationsTable.add(new ChowTable((theta-Math.sin(theta))/(2*Math.PI), 46 | Math.pow((theta-Math.sin(theta)), 5.0/3.0) / (2 * Math.PI * Math.pow(theta, 2.0/3.0)))); 47 | } 48 | } 49 | } 50 | 51 | public Double sectionFactorToArea(Double sectionFactor) { 52 | 53 | if (sectionFactor == 0.0) { 54 | return 0.0; 55 | } 56 | else { 57 | int elementCounter = 0; 58 | Double lowerSFValue = relationsTable.get(elementCounter).adimensionalSectionFactor; 59 | Double upperSFValue = null; 60 | 61 | for (ChowTable element : relationsTable) { 62 | if (element.getAdimensionalSectionFactor() < sectionFactor) { 63 | lowerSFValue = element.adimensionalSectionFactor; 64 | elementCounter++; 65 | } else { 66 | upperSFValue = element.adimensionalSectionFactor; 67 | break; 68 | } 69 | } 70 | 71 | if (upperSFValue == null) { 72 | int listSize = relationsTable.size(); 73 | upperSFValue = relationsTable.get(listSize).adimensionalSectionFactor; 74 | } 75 | 76 | double[] x = {lowerSFValue, upperSFValue}; 77 | double[] y = {relationsTable.get(elementCounter-1).getAdimensionalArea(), 78 | relationsTable.get(elementCounter).getAdimensionalArea()}; 79 | 80 | // return linear interpolation of (x,y) on sectionFactor 81 | LinearInterpolator interpolator = new LinearInterpolator(); 82 | PolynomialSplineFunction psf = interpolator.interpolate(x, y); 83 | return psf.value(sectionFactor); 84 | } 85 | } 86 | 87 | public Double areaToSectionFactor(Double area) { 88 | 89 | if (area == 0.0) { 90 | return 0.0; 91 | } 92 | else { 93 | int elementCounter = 0; 94 | Double lowerArea = relationsTable.get(elementCounter).adimensionalArea; 95 | Double upperArea = null; 96 | 97 | for (ChowTable element : relationsTable) { 98 | if (element.getAdimensionalArea() < area) { 99 | lowerArea = element.adimensionalArea; 100 | elementCounter++; 101 | } 102 | else { 103 | upperArea = element.adimensionalArea; 104 | break; 105 | } 106 | } 107 | double[] x = {lowerArea, upperArea}; 108 | double[] y = {relationsTable.get(elementCounter-1).getAdimensionalSectionFactor(), 109 | relationsTable.get(elementCounter).getAdimensionalSectionFactor()}; 110 | 111 | // return linear interpolation of (x,y) on sectionFactor 112 | LinearInterpolator interpolator = new LinearInterpolator(); 113 | PolynomialSplineFunction psf = interpolator.interpolate(x, y); 114 | return psf.value(area); 115 | } 116 | } 117 | 118 | public Double evaluateTheta(Double area, CrossSectionType crossSectionType) { 119 | 120 | Double tempTheta; 121 | Double deltaTheta; 122 | 123 | tempTheta = 0.031715 - 12.79384*area + 8.28479*Math.sqrt(area); 124 | do { 125 | deltaTheta = 2 * Math.PI * area - (tempTheta - Math.sin(tempTheta)) / (1 - Math.cos(tempTheta)); 126 | tempTheta += deltaTheta; 127 | } while (Math.abs(deltaTheta) > 0.0001); 128 | 129 | return tempTheta; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/routingDS/SteadyOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.routingDS; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.OutsideSetup; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.CrossSectionType; 22 | 23 | import java.time.Instant; 24 | import java.util.HashMap; 25 | import java.util.LinkedHashMap; 26 | 27 | public class SteadyOptions implements RoutingSolver { 28 | 29 | private SWMMroutingTools routingTools; 30 | 31 | public SteadyOptions(Integer referenceTableLength) { 32 | this.routingTools = new SWMMroutingTools(referenceTableLength); 33 | } 34 | 35 | public SteadyOptions() { 36 | this(180); 37 | } 38 | 39 | @Override 40 | public RoutedFlow routeFlowRate(Integer id, Instant currentTime, HashMap> flow, 41 | OutsideSetup downstreamOutside, Double linkLength, Double linkRoughness, 42 | Double linkSlope, CrossSectionType crossSectionType, double routingStepSize) { 43 | 44 | LinkedHashMap upstreamFlow = flow.get(id); 45 | Double dischargeFull = crossSectionType.getDischargeFull(linkRoughness, linkSlope); 46 | Double Afull = crossSectionType.getAreaFull(); 47 | 48 | final Double beta = (Math.sqrt(linkSlope) * linkRoughness) / dischargeFull; //with Gs as linkRoughness 49 | 50 | double currentFlow = upstreamFlow.get(currentTime) / dischargeFull; 51 | double area = routingTools.sectionFactorToArea(currentFlow / beta) * Afull; 52 | double celerity = currentFlow * dischargeFull / area; 53 | double timeDelay = (linkLength / celerity); 54 | 55 | double qout; 56 | if (currentFlow == 0.0) { 57 | qout = 0.0; 58 | } 59 | else if (currentFlow > 1.0) { 60 | qout = 1.0; 61 | } 62 | else { 63 | qout = currentFlow; 64 | } 65 | 66 | double currentValue = (qout * dischargeFull); 67 | 68 | if (timeDelay < routingStepSize) { 69 | return new RoutedFlow(currentTime, currentValue); 70 | } 71 | else { 72 | double downTime = adaptTimeDelay(routingStepSize, timeDelay); 73 | return new RoutedFlow(currentTime.plusSeconds((long) downTime), currentValue); 74 | 75 | } 76 | } 77 | 78 | @Override 79 | public double adaptTimeDelay(double routingStepSize, double timeDelay) { 80 | double temp = timeDelay / routingStepSize; 81 | return (int) temp * routingStepSize; 82 | } 83 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/AvailableODEmethods.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS; 20 | 21 | public enum AvailableODEmethods { 22 | DP54 23 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/DormandPrince54.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS; 20 | 21 | import oms3.annotations.*; 22 | 23 | import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; 24 | import org.apache.commons.math3.ode.FirstOrderIntegrator; 25 | import org.apache.commons.math3.ode.nonstiff.DormandPrince54Integrator; 26 | 27 | @Description("ODE solver for Manning equation over subcatchments") 28 | @Author(name = "ftt01", contact = "dallatorre.daniele@gmail.com") 29 | @Status(Status.DRAFT) 30 | @License("GPL3.0") 31 | 32 | public class DormandPrince54 implements RunoffSolver{ 33 | 34 | @Description("Precipitation data") 35 | @In 36 | private Double precipitation; 37 | 38 | @Description("Constant depth factor") 39 | @In 40 | private Double depthFactor; 41 | 42 | @Description("Initial time") 43 | @In 44 | private Double initialTime; 45 | 46 | @Description("Final time") 47 | @In 48 | private Double finalTime; 49 | 50 | @Description("Initial value") 51 | @In 52 | private double[] initialValue; 53 | 54 | @Description("Output step size") 55 | @In 56 | private Double outputStepSize; 57 | 58 | @Description("Output values") 59 | @Out 60 | private double[] outputValues; 61 | 62 | private FirstOrderIntegrator dp54; 63 | private FirstOrderDifferentialEquations ode; 64 | 65 | public DormandPrince54(Double minimumStepSize, Double maximumStepSize, 66 | Double absoluteTolerance, Double relativeTolerance){ 67 | this.dp54 = new DormandPrince54Integrator(minimumStepSize, maximumStepSize, 68 | absoluteTolerance, relativeTolerance); 69 | }; 70 | 71 | protected DormandPrince54(Double precipitation, Double depthFactor, 72 | Double minimumStepSize, Double maximumStepSize, 73 | Double absoluteTolerance, Double relativeTolerance) { 74 | 75 | this.precipitation = precipitation; 76 | this.ode = new RunoffODE(precipitation,depthFactor); 77 | this.dp54 = new DormandPrince54Integrator(minimumStepSize, maximumStepSize, 78 | absoluteTolerance, relativeTolerance); 79 | } 80 | 81 | @Override 82 | public double[] integrate(Double initialTime, double[] inputValues, 83 | Double finalTime, double[] outputValues){ 84 | dp54.integrate(ode, initialTime, inputValues, finalTime, outputValues); 85 | return outputValues; 86 | } 87 | 88 | @Override 89 | public FirstOrderIntegrator getFirstOrderIntegrator() { 90 | return this.dp54; 91 | } 92 | 93 | @Override 94 | public void setOde(Double rainfall, Double depthFactor) { 95 | this.ode = new RunoffODE(rainfall, depthFactor); 96 | } 97 | 98 | @Override 99 | public FirstOrderDifferentialEquations getOde() { 100 | return ode; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/ReceiverRunoff/AbstractReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS.ReceiverRunoff; 19 | 20 | import java.time.Instant; 21 | import java.util.LinkedHashMap; 22 | 23 | public abstract class AbstractReceiver { 24 | public abstract LinkedHashMap getRunoffInflow(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/ReceiverRunoff/NodeReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS.ReceiverRunoff; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.nodeObject.AbstractNode; 22 | import com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment.AbstractSubcatchment; 23 | 24 | public class NodeReceiver implements ReceiverRunoff { 25 | ReceiverType receiverType; 26 | AbstractNode receiverObject; 27 | Double percentage; 28 | 29 | public NodeReceiver(AbstractNode node, Double percentage) { 30 | this.receiverObject = node; 31 | this.percentage = percentage; 32 | this.receiverType = ReceiverType.NODE; 33 | } 34 | 35 | @Override 36 | public ReceiverType getReceiverType() { 37 | throw new NullPointerException("Nothing implemented yet"); 38 | 39 | } 40 | 41 | @Override 42 | public AbstractSubcatchment getReceiverObject() { 43 | throw new NullPointerException("Nothing implemented yet"); 44 | 45 | } 46 | 47 | @Override 48 | public Double getPercentage() { 49 | throw new NullPointerException("Nothing implemented yet"); 50 | 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/ReceiverRunoff/ReceiverRunoff.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS.ReceiverRunoff; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment.AbstractSubcatchment; 22 | 23 | public interface ReceiverRunoff { 24 | public enum ReceiverType { 25 | NODE, 26 | SUBCATCHMENT 27 | } 28 | 29 | public ReceiverType getReceiverType(); 30 | 31 | public AbstractSubcatchment getReceiverObject(); 32 | 33 | public Double getPercentage(); 34 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/ReceiverRunoff/SubcatchmentReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS.ReceiverRunoff; 20 | 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment.AbstractSubcatchment; 22 | 23 | public class SubcatchmentReceiver implements ReceiverRunoff { 24 | ReceiverType receiverType; 25 | AbstractSubcatchment receiverObject; 26 | Double percentage; 27 | 28 | public SubcatchmentReceiver(AbstractSubcatchment area, Double percentage) { 29 | this.receiverObject = area; 30 | this.percentage = percentage; 31 | this.receiverType = ReceiverType.SUBCATCHMENT; 32 | } 33 | 34 | @Override 35 | public ReceiverType getReceiverType() { 36 | return receiverType; 37 | } 38 | 39 | @Override 40 | public AbstractSubcatchment getReceiverObject() { 41 | return receiverObject; 42 | } 43 | 44 | @Override 45 | public Double getPercentage() { 46 | return percentage; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/RunoffODE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS; 20 | 21 | import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; 22 | import org.apache.commons.math3.util.FastMath; 23 | 24 | public class RunoffODE implements FirstOrderDifferentialEquations { 25 | 26 | private double precipitation; 27 | private double alpha; 28 | 29 | public RunoffODE(double precipitation, double alpha) { 30 | this.precipitation = precipitation; 31 | this.alpha = alpha; 32 | } 33 | 34 | public int getDimension() { 35 | return 1; 36 | } 37 | 38 | public void computeDerivatives(double t, double[] y, double[] yDot) { 39 | yDot[0] = precipitation - alpha*FastMath.pow(y[0],5.0/3.0); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/dataStructure/runoffDS/RunoffSolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | package com.github.geoframecomponents.jswmm.dataStructure.runoffDS; 20 | 21 | import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; 22 | import org.apache.commons.math3.ode.FirstOrderIntegrator; 23 | 24 | public interface RunoffSolver { 25 | 26 | FirstOrderIntegrator getFirstOrderIntegrator(); 27 | 28 | FirstOrderDifferentialEquations getOde(); 29 | 30 | void setOde(Double rainfall, Double depthFactor); 31 | 32 | double[] integrate(Double initialTime,double[] inputValues, 33 | Double finalTime, double[] outputValues); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/routing/FlowRateDispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.routing; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 22 | import oms3.annotations.Execute; 23 | import oms3.annotations.In; 24 | import oms3.annotations.InNode; 25 | import oms3.annotations.Out; 26 | 27 | import java.time.Instant; 28 | import java.util.*; 29 | 30 | public class FlowRateDispatcher { 31 | 32 | @InNode 33 | @Out 34 | public SWMMobject dataStructure; 35 | 36 | /** 37 | * HM of the flowrate to the node 38 | */ 39 | @InNode 40 | public HashMap> flowRate1; 41 | 42 | @InNode 43 | public HashMap> flowRate2; 44 | 45 | @InNode 46 | public HashMap> flowRate3; 47 | 48 | @InNode 49 | public HashMap> flowRate4; 50 | 51 | @InNode 52 | public HashMap> flowRate5; 53 | 54 | @InNode 55 | public HashMap> flowRate6; 56 | 57 | @InNode 58 | public HashMap> flowRate7; 59 | 60 | @InNode 61 | public HashMap> flowRate8; 62 | 63 | @InNode 64 | public HashMap> flowRate9; 65 | 66 | @InNode 67 | public HashMap> flowRate10; 68 | 69 | @In 70 | public String upstreamNodeName = null; 71 | 72 | @In 73 | public String linkName = null; 74 | 75 | @Execute 76 | public void run() { 77 | 78 | Long routingStepSize = dataStructure.getLinksDateTime().getDateTime(AvailableDateTypes.stepSize); 79 | Instant initialTime = dataStructure.getProjectDateTime().getDateTime(AvailableDateTypes.startDate); 80 | Instant totalTime = dataStructure.getProjectDateTime().getDateTime(AvailableDateTypes.endDate); 81 | 82 | if (flowRate1 != null) { 83 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), initialTime.getEpochSecond(), flowRate1); 84 | } 85 | 86 | if (flowRate2 != null) { 87 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 88 | initialTime.getEpochSecond(), flowRate2); 89 | } 90 | 91 | if (flowRate3 != null) { 92 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 93 | initialTime.getEpochSecond(), flowRate3); 94 | } 95 | 96 | if (flowRate4 != null) { 97 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 98 | initialTime.getEpochSecond(), flowRate4); 99 | } 100 | 101 | if (flowRate5 != null) { 102 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 103 | initialTime.getEpochSecond(), flowRate5); 104 | } 105 | 106 | if (flowRate6 != null) { 107 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 108 | initialTime.getEpochSecond(), flowRate6); 109 | } 110 | 111 | if (flowRate7 != null) { 112 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 113 | initialTime.getEpochSecond(), flowRate7); 114 | } 115 | 116 | if (flowRate8 != null) { 117 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 118 | initialTime.getEpochSecond(), flowRate8); 119 | } 120 | 121 | if (flowRate9 != null) { 122 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 123 | initialTime.getEpochSecond(), flowRate9); 124 | } 125 | 126 | if (flowRate10 != null) { 127 | dispatchFlow(routingStepSize, totalTime.getEpochSecond(), 128 | initialTime.getEpochSecond(), flowRate10); 129 | } 130 | 131 | } 132 | 133 | /** 134 | * Method to sum all flow rate to the node, upgrading the flow rate into the node and the related output stream. 135 | * @param routingStepSize 136 | * @param totalTime 137 | * @param initialTime 138 | * @param flowRate 139 | */ 140 | private void dispatchFlow(Long routingStepSize, long totalTime, long initialTime, 141 | HashMap> flowRate) { 142 | 143 | long flowRateStepSize = getTimeStep(flowRate); 144 | 145 | HashMap> newFlowRate = new HashMap<>(); 146 | if ( !routingStepSize.equals(flowRateStepSize) ) { 147 | for (Integer id : flowRate.keySet()) { 148 | LinkedHashMap currentFlowRate = dataStructure.adaptDataSeries(routingStepSize, 149 | flowRateStepSize, totalTime, initialTime, flowRate.get(id)); 150 | newFlowRate.put(id, currentFlowRate); 151 | } 152 | dataStructure.setNodeFlowRate(upstreamNodeName, newFlowRate); 153 | dataStructure.setLinkFlowRate(linkName, newFlowRate); 154 | } 155 | else { 156 | dataStructure.setNodeFlowRate(upstreamNodeName, flowRate); 157 | dataStructure.setLinkFlowRate(linkName, flowRate); 158 | } 159 | } 160 | 161 | private long getTimeStep(HashMap> flowRate) { 162 | 163 | Long flowRateStepSize = null; 164 | Set test = flowRate.keySet(); 165 | for (Iterator it = test.iterator(); it.hasNext(); ) { 166 | 167 | Integer curveId = it.next(); 168 | LinkedHashMap reorded = reorderHM(flowRate.get(curveId)); 169 | 170 | Set test3 = reorded.keySet(); 171 | for (Iterator it2 = test3.iterator(); it2.hasNext(); ) { 172 | Instant tmpInstant = it2.next(); 173 | Instant tmpInstantPlus = it2.next(); 174 | flowRateStepSize = tmpInstantPlus.minusSeconds(tmpInstant.getEpochSecond()).getEpochSecond(); 175 | break; 176 | } 177 | break; 178 | } 179 | 180 | return flowRateStepSize; 181 | } 182 | 183 | private LinkedHashMap reorderHM( LinkedHashMap flowRate ) { 184 | 185 | ArrayList flowByKey = new ArrayList<>(); 186 | Set test = flowRate.keySet(); 187 | for (Iterator it = test.iterator(); it.hasNext(); ) { 188 | Instant iter = it.next(); 189 | flowByKey.add(iter.toString()); 190 | } 191 | Collections.sort(flowByKey); 192 | 193 | LinkedHashMap sorted = new LinkedHashMap<>(); 194 | for (Iterator it = flowByKey.iterator(); it.hasNext(); ) { 195 | String stringKey = it.next(); 196 | Instant key = Instant.parse(stringKey); 197 | sorted.put(key, flowRate.get(key)); 198 | } 199 | return sorted; 200 | } 201 | 202 | public void setFlowRate1(HashMap> newFlowRate) { 203 | 204 | flowRate1 = new HashMap<>(); 205 | for (Integer id : newFlowRate.keySet()) { 206 | if (!flowRate1.containsKey(id)) { 207 | flowRate1.put(id, new LinkedHashMap<>()); 208 | } 209 | for (Instant time : newFlowRate.get(id).keySet()) { 210 | Double oldFLowRate = flowRate1.get(id).get(time); 211 | double value; 212 | if (oldFLowRate == null) { 213 | value = newFlowRate.get(id).get(time); 214 | } else { 215 | value = newFlowRate.get(id).get(time) + oldFLowRate; 216 | } 217 | LinkedHashMap oldLHM = flowRate1.get(id); 218 | oldLHM.put(time, value); 219 | flowRate1.put(id, oldLHM); 220 | } 221 | } 222 | } 223 | 224 | public void setFlowRate2(HashMap> newFlowRate) { 225 | 226 | flowRate2 = new HashMap<>(); 227 | for (Integer id : newFlowRate.keySet()) { 228 | if (!flowRate2.containsKey(id)) { 229 | flowRate2.put(id, new LinkedHashMap<>()); 230 | } 231 | for (Instant time : newFlowRate.get(id).keySet()) { 232 | Double oldFLowRate = flowRate2.get(id).get(time); 233 | double value; 234 | if (oldFLowRate == null) { 235 | value = newFlowRate.get(id).get(time); 236 | } else { 237 | value = newFlowRate.get(id).get(time) + oldFLowRate; 238 | } 239 | LinkedHashMap oldLHM = flowRate2.get(id); 240 | oldLHM.put(time, value); 241 | flowRate2.put(id, oldLHM); 242 | } 243 | } 244 | } 245 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/routing/Routing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.routing; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.Conduit; 22 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize.CommercialPipeSize; 23 | import com.github.geoframecomponents.jswmm.dataStructure.hydraulics.linkObjects.crossSections.pipeSize.Lucchese_ca; 24 | 25 | import oms3.annotations.*; 26 | 27 | import java.time.Instant; 28 | import java.util.HashMap; 29 | import java.util.LinkedHashMap; 30 | import java.util.List; 31 | 32 | import static org.junit.Assert.assertEquals; 33 | 34 | public class Routing { 35 | 36 | /** 37 | * Simulation node fields 38 | */ 39 | @In 40 | public String linkName = null; 41 | 42 | @In 43 | public String downstreamNodeName = null; 44 | 45 | /** 46 | * Link characteristics 47 | */ 48 | @In 49 | public Conduit conduit; 50 | 51 | @In 52 | public CommercialPipeSize pipeCompany = new Lucchese_ca(); 53 | 54 | /** 55 | * Data structure 56 | */ 57 | @In 58 | @Out 59 | public SWMMobject dataStructure = null; 60 | 61 | 62 | @OutNode 63 | public HashMap> routingFlowRate; 64 | 65 | @Execute 66 | public void run() { 67 | 68 | System.out.println("Routing on " + linkName); 69 | if (dataStructure != null && linkName != null) { 70 | this.conduit = dataStructure.getConduit(linkName); 71 | } else { 72 | throw new NullPointerException("Data structure is null"); 73 | } 74 | 75 | /** 76 | * Evaluate the maximum discharge over all the response curves 77 | */ 78 | double maxDischarge = conduit.evaluateMaxDischarge(); 79 | System.out.println("Q_MAX " + String.format("%.3f", maxDischarge)); 80 | 81 | /** 82 | * Dimensioning main method 83 | */ 84 | conduit.evaluateDimension(maxDischarge, pipeCompany); 85 | 86 | //route the maximum discharge to next bucket 87 | conduit.evaluateFlowRate(); 88 | 89 | routingFlowRate = conduit.getDownstreamFlowRate(); 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/runoff/PreRunoff.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.runoff; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 21 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 22 | import oms3.annotations.*; 23 | 24 | import java.time.Instant; 25 | import java.util.*; 26 | 27 | /** 28 | * PreRunoff 29 | */ 30 | public class PreRunoff { 31 | 32 | /** 33 | * Name of the area for the runoff process 34 | */ 35 | @In 36 | public String areaName = null; 37 | 38 | /** 39 | * Step size used by runoff evaluator 40 | */ 41 | private Long runoffStepSize; 42 | 43 | /** 44 | * Step size of the rainfall data 45 | */ 46 | private Long rainfallStepSize; 47 | 48 | /** 49 | * Define the starting data/time simulation 50 | */ 51 | private Instant initialTime; 52 | 53 | /** 54 | * Define the ending date/time simulation 55 | */ 56 | private Instant totalTime; 57 | 58 | /** 59 | * Set of rainfall data over time 60 | */ 61 | private LinkedHashMap rainfallData; 62 | 63 | /** 64 | * Coefficient $$a$$ of the equation $$I=a*tp^(n-1)$$ 65 | */ 66 | @In 67 | public Double aLPP = 60.4; 68 | 69 | /** 70 | * Coefficient $$n$$ of the equation $$I=a*tp^(n-1)$$ 71 | */ 72 | @In 73 | public Double nLPP = 0.61; 74 | 75 | /** 76 | * Number of curves to design the network 77 | */ 78 | @In 79 | public Integer numberOfCurves; 80 | 81 | @InNode 82 | @Out 83 | public SWMMobject dataStructure; 84 | 85 | /** 86 | * Rainfall data adapted over the runoff step size 87 | */ 88 | @Out 89 | public HashMap> adaptedRainfallData = new HashMap<>(); 90 | 91 | public HashMap> getAdaptedRainfallData() { 92 | return adaptedRainfallData; 93 | } 94 | 95 | @Initialize 96 | public void initialize() { 97 | } 98 | 99 | @Execute 100 | public void run() { 101 | 102 | if(dataStructure != null) { 103 | 104 | this.initialTime = dataStructure.getProjectDateTime().getDateTime(AvailableDateTypes.startDate); 105 | this.totalTime = dataStructure.getProjectDateTime().getDateTime(AvailableDateTypes.endDate); 106 | 107 | this.runoffStepSize = dataStructure.getAreasDateTime().getDateTime(AvailableDateTypes.stepSize); 108 | this.rainfallStepSize = runoffStepSize; 109 | 110 | if(aLPP == null && nLPP == null) { 111 | throw new NullPointerException("Nothing implemented yet"); 112 | } 113 | else{ 114 | for (int rainfallTimeId = 1; rainfallTimeId <= numberOfCurves; rainfallTimeId++) { 115 | adaptedRainfallData.put(rainfallTimeId, dataStructure.adaptDataSeries(runoffStepSize, 116 | rainfallStepSize, generateRainfall().get(rainfallTimeId)) ); 117 | } 118 | } 119 | } 120 | else { 121 | throw new NullPointerException("Data structure is null"); 122 | } 123 | } 124 | 125 | /** 126 | * Method to generate the curves to design from IDFs curves 127 | * @return HM with the ID of the curve as key and the HM of the design storm as value 128 | */ 129 | private HashMap> generateRainfall() { 130 | 131 | HashMap> rainfallData = new HashMap<>(); 132 | 133 | for (int rainfallTimeId = 1; rainfallTimeId <= numberOfCurves; rainfallTimeId++) { 134 | 135 | LinkedHashMap rainfallValues = new LinkedHashMap<>(); 136 | 137 | for (Long currentTime = initialTime.getEpochSecond(); currentTime<=totalTime.getEpochSecond(); currentTime+=rainfallStepSize) { 138 | 139 | if (rainfallTimeId == 1) { 140 | rainfallValues.put(Instant.ofEpochSecond(currentTime), 141 | constantRainfallData(Instant.ofEpochSecond(180L), 142 | Instant.ofEpochSecond(currentTime).minusSeconds(initialTime.getEpochSecond())) ); 143 | } 144 | else if (rainfallTimeId == 2) { 145 | rainfallValues.put(Instant.ofEpochSecond(currentTime), 146 | constantRainfallData(Instant.ofEpochSecond(300L), 147 | Instant.ofEpochSecond(currentTime).minusSeconds(initialTime.getEpochSecond())) ); 148 | } 149 | else if (rainfallTimeId == 3) { 150 | rainfallValues.put(Instant.ofEpochSecond(currentTime), 151 | constantRainfallData(Instant.ofEpochSecond(600L), 152 | Instant.ofEpochSecond(currentTime).minusSeconds(initialTime.getEpochSecond())) ); 153 | } 154 | else { 155 | throw new NullPointerException("numberOfCurves must be between 1 and 3"); 156 | } 157 | } 158 | 159 | //TODO nullo 160 | rainfallData.put( rainfallTimeId, rainfallValues ); 161 | 162 | } 163 | return rainfallData; 164 | } 165 | 166 | /** 167 | * Method to generate the constant intensity from IDFs curves 168 | * @param finalRainfallTime 169 | * @param currentTime 170 | * @return IDF related value of rainfall time 171 | */ 172 | private Double constantRainfallData(Instant finalRainfallTime, Instant currentTime) { 173 | 174 | Double rainfallValue = 0.0; 175 | 176 | if ( currentTime.isBefore(finalRainfallTime) ) { 177 | double timeInHours = finalRainfallTime.getEpochSecond() / 3600.0; 178 | if (timeInHours == 0.0) { 179 | timeInHours = 1.0; 180 | } 181 | rainfallValue = aLPP * Math.pow(timeInHours, nLPP - 1.0) / 3600.0; // [mm/s] 182 | } 183 | 184 | return rainfallValue; 185 | } 186 | public void setDataStructure(SWMMobject data) { 187 | this.dataStructure = data; 188 | } 189 | } -------------------------------------------------------------------------------- /src/main/java/com/github/geoframecomponents/jswmm/runoff/Runoff.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JSWMM: Reimplementation of EPA SWMM in Java 3 | * Copyright (C) 2019 Daniele Dalla Torre (ftt01) 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package com.github.geoframecomponents.jswmm.runoff; 19 | 20 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 21 | import com.github.geoframecomponents.jswmm.dataStructure.hydrology.subcatchment.Area; 22 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 23 | import oms3.annotations.*; 24 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.Datetimeable; 25 | import com.github.geoframecomponents.jswmm.dataStructure.runoffDS.RunoffSolver; 26 | 27 | import java.time.Instant; 28 | import java.util.HashMap; 29 | import java.util.LinkedHashMap; 30 | 31 | import static org.junit.Assert.assertEquals; 32 | 33 | public class Runoff { 34 | 35 | @In 36 | public HashMap> adaptedRainfallData; // [mm/hour] 37 | 38 | /** 39 | * Name of the area of current simulation 40 | */ 41 | @In 42 | public String areaName = null; 43 | 44 | /** 45 | * Name of the node where area drains in the current simulation 46 | */ 47 | @In 48 | public String nodeName = null; 49 | 50 | /** 51 | * Area properties 52 | */ 53 | private Area area; 54 | 55 | /** 56 | * Data structure 57 | */ 58 | @In 59 | public SWMMobject dataStructure; 60 | 61 | /** 62 | * HM of the flowrate over time that drains into the node, 63 | * ID of the rainfall curve is the key and the resulting runoff are the values 64 | */ 65 | @OutNode 66 | public HashMap> runoffFlowRate = new HashMap<>(); 67 | 68 | @Initialize 69 | public void initialize() { 70 | } 71 | 72 | @Execute 73 | public void run() { 74 | 75 | if (dataStructure != null && areaName != null) { 76 | this.area = dataStructure.getAreas(areaName); 77 | } 78 | else { 79 | throw new NullPointerException("Runoff over" + areaName + "fails setup."); 80 | } 81 | area.evaluateRunoffFlowRate(adaptedRainfallData); 82 | 83 | for (Integer curveId : adaptedRainfallData.keySet()) { 84 | runoffFlowRate.put(curveId, area.evaluateTotalFlowRate(curveId)); //[m^3/s] 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/base/SourceSetTest.java: -------------------------------------------------------------------------------- 1 | package base; 2 | 3 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 4 | import org.apache.commons.configuration2.ex.ConfigurationException; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | import static org.junit.Assert.assertNotNull; 9 | 10 | public class SourceSetTest { 11 | 12 | SWMMobject data; 13 | 14 | public SourceSetTest() throws ConfigurationException { 15 | //this.data = new SWMMobject("network12.inp"); 16 | } 17 | 18 | @Before 19 | public void initialize() throws ConfigurationException { 20 | data = new SWMMobject(); 21 | } 22 | 23 | @Test 24 | public void execute() { 25 | assertNotNull(data); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/base/SourceSetTestINP.java: -------------------------------------------------------------------------------- 1 | package base; 2 | 3 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 4 | import org.apache.commons.configuration2.ex.ConfigurationException; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | import static org.junit.Assert.assertNotNull; 9 | 10 | public class SourceSetTestINP { 11 | 12 | SWMMobject data; 13 | 14 | public SourceSetTestINP() throws ConfigurationException { 15 | //this.data = new SWMMobject("network12.inp"); 16 | } 17 | 18 | @Before 19 | public void initialize() throws ConfigurationException { 20 | data = new SWMMobject("network12.inp", 3); 21 | } 22 | 23 | @Test 24 | public void execute() { 25 | assertNotNull(data); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/routing/RoutingINP.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package routing; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.dataStructure.options.datetime.AvailableDateTypes; 20 | import com.github.geoframecomponents.jswmm.routing.FlowRateDispatcher; 21 | import com.github.geoframecomponents.jswmm.routing.Routing; 22 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 23 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 24 | import org.apache.commons.configuration2.ex.ConfigurationException; 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | 28 | import java.time.Instant; 29 | import java.util.ArrayList; 30 | import java.util.HashMap; 31 | import java.util.LinkedHashMap; 32 | import java.util.List; 33 | 34 | public class RoutingINP { 35 | 36 | SWMMobject data; 37 | PreRunoff preRunoff_1; 38 | PreRunoff preRunoff_2; 39 | Runoff runoff_1; 40 | Runoff runoff_2; 41 | Routing routing1; 42 | Routing routing2; 43 | Routing routing3; 44 | FlowRateDispatcher flowRateDispatcher1; 45 | FlowRateDispatcher flowRateDispatcher2; 46 | FlowRateDispatcher flowRateDispatcher3; 47 | 48 | @Before 49 | public void initialize() throws ConfigurationException { 50 | int numberOfCurves = 3; 51 | data = new SWMMobject("network12.inp", numberOfCurves); 52 | 53 | preRunoff_1 = new PreRunoff(); 54 | preRunoff_2 = new PreRunoff(); 55 | 56 | preRunoff_1.setDataStructure(data); 57 | preRunoff_2.setDataStructure(data); 58 | 59 | preRunoff_1.areaName = "S1"; 60 | preRunoff_2.areaName = "S2"; 61 | 62 | preRunoff_1.numberOfCurves = numberOfCurves; 63 | preRunoff_2.numberOfCurves = numberOfCurves; 64 | 65 | preRunoff_1.initialize(); 66 | preRunoff_2.initialize(); 67 | 68 | preRunoff_1.run(); 69 | preRunoff_2.run(); 70 | 71 | runoff_1 = new Runoff(); 72 | runoff_2 = new Runoff(); 73 | 74 | runoff_1.dataStructure = data; 75 | runoff_1.areaName = "S1"; 76 | runoff_1.nodeName = "J1"; 77 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 78 | 79 | runoff_2.dataStructure = data; 80 | runoff_2.areaName = "S2"; 81 | runoff_2.nodeName = "J3"; 82 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 83 | 84 | runoff_1.initialize(); 85 | runoff_2.initialize(); 86 | 87 | runoff_1.run(); 88 | runoff_2.run(); 89 | } 90 | 91 | @Test 92 | public void execute() { 93 | 94 | routing1 = new Routing(); 95 | flowRateDispatcher1 = new FlowRateDispatcher(); 96 | flowRateDispatcher1.dataStructure = data; 97 | flowRateDispatcher1.setFlowRate1(runoff_1.runoffFlowRate); 98 | flowRateDispatcher1.upstreamNodeName = "J1"; 99 | flowRateDispatcher1.linkName = "8"; 100 | flowRateDispatcher1.run(); 101 | 102 | //System.out.println(flowRateDispatcher1.flowRate1); 103 | 104 | List subtree = new ArrayList<>(); 105 | subtree.add(0, 8); 106 | //subtree.add(0, 10); 107 | //subtree.add(1, 8); 108 | //subtree.add(2, 9); 109 | //routingTest("10", subtree); 110 | 111 | routing1.dataStructure = data; 112 | routing1.linkName = "8"; 113 | 114 | routing1.run(); 115 | 116 | flowRateDispatcher2 = new FlowRateDispatcher(); 117 | flowRateDispatcher2.dataStructure = data; 118 | flowRateDispatcher2.setFlowRate1(runoff_2.runoffFlowRate); 119 | flowRateDispatcher2.upstreamNodeName = "J3"; 120 | flowRateDispatcher2.linkName = "9"; 121 | flowRateDispatcher2.run(); 122 | 123 | routing2 = new Routing(); 124 | 125 | subtree.set(0, 9); 126 | //subtree.add(0, 10); 127 | //subtree.add(1, 8); 128 | //subtree.add(2, 9); 129 | //routingTest("10", subtree); 130 | 131 | routing2.dataStructure = data; 132 | routing2.linkName = "9"; 133 | 134 | routing2.run(); 135 | 136 | flowRateDispatcher3 = new FlowRateDispatcher(); 137 | flowRateDispatcher3.dataStructure = data; 138 | flowRateDispatcher3.setFlowRate1(routing1.routingFlowRate); 139 | flowRateDispatcher3.setFlowRate2(routing2.routingFlowRate); 140 | flowRateDispatcher3.upstreamNodeName = "J4"; 141 | flowRateDispatcher3.linkName = "10"; 142 | flowRateDispatcher3.run(); 143 | 144 | routing3 = new Routing(); 145 | 146 | subtree.set(0, 10); 147 | subtree.add(1, 8); 148 | subtree.add(2, 9); 149 | 150 | routing3.dataStructure = data; 151 | routing3.linkName = "10"; 152 | 153 | routing3.run(); 154 | } 155 | } -------------------------------------------------------------------------------- /src/test/java/routing/RoutingINPfossolo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package routing; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.routing.FlowRateDispatcher; 20 | import com.github.geoframecomponents.jswmm.routing.Routing; 21 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 22 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 23 | import org.apache.commons.configuration2.ex.ConfigurationException; 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | 27 | import java.util.ArrayList; 28 | import java.util.HashMap; 29 | import java.util.List; 30 | 31 | public class RoutingINPfossolo { 32 | 33 | SWMMobject data; 34 | PreRunoff preRunoff_1; 35 | PreRunoff preRunoff_2; 36 | Runoff runoff_1; 37 | Runoff runoff_2; 38 | Routing routing1; 39 | Routing routing2; 40 | Routing routing3; 41 | FlowRateDispatcher flowRateDispatcher1; 42 | FlowRateDispatcher flowRateDispatcher2; 43 | FlowRateDispatcher flowRateDispatcher3; 44 | 45 | @Before 46 | public void initialize() throws ConfigurationException { 47 | int numberOfCurves =3; 48 | data = new SWMMobject("fossolo.inp", numberOfCurves); 49 | 50 | preRunoff_1 = new PreRunoff(); 51 | preRunoff_2 = new PreRunoff(); 52 | 53 | preRunoff_1.setDataStructure(data); 54 | preRunoff_2.setDataStructure(data); 55 | 56 | preRunoff_1.areaName = "Sub1"; 57 | preRunoff_2.areaName = "Sub2"; 58 | 59 | preRunoff_1.numberOfCurves = numberOfCurves; 60 | preRunoff_2.numberOfCurves = numberOfCurves; 61 | 62 | preRunoff_1.initialize(); 63 | preRunoff_2.initialize(); 64 | 65 | preRunoff_1.run(); 66 | preRunoff_2.run(); 67 | 68 | runoff_1 = new Runoff(); 69 | runoff_2 = new Runoff(); 70 | 71 | runoff_1.dataStructure = data; 72 | runoff_1.areaName = "Sub1"; 73 | runoff_1.nodeName = "J1"; 74 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 75 | 76 | runoff_2.dataStructure = data; 77 | runoff_2.areaName = "Sub2"; 78 | runoff_2.nodeName = "J2"; 79 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 80 | 81 | runoff_1.initialize(); 82 | runoff_2.initialize(); 83 | 84 | runoff_1.run(); 85 | runoff_2.run(); 86 | } 87 | 88 | @Test 89 | public void execute() { 90 | 91 | routing1 = new Routing(); 92 | flowRateDispatcher1 = new FlowRateDispatcher(); 93 | flowRateDispatcher1.dataStructure = data; 94 | flowRateDispatcher1.setFlowRate1(runoff_1.runoffFlowRate); 95 | flowRateDispatcher1.upstreamNodeName = "J1"; 96 | flowRateDispatcher1.linkName = "11"; 97 | flowRateDispatcher1.run(); 98 | 99 | //System.out.println(flowRateDispatcher1.flowRate1); 100 | 101 | List subtree = new ArrayList<>(); 102 | subtree.add(0, 1); 103 | //subtree.add(0, 10); 104 | //subtree.add(1, 8); 105 | //subtree.add(2, 9); 106 | //routingTest("10", subtree); 107 | 108 | routing1.dataStructure = data; 109 | routing1.linkName = "11"; 110 | 111 | routing1.run(); 112 | 113 | flowRateDispatcher2 = new FlowRateDispatcher(); 114 | flowRateDispatcher2.dataStructure = data; 115 | flowRateDispatcher2.setFlowRate1(runoff_2.runoffFlowRate); 116 | flowRateDispatcher2.upstreamNodeName = "J2"; 117 | flowRateDispatcher2.linkName = "12"; 118 | flowRateDispatcher2.run(); 119 | 120 | routing2 = new Routing(); 121 | 122 | subtree.set(0, 2); 123 | //subtree.add(0, 10); 124 | //subtree.add(1, 8); 125 | //subtree.add(2, 9); 126 | //routingTest("10", subtree); 127 | 128 | routing2.dataStructure = data; 129 | routing2.linkName = "12"; 130 | 131 | routing2.run(); 132 | 133 | flowRateDispatcher3 = new FlowRateDispatcher(); 134 | flowRateDispatcher3.dataStructure = data; 135 | flowRateDispatcher3.setFlowRate1(routing1.routingFlowRate); 136 | flowRateDispatcher3.setFlowRate2(routing2.routingFlowRate); 137 | flowRateDispatcher3.upstreamNodeName = "J3"; 138 | flowRateDispatcher3.linkName = "13"; 139 | flowRateDispatcher3.run(); 140 | 141 | routing3 = new Routing(); 142 | 143 | subtree.set(0, 3); 144 | subtree.add(1, 1); 145 | subtree.add(2, 2); 146 | 147 | routing3.dataStructure = data; 148 | routing3.linkName = "13"; 149 | 150 | routing3.run(); 151 | 152 | } 153 | } -------------------------------------------------------------------------------- /src/test/java/routing/RoutingMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package routing; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.routing.Routing; 20 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 21 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 22 | import org.junit.Before; 23 | import org.junit.Ignore; 24 | import org.junit.Test; 25 | 26 | @Ignore 27 | public class RoutingMain { 28 | 29 | SWMMobject data; 30 | PreRunoff preRunoff_1; 31 | PreRunoff preRunoff_2; 32 | Runoff runoff_1; 33 | Runoff runoff_2; 34 | Routing routing; 35 | 36 | @Before 37 | public void initialize() { 38 | data = new SWMMobject(); 39 | 40 | preRunoff_1 = new PreRunoff(); 41 | preRunoff_2 = new PreRunoff(); 42 | 43 | preRunoff_1.setDataStructure(data); 44 | preRunoff_2.setDataStructure(data); 45 | 46 | preRunoff_1.areaName = "RG1"; 47 | preRunoff_2.areaName = "RG2"; 48 | 49 | preRunoff_1.initialize(); 50 | preRunoff_2.initialize(); 51 | 52 | preRunoff_1.run(); 53 | preRunoff_2.run(); 54 | } 55 | 56 | @Test 57 | public void execute() { 58 | runoff_1 = new Runoff(); 59 | runoff_2 = new Runoff(); 60 | 61 | runoff_1.dataStructure = data; 62 | runoff_1.areaName = "1"; 63 | runoff_1.nodeName = "J3"; 64 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 65 | 66 | runoff_2.dataStructure = data; 67 | runoff_2.areaName = "1"; 68 | runoff_2.nodeName = "J3"; 69 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 70 | 71 | runoff_1.initialize(); 72 | runoff_2.initialize(); 73 | 74 | runoff_1.run(); 75 | runoff_2.run(); 76 | 77 | routing = new Routing(); 78 | 79 | routing.dataStructure = data; 80 | routing.linkName = "11"; 81 | 82 | routing.run(); 83 | //routingDS.SourceSetTest(); 84 | } 85 | } -------------------------------------------------------------------------------- /src/test/java/runoff/RunoffINP.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package runoff; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 20 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 21 | import org.apache.commons.configuration2.ex.ConfigurationException; 22 | import org.junit.Before; 23 | import org.junit.Ignore; 24 | import org.junit.Test; 25 | 26 | @Ignore 27 | public class RunoffINP { 28 | 29 | SWMMobject data; 30 | PreRunoff preRunoff_1; 31 | PreRunoff preRunoff_2; 32 | Runoff runoff_1; 33 | Runoff runoff_2; 34 | 35 | @Before 36 | public void initialize() throws ConfigurationException { 37 | data = new SWMMobject("network12.inp", 3); 38 | 39 | preRunoff_1 = new PreRunoff(); 40 | preRunoff_2 = new PreRunoff(); 41 | 42 | preRunoff_1.dataStructure = data; 43 | preRunoff_2.dataStructure = data; 44 | 45 | preRunoff_1.areaName = "S1"; 46 | preRunoff_2.areaName = "S2"; 47 | 48 | preRunoff_1.initialize(); 49 | preRunoff_2.initialize(); 50 | 51 | preRunoff_1.run(); 52 | preRunoff_2.run(); 53 | } 54 | 55 | @Test 56 | public void execute() { 57 | runoff_1 = new Runoff(); 58 | runoff_2 = new Runoff(); 59 | 60 | runoff_1.dataStructure = data; 61 | runoff_1.areaName = "S1"; 62 | runoff_1.nodeName = "J1"; 63 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 64 | 65 | runoff_2.dataStructure = data; 66 | runoff_2.areaName = "S2"; 67 | runoff_2.nodeName = "J3"; 68 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 69 | 70 | runoff_1.run(); 71 | runoff_2.run(); 72 | } 73 | } -------------------------------------------------------------------------------- /src/test/java/runoff/RunoffINPfossolo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package runoff; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 20 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 21 | import org.apache.commons.configuration2.ex.ConfigurationException; 22 | import org.junit.Before; 23 | import org.junit.Ignore; 24 | import org.junit.Test; 25 | 26 | @Ignore 27 | public class RunoffINPfossolo { 28 | 29 | SWMMobject data; 30 | PreRunoff preRunoff_1; 31 | PreRunoff preRunoff_2; 32 | Runoff runoff_1; 33 | Runoff runoff_2; 34 | 35 | @Before 36 | public void initialize() throws ConfigurationException { 37 | data = new SWMMobject("fossolo.inp", 3); 38 | 39 | preRunoff_1 = new PreRunoff(); 40 | preRunoff_2 = new PreRunoff(); 41 | 42 | preRunoff_1.dataStructure = data; 43 | preRunoff_2.dataStructure = data; 44 | 45 | preRunoff_1.areaName = "Sub1"; 46 | preRunoff_2.areaName = "Sub2"; 47 | 48 | preRunoff_1.initialize(); 49 | preRunoff_2.initialize(); 50 | 51 | preRunoff_1.run(); 52 | preRunoff_2.run(); 53 | } 54 | 55 | @Test 56 | public void execute() { 57 | runoff_1 = new Runoff(); 58 | runoff_2 = new Runoff(); 59 | 60 | runoff_1.dataStructure = data; 61 | runoff_1.areaName = "Sub1"; 62 | runoff_1.nodeName = "J1"; 63 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 64 | 65 | runoff_2.dataStructure = data; 66 | runoff_2.areaName = "Sub2"; 67 | runoff_2.nodeName = "J2"; 68 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 69 | 70 | runoff_1.run(); 71 | runoff_2.run(); 72 | 73 | System.out.println( runoff_1.runoffFlowRate ); 74 | System.out.println( runoff_2.runoffFlowRate ); 75 | } 76 | } -------------------------------------------------------------------------------- /src/test/java/runoff/RunoffMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | package runoff; 17 | 18 | import com.github.geoframecomponents.jswmm.dataStructure.SWMMobject; 19 | import com.github.geoframecomponents.jswmm.runoff.PreRunoff; 20 | import com.github.geoframecomponents.jswmm.runoff.Runoff; 21 | import org.junit.Before; 22 | import org.junit.Ignore; 23 | import org.junit.Test; 24 | 25 | import java.time.Instant; 26 | 27 | @Ignore 28 | public class RunoffMain { 29 | 30 | SWMMobject data; 31 | PreRunoff preRunoff_1; 32 | PreRunoff preRunoff_2; 33 | Runoff runoff_1; 34 | Runoff runoff_2; 35 | 36 | @Before 37 | public void initialize() { 38 | data = new SWMMobject(); 39 | 40 | preRunoff_1 = new PreRunoff(); 41 | preRunoff_2 = new PreRunoff(); 42 | 43 | preRunoff_1.dataStructure = data; 44 | preRunoff_2.dataStructure = data; 45 | 46 | preRunoff_1.areaName = "1"; 47 | preRunoff_2.areaName = "2"; 48 | 49 | preRunoff_1.initialize(); 50 | preRunoff_2.initialize(); 51 | 52 | preRunoff_1.run(); 53 | preRunoff_2.run(); 54 | } 55 | 56 | @Test 57 | public void execute() { 58 | runoff_1 = new Runoff(); 59 | runoff_2 = new Runoff(); 60 | 61 | runoff_1.dataStructure = data; 62 | runoff_1.areaName = "1"; 63 | runoff_1.nodeName = "J3"; 64 | runoff_1.adaptedRainfallData = preRunoff_1.getAdaptedRainfallData(); 65 | 66 | runoff_2.dataStructure = data; 67 | runoff_2.areaName = "2"; 68 | runoff_2.nodeName = "J3"; 69 | runoff_2.adaptedRainfallData = preRunoff_2.getAdaptedRainfallData(); 70 | 71 | runoff_1.run(); 72 | runoff_2.run(); 73 | } 74 | } -------------------------------------------------------------------------------- /src/test/resources/fossolo.inp: -------------------------------------------------------------------------------- 1 | [TITLE] 2 | ;;Project Title/Notes 3 | 4 | [OPTIONS] 5 | ;;Option Value 6 | FLOW_UNITS CMS 7 | INFILTRATION HORTON 8 | FLOW_ROUTING STEADY 9 | LINK_OFFSETS DEPTH 10 | MIN_SLOPE 0 11 | ALLOW_PONDING NO 12 | SKIP_STEADY_STATE NO 13 | 14 | START_DATE 01/01/2018 15 | START_TIME 00:00:00 16 | REPORT_START_DATE 01/01/2018 17 | REPORT_START_TIME 00:00:00 18 | END_DATE 01/01/2018 19 | END_TIME 01:00:00 20 | SWEEP_START 01/01 21 | SWEEP_END 12/31 22 | DRY_DAYS 0 23 | REPORT_STEP 00:00:30 24 | WET_STEP 00:01:00 25 | DRY_STEP 01:00:00 26 | ROUTING_STEP 0:00:30 27 | 28 | INERTIAL_DAMPING PARTIAL 29 | NORMAL_FLOW_LIMITED BOTH 30 | FORCE_MAIN_EQUATION H-W 31 | VARIABLE_STEP 0.75 32 | LENGTHENING_STEP 0 33 | MIN_SURFAREA 1.14 34 | MAX_TRIALS 8 35 | HEAD_TOLERANCE 0.0015 36 | SYS_FLOW_TOL 5 37 | LAT_FLOW_TOL 5 38 | MINIMUM_STEP 0.5 39 | THREADS 1 40 | 41 | [EVAPORATION] 42 | ;;Data Source Parameters 43 | ;;-------------- ---------------- 44 | CONSTANT 0.0 45 | DRY_ONLY NO 46 | 47 | [RAINGAGES] 48 | ;;Name Format Interval SCF Source 49 | ;;-------------- --------- ------ ------ ---------- 50 | RG1 INTENSITY 0:01 1.0 TIMESERIES 3mins 51 | 52 | [SUBCATCHMENTS] 53 | ;;Name Rain Gage Outlet Area %Imperv Width %Slope CurbLen SnowPack 54 | ;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ---------------- 55 | Sub1 RG1 J1 1.937 0.75 100 0.01 0 56 | Sub2 RG1 J2 1.731 0.75 100 0.01 0 57 | Sub3 RG1 J3 0.481 0.75 100 0.01 0 58 | Sub4 RG1 J5 0.547 0.75 100 0.01 0 59 | Sub5 RG1 J6 2.141 0.75 100 0.01 0 60 | Sub6 RG1 J7 0.383 0.75 100 0.01 0 61 | Sub7 RG1 J4 0.353 0.75 100 0.01 0 62 | Sub8 RG1 J9 0.999 0.75 100 0.01 0 63 | Sub9 RG1 J10 1.583 0.75 100 0.01 0 64 | Sub10 RG1 J8 0.633 0.75 100 0.01 0 65 | 66 | [SUBAREAS] 67 | ;;Subcatchment N-Imperv N-Perv S-Imperv S-Perv PctZero RouteTo PctRouted 68 | ;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 69 | Sub1 0.01 0.1 0.05 0.05 0.25 OUTLET 70 | Sub2 0.01 0.1 0.05 0.05 0.25 OUTLET 71 | Sub3 0.01 0.1 0.05 0.05 0.25 OUTLET 72 | Sub4 0.01 0.1 0.05 0.05 0.25 OUTLET 73 | Sub5 0.01 0.1 0.05 0.05 0.25 OUTLET 74 | Sub6 0.01 0.1 0.05 0.05 0.25 OUTLET 75 | Sub7 0.01 0.1 0.05 0.05 0.25 OUTLET 76 | Sub8 0.01 0.1 0.05 0.05 0.25 OUTLET 77 | Sub9 0.01 0.1 0.05 0.05 0.25 OUTLET 78 | Sub10 0.01 0.1 0.05 0.05 0.25 OUTLET 79 | 80 | [INFILTRATION] 81 | ;;Subcatchment MaxRate MinRate Decay DryTime MaxInfil 82 | ;;-------------- ---------- ---------- ---------- ---------- ---------- 83 | Sub1 3.0 0.5 4 7 0 84 | Sub2 3.0 0.5 4 7 0 85 | Sub3 3.0 0.5 4 7 0 86 | Sub4 3.0 0.5 4 7 0 87 | Sub5 3.0 0.5 4 7 0 88 | Sub6 3.0 0.5 4 7 0 89 | Sub7 3.0 0.5 4 7 0 90 | Sub8 3.0 0.5 4 7 0 91 | Sub9 3.0 0.5 4 7 0 92 | Sub10 3.0 0.5 4 7 0 93 | 94 | [JUNCTIONS] 95 | ;;Name Elevation MaxDepth InitDepth SurDepth Aponded 96 | ;;-------------- ---------- ---------- ---------- ---------- ---------- 97 | J1 8 0 0 0 0 98 | J2 8 0 0 0 0 99 | J3 6 0 0 0 0 100 | J4 4 0 0 0 0 101 | J5 8 0 0 0 0 102 | J6 8 0 0 0 0 103 | J7 6 0 0 0 0 104 | J8 2 0 0 0 0 105 | J9 4 0 0 0 0 106 | J10 4 0 0 0 0 107 | 108 | [OUTFALLS] 109 | ;;Name Elevation Type Stage Data Gated Route To 110 | ;;-------------- ---------- ---------- ---------------- -------- ---------------- 111 | Out1 0 FREE NO 112 | 113 | [CONDUITS] 114 | ;;Name From Node To Node Length Roughness InOffset OutOffset InitFlow MaxFlow 115 | ;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- 116 | 11 J1 J3 200 120 0 0 0 0 117 | 12 J2 J3 200 120 0 0 0 0 118 | 13 J3 J4 200 120 0 0 0 0 119 | 14 J5 J7 200 120 0 0 0 0 120 | 15 J6 J7 200 120 0 0 0 0 121 | 16 J7 J4 200 120 0 0 0 0 122 | 17 J4 J8 200 120 0 0 0 0 123 | 18 J9 J8 200 120 0 0 0 0 124 | 19 J10 J8 200 120 0 0 0 0 125 | 20 J8 Out1 200 120 0 0 0 0 126 | 127 | [XSECTIONS] 128 | ;;Link Shape Geom1 Geom2 Geom3 Geom4 Barrels Culvert 129 | ;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ---------- 130 | 11 CIRCULAR 0.5 0 0 0 1 131 | 12 CIRCULAR 0.5 0 0 0 1 132 | 13 CIRCULAR 0.6 0 0 0 1 133 | 14 CIRCULAR 0.4 0 0 0 1 134 | 15 CIRCULAR 0.5 0 0 0 1 135 | 16 CIRCULAR 0.6 0 0 0 1 136 | 17 CIRCULAR 0.8 0 0 0 1 137 | 18 CIRCULAR 0.4 0 0 0 1 138 | 19 CIRCULAR 0.4 0 0 0 1 139 | 20 CIRCULAR 1 0 0 0 1 140 | 141 | [TIMESERIES] 142 | ;;Name Date Time Value 143 | ;;-------------- ---------- ---------- ---------- 144 | 3mins 00:00 194.28 145 | 3mins 00:01 194.28 146 | 3mins 00:02 194.28 147 | 148 | [REPORT] 149 | ;;Reporting Options 150 | INPUT NO 151 | CONTROLS NO 152 | SUBCATCHMENTS ALL 153 | NODES ALL 154 | LINKS ALL 155 | 156 | [TAGS] 157 | 158 | [MAP] 159 | DIMENSIONS 0.000 0.000 10000.000 10000.000 160 | Units None 161 | 162 | [COORDINATES] 163 | ;;Node X-Coord Y-Coord 164 | ;;-------------- ------------------ ------------------ 165 | J1 1569.767 8357.558 166 | J2 3139.535 8401.163 167 | J3 2412.791 7063.953 168 | J4 4738.372 6191.860 169 | J5 6526.163 8430.233 170 | J6 7936.047 7151.163 171 | J7 6366.279 6744.186 172 | J8 5639.535 4113.372 173 | J9 7427.326 5436.047 174 | J10 3488.372 4273.256 175 | Out1 5581.395 1802.326 176 | 177 | [VERTICES] 178 | ;;Link X-Coord Y-Coord 179 | ;;-------------- ------------------ ------------------ 180 | 181 | [Polygons] 182 | ;;Subcatchment X-Coord Y-Coord 183 | ;;-------------- ------------------ ------------------ 184 | Sub1 29.070 8808.140 185 | Sub1 1947.674 8764.535 186 | Sub1 1947.674 9825.581 187 | Sub1 14.535 9840.116 188 | Sub2 3793.605 9738.372 189 | Sub2 3866.279 8720.930 190 | Sub2 2340.116 8808.140 191 | Sub2 2354.651 9796.512 192 | Sub3 1224.564 7539.971 193 | Sub3 1428.052 6362.645 194 | Sub3 -243.459 6638.808 195 | Sub3 -374.273 7539.971 196 | Sub4 6947.674 9781.977 197 | Sub4 6962.209 8735.465 198 | Sub4 5479.651 8662.791 199 | Sub4 5508.721 9752.907 200 | Sub5 9026.163 8895.349 201 | Sub5 9069.767 7674.419 202 | Sub5 7558.140 7601.744 203 | Sub5 7543.605 8808.140 204 | Sub6 5465.116 8473.837 205 | Sub6 5377.907 7063.953 206 | Sub6 4127.907 7078.488 207 | Sub6 4113.372 8299.419 208 | Sub7 1453.488 6002.907 209 | Sub7 3023.256 5959.302 210 | Sub7 3037.791 4796.512 211 | Sub7 1337.209 4811.047 212 | Sub7 1409.884 5741.279 213 | Sub8 9520.349 6889.535 214 | Sub8 9476.744 5566.860 215 | Sub8 7863.372 5494.186 216 | Sub8 7848.837 6468.023 217 | Sub9 3997.093 3677.326 218 | Sub9 4127.907 2572.674 219 | Sub9 2020.349 2659.884 220 | Sub9 2063.953 3619.186 221 | Sub10 8546.512 4255.087 222 | Sub10 8575.581 3106.831 223 | Sub10 6816.860 3135.901 224 | Sub10 6816.860 4327.762 225 | 226 | [SYMBOLS] 227 | ;;Gage X-Coord Y-Coord 228 | ;;-------------- ------------------ ------------------ 229 | RG1 -886.628 8284.884 230 | 231 | -------------------------------------------------------------------------------- /src/test/resources/network12.inp: -------------------------------------------------------------------------------- 1 | [TITLE] 2 | ;;Project Title/Notes 3 | 4 | [OPTIONS] 5 | ;;Option Value 6 | FLOW_UNITS CMS 7 | INFILTRATION HORTON 8 | FLOW_ROUTING STEADY 9 | LINK_OFFSETS ELEVATION 10 | MIN_SLOPE 0.1 11 | ALLOW_PONDING NO 12 | SKIP_STEADY_STATE NO 13 | 14 | START_DATE 01/01/2018 15 | START_TIME 00:00:00 16 | REPORT_START_DATE 01/01/2018 17 | REPORT_START_TIME 00:00:00 18 | END_DATE 01/01/2018 19 | END_TIME 01:00:00 20 | SWEEP_START 01/01 21 | SWEEP_END 12/31 22 | DRY_DAYS 10 23 | REPORT_STEP 00:01:00 24 | WET_STEP 00:05:00 25 | DRY_STEP 01:00:00 26 | ROUTING_STEP 00:00:30 27 | 28 | INERTIAL_DAMPING PARTIAL 29 | NORMAL_FLOW_LIMITED BOTH 30 | FORCE_MAIN_EQUATION H-W 31 | VARIABLE_STEP 0.75 32 | LENGTHENING_STEP 0 33 | MIN_SURFAREA 1.14 34 | MAX_TRIALS 8 35 | HEAD_TOLERANCE 0.0015 36 | SYS_FLOW_TOL 5 37 | LAT_FLOW_TOL 5 38 | MINIMUM_STEP 0.5 39 | THREADS 1 40 | 41 | [EVAPORATION] 42 | ;;Data Source Parameters 43 | ;;-------------- ---------------- 44 | CONSTANT 0.0 45 | DRY_ONLY NO 46 | 47 | [RAINGAGES] 48 | ;;Name Format Interval SCF Source 49 | ;;-------------- --------- ------ ------ ---------- 50 | RG1 INTENSITY 0:01 1.0 TIMESERIES 5mins 51 | 52 | [SUBCATCHMENTS] 53 | ;;Name Rain Gage Outlet Area %Imperv Width %Slope CurbLen SnowPack 54 | ;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ---------------- 55 | S1 RG1 J1 0.2 0.25 100 0.5 0 56 | S2 RG1 J3 0.5 0.25 100 0.5 0 57 | S3 RG1 J3 1 0.25 100 0.5 0 58 | S4 RG1 J3 1 0.25 100 0.5 0 59 | S5 RG1 J4 1 0.25 100 0.5 0 60 | S6 RG1 J2 1 0.25 100 0.5 0 61 | S7 RG1 J2 1 0.25 100 0.5 0 62 | 63 | [SUBAREAS] 64 | ;;Subcatchment N-Imperv N-Perv S-Imperv S-Perv PctZero RouteTo PctRouted 65 | ;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 66 | S1 0.01 0.1 0.05 0.05 0.25 OUTLET 67 | S2 0.01 0.1 0.05 0.05 0.25 OUTLET 68 | S3 0.01 0.1 0.05 0.05 0.25 OUTLET 69 | S4 0.01 0.1 0.05 0.05 0.25 OUTLET 70 | S5 0.01 0.1 0.05 0.05 0.25 OUTLET 71 | S6 0.01 0.1 0.05 0.05 0.25 OUTLET 72 | S7 0.01 0.1 0.05 0.05 0.25 OUTLET 73 | 74 | [INFILTRATION] 75 | ;;Subcatchment MaxRate MinRate Decay DryTime MaxInfil 76 | ;;-------------- ---------- ---------- ---------- ---------- ---------- 77 | S1 3.0 0.5 4 7 0 78 | S2 3.0 0.5 4 7 0 79 | S3 3.0 0.5 4 7 0 80 | S4 3.0 0.5 4 7 0 81 | S5 3.0 0.5 4 7 0 82 | S6 3.0 0.5 4 7 0 83 | S7 3.0 0.5 4 7 0 84 | 85 | [JUNCTIONS] 86 | ;;Name Elevation MaxDepth InitDepth SurDepth Aponded 87 | ;;-------------- ---------- ---------- ---------- ---------- ---------- 88 | J1 5 0 0 0 0 89 | J2 4.80 0 0 0 0 90 | J3 5 0 0 0 0 91 | J4 4.80 0 0 0 0 92 | J5 4.50 0 0 0 0 93 | 94 | [OUTFALLS] 95 | ;;Name Elevation Type Stage Data Gated Route To 96 | ;;-------------- ---------- ---------- ---------------- -------- ---------------- 97 | O1 4.20 FREE NO 98 | 99 | [CONDUITS] 100 | ;;Name From Node To Node Length Roughness InOffset OutOffset InitFlow MaxFlow 101 | ;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- 102 | 8 J1 J4 200 60 0 0 0 0 103 | 9 J3 J4 200 60 0 0 0 0 104 | 10 J4 J5 200 60 0 0 0 0 105 | 11 J2 J5 500 60 0 0 0 0 106 | 12 J5 O1 200 60 0 0 0 0 107 | 108 | [XSECTIONS] 109 | ;;Link Shape Geom1 Geom2 Geom3 Geom4 Barrels Culvert 110 | ;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ---------- 111 | 8 CIRCULAR 1 0 0 0 1 112 | 9 CIRCULAR 1 0 0 0 1 113 | 10 CIRCULAR 1 0 0 0 1 114 | 11 CIRCULAR 1 0 0 0 1 115 | 12 CIRCULAR 1 0 0 0 1 116 | 117 | [TIMESERIES] 118 | ;;Name Date Time Value 119 | ;;-------------- ---------- ---------- ---------- 120 | 5mins 01/01/2018 00:00 100 121 | 5mins 01/01/2018 00:01 100 122 | 5mins 01/01/2018 00:02 100 123 | 5mins 01/01/2018 00:03 100 124 | 5mins 01/01/2018 00:04 100 125 | 5mins 01/01/2018 00:05 100 126 | ; 127 | 7mins 01/01/2018 00:00 80 128 | 7mins 01/01/2018 00:01 80 129 | 7mins 01/01/2018 00:02 80 130 | 7mins 01/01/2018 00:03 80 131 | 7mins 01/01/2018 00:04 80 132 | 7mins 01/01/2018 00:05 80 133 | 7mins 01/01/2018 00:06 80 134 | 7mins 01/01/2018 00:07 80 135 | 136 | [REPORT] 137 | ;;Reporting Options 138 | INPUT NO 139 | CONTROLS NO 140 | SUBCATCHMENTS ALL 141 | NODES ALL 142 | LINKS ALL 143 | 144 | [TAGS] 145 | 146 | [MAP] 147 | DIMENSIONS 0.000 0.000 10000.000 10000.000 148 | Units None 149 | 150 | [COORDINATES] 151 | ;;Node X-Coord Y-Coord 152 | ;;-------------- ------------------ ------------------ 153 | J1 377.907 6642.442 154 | J2 -3713.178 3054.264 155 | J3 5558.140 6294.574 156 | J4 1697.674 2945.736 157 | J5 -1883.721 1674.419 158 | O1 -4643.411 899.225 159 | 160 | [VERTICES] 161 | ;;Link X-Coord Y-Coord 162 | ;;-------------- ------------------ ------------------ 163 | 164 | [Polygons] 165 | ;;Subcatchment X-Coord Y-Coord 166 | ;;-------------- ------------------ ------------------ 167 | S1 -735.465 7194.767 168 | S1 1023.256 7369.186 169 | S1 950.581 8851.744 170 | S1 -357.558 9186.047 171 | S1 -1534.884 8023.256 172 | S2 2726.986 5676.357 173 | S2 4427.568 5676.357 174 | S2 4427.568 8060.078 175 | S2 2712.452 8060.078 176 | S3 7345.203 9059.593 177 | S3 7345.203 6661.337 178 | S3 5717.297 6646.802 179 | S3 5731.831 9074.128 180 | S4 7231.105 3582.849 181 | S4 7260.174 6024.709 182 | S4 5559.593 5995.640 183 | S4 5588.663 3582.849 184 | S5 3966.085 3685.078 185 | S5 4998.062 1272.287 186 | S5 3966.085 850.775 187 | S5 2788.760 1126.938 188 | S5 2846.899 3685.078 189 | S6 -2168.605 5014.535 190 | S6 -482.558 4970.930 191 | S6 -511.628 2674.419 192 | S6 -2212.209 2718.023 193 | S6 -2183.140 4854.651 194 | S7 -3092.297 6122.820 195 | S7 -2976.017 3680.959 196 | S7 -4865.552 3637.355 197 | S7 -4880.087 6035.610 198 | 199 | [SYMBOLS] 200 | ;;Gage X-Coord Y-Coord 201 | ;;-------------- ------------------ ------------------ 202 | RG1 -3357.558 8284.884 --------------------------------------------------------------------------------