Skip to content

Commit 1d1d241

Browse files
authored
flow adjsuter fix (#1089)
* flow adjsuter fix * add test * fix adjuster bug
1 parent 3b7bb38 commit 1d1d241

File tree

2 files changed

+115
-4
lines changed
  • src

2 files changed

+115
-4
lines changed

src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java

+19-4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public void run(UUID id) {
198198
double deviation = targetValue - targetValueCurrent;
199199

200200
error = deviation;
201+
201202
if (iterations < 2) {
202203
if (adjustedVariable.equals("mass flow")) {
203204
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation,
@@ -220,9 +221,15 @@ public void run(UUID id) {
220221
double newVal = error / derivate;
221222
if (inputValue - newVal > maxAdjustedValue) {
222223
newVal = inputValue - maxAdjustedValue;
224+
if (Math.abs(oldInputValue - inputValue) < 1e-10) {
225+
error = tolerance * 0.9;
226+
}
223227
}
224228
if (inputValue - newVal < minAdjustedValue) {
225229
newVal = inputValue - minAdjustedValue;
230+
if (Math.abs(oldInputValue - inputValue) < 1e-10) {
231+
error = tolerance * 0.9;
232+
}
226233
}
227234
if (adjustedVariable.equals("mass flow")) {
228235
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
@@ -354,7 +361,9 @@ public void setActivateWhenLess(boolean activateWhenLess) {
354361
}
355362

356363
/**
357-
* <p>Setter for the field <code>maxAdjustedValue</code>.</p>
364+
* <p>
365+
* Setter for the field <code>maxAdjustedValue</code>.
366+
* </p>
358367
*
359368
* @param maxVal a double
360369
*/
@@ -366,7 +375,9 @@ public void setMaxAdjustedValue(double maxVal) {
366375
}
367376

368377
/**
369-
* <p>Setter for the field <code>minAdjustedValue</code>.</p>
378+
* <p>
379+
* Setter for the field <code>minAdjustedValue</code>.
380+
* </p>
370381
*
371382
* @param minVal a double
372383
*/
@@ -378,7 +389,9 @@ public void setMinAdjustedValue(double minVal) {
378389
}
379390

380391
/**
381-
* <p>Getter for the field <code>maxAdjustedValue</code>.</p>
392+
* <p>
393+
* Getter for the field <code>maxAdjustedValue</code>.
394+
* </p>
382395
*
383396
* @return a double
384397
*/
@@ -387,7 +400,9 @@ public double getMaxAdjustedValue() {
387400
}
388401

389402
/**
390-
* <p>Getter for the field <code>minAdjustedValue</code>.</p>
403+
* <p>
404+
* Getter for the field <code>minAdjustedValue</code>.
405+
* </p>
391406
*
392407
* @return a double
393408
*/

src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java

+96
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,102 @@ void testRun() {
4343
*/
4444
}
4545

46+
@Test
47+
void testRunTransientRes2() {
48+
neqsim.thermo.system.SystemInterface fluid1 =
49+
new neqsim.thermo.system.SystemPrEos(298.15, 38.0);
50+
fluid1.addComponent("water", 3.599);
51+
fluid1.addComponent("nitrogen", 0.599);
52+
fluid1.addComponent("CO2", 0.51);
53+
fluid1.addComponent("methane", 99.8);
54+
fluid1.setMixingRule(2);
55+
fluid1.setMultiPhaseCheck(true);
56+
57+
double producxtionIndex = 10.000100751427403E-3;
58+
59+
neqsim.processSimulation.processEquipment.reservoir.SimpleReservoir reservoirOps =
60+
new neqsim.processSimulation.processEquipment.reservoir.SimpleReservoir("Well 1 reservoir");
61+
reservoirOps.setReservoirFluid(fluid1.clone(), 700000000.0, 1.0, 10.0e7);
62+
reservoirOps.setLowPressureLimit(10.0, "bara");
63+
64+
StreamInterface producedGasStream = reservoirOps.addGasProducer("SLP_A32566GI");
65+
producedGasStream.setFlowRate(9.0, "MSm3/day");
66+
67+
neqsim.processSimulation.processEquipment.reservoir.WellFlow wellflow =
68+
new neqsim.processSimulation.processEquipment.reservoir.WellFlow("well flow unit");
69+
wellflow.setInletStream(producedGasStream);
70+
wellflow.setWellProductionIndex(producxtionIndex);
71+
72+
neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills pipe =
73+
new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills(
74+
wellflow.getOutletStream());
75+
pipe.setPipeWallRoughness(5e-6);
76+
pipe.setLength(170.0);
77+
pipe.setElevation(170);
78+
pipe.setDiameter(0.625);
79+
80+
neqsim.processSimulation.processEquipment.compressor.Compressor compressor =
81+
new neqsim.processSimulation.processEquipment.compressor.Compressor("subcomp");
82+
compressor.setInletStream(pipe.getOutletStream());
83+
compressor.setUsePolytropicCalc(true);
84+
compressor.setPolytropicEfficiency(0.6);
85+
compressor.setCompressionRatio(2.0);
86+
87+
neqsim.processSimulation.processEquipment.heatExchanger.Cooler intercooler =
88+
new neqsim.processSimulation.processEquipment.heatExchanger.Cooler(
89+
compressor.getOutletStream());
90+
intercooler.setOutTemperature(25.0, "C");
91+
92+
neqsim.processSimulation.processEquipment.compressor.Compressor compressor2 =
93+
new neqsim.processSimulation.processEquipment.compressor.Compressor("subcomp2");
94+
compressor2.setInletStream(intercooler.getOutletStream());
95+
compressor2.setUsePolytropicCalc(true);
96+
compressor2.setPolytropicEfficiency(0.6);
97+
compressor2.setCompressionRatio(2.0);
98+
99+
100+
neqsim.processSimulation.processEquipment.heatExchanger.Heater cooler1 =
101+
new neqsim.processSimulation.processEquipment.heatExchanger.Heater("cooler 1",
102+
compressor2.getOutletStream());
103+
cooler1.setOutTemperature(30.0, "C");
104+
105+
neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills pipeline =
106+
new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills(
107+
cooler1.getOutletStream());
108+
pipeline.setPipeWallRoughness(50e-6);
109+
pipeline.setLength(50 * 1e3);
110+
pipeline.setElevation(0);
111+
pipeline.setDiameter(17.0 * 0.0254);
112+
double richgas_inlet_pressure = 150.0;
113+
double max_gas_production = 9.0;
114+
115+
neqsim.processSimulation.processEquipment.util.Adjuster adjuster =
116+
new neqsim.processSimulation.processEquipment.util.Adjuster("adjuster");
117+
adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure", richgas_inlet_pressure,
118+
"bara");
119+
adjuster.setAdjustedVariable(producedGasStream, "flow", "MSm3/day");
120+
adjuster.setMaxAdjustedValue(max_gas_production);
121+
adjuster.setMinAdjustedValue(1.0);
122+
123+
124+
neqsim.processSimulation.processSystem.ProcessSystem process =
125+
new neqsim.processSimulation.processSystem.ProcessSystem();
126+
process.add(reservoirOps);
127+
process.add(wellflow);
128+
process.add(pipe);
129+
process.add(compressor);
130+
process.add(intercooler);
131+
process.add(compressor2);
132+
process.add(cooler1);
133+
process.add(pipeline);
134+
process.add(adjuster);
135+
process.run();
136+
137+
System.out
138+
.println("gas production " + reservoirOps.getGasProdution("Sm3/day") / 1e6 + " MSm3/day");
139+
140+
}
141+
46142
@Test
47143
void testRunTransient() {
48144
neqsim.thermo.system.SystemInterface fluid1 =

0 commit comments

Comments
 (0)