Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression test property flash #373

Merged
merged 81 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
adac548
feat: added equality comparator for CalculationResult
asmfstatoil Mar 26, 2022
92f6048
feat: initialize fluid composition fractions if not already done
asmfstatoil Mar 26, 2022
4920561
test: added regression tests
asmfstatoil Mar 26, 2022
d90ef81
test: skip tests with no components defined
asmfstatoil Mar 28, 2022
ba5a974
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Mar 28, 2022
abb8f5f
more api-tests
asmfstatoil Jun 5, 2022
0573779
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Jun 17, 2022
2426797
refact: split tests in two files
asmfstatoil Jun 17, 2022
ff1af01
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Jun 17, 2022
f461723
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Jun 17, 2022
c67820a
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Jun 19, 2022
a1ddcf4
add regression test input
asmfstatoil Jun 19, 2022
cf48339
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Jun 28, 2022
64ab2c2
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Sep 20, 2022
f508d51
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 24, 2023
e6b7d46
update dependencies
asmfstatoil Apr 24, 2023
9a8e0c0
fix?
asmfstatoil Apr 24, 2023
9a59ccd
bugfix
asmfstatoil Apr 24, 2023
d4f8c3b
Update pomJava8.xml
asmfstatoil Apr 24, 2023
36d0d7d
revert
asmfstatoil Apr 24, 2023
77c84e6
stuff
asmfstatoil Apr 24, 2023
f198911
wip
asmfstatoil Apr 25, 2023
b58c6a4
format
asmfstatoil Apr 25, 2023
e314e7c
wip
asmfstatoil Apr 25, 2023
7b0ecc0
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 25, 2023
de5d620
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 25, 2023
df0bad6
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 25, 2023
a8b6358
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 28, 2023
5643c12
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 28, 2023
58cefb2
revert
asmfstatoil Apr 28, 2023
a179ffb
style
asmfstatoil Apr 28, 2023
a8fa989
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 28, 2023
a97041d
revert
asmfstatoil Apr 28, 2023
6b2f3b9
revert
asmfstatoil Apr 28, 2023
d6ee991
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil Apr 28, 2023
d175d46
style
asmfstatoil Apr 28, 2023
78c955e
docfix
asmfstatoil Apr 28, 2023
3c4604f
docfix
asmfstatoil May 1, 2023
6a85e49
wip
asmfstatoil May 1, 2023
3283194
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 1, 2023
0571e8c
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 1, 2023
c453e9d
fix
asmfstatoil May 2, 2023
23ba2eb
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 2, 2023
c98b263
docfix
asmfstatoil May 2, 2023
275e8b0
debugging
asmfstatoil May 2, 2023
aa04a02
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 2, 2023
5481c71
Merge branch 'master' into add_test
asmfstatoil May 3, 2023
21c8925
fix test
asmfstatoil May 3, 2023
566ee45
Merge branch 'add_test' into regression_test_propertyFlash
asmfstatoil May 3, 2023
82c5fa6
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 3, 2023
8c1d9c8
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 3, 2023
8b9896a
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 5, 2023
47ab9f7
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 5, 2023
01acb5b
refact: cleaned up doc and name of checkForSolids
asmfstatoil May 8, 2023
d54c4b2
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 8, 2023
a36a40a
wip+++
asmfstatoil May 8, 2023
0c93571
wip
asmfstatoil May 8, 2023
952693f
wip
asmfstatoil May 9, 2023
2e063cb
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 9, 2023
69fc7e3
javadocfix
asmfstatoil May 9, 2023
9453b1e
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 9, 2023
bc1568c
revert
asmfstatoil May 9, 2023
a244dff
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 9, 2023
cfd4184
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 9, 2023
f4a9c55
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
c346836
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
e0198cb
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
bece8dc
style
asmfstatoil May 10, 2023
8ea0662
stuff
asmfstatoil May 10, 2023
ce8f057
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
da27934
bugfix: fix merge error
asmfstatoil May 10, 2023
dd97bd6
revert
asmfstatoil May 10, 2023
f3f075e
revert
asmfstatoil May 10, 2023
2eafc17
test: typo
asmfstatoil May 10, 2023
b94dd60
style
asmfstatoil May 10, 2023
13a4277
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
77f00e9
revert
asmfstatoil May 10, 2023
939a831
revert mole fraction
asmfstatoil May 10, 2023
675f45a
prettyprint fix
asmfstatoil May 10, 2023
56d2619
disable failing test
asmfstatoil May 10, 2023
d1e3358
Merge branch 'master' into regression_test_propertyFlash
asmfstatoil May 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"java.configuration.updateBuildConfiguration": "interactive",
"[java]": {
"editor.defaultFormatter": "redhat.java",
"editor.formatOnSave": true,
},
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
"java.saveActions.organizeImports": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"java.checkstyle.version": "10.9.3",
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
"java.debug.settings.hotCodeReplace": "never"
}
"java.configuration.updateBuildConfiguration": "interactive",
"[java]": {
"editor.defaultFormatter": "redhat.java",
"editor.formatOnSave": true,
},
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
"java.saveActions.organizeImports": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"java.checkstyle.version": "10.9.3",
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
"java.debug.settings.hotCodeReplace": "never"
}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
<version>53.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
6 changes: 6 additions & 0 deletions pomJava8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
<version>48.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neqsim/thermo/phase/PhaseInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public default double getExessGibbsEnergySymetric() {

/**
* <p>
* setEmptyFluid.
* Set the flow rate (moles) of all components to zero.
* </p>
*/
public void setEmptyFluid();
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/neqsim/thermo/system/SystemInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public default void removeMoles() {
}

/**
* Set the flow rate of all components to zero.
* Set the flow rate (moles) of all components to zero.
*/
public void setEmptyFluid();

Expand Down Expand Up @@ -1096,9 +1096,9 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m
*
* @param name Name of the component to be added. See NeqSim database for component in the
* database.
* @param value a double
* @param unitName the unit of rate (sported units are kg/sec, mol/sec, Nlitre/min, kg/hr,
* Sm^3/hr, Sm^3/day, MSm^3/day ..
* @param value a double
*/
public void addComponent(String name, double value, String unitName);

Expand All @@ -1107,7 +1107,8 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m
* addComponent.
* </p>
*
* @param name a {@link java.lang.String} object
* @param name Name of the component to be added. See NeqSim database for component in the
* database.
* @param moles a double
* @param TC a double
* @param PC a double
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/neqsim/thermo/system/SystemProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public SystemProperties(SystemInterface fluid) {
}

/**
* Get property names and values as a map
* Get property names and values as a map.
*
* @return map of property name and values
*/
Expand All @@ -197,7 +197,7 @@ public HashMap<String, Double> getProperties() {
}

/**
* Getter for property values
* Getter for property values.
*
* @return Systemproperty values
*/
Expand All @@ -206,7 +206,7 @@ public Double[] getValues() {
}

/**
* Get names of properties
* Get names of properties.
*
* @return Array of names of properties
*/
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/neqsim/thermo/system/SystemThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ public void addComponent(String componentName, double value, String name, int ph
@Override
public void addComponent(int index, double moles) {
if (index >= getPhase(0).getNumberOfComponents()) {
logger.error("componentIndex higher than number of components in database");
logger.error("componentIndex higher than number of components in system");
return;
}
setTotalNumberOfMoles(getTotalNumberOfMoles() + moles);
Expand All @@ -1321,7 +1321,7 @@ public void addComponent(int index, double moles) {
@Override
public void addComponent(int index, double moles, int phaseNumber) {
if (index >= getPhase(0).getNumberOfComponents()) {
logger.error("componentIndex higher than number of components in database");
logger.error("componentIndex higher than number of components in system");
return;
}
double k = 1.0;
Expand All @@ -1334,6 +1334,8 @@ public void addComponent(int index, double moles, int phaseNumber) {
}
phaseArray[phaseIndex[i]].addMolesChemReac(index, moles * k, moles);
}


setTotalNumberOfMoles(getTotalNumberOfMoles() + moles);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1968,27 +1968,43 @@ public CalculationResult propertyFlash(List<Double> Spec1, List<Double> Spec2, i
flashType = null;
}


Double[][] fluidProperties = new Double[Spec1.size()][SystemProperties.nCols];
String[] calculationError = new String[Spec1.size()];

Double[] sum = new Double[Spec1.size()];

if (onlineFractions != null) {
// Verify that sum of fractions equals 1/100, i.e., assume percentages
Boolean hasOnlineFractions = onlineFractions != null;
if (hasOnlineFractions) {
double range = 5;
for (int t = 0; t < sum.length; t++) {
sum[t] = 0.0;
for (int comp = 0; comp < onlineFractions.size(); comp++) {
sum[t] = sum[t] + onlineFractions.get(comp).get(t).doubleValue();
}
if (!((sum[t] >= 1 - range / 100 && sum[t] <= 1 + range / 100)
|| (sum[t] >= 100 - range && sum[t] <= 100 + range))) {
calculationError[t] = "Sum of fractions must be approximately 1 or 100, currently ("
+ String.valueOf(sum[t]) + ")";
}
}

if (this.system.getNumberOfMoles() == 0) {
this.system.setTotalNumberOfMoles(1);
}
} else {
double[] fraction = this.system.getMolarComposition();
sum[0] = 0.0;
for (int comp = 0; comp < fraction.length; comp++) {
sum[0] = sum[0] + fraction[comp];
sum[0] = this.system.getMoleFractionsSum();
if (sum[0] == 0) {
this.system.init(0);
}

double range = 1e-8;
if (!((sum[0] >= 1 - range && sum[0] <= 1 + range)
|| (sum[0] >= 100 - range && sum[0] <= 100 + range))) {
for (int t = 0; t < Spec1.size(); t++) {
calculationError[t] = "Sum of fractions must be equal to 1 or 100, currently ("
+ String.valueOf(sum[0]) + ")";
}
}
}

Expand All @@ -2008,35 +2024,26 @@ public CalculationResult propertyFlash(List<Double> Spec1, List<Double> Spec2, i
continue;
}

if (onlineFractions != null) {
double range = 5;
if (!((sum[t] >= 1 - range / 100 && sum[t] <= 1 + range / 100)
|| (sum[t] >= 100 - range && sum[t] <= 100 + range))) {
calculationError[t] = "Sum of fractions must be approximately 1 or 100, currently ("
+ String.valueOf(sum[t]) + ")";
logger.info("Online fraction does not sum to approximately 1 or 100 for datapoint {}",
t);
continue;
} else {
// Remaining fractions will be set to 0.0
double[] fraction = new double[this.system.getNumberOfComponents()];

for (int comp = 0; comp < onlineFractions.size(); comp++) {
fraction[comp] = onlineFractions.get(comp).get(t).doubleValue();
}

this.system.setMolarComposition(fraction);
this.system.init(0);
// Skip if sum is not similar to 100%
if (calculationError[t] != null) {
logger.info("{}", calculationError[t]);
continue;
}

if (hasOnlineFractions) {
this.system.setEmptyFluid();

// Components in system with no corresponding value in onlineFractions will be zero.
for (int componentNumber = 0; componentNumber < onlineFractions
.size(); componentNumber++) {
this.system.addComponent(componentNumber,
onlineFractions.get(componentNumber).get(t).doubleValue());
}
} else {
double range = 1e-8;
if (!((sum[0] >= 1 - range && sum[0] <= 1 + range)
|| (sum[0] >= 100 - range && sum[0] <= 100 + range))) {
calculationError[t] = "Sum of fractions must be equal to 1 or 100, currently ("
+ String.valueOf(sum[t]) + ")";
logger.info("Sum of fractions must be equal to 1 or 100 for datapoint {}", t);
continue;

if (this.system.getNumberOfMoles() < 1e-5) {
this.system.setTotalNumberOfMoles(1);
}
this.system.init(0);
}

this.system.setPressure(Sp1);
Expand Down Expand Up @@ -2064,7 +2071,6 @@ public CalculationResult propertyFlash(List<Double> Spec1, List<Double> Spec2, i
logger.error(ex.getMessage(), ex);
}
}

return new CalculationResult(fluidProperties, calculationError);
}

Expand Down
Loading