diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java index 622308a51b..e20295fe14 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java @@ -325,66 +325,42 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do this.gasVolume = gasVolume; this.waterVolume = waterVolume; - if (gasVolume > 1e-10 && oilVolume > 1e-10) { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + + if (waterVolume > 1e-10 && !thermoSystem.hasPhaseType("aqueous")) { + thermoSystem.addComponent("water", thermoSystem.getTotalNumberOfMoles()); ops.TPflash(); - thermoSystem.initProperties(); - SystemInterface thermoSystem2 = thermoSystem.clone(); - thermoSystem.setEmptyFluid(); - for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { - double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - if (j >= 1) { - if (j == 1) { - relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); - } else if (j == 2) { - relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += waterVolume / - // thermoSystem2.getPhase(j).getMolarVolume(); - } - } - for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { - thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); - } + } + + thermoSystem.initProperties(); + SystemInterface thermoSystem2 = thermoSystem.clone(); + thermoSystem.setEmptyFluid(); + for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { + String phaseType = thermoSystem.getPhase(j).getPhaseTypeName(); + double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + if (phaseType.equals("oil")) { + relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); + } else if (phaseType.equals("aqueous")) { + relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + } else { + relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); } - } else { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); - ops.TPflash(); - thermoSystem.initProperties(); - SystemInterface thermoSystem2 = thermoSystem.clone(); - thermoSystem.setEmptyFluid(); - double relFact = (gasVolume + oilVolume) / (thermoSystem2.getPhase("oil").getVolume("m3")); - for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) { - thermoSystem.addComponent(thermoSystem.getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getComponent(i).getNumberOfMolesInPhase()); + for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { + thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), + relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); } - double relFactWater = (waterVolume) / (thermoSystem2.getPhase("aqueous").getVolume("m3")); - thermoSystem.addComponent("water", relFactWater - * thermoSystem2.getPhase("aqueous").getComponent("water").getNumberOfMolesInPhase()); } - /* - * if (thermoSystem.hasPhaseType("gas")) { thermoSystem.setBeta(gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() / (gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() + oilVolume / - * thermoSystem2.getPhase(1).getMolarVolume())); } - */ + ThermodynamicOperations ops2 = new ThermodynamicOperations(thermoSystem); ops2.TPflash(); thermoSystem.initProperties(); - // thermoSystem.display(); - // gasOutStream = new Stream(); - // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); reservoirVolume = gasVolume + oilVolume + waterVolume; - OOIP = - - getOilInPlace("Sm3"); + OOIP = getOilInPlace("Sm3"); OGIP = getGasInPlace("Sm3"); - // oilOutStream = new Stream(); - // oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); - lowPressureLimit = 50.0; } @@ -867,6 +843,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); } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java index daef85468a..7467c8ddcb 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java @@ -188,5 +188,31 @@ void testRunTransient() { } } + @Test + void testCalcWellFlow() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemPrEos(373.15, 100.0); + fluid1.addComponent("water", 3.599); + fluid1.addComponent("nitrogen", 0.599); + fluid1.addComponent("CO2", 0.51); + fluid1.addComponent("methane", 62.8); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(fluid1, 1e9, 1.0, 10.0e7); + reservoirOps.setLowPressureLimit(10.0, "bara"); + + StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1"); + producedGasStream.setFlowRate(9.0, "MSm3/day"); + + WellFlow wellflow = new WellFlow("well flow unit"); + wellflow.setInletStream(producedGasStream); + + double permeability = 50.0; // milli darcy + // wellflow.setDarcyLawParameters(permeability, ); + // wellflow.setWellProductionIndex(10.000100751427403E-3); + } + }