Skip to content

Commit

Permalink
possible to calc out pressure of valve (#897)
Browse files Browse the repository at this point in the history
* possible to calc out pressure of valve

* added test to pipeline flow

* remove output

* prepare version 2.5.16
  • Loading branch information
EvenSol authored Jan 8, 2024
1 parent 72f24b1 commit c757026
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 92 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>${revision}${sha1}${changelist}</version>

<properties>
<revision>2.5.15</revision>
<revision>2.5.16</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sha1/>
Expand Down
2 changes: 1 addition & 1 deletion pomJava21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>${revision}${sha1}${changelist}</version>

<properties>
<revision>2.5.15</revision>
<revision>2.5.16</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sha1/>
Expand Down
2 changes: 1 addition & 1 deletion pomJava8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>${revision}${sha1}${changelist}-Java8</version>

<properties>
<revision>2.5.15</revision>
<revision>2.5.16</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sha1 />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface
private String pressureUnit = "bara";
private boolean acceptNegativeDP = true;
ValveMechanicalDesign valveMechanicalDesign;
boolean isCalcPressure = false;

/**
* <p>
Expand All @@ -53,8 +54,9 @@ public ThrottlingValve() {
* Constructor for ThrottlingValve.
* </p>
*
* @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) {
Expand All @@ -75,9 +77,10 @@ public ThrottlingValve(String name) {
* Constructor for ThrottlingValve.
* </p>
*
* @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);
Expand Down Expand Up @@ -135,7 +138,7 @@ public void setPressure(double pressure) {
* </p>
*
* @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);
Expand All @@ -154,7 +157,7 @@ public void setOutletPressure(double pressure) {
* </p>
*
* @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;
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand All @@ -73,15 +72,15 @@ 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);
pipeline.setDiameter(0.725);

ThrottlingValve chokeValve = new ThrottlingValve("chocke");
chokeValve.setInletStream(pipeline.getOutletStream());
chokeValve.setOutletPressure(55.0, "bara");
chokeValve.setOutletPressure(5.0, "bara");


Adjuster adjuster = new Adjuster("adjuster");
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit c757026

Please sign in to comment.