Skip to content

Commit

Permalink
added RVP and TVP methods (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Apr 29, 2024
1 parent 87f5c4a commit 96a62f0
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.util.monitor.StreamResponse;
import neqsim.standards.gasQuality.Standard_ISO6976;
import neqsim.standards.oilQuality.Standard_ASTM_D6377;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

Expand Down Expand Up @@ -443,8 +444,6 @@ public String[][] getResultTable() {
return getFluid().calcResultTable();
}



/** {@inheritDoc} */
@Override
public void runTransient(double dt, UUID id) {
Expand Down Expand Up @@ -550,6 +549,29 @@ public double TVP(double temperature, String unit) {
return localSyst.getPressure();
}

/** {@inheritDoc} */
@Override
public double getTVP(double referenceTemperature, String unit, String returnUnit) {
SystemInterface localSyst = getFluid().clone();
localSyst.setTemperature(referenceTemperature, unit);
ThermodynamicOperations ops = new ThermodynamicOperations(localSyst);
try {
ops.bubblePointPressureFlash(false);
} catch (Exception ex) {
}
return localSyst.getPressure(returnUnit);
}

/** {@inheritDoc} */
@Override
public double getRVP(double referenceTemperature, String unit, String returnUnit) {
SystemInterface localSyst = getFluid().clone();
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(localSyst);
standard.setReferenceTemperature(referenceTemperature, unit);
standard.calculate();
return standard.getValue("RVP", returnUnit);
}

/** {@inheritDoc} */
@Override
public String[][] reportResults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,30 @@ public default double getFlowRate(String unit) {
*/
public double TVP(double temperature, String unit);

/**
* <p>
* TVP.
* </p>
*
* @param referenceTemperature a double
* @param unit a {@link java.lang.String} object
* @param returnUnit a {@link java.lang.String} object
* @return a double
*/
public double getTVP(double referenceTemperature, String unit, String returnUnit);

/**
* <p>
* TVP.
* </p>
*
* @param referenceTemperature a double
* @param unit a {@link java.lang.String} object
* @param returnUnit a {@link java.lang.String} object
* @return a double
*/
public double getRVP(double referenceTemperature, String unit, String returnUnit);

/**
* <p>
* setFluid.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/neqsim/standards/Standard.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class Standard extends NamedBaseClass implements StandardInterfa
/**
* Constructor for Standard.
*
* @param name name of standard
* @param name name of standard
* @param description description
*/
public Standard(String name, String description) {
Expand All @@ -52,8 +52,8 @@ public Standard(String name, String description) {
/**
* Constructor for Standard.
*
* @param name name of standard
* @param thermoSyst input fluid
* @param name name of standard
* @param thermoSyst input fluid
* @param description description of standard
*/
public Standard(String name, String description, SystemInterface thermoSyst) {
Expand Down Expand Up @@ -161,7 +161,7 @@ public void display(String name) {
Container dialogContentPane = dialog.getContentPane();
dialogContentPane.setLayout(new BorderLayout());

String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"};
String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" };
String[][] table = createTable(name);
JTable Jtab = new JTable(table, names);
JScrollPane scrollpane = new JScrollPane(Jtab);
Expand Down
32 changes: 29 additions & 3 deletions src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class Standard_ASTM_D6377 extends neqsim.standards.Standard {

String unit = "bara";
double RVP = 1.0;
double TVP = 1.0;
double referenceTemperature = 37.8;
String referenceTemperatureUnit = "C";

/**
* <p>
Expand All @@ -36,7 +39,7 @@ public Standard_ASTM_D6377(SystemInterface thermoSystem) {
/** {@inheritDoc} */
@Override
public void calculate() {
this.thermoSystem.setTemperature(273.15 + 37.8);
this.thermoSystem.setTemperature(referenceTemperature, "C");
this.thermoSystem.setPressure(ThermodynamicConstantsInterface.referencePressure);
this.thermoOps = new ThermodynamicOperations(thermoSystem);
try {
Expand All @@ -45,7 +48,7 @@ public void calculate() {
logger.error(ex.getMessage(), ex);
}

// double TVP = this.thermoSystem.getPressure();
TVP = this.thermoSystem.getPressure();
double liquidVolume = thermoSystem.getVolume();

this.thermoSystem.setPressure(0.9);
Expand Down Expand Up @@ -73,7 +76,16 @@ public String getUnit(String returnParameter) {
/** {@inheritDoc} */
@Override
public double getValue(String returnParameter, java.lang.String returnUnit) {
return RVP;
if (returnParameter == "RVP") {
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(RVP, "bara");
return presConversion.getValue(returnUnit);
}
if (returnParameter == "TVP") {
neqsim.util.unit.PressureUnit presConversion = new neqsim.util.unit.PressureUnit(TVP, "bara");
return presConversion.getValue(returnUnit);
} else {
return RVP;
}
}

/** {@inheritDoc} */
Expand All @@ -82,6 +94,20 @@ public double getValue(String returnParameter) {
return RVP;
}

/**
* <p>
* setReferenceTemperature.
* </p>
*
* @param refTemp a double
* @param refTempUnit a {@link java.lang.String} object
*/
public void setReferenceTemperature(double refTemp, String refTempUnit) {
neqsim.util.unit.TemperatureUnit tempConversion =
new neqsim.util.unit.TemperatureUnit(refTemp, refTempUnit);
referenceTemperature = tempConversion.getValue(refTemp, refTempUnit, "C");
}

/**
* <p>
* main.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package neqsim.standards.oilQuality;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;

public class Standard_ASTM_D6377Test {
@Test
void testCalculate() {
SystemInterface testSystem = new SystemSrkEos(273.15 + 2.0, 1.0);
testSystem.addComponent("methane", 0.0006538);
testSystem.addComponent("ethane", 0.006538);
testSystem.addComponent("propane", 0.006538);
testSystem.addComponent("n-pentane", 0.545);
testSystem.setMixingRule(2);
testSystem.init(0);
Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem);
standard.setReferenceTemperature(37.8, "C");
standard.calculate();
Assertions.assertEquals(0.7298246193, standard.getValue("RVP", "bara"), 1e-3);
Assertions.assertEquals(1.8710732396722, standard.getValue("TVP", "bara"), 1e-3);
}
}

0 comments on commit 96a62f0

Please sign in to comment.