diff --git a/pom.xml b/pom.xml index 8eb17538ae..65791ebfaa 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ ${revision}${sha1}${changelist} - 2.5.15 + 2.5.16 UTF-8 UTF-8 diff --git a/pomJava21.xml b/pomJava21.xml index e05bea9a32..0e35054d46 100644 --- a/pomJava21.xml +++ b/pomJava21.xml @@ -10,7 +10,7 @@ ${revision}${sha1}${changelist} - 2.5.15 + 2.5.16 UTF-8 UTF-8 diff --git a/pomJava8.xml b/pomJava8.xml index 953f0ebd20..336078f3d1 100644 --- a/pomJava8.xml +++ b/pomJava8.xml @@ -10,7 +10,7 @@ ${revision}${sha1}${changelist}-Java8 - 2.5.15 + 2.5.16 UTF-8 UTF-8 diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java index 2595102492..a11ce27278 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java @@ -159,9 +159,9 @@ public double calcPressureOut() { * system.getTemperature() / Math.pow(insideDiameter, 5.0); // \\System.out.println("friction fact" + frictionFactor + " velocity " + // velocity + " reynolds number " + reynoldsNumber); - System.out.println("dp gravity " - + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity - * (inletElevation - outletElevation) / 1.0e5); + // System.out.println("dp gravity " + // + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity + // * (inletElevation - outletElevation) / 1.0e5); double dp_gravity = system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity * (inletElevation - outletElevation); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java index 47152a99d4..fffb656ffd 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java @@ -249,7 +249,7 @@ public void setEquilibriumHeatTransfer(boolean test) { /** {@inheritDoc} */ @Override public void run(UUID id) { - system = inStream.getThermoSystem(); + system = inStream.getThermoSystem().clone(); GeometryDefinitionInterface[] pipeGemometry = new PipeData[numberOfLegs + 1]; for (int i = 0; i < pipeDiameters.length; i++) { pipeGemometry[i] = new PipeData(pipeDiameters[i], pipeWallRoughness[i]); @@ -344,4 +344,9 @@ public double getEntropyProduction(String unit) { return outStream.getThermoSystem().getEntropy(unit) - inStream.getThermoSystem().getEntropy(unit); } + + + public double getOutletPressure(String unit) { + return outStream.getPressure(unit); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java index 9441f872a1..c9be581df5 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java @@ -37,6 +37,7 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface private String pressureUnit = "bara"; private boolean acceptNegativeDP = true; ValveMechanicalDesign valveMechanicalDesign; + boolean isCalcPressure = false; /** *

@@ -53,8 +54,9 @@ public ThrottlingValve() { * Constructor for ThrottlingValve. *

* - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @param inletStream a + * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object */ @Deprecated public ThrottlingValve(StreamInterface inletStream) { @@ -75,9 +77,10 @@ public ThrottlingValve(String name) { * Constructor for ThrottlingValve. *

* - * @param name a {@link java.lang.String} object - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object + * @param name a {@link java.lang.String} object + * @param inletStream a + * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object */ public ThrottlingValve(String name, StreamInterface inletStream) { super(name); @@ -135,7 +138,7 @@ public void setPressure(double pressure) { *

* * @param pressure a double - * @param unit a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object */ public void setPressure(double pressure, String unit) { setOutletPressure(pressure, unit); @@ -154,7 +157,7 @@ public void setOutletPressure(double pressure) { *

* * @param pressure a double - * @param unit a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object */ public void setOutletPressure(double pressure, String unit) { pressureUnit = unit; @@ -185,6 +188,14 @@ public void run(UUID id) { ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoSystem.init(3); double enthalpy = thermoSystem.getEnthalpy(); + + if (valveCvSet && isCalcPressure) { + double outp = (inStream.getThermoSystem().getPressure() + - Math.pow(inStream.getThermoSystem().getTotalNumberOfMoles() / Cv + / getPercentValveOpening() * 100.0, 2.0) * thermoSystem.getDensity()); + setOutletPressure(outp); + } + if ((thermoSystem.getPressure(pressureUnit) - pressure) < 0) { if (isAcceptNegativeDP()) { thermoSystem.setPressure(pressure, pressureUnit); @@ -211,7 +222,8 @@ public void run(UUID id) { // inletStream.getThermoSystem().getDensity()); if (!valveCvSet) { - // If valve CV is not set, calculate it from inletstream flow, percent opening and + // If valve CV is not set, calculate it from inletstream flow, percent opening + // and // differential pressure over valve. Cv = inStream.getThermoSystem().getTotalNumberOfMoles() / (getPercentValveOpening() / 100.0 * Math.sqrt( @@ -449,14 +461,20 @@ public void initMechanicalDesign() { valveMechanicalDesign = new ValveMechanicalDesign(this); } - /** * {@inheritDoc} * - * @return a {@link neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign} object + * @return a + * {@link neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign} + * object */ @Override public ValveMechanicalDesign getMechanicalDesign() { return valveMechanicalDesign; } + + public void setIsCalcOutPressure(boolean isSetPres) { + isCalcPressure = isSetPres; + } + } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java new file mode 100644 index 0000000000..2281e58ebb --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java @@ -0,0 +1,70 @@ +package neqsim.processSimulation.processEquipment.pipeline; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; + +public class PipelineTest { + + @Test + public void testMain() { + + double flow = 60.0; + double temperature = 20.0; + double pressure = 200.0; + + double diameter = 1.0; + double length = 700000.0; + double elevation = 0; + double wallroughness = 5e-6; + + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + temperature), pressure); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + testSystem.setMixingRule("classic"); + + Stream stream_1 = new Stream("Stream1", testSystem); + stream_1.setFlowRate(flow, "MSm3/day"); + stream_1.setTemperature(temperature, "C"); + stream_1.setPressure(pressure, "bara"); + + stream_1.run(); + OnePhasePipeLine pipeline = new OnePhasePipeLine("pipeline", stream_1); + pipeline.setNumberOfLegs(1); + pipeline.setPipeDiameters(new double[] {diameter, diameter}); + pipeline.setLegPositions(new double[] {0, length}); + pipeline.setHeightProfile(new double[] {0, elevation}); + pipeline.setPipeWallRoughness(new double[] {wallroughness, wallroughness}); + pipeline.setOuterTemperatures(new double[] {temperature + 273.15, temperature + 273.15}); + pipeline.setPipeOuterHeatTransferCoefficients(new double[] {15.0, 15.0}); + pipeline.setPipeWallHeatTransferCoefficients(new double[] {15.0, 15.0}); + + AdiabaticPipe simplePipeline = new AdiabaticPipe("simplePipeline", stream_1); + simplePipeline.setDiameter(diameter); + simplePipeline.setLength(length); + simplePipeline.setPipeWallRoughness(wallroughness); + simplePipeline.setInletElevation(0); + simplePipeline.setOutletElevation(elevation); + + PipeBeggsAndBrills beggsBrilsPipe = new PipeBeggsAndBrills("simplePipeline 2", stream_1); + beggsBrilsPipe.setPipeWallRoughness(wallroughness); + beggsBrilsPipe.setLength(length); + beggsBrilsPipe.setElevation(elevation); + beggsBrilsPipe.setDiameter(diameter); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(pipeline); + operations.add(simplePipeline); + operations.add(beggsBrilsPipe); + operations.run(); + + // pipeline.run(); + + Assertions.assertEquals(123.876927, pipeline.getOutletPressure("bara"), 0.1); + Assertions.assertEquals(120.711887695240, simplePipeline.getOutletPressure(), 0.1); + Assertions.assertEquals(113.983562217178, beggsBrilsPipe.getOutletPressure(), 0.1); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java index 7467c8ddcb..1f9fa0e3fc 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.reservoir; import org.junit.jupiter.api.Test; -import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.processSimulation.processEquipment.util.Adjuster; @@ -48,7 +47,7 @@ void testRun() { @Test void testRunTransient() { neqsim.thermo.system.SystemInterface fluid1 = - new neqsim.thermo.system.SystemPrEos(373.15, 100.0); + new neqsim.thermo.system.SystemPrEos(298.15, 60.0); fluid1.addComponent("water", 3.599); fluid1.addComponent("nitrogen", 0.599); fluid1.addComponent("CO2", 0.51); @@ -57,7 +56,7 @@ void testRunTransient() { fluid1.setMultiPhaseCheck(true); SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); - reservoirOps.setReservoirFluid(fluid1, 1e9, 1.0, 10.0e7); + reservoirOps.setReservoirFluid(fluid1, 7e8, 1.0, 10.0e7); reservoirOps.setLowPressureLimit(10.0, "bara"); StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1"); @@ -73,7 +72,7 @@ void testRunTransient() { pipe.setElevation(300); pipe.setDiameter(0.625); - PipeBeggsAndBrills pipeline = new PipeBeggsAndBrills(wellflow.getOutletStream()); + PipeBeggsAndBrills pipeline = new PipeBeggsAndBrills(pipe.getOutletStream()); pipeline.setPipeWallRoughness(5e-6); pipeline.setLength(60000.0); pipeline.setElevation(200); @@ -81,7 +80,7 @@ void testRunTransient() { ThrottlingValve chokeValve = new ThrottlingValve("chocke"); chokeValve.setInletStream(pipeline.getOutletStream()); - chokeValve.setOutletPressure(55.0, "bara"); + chokeValve.setOutletPressure(5.0, "bara"); Adjuster adjuster = new Adjuster("adjuster"); @@ -110,84 +109,30 @@ void testRunTransient() { */ // process.setTimeStep(60 * 60 * 24 * 365); - for (int i = 0; i < 10; i++) { - reservoirOps.runTransient(60 * 60 * 24 * 365); + for (int i = 0; i < 800; i++) { + reservoirOps.runTransient(60 * 60 * 365); process.run(); - /* - * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); - * System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara")); - * System.out .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") + - * " bara"); - * - * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + - * " bara"); System.out .println("top side pressure " + - * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out - * .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3"); - * System.out.println("gas velocity " + pipeline.getSuperficialVelocity()); - */ - } - - Compressor compressor = new Compressor("subcomp"); - compressor.setInletStream(pipe.getOutletStream()); - compressor.setCompressionRatio(3.0); - pipeline.setInletStream(compressor.getOutletStream()); + if (pipeline.getOutletStream().getPressure("bara") < 5.0) { + continue; + } - process.add(3, compressor); + System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); + System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara")); + System.out + .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") + " bara"); - for (int i = 0; i < 8; i++) { - reservoirOps.runTransient(60 * 60 * 24 * 365); - process.run(); - /* - * System.out.println("Compressor in pressure " + compressor.getInletStream().getPressure() + - * " out pressure " + compressor.getOutletStream().getPressure() + " flow " + - * compressor.getInletStream().getFlowRate("m3/hr")); - * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); - * System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara")); - * System.out .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") + - * " bara"); - * - * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + - * " bara"); System.out .println("top side pressure " + - * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out - * .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3"); - * System.out.println("gas velocity " + pipeline.getSuperficialVelocity()); - */ + System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + " bara"); + System.out + .println("top side pressure " + pipeline.getOutletStream().getPressure("bara") + " bara"); + System.out + .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3"); + System.out.println("gas velocity " + pipeline.getSuperficialVelocity()); } - adjuster.setMaxAdjustedValue(4.0); - adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure", 22.0, "bara"); - boolean reset = false; - for (int i = 0; i < 35; i++) { - if (wellflow.getOutletStream().getPressure("bara") > 15 || reset) { - reset = false; - reservoirOps.runTransient(60 * 60 * 24 * 365); - compressor.setOutletPressure(pipe.getOutletPressure() * 3.5); - process.run(); - /* - * System.out.println("Compressor in pressure " + compressor.getInletStream().getPressure() - * + " out pressure " + compressor.getOutletStream().getPressure() + " flow " + - * compressor.getInletStream().getFlowRate("m3/hr")); - * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); - * System.out.println("reservoir pressure " + - * wellflow.getInletStream().getPressure("bara")); System.out .println("pres bottomhole " + - * wellflow.getOutletStream().getPressure("bara") + " bara"); - * - * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + - * " bara"); System.out.println( "top side pressure " + - * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out.println( - * "Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3"); - * System.out.println("gas velocity " + pipeline.getSuperficialVelocity()); - */ - } else { - reset = true; - adjuster.setMaxAdjustedValue(adjuster.getMaxAdjustedValue() / 2.0); - adjuster.setMinAdjustedValue(adjuster.getMinAdjustedValue() / 2.0); - } - - } } + @Test void testCalcWellFlow() { neqsim.thermo.system.SystemInterface fluid1 =