Skip to content

Commit

Permalink
Create WellAllocator.java (#384)
Browse files Browse the repository at this point in the history
* Create WellAllocator.java

* Create WellAllocatorResponse.java

* updates

* update
  • Loading branch information
EvenSol authored Apr 9, 2022
1 parent a11f861 commit ddfaa0d
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package neqsim.processSimulation.measurementDevice;

import neqsim.processSimulation.processEquipment.separator.Separator;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.processSimulation.util.monitor.WellAllocatorResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

public class WellAllocator extends MeasurementDeviceBaseClass {

protected StreamInterface wellStream = null;
protected StreamInterface exportGasStream = null;
protected StreamInterface exportOilStream = null;

public WellAllocator() {
name = "Well Allocator";
}


public WellAllocator(StreamInterface stream) {
name = "Well Allocator";
this.wellStream = stream;
}

public WellAllocator(String streamname, StreamInterface stream) {
this(stream);
name = streamname;
}


public void setExportGasStream(StreamInterface stream) {
this.exportGasStream = stream;
}

public void setExportOilStream(StreamInterface stream) {
this.exportOilStream = stream;
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue() {
return wellStream.getThermoSystem().getFlowRate("kg/hr");
}

/** {@inheritDoc} */
@Override
public double getMeasuredValue(String measurement) {
int numberOfComps = wellStream.getThermoSystem().getNumberOfComponents();
double[] splitFactors = new double[numberOfComps];
double gasExportFlow = 0.0;
double oilExportFlow = 0.0;
for (int i = 0; i < numberOfComps; i++) {
splitFactors[i] = exportGasStream.getFluid().getComponent(i).getFlowRate("kg/hr")
/ (exportGasStream.getFluid().getComponent(i).getFlowRate("kg/hr")
+ exportOilStream.getFluid().getComponent(i).getFlowRate("kg/hr"));
gasExportFlow += wellStream.getFluid().getComponent(i).getTotalFlowRate("kg/hr") * splitFactors[i];
oilExportFlow +=
wellStream.getFluid().getComponent(i).getTotalFlowRate("kg/hr") * (1.0 - splitFactors[i]);
}

if (measurement.equals("gas export rate")) {
return gasExportFlow;
}
if (measurement.equals("oil export rate")) {
return oilExportFlow;
}
if (measurement.equals("total export rate")) {
return wellStream.getFluid().getFlowRate("kg/hr");
}
return 0.0;
}

public static void main(String[] args) {
SystemInterface testFluid = new SystemSrkEos(338.15, 50.0);
testFluid.addComponent("nitrogen", 1.205);
testFluid.addComponent("CO2", 1.340);
testFluid.addComponent("methane", 87.974);
testFluid.addComponent("ethane", 5.258);
testFluid.addComponent("propane", 3.283);
testFluid.addComponent("i-butane", 0.082);
testFluid.addComponent("n-butane", 0.487);
testFluid.addComponent("i-pentane", 0.056);
testFluid.addComponent("n-pentane", 1.053);
testFluid.addComponent("nC10", 14.053);
testFluid.setMixingRule(2);

testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(2500.0, "kg/hr");

Stream stream_1 = new Stream("Stream1", testFluid);

SystemInterface testFluid2 = testFluid.clone();
// testFluid2.setMolarComposition(new double[] {0.1, 0.1, 0.9, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0});
Stream stream_2 = new Stream("Stream2", testFluid2);

Separator sep1 = new Separator("sep1", stream_1);
sep1.addStream(stream_2);

Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream());

Stream stream_oilExp = new Stream("gasexp", sep1.getLiquidOutStream());

WellAllocator wellAlloc = new WellAllocator("alloc", stream_1);
wellAlloc.setExportGasStream(stream_gasExp);
wellAlloc.setExportOilStream(stream_oilExp);

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(stream_2);
operations.add(sep1);
operations.add(stream_gasExp);
operations.add(stream_oilExp);
operations.add(wellAlloc);
operations.run();

WellAllocatorResponse responsAl = new WellAllocatorResponse(wellAlloc);

System.out.println("name " + responsAl.name);
System.out.println("gas flow " + responsAl.gasExportRate);
System.out.println("oil flow " + responsAl.oilExportRate);
System.out.println("total flow " + responsAl.totalExportRate);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package neqsim.processSimulation.util.monitor;

import neqsim.processSimulation.measurementDevice.WellAllocator;

/**
* <p>
* WellAllocatorResponse class.
* </p>
*
* @author asmund
* @version $Id: $Id
*/
public class WellAllocatorResponse {
public String name;
public Double gasExportRate, oilExportRate, totalExportRate;

/**
* <p>
* Constructor for WellAllocatorResponse.
* </p>
*/
public WellAllocatorResponse() {}

/**
* <p>
* Constructor for WellAllocatorResponse.
* </p>
*
* @param inputAllocator a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object
*/
public WellAllocatorResponse(WellAllocator inputAllocator) {
name = inputAllocator.getName();
gasExportRate = inputAllocator.getMeasuredValue("gas export rate");
oilExportRate = inputAllocator.getMeasuredValue("oil export rate");
totalExportRate = inputAllocator.getMeasuredValue("total export rate");
}
}
3 changes: 3 additions & 0 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -2496,4 +2496,7 @@ public void setImplementedCompositionDeriativesofFugacity(
/** {@inheritDoc} */
@Override
public int hashCode();

/** {@inheritDoc} */
public void addToComponentNames(java.lang.String name);
}
13 changes: 12 additions & 1 deletion src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3813,7 +3813,18 @@ public java.lang.String getFluidName() {
public void setFluidName(java.lang.String fluidName) {
this.fluidName = fluidName;
}


public void addToComponentNames(java.lang.String name) {
for(int j=0;j<componentNames.size();j++) {
componentNames.set(j, componentNames.get(j)+name);
}
for (int i = 0; i < getMaxNumberOfPhases(); i++) {
for(int j=0;j<componentNames.size();j++) {
getPhase(i).getComponent(j).setComponentName(getPhase(i).getComponent(j).getComponentName()+name);
}
}
}

/**
* <p>
* setLastTBPasPlus.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
*
*/
package neqsim.processSimulation.measurementDevice;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import neqsim.processSimulation.processEquipment.separator.Separator;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.util.monitor.WellAllocatorResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

/**
* @author ESOL
*
*/
class WellAllocatorTest extends neqsim.NeqSimTest{

/**
* @throws java.lang.Exception
*/
@BeforeAll
static void setUpBeforeClass() throws Exception {}

/**
* Test method for {@link neqsim.processSimulation.measurementDevice.WellAllocator#getMeasuredValue(java.lang.String)}.
*/
@Test
void testGetMeasuredValueString() {
SystemInterface testFluid = new SystemSrkEos(338.15, 50.0);
testFluid.addComponent("nitrogen", 1.205);
testFluid.addComponent("CO2", 1.340);
testFluid.addComponent("methane", 87.974);
testFluid.addComponent("ethane", 5.258);
testFluid.addComponent("propane", 3.283);
testFluid.addComponent("i-butane", 0.082);
testFluid.addComponent("n-butane", 0.487);
testFluid.addComponent("i-pentane", 0.056);
testFluid.addComponent("n-pentane", 1.053);
testFluid.addComponent("nC10", 14.053);
testFluid.setMixingRule(2);

testFluid.addToComponentNames("_well1");

testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(2500.0, "kg/hr");


SystemInterface testFluid2 = testFluid.clone();


testFluid.setTemperature(24.0, "C");
testFluid.setPressure(48.0, "bara");
testFluid.setTotalFlowRate(2500.0, "kg/hr");

Stream stream_1 = new Stream("Stream1", testFluid);

Stream stream_2 = new Stream("Stream2", testFluid2);

Separator sep1 = new Separator("sep1", stream_1);
sep1.addStream(stream_2);

Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream());

Stream stream_oilExp = new Stream("gasexp", sep1.getLiquidOutStream());

WellAllocator wellAlloc = new WellAllocator("alloc", stream_1);
wellAlloc.setExportGasStream(stream_gasExp);
wellAlloc.setExportOilStream(stream_oilExp);

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(stream_2);
operations.add(sep1);
operations.add(stream_gasExp);
operations.add(stream_oilExp);
operations.add(wellAlloc);
operations.run();

WellAllocatorResponse responsAl = new WellAllocatorResponse(wellAlloc);

System.out.println("name " + responsAl.name);
System.out.println("gas flow " + responsAl.gasExportRate);
System.out.println("oil flow " + responsAl.oilExportRate);
System.out.println("total flow " + responsAl.totalExportRate);
// stream_1.displayResult();
// stream_1.displayResult();
}

}

0 comments on commit ddfaa0d

Please sign in to comment.