Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Jan 4, 2024
1 parent a528a35 commit e4c56a8
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,17 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do
thermoSystem.initProperties();
SystemInterface thermoSystem2 = thermoSystem.clone();
thermoSystem.setEmptyFluid();
double relFact = (gasVolume + oilVolume) / (thermoSystem2.getPhase("oil").getVolume("m3"));
double relFact = (gasVolume + oilVolume) / (thermoSystem2.getPhase(0).getVolume("m3"));
for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) {
thermoSystem.addComponent(thermoSystem.getComponent(i).getComponentNumber(),
relFact * thermoSystem2.getComponent(i).getNumberOfMolesInPhase());
}
double relFactWater = (waterVolume) / (thermoSystem2.getPhase("aqueous").getVolume("m3"));
thermoSystem.addComponent("water", relFactWater
* thermoSystem2.getPhase("aqueous").getComponent("water").getNumberOfMolesInPhase());
thermoSystem2.initProperties();
double relFactWater = waterVolume / (thermoSystem2.getPhase("aqueous").getVolume("m3"));
for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) {
thermoSystem.addComponent(thermoSystem.getComponent(i).getComponentNumber(), relFactWater
* thermoSystem2.getPhase("aqueous").getComponent(i).getNumberOfMolesInPhase());
}
}

/*
Expand Down Expand Up @@ -867,6 +870,6 @@ public void setLowPressureLimit(double value, String unit) {

public double getLowPressureLimit(String unit) {
PressureUnit conver = new PressureUnit(lowPressureLimit, "bara");
return conver.getValue(unit);
return conver.getValue(unit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface
private String pressureUnit = "bara";
private boolean acceptNegativeDP = true;
ValveMechanicalDesign valveMechanicalDesign;
boolean isCalcPressure = false;



/**
* <p>
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 @@ -193,6 +204,7 @@ public void run(UUID id) {
thermoSystem.setPressure(pressure, pressureUnit);
}


if (getSpecification().equals("out stream")) {
thermoSystem.setPressure(outStream.getPressure(), pressureUnit);
}
Expand Down Expand Up @@ -459,4 +471,8 @@ public void initMechanicalDesign() {
public ValveMechanicalDesign getMechanicalDesign() {
return valveMechanicalDesign;
}

public void setIsCalcOutPressure(boolean isSetPres) {
isCalcPressure = isSetPres;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import neqsim.processSimulation.processEquipment.compressor.Compressor;
import neqsim.processSimulation.processEquipment.heatExchanger.Cooler;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.processEquipment.valve.ThrottlingValve;

public class SimpleReservoirTest {
static Logger logger = LogManager.getLogger(SimpleReservoirTest.class);
Expand Down Expand Up @@ -65,4 +68,85 @@ void testRun2() {
Assertions.assertEquals(52.0, reservoirOps.getLowPressureLimit("bara"), 0.1);
Assertions.assertEquals(52.0e5, reservoirOps.getLowPressureLimit("Pa"), 0.1);
}

@Test
void testPureGasReservoir() {
neqsim.thermo.system.SystemInterface fluid1 =
new neqsim.thermo.system.SystemPrEos(273.15 + 13, 59.7);
fluid1.addComponent("water", 1.1);
fluid1.addComponent("methane", 99.5);
fluid1.addComponent("nitrogen", 0.45);
fluid1.setMixingRule("classic");
fluid1.setMultiPhaseCheck(true);

SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir");
reservoirOps.setReservoirFluid(fluid1, 1 * 27 * 1e9 / 60.0, 0.0, 1.0e9);
reservoirOps.setLowPressureLimit(5.0, "bara");

StreamInterface producedGasStream = reservoirOps.addGasProducer("gas producer 1");
// StreamInterface producedWaterStream = reservoirOps.addWaterProducer("water producer 1");

double[] productionprofile = new double[] {10.38, 9.9, 9.22, 8.18, 6.94, 5.83, 4.91, 4.09, 3.41,
2.86, 2.35, 2.35, 2.35, 2.35, 2.35, 2.35, 2.35, 2.35};
// double[] producedwaterprofile =
// new double[] {1e-12, 1e-12, 1e-12, 50.0, 100.94, 5.83, 4.91, 4.09};
reservoirOps.run();

System.out.println("OGIP " + reservoirOps.getOGIP("GSm3") + " GMSm3");
double deltaTime = 24 * 60 * 60.0 * 365;
for (int i = 0; i < 13; i++) {

producedGasStream.setFlowRate(productionprofile[i], "MSm3/day");
// producedWaterStream.setFlowRate(producedwaterprofile[i] * 1000.0, "kg/day");
System.out.println("pressure " + reservoirOps.getReservoirFluid().getPressure("bara")
+ " water in gas " + producedGasStream.getFluid().getComponent("water").getx()
+ " produced MSm3oe " + reservoirOps.getProductionTotal("MSm3 oe"));
reservoirOps.runTransient(deltaTime);

System.out
.println("flow calc" + Math.sqrt((10.0) / reservoirOps.getFluid().getDensity("kg/m3")));
}
// valve1.setOutletPressure(51);
// valve1.run();
ThrottlingValve valve1 = new ThrottlingValve("valve1", producedGasStream);
// valve1.setOutletPressure(51);
valve1.setCv(25443.44371323);
valve1.setIsCalcOutPressure(true);
valve1.run();
System.out.println("flow " + valve1.getOutletStream().getFlowRate("MSm3/day"));
System.out.println("out pres " + valve1.getOutletPressure());
System.out.println("Cv " + valve1.getCv());

Compressor subseaCompressor = new Compressor("compressor 1", valve1.getOutletStream());
subseaCompressor.setOutletPressure(40.0, "bara");
subseaCompressor.setPolytropicEfficiency(0.8);
subseaCompressor.setUsePolytropicCalc(true);
subseaCompressor.run();

System.out.println("compressor power " + subseaCompressor.getPower("MW") + " head "
+ subseaCompressor.getPolytropicFluidHead() + " kJ/kg" + " flow "
+ subseaCompressor.getInletStream().getFlowRate("m3/hr") + " m3/hr " + " pressure out "
+ subseaCompressor.getOutletPressure() + " pressure in "
+ subseaCompressor.getInletPressure() + " pressure ratio "
+ subseaCompressor.getOutletPressure() / subseaCompressor.getInletPressure());

Cooler cooler1 = new Cooler("cooler1", subseaCompressor.getOutletStream());
cooler1.setOutTemperature(30.0, "C");

Compressor subseaCompressor2 = new Compressor("compressor 1", cooler1.getOutletStream());
subseaCompressor2.setOutletPressure(170.0, "bara");
subseaCompressor2.setPolytropicEfficiency(0.8);
subseaCompressor2.setUsePolytropicCalc(true);
subseaCompressor2.run();

System.out.println("compressor power " + subseaCompressor2.getPower("MW") + " head "
+ subseaCompressor2.getPolytropicFluidHead() + " kJ/kg" + " flow "
+ subseaCompressor2.getInletStream().getFlowRate("m3/hr") + " m3/hr " + " pressure out "
+ subseaCompressor2.getOutletPressure() + " pressure in "
+ subseaCompressor2.getInletPressure() + " pressure ratio "
+ subseaCompressor2.getOutletPressure() / subseaCompressor2.getInletPressure());



}
}

0 comments on commit e4c56a8

Please sign in to comment.