-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
package neqsim.processSimulation.processEquipment.util; | ||
|
||
import java.util.UUID; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import neqsim.processSimulation.processEquipment.TwoPortEquipment; | ||
import neqsim.processSimulation.processEquipment.stream.StreamInterface; | ||
import neqsim.thermo.system.SystemInterface; | ||
import neqsim.thermodynamicOperations.ThermodynamicOperations; | ||
|
||
/** | ||
* <p> | ||
* FlowSetter class. | ||
* </p> | ||
* | ||
* @author esol | ||
* @version $Id: $Id | ||
*/ | ||
public class FlowSetter extends TwoPortEquipment { | ||
private static final long serialVersionUID = 1000; | ||
static Logger logger = LogManager.getLogger(GORfitter.class); | ||
|
||
double pressure = 1.01325; | ||
double temperature = 15.0; | ||
String unitT = "C"; | ||
String unitP = "bara"; | ||
|
||
private double gasFlowRate; | ||
private double oilFlowRate; | ||
private double waterFlowRate; | ||
String unitGasFlowRate = "Sm3/day"; | ||
String unitOilFlowRate = "m3/hr"; | ||
String unitWaterFlowRate = "m3/hr"; | ||
|
||
@Deprecated | ||
/** | ||
* <p> | ||
* Constructor for FlowSetter. | ||
* </p> | ||
*/ | ||
public FlowSetter() { | ||
super("Flow Setter"); | ||
} | ||
|
||
/** | ||
* <p> | ||
* Constructor for FlowSetter. | ||
* </p> | ||
* | ||
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object | ||
*/ | ||
@Deprecated | ||
public FlowSetter(StreamInterface stream) { | ||
this("Flow Setter", stream); | ||
} | ||
|
||
/** | ||
* <p> | ||
* Constructor for FlowSetter. | ||
* </p> | ||
* | ||
* @param name a {@link java.lang.String} object | ||
* @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object | ||
*/ | ||
public FlowSetter(String name, StreamInterface stream) { | ||
super(name, stream); | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* <p> | ||
* Setter for the field <code>inletStream</code>. | ||
* </p> | ||
*/ | ||
public void setInletStream(StreamInterface inletStream) { | ||
this.inStream = inletStream; | ||
try { | ||
this.outStream = inletStream.clone(); | ||
} catch (Exception ex) { | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
} | ||
|
||
/** | ||
* <p> | ||
* Getter for the field <code>pressure</code>. | ||
* </p> | ||
* | ||
* @return a double | ||
*/ | ||
public double getPressure() { | ||
return pressure; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Setter for the field <code>pressure</code>. | ||
* </p> | ||
* | ||
* @param pressure a double | ||
* @param unitP a {@link java.lang.String} object | ||
*/ | ||
public void setPressure(double pressure, String unitP) { | ||
this.pressure = pressure; | ||
this.unitP = unitP; | ||
} | ||
|
||
/** | ||
* <p> | ||
* getTemperature. | ||
* </p> | ||
* | ||
* @return a double | ||
*/ | ||
public double getTemperature() { | ||
return temperature; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Setter for the field <code>temperature</code>. | ||
* </p> | ||
* | ||
* @param temperature a double | ||
* @param unitT a {@link java.lang.String} object | ||
*/ | ||
public void setTemperature(double temperature, String unitT) { | ||
this.temperature = temperature; | ||
this.unitT = unitT; | ||
} | ||
|
||
public void setGasFlowRate(double flowRate, String flowUnit) { | ||
gasFlowRate = flowRate; | ||
unitGasFlowRate = flowUnit; | ||
} | ||
|
||
public double getGasFlowRate(String flowUnit) { | ||
return gasFlowRate; | ||
} | ||
|
||
public void setOilFlowRate(double flowRate, String flowUnit) { | ||
oilFlowRate = flowRate; | ||
unitOilFlowRate = flowUnit; | ||
} | ||
|
||
public double getOilFlowRate(String flowUnit) { | ||
return oilFlowRate; | ||
} | ||
|
||
public void setWaterFlowRate(double flowRate, String flowUnit) { | ||
waterFlowRate = flowRate; | ||
unitWaterFlowRate = flowUnit; | ||
} | ||
|
||
public double getWaterFlowRate(String flowUnit) { | ||
return waterFlowRate; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public void run(UUID id) { | ||
SystemInterface tempFluid = inStream.getThermoSystem().clone(); | ||
double flow = tempFluid.getFlowRate("kg/sec"); | ||
|
||
if (flow < 1e-6) { | ||
outStream.setThermoSystem(tempFluid); | ||
return; | ||
} | ||
|
||
tempFluid.setTemperature(temperature, unitT); | ||
tempFluid.setPressure(pressure, unitP); | ||
|
||
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); | ||
try { | ||
thermoOps.TPflash(); | ||
} catch (Exception ex) { | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
|
||
tempFluid.initPhysicalProperties("density"); | ||
|
||
double[] moleChange = new double[tempFluid.getNumberOfComponents()]; | ||
for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { | ||
moleChange[i] = tempFluid.getPhase("gas").getComponent(i).getx() | ||
* (getGasFlowRate("Sm3/sec") / tempFluid.getPhase("gas").getMolarVolume("m3/mol")) | ||
+ tempFluid.getPhase("oil").getComponent(i).getx() | ||
* (getOilFlowRate("Sm3/sec") / tempFluid.getPhase("oil").getMolarVolume("m3/mol")) | ||
- tempFluid.getComponent(i).getNumberOfmoles(); | ||
} | ||
tempFluid.init(0); | ||
for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { | ||
tempFluid.addComponent(i, moleChange[i]); | ||
} | ||
tempFluid.setPressure((inStream.getThermoSystem()).getPressure()); | ||
tempFluid.setTemperature((inStream.getThermoSystem()).getTemperature()); | ||
tempFluid.setTotalFlowRate(flow, "kg/sec"); | ||
try { | ||
thermoOps.TPflash(); | ||
} catch (Exception ex) { | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
outStream.setThermoSystem(tempFluid); | ||
outStream.setCalculationIdentifier(id); | ||
setCalculationIdentifier(id); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package neqsim.processSimulation.processEquipment.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; | ||
import neqsim.processSimulation.processEquipment.stream.Stream; | ||
import neqsim.thermo.system.SystemInterface; | ||
import neqsim.thermo.system.SystemSrkEos; | ||
|
||
public class FlowSetterTest { | ||
@Test | ||
void testMain() { | ||
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", 4.053); | ||
testFluid.setMixingRule(2); | ||
testFluid.setMultiPhaseCheck(true); | ||
|
||
testFluid.setTemperature(90.0, "C"); | ||
testFluid.setPressure(60.0, "bara"); | ||
testFluid.setTotalFlowRate(1e6, "kg/hr"); | ||
|
||
Stream stream_1 = new Stream("Stream1", testFluid); | ||
stream_1.run(); | ||
|
||
MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1); | ||
multiPhaseMeter.setTemperature(90.0, "C"); | ||
multiPhaseMeter.setPressure(60.0, "bara"); | ||
|
||
FlowSetter flowset = new FlowSetter("flowset", stream_1); | ||
flowset.setGasFlowRate(multiPhaseMeter.getMeasuredValue("Gas Flow Rate", "Sm3/hr"), "Sm3/hr"); | ||
flowset.setOilFlowRate(multiPhaseMeter.getMeasuredValue("Oil Flow Rate", "Sm3/hr"), "Sm3/hr"); | ||
|
||
neqsim.processSimulation.processSystem.ProcessSystem operations = | ||
new neqsim.processSimulation.processSystem.ProcessSystem(); | ||
operations.add(stream_1); | ||
operations.add(multiPhaseMeter); | ||
operations.add(flowset); | ||
operations.run(); | ||
} | ||
} |