Skip to content

Commit d2c2c04

Browse files
committed
Bug fix issue 'No quality data generated'
HydraulicSim manages a QualitySim data member when Water quality analysis is needed in order to fill the water quality data in output. It fixes the issue: #4
1 parent e3b8873 commit d2c2c04

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/org/addition/epanet/hydraulic/HydraulicSim.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.addition.epanet.network.structures.*;
3434
import org.addition.epanet.network.structures.Link.LinkType;
3535
import org.addition.epanet.network.structures.Link.StatType;
36+
import org.addition.epanet.quality.QualitySim;
3637
import org.addition.epanet.util.ENException;
3738
import org.addition.epanet.util.Utilities;
3839

@@ -151,6 +152,11 @@ private NetSolveStep(int iter, double relerr) {
151152
*/
152153
protected PipeHeadModel pHLModel;
153154

155+
/**
156+
* Optional related QualitySim when Water quality analysis is needed.
157+
*/
158+
protected QualitySim qualitySim;
159+
154160
/**
155161
* Get current hydraulic simulation time.
156162
*
@@ -183,6 +189,7 @@ public HydraulicSim(Network net, Logger log) throws ENException {
183189
running = false;
184190
logger = log;
185191
createSimulationNetwork(tmpNodes, tmpLinks, net);
192+
if (!net.getPropertiesMap().getQualflag().equals(PropertiesMap.QualType.NONE)) qualitySim = new QualitySim(net, log);
186193
}
187194

188195
protected void createSimulationNetwork(List<Node> tmpNodes, List<Link> tmpLinks, Network net) throws ENException {
@@ -692,7 +699,12 @@ protected long nextHyd() throws ENException, IOException {
692699
long hydstep = 0;
693700

694701
if (simulationOutput != null)
695-
AwareStep.write(simulationOutput, this, Htime);
702+
{
703+
if (qualitySim != null)
704+
AwareStep.writeHydAndQual(simulationOutput, this, qualitySim, Rtime-Htime, Htime);
705+
else
706+
AwareStep.write(simulationOutput, this, Htime);
707+
}
696708

697709
if (Htime < pMap.getDuration())
698710
hydstep = timeStep();
@@ -708,6 +720,11 @@ else if (Htime < pMap.getDuration())
708720
Rtime += pMap.getRstep();
709721
}
710722

723+
if (qualitySim != null) {
724+
for (long i = 0, qstep = pMap.getQstep(), numQsteps = hydstep/pMap.getQstep(); i < numQsteps; i++) {
725+
qualitySim.simulateSingleStep(nNodes, nLinks, qstep);
726+
}
727+
}
711728
return hydstep;
712729
}
713730

0 commit comments

Comments
 (0)