Skip to content

Commit

Permalink
Merge master into branch (#536)
Browse files Browse the repository at this point in the history
* chore: update plugin versions, switch to using jdk 11 to compile (#532)

* javadoc fixes for jdk11 (#534)

* Checkstyle config (#524)

* added checkstyle config xml file to specify which warnings to produce

* refact: use useing pattern for disposable/close objects (#533)

* refact: use useing pattern for disposable/close objects

* close connectors

Co-authored-by: fannemel <fannemel@gmail.com>
Co-authored-by: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 1, 2022
1 parent fe17d82 commit 30da69a
Show file tree
Hide file tree
Showing 36 changed files with 471 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"java.checkstyle.version": "10.3",
"java.checkstyle.configuration": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml"
},
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
},


// Add the IDs of extensions you want installed when the container is created.
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"java.checkstyle.version": "10.3",
"java.checkstyle.configuration": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml",
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
"java.debug.settings.hotCodeReplace": "never"
}
349 changes: 349 additions & 0 deletions checkstyle_neqsim.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentvapourpressures WHERE ComponentName='water' AND VapourPressure<100");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentvapourpressures WHERE ComponentName='water' AND VapourPressure<100")) {
System.out.println("adding....");
while (dataSet.next()) {
MassTransferFunction function = new MassTransferFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet =
database.getResultSet("SELECT * FROM binarysystemviscosity WHERE ComponentName1='TEG'");

try {
try (ResultSet dataSet =
database.getResultSet("SELECT * FROM binarysystemviscosity WHERE ComponentName1='TEG'")) {
logger.info("adding....");
while (dataSet.next()) {
GrunbergNissanFunction function = new GrunbergNissanFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryliquiddiffusioncoefficientdata WHERE ComponentSolute='CO2' AND ComponentSolvent='water'");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryliquiddiffusioncoefficientdata WHERE ComponentSolute='CO2' AND ComponentSolvent='water'")) {
logger.info("adding....");
while (dataSet.next()) {
DiffusivityFunction function = new DiffusivityFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet =
database.getResultSet("SELECT * FROM purecomponentdensity WHERE ComponentName='MEG'");
// ResultSet dataSet = database.getResultSet("NeqSimDataBase", "SELECT * FROM
// activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");

try {
try (ResultSet dataSet =
database.getResultSet("SELECT * FROM purecomponentdensity WHERE ComponentName='MEG'")) {
logger.info("adding....");
while (dataSet.next()) {
RacketFunction function = new RacketFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ public static void main(String[] args) {
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();

NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentsurfacetension2 WHERE ComponentName IN ('n-pentane','ethane','methane', 'propane','CO2', 'c-hexane','M-cy-C5', 'n-pentane','n-hexane', 'n-nonane','nC10')"); // AND
// ComponentName<>'nC10'
// AND
// ComponentName<>'nC11'
// AND
// ComponentName<>'nC12'
// AND
// ComponentName<>'nC13'");
// ComponentName<>'nC10'
// AND
// ComponentName<>'nC11'
// AND
// ComponentName<>'nC12'
// AND
// ComponentName<>'nC13'");
boolean includePureCompData = true;

// double guess[] = { -0.7708158524, 0.4990571549, 0.8645478315, -0.3509810630,
Expand All @@ -55,7 +53,9 @@ public static void main(String[] args) {
// double guess[] = {-5.2897559010400935E-17, 7.103588505598196E-17}; //,
// 1.1161368619, 0.8363538313}; // PR param

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentsurfacetension2 WHERE ComponentName IN ('n-pentane','ethane','methane', 'propane','CO2', 'c-hexane','M-cy-C5', 'n-pentane','n-hexane', 'n-nonane','nC10')") // AND
) {
while (dataSet.next() && includePureCompData) {
InfluenceParamGTFunction function = new InfluenceParamGTFunction();
function.setInitialGuess(guess);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public static void main(String[] args) {
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();

NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database
.getResultSet("SELECT * FROM purecomponentsurfacetension WHERE ComponentName='MEG'");

try {
try (ResultSet dataSet = database
.getResultSet("SELECT * FROM purecomponentsurfacetension WHERE ComponentName='MEG'")) {
while (dataSet.next()) {
ParachorFunction function = new ParachorFunction();
double guess[] = {207.2}; // methane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet("SELECT * FROM purecomponentviscosity"); // WHERE
// ComponentName='MDEA*'");

try {
try (ResultSet dataSet = database.getResultSet("SELECT * FROM purecomponentviscosity") // WHERE
// ComponentName='MDEA*'");
) {
while (dataSet.next()) {
ChungFunction function = new ChungFunction();
double guess[] = {0.3211};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimExperimentDatabase database = new NeqSimExperimentDatabase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentviscosity WHERE ComponentName='MEG' ORDER BY Temperature");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM purecomponentviscosity WHERE ComponentName='MEG' ORDER BY Temperature")) {
while (dataSet.next()) {
ViscosityFunction function = new ViscosityFunction();
// double guess[] = {-66.2, 11810, 0.1331, -0.0000983}; //mdea
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/neqsim/thermo/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package neqsim.thermo.component;

import java.sql.Connection;
import java.sql.Statement;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
Expand Down Expand Up @@ -459,11 +461,14 @@ public void createComponent(String component_name, double moles, double molesInP
if (dataSet != null) {
dataSet.close();
}
if (database.getStatement() != null) {
database.getStatement().close();

Statement s = database.getStatement();
if (s != null) {
s.close();
}
if (database.getConnection() != null) {
database.getConnection().close();
Connection c = database.getConnection();
if (c != null) {
c.close();
}
} catch (Exception ex) {
logger.error("error closing database.....", ex);
Expand Down Expand Up @@ -908,11 +913,7 @@ public double getPureComponentLiquidDensity(double temperature) {
// Math.pow(1.0 - temperature / liquidDensityCoefs[2], liquidDensityCoefs[3]));
}

/**
* {@inheritDoc}
*
* Calculates the pure comonent heat of vaporization in J/mol
*/
/** {@inheritDoc} */
@Override
public double getPureComponentHeatOfVaporization(double temperature) {
return 1.0e-3 * heatOfVaporizationCoefs[0]
Expand Down Expand Up @@ -994,8 +995,7 @@ public final double getFugacityCoefficient() {
@Override
public double fugcoef(PhaseInterface phase) {
fugacityCoefficient = 1.0; // this.fugcoef(phase, phase.getNumberOfComponents(),
// phase.getTemperature(),
// phase.getPressure());
// phase.getTemperature(), phase.getPressure());
logFugacityCoefficient = Math.log(fugacityCoefficient);
return fugacityCoefficient;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m

/**
* <p>
* hasPlusFraction.
* Getter for property hasPlusFraction.
* </p>
*
* @return a boolean
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4155,11 +4155,7 @@ public neqsim.standards.StandardInterface getStandard(String standardName) {
return standard;
}

/**
* {@inheritDoc}
*
* Setter for property standard.
*/
/** {@inheritDoc} */
@Override
public void setStandard(String standardName) {
if (standardName.equals("ISO1992")) {
Expand All @@ -4171,11 +4167,7 @@ public void setStandard(String standardName) {
}
}

/**
* {@inheritDoc}
*
* Getter for property hasPlusFraction.
*/
/** {@inheritDoc} */
@Override
public boolean hasPlusFraction() {
for (int i = 0; i < numberOfComponents; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet("SELECT * FROM Sleipner");
int error = 1;
double ID;

Expand All @@ -48,7 +47,7 @@ public static void main(String[] args) {
double pressure;
double[] guess = {0.0000708122};

try {
try (ResultSet dataSet = database.getResultSet("SELECT * FROM Sleipner")) {
int i = 0;
logger.info("adding....");
while (dataSet.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public static void main(String[] args) {
ArrayList<SampleValue> sampleList = new ArrayList<SampleValue>();
// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM activitycoefficienttable WHERE ((Component1='TEG' AND Component2='water') OR (Component1='water' AND Component2='TEG')) AND ReferenceID<>'shell data'");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM activitycoefficienttable WHERE ((Component1='TEG' AND Component2='water') OR (Component1='water' AND Component2='TEG')) AND ReferenceID<>'shell data'")) {
while (dataSet.next()) {
BinaryCPAparameterFitToActivityCoefficientFunction function =
new BinaryCPAparameterFitToActivityCoefficientFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM waterdewpointpaper WHERE gascomponent='nitrogen' AND reference='Gil'");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM waterdewpointpaper WHERE gascomponent='nitrogen' AND reference='Gil'")) {
int p = 0;
logger.info("adding....");
while (dataSet.next() && p < 500) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimExperimentDatabase database = new NeqSimExperimentDatabase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>283.15 AND Temperature<373.15 AND Pressure<60.01325 ORDER BY Temperature");
// ResultSet dataSet = database.getResultSet( "SELECT * FROM
// binarysolubilitydata WHERE ComponentSolute='methane' AND
// ComponentSolvent='water' AND Temperature>278.0 AND Temperature<350.0");
double parameterGuess[] = {-0.27686, 0.001121}; // , 0.000117974}; //cpa

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarySolubilityData WHERE ComponentSolute='CO2' AND ComponentSolvent='water' AND Reference='Houghton1957' AND Reference<>'Nighswander1989' AND Temperature>283.15 AND Temperature<373.15 AND Pressure<60.01325 ORDER BY Temperature")) {
int p = 0;
logger.info("adding....");
while (dataSet.next() && p < 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase(); // AND reference<>'Lindboe2002'
ResultSet dataSet = database.getResultSet(
"SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure"); // AND
// AND
// Reference='Houghton1957'
// AND
// Reference<>'Nighswander1989'
Expand All @@ -52,7 +51,8 @@ public static void main(String[] args) {
double parameterGuess[] = {1924, 4938}; // , -1.11, 1.24};
// double parameterGuess[] = {0.0471326591};

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM hcglycollldata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure")) {
int p = 0;
logger.info("adding....");
while (!dataSet.next() && p < 50) {
Expand Down Expand Up @@ -87,10 +87,9 @@ public static void main(String[] args) {
logger.error("database error" + ex);
}

dataSet = database.getResultSet(
"SELECT * FROM HCGlycolLLdata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM HCGlycolLLdata WHERE comp1='n-heptane' AND comp2='MEG' AND reference='Lindboe2002' ORDER BY Temperature,Pressure")) {
int p = 0;
logger.info("adding....");
while (!dataSet.next() && p < 50) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryequilibriumdata WHERE Component1='methane' AND Component2='ethane'");
// ResultSet dataSet = database.getResultSet( "SELECT * FROM
// activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM binaryequilibriumdata WHERE Component1='methane' AND Component2='ethane'");) {
logger.info("adding....");
while (dataSet.next()) {
EosInteractionParameterFittingFunction function =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ public static void main(String[] args) {
// inserting samples from database
NeqSimExperimentDatabase database = new NeqSimExperimentDatabase();

ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarysolubilitydata WHERE ComponentSolute='mercury' AND ComponentSolvent='n-hexane'");
// double parameterGuess[] = {0.13}; // mercury-methane
// double parameterGuess[] = {0.0496811275399517}; // mercury-methane
// double parameterGuess[] = {0.0704}; // mercury-ethane
double parameterGuess[] = {-0.03310000498911416}; // mercury-ibutane
// double parameterGuess[] = {0.0674064646735}; // mercury-propane
// double parameterGuess[] = { 0.3674008071}; // mercury-CO2
// double parameterGuess[] = { 0.016529772608}; // mercury-nitrogen
try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarysolubilitydata WHERE ComponentSolute='mercury' AND ComponentSolvent='n-hexane'")) {
int p = 0;
logger.info("adding....");
while (dataSet.next() && p < 40) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarysolubilitydataeinar WHERE ComponentSolute='methane' AND ComponentSolvent='Water'");

try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM binarysolubilitydataeinar WHERE ComponentSolute='methane' AND ComponentSolvent='Water'");
) {
int p = 0;
logger.info("adding....");
while (dataSet.next() && p < 4000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ public static void main(String[] args) {

// inserting samples from database
NeqSimDataBase database = new NeqSimDataBase();
ResultSet dataSet = database.getResultSet(
"SELECT * FROM dewpointquaternary WHERE temperature>173.1 AND x4>0.0000021 ORDER BY x4,pressure");
// ResultSet dataSet = database.getResultSet( "SELECT * FROM
// activityCoefficientTable WHERE Component1='MDEA' AND Component2='water'");
// testSystem.addComponent(dataSet.getString("ComponentSolute"), 1.0);
// testSystem.addComponent(dataSet.getString("ComponentSolvent"), 1.0);
try {
try (ResultSet dataSet = database.getResultSet(
"SELECT * FROM dewpointquaternary WHERE temperature>173.1 AND x4>0.0000021 ORDER BY x4,pressure")) {
int p = 0;
logger.info("adding....");
while (dataSet.next() && p < 300) {
Expand Down
Loading

0 comments on commit 30da69a

Please sign in to comment.