Skip to content

Commit

Permalink
possible to calc out pressure of valve
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Jan 5, 2024
1 parent d414887 commit 13d449c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 85 deletions.
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
@@ -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 13d449c

Please sign in to comment.