diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 48630efb30..74f679ded3 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -15,51 +15,40 @@
"NODE_VERSION": "lts/*"
}
},
-
// Set *default* container specific settings.json values on container create.
- //"settings": {
- // "java.home": "/docker-java-home"
- //},
- "settings": {
- "java.configuration.updateBuildConfiguration": "interactive",
- "[java]": {
- "editor.defaultFormatter": "redhat.java",
- "editor.formatOnSave": true,
- "editor.tabSize": 2,
- "editor.insertSpaces": true,
- "editor.detectIndentation": false
- },
- "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.3",
- "java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
- },
-
-
-// Add the IDs of extensions you want installed when the container is created.
-"extensions": [
- "vscjava.vscode-java-pack",
- "ms-vscode.test-adapter-converter",
- "shengchen.vscode-checkstyle",
- "mechatroner.rainbow-csv",
- "redhat.vscode-xml",
- "eamodio.gitlens"
-]
-
-
-// Use 'forwardPorts' to make a list of ports inside the container available locally.
-// "forwardPorts": [],
-
-// Use 'postCreateCommand' to run commands after the container is created.
-//"postCreateCommand": "mvn package",
-
-// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
-//"remoteUser": "vscode",
-//"features": {
-// "github-cli": "latest"
-//}
-}
-
+ "customizations": {
+ "vscode": {
+ // Add the IDs of extensions you want installed when the container is created.
+ "extensions": [
+ "vscjava.vscode-java-pack",
+ "ms-vscode.test-adapter-converter",
+ "shengchen.vscode-checkstyle",
+ "mechatroner.rainbow-csv",
+ "redhat.vscode-xml",
+ "vscjava.vscode-java-test"
+ ],
+ "settings": {
+ "java.configuration.updateBuildConfiguration": "interactive",
+ "[java]": {
+ "editor.defaultFormatter": "redhat.java",
+ "editor.formatOnSave": true,
+ "editor.tabSize": 2,
+ "editor.insertSpaces": true,
+ "editor.detectIndentation": false
+ },
+ "java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
+ "java.saveActions.organizeImports": true,
+ "java.checkstyle.version": "10.18.1",
+ "java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
+ "[xml]": {
+ "editor.tabSize": 4,
+ "editor.insertSpaces": false
+ },
+ "[json]": {
+ "editor.tabSize": 4,
+ "editor.insertSpaces": true
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/.github/workflows/maven_publish.yml b/.github/workflows/maven_publish.yml
new file mode 100644
index 0000000000..fb84743190
--- /dev/null
+++ b/.github/workflows/maven_publish.yml
@@ -0,0 +1,28 @@
+name: Publish package to the Maven Central Repository
+on:
+ workflow_dispatch:
+ release:
+ types: [published]
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Maven Central Repository
+ uses: actions/setup-java@v4
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ server-id: central
+ server-username: MAVEN_USERNAME
+ server-password: MAVEN_PASSWORD
+ gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
+ gpg-passphrase: MAVEN_GPG_PASSPHRASE
+ - name: Set version
+ run: mvn versions:set -DnewVersion=${{ github.event.release.tag_name }}
+ - name: Publish package
+ run: mvn -P release --batch-mode deploy -DskipTests
+ env:
+ MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
+ MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
diff --git a/.github/workflows/publish_javadoc.yml b/.github/workflows/publish_javadoc.yml
new file mode 100644
index 0000000000..dd19781bbb
--- /dev/null
+++ b/.github/workflows/publish_javadoc.yml
@@ -0,0 +1,21 @@
+name: Deploy Javadoc
+
+on:
+ workflow_dispatch:
+ release:
+ types: [published]
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write # if you have a protection rule on your repository, you'll need to give write permission to the workflow.
+ steps:
+ - name: Deploy JavaDoc 🚀
+ uses: MathieuSoysal/Javadoc-publisher.yml@v2.5.0
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ javadoc-branch: javadoc
+ java-version: 17
+ target-folder: javadoc # url will be https://equinor.github.io/neqsim/javadoc
+ project: maven
diff --git a/.github/workflows/release_to_github_packages.yml b/.github/workflows/release_to_github_packages.yml
index 0286401880..2d2045fe03 100644
--- a/.github/workflows/release_to_github_packages.yml
+++ b/.github/workflows/release_to_github_packages.yml
@@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Set up JDK 11
- uses: actions/setup-java@v3.6.0
+ uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
diff --git a/.github/workflows/release_with_jars.yml b/.github/workflows/release_with_jars.yml
index a31bdd8406..177d68aeef 100644
--- a/.github/workflows/release_with_jars.yml
+++ b/.github/workflows/release_with_jars.yml
@@ -1,9 +1,4 @@
name: Create release (draft)
-# Workflow is triggered when any pom-file is updated in master-branch
-# If both pom-files have the same version number it
-# - builds NeqSim-jars both in Java 8 and Java 11
-# - creates a new release and uploads the jars as artifacts
-# - makes a new branch in neqsimpython and updates the jar-files used there.
on:
workflow_dispatch:
@@ -26,7 +21,7 @@ jobs:
steps:
- name: Check out neqsim java project
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Get version number for pomJava8.xml
id: java-8
uses: JActions/maven-version@v1.2.0
@@ -50,9 +45,9 @@ jobs:
steps:
- name: Check out neqsim java project
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up JDK 8 environment
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
@@ -61,9 +56,9 @@ jobs:
run: mvn -B package --file pomJava8.xml
- name: Copy jar file to staging
run: mkdir staging && cp target/neqsim*Java8.jar staging
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
with:
- name: jarfiles
+ name: jarfiles-java8
path: staging
compile_java_11:
@@ -75,9 +70,9 @@ jobs:
steps:
- name: Check out neqsim java project
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Set up JDK 11 environment
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
@@ -86,21 +81,56 @@ jobs:
run: mvn -B package --file pom.xml
- name: Copy jar file to staging
run: mkdir staging && cp target/neqsim*.jar staging
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@v3
with:
- name: jarfiles
+ name: jarfiles-java11
path: staging
-
+
+ compile_java_21:
+ name: Build Neqsim ${{ needs.get_versions.outputs.version }} with java 21
+ needs: get_versions
+
+ if: ${{ needs.get_versions.outputs.version_8 == needs.get_versions.outputs.version }}
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out neqsim java project
+ uses: actions/checkout@v4
+ - name: Set up JDK 21 environment
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ cache: 'maven'
+ - name: Build java 21 version with Maven
+ run: mvn -B package --file pomJava21.xml
+ - name: Rename files
+ run: cd target && find . -type f -name "neqsim-*.jar" -exec sh -c 'mv -f $0 ${0%.jar}-Java21.jar' {} \; && cd ..
+ - name: Copy jar file to staging
+ run: mkdir staging && cp target/neqsim*Java21.jar staging
+ - uses: actions/upload-artifact@v3
+ with:
+ name: jarfiles-java21
+ path: staging
+
create_release:
name: Create release v${{ needs.get_versions.outputs.version_8 }}
runs-on: ubuntu-latest
- needs: [get_versions, compile_java_8, compile_java_11]
+ needs: [get_versions, compile_java_8, compile_java_11, compile_java_21]
steps:
- - name: Download jar files from artifacts
+ - name: Download java 8 jar files
uses: actions/download-artifact@v3.0.1
with:
- name: jarfiles
+ name: jarfiles-java8
+ - name: Download java 11 jar files
+ uses: actions/download-artifact@v3.0.1
+ with:
+ name: jarfiles-java11
+ - name: Download java 21 jar files
+ uses: actions/download-artifact@v3.0.1
+ with:
+ name: jarfiles-java21
- name: Create release v${{ needs.get_versions.outputs.version_8 }}
uses: ncipollo/release-action@v1.11.2
@@ -110,32 +140,5 @@ jobs:
draft: true
generateReleaseNotes: true
skipIfReleaseExists: true
- artifactErrorsFailBuild: true
artifacts: "*.jar"
artifactContentType: application/java-archive
-
- # # Needs to delete the old jars manually
- # - run: mkdir lib && cp *.jar lib/
- # - run: cd lib && mkdir libj8 && mv *Java8.jar libj8/ && cd ..
-
- # - name: Create release branch in neqsimpython repo
- # uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5
- # with:
- # repository_owner: Equinor
- # repository_name: neqsimpython
- # new_branch_name: NeqSim-jars-updated-${{ needs.get_versions.outputs.version_8 }}
- # ssh_deploy_key: ${{ secrets.SSH_DEPLOY_KEY }}
-
- # - name: Push directory to another repository
- # uses: cpina/github-action-push-to-another-repository@v1.5.1
- # env:
- # SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
- # with:
- # source-directory: 'lib'
- # destination-github-username: 'equinor'
- # destination-repository-name: 'neqsimpython'
- # user-email: asmf@equinor.com
- # target-branch: NeqSim-jars-updated-${{ needs.get_versions.outputs.version_8 }}
- # target-directory: neqsim/lib
- # commit_message: 'chore: updated jar-files'
-
diff --git a/.github/workflows/verify_build.yml b/.github/workflows/verify_build.yml
index d3cd2dc7a9..11d0c38376 100644
--- a/.github/workflows/verify_build.yml
+++ b/.github/workflows/verify_build.yml
@@ -1,4 +1,4 @@
-name: Assert package builds, tests run and javadoc builds
+name: Run build, test and javadoc
on:
workflow_dispatch:
@@ -11,13 +11,13 @@ on:
- master
jobs:
- test_javadoc:
+ test_java_11:
name: Assert tests and javadoc with java 11
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Set up JDK 11
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
@@ -29,21 +29,22 @@ jobs:
- name: Create coverage report from jacoco execution data
run: mvn -B jacoco:report -ntp
- name: Upload jacoco coverage reports to Codecov
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
file: jacoco.xml
name: codecov
token: ${{ secrets.CODECOV_TOKEN }}
+ # tags: coverage
test_java_8:
- name: Assert tests and javadoc with java 8
+ name: Assert tests with java 8
runs-on: ubuntu-latest
- needs: test_javadoc
+ needs: test_java_11
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Set up JDK 8
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
@@ -51,3 +52,19 @@ jobs:
- name: Run tests
run: mvn -B test --file pomJava8.xml -ntp
+
+ test_java_21:
+ name: Assert tests with java 21
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'temurin'
+ java-version: '21'
+ cache: 'maven'
+ - name: Generate javadoc
+ run: mvn javadoc:javadoc
+ - name: Run tests
+ run: mvn -B test --file pomJava21.xml -ntp
diff --git a/.gitignore b/.gitignore
index 9757544c87..b873bed133 100644
--- a/.gitignore
+++ b/.gitignore
@@ -87,3 +87,6 @@ test_*.ser
html/
latex/
eclipse_dictionary.txt
+
+src/main/**/*.png
+src/main/**/*.gif
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ed5a134c10..73a30604ea 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,15 +1,23 @@
{
- "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,
+ "java.configuration.updateBuildConfiguration": "interactive",
+ "[java]": {
+ "editor.defaultFormatter": "redhat.java",
+ "editor.formatOnSave": 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"
-}
+ "editor.detectIndentation": false
+ },
+ "java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
+ "java.saveActions.organizeImports": true,
+ "java.checkstyle.version": "10.18.1",
+ "java.checkstyle.configuration": "${workspaceFolder}/checkstyle_neqsim.xml",
+ "java.debug.settings.hotCodeReplace": "never",
+ "[xml]": {
+ "editor.tabSize": 4,
+ "editor.insertSpaces": false
+ },
+ "[json]": {
+ "editor.tabSize": 4,
+ "editor.insertSpaces": true
+ }
+}
\ No newline at end of file
diff --git a/CHANGELOG b/CHANGELOG
deleted file mode 100644
index dbd4b2a478..0000000000
--- a/CHANGELOG
+++ /dev/null
@@ -1,36 +0,0 @@
-Version 2.3
-- Updated mercury heat of formation, melting point temperature and triple point pressure (for improved prediction of solid formation conditions)
-- Updated TPflash with solids (will remove a fluid phase if the phase fraction is zero)
-
-Version 2.2 (17/4/2020)
-- Huron Vidal parameter oxygen-water updated
-- CPA-binary interaction paramter kij updated for N2-water and o2-water
-- Peneloux volume correction paramters water, MEG, TEG
-- Volume correction parameters for water, MEG and TEG updated (temperature dependent volume correction)
-- UMR-PRU model updated with parameters for c-C7 and c-C8, c-C9
-- various bug fixes and new features for process calculations (changes for compressors, mixers, etc.)
-- Short-cut class for creating new fluids implemented (neqsim.thermo.Fluid class)
-
-Version 2.1
-- improved stability of TPflash calculations
-
-Version 2.0 (10/12/2019)
-- verson name changed from 2018.X to 2.X
-- improved speed and stability of algorithms (TPflash, phase envelopes)
-- added GERG-2008 for calculation of gas density
-- various updates in process simulation models (compressors, recycle, mechanical design)
-
-version 2018.5
-- stability and speed improvements
-
-version 2018.4
-- included test framework (Junit5) as part of maven builds
-
-Version 2018.3
-- updates on multithreading performance
-
-Version 2018.2
-- update base package to neqsim
-
-Version 2018.1
-- improved speed for CPA model22
diff --git a/README.md b/README.md
index 00f882efe6..2e6e2bbc23 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,14 @@
-# NeqSim
+![NeqSim Logo](https://github.com/equinor/neqsim/blob/master/docs/wiki/neqsimlogocircleflatsmall.png)
[![Build Status](https://neqsim.visualstudio.com/neqsim_cicd/_apis/build/status/neqsim_build?branchName=master)](https://neqsim.visualstudio.com/neqsim_cicd/_build/latest?definitionId=1&branchName=master)
-![Build maven](https://github.com/equinor/neqsim/workflows/Build%20maven/badge.svg?branch=master)
+![Build maven](https://github.com/equinor/neqsim/actions/workflows/verify_build.yml/badge.svg?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/equinor/neqsim/badge.svg)](https://snyk.io/test/github/equinor/neqsim)
[![codecov](https://codecov.io/gh/equinor/neqsim/branch/master/graph/badge.svg?token=IRnbAwRDtc)](https://codecov.io/gh/equinor/neqsim)
+[![SCM Compliance](https://scm-compliance-api.radix.equinor.com/repos/equinor/neqsim/badge)](https://scm-compliance-api.radix.equinor.com/repos/equinor/neqsim/badge)
-NeqSim is the main part of the [NeqSim project](https://equinor.github.io/neqsimhome/). NeqSim (Non-Equilibrium Simulator) is a Java library for estimating fluid behavior and process design for oil and gas production.
-The basis for NeqSim is a library of fundamental mathematical models related to phase behavior and physical properties of oil and gas. NeqSim is easilly extended with new models. NeqSim development was initiated at the [Norwegian University of Science and Technology (NTNU)](https://www.ntnu.edu/employees/even.solbraa).
+
+NeqSim is the main part of the [NeqSim project](https://equinor.github.io/neqsimhome/). NeqSim (Non-Equilibrium Simulator) is a Java library for estimating fluid properties and process design.
+The basis for NeqSim is a library of fundamental mathematical models related to phase behavior and physical properties of fluids. NeqSim is easilly extended with new models. NeqSim development was initiated at the [Norwegian University of Science and Technology (NTNU)](https://www.ntnu.edu/employees/even.solbraa).
## Releases
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000000..ea3ba1e729
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,16 @@
+If you discover a security vulnerability in this project, please follow these steps to responsibly disclose it:
+
+1. **Do not** create a public GitHub issue for the vulnerability.
+2. Follow our guideline for Responsible Disclosure Policy at [https://www.equinor.com/about-us/csirt](https://www.equinor.com/about-us/csirt) to report the issue
+
+The following information will help us triage your report more quickly:
+
+- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
+- Full paths of source file(s) related to the manifestation of the issue
+- The location of the affected source code (tag/branch/commit or direct URL)
+- Any special configuration required to reproduce the issue
+- Step-by-step instructions to reproduce the issue
+- Proof-of-concept or exploit code (if possible)
+- Impact of the issue, including how an attacker might exploit the issue
+
+We prefer all communications to be in English.
diff --git a/checkstyle_neqsim.xml b/checkstyle_neqsim.xml
index dc35055c58..d7858800da 100644
--- a/checkstyle_neqsim.xml
+++ b/checkstyle_neqsim.xml
@@ -104,10 +104,7 @@
or preceding-sibling::*[last()][self::LCURLY]]" />
@@ -96,11 +97,11 @@ public static double fugcoefDiffPres(ComponentInterface component, PhaseInterfac * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public static double fugcoefDiffTemp(ComponentInterface component, PhaseInterface phase, - int numberOfComponents, double temperature, double pressure, int phasetype) { + int numberOfComponents, double temperature, double pressure, PhaseType pt) { double ans = 0.000001; // double errt, fac, hh, err = 0.00000000000001; // double h = temperature / 50; diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java b/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java index 229fc98b76..1005d3ec9e 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/newtonRhapson.java @@ -56,7 +56,7 @@ public void setOrder(int o) { * setConstants. *
* - * @param constants an array of {@link double} objects + * @param constants an array of type double */ public void setConstants(double[] constants) { System.arraycopy(constants, 0, polyConstants, 0, constants.length); diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java b/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java index 26309b2485..4d4d563617 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/sysNewtonRhapson.java @@ -1,6 +1,7 @@ package neqsim.MathLib.nonLinearSolver; import Jama.Matrix; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; /** @@ -358,8 +359,8 @@ public void calcInc2(int np) { PC2 = Math.exp(u.get(numberOfComponents + 1, 0)); system.setTC((TC1 + TC2) * 0.5); system.setPC((PC1 + PC2) * 0.5); - system.setPhaseType(0, 1); - system.setPhaseType(1, 0); + system.setPhaseType(0, PhaseType.byValue(1)); + system.setPhaseType(1, PhaseType.byValue(0)); return; } else if ((xlnkmax < avscp && testcrit != 1) && (np != ic03p && !etterCP)) { // System.out.println("hei fra her"); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java index ca82082bcd..e6838e108a 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/BasePVTsimulation.java @@ -18,12 +18,13 @@ public class BasePVTsimulation implements SimulationInterface { public ThermodynamicOperations thermoOps = null; private double pressure; public double[] pressures = {381.5, 338.9, 290.6, 242.3, 194.1, 145.8, 145.8, 97.5, 49.3}; - public double temperature = 289.0; + public double temperature = Double.NaN; double[][] experimentalData = null; double saturationVolume = 0; double saturationPressure = 0; double saturationTemperature; double Zsaturation = 0; + String temperatureUnit = "K"; public LevenbergMarquardt optimizer = new LevenbergMarquardt(); /** @@ -44,7 +45,7 @@ public BasePVTsimulation(SystemInterface tempSystem) { * Setter for the fieldexperimentalData
.
*
*
- * @param expData an array of {@link double} objects
+ * @param expData an array of type double
*/
public void setExperimentalData(double[][] expData) {
experimentalData = expData;
@@ -120,7 +121,7 @@ public double getTemperature() {
/**
*
- * Setter for the field temperature
.
+ * Setter for the field temperature
. NB! Verify unit is correct.
*
* Getter for the field pressures
.
@@ -169,7 +177,9 @@ public double getZsaturation() {
}
/**
- *
Getter for the field saturationTemperature
.
+ * Getter for the field saturationTemperature
.
+ *
- * main. + * main *
* * @param args an array of {@link java.lang.String} objects @@ -206,11 +209,11 @@ public static void main(String[] args) { SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 450.0); tempSystem.addComponent("nitrogen", 0.586); tempSystem.addComponent("CO2", 0.087); - tempSystem.addComponent("methane", 17.0209); - tempSystem.addComponent("ethane", 5.176); + tempSystem.addComponent("methane", 107.0209); + tempSystem.addComponent("ethane", 15.176); tempSystem.addComponent("propane", 6.652); - tempSystem.addComponent("i-butane", 1.533); - tempSystem.addComponent("n-butane", 3.544); + tempSystem.addComponent("i-butane", 3.533); + tempSystem.addComponent("n-butane", 5.544); tempSystem.addComponent("i-pentane", 1.585); tempSystem.addComponent("n-pentane", 2.036); tempSystem.addTBPfraction("C6", 2.879, 84.9 / 1000.0, 0.6668); @@ -219,13 +222,12 @@ public static void main(String[] args) { tempSystem.addTBPfraction("C9", 3.488, 119.8 / 1000.0, 0.7743); tempSystem.addPlusFraction("C10", 45.944, 320.0 / 1000.0, 0.924); tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.getCharacterization().characterisePlusFraction(); - - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - DifferentialLiberation CVDsim = new DifferentialLiberation(tempSystem); - CVDsim.runCalc(); + DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem); + differentialLiberation.setPressures( + new double[] {350.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 40.0, 30.0, 20.0, 1.0}); + differentialLiberation.setTemperature(83.5, "C"); + differentialLiberation.runCalc(); } /** diff --git a/src/main/java/neqsim/PVTsimulation/simulation/GOR.java b/src/main/java/neqsim/PVTsimulation/simulation/GOR.java index e0b68dfa57..b91d7677ed 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/GOR.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/GOR.java @@ -1,5 +1,6 @@ package neqsim.PVTsimulation.simulation; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -40,8 +41,8 @@ public GOR(SystemInterface tempSystem) { * setTemperaturesAndPressures. * * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects + * @param temperature an array of type double + * @param pressure an array of type double */ public void setTemperaturesAndPressures(double[] temperature, double[] pressure) { this.pressure = pressure; @@ -70,14 +71,15 @@ public void runCalc() { } if (getThermoSystem().getNumberOfPhases() > 1 && getThermoSystem().getPhase(0).getType() == PhaseType.GAS) { - getThermoSystem().getPhase(0).setPressure(1.01325); + getThermoSystem().getPhase(0) + .setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().getPhase(0).setTemperature(288.15); getThermoSystem().init(1); Sm3gas[i] = getThermoSystem().getPhase(0).getVolume(); // setThermoSystem(getThermoSystem().phaseToSystem(1)); } } - getThermoSystem().setPressure(1.01325); + getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().setTemperature(288.15); thermoOps.TPflash(); oilVolumeStdCond = getThermoSystem().getPhase("oil").getVolume(); @@ -130,7 +132,8 @@ public static void main(String[] args) { GOR sepSim = new GOR(tempSystem); double[] temps = {313.15, 313.15, 313.15, 313.15, 313.15, 313.15, 313.15}; - double[] pres = {500, 400, 200, 100, 50.0, 5.0, 1.01325}; + double[] pres = + {500, 400, 200, 100, 50.0, 5.0, ThermodynamicConstantsInterface.referencePressure}; sepSim.setTemperaturesAndPressures(temps, pres); sepSim.runCalc(); } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java index b20bb57dcc..6cf8501e46 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationPressure.java @@ -31,7 +31,16 @@ public SaturationPressure(SystemInterface tempSystem) { * @return a double */ public double calcSaturationPressure() { - getThermoSystem().isImplementedCompositionDeriativesofFugacity(false); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } + + boolean isMultiPhaseCheckChanged = false; + if (!getThermoSystem().doMultiPhaseCheck()) { + isMultiPhaseCheckChanged = true; + getThermoSystem().setMultiPhaseCheck(true); + } + // getThermoSystem().isImplementedCompositionDeriativesofFugacity(false); getThermoSystem().setPressure(1.0); do { getThermoSystem().setPressure(getThermoSystem().getPressure() + 10.0); @@ -62,6 +71,9 @@ public double calcSaturationPressure() { } while (Math.abs(maxPres - minPres) > 1e-5 && iteration < 500); getThermoSystem().setPressure(maxPres); thermoOps.TPflash(); + if (isMultiPhaseCheckChanged) { + getThermoSystem().setMultiPhaseCheck(false); + } return getThermoSystem().getPressure(); } @@ -109,7 +121,7 @@ public static void main(String[] args) { // satPresSim.getThermoSystem().display(); /* * double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80; - * + * * TuningInterface tuning = new TuneToSaturation(satPresSim); * tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run(); * tuning.getSimulation().getThermoSystem().display(); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java index 85a9dd37ce..ab17808195 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SaturationTemperature.java @@ -31,7 +31,11 @@ public SaturationTemperature(SystemInterface tempSystem) { * @return a double */ public double calcSaturationTemperature() { - getThermoSystem().isImplementedCompositionDeriativesofFugacity(false); + boolean isMultiPhaseCheckChanged = false; + if (!getThermoSystem().doMultiPhaseCheck()) { + isMultiPhaseCheckChanged = true; + getThermoSystem().setMultiPhaseCheck(true); + } do { getThermoSystem().setTemperature(getThermoSystem().getTemperature() - 10.0); thermoOps.TPflash(); @@ -57,6 +61,9 @@ public double calcSaturationTemperature() { } while (Math.abs(maxTemp - minTemp) > 1e-5 && iteration < 500); getThermoSystem().setTemperature(maxTemp); thermoOps.TPflash(); + if (isMultiPhaseCheckChanged) { + getThermoSystem().setMultiPhaseCheck(false); + } return getThermoSystem().getTemperature(); } @@ -101,7 +108,7 @@ public static void main(String[] args) { // satPresSim.getThermoSystem().display(); /* * double saturationPressure = 350.0; double saturationTemperature = 273.15 + 80; - * + * * TuningInterface tuning = new TuneToSaturation(satPresSim); * tuning.setSaturationConditions(saturationTemperature, saturationPressure); tuning.run(); * tuning.getSimulation().getThermoSystem().display(); diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SeparatorTest.java b/src/main/java/neqsim/PVTsimulation/simulation/SeparatorTest.java index e4e104501e..506faaf966 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SeparatorTest.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SeparatorTest.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -40,8 +41,8 @@ public SeparatorTest(SystemInterface tempSystem) { * setSeparatorConditions. * * - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects + * @param temperature an array of type double + * @param pressure an array of type double */ public void setSeparatorConditions(double[] temperature, double[] pressure) { this.pressure = pressure; @@ -70,14 +71,15 @@ public void runCalc() { } if (getThermoSystem().getNumberOfPhases() > 1 && getThermoSystem().getPhase(0).getType() == PhaseType.GAS) { - getThermoSystem().getPhase(0).setPressure(1.01325); + getThermoSystem().getPhase(0) + .setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().getPhase(0).setTemperature(288.15); getThermoSystem().init(1); Sm3gas[i] = getThermoSystem().getPhase(0).getVolume(); setThermoSystem(getThermoSystem().phaseToSystem(1)); } } - getThermoSystem().setPressure(1.01325); + getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().setTemperature(288.15); thermoOps.TPflash(); oilVolumeStdCond = getThermoSystem().getPhase("oil").getVolume(); @@ -130,7 +132,8 @@ public static void main(String[] args) { SeparatorTest sepSim = new SeparatorTest(tempSystem); double[] temps = {313.15, 313.15, 313.15, 313.15, 313.15, 313.15, 313.15}; - double[] pres = {500, 400, 200, 100, 50.0, 5.0, 1.01325}; + double[] pres = + {500, 400, 200, 100, 50.0, 5.0, ThermodynamicConstantsInterface.referencePressure}; sepSim.setSeparatorConditions(temps, pres); sepSim.runCalc(); } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java b/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java index 4e5def965a..fab1696d8f 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SimulationInterface.java @@ -56,4 +56,14 @@ public interface SimulationInterface { * object */ public LevenbergMarquardt getOptimizer(); + + /** + *
+ * Setter for the field temperature
.
+ *
- * Constructor for DensityFunction. - *
- */ - public DensityFunction() { - params = new double[1]; - } + /** + *+ * Constructor for DensityFunction. + *
+ */ + public DensityFunction() { + params = new double[1]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.setTemperature(dependentValues[0]); - thermoOps.TPflash(); - system.initPhysicalProperties(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.setTemperature(dependentValues[0]); + thermoOps.TPflash(); + system.initPhysicalProperties(); - // system.display(); - return system.getPhase(0).getPhysicalProperties().getDensity(); - } + // system.display(); + return system.getPhase(0).getPhysicalProperties().getDensity(); + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - } + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + } } diff --git a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/FunctionJohanSverderup.java b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/FunctionJohanSverderup.java index 432e327c08..7e0d5fff52 100644 --- a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/FunctionJohanSverderup.java +++ b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/FunctionJohanSverderup.java @@ -12,35 +12,34 @@ * @version $Id: $Id */ public class FunctionJohanSverderup extends LevenbergMarquardtFunction { - double molarMass = 0.0; + double molarMass = 0.0; - /** - *- * Constructor for FunctionJohanSverderup. - *
- */ - public FunctionJohanSverderup() { - params = new double[1]; - } + /** + *+ * Constructor for FunctionJohanSverderup. + *
+ */ + public FunctionJohanSverderup() { + params = new double[1]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.addComponent("methane", - -system.getPhase(0).getComponent("methane").getNumberOfmoles()); - system.addComponent("methane", params[0]); - system.init_x_y(); - system.init(1); - system.setPressure(system.getPressure() - 25.0); - SaturationPressure satCalc = new SaturationPressure(system); - double satPres = satCalc.calcSaturationPressure(); + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.addComponent("methane", -system.getPhase(0).getComponent("methane").getNumberOfmoles()); + system.addComponent("methane", params[0]); + system.init_x_y(); + system.init(1); + system.setPressure(system.getPressure() - 25.0); + SaturationPressure satCalc = new SaturationPressure(system); + double satPres = satCalc.calcSaturationPressure(); - return satPres; - } + return satPres; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - } + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + } } diff --git a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/SaturationPressureFunction.java b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/SaturationPressureFunction.java index 9ca7717173..b12d9daadd 100644 --- a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/SaturationPressureFunction.java +++ b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/SaturationPressureFunction.java @@ -13,51 +13,51 @@ * @version $Id: $Id */ public class SaturationPressureFunction extends LevenbergMarquardtFunction { - double molarMass = 0.0; + double molarMass = 0.0; - /** - *- * Constructor for SaturationPressureFunction. - *
- */ - public SaturationPressureFunction() { - params = new double[1]; - } - - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - int plusNumber = 0; - molarMass = params[0]; - for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { - if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { - plusNumber = i; - } - } - SystemInterface tempSystem = system.clone(); - tempSystem.resetCharacterisation(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(system.getMixingRule()); + /** + *+ * Constructor for SaturationPressureFunction. + *
+ */ + public SaturationPressureFunction() { + params = new double[1]; + } - tempSystem.getPhase(0).getComponent(plusNumber).setMolarMass(molarMass); - tempSystem.getPhase(1).getComponent(plusNumber).setMolarMass(molarMass); - tempSystem.setTemperature(dependentValues[0]); - tempSystem.setPressure(50.0); - tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(system.getMixingRule()); - tempSystem.init(0); - tempSystem.init(1); - // \\tempSystem.display(); - SaturationPressure satCalc = new SaturationPressure(tempSystem); - double satPres = satCalc.calcSaturationPressure(); - // tempSystem.display(); - return satPres; + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + int plusNumber = 0; + molarMass = params[0]; + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).isIsPlusFraction()) { + plusNumber = i; + } } + SystemInterface tempSystem = system.clone(); + tempSystem.resetCharacterisation(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(system.getMixingRule()); - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - } + tempSystem.getPhase(0).getComponent(plusNumber).setMolarMass(molarMass); + tempSystem.getPhase(1).getComponent(plusNumber).setMolarMass(molarMass); + tempSystem.setTemperature(dependentValues[0]); + tempSystem.setPressure(50.0); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.createDatabase(true); + tempSystem.setMixingRule(system.getMixingRule()); + tempSystem.init(0); + tempSystem.init(1); + // \\tempSystem.display(); + SaturationPressure satCalc = new SaturationPressure(tempSystem); + double satPres = satCalc.calcSaturationPressure(); + // tempSystem.display(); + return satPres; + } + + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + } } diff --git a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/ViscosityFunction.java b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/ViscosityFunction.java index ae7659896d..03dabd1b7a 100644 --- a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/ViscosityFunction.java +++ b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/ViscosityFunction.java @@ -12,51 +12,51 @@ * @version $Id: $Id */ public class ViscosityFunction extends LevenbergMarquardtFunction { - double molarMass = 0.0; - boolean includeWaxEmulsionViscosity = true; + double molarMass = 0.0; + boolean includeWaxEmulsionViscosity = true; - /** - *- * Constructor for ViscosityFunction. - *
- */ - public ViscosityFunction() { - params = new double[1]; - } + /** + *+ * Constructor for ViscosityFunction. + *
+ */ + public ViscosityFunction() { + params = new double[1]; + } - /** - *- * Constructor for ViscosityFunction. - *
- * - * @param includeWax a boolean - */ - public ViscosityFunction(boolean includeWax) { - params = new double[1]; - includeWaxEmulsionViscosity = includeWax; - } + /** + *+ * Constructor for ViscosityFunction. + *
+ * + * @param includeWax a boolean + */ + public ViscosityFunction(boolean includeWax) { + params = new double[1]; + includeWaxEmulsionViscosity = includeWax; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - thermoOps.TPflash(); - system.initPhysicalProperties(); - double waxFraction = 0.0; - if (system.hasPhaseType("wax") && includeWaxEmulsionViscosity) { - waxFraction = system.getWtFraction(system.getPhaseNumberOfPhase("wax")); - return system.getPhase(0).getPhysicalProperties().getViscosityOfWaxyOil(waxFraction, - dependentValues[0]); // %wax - } - // system.display(); - return system.getPhase(0).getPhysicalProperties().getViscosity(); // %wax + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + thermoOps.TPflash(); + system.initPhysicalProperties(); + double waxFraction = 0.0; + if (system.hasPhaseType("wax") && includeWaxEmulsionViscosity) { + waxFraction = system.getWtFraction(system.getPhaseNumberOfPhase("wax")); + return system.getPhase(0).getPhysicalProperties().getViscosityOfWaxyOil(waxFraction, + dependentValues[0]); // %wax } + // system.display(); + return system.getPhase(0).getPhysicalProperties().getViscosity(); // %wax + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; - ((FrictionTheoryViscosityMethod) system.getPhase(0).getPhysicalProperties() - .getViscosityModel()).setTBPviscosityCorrection(value); - } + ((FrictionTheoryViscosityMethod) system.getPhase(0).getPhysicalProperties().getViscosityModel()) + .setTBPviscosityCorrection(value); + } } diff --git a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/WaxFunction.java b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/WaxFunction.java index 3f92961289..63b494975e 100644 --- a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/WaxFunction.java +++ b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/WaxFunction.java @@ -11,42 +11,42 @@ * @version $Id: $Id */ public class WaxFunction extends LevenbergMarquardtFunction { - double molarMass = 0.0; + double molarMass = 0.0; - /** - *- * Constructor for WaxFunction. - *
- */ - public WaxFunction() { - params = new double[3]; - } + /** + *+ * Constructor for WaxFunction. + *
+ */ + public WaxFunction() { + params = new double[3]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.setTemperature(dependentValues[0]); - thermoOps.TPflash(); - double waxFraction = 0.0; - if (system.hasPhaseType("wax")) { - waxFraction = system.getWtFraction(system.getPhaseNumberOfPhase("wax")); - } - // system.display(); - return waxFraction * 100.0; // %wax + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.setTemperature(dependentValues[0]); + thermoOps.TPflash(); + double waxFraction = 0.0; + if (system.hasPhaseType("wax")) { + waxFraction = system.getWtFraction(system.getPhaseNumberOfPhase("wax")); } + // system.display(); + return waxFraction * 100.0; // %wax + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - if (i < 3) { - system.getWaxModel().setWaxParameter(i, params[i]); - } else if (i == 3) { - system.getWaxModel().setParameterWaxHeatOfFusion(i - 3, value); - } else { - system.getWaxModel().setParameterWaxTriplePointTemperature(i - 4, value); - } - system.getWaxModel().removeWax(); - system.getWaxModel().addTBPWax(); + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + if (i < 3) { + system.getWaxModel().setWaxParameter(i, params[i]); + } else if (i == 3) { + system.getWaxModel().setParameterWaxHeatOfFusion(i - 3, value); + } else { + system.getWaxModel().setParameterWaxTriplePointTemperature(i - 4, value); } + system.getWaxModel().removeWax(); + system.getWaxModel().addTBPWax(); + } } diff --git a/src/main/java/neqsim/api/ioc/CalculationResult.java b/src/main/java/neqsim/api/ioc/CalculationResult.java index 09f6550db6..89dceb2a90 100644 --- a/src/main/java/neqsim/api/ioc/CalculationResult.java +++ b/src/main/java/neqsim/api/ioc/CalculationResult.java @@ -3,7 +3,9 @@ import java.util.Arrays; /** - *CalculationResult class.
+ *+ * CalculationResult class. + *
* * @author jo.lyshoel * @version $Id: $Id @@ -13,7 +15,9 @@ public class CalculationResult { public String[] calculationError; /** - *Constructor for CalculationResult.
+ *+ * Constructor for CalculationResult. + *
* * @param fluidProperties an array of {@link java.lang.Double} objects * @param calculationError an array of {@link java.lang.String} objects @@ -23,16 +27,6 @@ public CalculationResult(Double[][] fluidProperties, String[] calculationError) this.calculationError = calculationError; } - /** {@inheritDoc} */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(calculationError); - result = prime * result + Arrays.deepHashCode(fluidProperties); - return result; - } - /** {@inheritDoc} */ @Override public boolean equals(Object obj) { @@ -49,4 +43,14 @@ public boolean equals(Object obj) { return Arrays.equals(calculationError, other.calculationError) && Arrays.deepEquals(fluidProperties, other.fluidProperties); } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(calculationError); + result = prime * result + Arrays.deepHashCode(fluidProperties); + return result; + } } diff --git a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java index 10b4a533a1..ce4e5bf703 100644 --- a/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java +++ b/src/main/java/neqsim/chemicalReactions/ChemicalReactionOperations.java @@ -52,13 +52,6 @@ public class ChemicalReactionOperations Kinetics kineticsSolver; LinearProgrammingChemicalEquilibrium initCalc; - /** - *- * Constructor for ChemicalReactionOperations. - *
- */ - public ChemicalReactionOperations() {} - /** ** Constructor for ChemicalReactionOperations. @@ -67,7 +60,6 @@ public ChemicalReactionOperations() {} * @param system a {@link neqsim.thermo.system.SystemInterface} object */ public ChemicalReactionOperations(SystemInterface system) { - initCalc = new LinearProgrammingChemicalEquilibrium(); boolean newcomps = true; int old = system.getPhase(0).getNumberOfComponents(); this.system = system; @@ -293,7 +285,7 @@ public String[] getAllElements() { * * @return a boolean */ - public boolean hasRections() { + public boolean hasReactions() { return components.length > 0; } @@ -302,7 +294,7 @@ public boolean hasRections() { * calcNVector. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcNVector() { double[] nvec = new double[components.length]; @@ -318,7 +310,7 @@ public double[] calcNVector() { * calcBVector. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcBVector() { Matrix tempA = new Matrix(Amatrix); @@ -337,7 +329,7 @@ public double[] calcBVector() { * * * @param phase a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcChemRefPot(int phase) { double[] referencePotentials = new double[components.length]; @@ -421,7 +413,7 @@ public boolean solveChemEq(int phase, int type) { // System.out.println("pressure1"); calcChemRefPot(phase); // System.out.println("pressure2"); - if (firsttime == true || type == 0) { + if (firsttime || type == 0) { try { // System.out.println("Calculating initial estimates"); nVector = calcNVector(); @@ -448,6 +440,7 @@ public boolean solveChemEq(int phase, int type) { solver = new ChemicalEquilibrium(Amatrix, bVector, system, components, phase); } catch (Exception ex) { logger.error(ex.getMessage(), ex); + // todo: Will this crash below? } return solver.solve(); } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java index 40db28d2ff..b2acd76b87 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemEq.java @@ -1,6 +1,7 @@ package neqsim.chemicalReactions.chemicalEquilibriaum; import Jama.Matrix; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *@@ -14,7 +15,7 @@ public class ChemEq implements java.io.Serializable { private static final long serialVersionUID = 1000; int NSPEC = 10; int NELE = 3; - double R = 8.3143; + double R = ThermodynamicConstantsInterface.R; double G_min = 0; double T = 3500; double P = 51; @@ -73,10 +74,10 @@ public ChemEq() { * * @param T a double * @param P a double - * @param A_matrix an array of {@link double} objects - * @param n_mol an array of {@link double} objects - * @param chem_ref an array of {@link double} objects - * @param b_element an array of {@link double} objects + * @param A_matrix an array of type double + * @param n_mol an array of type double + * @param chem_ref an array of type double + * @param b_element an array of type double */ public ChemEq(double T, double P, double[][] A_matrix, double[] n_mol, double[] chem_ref, double[] b_element) { @@ -115,7 +116,7 @@ public ChemEq(double T, double P, double[][] A_matrix, double[] n_mol, double[] * Constructor for ChemEq. *
* - * @param A_matrix an array of {@link double} objects + * @param A_matrix an array of type double */ public ChemEq(double[][] A_matrix) { this.A_matrix = A_matrix; @@ -128,7 +129,7 @@ public ChemEq(double[][] A_matrix) { * * @param T a double * @param P a double - * @param A_matrix an array of {@link double} objects + * @param A_matrix an array of type double */ public ChemEq(double T, double P, double[][] A_matrix) { this.T = T; @@ -242,9 +243,7 @@ public double step() { double[] n_omega = new double[NSPEC]; double[] chem_pot_omega = new double[NSPEC]; double[] chem_pot = new double[NSPEC]; - double G_1; - double G_0; check = 0; step = 1; @@ -261,8 +260,8 @@ public double step() { } } - G_1 = 0; - + double G_0; + double G_1 = 0; for (i = 0; i < NSPEC; i++) { G_1 += chem_pot_omega[i] * d_n[i]; } @@ -287,7 +286,7 @@ public double step() { * innerStep. * * - * @param n_omega an array of {@link double} objects + * @param n_omega an array of type double * @param check a int * @param step a double * @return a double @@ -323,8 +322,8 @@ public double innerStep(double[] n_omega, int check, double step) { * * @param T a double * @param P a double - * @param n_mol an array of {@link double} objects - * @param chem_ref an array of {@link double} objects + * @param n_mol an array of type double + * @param chem_ref an array of type double */ public void solve(double T, double P, double[] n_mol, double[] chem_ref) { this.T = T; diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java index 25df36f936..f9f212c962 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/ChemicalEquilibrium.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.system.SystemInterface; @@ -24,7 +25,7 @@ public class ChemicalEquilibrium implements java.io.Serializable { double d_n_t = 0; int NSPEC = 2; int NELE = 2; - double R = 8.314; + double R = ThermodynamicConstantsInterface.R; Matrix x_solve; double y_solve; double n_t = 0.0; @@ -63,8 +64,8 @@ public class ChemicalEquilibrium implements java.io.Serializable { * Constructor for ChemicalEquilibrium. * * - * @param A_matrix an array of {@link double} objects - * @param b_element an array of {@link double} objects + * @param A_matrix an array of type double + * @param b_element an array of type double * @param system a {@link neqsim.thermo.system.SystemInterface} object * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects * @param phase a int @@ -268,7 +269,6 @@ public void updateMoles() { phasenumb); } - // changeMoles += n_mol[i] - // system.getPhase(phasenumb).getComponents()[components[i].getComponentNumber()] // .getNumberOfMolesInPhase(); @@ -377,7 +377,7 @@ public void printComp() { * getMoles. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMoles() { return n_mol; @@ -482,7 +482,7 @@ public double step() { * * * @param i a int - * @param n_omega an array of {@link double} objects + * @param n_omega an array of type double * @param check a int * @param step a double * @param test a boolean @@ -517,9 +517,9 @@ public double innerStep(int i, double[] n_omega, int check, double step, boolean * public double step(){ double step=1.0; int i, check=0; double[] F = new double[NSPEC]; double[] * F_omega = new double[NSPEC]; double[] chem_pot = new double[NSPEC]; double[] n_omega = new * double[NSPEC]; - * + * * Matrix F_matrix, F_omega_matrix, fs_matrix, f_matrix, f_omega_matrix; double fs,f,f_omega; - * + * * for(i = 0;i- * Constructor for LinearProgrammingChemicalEquilibrium. - *
- */ - public LinearProgrammingChemicalEquilibrium() {} - /** ** Constructor for LinearProgrammingChemicalEquilibrium. *
* - * @param chemRefPot an array of {@link double} objects + * @param chemRefPot an array of type double * @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects * @param elements an array of {@link java.lang.String} objects * @param operations a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object @@ -119,7 +112,7 @@ public LinearProgrammingChemicalEquilibrium(double[] chemRefPot, ComponentInterf * calcA. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] calcA() { int A_size = components.length - operations.getReactionList().getChemicalReactionList().size(); @@ -158,7 +151,7 @@ public double[][] calcA() { * getA. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getA() { return Amatrix; @@ -169,7 +162,7 @@ public double[][] getA() { * getRefPot. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getRefPot() { return chemRefPot; @@ -209,50 +202,41 @@ public void changePrimaryComponents() { * //System.out.println("Ans"); //Ans.print(10,8); //Print statements added by Neeraj * System.out.println("lagranges: "); lagrangeTemp.print(10,2); System.out.println("refpot: "); * mutemp.print(10,2); System.out.println("A: "); atemp.print(10,2); - * - * + * * Matrix rTemp = new Matrix(atemp.getRowDimension(),1); rTemp.set(0,0,inertMoles/bVector[0]); * for(int i=1;i- * Constructor for ChemicalReaction. - *
- * - * @deprecated use - * {@link #ChemicalReaction(String, String[], double[], double[], double, double, double)} - * instead - */ - @Deprecated - public ChemicalReaction() { - super("ChemicalReaction"); - } - /** ** Constructor for ChemicalReaction. @@ -61,8 +47,8 @@ public ChemicalReaction() { * * @param name a {@link java.lang.String} object * @param names an array of {@link java.lang.String} objects - * @param stocCoefs an array of {@link double} objects - * @param K an array of {@link double} objects + * @param stocCoefs an array of type double + * @param K an array of type double * @param r a double * @param activationEnergy a double * @param refT a double @@ -71,7 +57,6 @@ public ChemicalReaction(String name, String[] names, double[] stocCoefs, double[ double activationEnergy, double refT) { /* * this.names = names; this.stocCoefs = stocCoefs; this.K = K; - * */ super(name); this.names = new String[names.length]; @@ -145,30 +130,12 @@ public double getRateFactor(PhaseInterface phase) { return 2.576e9 * Math.exp(-6024.0 / phase.getTemperature()) / 1000.0; } - /** - *
- * getK. - *
- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a double - */ - public double getK(PhaseInterface phase) { - double temperature = phase.getTemperature(); - lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; - if (shiftSignK) { - lnK = -lnK; - } - // System.out.println("K " + Math.exp(lnK)); - return Math.exp(lnK); - } - /** *
* Getter for the field stocCoefs
.
*
+ * getK. + *
+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a double + */ + public double getK(PhaseInterface phase) { + double temperature = phase.getTemperature(); + lnK = K[0] + K[1] / (temperature) + K[2] * Math.log(temperature) + K[3] * temperature; + if (shiftSignK) { + lnK = -lnK; + } + // System.out.println("K " + Math.exp(lnK)); + return Math.exp(lnK); + } + /** * Setter for property k. * diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java index fd76986e6c..136df62f9e 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReactionList.java @@ -37,13 +37,6 @@ public class ChemicalReactionList implements ThermodynamicConstantsInterface { double[][] tempReacMatrix; double[][] tempStocMatrix; - /** - *- * Constructor for ChemicalReactionList. - *
- */ - public ChemicalReactionList() {} - /** *
* readReactions.
@@ -119,7 +112,7 @@ public void readReactions(SystemInterface system) {
}
} while (dataSet.next());
} catch (Exception ex) {
- logger.error("could not add reacton: ", ex);
+ logger.error("could not add reaction: ", ex);
}
}
@@ -192,8 +185,8 @@ public void checkReactions(PhaseInterface phase) {
*
* @param phase a {@link neqsim.thermo.phase.PhaseInterface} object
* @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects
- * @param Amatrix an array of {@link double} objects
- * @param chemRefPot an array of {@link double} objects
+ * @param Amatrix an array of type double
+ * @param chemRefPot an array of type double
*/
public void initMoleNumbers(PhaseInterface phase, ComponentInterface[] components,
double[][] Amatrix, double[] chemRefPot) {
@@ -236,7 +229,7 @@ public String[] getAllComponents() {
*
* @param phase a {@link neqsim.thermo.phase.PhaseInterface} object
* @param components an array of {@link neqsim.thermo.component.ComponentInterface} objects
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] createReactionMatrix(PhaseInterface phase, ComponentInterface[] components) {
Iterator
reacMatrix
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] getReacMatrix() {
return tempReacMatrix;
@@ -394,7 +387,7 @@ public double[][] getReacMatrix() {
* getStocMatrix.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] getStocMatrix() {
return tempStocMatrix;
diff --git a/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java b/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java
index ecc03c6f67..80b922cf48 100644
--- a/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java
+++ b/src/main/java/neqsim/chemicalReactions/kinetics/Kinetics.java
@@ -25,13 +25,6 @@ public class Kinetics implements java.io.Serializable {
double phiInfinite = 0.0;
boolean isIrreversible;
- /**
- * - * Constructor for Kinetics. - *
- */ - public Kinetics() {} - /** *
* Constructor for Kinetics.
@@ -62,7 +55,10 @@ public void calcKinetics() {}
*/
public double calcReacMatrix(PhaseInterface phase, PhaseInterface interPhase, int comp) {
ChemicalReaction reaction;
- double reacCoef = 0.0, irr = 0.0, ktemp = 0.0, exponent = 0.0;
+ double reacCoef = 0.0;
+ double irr = 0.0;
+ double ktemp = 0.0;
+ double exponent = 0.0;
Iterator
* Constructor for SampleXYDataSource. *
* - * @param p an array of {@link double} objects + * @param p an array of type double * @param name an array of {@link java.lang.String} objects * @param title a {@link java.lang.String} object * @param xaxis a {@link java.lang.String} object @@ -66,25 +61,13 @@ public SampleXYDataSource(double[][] p, String[] name, String title, String xaxi } /** - * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... - * - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The x-value for the specified series and item. - */ - public Number getXValue(int series, int item) { - return (Double.valueOf(points[2 * series][item])); - } - - /** - * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + * Returns the number of items in the specified series. * * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The y-value for the specified series and item. + * @return The number of items in the specified series. */ - public Number getYValue(int series, int item) { - return (Double.valueOf(points[(series * 2 + 1)][item])); + public int getItemCount(int series) { + return items[series]; } /** @@ -107,12 +90,24 @@ public String getSeriesName(int series) { } /** - * Returns the number of items in the specified series. + * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... * * @param series The index (zero-based) of the series; - * @return The number of items in the specified series. + * @param item The index (zero-based) of the required item; + * @return The x-value for the specified series and item. */ - public int getItemCount(int series) { - return items[series]; + public Number getXValue(int series, int item) { + return (Double.valueOf(points[2 * series][item])); + } + + /** + * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + * + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The y-value for the specified series and item. + */ + public Number getYValue(int series, int item) { + return (Double.valueOf(points[(series * 2 + 1)][item])); } } diff --git a/src/main/java/neqsim/dataPresentation/dataHandeling.java b/src/main/java/neqsim/dataPresentation/dataHandeling.java index 4ce655f072..5da9caccbc 100644 --- a/src/main/java/neqsim/dataPresentation/dataHandeling.java +++ b/src/main/java/neqsim/dataPresentation/dataHandeling.java @@ -26,32 +26,39 @@ public class dataHandeling { */ public dataHandeling() {} + /** + * Returns the number of items in the specified series. + * + * @param series The index (zero-based) of the series; + * @return The number of items in the specified series. + */ + public int getItemCount(int series) { + return 81; + } + /** *- * getXValue. + * getLegendItemCount. *
* - * @param series a int - * @param item a int - * @return a {@link java.lang.Number} object + * @return a int */ - public Number getXValue(int series, int item) { - return Double.valueOf(-10.0 + (item * 0.2)); + public int getLegendItemCount() { + return 2; } /** - * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + *+ * getLegendItemLabels. + *
* - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The y-value for the specified series and item. + * @return an array of {@link java.lang.String} objects */ - public Number getYValue(int series, int item) { - if (series == 0) { - return Double.valueOf(Math.cos(-10.0 + (item * 0.2))); - } else { - return Double.valueOf(2 * (Math.sin(-10.0 + (item * 0.2)))); - } + public String[] getLegendItemLabels() { + String[] str = new String[2]; + str[1] = ""; + str[2] = ""; + return str; } /** @@ -79,39 +86,32 @@ public String getSeriesName(int series) { } } - /** - * Returns the number of items in the specified series. - * - * @param series The index (zero-based) of the series; - * @return The number of items in the specified series. - */ - public int getItemCount(int series) { - return 81; - } - /** *- * getLegendItemCount. + * getXValue. *
* - * @return a int + * @param series a int + * @param item a int + * @return a {@link java.lang.Number} object */ - public int getLegendItemCount() { - return 2; + public Number getXValue(int series, int item) { + return Double.valueOf(-10.0 + (item * 0.2)); } /** - *- * getLegendItemLabels. - *
+ * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... * - * @return an array of {@link java.lang.String} objects + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The y-value for the specified series and item. */ - public String[] getLegendItemLabels() { - String[] str = new String[2]; - str[1] = ""; - str[2] = ""; - return str; + public Number getYValue(int series, int item) { + if (series == 0) { + return Double.valueOf(Math.cos(-10.0 + (item * 0.2))); + } else { + return Double.valueOf(2 * (Math.sin(-10.0 + (item * 0.2)))); + } } /** @@ -119,7 +119,7 @@ public String[] getLegendItemLabels() { * printToFile. * * - * @param points an array of {@link double} objects + * @param points an array of type double * @param filename a {@link java.lang.String} object */ public void printToFile(double[][] points, String filename) { diff --git a/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java b/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java index fb25a08023..2431ca49f0 100644 --- a/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java +++ b/src/main/java/neqsim/dataPresentation/fileHandeling/createTextFile/TextFile.java @@ -70,7 +70,7 @@ public void setValues(String[][] values) { * Setter for the fieldvalues
.
*
*
- * @param valuesloca an array of {@link double} objects
+ * @param valuesloca an array of type double
*/
public void setValues(double[][] valuesloca) {
values = new String[valuesloca[0].length][valuesloca.length];
diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java
index 197131ae89..0bedd2fd53 100644
--- a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java
+++ b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNode.java
@@ -156,7 +156,7 @@ public void setFrictionFactorType(int type) {
if (type == 1) {
interphaseTransportCoefficient = new InterphaseTransportCoefficientBaseClass(this);
} else {
- System.out.println("error chhosing friction type");
+ System.out.println("error choosing friction type");
}
}
@@ -444,7 +444,7 @@ public void setBulkSystem(SystemInterface bulkSystem) {
/** {@inheritDoc} */
@Override
public FlowNodeInterface getNextNode() {
- return (FlowNodeInterface) this.clone();
+ return this.clone();
}
/** {@inheritDoc} */
@@ -590,10 +590,12 @@ public void display(String name) {
JTable Jtab = new JTable(table, names);
JScrollPane scrollpane = new JScrollPane(Jtab);
dialogContentPane.add(scrollpane);
- Jtab.setRowHeight(dialog.getHeight() / table.length);
- Jtab.setFont(new Font("Serif", Font.PLAIN,
- dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10));
- // dialog.pack();
+ if (table.length > 0) {
+ Jtab.setRowHeight(dialog.getHeight() / table.length);
+ Jtab.setFont(new Font("Serif", Font.PLAIN,
+ dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10));
+ // dialog.pack();
+ }
dialog.setVisible(true);
}
@@ -643,11 +645,19 @@ public void setFlowDirection(int flowDirection, int i) {
* @return an array of {@link java.lang.String} objects
*/
public String[][] createTable(String name) {
+ int rows = 0;
+ if (bulkSystem == null) {
+ String[][] table = new String[0][5];
+ return table;
+ }
+
+ rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10;
+ String[][] table = new String[rows][5];
+
DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(5);
nf.applyPattern("#.#####E0");
- String[][] table = new String[bulkSystem.getPhases()[0].getNumberOfComponents() * 10][5];
table[0][0] = "";
table[0][1] = "";
table[0][2] = "";
@@ -689,7 +699,6 @@ public String[][] createTable(String name) {
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 5][4] = "[-]";
// Double.longValue(system.getPhase(phaseIndex[i]).getBeta());
-
buf = new StringBuffer();
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][0] = "Velocity";
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 6][i + 1] =
@@ -739,6 +748,7 @@ public String[][] createTable(String name) {
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][i + 1] = name;
table[3 * bulkSystem.getPhases()[0].getNumberOfComponents() + 13][4] = "-";
}
+
return table;
}
diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java
index 3ef19b9189..62beeb5ba0 100644
--- a/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java
+++ b/src/main/java/neqsim/fluidMechanics/flowNode/FlowNodeInterface.java
@@ -608,7 +608,7 @@ public default void setVelocityIn(DoubleCloneable vel) {
* setFluxes.
*
*
- * @param dn an array of {@link double} objects
+ * @param dn an array of type double
*/
public void setFluxes(double[] dn);
diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundary.java
index 2fd33b1aaa..32464155f3 100644
--- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundary.java
+++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundary.java
@@ -61,13 +61,6 @@ public abstract class FluidBoundary implements FluidBoundaryInterface, java.io.S
protected double[] prandtlNumber;
protected int solverType = 0;
- /**
- * - * Constructor for FluidBoundary. - *
- */ - public FluidBoundary() {} - /** ** Constructor for FluidBoundary. @@ -427,7 +420,15 @@ public String[][] createTable(String name) { nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - String[][] table = new String[bulkSystem.getPhases()[0].getNumberOfComponents() * 10][5]; + int rows = 0; + if (bulkSystem == null) { + String[][] table = new String[0][5]; + return table; + } + + rows = bulkSystem.getPhases()[0].getNumberOfComponents() * 10; + String[][] table = new String[rows][5]; + // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; table[0][1] = ""; diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java index ef8788fd52..ba885c5ce2 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/FluidBoundaryInterface.java @@ -123,7 +123,7 @@ public interface FluidBoundaryInterface extends Cloneable { * calcFluxes. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcFluxes(); diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/equilibriumFluidBoundary/EquilibriumFluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/equilibriumFluidBoundary/EquilibriumFluidBoundary.java index 87f1bdeb68..bdba405441 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/equilibriumFluidBoundary/EquilibriumFluidBoundary.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/equilibriumFluidBoundary/EquilibriumFluidBoundary.java @@ -19,13 +19,6 @@ public class EquilibriumFluidBoundary extends neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.FluidBoundary { private static final long serialVersionUID = 1000; - /** - *- * Constructor for EquilibriumFluidBoundary. - *
- */ - public EquilibriumFluidBoundary() {} - /** ** Constructor for EquilibriumFluidBoundary. diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java index f4411396a6..21b584da3e 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySolver/FluidBoundarySolver.java @@ -41,7 +41,9 @@ public FluidBoundarySolver() {} * Constructor for FluidBoundarySolver. *
* - * @param boundary a {@link FluidBoundarySystemInterface} object + * @param boundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} + * object */ public FluidBoundarySolver(FluidBoundarySystemInterface boundary) { this.boundary = boundary; @@ -67,7 +69,9 @@ public FluidBoundarySolver(FluidBoundarySystemInterface boundary) { * Constructor for FluidBoundarySolver. * * - * @param boundary a {@link FluidBoundarySystemInterface} * object + * @param boundary a + * {@link neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystemInterface} + * * object * @param reactive a boolean */ public FluidBoundarySolver(FluidBoundarySystemInterface boundary, boolean reactive) { diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundaryNonReactive/FluidBoundarySystemNonReactive.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundaryNonReactive/FluidBoundarySystemNonReactive.java index 7568293132..c73f6edbdf 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundaryNonReactive/FluidBoundarySystemNonReactive.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundaryNonReactive/FluidBoundarySystemNonReactive.java @@ -6,6 +6,7 @@ import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystem; import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode; import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; @@ -58,7 +59,7 @@ public void createSystem() { * @param args an array of {@link java.lang.String} objects */ public static void main(String[] args) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); + SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure); PipeData pipe1 = new PipeData(10.0, 0.025); testSystem.addComponent("methane", 0.061152181, 0); diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java index f46d9886ae..85e97dc80e 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/finiteVolumeBoundary/fluidBoundarySystem/fluidBoundarySystemReactive/FluidBoundarySystemReactive.java @@ -12,6 +12,7 @@ import neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.finiteVolumeBoundary.fluidBoundarySystem.FluidBoundarySystem; import neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode.StratifiedFlowNode; import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; @@ -65,7 +66,8 @@ public void createSystem() { * @param args an array of {@link java.lang.String} objects */ public static void main(String[] args) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); + SystemInterface testSystem = + new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure); PipeData pipe1 = new PipeData(10.0, 0.025); testSystem.addComponent("methane", 0.061152181, 0); diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java index 9e1db0eecc..4458546fc0 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/NonEquilibriumFluidBoundary.java @@ -26,13 +26,6 @@ public abstract class NonEquilibriumFluidBoundary public double[][] molFractionDifference; - /** - *- * Constructor for NonEquilibriumFluidBoundary. - *
- */ - public NonEquilibriumFluidBoundary() {} - /** ** Constructor for NonEquilibriumFluidBoundary. diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/KrishnaStandartFilmModel.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/KrishnaStandartFilmModel.java index b9a562bdef..bc527dfac1 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/KrishnaStandartFilmModel.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/KrishnaStandartFilmModel.java @@ -27,13 +27,6 @@ public class KrishnaStandartFilmModel extends Matrix redCorrectionMatrix; Matrix betaMatrix; - /** - *
- * Constructor for KrishnaStandartFilmModel. - *
- */ - public KrishnaStandartFilmModel() {} - /** ** Constructor for KrishnaStandartFilmModel. diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java index fa2eb461a0..773c0d3d62 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveFluidBoundary.java @@ -26,13 +26,6 @@ public abstract class ReactiveFluidBoundary extends KrishnaStandartFilmModel { public double[][] molFractionDifference; - /** - *
- * Constructor for ReactiveFluidBoundary. - *
- */ - public ReactiveFluidBoundary() {} - /** ** Constructor for ReactiveFluidBoundary. @@ -530,7 +523,7 @@ public double[] calcFluxes() { * calcFluxes2. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcFluxes2() { double sum = 0.0; diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java index b65f1e4f94..eee40422b8 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/fluidBoundary/heatMassTransferCalc/nonEquilibriumFluidBoundary/filmModelBoundary/reactiveFilmModel/ReactiveKrishnaStandartFilmModel.java @@ -26,13 +26,6 @@ public class ReactiveKrishnaStandartFilmModel extends KrishnaStandartFilmModel { int enhancementType = 1; - /** - *- * Constructor for ReactiveKrishnaStandartFilmModel. - *
- */ - public ReactiveKrishnaStandartFilmModel() {} - /** ** Constructor for ReactiveKrishnaStandartFilmModel. diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/waxNode/WaxDepositionFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/waxNode/WaxDepositionFlowNode.java index cfbeb38504..f2d85ec04e 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/waxNode/WaxDepositionFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/multiPhaseNode/waxNode/WaxDepositionFlowNode.java @@ -60,12 +60,7 @@ public WaxDepositionFlowNode(SystemInterface system, GeometryDefinitionInterface */ public WaxDepositionFlowNode(SystemInterface system, SystemInterface interphaseSystem, GeometryDefinitionInterface pipe) { - super(system, pipe); - this.flowNodeType = "wax deposition node"; - this.interphaseTransportCoefficient = new InterphaseStratifiedFlow(this); - this.fluidBoundary = - new neqsim.fluidMechanics.flowNode.fluidBoundary.heatMassTransferCalc.nonEquilibriumFluidBoundary.filmModelBoundary.KrishnaStandartFilmModel( - this); + this(system, pipe); } /** {@inheritDoc} */ @@ -126,7 +121,8 @@ public FlowNodeInterface getNextNode() { @SuppressWarnings("unused") public static void main(String[] args) { SystemInterface testSystem = new SystemSrkEos(273.15 + 40.0, 10.0); - // SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, 1.01325); + // SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); PipeData pipe1 = new PipeData(0.203, 0.00025); @@ -165,7 +161,7 @@ public static void main(String[] args) { /* * double length = 0; - * + * * double[][] temperatures2 = new double[3][1000]; int k = 0; for (int i = 0; i < 11; i++) { * length += test.getLengthOfNode(); test.initFlowCalc(); test.calcFluxes(); if (i > 1 && (i % * 1) == 0) { k++; test.display("length " + length); test.getBulkSystem().display("length " + @@ -173,13 +169,12 @@ public static void main(String[] args) { * //test.getFluidBoundary().display("length " + length); test.setLengthOfNode(0.000005 + * test.getLengthOfNode() / 2.0); temperatures2[0][k] = length; temperatures2[1][k] = * test.getGeometry().getTemperature(); test.getFluidBoundary().display("test"); } - * + * * //test.getBulkSystem().display(); test.update(); test.getFluidBoundary().display("length " + * length); test.getInterphaseSystem().display("length " + length); - * - * + * * //test.getFluidBoundary().display("test"); } - * + * * for (int i = 0; i < k; i++) { System.out.println("len temp " + temperatures2[0][i] + " " + * temperatures2[1][i]); } */ diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java index 7291beba3f..bf2bb61b58 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/TwoPhaseFlowNode.java @@ -94,7 +94,6 @@ public double initVelocity() { /** {@inheritDoc} */ @Override public void initFlowCalc() { - initVelocity(); init(); @@ -401,6 +400,13 @@ public void update() { } } + /** + *
+ * update. + *
+ * + * @param deltaTime a double + */ public void update(double deltaTime) { for (int componentNumber = 0; componentNumber < getBulkSystem().getPhases()[0] .getNumberOfComponents(); componentNumber++) { @@ -419,6 +425,5 @@ public void update(double deltaTime) { getBulkSystem().initBeta(); getBulkSystem().init_x_y(); getBulkSystem().initProperties(); - } } diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/DropletFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/DropletFlowNode.java index 614c5747a5..b091df923e 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/DropletFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/DropletFlowNode.java @@ -152,7 +152,8 @@ public FlowNodeInterface getNextNode() { @SuppressWarnings("unused") public static void mainOld(String[] args) { SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 11.0, 60.0); - // SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, 1.01325); + // SystemInterface testSystem = new SystemSrkCPAstatoil(275.3, + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); PipeData pipe1 = new PipeData(0.203, 0.00025); diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhaseTrayTowerFlowNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhaseTrayTowerFlowNode.java index d5d3727949..1afffbb19a 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhaseTrayTowerFlowNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseReactorFlowNode/TwoPhaseTrayTowerFlowNode.java @@ -5,6 +5,7 @@ import neqsim.fluidMechanics.flowNode.twoPhaseNode.TwoPhaseFlowNode; import neqsim.fluidMechanics.geometryDefinitions.GeometryDefinitionInterface; import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -129,15 +130,16 @@ public FlowNodeInterface getNextNode() { public static void main(String[] args) { /* * System.out.println("Starter....."); SystemSrkEos testSystem = new SystemSrkEos(275.3, - * 1.01325); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); PipeData - * pipe1 = new PipeData(10.0, 0.025); - * + * ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new + * ThermodynamicOperations(testSystem); PipeData pipe1 = new PipeData(10.0, 0.025); + * * testSystem.addComponent("methane", 0.011152181, 0); testSystem.addComponent("ethane", * 0.00011152181, 0); testSystem.addComponent("water", 0.00462204876, 1); * testSystem.addComponent("methane", 0.061152181, 0); testSystem.addComponent("water", * 0.00862204876, 1); */ - SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); + SystemInterface testSystem = + new SystemFurstElectrolyteEos(275.3, ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); PipeData pipe1 = new PipeData(10.0, 0.025); diff --git a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseStirredCellNode/StirredCellNode.java b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseStirredCellNode/StirredCellNode.java index 69c298729e..c28f2ea4f4 100644 --- a/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseStirredCellNode/StirredCellNode.java +++ b/src/main/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhaseStirredCellNode/StirredCellNode.java @@ -226,7 +226,8 @@ public void setDt(double dt) { */ @SuppressWarnings("unused") public static void main(String[] args) { - // SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, 1.01325); + // SystemInterface testSystem = new SystemFurstElectrolyteEos(275.3, + // ThermodynamicConstantsInterface.referencePressure); // SystemInterface testSystem = new SystemSrkEos(313.3, 70.01325); SystemInterface testSystem = new SystemSrkCPAstatoil(313.3, 70.01325); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); diff --git a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java index d01c51afd4..aeb927ae4f 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java +++ b/src/main/java/neqsim/fluidMechanics/flowSolver/twoPhaseFlowSolver/twoPhasePipeFlowSolver/TwoPhaseFixedStaggeredGridSolver.java @@ -155,7 +155,7 @@ public void initProfiles() { /* * do{ err=0; pipe.getNode(0).init(); for(int i = 0;i* getSolver. @@ -159,7 +147,7 @@ public default void solveTransient(int type) { * setLegHeights. *
* - * @param legHeights an array of {@link double} objects + * @param legHeights an array of type double */ public void setLegHeights(double[] legHeights); @@ -168,7 +156,7 @@ public default void solveTransient(int type) { * getLegHeights. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getLegHeights(); @@ -177,7 +165,7 @@ public default void solveTransient(int type) { * setLegPositions. * * - * @param legPositions an array of {@link double} objects + * @param legPositions an array of type double */ public void setLegPositions(double[] legPositions); @@ -212,7 +200,7 @@ public default void solveTransient(int type) { * setLegOuterHeatTransferCoefficients. * * - * @param coefs an array of {@link double} objects + * @param coefs an array of type double */ public void setLegOuterHeatTransferCoefficients(double[] coefs); @@ -221,7 +209,7 @@ public default void solveTransient(int type) { * setLegWallHeatTransferCoefficients. * * - * @param coefs an array of {@link double} objects + * @param coefs an array of type double */ public void setLegWallHeatTransferCoefficients(double[] coefs); @@ -313,7 +301,7 @@ public default void solveSteadyState(int type) { * setLegOuterTemperatures. * * - * @param temps an array of {@link double} objects + * @param temps an array of type double */ public void setLegOuterTemperatures(double[] temps); diff --git a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java index 53ce4b5d3c..649c8ef8c8 100644 --- a/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java +++ b/src/main/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGship.java @@ -8,6 +8,7 @@ import neqsim.standards.gasQuality.Standard_ISO6578; import neqsim.standards.gasQuality.Standard_ISO6976; import neqsim.standards.gasQuality.Standard_ISO6976_2016; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -407,7 +408,8 @@ public static void main(String[] args) { // thermo.system.SystemInterface testSystem = new // thermo.system.SystemGERG2004Eos(273.15 - 161.4, 1.0); neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4, 1.013); + new neqsim.thermo.system.SystemSrkEos(273.15 - 161.4, + ThermodynamicConstantsInterface.referencePressure); /* * testSystem.addComponent("nitrogen", 0.0136); testSystem.addComponent("methane", 0.9186); * testSystem.addComponent("ethane", 0.0526); testSystem.addComponent("propane", 0.0115); diff --git a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java index add78f9454..68328dbe08 100644 --- a/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java +++ b/src/main/java/neqsim/fluidMechanics/geometryDefinitions/internalGeometry/packings/Packing.java @@ -37,14 +37,14 @@ public Packing(String name) { super(name); try (neqsim.util.database.NeqSimProcessDesignDataBase database = new neqsim.util.database.NeqSimProcessDesignDataBase()) { - System.out.println("init packing"); + // System.out.println("init packing"); java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM packing WHERE name='" + name + "'")); dataSet.next(); size = 1e-3 * Double.parseDouble(dataSet.getString("size")); // C surfaceAreaPrVolume = Double.parseDouble(dataSet.getString("surfaceAreaPrVolume")); voidFractionPacking = Double.parseDouble(dataSet.getString("voidFraction")); - System.out.println("packing ok"); + // System.out.println("packing ok"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -61,7 +61,8 @@ public Packing(String name) { */ public Packing(String name, String material, int size) { super(name); - try (neqsim.util.database.NeqSimProcessDesignDataBase database = new neqsim.util.database.NeqSimProcessDesignDataBase()) { + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { System.out.println("init packing"); java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM packing WHERE name='" + name + "' AND size=" + size + " AND material='" + material + "'")); diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java deleted file mode 100644 index 3151769c9c..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterBaseClass.java +++ /dev/null @@ -1,20 +0,0 @@ -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling; - -/** - *- * FileWriterBaseClass class. - *
- * - * @author esol - * @version $Id: $Id - */ -public class FileWriterBaseClass implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - /** - *- * Constructor for FileWriterBaseClass. - *
- */ - public FileWriterBaseClass() {} -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java deleted file mode 100644 index 754c7be7a2..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/FileWriterInterface.java +++ /dev/null @@ -1,12 +0,0 @@ -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling; - -/** - *- * FileWriterInterface interface. - *
- * - * @author esol - * @version $Id: $Id - */ -public interface FileWriterInterface { -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java deleted file mode 100644 index 8774324987..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/OnePhaseFileWriter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * OnePhaseFileWriter.java - * - * Created on 27. oktober 2000, 22:27 - */ - -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter; - -import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterBaseClass; - -/** - *- * OnePhaseFileWriter class. - *
- * - * @author esol - * @version $Id: $Id - */ -public class OnePhaseFileWriter extends FileWriterBaseClass { - private static final long serialVersionUID = 1000; - - /** - *- * Constructor for OnePhaseFileWriter. - *
- */ - public OnePhaseFileWriter() {} -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java deleted file mode 100644 index 8ec0b7b82d..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/onePhaseFileWriter/pipeFlowFileWriter/PipeFlowFileWriter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * PipeFlowFileWriter.java - * - * Created on 27. oktober 2000, 22:29 - */ - -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.pipeFlowFileWriter; - -import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.onePhaseFileWriter.OnePhaseFileWriter; - -/** - *- * PipeFlowFileWriter class. - *
- * - * @author esol - * @version $Id: $Id - */ -public class PipeFlowFileWriter extends OnePhaseFileWriter { - private static final long serialVersionUID = 1000; - - /** - *- * Constructor for PipeFlowFileWriter. - *
- */ - public PipeFlowFileWriter() {} -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java deleted file mode 100644 index 9dbeacd2e3..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/TwoPhaseFileWriter.java +++ /dev/null @@ -1,22 +0,0 @@ -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter; - -import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterBaseClass; - -/** - *- * TwoPhaseFileWriter class. - *
- * - * @author esol - * @version $Id: $Id - */ -public class TwoPhaseFileWriter extends FileWriterBaseClass { - private static final long serialVersionUID = 1000; - - /** - *- * Constructor for TwoPhaseFileWriter. - *
- */ - public TwoPhaseFileWriter() {} -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java deleted file mode 100644 index 0f3341d53e..0000000000 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsDataHandeling/twoPhaseFileWriter/twoPhasePipeFlowFileWriter/TwoPhasePipeFlowFileWriter.java +++ /dev/null @@ -1,22 +0,0 @@ -package neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter.twoPhasePipeFlowFileWriter; - -import neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.twoPhaseFileWriter.TwoPhaseFileWriter; - -/** - *- * TwoPhasePipeFlowFileWriter class. - *
- * - * @author esol - * @version $Id: $Id - */ -public class TwoPhasePipeFlowFileWriter extends TwoPhaseFileWriter { - private static final long serialVersionUID = 1000; - - /** - *- * Constructor for TwoPhasePipeFlowFileWriter. - *
- */ - public TwoPhasePipeFlowFileWriter() {} -} diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/twoPhaseFlowNodeVisualization/TwoPhaseFlowNodeVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/twoPhaseFlowNodeVisualization/TwoPhaseFlowNodeVisualization.java index 57d1b8a80d..127c4ebe7c 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/twoPhaseFlowNodeVisualization/TwoPhaseFlowNodeVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowNodeVisualization/twoPhaseFlowNodeVisualization/TwoPhaseFlowNodeVisualization.java @@ -12,54 +12,51 @@ * @version $Id: $Id */ public class TwoPhaseFlowNodeVisualization extends FlowNodeVisualization { - /** - *- * Constructor for TwoPhaseFlowNodeVisualization. - *
- */ - public TwoPhaseFlowNodeVisualization() {} + /** + *+ * Constructor for TwoPhaseFlowNodeVisualization. + *
+ */ + public TwoPhaseFlowNodeVisualization() {} - /** {@inheritDoc} */ - @Override - public void setData(FlowNodeInterface node) { - super.setData(node); - bulkComposition = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - effectiveMassTransferCoefficient = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - effectiveSchmidtNumber = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - interfaceComposition = - new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - molarFlux = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + /** {@inheritDoc} */ + @Override + public void setData(FlowNodeInterface node) { + super.setData(node); + bulkComposition = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + effectiveMassTransferCoefficient = + new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + effectiveSchmidtNumber = + new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + interfaceComposition = + new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; + molarFlux = new double[2][node.getBulkSystem().getPhases()[0].getNumberOfComponents()]; - for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { - bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponents()[i].getx(); - bulkComposition[1][i] = node.getBulkSystem().getPhases()[1].getComponents()[i].getx(); - effectiveMassTransferCoefficient[1][i] = - node.getFluidBoundary().getEffectiveMassTransferCoefficient(1, i); - effectiveMassTransferCoefficient[0][i] = - node.getFluidBoundary().getEffectiveMassTransferCoefficient(0, i); - effectiveSchmidtNumber[0][i] = node.getEffectiveSchmidtNumber(0, i); - effectiveSchmidtNumber[1][i] = node.getEffectiveSchmidtNumber(1, i); - // System.out.println("sc " + effectiveSchmidtNumber[1][i]); - interfaceComposition[0][i] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getComponents()[i] - .getx(); - interfaceComposition[1][i] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponents()[i] - .getx(); - molarFlux[0][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); - molarFlux[1][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); - } - - reynoldsNumber[0] = node.getReynoldsNumber(0); - reynoldsNumber[1] = node.getReynoldsNumber(1); - phaseFraction[0] = node.getPhaseFraction(0); - phaseFraction[1] = node.getPhaseFraction(1); - interfaceTemperature[0] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getTemperature(); - interfaceTemperature[1] = - node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getTemperature(); + for (int i = 0; i < node.getBulkSystem().getPhases()[0].getNumberOfComponents(); i++) { + bulkComposition[0][i] = node.getBulkSystem().getPhases()[0].getComponents()[i].getx(); + bulkComposition[1][i] = node.getBulkSystem().getPhases()[1].getComponents()[i].getx(); + effectiveMassTransferCoefficient[1][i] = + node.getFluidBoundary().getEffectiveMassTransferCoefficient(1, i); + effectiveMassTransferCoefficient[0][i] = + node.getFluidBoundary().getEffectiveMassTransferCoefficient(0, i); + effectiveSchmidtNumber[0][i] = node.getEffectiveSchmidtNumber(0, i); + effectiveSchmidtNumber[1][i] = node.getEffectiveSchmidtNumber(1, i); + // System.out.println("sc " + effectiveSchmidtNumber[1][i]); + interfaceComposition[0][i] = + node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getComponents()[i].getx(); + interfaceComposition[1][i] = + node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getComponents()[i].getx(); + molarFlux[0][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); + molarFlux[1][i] = node.getFluidBoundary().getInterphaseMolarFlux(i); } + + reynoldsNumber[0] = node.getReynoldsNumber(0); + reynoldsNumber[1] = node.getReynoldsNumber(1); + phaseFraction[0] = node.getPhaseFraction(0); + phaseFraction[1] = node.getPhaseFraction(1); + interfaceTemperature[0] = + node.getFluidBoundary().getInterphaseSystem().getPhases()[0].getTemperature(); + interfaceTemperature[1] = + node.getFluidBoundary().getInterphaseSystem().getPhases()[1].getTemperature(); + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java index 95d529b211..40cb106778 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/onePhaseFlowVisualization/pipeFlowVisualization/PipeFlowVisualization.java @@ -103,7 +103,7 @@ public void calcPoints(String name) { } /* * try { System.out.println("points: " + points.length); - * + * * if (pressurePoint.length > 1) { System.out.println("3D plot "); plot = new * neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", "title[2]"); * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, @@ -138,7 +138,7 @@ public void displayResult(String name) { } /* * try { System.out.println("points: " + points.length); - * + * * if (pressurePoint.length > 1) { System.out.println("3D plot "); plot = new * neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot("title[0]", "title[1]", "title[2]"); * ((neqsim.dataPresentation.visAD.visAd3D.visAd3DPlot) plot).setXYvals(150, 160, diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/TwoPhaseFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/TwoPhaseFlowVisualization.java index df0a87e5eb..123244bbb3 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/TwoPhaseFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/TwoPhaseFlowVisualization.java @@ -9,23 +9,23 @@ * @version $Id: $Id */ public class TwoPhaseFlowVisualization extends - neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualization { - /** - *- * Constructor for TwoPhaseFlowVisualization. - *
- */ - public TwoPhaseFlowVisualization() {} + neqsim.fluidMechanics.util.fluidMechanicsVisualization.flowSystemVisualization.FlowSystemVisualization { + /** + *+ * Constructor for TwoPhaseFlowVisualization. + *
+ */ + public TwoPhaseFlowVisualization() {} - /** - *- * Constructor for TwoPhaseFlowVisualization. - *
- * - * @param nodes a int - * @param timeSteps a int - */ - public TwoPhaseFlowVisualization(int nodes, int timeSteps) { - super(nodes, timeSteps); - } + /** + *+ * Constructor for TwoPhaseFlowVisualization. + *
+ * + * @param nodes a int + * @param timeSteps a int + */ + public TwoPhaseFlowVisualization(int nodes, int timeSteps) { + super(nodes, timeSteps); + } } diff --git a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java index e40849597e..b902f8adb5 100644 --- a/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java +++ b/src/main/java/neqsim/fluidMechanics/util/fluidMechanicsVisualization/flowSystemVisualization/twoPhaseFlowVisualization/twoPhasePipeFlowVisualization/TwoPhasePipeFlowVisualization.java @@ -175,7 +175,7 @@ public void displayResult(String name) { * file.setYvalues(interfaceTemperaturePoint[0][0], "gas interface temperature", "sec"); * file.setYvalues(interfaceTemperaturePoint[1][0], "liquid interface temperature", "sec"); * file.setYvalues(interphaseContactLength[0][0], "interphase contact length", "sec"); - * + * * for (int p = 0; p < flowNodes[0][0].getNumberOfComponents(); p++) { String comp = * "component molefraction " + p; file.setYvalues(bulkComposition[0][p][0], ("gas " + comp + p), * "sec"); file.setYvalues(bulkComposition[1][p][0], ("liquid " + comp + p), "sec"); diff --git a/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java b/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java index 4d3b9dc8bb..725bc48986 100644 --- a/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java +++ b/src/main/java/neqsim/fluidMechanics/util/timeSeries/TimeSeries.java @@ -40,7 +40,7 @@ public TimeSeries() { * Setter for the fieldtimes
.
*
*
- * @param times an array of {@link double} objects
+ * @param times an array of type double
*/
public void setTimes(double[] times) {
this.timeSeries = times;
@@ -62,7 +62,7 @@ public void setInletThermoSystems(SystemInterface[] inletThermoSystem) {
* Setter for the field outletMolarFlowRate
.
*
*
- * @param outletMolarFlowRate an array of {@link double} objects
+ * @param outletMolarFlowRate an array of type double
*/
public void setOutletMolarFlowRate(double[] outletMolarFlowRate) {
this.outletMolarFlowRate = outletMolarFlowRate;
@@ -73,7 +73,7 @@ public void setOutletMolarFlowRate(double[] outletMolarFlowRate) {
* Getter for the field outletMolarFlowRates
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getOutletMolarFlowRates() {
return this.outletMolarFlowRates;
@@ -136,7 +136,7 @@ public SystemInterface[] getThermoSystem() {
* getTimeStep.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getTimeStep() {
return timeSteps;
@@ -147,7 +147,7 @@ public double[] getTimeStep() {
* getTime.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getTime() {
return times;
diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/AdsorptionInterface.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/AdsorptionInterface.java
index 1af1b9638a..ba9d15bdfa 100644
--- a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/AdsorptionInterface.java
+++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/AdsorptionInterface.java
@@ -18,19 +18,6 @@ public interface AdsorptionInterface extends neqsim.thermo.ThermodynamicConstant
*/
public void calcAdsorption(int phase);
- /**
- * - * calcAdsorption. - *
- * - * @param phase a int - * @deprecated Replaced by {@link calcAdsorption} - */ - @Deprecated - public default void calcAdorption(int phase) { - calcAdsorption(phase); - } - /** ** getSurfaceExcess. @@ -41,20 +28,6 @@ public default void calcAdorption(int phase) { */ public double getSurfaceExcess(int component); - /** - *
- * getSurfaceExess. - *
- * - * @param component a int - * @return a double - * @deprecated Replaced by {@link getSurfaceExcess} - */ - @Deprecated - public default double getSurfaceExess(int component) { - return getSurfaceExcess(component); - } - /** ** setSolidMaterial. diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java index 05f8f7561d..5497040db1 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/solidAdsorption/PotentialTheoryAdsorption.java @@ -142,8 +142,7 @@ public void calcAdsorption(int phase) { /** {@inheritDoc} */ @Override public double getSurfaceExcess(int component) { - // TODO: remove not in use - return 1.0; + throw new UnsupportedOperationException("Unimplemented method 'getSurfaceExcess'"); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/FirozabadiRamleyInterfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/FirozabadiRamleyInterfaceTension.java index 7b7efa198c..e3d90b8883 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/FirozabadiRamleyInterfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/FirozabadiRamleyInterfaceTension.java @@ -68,7 +68,7 @@ public double calcSurfaceTension(int interface1, int interface2) { - system.getPhase(interface1).getPhysicalProperties().getDensity()); double Tr = system.getPhase(interface1).getTemperature() / system.getPhase(interface1).getPseudoCriticalTemperature(); - // System.out.println("deltaDens " + deltaDens + " Tr " + Tr + " phasetype " + + // System.out.println("deltaDens " + deltaDens + " Tr " + Tr + " pt " + // system.getPhase(interface1).getType()); double a1 = 0.0; double b1 = 0.0; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java index 13d862cece..708be1322a 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTension.java @@ -15,7 +15,6 @@ * method assumes the number of components to be two or more, and that the species set is equal and * in the same component order for both phases. * - * * Near a fluid-fluid interface, we consider the variation of densities of chemical species, * \f$\boldsymbol{n}(z)\f$, as function of position, \f$z\f$, where element \f$k\f$ of the vector * \f$\boldsymbol{n}(z)\f$ is the number density of chemical species \f$k\f$ in the mixture. The @@ -185,7 +184,6 @@ public static double solveWithRefcomp(SystemInterface system, int interface1, in * Tolerances for the odesystem.abstol and .reltol should be less than the integrator tolerances * for stability. Default Newton-Rhapson values are odesystem.normtol = 1e-10; odesystem.reltol * = 1e-8; - * */ odesystem.normtol = 1e-10; odesystem.reltol = 1e-8; @@ -216,7 +214,6 @@ public static double solveWithRefcomp(SystemInterface system, int interface1, in * results. The boundary conditions are the homogeneous densities of the two fluids in contact, as * calculated by a flash calculation. * - * * We approximate the solution on a equi-spaced grid with \f$2^N+1\f$ points where \f$N\f$ is an * integer. Using a Finite Difference approximation, the equation for \f$\delta\mu\f$ can then be * written as an equation system for the internal grid points, \f$i=2,3,...,2^N\f$: diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionFullGT.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionFullGT.java index 3e46e3e5c3..36563801b9 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionFullGT.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionFullGT.java @@ -265,17 +265,17 @@ public double runcase() { * large 4. Iterate until convergence or max #iterations (N_Newton) *
* - * @param cij an array of {@link double} objects + * @param cij an array of type double * @param L a double * @param N_Newton a int * @param allowedRelChange a double * @param highOrder a boolean * @param directMethod a boolean - * @param rhomat an array of {@link double} objects + * @param rhomat an array of type double * @param sys a {@link neqsim.thermo.system.SystemInterface} object * @param ncomp a int * @param t a double - * @param mueq an array of {@link double} objects + * @param mueq an array of type double * @return sigma The surface tension [N/m] */ public static double Newton(double[][] cij, double L, int N_Newton, double allowedRelChange, @@ -428,12 +428,12 @@ public static double Newton(double[][] cij, double L, int N_Newton, double allow * directsolve. Solve linear system for Full Gradient method * * - * @param rres an array of {@link double} objects - * @param JJ an array of {@link double} objects - * @param C an array of {@link double} objects + * @param rres an array of type double + * @param JJ an array of type double + * @param C an array of type double * @param H a double * @param Ngrid a int - * @param rhomat an array of {@link double} objects + * @param rhomat an array of type double * @param ncomp a int */ public static void directsolve(double[][] rres, double[][][] JJ, double[][] C, double H, @@ -524,10 +524,10 @@ public static void directsolve(double[][] rres, double[][][] JJ, double[][] C, d * * * @param h a double - * @param rrho an array of {@link double} objects - * @param C an array of {@link double} objects + * @param rrho an array of type double + * @param C an array of type double * @param highOrder a boolean - * @param drhodz an array of {@link double} objects + * @param drhodz an array of type double * @param ncomp a int * @return sigma The surface tension [N/m] */ @@ -570,9 +570,9 @@ public static double sigmaCalc(double h, double[][] rrho, double[][] C, boolean * integrand. Used to adjust the domain size * * - * @param z an array of {@link double} objects - * @param C an array of {@link double} objects - * @param drhodz an array of {@link double} objects + * @param z an array of type double + * @param C an array of type double + * @param drhodz an array of type double * @return Interface width (length scale) [nm] */ public double calc_std_integral(double[] z, double[][] C, double[][] drhodz) { @@ -612,10 +612,10 @@ public double calc_std_integral(double[] z, double[][] C, double[][] drhodz) { * @param sys a {@link neqsim.thermo.system.SystemInterface} object * @param ncomp a int * @param t a double - * @param mueq an array of {@link double} objects - * @param rho an array of {@link double} objects - * @param delta_mu an array of {@link double} objects - * @param dmu_drho an array of {@link double} objects + * @param mueq an array of type double + * @param rho an array of type double + * @param delta_mu an array of type double + * @param dmu_drho an array of type double */ public static void delta_mu(SystemInterface sys, int ncomp, double t, double[] mueq, double[] rho, double[] delta_mu, double[][] dmu_drho) { @@ -638,7 +638,7 @@ public static void delta_mu(SystemInterface sys, int ncomp, double t, double[] m * @param a start of range * @param b end of range * @param N number of values. - * @return an array of {@link double} objects + * @return an array of type double */ public static double[] linspace(double a, double b, int N) { double[] x = new double[N]; @@ -687,10 +687,10 @@ public static void debugPlot(double[] x, double[][] y) { * @param sys a {@link neqsim.thermo.system.SystemInterface} object * @param ncomp a int * @param t a double - * @param rho_ph1 an array of {@link double} objects - * @param rho_ph2 an array of {@link double} objects - * @param mueq an array of {@link double} objects - * @param p0 an array of {@link double} objects + * @param rho_ph1 an array of type double + * @param rho_ph2 an array of type double + * @param mueq an array of type double + * @param p0 an array of type double * @param reltol a double */ public static void initmu(SystemInterface sys, int ncomp, double t, double[] rho_ph1, @@ -709,7 +709,7 @@ public static void initmu(SystemInterface sys, int ncomp, double t, double[] rho maxerr = Math.max(maxerr, Math.abs(mueq[i] / mueq2[i] - 1.0)); } if (maxerr > reltol) { - logger.error("Flash is not properly solved. Maximum relative error in chemical potential: " + logger.warn("Flash is not properly solved. Maximum relative error in chemical potential: " + maxerr + " > " + reltol); throw new RuntimeException("Flash not solved!"); } diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionODE.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionODE.java index 89105f3180..faf49f6e29 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionODE.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionODE.java @@ -346,10 +346,10 @@ private void solveRho(double[] rho, double[] mu, double[][] dmu_drho, double[] p /** * Residual function for the algebraic equilibrium equations. * - * @param mu an array of {@link double} objects - * @param dmu_drho an array of {@link double} objects - * @param f an array of {@link double} objects - * @param jac an array of {@link double} objects + * @param mu an array of type double + * @param dmu_drho an array of type double + * @param f an array of type double + * @param jac an array of type double */ public void fjacfun(double[] mu, double[][] dmu_drho, double[] f, double[][] jac) { int i; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java index 2b25f3ffc3..dcf8adf553 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionSimple.java @@ -328,7 +328,7 @@ public double calcSurfaceTension(int interface1, int interface2) { * * * @param compnum a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMolarDensity(int compnum) { double[] temp = new double[ite_step]; @@ -343,7 +343,7 @@ public double[] getMolarDensity(int compnum) { * getMolarDensityTotal. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMolarDensityTotal() { double[] temp = new double[ite_step]; @@ -360,7 +360,7 @@ public double[] getMolarDensityTotal() { * getz. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getz() { return z_step; @@ -371,7 +371,7 @@ public double[] getz() { * getPressure. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getPressure() { return pressure_interface; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionUtils.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionUtils.java index 453526d21b..9bde4be2f5 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionUtils.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/GTSurfaceTensionUtils.java @@ -30,10 +30,10 @@ public class GTSurfaceTensionUtils { * @param sys a {@link neqsim.thermo.system.SystemInterface} object * @param ncomp a int * @param t a double - * @param rho an array of {@link double} objects - * @param mu an array of {@link double} objects - * @param dmu_drho an array of {@link double} objects - * @param p an array of {@link double} objects + * @param rho an array of type double + * @param mu an array of type double + * @param dmu_drho an array of type double + * @param p an array of type double */ public static void mufun(SystemInterface sys, int ncomp, double t, double[] rho, double[] mu, double[][] dmu_drho, double[] p) { diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java index 7933b98f54..f9f29ebeac 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/LGTSurfaceTension.java @@ -205,7 +205,7 @@ public double calcSurfaceTension(int interface1, int interface2) { * * * @param compnum a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMolarDensity(int compnum) { double[] temp = new double[ite_step]; @@ -220,7 +220,7 @@ public double[] getMolarDensity(int compnum) { * getMolarDensityTotal. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMolarDensityTotal() { double[] temp = new double[ite_step]; @@ -237,7 +237,7 @@ public double[] getMolarDensityTotal() { * getz. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getz() { return z_step; @@ -248,7 +248,7 @@ public double[] getz() { * getPressure. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getPressure() { return pressure_interface; diff --git a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java index 830f2bee36..f255d198cf 100644 --- a/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java +++ b/src/main/java/neqsim/physicalProperties/interfaceProperties/surfaceTension/SurfaceTension.java @@ -67,7 +67,7 @@ public double calcSurfaceTension(int interface1, int interface2) { */ public int getComponentWithHighestBoilingpoint() { int compNumb = 0; - double boilPoint = -273.15; + double boilPoint = 0; for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (system.getPhase(0).getComponent(i).getNormalBoilingPoint() > boilPoint) { compNumb = i; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java index d723aa3924..6f72f4806f 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/PhysicalPropertyMethod.java @@ -50,7 +50,7 @@ public void setPhase( /** {@inheritDoc} */ @Override public void tuneModel(double val, double temperature, double pressure) { - logger.error("model tuning not implemented!"); + throw new UnsupportedOperationException("Unimplemented method 'tuneModel'"); } // should contain phase objects ++ get diffusivity methods .. more ? } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java index 64eda4d617..17bc0f7997 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/conductivity/PFCTConductivityMethodMod86.java @@ -1,5 +1,6 @@ package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.conductivity; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -15,7 +16,8 @@ public class PFCTConductivityMethodMod86 extends Conductivity { private static final long serialVersionUID = 1000; /** ConstantreferenceSystem
. */
- public static SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325);
+ public static SystemInterface referenceSystem =
+ new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure);
double[] GVcoef = {-2.147621e5, 2.190461e5, -8.618097e4, 1.496099e4, -4.730660e2, -2.331178e2,
3.778439e1, -2.320481, 5.311764e-2};
double condRefA = -0.25276292;
@@ -167,7 +169,8 @@ public double calcConductivity() {
T0 = 273.15;
}
- double nstarRef = getRefComponentViscosity(T0, 1.01325);
+ double nstarRef =
+ getRefComponentViscosity(T0, ThermodynamicConstantsInterface.referencePressure);
double CpID = referenceSystem.getLowestGibbsEnergyPhase().getComponent(0).getCp0(T0);
double Ffunc = 1.0 + 0.053432 * redDens - 0.030182 * redDens * redDens
- 0.029725 * redDens * redDens * redDens;
@@ -261,7 +264,8 @@ public double getRefComponentViscosity(double temp, double pres) {
4.2903609488e-2, 1.4529023444e2, 6.1276818706e3};
// double viscRefK[] = {-9.74602, 18.0834, -4126.66, 44.6055, 0.9676544, 81.8134, 15649.9};
- double molDens = 101325.0 / 8.315 / phase.getPhase().getTemperature() / 1.0e3;
+ double molDens = ThermodynamicConstantsInterface.atm / ThermodynamicConstantsInterface.R
+ / phase.getPhase().getTemperature() / 1.0e3;
double critMolDens = 10.15;
double redMolDens = (molDens - critMolDens) / critMolDens;
double viscRefO = GVcoef[0] * Math.pow(temp, -1.0) + GVcoef[1] * Math.pow(temp, -2.0 / 3.0)
@@ -314,12 +318,13 @@ public double calcMixLPViscosity() {
* phase.getPhase().getComponent(i).getx() *
* Math.pow(phase.getPhase().getComponent(i).getMolarMass(), 2.0); Mmtemp +=
* phase.getPhase().getComponent(i).getx() * phase.getPhase().getComponent(i).getMolarMass(); }
- *
+ *
* PCmix = 8.0 * tempPC1 / (tempPC2 * tempPC2); TCmix = tempTC1 / tempTC2; Mmix = (Mmtemp +
* 1.304e-4 * (Math.pow(Mwtemp / Mmtemp, 2.303) - Math.pow(Mmtemp, 2.303))) * 1e3;
* //phase.getPhase().getMolarMass();
*/
- double redDens = 101325 / 8.315 / phase.getPhase().getTemperature() / 1.0e3 / 10.15;
+ double redDens = 101325 / ThermodynamicConstantsInterface.R / phase.getPhase().getTemperature()
+ / 1.0e3 / 10.15;
double alfa0 = 0.0;
double alfaMix = 0.0;
double[] alphai = new double[phase.getPhase().getNumberOfComponents()];
@@ -339,8 +344,8 @@ public double calcMixLPViscosity() {
double T0 = phase.getPhase().getTemperature()
* referenceSystem.getPhase(0).getComponent(0).getTC() / TCmix * alfaMix / alfa0;
- double P0 =
- 1.01325 * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfaMix / alfa0;
+ double P0 = ThermodynamicConstantsInterface.referencePressure
+ * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix * alfaMix / alfa0;
double refVisosity = getRefComponentViscosity(T0, P0);
double viscosity = refVisosity * Math.pow(TCmix / Tc0, -1.0 / 6.0)
diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/CorrespondingStatesDiffusivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/CorrespondingStatesDiffusivity.java
index 76289ca209..1dd87eaedc 100644
--- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/CorrespondingStatesDiffusivity.java
+++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/diffusivity/CorrespondingStatesDiffusivity.java
@@ -1,5 +1,7 @@
package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.diffusivity;
+import neqsim.thermo.phase.PhaseType;
+
/**
* * CorrespondingStatesDiffusivity class. @@ -39,7 +41,7 @@ public CorrespondingStatesDiffusivity( /** {@inheritDoc} */ @Override public double calcBinaryDiffusionCoefficient(int i, int j, int method) { - if (phase.getPhase().getType().getValue() == 0) { + if (phase.getPhase().getType() == PhaseType.LIQUID) { binaryDiffusionCoefficients[i][j] = 1.0e-4 * 9.89e-8 * Math.pow(phase.getViscosity() * 1e3, -0.907) * Math.pow(1.0 / phase.getPhase().getComponents()[i].getNormalLiquidDensity() diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java index 015475e32f..021f95211b 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethod.java @@ -6,6 +6,7 @@ package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -20,8 +21,10 @@ public class PFCTViscosityMethod extends Viscosity { private static final long serialVersionUID = 1000; + // todo: is this parameter required? int phaseTypeNumb = 1; - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + SystemInterface referenceSystem = + new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure); double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, -9.627993e1, 4.274152, -8.141531e-2}; double visRefA = 1.696985927; @@ -63,7 +66,7 @@ public PFCTViscosityMethod( /** {@inheritDoc} */ @Override public double calcViscosity() { - int phaseTypeNumb = 0; + // int phaseTypeNumb = 0; // if(phase.getPhase().getPhaseType()==0) phaseTypeNumb=1; double Pc0 = referenceSystem.getPhase(0).getComponent(0).getPC(); @@ -114,6 +117,8 @@ public double calcViscosity() { referenceSystem.setPressure(phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); referenceSystem.init(1); + + // todo: mixing phasetype and phase index? double molDens = 1.0 / referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; double critMolDens = 10.15; // 1.0/referenceSystem.getPhase(0).getComponent(0).getCriticalVolume(); double redDens = molDens / critMolDens; diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java index 68fd00152a..3dd5860b87 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodHeavyOil.java @@ -1,5 +1,6 @@ package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -14,8 +15,12 @@ public class PFCTViscosityMethodHeavyOil extends Viscosity { private static final long serialVersionUID = 1000; - // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + // SystemInterface referenceSystem = new SystemBWRSEos(273.15, + // ThermodynamicConstantsInterface.referencePressure); + SystemInterface referenceSystem = + new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure); + + // todo: is this parameter required? int phaseTypeNumb = 1; double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, -9.627993e1, 4.274152, -8.141531e-2}; @@ -115,6 +120,8 @@ public double calcViscosity() { referenceSystem.setPressure(phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); referenceSystem.init(1); + + // todo: mixing phasetype and phase index? // double molDens = 1.0 / // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; @@ -184,6 +191,8 @@ public double getRefComponentViscosity(double temp, double pres) { // System.out.println("ref pres " + pres); referenceSystem.init(1); // referenceSystem.display(); + + // todo: mixing phasetype and phase index? // double molDens = 1.0 / // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java index fbee45c371..aac367862d 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/PFCTViscosityMethodMod86.java @@ -1,5 +1,6 @@ package neqsim.physicalProperties.physicalPropertyMethods.commonPhasePhysicalProperties.viscosity; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -14,8 +15,12 @@ public class PFCTViscosityMethodMod86 extends Viscosity { private static final long serialVersionUID = 1000; - // SystemInterface referenceSystem = new SystemBWRSEos(273.15, 1.01325); - SystemInterface referenceSystem = new SystemSrkEos(273.0, 1.01325); + // SystemInterface referenceSystem = new SystemBWRSEos(273.15, + // ThermodynamicConstantsInterface.referencePressure); + SystemInterface referenceSystem = + new SystemSrkEos(273.0, ThermodynamicConstantsInterface.referencePressure); + + // todo: is this parameter required? int phaseTypeNumb = 1; double[] GVcoef = {-2.090975e5, 2.647269e5, -1.472818e5, 4.716740e4, -9.491872e3, 1.219979e3, -9.627993e1, 4.274152, -8.141531e-2}; @@ -113,6 +118,7 @@ public double calcViscosity() { referenceSystem.setPressure(phase.getPhase().getPressure() * referenceSystem.getPhase(0).getComponent(0).getPC() / PCmix); referenceSystem.init(1); + // todo: mixing phasetype and phase index? // double molDens = 1.0 / // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; @@ -154,6 +160,7 @@ public double getRefComponentViscosity(double temp, double pres) { // System.out.println("ref pres " + pres); referenceSystem.init(1); // referenceSystem.display(); + // todo: mixing phasetype and phase index? // double molDens = 1.0 / // referenceSystem.getPhase(phaseTypeNumb).getMolarVolume() * 100.0; double molDens = 1.0 / referenceSystem.getLowestGibbsEnergyPhase().getMolarVolume() * 100.0; // mol/dm^3 diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java index 812309a89d..a796889319 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/Viscosity.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; /** + * Abstract class for Viscosity property. * * @author Even Solbraa */ diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java index 7113d83191..b6cc542e62 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/conductivity/Conductivity.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.Logger; /** + * Abstract class Conductivity. * * @author Even Solbraa */ diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java index ccf64bf7b3..a8344de742 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/density/Density.java @@ -61,20 +61,21 @@ public Density clone() { /** * {@inheritDoc} * - *
* Returns the density of the phase. Unit: kg/m^3 - *
*/ @Override public double calcDensity() { - double tempVar = 0; + double tempVar = 0.0; if (gasPhase.getPhase().useVolumeCorrection()) { for (int i = 0; i < gasPhase.getPhase().getNumberOfComponents(); i++) { tempVar += gasPhase.getPhase().getComponents()[i].getx() - * gasPhase.getPhase().getComponents()[i].getVolumeCorrection(); + * (gasPhase.getPhase().getComponents()[i].getVolumeCorrection() + + gasPhase.getPhase().getComponents()[i].getVolumeCorrectionT() + * (gasPhase.getPhase().getTemperature() - 288.15)); } } + // System.out.println("density correction tempvar " + tempVar); return 1.0 / (gasPhase.getPhase().getMolarVolume() - tempVar) - * gasPhase.getPhase().getMolarMass() * 1e5; + * gasPhase.getPhase().getMolarMass() * 1.0e5; } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/Viscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/Viscosity.java index f8bddcaa26..042da61106 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/Viscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/gasPhysicalProperties/viscosity/Viscosity.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; /** + * * Abstract class for Viscosity property. * * @author Even Solbraa */ diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java index 88d6ec48d4..bd538bd63a 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/liquidPhysicalProperties/viscosity/Viscosity.java @@ -61,7 +61,6 @@ public Viscosity clone() { public double calcViscosity() { double tempVar = 0; double tempVar2 = 0; - double viscosity = 0; this.calcPureComponentViscosity(); // method og Grunberg and Nissan [87] @@ -85,7 +84,7 @@ public double calcViscosity() { // liquidPhase.getPhase().getComponents()[i].getx()*liquidPhase.getPhase().getComponents()[j].getx()*liquidPhase.getMixingRule().getViscosityGij(i,j); } } - viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2 + double viscosity = Math.exp(tempVar + tempVar2) / 1.0e3; // N-sek/m2 return viscosity; } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/methodInterface/DiffusivityInterface.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/methodInterface/DiffusivityInterface.java index 971510ea3c..7e75bd2b38 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/methodInterface/DiffusivityInterface.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/methodInterface/DiffusivityInterface.java @@ -31,7 +31,7 @@ public interface DiffusivityInterface extends ThermodynamicConstantsInterface, * * @param binaryDiffusionCoefficientMethod a int * @param multicomponentDiffusionMethod a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] calcDiffusionCoefficients(int binaryDiffusionCoefficientMethod, int multicomponentDiffusionMethod); diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/diffusivity/Diffusivity.java b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/diffusivity/Diffusivity.java index 18b9cb1d04..c0d651ab66 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/diffusivity/Diffusivity.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertyMethods/solidPhysicalProperties/diffusivity/Diffusivity.java @@ -101,6 +101,6 @@ public double getFickBinaryDiffusionCoefficient(int i, int j) { /** {@inheritDoc} */ @Override public double calcBinaryDiffusionCoefficient(int i, int j, int method) { - throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Unimplemented method 'calcBinaryDiffusionCoefficient"); } } diff --git a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java index 3ff1399a68..068e104245 100644 --- a/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java +++ b/src/main/java/neqsim/physicalProperties/physicalPropertySystem/PhysicalProperties.java @@ -339,6 +339,7 @@ public double getKinematicViscosity() { } /** {@inheritDoc} */ + @Override public double getDiffusionCoefficient(int i, int j) { return diffusivityCalc.getMaxwellStefanBinaryDiffusionCoefficient(i, j); } diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/ChungFunction.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/ChungFunction.java index 8595e451b4..a13f208be3 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/ChungFunction.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/chungMethod/ChungFunction.java @@ -11,29 +11,29 @@ * @version $Id: $Id */ public class ChungFunction extends LevenbergMarquardtFunction { - /** - *- * Constructor for ChungFunction. - *
- */ - public ChungFunction() { - params = new double[1]; - } + /** + *+ * Constructor for ChungFunction. + *
+ */ + public ChungFunction() { + params = new double[1]; + } - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.setTemperature(dependentValues[0]); - system.init(1); - system.initPhysicalProperties(); - return system.getPhases()[1].getPhysicalProperties().getViscosity(); - } + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.setTemperature(dependentValues[0]); + system.init(1); + system.initPhysicalProperties(); + return system.getPhases()[1].getPhysicalProperties().getViscosity(); + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - system.getPhases()[0].getComponents()[i].setViscosityAssociationFactor(value); - system.getPhases()[1].getComponents()[i].setViscosityAssociationFactor(value); - } + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + system.getPhases()[0].getComponents()[i].setViscosityAssociationFactor(value); + system.getPhases()[1].getComponents()[i].setViscosityAssociationFactor(value); + } } diff --git a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java index 612b3bf1e8..1400d0d81a 100644 --- a/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java +++ b/src/main/java/neqsim/physicalProperties/util/parameterFitting/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java @@ -17,26 +17,26 @@ * @version $Id: $Id */ public class ViscosityFunction extends LevenbergMarquardtFunction { - /** - *- * Constructor for ViscosityFunction. - *
- */ - public ViscosityFunction() {} + /** + *+ * Constructor for ViscosityFunction. + *
+ */ + public ViscosityFunction() {} - /** {@inheritDoc} */ - @Override - public double calcValue(double[] dependentValues) { - system.init(1); - system.initPhysicalProperties(); - return system.getPhases()[1].getPhysicalProperties().getViscosity() * 1e3; - } + /** {@inheritDoc} */ + @Override + public double calcValue(double[] dependentValues) { + system.init(1); + system.initPhysicalProperties(); + return system.getPhases()[1].getPhysicalProperties().getViscosity() * 1e3; + } - /** {@inheritDoc} */ - @Override - public void setFittingParams(int i, double value) { - params[i] = value; - system.getPhases()[0].getComponents()[0].setLiquidViscosityParameter(value, i); - system.getPhases()[1].getComponents()[0].setLiquidViscosityParameter(value, i); - } + /** {@inheritDoc} */ + @Override + public void setFittingParams(int i, double value) { + params[i] = value; + system.getPhases()[0].getComponents()[0].setLiquidViscosityParameter(value, i); + system.getPhases()[1].getComponents()[0].setLiquidViscosityParameter(value, i); + } } diff --git a/src/main/java/neqsim/processSimulation/SimulationBaseClass.java b/src/main/java/neqsim/processSimulation/SimulationBaseClass.java index affaa89134..c572a6c0e1 100644 --- a/src/main/java/neqsim/processSimulation/SimulationBaseClass.java +++ b/src/main/java/neqsim/processSimulation/SimulationBaseClass.java @@ -2,6 +2,7 @@ import java.util.UUID; import neqsim.util.NamedBaseClass; +import neqsim.util.exception.InvalidInputException; /** * Base class for process simulation objects. @@ -18,9 +19,12 @@ public abstract class SimulationBaseClass extends NamedBaseClass implements Simu protected UUID calcIdentifier; protected boolean calculateSteadyState = true; protected double time = 0; + private boolean runInSteps = false; /** - *Constructor for SimulationBaseClass.
+ *+ * Constructor for SimulationBaseClass. + *
* * @param name a {@link java.lang.String} object */ @@ -29,11 +33,13 @@ public SimulationBaseClass(String name) { } /** {@inheritDoc} */ + @Override public UUID getCalculationIdentifier() { return calcIdentifier; } /** {@inheritDoc} */ + @Override public void setCalculationIdentifier(UUID value) { if (this.calcIdentifier == null || this.calcIdentifier != value) { this.calcIdentifier = value; @@ -55,21 +61,36 @@ public void setCalculateSteadyState(boolean steady) { } /** {@inheritDoc} */ + @Override public double getTime() { return this.time; } /** {@inheritDoc} */ + @Override public void setTime(double value) { this.time = value; } /** {@inheritDoc} */ + @Override public void increaseTime(double dt) { if (dt < 0) { - throw new UnsupportedOperationException( - "Input dt is negative - not allowed to go backwards in time."); + throw new RuntimeException(new InvalidInputException(this, "increaseTime", "dt", + "Negative values are not allowed. Not possible to go backwards in time.")); } this.time = this.time + dt; } + + /** {@inheritDoc} */ + @Override + public void setRunInSteps(boolean setRunSteps) { + runInSteps = setRunSteps; + } + + /** {@inheritDoc} */ + @Override + public boolean isRunInSteps() { + return runInSteps; + } } diff --git a/src/main/java/neqsim/processSimulation/SimulationInterface.java b/src/main/java/neqsim/processSimulation/SimulationInterface.java index 1ea7bb06eb..bc7a608b97 100644 --- a/src/main/java/neqsim/processSimulation/SimulationInterface.java +++ b/src/main/java/neqsim/processSimulation/SimulationInterface.java @@ -40,49 +40,87 @@ public interface SimulationInterface extends NamedInterface, Runnable, Serializa public void setCalculateSteadyState(boolean steady); /** - * Getter for property time. + * Getter for the fieldtime
.
*
* @return Value of property time.
*/
public double getTime();
/**
- * Setter for property time.
+ * Setter for field time
.
*
* @param value Value to set.
*/
public void setTime(double value);
/**
- * Method to increase parameter time by a given value.
+ * Method to increase field time
by a given value.
*
* @param dt Value to increase time by.
*/
public void increaseTime(double dt);
/**
- * {@inheritDoc}
+ * + * setRunInSteps. + *
* + * @param setRunSteps boolean set true to run in steps + */ + public void setRunInSteps(boolean setRunSteps); + + /** *- * In this method all thermodynamic and unit operations will be calculated in a steady state - * calculation. Sets calc identifier UUID. + * isRunInSteps. + *
+ * + * @return boolean + */ + public boolean isRunInSteps(); + + /** + *+ * run. + *
+ * + * @param id UUID + */ + public void run(UUID id); + + /** + *+ * run. *
*/ - @Override public default void run() { - run(UUID.randomUUID()); + if (isRunInSteps()) { + run_step(UUID.randomUUID()); + } else { + run(UUID.randomUUID()); + } + } + + /** + *+ * run_step + *
+ * In this method all thermodynamic and unit operations will be calculated in a steady state + * calculation. It does not solve recycles - only calculates one step. + */ + public default void run_step() { + run_step(UUID.randomUUID()); } /** *- * run + * run_step *
* In this method all thermodynamic and unit operations will be calculated in a steady state - * calculation. Sets calc identifier UUID. + * calculation. Sets calc identifier UUID. It does not solve recycles - only calculates one step * * @param value Calc identifier UUID to set. */ - public void run(UUID value); + public void run_step(UUID value); /** *@@ -122,10 +160,20 @@ public default void runTransient(double dt, UUID id) { /** *
- * solved. + * Returns whether or not the module has been solved. *
* * @return a boolean */ public boolean solved(); + + /** + *+ * getReport_json. + *
+ * Return results of simulation in json format + * + * @return a String + */ + public String getReport_json(); } diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java index 685eb70533..e05e29633a 100644 --- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java +++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClass.java @@ -7,6 +7,8 @@ package neqsim.processSimulation.controllerDevice; import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface; import neqsim.util.NamedBaseClass; @@ -20,6 +22,7 @@ */ public class ControllerDeviceBaseClass extends NamedBaseClass implements ControllerDeviceInterface { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ControllerDeviceBaseClass.class); /** * Unique identifier of which solve/run call was last called successfully. @@ -41,12 +44,38 @@ public class ControllerDeviceBaseClass extends NamedBaseClass implements Control // Internal state of integration contribution private double TintValue = 0.0; + boolean isActive = true; /** - *Constructor for ControllerDeviceBaseClass.
+ *+ * Constructor for ControllerDeviceBaseClass. + *
*/ public ControllerDeviceBaseClass() { - super("controller"); + this("controller"); + } + + /** {@inheritDoc} */ + @Override + public void setActive(boolean isActive) { + this.isActive = isActive; + } + + /** {@inheritDoc} */ + @Override + public boolean isActive() { + return isActive; + } + + /** + *+ * Constructor for ControllerDeviceBaseClass. + *
+ * + * @param name Name of PID controller object + */ + public ControllerDeviceBaseClass(String name) { + super(name); } /** {@inheritDoc} */ @@ -64,6 +93,11 @@ public double getMeasuredValue() { /** {@inheritDoc} */ @Override public void runTransient(double initResponse, double dt, UUID id) { + if (!isActive) { + response = initResponse; + calcIdentifier = id; + return; + } if (isReverseActing()) { propConstant = -1; } @@ -75,12 +109,13 @@ public void runTransient(double initResponse, double dt, UUID id) { transmitter.getMeasuredPercentValue() - (controllerSetPoint - transmitter.getMinimumValue()) / (transmitter.getMaximumValue() - transmitter.getMinimumValue()) * 100; - TintValue += Kp / Ti * error * dt; - double TderivValue = Kp * Td * (error - oldError) / dt; - response = initResponse + propConstant * (Kp * error + TintValue + TderivValue); - // System.out.println("error " + error + " %"); - // error = device.getMeasuredPercentValue()-controlValue; - // double regulatorSignal = error*1.0; + if (Ti != 0) { + TintValue = Kp / Ti * error; + } + double TderivValue = Kp * Td * ((error - 2 * oldError + oldoldError) / (dt * dt)); + + response = initResponse + + propConstant * ((Kp * (error - oldError) / dt) + TintValue + TderivValue) * dt; calcIdentifier = id; } @@ -139,7 +174,11 @@ public double getKp() { * @param Kp Proportional gain of PID controller */ public void setKp(double Kp) { - this.Kp = Kp; + if (Kp >= 0) { + this.Kp = Kp; + } else { + logger.warn("Negative Kp is not allowed. Use setReverseActing."); + } } /** {@inheritDoc} */ @@ -169,7 +208,11 @@ public double getTi() { * @param Ti Integral time in seconds */ public void setTi(double Ti) { - this.Ti = Ti; + if (Ti >= 0) { + this.Ti = Ti; + } else { + logger.warn("Negative Ti is not allowed."); + } } /** @@ -191,6 +234,10 @@ public double getTd() { * @param Td Derivative time in seconds */ public void setTd(double Td) { - this.Td = Td; + if (Td >= 0) { + this.Td = Td; + } else { + logger.warn("Negative Td is not allowed."); + } } } diff --git a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java index 4f2052ea56..9b7f9fd2b6 100644 --- a/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java +++ b/src/main/java/neqsim/processSimulation/controllerDevice/ControllerDeviceInterface.java @@ -128,4 +128,24 @@ public default void runTransient(double initResponse, double dt) { /** {@inheritDoc} */ @Override public int hashCode(); + + /** + *+ * setActive. + *
+ * Set if controller is active + * + * @param isActive Set true to make controller active. + */ + public void setActive(boolean isActive); + + /** + *+ * isActive. + *
+ * Specifies if controller is active + * + * @return a boolean + */ + public boolean isActive(); } diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/CombustionEmissionsCalculator.java b/src/main/java/neqsim/processSimulation/measurementDevice/CombustionEmissionsCalculator.java index 8566dd5131..c2882e9e43 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/CombustionEmissionsCalculator.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/CombustionEmissionsCalculator.java @@ -4,7 +4,15 @@ import java.util.Map; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +/** + *+ * CombustionEmissionsCalculator class. + *
+ * + * @author Even Solbraa + */ public class CombustionEmissionsCalculator extends StreamMeasurementDeviceBaseClass { + private static final long serialVersionUID = 1L; // Composition of natural gas (in mole percent) private static final Map+ * setComponents. + *
+ */ public void setComponents() { NATURAL_GAS_COMPOSITION.clear(); CO2_EMISSIONS_FACTORS.clear(); @@ -70,6 +83,15 @@ public double getMeasuredValue(String unit) { * stream.getFluid().getFlowRate(unit); } + /** + *+ * calculateCO2Emissions. + *
+ * + * @param composition a {@link java.util.Map} object + * @param emissionsFactors a {@link java.util.Map} object + * @return a double + */ public static double calculateCO2Emissions(Map+ * CompressorMonitor class. + *
+ * + * @author ESOL + * @version $Id: $Id + */ +public class CompressorMonitor extends MeasurementDeviceBaseClass { + private static final long serialVersionUID = 1000; + protected Compressor compressor = null; + + /** + *+ * Constructor for CompressorMonitor. + *
+ * + * @param compressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor} + * object + */ + public CompressorMonitor(Compressor compressor) { + this("Compressor Monitor", compressor); + } + + /** + *+ * Constructor for CompressorMonitor. + *
+ * + * @param name Name of Compressor + * @param compressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor} + */ + public CompressorMonitor(String name, Compressor compressor) { + super(name, "rpm"); + this.compressor = compressor; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + System.out.println("measured speed " + compressor.getSpeed()); + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue(String unit) { + if (unit.equals("distance to surge")) { + return compressor.getDistanceToSurge(); + } else { + return compressor.getDistanceToSurge(); + // return compressor.getSpeed(); + } + } +} diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/FlowInducedVibrationAnalyser.java b/src/main/java/neqsim/processSimulation/measurementDevice/FlowInducedVibrationAnalyser.java new file mode 100644 index 0000000000..346c3ff69e --- /dev/null +++ b/src/main/java/neqsim/processSimulation/measurementDevice/FlowInducedVibrationAnalyser.java @@ -0,0 +1,184 @@ +package neqsim.processSimulation.measurementDevice; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills; + +/** + *+ * FlowInducedVibrationAnalyser class. + *
+ * + * @author SEROS + * @version $Id: $Id + */ +public class FlowInducedVibrationAnalyser extends MeasurementDeviceBaseClass { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(WaterDewPointAnalyser.class); + + private double supportDistance = 3; + + private Boolean calcSupportArrangement = false; + + private String supportArrangement = "Stiff"; // Consult with a mechanical engineer regarding + // either the support distance or + // natural frequency of vibrations, especially if measurements have been taken + + private String method = "LOF"; // Likelihood of failure + private PipeBeggsAndBrills pipe; + private Boolean segmentSet = false; + private int segment; + private double FRMSConstant = 6.7; + + /** + *+ * Constructor for WaterDewPointAnalyser. + *
+ * + * @param pipe a {@link neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills} + * object + */ + public FlowInducedVibrationAnalyser(PipeBeggsAndBrills pipe) { + this("Pipeline Flow Induced Vibration Analyzer", pipe); + } + + /** + *+ * Constructor for FlowInducedVibrationAnalyser. + *
+ * + * @param name Name of FlowInducedVibrationAnalyser + * @param pipe a {@link neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills} + * object + */ + public FlowInducedVibrationAnalyser(String name, PipeBeggsAndBrills pipe) { + super(name, pipe.getName() + " FIV analyser"); + this.pipe = pipe; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() { + try { + } finally { + } + } + + /** {@inheritDoc} */ + @Override + public double getMeasuredValue(String unit) { + if (!segmentSet) { + segment = pipe.getNumberOfIncrements(); + } + double mixDensity = pipe.getSegmentMixtureDensity(segment); + double mixVelocity = pipe.getSegmentMixtureSuperficialVelocity(segment); + double gasVelocity = pipe.getSegmentGasSuperficialVelocity(segment); + double GVF = gasVelocity / mixVelocity; + if (method.equals("LOF")) { + double FVF = 1.0; + if (GVF > 0.88) { + if (GVF > 0.99) { + FVF = Math.sqrt(pipe.getSegmentMixtureViscosity(segment) / Math.sqrt(0.001)); + } else { + FVF = -27.882 * GVF * GVF + 45.545 * GVF - 17.495; + } + } + double externalDiamater = (pipe.getDiameter() + 2 * pipe.getThickness()) * 1000;// mm + double alpha = 0.0; + double betta = 0.0; + if (supportArrangement.equals("Stiff")) { + alpha = 446187 + 646 * externalDiamater + + 9.17E-4 * externalDiamater * externalDiamater * externalDiamater; + betta = 0.1 * Math.log(externalDiamater) - 1.3739; + } else if (supportArrangement.equals("Medium stiff")) { + alpha = 283921 + 370 * externalDiamater; + betta = 0.1106 * Math.log(externalDiamater) - 1.501; + } else if (supportArrangement.equals("Medium")) { + alpha = 150412 + 209 * externalDiamater; + betta = 0.0815 * Math.log(externalDiamater) - 1.3269; + } else { + alpha = 41.21 * Math.log(externalDiamater) + 49397; + betta = 0.0815 * Math.log(externalDiamater) - 1.3842; + } + double diameterOverThickness = externalDiamater / (1000 * pipe.getThickness()); + double Fv = alpha * Math.pow(diameterOverThickness, betta); + double LOF = mixDensity * mixVelocity * mixVelocity * FVF / Fv; + return LOF; + } else if (method.equals("FRMS")) { + if (GVF < 0.8) { + return GVF; + } else { + return 1 + 5 * (1 - GVF) * Math.pow(pipe.getDiameter(), 1.6) * FRMSConstant + * Math.pow(pipe.getSegmentLiquidDensity(segment), 0.6) * Math.pow(mixVelocity, 1.2); + } + } + return Double.NaN; + } + + /** + *
+ * Getter for the field method
.
+ *
+ * Setter for the field method
.
+ *
+ * Setter for the field segment
.
+ *
+ * setFRMSConstant. + *
+ * + * @param frms a double + */ + public void setFRMSConstant(double frms) { + this.FRMSConstant = frms; + } + + /** + *
+ * Setter for the support arrangement supportArrangement
.
+ *
+ * Setter for the support distance .
+ *
referencePressure
.
*
*
- * @return a double
+ * @return Reference pressure in bara
*/
public double getReferencePressure() {
return referencePressure;
@@ -93,7 +92,7 @@ public double getReferencePressure() {
* Setter for the field referencePressure
.
*
*
- * @param referencePressure a double
+ * @param referencePressure Reference pressure to set in in bara
*/
public void setReferencePressure(double referencePressure) {
this.referencePressure = referencePressure;
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/LevelTransmitter.java b/src/main/java/neqsim/processSimulation/measurementDevice/LevelTransmitter.java
index cd8e7c299e..c2ee757350 100644
--- a/src/main/java/neqsim/processSimulation/measurementDevice/LevelTransmitter.java
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/LevelTransmitter.java
@@ -47,9 +47,7 @@ public void displayResult() {
System.out.println("measured level " + separator.getLiquidLevel());
}
- /**
- * Get level as volume fraction.
- */
+ /** {@inheritDoc} */
@Override
public double getMeasuredValue(String unit) {
if (!unit.equalsIgnoreCase("")) {
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MeasurementDeviceInterface.java b/src/main/java/neqsim/processSimulation/measurementDevice/MeasurementDeviceInterface.java
index 2c70cd2ab2..4f0e11d220 100644
--- a/src/main/java/neqsim/processSimulation/measurementDevice/MeasurementDeviceInterface.java
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/MeasurementDeviceInterface.java
@@ -32,7 +32,7 @@ public default double getMeasuredValue() {
/**
* - * getMeasuredValue. + * Get Measured value in specified unit. *
* * @param unit a {@link java.lang.String} object diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java index 14e238ed1e..fa33ec465e 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeter.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -18,8 +19,8 @@ public class MultiPhaseMeter extends StreamMeasurementDeviceBaseClass { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(MultiPhaseMeter.class); - double pressure = 10.0; - double temperature = 298.15; + double pressure = 1.01325; + double temperature = 288.15; String unitT; String unitP; @@ -110,15 +111,15 @@ public double getMeasuredValue(String unit) { */ public double getMeasuredValue(String measurement, String unit) { if (measurement.equals("mass rate")) { - return stream.getThermoSystem().getFlowRate(unit); + return stream.getFlowRate(unit); } - if (stream.getThermoSystem().getFlowRate("kg/hr") < 1e-10) { + if (stream.getFlowRate("kg/hr") < 1e-10) { return Double.NaN; } if (measurement.equals("GOR")) { - SystemInterface tempFluid = stream.getThermoSystem().clone(); + SystemInterface tempFluid = stream.getFluid().clone(); tempFluid.setTemperature(temperature, unitT); tempFluid.setPressure(pressure, unitP); ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); @@ -139,6 +140,60 @@ public double getMeasuredValue(String measurement, String unit) { return tempFluid.getPhase("gas").getCorrectedVolume() / tempFluid.getPhase("oil").getCorrectedVolume(); } + if (measurement.equals("Gas Flow Rate")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(temperature, unitT); + tempFluid.setPressure(pressure, unitP); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return Double.NaN; + } + // tempFluid.display(); + if (!tempFluid.hasPhaseType("gas")) { + return Double.NaN; + } + tempFluid.initPhysicalProperties("density"); + return tempFluid.getPhase("gas").getFlowRate(unit); + } + if (measurement.equals("Oil Flow Rate")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(temperature, unitT); + tempFluid.setPressure(pressure, unitP); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return Double.NaN; + } + // tempFluid.display(); + if (!tempFluid.hasPhaseType("oil")) { + return Double.NaN; + } + tempFluid.initPhysicalProperties("density"); + return tempFluid.getPhase("oil").getFlowRate(unit); + } + if (measurement.equals("Water Flow Rate")) { + SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(temperature, unitT); + tempFluid.setPressure(pressure, unitP); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return Double.NaN; + } + // tempFluid.display(); + if (!tempFluid.hasPhaseType("aqueous")) { + return Double.NaN; + } + tempFluid.initPhysicalProperties("density"); + return tempFluid.getPhase("aqueous").getFlowRate(unit); + } if (measurement.equals("gasDensity") || measurement.equals("oilDensity") || measurement.equals("waterDensity")) { SystemInterface tempFluid = stream.getThermoSystem().clone(); @@ -176,8 +231,9 @@ public double getMeasuredValue(String measurement, String unit) { return 0.0; } else if (measurement.equals("GOR_std")) { SystemInterface tempFluid = stream.getThermoSystem().clone(); + tempFluid.setTemperature(15.0, "C"); - tempFluid.setPressure(1.01325, "bara"); + tempFluid.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); try { thermoOps.TPflash(); @@ -192,6 +248,21 @@ public double getMeasuredValue(String measurement, String unit) { return Double.NaN; } tempFluid.initPhysicalProperties("density"); + + double GOR_in_sm3_sm3 = tempFluid.getPhase("gas").getFlowRate("Sm3/hr") + / tempFluid.getPhase("oil").getFlowRate("m3/hr"); + double GOR_via_corrected_volume = tempFluid.getPhase("gas").getCorrectedVolume() + / tempFluid.getPhase("oil").getCorrectedVolume(); + + // System.out.println("Stream 2 (results inside MPM) " + " GOR sm3/sm3 " + GOR_in_sm3_sm3 + // + " GOR Corrected by volume " + GOR_via_corrected_volume); + + // System.out.println("Stream 2 (results inside MPM) getPhase(gas).getCorrectedVolume() " + // + tempFluid.getPhase("gas").getCorrectedVolume()); + // System.out.println("Stream 2 (results inside MPM) getPhase(oil).getCorrectedVolume() " + // + tempFluid.getPhase("oil").getCorrectedVolume()); + + // GOR_via_corrected_volume and GOR_in_sm3_sm3 should not be so different ? return tempFluid.getPhase("gas").getCorrectedVolume() / tempFluid.getPhase("oil").getCorrectedVolume(); } else { diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/StreamMeasurementDeviceBaseClass.java b/src/main/java/neqsim/processSimulation/measurementDevice/StreamMeasurementDeviceBaseClass.java index b31ceb0abb..ae74b3f5b9 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/StreamMeasurementDeviceBaseClass.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/StreamMeasurementDeviceBaseClass.java @@ -45,4 +45,3 @@ public void setStream(StreamInterface stream) { this.stream = stream; } } - diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/VolumeFlowTransmitter.java b/src/main/java/neqsim/processSimulation/measurementDevice/VolumeFlowTransmitter.java index aabd8a74b5..2a3f952456 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/VolumeFlowTransmitter.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/VolumeFlowTransmitter.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.measurementDevice; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *
@@ -58,13 +59,13 @@ public double getMeasuredValue(String unit) {
} else if (unit.equals("Nm^3/day")) {
return stream.getThermoSystem().getPhase(measuredPhaseNumber).getNumberOfMolesInPhase()
* neqsim.thermo.ThermodynamicConstantsInterface.R
- * neqsim.thermo.ThermodynamicConstantsInterface.normalStateTemperature / 101325.0 * 3600.0
- * 24;
+ * neqsim.thermo.ThermodynamicConstantsInterface.normalStateTemperature
+ / ThermodynamicConstantsInterface.atm * 3600.0 * 24;
} else if (unit.equals("Sm^3/day")) {
return stream.getThermoSystem().getPhase(measuredPhaseNumber).getNumberOfMolesInPhase()
* neqsim.thermo.ThermodynamicConstantsInterface.R
- * neqsim.thermo.ThermodynamicConstantsInterface.standardStateTemperature / 101325.0
- * 3600.0 * 24;
+ * neqsim.thermo.ThermodynamicConstantsInterface.standardStateTemperature
+ / ThermodynamicConstantsInterface.atm * 3600.0 * 24;
} else {
return stream.getThermoSystem().getPhase(measuredPhaseNumber).getNumberOfMolesInPhase()
* stream.getThermoSystem().getPhase(measuredPhaseNumber).getMolarMass() / stream
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/WaterDewPointAnalyser.java b/src/main/java/neqsim/processSimulation/measurementDevice/WaterDewPointAnalyser.java
index 688b3cfbb1..f18c4629fe 100644
--- a/src/main/java/neqsim/processSimulation/measurementDevice/WaterDewPointAnalyser.java
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/WaterDewPointAnalyser.java
@@ -31,7 +31,6 @@ public class WaterDewPointAnalyser extends StreamMeasurementDeviceBaseClass {
*/
public WaterDewPointAnalyser(StreamInterface stream) {
this("WaterDewPointAnalyser", stream);
-
}
/**
@@ -99,7 +98,7 @@ public double getMeasuredValue(String unit) {
* Getter for the field referencePressure
.
*
referencePressure
.
*
*
- * @param referencePressure a double
+ * @param referencePressure Reference pressure to set in in bara
*/
public void setReferencePressure(double referencePressure) {
this.referencePressure = referencePressure;
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java
index cb7723b685..ac2e7e2439 100644
--- a/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/WellAllocator.java
@@ -74,7 +74,6 @@ public double getMeasuredValue(String unit) {
* @param unit Unit to get value in
* @return Measured value
*/
-
public double getMeasuredValue(String measurement, String unit) {
int numberOfComps = stream.getThermoSystem().getNumberOfComponents();
double[] splitFactors = new double[numberOfComps];
diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/pHProbe.java b/src/main/java/neqsim/processSimulation/measurementDevice/pHProbe.java
index a8ef3a9ec2..3c80505a58 100644
--- a/src/main/java/neqsim/processSimulation/measurementDevice/pHProbe.java
+++ b/src/main/java/neqsim/processSimulation/measurementDevice/pHProbe.java
@@ -114,19 +114,6 @@ public double getAlkalinity() {
return alkalinity;
}
- /**
- *
- * Getter for the field alkalinity
.
- *
* Setter for the field alkalinity
.
@@ -137,17 +124,4 @@ public double getAlkanility() {
public void setAlkalinity(double alkalinity) {
this.alkalinity = alkalinity;
}
-
- /**
- *
- * Setter for the field alkalinity
.
- *
- * getMeasuredValue. - *
- * - * @return a double - */ + /** {@inheritDoc} */ @Override public double getMeasuredValue(String unit) { if (!unit.equalsIgnoreCase("m3/sec")) { @@ -753,7 +747,6 @@ public static void main(String[] args) { // inputStream.setFlowRate(0.00001, "MSm^3/day"); // System.out.println(inputStream.getFlowRate("kg/sec")); // mySevereSlug4.getPredictedFlowRegime(); - } // To be implemented diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java index fdb0dd535b..82e64570ae 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/MechanicalDesign.java @@ -119,6 +119,8 @@ public void setMaterialDesignStandard(MaterialPlateDesignStandard materialDesign public double moduleLength = 0.0; public Hashtable@@ -424,7 +426,7 @@ public void setPressureMarginFactor(double pressureMarginFactor) { * @return a double */ public double getOuterDiameter() { - return 1.0; // processEquipment.getInternalDiameter(); + return outerDiameter; } /** @@ -1023,11 +1025,11 @@ public void displayResults() { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"", "Volume", "Weight"}; String[][] table = new String[3][3]; // createTable(getProcessEquipment().getName()); table[1][0] = getProcessEquipment().getName(); table[1][1] = Double.toString(getWeightTotal()); table[1][2] = Double.toString(getVolumeTotal()); + String[] names = {"", "Volume", "Weight"}; JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); dialogContentPane.add(scrollpane); @@ -1081,6 +1083,50 @@ public UnitCostEstimateBaseClass getCostEstimate() { return costEstimate; } + /** + *
+ * Setter for the field defaultLiquidDensity
.
+ *
+ * Getter for the field defaultLiquidDensity
.
+ *
+ * Setter for the field defaultLiquidViscosity
.
+ *
+ * Getter for the field defaultLiquidViscosity
.
+ *
+ * getProcess. + *
+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ public ProcessSystem getProcess() { return processSystem; } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java index f689f4c041..006048330b 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/AdsorptionDehydrationDesignStandard.java @@ -29,10 +29,9 @@ public class AdsorptionDehydrationDesignStandard extends DesignStandard { public AdsorptionDehydrationDesignStandard(String name, MechanicalDesign equipmentInn) { super(name, equipmentInn); - final neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - java.sql.ResultSet dataSet = null; - try { + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + java.sql.ResultSet dataSet = null; try { dataSet = database.getResultSet( ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Adsorber Dehydration' AND Company='" @@ -45,18 +44,19 @@ public AdsorptionDehydrationDesignStandard(String name, MechanicalDesign equipme } } catch (Exception ex) { logger.error(ex.getMessage(), ex); - } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (dataSet != null) { - dataSet.close(); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception ex) { + System.out.println("error closing database.....GasScrubberDesignStandard"); + logger.error(ex.getMessage(), ex); } - } catch (Exception ex) { - System.out.println("error closing database.....GasScrubberDesignStandard"); - logger.error(ex.getMessage(), ex); } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java index 28edafcfd4..29fde9c887 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/CompressorDesignStandard.java @@ -29,22 +29,25 @@ public class CompressorDesignStandard extends DesignStandard { public CompressorDesignStandard(String name, MechanicalDesign equipmentInn) { super(name, equipmentInn); - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - - try (java.sql.ResultSet dataSet = database.getResultSet( - ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Compressor' AND Company='" - + standardName + "'"))) { - while (dataSet.next()) { - String specName = dataSet.getString("SPECIFICATION"); - if (specName.equals("compressorFactor")) { - compressorFactor = Double.parseDouble(dataSet.getString("MAXVALUE")); + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + try (java.sql.ResultSet dataSet = database.getResultSet( + ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Compressor' AND Company='" + + standardName + "'"))) { + while (dataSet.next()) { + String specName = dataSet.getString("SPECIFICATION"); + if (specName.equals("compressorFactor")) { + compressorFactor = Double.parseDouble(dataSet.getString("MAXVALUE")); + } } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); } /** diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java index fb84c82518..5b2621ebc7 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/GasScrubberDesignStandard.java @@ -33,10 +33,9 @@ public class GasScrubberDesignStandard extends DesignStandard { public GasScrubberDesignStandard(String name, MechanicalDesign equipmentInn) { super(name, equipmentInn); - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - java.sql.ResultSet dataSet = null; - try { + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + java.sql.ResultSet dataSet = null; try { dataSet = database.getResultSet( ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Gas scrubber' AND Company='" @@ -53,22 +52,23 @@ public GasScrubberDesignStandard(String name, MechanicalDesign equipmentInn) { designFactorVolumeFlow = Double.parseDouble(dataSet.getString("MINVALUE")); } } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } + // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); } catch (Exception ex) { - System.out.println("error closing database.....GasScrubberDesignStandard"); logger.error(ex.getMessage(), ex); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception ex) { + System.out.println("error closing database.....GasScrubberDesignStandard"); + logger.error(ex.getMessage(), ex); + } } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java index 35b5e900e6..af26aad349 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPipeDesignStandard.java @@ -144,21 +144,25 @@ public void readMaterialDesignStandard(String specNo, String grade) { this.grade = grade; specificationNumber = specNo; - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - try (java.sql.ResultSet dataSet = - database.getResultSet(("SELECT * FROM materialpipeproperties WHERE specificationNumber='" - + specificationNumber + "' AND grade='" + grade + "'"))) { - while (dataSet.next()) { - minimumYeildStrength = - (Double.parseDouble(dataSet.getString("minimumYeildStrength"))) * 0.00689475729; - // design factor table has to be developed - // Efactor table has to be implemented - // temperatureDeratingFactor has to be implemented + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + try (java.sql.ResultSet dataSet = + database.getResultSet(("SELECT * FROM materialpipeproperties WHERE specificationNumber='" + + specificationNumber + "' AND grade='" + grade + "'"))) { + while (dataSet.next()) { + minimumYeildStrength = + (Double.parseDouble(dataSet.getString("minimumYeildStrength"))) * 0.00689475729; + // design factor table has to be developed + // Efactor table has to be implemented + // temperatureDeratingFactor has to be implemented + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java index 206a96e68f..aea9e26bb1 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/MaterialPlateDesignStandard.java @@ -80,10 +80,9 @@ public void readMaterialDesignStandard(String name, String specNo, String grade, specificationNumber = specNo; divisionClassNumber = divClassNo; - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - java.sql.ResultSet dataSet = null; - try { + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + java.sql.ResultSet dataSet = null; try { dataSet = database.getResultSet(("SELECT * FROM materialplateproperties WHERE materialName='" @@ -97,22 +96,23 @@ public void readMaterialDesignStandard(String name, String specNo, String grade, (Double.parseDouble(dataSet.getString("divisionClass2"))) * 0.00689475729; // MPa } } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } + // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); } catch (Exception ex) { - System.out.println("error closing database.....GasScrubberDesignStandard"); logger.error(ex.getMessage(), ex); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception ex) { + System.out.println("error closing database.....GasScrubberDesignStandard"); + logger.error(ex.getMessage(), ex); + } } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java index 4806a74a03..65110623e0 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PipelineDesignStandard.java @@ -34,20 +34,23 @@ public PipelineDesignStandard(String name, MechanicalDesign equipmentInn) { // double jointEfficiency = // equipment.getJointEfficiencyStandard().getJEFactor(); - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - - try (java.sql.ResultSet dataSet = database.getResultSet( - ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Pipeline' AND Company='" - + standardName + "'"))) { - while (dataSet.next()) { - String specName = dataSet.getString("SPECIFICATION"); - if (specName.equals("safetyFactor")) { - safetyFactor = Double.parseDouble(dataSet.getString("MAXVALUE")); + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + try (java.sql.ResultSet dataSet = database.getResultSet( + ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Pipeline' AND Company='" + + standardName + "'"))) { + while (dataSet.next()) { + String specName = dataSet.getString("SPECIFICATION"); + if (specName.equals("safetyFactor")) { + safetyFactor = Double.parseDouble(dataSet.getString("MAXVALUE")); + } } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PressureVesselDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PressureVesselDesignStandard.java index f483d0d644..a55df29194 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PressureVesselDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/PressureVesselDesignStandard.java @@ -64,7 +64,6 @@ public double calcWallThickness() { - 0.2 * equipment.getMaxOperationPressure() / 10.0) + equipment.getCorrosionAllowanse(); } - return wallT / 1000.0; // return wall thickness in meter } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java index e74f575b23..1fac2ce3ba 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/designStandards/SeparatorDesignStandard.java @@ -53,10 +53,9 @@ public void setFg(double Fg) { */ public SeparatorDesignStandard(String name, MechanicalDesign equipmentInn) { super(name, equipmentInn); - neqsim.util.database.NeqSimProcessDesignDataBase database = - new neqsim.util.database.NeqSimProcessDesignDataBase(); - java.sql.ResultSet dataSet = null; - try { + try (neqsim.util.database.NeqSimProcessDesignDataBase database = + new neqsim.util.database.NeqSimProcessDesignDataBase()) { + java.sql.ResultSet dataSet = null; try { dataSet = database.getResultSet( ("SELECT * FROM technicalrequirements_process WHERE EQUIPMENTTYPE='Separator' AND Company='" @@ -76,22 +75,23 @@ public SeparatorDesignStandard(String name, MechanicalDesign equipmentInn) { + Double.parseDouble(dataSet.getString("MINVALUE"))) / 2.0; } } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } + // gasLoadFactor = Double.parseDouble(dataSet.getString("gasloadfactor")); } catch (Exception ex) { - System.out.println("error closing database.....GasScrubberDesignStandard"); logger.error(ex.getMessage(), ex); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception ex) { + System.out.println("error closing database.....GasScrubberDesignStandard"); + logger.error(ex.getMessage(), ex); + } } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/pipeline/PipelineMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/pipeline/PipelineMechanicalDesign.java index e648a8ff0f..2d0cb32b20 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/pipeline/PipelineMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/pipeline/PipelineMechanicalDesign.java @@ -59,7 +59,7 @@ public void calcDesign() { /* * Pipeline pipeline = (Pipeline) getProcessEquipment(); double flow = ((AdiabaticPipe) * getProcessEquipment()).getOutStream().getThermoSystem().getVolume() / 1e5; - * + * * double innerArea = Math.PI * innerDiameter * innerDiameter / 4.0; double gasVelocity = flow / * innerArea; double wallThickness = 0.0; */ diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/GasScrubberMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/GasScrubberMechanicalDesign.java index c4cc485081..cf65eb86b8 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/GasScrubberMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/GasScrubberMechanicalDesign.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.mechanicalDesign.separator; import neqsim.processSimulation.mechanicalDesign.designStandards.GasScrubberDesignStandard; +import neqsim.processSimulation.mechanicalDesign.separator.sectionType.SepDesignSection; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.separator.SeparatorInterface; @@ -72,7 +73,9 @@ public void calcDesign() { .getPhysicalProperties().getDensity(); double liqDensity = ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(1) .getPhysicalProperties().getDensity(); - + if (((SeparatorInterface) getProcessEquipment()).getThermoSystem().getNumberOfPhases() == 1) { + liqDensity = getDefaultLiquidDensity(); + } maxDesignVolumeFlow = volumeSafetyFactor * ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(0).getVolume() / 1e5; @@ -81,17 +84,21 @@ public void calcDesign() { innerDiameter = Math.sqrt(4.0 * getMaxDesignVolumeFlow() / (neqsim.thermo.ThermodynamicConstantsInterface.pi * maxGasVelocity * Fg)); tantanLength = innerDiameter * 5.0; - System.out.println("inner Diameter " + innerDiameter); + // System.out.println("inner Diameter " + innerDiameter); // calculating from standard codes // sepLength = innerDiameter * 2.0; emptyVesselWeight = 0.032 * getWallThickness() * 1e3 * innerDiameter * 1e3 * tantanLength; + + setOuterDiameter(innerDiameter + 2.0 * getWallThickness()); for (SeparatorSection sep : separator.getSeparatorSections()) { - sep.getMechanicalDesign().calcDesign(); - internalsWeight += sep.getMechanicalDesign().getTotalWeight(); + sep.setOuterDiameter(getOuterDiameter()); + SepDesignSection sect = sep.getMechanicalDesign(); + sect.calcDesign(); + internalsWeight += sect.getTotalWeight(); } - System.out.println("internal weight " + internalsWeight); + // System.out.println("internal weight " + internalsWeight); externalNozzelsWeight = 0.0; double Wv = emptyVesselWeight + internalsWeight + externalNozzelsWeight; @@ -104,17 +111,14 @@ public void calcDesign() { moduleLength = innerDiameter * 2.5; moduleLength = tantanLength * 1.5; moduleHeight = innerDiameter * 2; - // } - - setOuterDiameter(innerDiameter + 2.0 * getWallThickness()); - - System.out.println("wall thickness: " + separator.getName() + " " + getWallThickness() + " m"); - System.out.println("separator dry weigth: " + emptyVesselWeight + " kg"); - System.out.println("total skid weigth: " + totalSkidWeight + " kg"); - System.out.println("foot print: width:" + moduleWidth + " length " + moduleLength + " height " - + moduleHeight + " meter."); - System.out.println("mechanical price: " + materialsCost + " kNOK"); - + /* + * System.out.println("wall thickness: " + separator.getName() + " " + getWallThickness() + + * " m"); System.out.println("separator dry weigth: " + emptyVesselWeight + " kg"); + * System.out.println("total skid weigth: " + totalSkidWeight + " kg"); + * System.out.println("foot print: width:" + moduleWidth + " length " + moduleLength + + * " height " + moduleHeight + " meter."); System.out.println("mechanical price: " + + * materialsCost + " kNOK"); + */ setWeigthVesselShell(emptyVesselWeight); tantanLength = innerDiameter * 5; diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java index ee3e75fd69..e718eca581 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/SeparatorMechanicalDesign.java @@ -25,9 +25,6 @@ */ public class SeparatorMechanicalDesign extends MechanicalDesign { private static final long serialVersionUID = 1000; - - double wallThickness = 0.0; - private double outerDiameter = 0.0; double gasLoadFactor = 1.0; double volumeSafetyFactor = 1.0; double Fg = 1.0; @@ -81,7 +78,6 @@ public void readDesignSpecifications() { // design")).getLiquidRetentionTime("API12J", this); } else { System.out.println("no separator process design specified......"); - return; } } @@ -163,11 +159,15 @@ public void calcDesign() { double materialsCost = 0.0; double gasDensity = ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(0) .getPhysicalProperties().getDensity(); + double liqDensity = ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(1) .getPhysicalProperties().getDensity(); double liqViscosity = ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(1) .getPhysicalProperties().getViscosity(); - + if (((SeparatorInterface) getProcessEquipment()).getThermoSystem().getNumberOfPhases() == 1) { + liqDensity = getDefaultLiquidDensity(); + liqViscosity = getDefaultLiquidViscosity(); + } maxDesignVolumeFlow = volumeSafetyFactor * ((SeparatorInterface) getProcessEquipment()).getThermoSystem().getPhase(0).getVolume() / 1e5; @@ -187,12 +187,12 @@ public void calcDesign() { double sepratorLength = tantanLength + innerDiameter; if (sepratorLength / innerDiameter > 6 || sepratorLength / innerDiameter < 3) { - System.out - .println("Fg need to be modified ... L/D separator= " + sepratorLength / innerDiameter); + // System.out + // .println("Fg need to be modified ... L/D separator= " + sepratorLength / innerDiameter); tantanLength = innerDiameter * 5.0; sepratorLength = tantanLength + innerDiameter; } - System.out.println("inner Diameter " + innerDiameter); + // System.out.println("inner Diameter " + innerDiameter); // alternative design double bubbleDiameter = 250.0e-6; @@ -211,12 +211,14 @@ public void calcDesign() { // sepLength = innerDiameter * 2.0; emptyVesselWeight = 0.032 * getWallThickness() * 1e3 * innerDiameter * 1e3 * tantanLength; + setOuterDiameter(innerDiameter + 2.0 * getWallThickness()); for (SeparatorSection sep : separator.getSeparatorSections()) { + sep.setOuterDiameter(getOuterDiameter()); sep.getMechanicalDesign().calcDesign(); internalsWeight += sep.getMechanicalDesign().getTotalWeight(); } - System.out.println("internal weight " + internalsWeight); + // System.out.println("internal weight " + internalsWeight); externalNozzelsWeight = 0.0; // need to be implemented double Wv = emptyVesselWeight + internalsWeight + externalNozzelsWeight; @@ -230,15 +232,14 @@ public void calcDesign() { moduleHeight = innerDiameter * 2 + 1.0; // } - setOuterDiameter(innerDiameter + 2.0 * getWallThickness()); - - System.out.println("wall thickness: " + separator.getName() + " " + getWallThickness() + " m"); - System.out.println("separator dry weigth: " + emptyVesselWeight + " kg"); - System.out.println("total skid weigth: " + totalSkidWeight + " kg"); - System.out.println("foot print: width:" + moduleWidth + " length " + moduleLength + " height " - + moduleHeight + " meter."); - System.out.println("mechanical price: " + materialsCost + " kNOK"); - + /* + * System.out.println("wall thickness: " + separator.getName() + " " + getWallThickness() + + * " m"); System.out.println("separator dry weigth: " + emptyVesselWeight + " kg"); + * System.out.println("total skid weigth: " + totalSkidWeight + " kg"); + * System.out.println("foot print: width:" + moduleWidth + " length " + moduleLength + + * " height " + moduleHeight + " meter."); System.out.println("mechanical price: " + + * materialsCost + " kNOK"); + */ setWeigthVesselShell(emptyVesselWeight); // tantanLength = innerDiameter * 5; @@ -274,28 +275,4 @@ public void setDesign() { ((Separator) getProcessEquipment()).setSeparatorLength(tantanLength); // this method will be implemented to set calculated design... } - - /** {@inheritDoc} */ - @Override - public double getOuterDiameter() { - return outerDiameter; - } - - /** {@inheritDoc} */ - @Override - public double getWallThickness() { - return wallThickness; - } - - /** {@inheritDoc} */ - @Override - public void setWallThickness(double wallThickness) { - this.wallThickness = wallThickness; - } - - /** {@inheritDoc} */ - @Override - public void setOuterDiameter(double outerDiameter) { - this.outerDiameter = outerDiameter; - } } diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/DistillationTraySection.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/DistillationTraySection.java index dc9041c183..4cbedcc789 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/DistillationTraySection.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/DistillationTraySection.java @@ -27,8 +27,7 @@ public DistillationTraySection(SeparatorSection separatorSection) { /** {@inheritDoc} */ @Override public void calcDesign() { - double vesselDiameter = - separatorSection.getSeparator().getMechanicalDesign().getOuterDiameter() * 1e3; + double vesselDiameter = separatorSection.getOuterDiameter() * 1e3; if (vesselDiameter <= 616) { totalWeight = 32.0; } else if (vesselDiameter <= 770) { diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MecMeshSection.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MecMeshSection.java index e17b364348..8ea032ef9e 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MecMeshSection.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MecMeshSection.java @@ -27,8 +27,7 @@ public MecMeshSection(SeparatorSection separatorSection) { /** {@inheritDoc} */ @Override public void calcDesign() { - double vesselDiameter = - separatorSection.getSeparator().getMechanicalDesign().getOuterDiameter() * 1e3; + double vesselDiameter = separatorSection.getOuterDiameter() * 1e3; if (vesselDiameter <= 616) { totalWeight = 5.0; } else if (vesselDiameter <= 770) { diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MechVaneSection.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MechVaneSection.java index bced222fb6..f4620ee716 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MechVaneSection.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/separator/sectionType/MechVaneSection.java @@ -28,7 +28,7 @@ public MechVaneSection(SeparatorSection separatorSection) { @Override public void calcDesign() { double vesselDiameter = - separatorSection.getSeparator().getMechanicalDesign().getOuterDiameter() * 1e3; + separatorSection.getOuterDiameter() * 1e3; if (vesselDiameter <= 616) { totalWeight = 6.0; } else if (vesselDiameter <= 770) { diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java index 248bdb2b27..4a53efcec1 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/valve/ValveMechanicalDesign.java @@ -33,8 +33,9 @@ public class ValveMechanicalDesign extends MechanicalDesign { * Constructor for ValveMechanicalDesign. * * - * @param equipment a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} - * object + * @param equipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} + * object */ public ValveMechanicalDesign(ProcessEquipmentInterface equipment) { super(equipment); @@ -49,8 +50,7 @@ public void readDesignSpecifications() { if (getDesignStandard().containsKey("valve design codes")) { System.out.println("valve code standard: " + getDesignStandard().get("valve design codes").getStandardName()); - valveCvMax = - ((ValveDesignStandard) getDesignStandard().get("valve design codes")).getValveCvMax(); + valveCvMax = ((ValveDesignStandard) getDesignStandard().get("valve design codes")).getValveCvMax(); } else { System.out.println("no valve code standard specified......using default"); } @@ -65,7 +65,7 @@ public void calcDesign() { outletPressure = valve1.getOutletPressure(); dP = inletPressure - outletPressure; - valveCvMax = valve1.getThermoSystem().getVolume("m3/hr") + valveCvMax = valve1.getThermoSystem().getFlowRate("m3/hr") * Math.sqrt(valve1.getThermoSystem().getDensity("kg/m3") / 1000.0 / dP); valveWeight = valveCvMax * 100.0; setWeightTotal(valveWeight); @@ -78,7 +78,7 @@ public void displayResults() { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"Name", "Value", "Unit"}; + String[] names = { "Name", "Value", "Unit" }; String[][] table = new String[16][3]; // createTable(getProcessEquipment().getName()); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java index 8ceaacab5f..2799a1a065 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentBaseClass.java @@ -9,11 +9,13 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Objects; +import java.util.UUID; import org.apache.commons.lang.SerializationUtils; import neqsim.processSimulation.SimulationBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; import neqsim.processSimulation.mechanicalDesign.MechanicalDesign; import neqsim.processSimulation.processEquipment.stream.EnergyStream; +import neqsim.processSimulation.util.report.Report; import neqsim.thermo.system.SystemInterface; /** @@ -241,13 +243,8 @@ public String getConditionAnalysisMessage() { return conditionAnalysisMessage; } - /** - *- * getResultTable. - *
- * - * @return an array of {@link java.lang.String} objects - */ + /** {@inheritDoc} */ + @Override public String[][] getResultTable() { return null; } @@ -285,4 +282,23 @@ public boolean equals(Object obj) { && Arrays.deepEquals(report, other.report) && Objects.equals(specification, other.specification); } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return null; + } + + /** + * {@inheritDoc} + * + * @return a String + */ + public String getReport_json() { + return new Report(this).generateJsonReport(); + } + + /** {@inheritDoc} */ + @Override + public void run_step(UUID id) {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentInterface.java index fc1507259a..4fea2f15a6 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/ProcessEquipmentInterface.java @@ -25,12 +25,10 @@ public interface ProcessEquipmentInterface extends SimulationInterface { /** *
- * Get a initMechanicalDesign
for the equipment.
+ * Initialize a initMechanicalDesign
for the equipment.
*
@@ -47,7 +45,6 @@ default void initMechanicalDesign() { *
* * @return true or false - * */ public default boolean needRecalculation() { return true; @@ -138,7 +135,7 @@ public default SystemInterface getFluid() { /** *
- * getPressure.
+ * Getter for the field pressure
.
*
- * getPressure.
+ * Getter for the field pressure
converted to specified unit.
*
- * setPressure.
+ * Setter for the field pressure
.
*
+ * toJson. + *
+ * + * @return a String + */ + public String toJson(); + + /** + *+ * getReport_json + *
+ * Return results of simulation in json format + * + * @return a String + */ + public String getReport_json(); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/TwoPortEquipment.java b/src/main/java/neqsim/processSimulation/processEquipment/TwoPortEquipment.java index 489edf9801..891c53f67c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/TwoPortEquipment.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/TwoPortEquipment.java @@ -31,8 +31,7 @@ public TwoPortEquipment(String name) { */ public TwoPortEquipment(String name, StreamInterface stream) { this(name); - this.inStream = stream; - this.outStream = stream.clone(); + this.setInletStream(stream); } /** {@inheritDoc} */ @@ -81,6 +80,7 @@ public void setInletPressure(double pressure) { @Override public void setInletStream(StreamInterface stream) { this.inStream = stream; + this.outStream = inStream.clone(this.getName() + " out stream"); } /** {@inheritDoc} */ @@ -106,4 +106,10 @@ public void setOutletStream(StreamInterface stream) { public void setOutletTemperature(double temperature) { this.outStream.setTemperature(temperature, "unit"); } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return null; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java index b5f747916e..cef60e70e0 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorber.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.absorber; import java.util.UUID; - import neqsim.processSimulation.mechanicalDesign.absorber.AbsorberMechanicalDesign; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -33,28 +32,6 @@ public class SimpleAbsorber extends Separator implements AbsorberInterface { private double stageEfficiency = 0.25; private double fsFactor = 0.0; - /** - *- * Constructor for SimpleAbsorber. - *
- */ - @Deprecated - public SimpleAbsorber() { - this("SimpleAbsorber"); - } - - /** - *- * Constructor for SimpleAbsorber. - *
- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public SimpleAbsorber(StreamInterface inStream1) { - this("SimpleAbsorber", inStream1); - } - /** ** Constructor for SimpleAbsorber. @@ -99,12 +76,7 @@ public SimpleAbsorber(String name, StreamInterface inStream1) { outStream[1].run(); } - /** - * {@inheritDoc} - * - * @return a {@link neqsim.processSimulation.mechanicalDesign.absorber.AbsorberMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public AbsorberMechanicalDesign getMechanicalDesign() { return new AbsorberMechanicalDesign(this); @@ -114,8 +86,8 @@ public AbsorberMechanicalDesign getMechanicalDesign() { @Override public void setName(String name) { super.setName(name); - // outStream[0].setName(name + "_Sout1"); - // outStream[1].setName(name + "_Sout2"); + outStream[0].setName(name + "_Sout1"); + outStream[1].setName(name + "_Sout2"); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java index d9fc256ef3..d07d1bfb6a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/SimpleTEGAbsorber.java @@ -13,7 +13,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -44,14 +43,6 @@ public class SimpleTEGAbsorber extends SimpleAbsorber { private boolean isSetWaterInDryGas = false; private double waterInDryGas = 30e-6; - /** - *
- * Constructor for SimpleTEGAbsorber. - *
- */ - @Deprecated - public SimpleTEGAbsorber() {} - /** ** Constructor for SimpleTEGAbsorber. @@ -68,7 +59,7 @@ public SimpleTEGAbsorber(String name) { public void addStream(StreamInterface newStream) { streams.add(newStream); if (numberOfInputStreams == 0) { - mixedStream = (Stream) streams.get(0).clone(); + mixedStream = streams.get(0).clone(this.getName() + " mixed stream"); mixedStream.getThermoSystem().setNumberOfPhases(2); mixedStream.getThermoSystem().init(0); mixedStream.getThermoSystem().init(3); @@ -87,8 +78,8 @@ public void addStream(StreamInterface newStream) { */ public void addGasInStream(StreamInterface newStream) { // TODO: fail if gasInStream is not null? - gasInStream = (Stream) newStream; - gasOutStream = (Stream) newStream.clone(); + gasInStream = newStream; + gasOutStream = newStream.clone(); addStream(newStream); } @@ -102,8 +93,8 @@ public void addGasInStream(StreamInterface newStream) { */ public void addSolventInStream(StreamInterface newStream) { // TODO: fail if solventInStream is not null? - solventInStream = (Stream) newStream; - solventOutStream = (Stream) newStream.clone(); + solventInStream = newStream; + solventOutStream = newStream.clone(); addStream(newStream); solventStreamNumber = streams.size() - 1; } @@ -118,7 +109,7 @@ public void addSolventInStream(StreamInterface newStream) { */ public void replaceSolventInStream(StreamInterface newStream) { // TODO: fails if solventStreamNumber is 0, i.e. no solventinstream set? - solventInStream = (Stream) newStream; + solventInStream = newStream; streams.set(solventStreamNumber, solventInStream); } @@ -369,7 +360,6 @@ public void run(UUID id) { // System.out.println("total moles water " + // mixedStream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles()); StreamInterface newMixedStream = mixedStream.clone(); - newMixedStream.setName("test"); newMixedStream.getThermoSystem().addComponent("water", -molesWaterToMove, 0); newMixedStream.getThermoSystem().addComponent("water", molesWaterToMove, 1); newMixedStream.getThermoSystem().initBeta(); @@ -423,13 +413,8 @@ public void run(UUID id) { // getSolventOutStream().getFlowRate("kg/hr")); } - /** - *
- * getGasLoadFactor. - *
- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double getGasLoadFactor() { double intArea = 3.14 * getInternalDiameter() * getInternalDiameter() / 4.0; double vs = getGasOutStream().getThermoSystem().getFlowRate("m3/sec") / intArea; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java b/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java index 654e3c246b..fefb6fb9ed 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/absorber/WaterStripperColumn.java @@ -12,7 +12,6 @@ import javax.swing.JTable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; @@ -46,14 +45,6 @@ public class WaterStripperColumn extends SimpleAbsorber { int solventStreamNumber = 0; - /** - *- * Constructor for WaterStripperColumn. - *
- */ - @Deprecated - public WaterStripperColumn() {} - /** ** Constructor for WaterStripperColumn. @@ -70,7 +61,7 @@ public WaterStripperColumn(String name) { public void addStream(StreamInterface newStream) { streams.add(newStream); if (numberOfInputStreams == 0) { - mixedStream = (Stream) streams.get(0).clone(); + mixedStream = streams.get(0).clone(this.getName() + " mixed stream"); mixedStream.getThermoSystem().setNumberOfPhases(2); mixedStream.getThermoSystem().init(0); mixedStream.getThermoSystem().init(3); @@ -88,8 +79,8 @@ public void addStream(StreamInterface newStream) { * object */ public void addGasInStream(StreamInterface newStream) { - gasInStream = (Stream) newStream; - gasOutStream = (Stream) newStream.clone(); + gasInStream = newStream; + gasOutStream = newStream.clone(); addStream(newStream); } @@ -102,8 +93,8 @@ public void addGasInStream(StreamInterface newStream) { * object */ public void addSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; - solventOutStream = (Stream) newStream.clone(); + solventInStream = newStream; + solventOutStream = newStream.clone(); addStream(newStream); solventStreamNumber = streams.size() - 1; } @@ -117,7 +108,7 @@ public void addSolventInStream(StreamInterface newStream) { * object */ public void replaceSolventInStream(StreamInterface newStream) { - solventInStream = (Stream) newStream; + solventInStream = newStream; streams.set(solventStreamNumber, solventInStream); } @@ -352,7 +343,6 @@ public void run(UUID id) { // System.out.println("mole water to move " + molesWaterToMove); StreamInterface stream = mixedStream.clone(); - stream.setName("test"); stream.getThermoSystem().addComponent("water", molesWaterToMove, 0); stream.getThermoSystem().addComponent("water", -molesWaterToMove, 1); stream.getThermoSystem().initBeta(); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java index fd9b62dd37..4c399d13de 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorber.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.adsorber; import java.util.UUID; - import neqsim.processSimulation.mechanicalDesign.adsorber.AdsorberMechanicalDesign; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -34,48 +33,6 @@ public class SimpleAdsorber extends ProcessEquipmentBaseClass { private double NTU = 2.0; private double stageEfficiency = 0.25; - /** - *
- * Constructor for SimpleAdsorber. - *
- */ - @Deprecated - public SimpleAdsorber() { - this("SimpleAdsorber"); - } - - /** - *- * Constructor for SimpleAdsorber. - *
- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleAdsorber(StreamInterface inStream1) { - this("SimpleAdsorber"); - this.inStream[0] = inStream1; - this.inStream[1] = inStream1; - outStream[0] = (Stream) inStream1.clone(); - outStream[1] = (Stream) inStream1.clone(); - - SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); - outStream[0].setThermoSystem(systemOut1); - - double molCO2 = inStream1.getThermoSystem().getPhase(0).getComponent("CO2").getNumberOfmoles(); - System.out.println("mol CO2 " + molCO2); - SystemInterface systemOut0 = inStream1.getThermoSystem().clone(); - systemOut0.init(0); - systemOut0.addComponent("MDEA", molCO2 * absorptionEfficiency); - systemOut0.addComponent("water", molCO2 * absorptionEfficiency * 10.0); - systemOut0.chemicalReactionInit(); - systemOut0.createDatabase(true); - systemOut0.setMixingRule(4); - outStream[1].setThermoSystem(systemOut0); - outStream[1].run(); - } - /** * {@inheritDoc} * @@ -98,8 +55,8 @@ public SimpleAdsorber(String name, StreamInterface inStream1) { this(name); this.inStream[0] = inStream1; this.inStream[1] = inStream1; - outStream[0] = (Stream) inStream1.clone(); - outStream[1] = (Stream) inStream1.clone(); + outStream[0] = inStream1.clone(); + outStream[1] = inStream1.clone(); setName(name); SystemInterface systemOut1 = inStream1.getThermoSystem().clone(); @@ -118,12 +75,7 @@ public SimpleAdsorber(String name, StreamInterface inStream1) { outStream[1].run(); } - /** - * {@inheritDoc} - * - * @return a {@link neqsim.processSimulation.mechanicalDesign.adsorber.AdsorberMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public AdsorberMechanicalDesign getMechanicalDesign() { return new AdsorberMechanicalDesign(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java index 932014083e..8c21ffd8a3 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java @@ -12,9 +12,11 @@ import javax.swing.JTable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.gson.GsonBuilder; import neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.CompressorResponse; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -34,11 +36,18 @@ public class Compressor extends TwoPortEquipment implements CompressorInterface public SystemInterface thermoSystem; private double outTemperature = 298.15; private boolean useOutTemperature = false; + private double compressionRatio = 2.0; + private double actualCompressionRatio = 2.0; + private boolean useCompressionRatio = false; + private double maxOutletPressure = 10000.0; + private boolean isSetMaxOutletPressure = false; private CompressorPropertyProfile propertyProfile = new CompressorPropertyProfile(); public double dH = 0.0; public double inletEnthalpy = 0; public double pressure = 0.0; - private int speed = 3000; + private double speed = 3000; + private double maxspeed = 30000; + private double minspeed = 0; public double isentropicEfficiency = 1.0; public double polytropicEfficiency = 1.0; public boolean usePolytropicCalc = false; @@ -55,42 +64,6 @@ public class Compressor extends TwoPortEquipment implements CompressorInterface private String pressureUnit = "bara"; private String polytropicMethod = "detailed"; - /** - *- * Constructor for Compressor. - *
- */ - @Deprecated - public Compressor() { - this("Compressor"); - } - - /** - *- * Constructor for Compressor. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Compressor(StreamInterface inletStream) { - this(); - setInletStream(inletStream); - } - - /** - *- * Constructor for Compressor. - *
- * - * @param interpolateMapLookup a boolean - */ - @Deprecated - public Compressor(boolean interpolateMapLookup) { - this("Compressor", interpolateMapLookup); - } - /** * Constructor for Compressor. * @@ -129,25 +102,14 @@ public Compressor(String name, boolean interpolateMapLookup) { } } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public CompressorMechanicalDesign getMechanicalDesign() { return new CompressorMechanicalDesign(this); } - /** - *- * Create deep copy. - *
- * - * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object - */ + /** {@inheritDoc} */ + @Override public Compressor copy() { return (Compressor) super.copy(); } @@ -193,13 +155,8 @@ public void setOutletPressure(double pressure, String unit) { this.pressureUnit = unit; } - /** - *- * getOutletPressure. - *
- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double getOutletPressure() { return pressure; } @@ -358,6 +315,13 @@ public void run(UUID id) { double orginalMolarFLow = thermoSystem.getTotalNumberOfMoles(); double fractionAntiSurge = 0.0; double kappa = 0.0; + if (useCompressionRatio) { + double outpres = presinn * compressionRatio; + if (isSetMaxOutletPressure && outpres > maxOutletPressure) { + outpres = maxOutletPressure; + } + setOutletPressure(outpres); + } if (useOutTemperature) { if (useRigorousPolytropicMethod) { solveEfficiency(outTemperature); @@ -473,9 +437,11 @@ public void run(UUID id) { polytropicFluidHead = polytropicHead; polytropicHeadMeter = polytropicHead * 1000.0 / 9.81; } - double pressureRatio = Math.pow((polytropicFluidHead * 1000.0 - + (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW)) - / (n / (n - 1.0) * z_inlet * 8.314 * (temperature_inlet) / MW), n / (n - 1.0)); + double pressureRatio = Math.pow((polytropicFluidHead * 1000.0 + (n / (n - 1.0) * z_inlet + * ThermodynamicConstantsInterface.R * (temperature_inlet) / MW)) + / (n / (n - 1.0) * z_inlet * ThermodynamicConstantsInterface.R * (temperature_inlet) + / MW), + n / (n - 1.0)); setOutletPressure(thermoSystem.getPressure() * pressureRatio); if (getAntiSurge().isActive()) { logger.info("surge flow " @@ -664,7 +630,51 @@ public void run(UUID id) { polytropicFluidHead = getPower() / getThermoSystem().getFlowRate("kg/sec") / 1000.0 * getPolytropicEfficiency(); polytropicHeadMeter = polytropicFluidHead * 1000.0 / 9.81; + actualCompressionRatio = getOutletPressure() / presinn; + setCalculationIdentifier(id); + } + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + if (getCalculateSteadyState()) { + run(id); + increaseTime(dt); + return; + } + runController(dt, id); + + inStream.getThermoSystem().init(3); + outStream.getThermoSystem().init(3); + double head = (outStream.getThermoSystem().getEnthalpy("kJ/kg") + - inStream.getThermoSystem().getEnthalpy("kJ/kg")); + double guessFlow = inStream.getFluid().getFlowRate("m3/hr"); + double actualFlowRateNew = getCompressorChart().getFlow(head, getSpeed(), guessFlow); + if (actualFlowRateNew < 0.0 || Double.isNaN(actualFlowRateNew)) { + logger.error( + "actual flow rate is negative or NaN and would lead to failure of calculation: actual flow rate " + + actualFlowRateNew); + } + inStream.setFlowRate(actualFlowRateNew, "Am3/hr"); + + inStream.getThermoSystem().init(3); + inStream.getThermoSystem().initPhysicalProperties("density"); + inStream.run(id); + inStream.getThermoSystem().init(3); + + outStream.setFlowRate(inStream.getFlowRate("kg/hr"), "kg/hr"); + outStream.run(); + outStream.getThermoSystem().init(3); + + inletEnthalpy = inStream.getFluid().getEnthalpy(); + thermoSystem = outStream.getThermoSystem().clone(); + thermoSystem.initPhysicalProperties("density"); + + polytropicEfficiency = + compressorChart.getPolytropicEfficiency(inStream.getFlowRate("m3/hr"), speed) / 100.0; + polytropicFluidHead = head * polytropicEfficiency; + dH = polytropicFluidHead * 1000.0 * thermoSystem.getMolarMass() / getPolytropicEfficiency() + * inStream.getThermoSystem().getTotalNumberOfMoles(); setCalculationIdentifier(id); } @@ -953,6 +963,16 @@ public boolean isSurge(double flow, double head) { return getAntiSurge().isSurge(); } + /** {@inheritDoc} */ + @Override + public double getDistanceToSurge() { + getCompressorChart().getSurgeCurve(); + getCompressorChart().getSurgeCurve().getSurgeFlow(getPolytropicFluidHead()); + return (getInletStream().getFlowRate("m3/hr") + - getCompressorChart().getSurgeCurve().getSurgeFlow(getPolytropicFluidHead())) + / getCompressorChart().getSurgeCurve().getSurgeFlow(getPolytropicFluidHead()); + } + /** *
* isStoneWall.
@@ -983,9 +1003,9 @@ public void setAntiSurge(AntiSurge antiSurge) {
* Getter for the field speed
.
*
+ * runController. + *
+ * + * @param dt a double + * @param id Calculation identifier + */ + public void runController(double dt, UUID id) { + if (hasController && getController().isActive()) { + getController().runTransient(this.speed, dt, id); + this.speed = getController().getResponse(); + if (this.speed > maxspeed) { + this.speed = maxspeed; + } + if (this.speed < minspeed) { + this.speed = minspeed; + } + // System.out.println("valve opening " + this.percentValveOpening + " %"); + } + setCalculationIdentifier(id); + } + /** {@inheritDoc} */ @Override public int hashCode() { @@ -1308,4 +1351,78 @@ public boolean equals(Object obj) { && usePolytropicCalc == other.usePolytropicCalc && useRigorousPolytropicMethod == other.useRigorousPolytropicMethod; } + + /** {@inheritDoc} */ + @Override + public void setMaximumSpeed(double maxSpeed) { + this.maxspeed = maxSpeed; + } + + /** {@inheritDoc} */ + @Override + public void setMinimumSpeed(double minspeed) { + this.minspeed = minspeed; + } + + /** {@inheritDoc} */ + @Override + public double getMaximumSpeed() { + return maxspeed; + } + + /** {@inheritDoc} */ + @Override + public double getMinimumSpeed() { + return minspeed; + } + + /** + *
+ * Setter for the field compressionRatio
.
+ *
+ * Getter for the field compressionRatio
.
+ *
* addSurgeCurve. *
* - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects + * @param flow an array of type double + * @param head an array of type double */ public void addSurgeCurve(double[] flow, double[] head) { surgeCurve = new SurgeCurve(flow, head); @@ -390,18 +416,38 @@ public boolean equals(Object obj) { // other.reducedPolytropicEfficiencyFitter) } + /** + *Getter for the field maxSpeedCurve
.
Setter for the field maxSpeedCurve
.
Getter for the field minSpeedCurve
.
Setter for the field minSpeedCurve
.
+ * Constructor for CompressorChartGenerator. + *
+ * + * @param inpcompressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor} + * object + */ public CompressorChartGenerator(Compressor inpcompressor) { this.compressor = inpcompressor; } /** + *+ * generateCompressorChart. + *
+ * * @param generationOption string to specify how to generate the compressor chart * @return a {@link neqsim.processSimulation.processEquipment.compressor.CompressorChart} object */ public CompressorChart generateCompressorChart(String generationOption) { - // Generation compressor chart double[] chartConditions = new double[3]; chartConditions[0] = compressor.getOutletStream().getFluid().getMolarMass("kg/mol"); - int refspeed = compressor.getSpeed(); + double refspeed = compressor.getSpeed(); double[] speed = new double[1]; speed[0] = refspeed; double minSpeed = refspeed / 2.0; double maxSpeed = refspeed * 2.0; + compressor.getInletStream().getFluid().initPhysicalProperties("density"); double refflow = compressor.getInletStream().getFlowRate("m3/hr"); - double[][] flow = new double[1][1]; - flow[0][0] = refflow; + double[][] flow = new double[1][3]; + flow[0][0] = refflow * 0.7; + flow[0][1] = refflow * 1.0; + flow[0][2] = refflow * 1.43; double minFlow = refflow / 2.0; double maxFlow = refflow * 2.0; - double refhead = compressor.getPolytropicHead("kJ/kg"); - double[][] head = new double[1][1]; - head[0][0] = refhead; - - double[][] polyEff = new double[1][1]; - polyEff[0][0] = compressor.getPolytropicEfficiency() * 100.0; + double refhead = compressor.getPolytropicFluidHead(); + double[][] head = new double[1][3]; + head[0][0] = refhead * 1.5; + head[0][1] = refhead; + head[0][2] = refhead * 0.5; + double[][] polyEff = new double[1][3]; + polyEff[0][0] = compressor.getPolytropicEfficiency() * 100.0 * 0.9; + polyEff[0][1] = compressor.getPolytropicEfficiency() * 100.0; + polyEff[0][2] = compressor.getPolytropicEfficiency() * 100.0 * 0.85; CompressorChart compChart = new CompressorChart(); compChart.setUseCompressorChart(true); compChart.setHeadUnit("kJ/kg"); compChart.setCurves(chartConditions, speed, flow, head, polyEff); - // Generating surge curve - double minFlowSurgeFlow = 0.3 * refflow; - double refSurgeFlow = 0.5 * refflow; - double maxSurgeFlow = 0.8 * refflow; + double minFlowSurgeFlow = 0.7 * refflow; + double refSurgeFlow = 0.8 * refflow; + double maxSurgeFlow = 0.9 * refflow; double headSurgeRef = compChart.getPolytropicHead(refSurgeFlow, refspeed); double headSurgeMin = compChart.getPolytropicHead(minFlow, minSpeed); double headSurgeMax = compChart.getPolytropicHead(maxSurgeFlow, maxSpeed); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java index 1c3f72efa2..2a2178a078 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartInterface.java @@ -13,20 +13,20 @@ public interface CompressorChartInterface extends Cloneable { * This method is used add a curve to the CompressorChart object. * * @param speed a double - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects - * @param polytropicEfficiency an array of {@link double} objects + * @param flow an array of type double + * @param head an array of type double + * @param polytropicEfficiency an array of type double */ public void addCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency); /** * This method is used add a set of curves to the CompressorChart object. * - * @param chartConditions an array of {@link double} objects - * @param speed an array of {@link double} objects - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects - * @param polyEff an array of {@link double} objects + * @param chartConditions an array of type double + * @param speed an array of type double + * @param flow an array of type double + * @param head an array of type double + * @param polyEff an array of type double */ public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head, double[][] polyEff); @@ -166,4 +166,14 @@ public void setReferenceConditions(double refMW, double refTemperature, double r /** {@inheritDoc} */ @Override public int hashCode(); + + /** + *getFlow.
+ * + * @param head a double + * @param speed a double + * @param guessFlow a double + * @return a double + */ + public double getFlow(double head, double speed, double guessFlow); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorCurve.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorCurve.java index 3820b4cfab..9fd12cb869 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorCurve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorCurve.java @@ -35,9 +35,9 @@ public CompressorCurve() { * * * @param speed a double - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects - * @param polytropicEfficiency an array of {@link double} objects + * @param flow an array of type double + * @param head an array of type double + * @param polytropicEfficiency an array of type double */ public CompressorCurve(double speed, double[] flow, double[] head, double[] polytropicEfficiency) { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java index 1fea5d6015..d78bb058db 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorInterface.java @@ -71,4 +71,39 @@ public interface CompressorInterface extends ProcessEquipmentInterface, TwoPortI * @return a {@link neqsim.processSimulation.processEquipment.compressor.AntiSurge} object */ public AntiSurge getAntiSurge(); + + /** + *getDistanceToSurge.
+ * + * @return a double + */ + public double getDistanceToSurge(); + + /** + *setMaximumSpeed.
+ * + * @param maxSpeed a double + */ + public void setMaximumSpeed(double maxSpeed); + + /** + *setMinimumSpeed.
+ * + * @param minspeed a double + */ + public void setMinimumSpeed(double minspeed); + + /** + *getMaximumSpeed.
+ * + * @return a double + */ + public double getMaximumSpeed(); + + /** + *getMinimumSpeed.
+ * + * @return a double + */ + public double getMinimumSpeed(); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/StoneWallCurve.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/StoneWallCurve.java index 31cb09263f..6727b9f236 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/StoneWallCurve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/StoneWallCurve.java @@ -42,8 +42,8 @@ public StoneWallCurve() { * Constructor for StoneWallCurve. * * - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects + * @param flow an array of type double + * @param head an array of type double */ public StoneWallCurve(double[] flow, double[] head) { this.flow = flow; @@ -55,9 +55,9 @@ public StoneWallCurve(double[] flow, double[] head) { * setCurve. * * - * @param chartConditions an array of {@link double} objects - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects + * @param chartConditions an array of type double + * @param flow an array of type double + * @param head an array of type double */ public void setCurve(double[] chartConditions, double[] flow, double[] head) { this.chartConditions = chartConditions; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/SurgeCurve.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/SurgeCurve.java index be9e915102..e432b63b63 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/SurgeCurve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/SurgeCurve.java @@ -40,12 +40,13 @@ public SurgeCurve() {} * Constructor for SurgeCurve. * * - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects + * @param flow an array of type double + * @param head an array of type double */ public SurgeCurve(double[] flow, double[] head) { this.flow = flow; this.head = head; + this.setCurve(null, flow, head); } /** @@ -53,9 +54,9 @@ public SurgeCurve(double[] flow, double[] head) { * setCurve. * * - * @param chartConditions an array of {@link double} objects - * @param flow an array of {@link double} objects - * @param head an array of {@link double} objects + * @param chartConditions an array of type double + * @param flow an array of type double + * @param head an array of type double */ public void setCurve(double[] chartConditions, double[] flow, double[] head) { this.flow = flow; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java index 30a647b621..4bb8c4f304 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/Condenser.java @@ -24,6 +24,13 @@ public class Condenser extends SimpleTray { boolean totalCondenser = false; Splitter mixedStreamSplitter = null; + /** + *
+ * Setter for the field totalCondenser
.
+ *
- * getGasOutStream. - *
- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ + /** {@inheritDoc} */ + @Override public StreamInterface getGasOutStream() { if (totalCondenser) { return new Stream("", mixedStreamSplitter.getSplitStream(1)); @@ -99,12 +101,13 @@ public StreamInterface getProductOutStream() { } /** + * {@inheritDoc} + * ** getLiquidOutStream. *
- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.Stream} object */ + @Override public StreamInterface getLiquidOutStream() { if (totalCondenser) { return new Stream("", mixedStreamSplitter.getSplitStream(0)); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java index 478fd5a19f..898d5dc698 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumn.java @@ -55,12 +55,14 @@ public class DistillationColumn extends ProcessEquipmentBaseClass implements Dis * Constructor for DistillationColumn. * * - * @param numberOfTraysLocal a int - * @param hasReboiler a boolean - * @param hasCondenser a boolean + * @param name Name of distillation column + * @param numberOfTraysLocal Number of SimpleTrays to add + * @param hasReboiler Set true to add reboiler + * @param hasCondenser Set true to add Condenser */ - public DistillationColumn(int numberOfTraysLocal, boolean hasReboiler, boolean hasCondenser) { - super("DistillationColumn"); + public DistillationColumn(String name, int numberOfTraysLocal, boolean hasReboiler, + boolean hasCondenser) { + super(name); this.hasReboiler = hasReboiler; this.hasCondenser = hasCondenser; distoperations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -154,7 +156,6 @@ public void init() { // ((Runnable) trays.get(numberOfTrays - 1)).run(); ((Runnable) trays.get(0)).run(); - double feedTrayTemperature = getTray(getFeedTrayNumber()).getTemperature(); if (trays.get(numberOfTrays - 1).getNumberOfInputStreams() > 0) { @@ -200,7 +201,6 @@ public void init() { ((Runnable) trays.get(0)).run(); // massBalanceCheck(); - } /** @@ -318,11 +318,11 @@ public void run(UUID id) { for (int i = 0; i < numberOfTrays; i++) { trays.get(i).setPressure(bottomTrayPressure - i * dp); } - SystemInterface inpS = (SystemInterface) feedStream.getThermoSystem().clone(); + SystemInterface inpS = feedStream.getThermoSystem().clone(); getTray(feedTrayNumber).getStream(0).setThermoSystem(inpS); if (numberOfTrays == 1) { - ((SimpleTray) trays.get(0)).run(id); + trays.get(0).run(id); gasOutStream.setThermoSystem(trays.get(0).getGasOutStream().getThermoSystem().clone()); liquidOutStream.setThermoSystem(trays.get(0).getLiquidOutStream().getThermoSystem().clone()); } else { @@ -333,7 +333,7 @@ public void run(UUID id) { double errOld; int iter = 0; double[] oldtemps = new double[numberOfTrays]; - ((SimpleTray) trays.get(feedTrayNumber)).run(id); + trays.get(feedTrayNumber).run(id); do { iter++; @@ -348,12 +348,12 @@ public void run(UUID id) { ((Mixer) trays.get(i - 1)).replaceStream(replaceStream1, trays.get(i).getLiquidOutStream()); trays.get(i - 1).setPressure(bottomTrayPressure - (i - 1) * dp); - ((SimpleTray) trays.get(i - 1)).run(id); + trays.get(i - 1).run(id); } int streamNumb = trays.get(0).getNumberOfInputStreams() - 1; trays.get(0).setPressure(bottomTrayPressure); ((Mixer) trays.get(0)).replaceStream(streamNumb, trays.get(1).getLiquidOutStream()); - ((SimpleTray) trays.get(0)).run(id); + trays.get(0).run(id); for (int i = 1; i <= numberOfTrays - 1; i++) { int replaceStream = trays.get(i).getNumberOfInputStreams() - 2; @@ -361,22 +361,14 @@ public void run(UUID id) { replaceStream = trays.get(i).getNumberOfInputStreams() - 1; } ((Mixer) trays.get(i)).replaceStream(replaceStream, trays.get(i - 1).getGasOutStream()); - ((SimpleTray) trays.get(i)).run(id); + trays.get(i).run(id); } for (int i = numberOfTrays - 2; i >= feedTrayNumber; i--) { int replaceStream = trays.get(i).getNumberOfInputStreams() - 1; ((Mixer) trays.get(i)).replaceStream(replaceStream, trays.get(i + 1).getLiquidOutStream()); - ((SimpleTray) trays.get(i)).run(id); - } - for (int i = 1; i <= numberOfTrays - 1; i++) { - int replaceStream = trays.get(i).getNumberOfInputStreams() - 2; - if (i == (numberOfTrays - 1)) { - replaceStream = trays.get(i).getNumberOfInputStreams() - 1; - } - ((Mixer) trays.get(i)).replaceStream(replaceStream, trays.get(i - 1).getGasOutStream()); - ((SimpleTray) trays.get(i)).run(id); + trays.get(i).run(id); } for (int i = 0; i < numberOfTrays; i++) { err += Math.abs( @@ -385,7 +377,7 @@ public void run(UUID id) { logger.info("error iter " + err + " iteration " + iter); // System.out.println("error iter " + err + " iteration " + iter); // massBalanceCheck(); - } while (err > 1e-4 && err < errOld && iter < maxNumberOfIterations); // && + } while (err > 1e-4 && err < errOld && iter < maxNumberOfIterations); // && // !massBalanceCheck()); // massBalanceCheck(); // componentMassBalanceCheck("water"); @@ -397,7 +389,7 @@ public void run(UUID id) { for (int i = 0; i < numberOfTrays; i++) { // TODO: set calculation ids of child elements of trays - ((SimpleTray) trays.get(i)).setCalculationIdentifier(id); + trays.get(i).setCalculationIdentifier(id); } } setCalculationIdentifier(id); @@ -413,7 +405,7 @@ public void displayResult() { ** component componentMassBalanceCheck. *
- * + * * @param componentName component name to heck mass balance for * @return a boolean */ @@ -434,7 +426,6 @@ public boolean componentMassBalanceCheck(String componentName) { .getComponent(componentName).getFlowRate("kg/hr"); } } - } for (int i = 0; i < numberOfTrays; i++) { @@ -459,7 +450,6 @@ public boolean componentMassBalanceCheck(String componentName) { + trays.get(i).getLiquidOutStream().getFluid().getComponent("water").getFlowRate("kg/hr") + " pressure " + trays.get(i).getGasOutStream().getPressure() + " temperature " + trays.get(i).getGasOutStream().getTemperature("C") + " feedtotray " + massFeedInput[i]); - } double massError = 0.0; @@ -580,7 +570,7 @@ public static void main(String[] args) { testSystem.display(); Stream stream_1 = new Stream("Stream1", testSystem); - DistillationColumn column = new DistillationColumn(5, true, true); + DistillationColumn column = new DistillationColumn("distColumn", 5, true, true); column.addFeedStream(stream_1, 3); // column.getReboiler().setHeatInput(520000.0); ((Reboiler) column.getReboiler()).setRefluxRatio(0.5); @@ -732,13 +722,8 @@ public double getInternalDiameter() { return internalDiameter; } - /** - *
- * Getter for the field solved
.
- *
- * Constructor for Expander. - *
- */ - @Deprecated - public Expander() { - super(); - } - - /** - *- * Constructor for Expander. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Expander(StreamInterface inletStream) { - super(inletStream); - } - /** * Constructor for Expander. * @@ -89,7 +66,6 @@ public void run(UUID id) { /* * HYSYS method double oldPolyt = 10.5; int iter = 0; do { * - * * iter++; double n = Math.log(thermoSystem.getPressure() / presinn) / * Math.log(thermoSystem.getDensity() / densInn); double k = * Math.log(thermoSystem.getPressure() / presinn) / Math.log(densOutIdeal / densInn); double @@ -98,11 +74,9 @@ public void run(UUID id) { * 1.0); oldPolyt = polytropicEfficiency; polytropicEfficiency = factor * * isentropicEfficiency; dH = thermoSystem.getEnthalpy() - hinn; hout = hinn + dH / * polytropicEfficiency; thermoOps.PHflash(hout, 0); System.out.println(" factor " + factor + - * " n " + n + " k " + k + " polytropic effici " + polytropicEfficiency + " iter " + iter); - * - * } while (Math.abs((oldPolyt - polytropicEfficiency) / oldPolyt) > 1e-5 && iter < 500); // + * " n " + n + " k " + k + " polytropic effici " + polytropicEfficiency + " iter " + iter); } + * while (Math.abs((oldPolyt - polytropicEfficiency) / oldPolyt) > 1e-5 && iter < 500); // * polytropicEfficiency = isentropicEfficiency * (); - * */ } else { getThermoSystem().setPressure(pressure); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java b/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java index bc003ad9b2..64447dcffc 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/expander/ExpanderOld.java @@ -32,29 +32,6 @@ public class ExpanderOld extends TwoPortEquipment implements ExpanderInterface { double dH = 0.0; double pressure = 0.0; - /** - *- * Constructor for ExpanderOld. - *
- */ - @Deprecated - public ExpanderOld() { - this("ExpanderOld"); - } - - /** - *- * Constructor for ExpanderOld. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ExpanderOld(StreamInterface inletStream) { - this("ExpanderOld", inletStream); - } - /** * Constructor for ExpanderOld. * @@ -74,7 +51,7 @@ public ExpanderOld(String name) { * object */ public ExpanderOld(String name, StreamInterface inletStream) { - super(name); + this(name); setInletStream(inletStream); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/filter/CharCoalFilter.java b/src/main/java/neqsim/processSimulation/processEquipment/filter/CharCoalFilter.java index c3e1ce1afc..87e6890d46 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/filter/CharCoalFilter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/filter/CharCoalFilter.java @@ -13,19 +13,6 @@ public class CharCoalFilter extends Filter { private static final long serialVersionUID = 1000; - /** - *- * Constructor for CharCoalFilter. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public CharCoalFilter(StreamInterface inStream) { - super(inStream); - } - /** * Constructor for CharCoalFilter. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java b/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java index e78af11329..23b59af016 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/filter/Filter.java @@ -21,19 +21,6 @@ public class Filter extends TwoPortEquipment { private double deltaP = 0.01; private double Cv = 0.0; - /** - *- * Constructor for Filter. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Filter(StreamInterface inStream) { - this("Filter", inStream); - } - /** ** Constructor for Filter. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Cooler.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Cooler.java index 21e9078916..3120ca3d15 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Cooler.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Cooler.java @@ -1,8 +1,9 @@ package neqsim.processSimulation.processEquipment.heatExchanger; import java.util.UUID; - +import com.google.gson.GsonBuilder; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.HeaterResponse; /** *
@@ -15,29 +16,6 @@ public class Cooler extends Heater { private static final long serialVersionUID = 1000; - /** - *
- * Constructor for Cooler. - *
- */ - @Deprecated - public Cooler() { - super(); - } - - /** - *- * Constructor for Cooler. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Cooler(StreamInterface inStream) { - super(inStream); - } - /** * Constructor for Cooler. * @@ -76,4 +54,10 @@ public double getEntropyProduction(String unit) { return entrop; } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new HeaterResponse(this)); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java index 42a2ed1fe3..8623e90af8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchanger.java @@ -7,11 +7,12 @@ package neqsim.processSimulation.processEquipment.heatExchanger; import java.util.UUID; - +import com.google.gson.GsonBuilder; import neqsim.processSimulation.conditionMonitor.ConditionMonitorSpecifications; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.HXResponse; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -41,47 +42,11 @@ public class HeatExchanger extends Heater implements HeatExchangerInterface { private double hotColdDutyBalance = 1.0; boolean firstTime = true; public double guessOutTemperature = 273.15 + 130.0; + public String guessOutTemperatureUnit = "K"; int outStreamSpecificationNumber = 0; public double thermalEffectiveness = 0.0; private String flowArrangement = "concentric tube counterflow"; - - /** - *- * Constructor for HeatExchanger. - *
- */ - @Deprecated - public HeatExchanger() { - this("HeatExchanger"); - } - - /** - *- * Constructor for HeatExchanger. - *
- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public HeatExchanger(StreamInterface inStream1) { - this("HeatExchanger", inStream1); - } - - /** - *- * Constructor for HeatExchanger. - *
- * - * @param inStream1 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - * @param inStream2 a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public HeatExchanger(StreamInterface inStream1, StreamInterface inStream2) { - this("HeatExchanger", inStream1, inStream2); - } + private boolean useDeltaT = false; /** * Constructor for HeatExchanger. @@ -258,16 +223,110 @@ public void runSpecifiedStream(UUID id) { outStream[nonOutStreamSpecifiedStreamNumber].setFluid(systemOut0); } + /** + *+ * runSpecifiedStream. + *
+ * + * @param id UUID of run + */ + public void runDeltaT(UUID id) { + + if (getSpecification().equals("out stream")) { + runSpecifiedStream(id); + } else if (firstTime) { + firstTime = false; + SystemInterface systemOut0 = inStream[0].getThermoSystem().clone(); + outStream[0].setThermoSystem(systemOut0); + outStream[0].getThermoSystem().setTemperature(guessOutTemperature, guessOutTemperatureUnit); + outStream[0].run(id); + run(id); + } else { + int streamToCalculate = 0; + + for (StreamInterface stream : inStream) { + stream.run(); + } + + int streamToSet = 1; + SystemInterface systemOut0 = inStream[streamToSet].getThermoSystem().clone(); + SystemInterface systemOut1 = inStream[streamToCalculate].getThermoSystem().clone(); + double sign = Math.signum( + inStream[streamToCalculate].getTemperature() - inStream[streamToSet].getTemperature()); + // systemOut1.setTemperature(inTemp1); + outStream[streamToSet].setThermoSystem(systemOut0); + outStream[streamToCalculate].setThermoSystem(systemOut1); + outStream[streamToSet] + .setTemperature(inStream[streamToCalculate].getTemperature() + sign * deltaT, "K"); + if (!outStream[streamToSet].getSpecification().equals("TP")) { + outStream[streamToSet].runTPflash(); + } + outStream[streamToSet].run(id); + double dEntalphy1 = outStream[streamToSet].getThermoSystem().getEnthalpy() + - inStream[streamToSet].getThermoSystem().getEnthalpy(); + double C1 = + Math.abs(dEntalphy1) / Math.abs((outStream[streamToSet].getThermoSystem().getTemperature() + - inStream[streamToSet].getThermoSystem().getTemperature())); + + outStream[streamToCalculate].setTemperature( + inStream[streamToSet].getThermoSystem().getTemperature() - sign * deltaT, "K"); + if (!outStream[streamToCalculate].getSpecification().equals("TP")) { + outStream[streamToCalculate].runTPflash(); + } + outStream[streamToCalculate].run(id); + double dEntalphy2 = outStream[streamToCalculate].getThermoSystem().getEnthalpy() + - inStream[streamToCalculate].getThermoSystem().getEnthalpy(); + double C2 = Math.abs(dEntalphy2) + / Math.abs(outStream[streamToCalculate].getThermoSystem().getTemperature() + - inStream[streamToCalculate].getThermoSystem().getTemperature()); + double Cmin = C1; + double Cmax = C2; + if (C2 < C1) { + Cmin = C2; + Cmax = C1; + } + double Cr = Cmin / Cmax; + if (Math.abs(dEntalphy1) < Math.abs(dEntalphy2)) { + int streamCHange = streamToCalculate; + streamToCalculate = streamToSet; + streamToSet = streamCHange; + } + + double dEntalphy = outStream[streamToSet].getThermoSystem().getEnthalpy() + - inStream[streamToSet].getThermoSystem().getEnthalpy(); + // System.out.println("dent " + dEntalphy); + ThermodynamicOperations testOps = + new ThermodynamicOperations(outStream[streamToCalculate].getThermoSystem()); + testOps.PHflash(inStream[streamToCalculate].getThermoSystem().getEnthalpy() - dEntalphy, 0); + + if (Math.abs(thermalEffectiveness - 1.0) > 1e-10) { + testOps = new ThermodynamicOperations(outStream[streamToSet].getThermoSystem()); + testOps.PHflash(inStream[streamToSet].getThermoSystem().getEnthalpy() + dEntalphy, 0); + } + duty = dEntalphy; + hotColdDutyBalance = 1.0; + + UAvalue = dEntalphy / (outStream[streamToSet].getThermoSystem().getTemperature() + - inStream[streamToSet].getThermoSystem().getTemperature()); + } + + setCalculationIdentifier(id); + } + /** {@inheritDoc} */ @Override public void run(UUID id) { + if (useDeltaT) { + runDeltaT(id); + return; + } if (getSpecification().equals("out stream")) { runSpecifiedStream(id); } else if (firstTime) { firstTime = false; SystemInterface systemOut0 = inStream[0].getThermoSystem().clone(); outStream[0].setThermoSystem(systemOut0); - outStream[0].getThermoSystem().setTemperature(guessOutTemperature); + outStream[0].getThermoSystem().setTemperature(guessOutTemperature, guessOutTemperatureUnit); outStream[0].run(id); run(id); } else { @@ -280,6 +339,12 @@ public void run(UUID id) { // streamToSet = 0; // } + // Make sure these streams to run because of the issues with enthalpy + // calculations if not run + for (StreamInterface stream : inStream) { + stream.run(); + } + int streamToSet = 1; SystemInterface systemOut0 = inStream[streamToSet].getThermoSystem().clone(); SystemInterface systemOut1 = inStream[streamToCalculate].getThermoSystem().clone(); @@ -287,10 +352,7 @@ public void run(UUID id) { // systemOut1.setTemperature(inTemp1); outStream[streamToSet].setThermoSystem(systemOut0); outStream[streamToCalculate].setThermoSystem(systemOut1); - outStream[streamToSet] - .setTemperature(inStream[streamToCalculate].getThermoSystem().getTemperature(), "K"); - outStream[streamToSet].getThermoSystem() - .setTemperature(inStream[streamToCalculate].getThermoSystem().getTemperature()); + outStream[streamToSet].setTemperature(inStream[streamToCalculate].getTemperature(), "K"); if (!outStream[streamToSet].getSpecification().equals("TP")) { outStream[streamToSet].runTPflash(); } @@ -303,8 +365,6 @@ public void run(UUID id) { outStream[streamToCalculate] .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature(), "K"); - outStream[streamToCalculate].getThermoSystem() - .setTemperature(inStream[streamToSet].getThermoSystem().getTemperature()); if (!outStream[streamToCalculate].getSpecification().equals("TP")) { outStream[streamToCalculate].runTPflash(); } @@ -359,12 +419,12 @@ public void run(UUID id) { /* * if (systemOut0.getTemperature() <= inTemp1 - dT) { systemOut0.setTemperature(inTemp1); * outStream[0].setThermoSystem(systemOut0); outStream[0].run(); //inStream[0].run(); - * + * * dEntalphy = outStream[0].getThermoSystem().getEnthalpy() - * inStream[0].getThermoSystem().getEnthalpy(); corrected_Entalphy = dEntalphy * * inStream[0].getThermoSystem().getNumberOfMoles() / * inStream[1].getThermoSystem().getNumberOfMoles(); - * + * * systemOut1 = inStream[1].getThermoSystem().clone(); System.out.println("dent " + * dEntalphy); testOps = new ThermodynamicOperations(systemOut1); * testOps.PHflash(systemOut1.getEnthalpy() - corrected_Entalphy, 0); @@ -431,6 +491,19 @@ public double getGuessOutTemperature() { */ public void setGuessOutTemperature(double guessOutTemperature) { this.guessOutTemperature = guessOutTemperature; + this.guessOutTemperatureUnit = "K"; + } + + /** + *
+ * Setter for the field guessOutTemperature
.
+ *
Getter for the field flowArrangement
.
+ * Getter for the field flowArrangement
.
+ *
Setter for the field flowArrangement
.
+ * Setter for the field flowArrangement
.
+ *
- * Constructor for Heater. - *
- */ - @Deprecated - public Heater() { - super("Heater"); - } - - /** - *- * Constructor for Heater. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Heater(StreamInterface inStream) { - this("Heater", inStream); - } - /** * Constructor for Heater. * @@ -155,7 +133,6 @@ public void setOutTP(double temperature, double pressure) { public boolean needRecalculation() { if (inStream == null) { return true; - } if (inStream.getFluid().getTemperature() == lastTemperature && inStream.getFluid().getPressure() == lastPressure @@ -221,6 +198,20 @@ public void run(UUID id) { setCalculationIdentifier(id); } + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + if (getCalculateSteadyState()) { + run(id); + increaseTime(dt); + } else { + inStream.setPressure(outStream.getPressure()); + inStream.run(); + run(id); + increaseTime(dt); + } + } + /** {@inheritDoc} */ @Override public void displayResult() { @@ -357,4 +348,10 @@ public double getExergyChange(String unit, double surroundingTemperature) { return outStream.getThermoSystem().getExergy(surroundingTemperature, unit) - inStream.getThermoSystem().getExergy(surroundingTemperature, unit); } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new HeaterResponse(this)); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java index fc86b56da2..01b2dbc546 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/NeqHeater.java @@ -18,29 +18,6 @@ public class NeqHeater extends Heater { SystemInterface system; double dH = 0.0; - /** - *- * Constructor for NeqHeater. - *
- */ - @Deprecated - public NeqHeater() { - this("NeqHeater"); - } - - /** - *- * Constructor for NeqHeater. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public NeqHeater(StreamInterface inStream) { - this("NeqHeater", inStream); - } - /** * Constructor for NeqHeater. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java index e07f86cf22..cf76b80999 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/ReBoiler.java @@ -21,29 +21,6 @@ public class ReBoiler extends TwoPortEquipment { SystemInterface system; private double reboilerDuty = 0.0; - /** - *- * Constructor for ReBoiler. - *
- */ - @Deprecated - public ReBoiler() { - super("ReBoiler"); - } - - /** - *- * Constructor for ReBoiler. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ReBoiler(StreamInterface inStream) { - this("ReBoiler", inStream); - } - /** ** Constructor for ReBoiler. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/manifold/Manifold.java b/src/main/java/neqsim/processSimulation/processEquipment/manifold/Manifold.java index 5779920dc7..a547a8c98b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/manifold/Manifold.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/manifold/Manifold.java @@ -40,13 +40,21 @@ public Manifold() { *
* Constructor for Splitter with name as input. *
- * + * * @param name name of manifold */ public Manifold(String name) { super(name); } + /** + *+ * addStream. + *
+ * + * @param newStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ public void addStream(StreamInterface newStream) { localmixer.addStream(newStream); } @@ -56,7 +64,7 @@ public void addStream(StreamInterface newStream) { * setSplitFactors. * * - * @param splitFact an array of {@link double} objects + * @param splitFact an array of type double */ public void setSplitFactors(double[] splitFact) { splitFactors = splitFact; @@ -64,19 +72,23 @@ public void setSplitFactors(double[] splitFact) { localsplitter.setSplitFactors(splitFactors); } - /** {@inheritDoc} */ + /** + *getSplitStream.
+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ public StreamInterface getSplitStream(int i) { return localsplitter.getSplitStream(i); } - /** ** getMixedStream. *
- * + * * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - **/ + */ public StreamInterface getMixedStream() { return localmixer.getOutletStream(); } @@ -88,5 +100,4 @@ public void run(UUID id) { localsplitter.setInletStream(localmixer.getOutletStream()); localsplitter.run(); } - } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java index 06b4273db9..188c8db4ad 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/Mixer.java @@ -15,7 +15,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -38,16 +37,6 @@ public class Mixer extends ProcessEquipmentBaseClass implements MixerInterface { private boolean isSetOutTemperature = false; private double outTemperature = Double.NaN; - /** - *- * Constructor for Mixer. - *
- */ - @Deprecated - public Mixer() { - super("Mixer"); - } - /** ** Constructor for Mixer. @@ -85,7 +74,7 @@ public void addStream(StreamInterface newStream) { try { if (getNumberOfInputStreams() == 0) { - mixedStream = (Stream) streams.get(0).clone(); // cloning the first stream + mixedStream = streams.get(0).clone(this.getName() + " mixed stream"); // mixedStream.getThermoSystem().setNumberOfPhases(2); // mixedStream.getThermoSystem().init(0); // mixedStream.getThermoSystem().init(3); @@ -196,10 +185,7 @@ public double calcMixStreamEnthalpy() { for (int k = 0; k < streams.size(); k++) { streams.get(k).getThermoSystem().init(3); enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( ((Stream) - // streams.get(k)).getThermoSystem()).getEnthalpy()); } - // System.out.println("total enthalpy of streams: " + enthalpy); return enthalpy; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java index 5fbba08e36..390fd06220 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/MixerInterface.java @@ -31,7 +31,7 @@ public interface MixerInterface extends ProcessEquipmentInterface { /** *
- * getOutStream. + * Getter for outlet stream object. *
* * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object @@ -40,7 +40,7 @@ public interface MixerInterface extends ProcessEquipmentInterface { /** *- * getOutStream. + * Getter for outlet stream object. *
* * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java index ac1c67ed06..d37a85f948 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticMixer.java @@ -20,14 +20,6 @@ public class StaticMixer extends Mixer { private static final long serialVersionUID = 1000; - /** - *- * Constructor for StaticMixer. - *
- */ - @Deprecated - public StaticMixer() {} - /** ** Constructor for StaticMixer. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java index d4c5ca9c46..5cfe43337d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticNeqMixer.java @@ -21,14 +21,6 @@ public class StaticNeqMixer extends StaticMixer { private static final long serialVersionUID = 1000; - /** - *
- * Constructor for StaticNeqMixer. - *
- */ - @Deprecated - public StaticNeqMixer() {} - /** ** Constructor for StaticNeqMixer. diff --git a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java index 78755497c3..4e154cbc52 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/mixer/StaticPhaseMixer.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.mixer; import java.util.UUID; +import neqsim.thermo.phase.PhaseType; /** *
@@ -13,14 +14,6 @@ public class StaticPhaseMixer extends StaticMixer { private static final long serialVersionUID = 1000; - /** - *
- * Constructor for StaticPhaseMixer. - *
- */ - @Deprecated - public StaticPhaseMixer() {} - /** ** Constructor for StaticPhaseMixer. @@ -47,17 +40,17 @@ public void mixStream() { System.out.println("adding: " + componentName); int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); double[] moles = new double[numberOfPhases]; - int[] phaseType = new int[numberOfPhases]; + PhaseType[] phaseType = new PhaseType[numberOfPhases]; // her maa man egentlig sjekke at phase typen er den samme !!! antar at begge er // to fase elle gass - tofase for (int p = 0; p < numberOfPhases; p++) { moles[p] = streams.get(k).getThermoSystem().getPhase(p).getComponents()[i] .getNumberOfMolesInPhase(); - phaseType[p] = streams.get(k).getThermoSystem().getPhase(p).getType().getValue(); + phaseType[p] = streams.get(k).getThermoSystem().getPhase(p).getType(); } if (k == 1) { - phaseType[0] = 0; + phaseType[0] = PhaseType.LIQUID; mixedStream.getThermoSystem().getPhase(1) .setTemperature(streams.get(k).getThermoSystem().getTemperature()); } @@ -77,10 +70,10 @@ public void mixStream() { if (gotComponent) { System.out.println("adding moles starting...."); for (int p = 0; p < numberOfPhases; p++) { - if (phaseType[p] == 0) { + if (phaseType[p] == PhaseType.LIQUID) { System.out.println("adding liq"); mixedStream.getThermoSystem().addComponent(index, moles[p], 1); - } else if (phaseType[p] == 1) { + } else if (phaseType[p] == PhaseType.GAS) { System.out.println("adding gas"); mixedStream.getThermoSystem().addComponent(index, moles[p], 0); } else { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java index 2595102492..7e9343b1ce 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticPipe.java @@ -36,29 +36,6 @@ public class AdiabaticPipe extends Pipeline { String flowPattern = "unknown"; String pipeSpecification = "AP02"; - /** - *
- * Constructor for AdiabaticPipe. - *
- */ - @Deprecated - public AdiabaticPipe() { - this("AdiabaticPipe"); - } - - /** - *- * Constructor for AdiabaticPipe. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public AdiabaticPipe(StreamInterface inStream) { - this("AdiabaticPipe", inStream); - } - /** * Constructor for AdiabaticPipe. * @@ -77,7 +54,7 @@ public AdiabaticPipe(String name) { public AdiabaticPipe(String name, StreamInterface inStream) { this(name); this.inStream = inStream; - outStream = (Stream) inStream.clone(); + outStream = inStream.clone(); } /** @@ -159,9 +136,9 @@ public double calcPressureOut() { * system.getTemperature() / Math.pow(insideDiameter, 5.0); // \\System.out.println("friction fact" + frictionFactor + " velocity " + // velocity + " reynolds number " + reynoldsNumber); - System.out.println("dp gravity " - + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity - * (inletElevation - outletElevation) / 1.0e5); + // System.out.println("dp gravity " + // + system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity + // * (inletElevation - outletElevation) / 1.0e5); double dp_gravity = system.getDensity("kg/m3") * neqsim.thermo.ThermodynamicConstantsInterface.gravity * (inletElevation - outletElevation); @@ -383,7 +360,7 @@ public static void main(String[] name) { Stream stream_1 = new Stream("Stream1", testSystem); - AdiabaticPipe pipe = new AdiabaticPipe(stream_1); + AdiabaticPipe pipe = new AdiabaticPipe("pipe1", stream_1); pipe.setLength(700000.0); pipe.setDiameter(0.7112); pipe.setPipeWallRoughness(5e-6); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java index 4a74e3eb3e..c77b190485 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/AdiabaticTwoPhasePipe.java @@ -44,27 +44,6 @@ public class AdiabaticTwoPhasePipe extends Pipeline { String flowPattern = "unknown"; String pipeSpecification = "AP02"; - /** - *- * Constructor for AdiabaticTwoPhasePipe. - *
- */ - @Deprecated - public AdiabaticTwoPhasePipe() {} - - /** - *- * Constructor for AdiabaticTwoPhasePipe. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public AdiabaticTwoPhasePipe(StreamInterface inStream) { - this("AdiabaticTwoPhasePipe", inStream); - } - /** * Constructor for AdiabaticTwoPhasePipe. * @@ -284,6 +263,7 @@ public void run(UUID id) { system.setTotalFlowRate(flowLimit, maxflowunit); system.init(1); } + // SetTotalFlowRate resets beta factors, but they are fixed in run below inStream.getThermoSystem().setTotalFlowRate(system.getFlowRate(maxflowunit), maxflowunit); inStream.run(id); } else { @@ -322,7 +302,9 @@ public void displayResult() { } /** - *getSuperficialVelocity.
+ *+ * getSuperficialVelocity. + *
* * @return a double */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java index ea33e69752..f1dffad6df 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/IncompressiblePipeFlow.java @@ -20,29 +20,6 @@ public class IncompressiblePipeFlow extends AdiabaticPipe { private double totalEqLenth = 0; double momentum = 0; - /** - *- * Constructor for IncompressiblePipeFlow. - *
- */ - @Deprecated - public IncompressiblePipeFlow() { - super("IncompressiblePipeFlow"); - } - - /** - *- * Constructor for IncompressiblePipeFlow. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public IncompressiblePipeFlow(StreamInterface inStream) { - this("IncompressiblePipeFlow", inStream); - } - /** * Constructor for IncompressiblePipeFlow. * @@ -159,13 +136,13 @@ public static void main(String[] name) { testSystem.initPhysicalProperties(); Stream stream_1 = new Stream("Stream1", testSystem); - IncompressiblePipeFlow pipe = new IncompressiblePipeFlow(stream_1); + IncompressiblePipeFlow pipe = new IncompressiblePipeFlow("pipe1", stream_1); pipe.setLength(1000.0); pipe.setDiameter(0.25); pipe.setPipeWallRoughness(2e-5); pipe.addFittingFromDatabase("Standard elbow (R=1.5D), 90deg"); - IncompressiblePipeFlow pipe2 = new IncompressiblePipeFlow(pipe.getOutletStream()); + IncompressiblePipeFlow pipe2 = new IncompressiblePipeFlow("pipe2", pipe.getOutletStream()); pipe2.setLength(1000.0); pipe2.setDiameter(0.25); pipe2.setPipeWallRoughness(2e-5); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java index de6e2fada4..58e5129b4f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/OnePhasePipeLine.java @@ -9,7 +9,6 @@ import java.util.UUID; import neqsim.fluidMechanics.flowSystem.onePhaseFlowSystem.pipeFlowSystem.PipeFlowSystem; import neqsim.processSimulation.processEquipment.stream.StreamInterface; -import neqsim.thermo.system.SystemInterface; /** *@@ -22,16 +21,6 @@ public class OnePhasePipeLine extends Pipeline { private static final long serialVersionUID = 1000; - /** - *
- * Constructor for OnePhasePipeLine. - *
- */ - @Deprecated - public OnePhasePipeLine() { - this("OnePhasePipeLine"); - } - /** *
* Constructor for OnePhasePipeLine.
@@ -78,7 +67,8 @@ public void run(UUID id) {
setCalculationIdentifier(oldid);
pipe.solveSteadyState(10, id);
// pipe.print();
- outStream.setThermoSystem((SystemInterface)pipe.getNode(pipe.getTotalNumberOfNodes() - 1).getBulkSystem().clone());
+ outStream
+ .setThermoSystem(pipe.getNode(pipe.getTotalNumberOfNodes() - 1).getBulkSystem().clone());
outStream.setCalculationIdentifier(id);
setCalculationIdentifier(id);
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
index 6f1212fa92..b0d070df62 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java
@@ -1,5 +1,6 @@
package neqsim.processSimulation.processEquipment.pipeline;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -18,8 +19,14 @@
public class PipeBeggsAndBrills extends Pipeline {
private static final long serialVersionUID = 1001;
+ int iteration;
+
+ private double nominalDiameter;
+
+ private Boolean PipeSpecSet = false;
+
// Inlet pressure of the pipeline (initialization)
- private double inletPressure = 0;
+ private double inletPressure = Double.NaN;
private double totalPressureDrop = 0;
@@ -31,16 +38,19 @@ public class PipeBeggsAndBrills extends Pipeline {
String maxflowunit = "kg/hr";
// Inside diameter of the pipe [m]
- private double insideDiameter = 0.1;
+ private double insideDiameter = Double.NaN;
+
+ // Thickness diameter of the pipe [m]
+ private double pipeThickness = Double.NaN;
// Roughness of the pipe wall [m]
private double pipeWallRoughness = 1e-5;
- // Flag to run isothermal calculations
- private boolean runIsothermal = false;
+ // Flag to run isothermal calculations
+ private boolean runIsothermal = true;
// Flow pattern of the fluid in the pipe
- private String regime = "unknown";
+ private String regime;
// Volume fraction of liquid in the input mixture
private double inputVolumeFractionLiquid;
@@ -49,7 +59,7 @@ public class PipeBeggsAndBrills extends Pipeline {
private double mixtureFroudeNumber;
// Specification of the pipe
- private String pipeSpecification = "AP02";
+ private String pipeSpecification = "LD201";
// Ref. Beggs and Brills
private double A;
@@ -109,11 +119,10 @@ public class PipeBeggsAndBrills extends Pipeline {
private double cumulativeElevation;
- //For segment calculation
+ // For segment calculation
double length;
double elevation;
-
// Results initialization (for each segment)
private List
- * Constructor for PipeBeggsAndBrills.
- *
- * Constructor for PipeBeggsAndBrills.
- * pipeSpecification
.
*
* Setter for the field length
.
@@ -226,6 +234,27 @@ public void setDiameter(double diameter) {
insideDiameter = diameter;
}
+ /**
+ *
+ * setThickness. + *
+ * + * @param pipeThickness the thickness to set + */ + public void setThickness(double pipeThickness) { + this.pipeThickness = pipeThickness; + } + + /** + *+ * getThickness. + *
+ * + * @return a double + */ + public double getThickness() { + return this.pipeThickness; + } /** *@@ -260,7 +289,6 @@ public void setNumberOfIncrements(int numberOfIncrements) { this.numberOfIncrements = numberOfIncrements; } - /** *
* Setter for the field runIsothermal
.
@@ -272,7 +300,6 @@ public void setRunIsothermal(boolean runIsothermal) {
this.runIsothermal = runIsothermal;
}
-
/**
* Converts the input values from the system measurement units to imperial units. Needed because
* the main equations and coefficients are developed for imperial system
@@ -318,10 +345,13 @@ public void convertSystemUnitToMetric() {
length = length / 3.2808399;
pipeWallRoughness = pipeWallRoughness / 3.2808399;
pressureDrop = pressureDrop * 1.48727E-05;
-
}
-
+ /**
+ *
+ * calculateMissingValue. + *
+ */ public void calculateMissingValue() { if (Double.isNaN(totalLength)) { totalLength = calculateLength(); @@ -335,18 +365,17 @@ public void calculateMissingValue() { new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue", "elevation", "- cannot be higher than length of the pipe" + length)); } - - if (Double.isNaN(totalElevation) || Double.isNaN(totalLength) || Double.isNaN(angle)) { + if (Double.isNaN(totalElevation) || Double.isNaN(totalLength) || Double.isNaN(angle) + || Double.isNaN(insideDiameter)) { throw new RuntimeException( new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue", - "elevation or length or angle", "cannot be null")); - } - + "elevation or length or angle or inlet diameter", "cannot be null")); + } } /** * Calculates the length based on the elevation and angle. - * + * * @return the calculated length. */ private double calculateLength() { @@ -354,9 +383,8 @@ private double calculateLength() { } /** - * * Calculates the elevation based on the length and angle. - * + * * @return the calculated elevation. */ private double calculateElevation() { @@ -364,9 +392,8 @@ private double calculateElevation() { } /** - * * Calculates the angle based on the length and elevation. - * + * * @return the calculated angle. */ private double calculateAngle() { @@ -374,8 +401,6 @@ private double calculateAngle() { } /** - * - * /** ** calcFlowRegime. *
@@ -393,13 +418,10 @@ public String calcFlowRegime() { } else { supLiquidVel = system.getPhase(1).getFlowRate("ft3/sec") / area; } + supGasVel = system.getPhase(0).getFlowRate("ft3/sec") / area; supMixVel = supLiquidVel + supGasVel; - liquidSuperficialVelocityProfile.add(supLiquidVel / 3.2808399); // to meters - gasSuperficialVelocityProfile.add(supGasVel / 3.2808399); - mixtureSuperficialVelocityProfile.add(supMixVel / 3.2808399); - mixtureFroudeNumber = Math.pow(supMixVel, 2) / (32.174 * insideDiameter); inputVolumeFractionLiquid = supLiquidVel / supMixVel; } else { @@ -416,6 +438,10 @@ public String calcFlowRegime() { } } + liquidSuperficialVelocityProfile.add(supLiquidVel / 3.2808399); // to meters + gasSuperficialVelocityProfile.add(supGasVel / 3.2808399); + mixtureSuperficialVelocityProfile.add(supMixVel / 3.2808399); + double L1 = 316 * Math.pow(inputVolumeFractionLiquid, 0.302); double L2 = 0.0009252 * Math.pow(inputVolumeFractionLiquid, -2.4684); double L3 = 0.1 * Math.pow(inputVolumeFractionLiquid, -1.4516); @@ -436,9 +462,12 @@ public String calcFlowRegime() { } else if (mixtureFroudeNumber > L2 && mixtureFroudeNumber < L3) { regime = "TRANSITION"; } else if (inputVolumeFractionLiquid < 0.1 || inputVolumeFractionLiquid > 0.9) { - regime = "Single Phase"; + regime = "INTERMITTENT"; + } else if (mixtureFroudeNumber > 110) { + regime = "INTERMITTENT"; } else { - logger.debug("Flow regime is not found"); + throw new RuntimeException(new neqsim.util.exception.InvalidOutputException( + "PipeBeggsAndBrills", "run: calcFlowRegime", "FlowRegime", "Flow regime is not found")); } } @@ -448,8 +477,6 @@ public String calcFlowRegime() { return regime; } - - /** ** calcHydrostaticPressureDifference @@ -485,7 +512,6 @@ public double calcHydrostaticPressureDifference() { } if (regime != "Single Phase") { - double SG; if (system.getNumberOfPhases() == 3) { mixtureOilMassFraction = system.getPhase(1).getFlowRate("kg/hr") @@ -504,7 +530,6 @@ public double calcHydrostaticPressureDifference() { SG = system.getPhase(1).getDensity("lb/ft3") / (1000 * 0.0624279606); } - double APIgrav = (141.5 / (SG)) - 131.0; double sigma68 = 39.0 - 0.2571 * APIgrav; double sigma100 = 37.5 - 0.2571 * APIgrav; @@ -581,31 +606,42 @@ public double calcFrictionPressureLoss() { if (system.getNumberOfPhases() != 1) { if (regime != "Single Phase") { - double y = Math.log(inputVolumeFractionLiquid / (Math.pow(El, 2))); - S = y / (-0.0523 + 3.18 * y - 0.872 * Math.pow(y, 2.0) + 0.01853 * Math.pow(y, 4)); + double y = inputVolumeFractionLiquid / (Math.pow(El, 2)); + if (1 < y && y < 1.2) { + S = Math.log(2.2 * y - 1.2); + } else { + S = Math.log(y) / (-0.0523 + 3.18 * Math.log(y) - 0.872 * Math.pow(Math.log(y), 2.0) + + 0.01853 * Math.pow(Math.log(y), 4)); + } if (system.getNumberOfPhases() == 3) { rhoNoSlip = mixtureLiquidDensity * inputVolumeFractionLiquid + (system.getPhase(0).getDensity("lb/ft3")) * (1 - inputVolumeFractionLiquid); muNoSlip = mixtureLiquidViscosity * inputVolumeFractionLiquid + (system.getPhase(0).getViscosity("cP")) * (1 - inputVolumeFractionLiquid); + liquidDensityProfile.add(mixtureLiquidDensity * 16.01846); + } else { + rhoNoSlip = (system.getPhase(1).getDensity("lb/ft3")) * inputVolumeFractionLiquid + + (system.getPhase(0).getDensity("lb/ft3")) * (1 - inputVolumeFractionLiquid); + muNoSlip = system.getPhase(1).getViscosity("cP") * inputVolumeFractionLiquid + + (system.getPhase(0).getViscosity("cP")) * (1 - inputVolumeFractionLiquid); + liquidDensityProfile.add((system.getPhase(1).getDensity("lb/ft3")) * 16.01846); } - rhoNoSlip = (system.getPhase(1).getDensity("lb/ft3")) * inputVolumeFractionLiquid - + (system.getPhase(0).getDensity("lb/ft3")) * (1 - inputVolumeFractionLiquid); - muNoSlip = system.getPhase(1).getViscosity("cP") * inputVolumeFractionLiquid - + (system.getPhase(0).getViscosity("cP")) * (1 - inputVolumeFractionLiquid); } else { rhoNoSlip = (system.getPhase(1).getDensity("lb/ft3")) * inputVolumeFractionLiquid + (system.getPhase(0).getDensity("lb/ft3")) * (1 - inputVolumeFractionLiquid); muNoSlip = system.getPhase(1).getViscosity("cP") * inputVolumeFractionLiquid + (system.getPhase(0).getViscosity("cP")) * (1 - inputVolumeFractionLiquid); + liquidDensityProfile.add((system.getPhase(1).getDensity("lb/ft3")) * 16.01846); } } else { if (system.hasPhaseType("gas")) { rhoNoSlip = (system.getPhase(0).getDensity("lb/ft3")); muNoSlip = (system.getPhase(0).getViscosity("cP")); + liquidDensityProfile.add(0.0); } else { rhoNoSlip = (system.getPhase(1).getDensity("lb/ft3")); muNoSlip = (system.getPhase(1).getViscosity("cP")); + liquidDensityProfile.add(rhoNoSlip * 16.01846); } } @@ -637,17 +673,21 @@ public double calcFrictionPressureLoss() { */ public double calcPressureDrop() { convertSystemUnitToImperial(); + regime = "unknown"; calcFlowRegime(); hydrostaticPressureDrop = calcHydrostaticPressureDifference(); frictionPressureLoss = calcFrictionPressureLoss(); pressureDrop = (hydrostaticPressureDrop + frictionPressureLoss); convertSystemUnitToMetric(); + iteration = iteration + 1; return pressureDrop; } /** {@inheritDoc} */ @Override public void run(UUID id) { + iteration = 0; + pressureProfile = new ArrayList<>(); temperatureProfile = new ArrayList<>(); @@ -660,11 +700,13 @@ public void run(UUID id) { mixtureViscosityProfile = new ArrayList<>(); mixtureDensityProfile = new ArrayList<>(); + liquidDensityProfile = new ArrayList<>(); liquidHoldupProfile = new ArrayList<>(); mixtureReynoldsNumber = new ArrayList<>(); lengthProfile = new ArrayList<>(); elevationProfile = new ArrayList<>(); + incrementsProfile = new ArrayList<>(); calculateMissingValue(); double enthalpyInlet = Double.NaN; @@ -675,18 +717,22 @@ public void run(UUID id) { testOps.TPflash(); system.initProperties(); - if (!runIsothermal){ + if (!runIsothermal) { enthalpyInlet = system.getEnthalpy(); } double pipeInletPressure = system.getPressure(); cumulativeLength = 0.0; cumulativeElevation = 0.0; + pressureProfile.add(system.getPressure()); // pressure at segment 0 + temperatureProfile.add(system.getTemperature()); // temperature at segment 0 + pressureDropProfile.add(0.0); // DP at segment 0 for (int i = 1; i <= numberOfIncrements; i++) { - cumulativeLength += length; - cumulativeElevation += elevation; - lengthProfile.add(cumulativeLength); elevationProfile.add(cumulativeElevation); + incrementsProfile.add(i - 1); + + cumulativeLength += length; + cumulativeElevation += elevation; inletPressure = system.getPressure(); pressureDrop = calcPressureDrop(); @@ -694,23 +740,43 @@ public void run(UUID id) { pressureOut = inletPressure - pressureDrop; pressureProfile.add(pressureOut); if (pressureOut < 0) { - throw new RuntimeException(new neqsim.util.exception.InvalidInputException( + throw new RuntimeException(new neqsim.util.exception.InvalidOutputException( "PipeBeggsAndBrills", "run: calcOutletPressure", "pressure out", "- Outlet pressure is negative" + pressureOut)); } system.setPressure(pressureOut); - if (!runIsothermal){ + if (!runIsothermal) { testOps.PHflash(enthalpyInlet); + } else { + testOps.TPflash(); } system.initProperties(); temperatureProfile.add(system.getTemperature()); } totalPressureDrop = pipeInletPressure - system.getPressure(); + calcPressureDrop(); // to initialize final parameters + lengthProfile.add(cumulativeLength); + elevationProfile.add(cumulativeElevation); + incrementsProfile.add(getNumberOfIncrements()); + outStream.setThermoSystem(system); outStream.setCalculationIdentifier(id); } + /** + * {@inheritDoc} + * + *
+ * runTransient. + *
+ */ + @Override + public void runTransient(double dt, UUID id) { + run(id); + increaseTime(dt); + } + /** {@inheritDoc} */ @Override public void displayResult() { @@ -719,42 +785,72 @@ public void displayResult() { /** *- * getSuperficialVelocity. + * getInletSuperficialVelocity. *
* * @return a double */ - public double getSuperficialVelocity() { + public double getInletSuperficialVelocity() { return getInletStream().getThermoSystem().getFlowRate("kg/sec") / getInletStream().getThermoSystem().getDensity("kg/m3") / (Math.PI / 4.0 * Math.pow(insideDiameter, 2.0)); } + /** + *+ * getOutletSuperficialVelocity. + *
+ * + * @return a double + */ + public double getOutletSuperficialVelocity() { + return getSegmentMixtureSuperficialVelocity(numberOfIncrements); + } + + /** + *+ * getNumberOfIncrements + *
+ * + * @return a double + */ + public int getNumberOfIncrements() { + return numberOfIncrements; + } /** + *
+ * Getter for the field angle
.
+ *
+ * Getter for the field length
.
+ *
+ * Getter for the field elevation
.
+ *
* getDiameter. @@ -777,7 +873,6 @@ public String getFlowRegime() { return regime; } - /** *
* Getter for the field LastSegmentPressureDrop
.
@@ -800,7 +895,6 @@ public double getPressureDrop() {
return totalPressureDrop;
}
-
/**
*
* Getter for the field
* getSegmentPressure
@@ -823,280 +915,370 @@ public List
+ * getSegmentPressureDrop.
+ *
+ * Getter for the field
+ * getSegmentTemperature.
+ *
+ * Getter for the field
+ * getSegmentFlowRegime.
+ *
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * Getter for the field
+ * getSegmentLiquidSuperficialVelocity.
+ *
+ * getSegmentGasSuperficialVelocity.
+ *
+ * getSegmentMixtureSuperficialVelocity.
+ *
+ * getSegmentMixtureViscosity.
+ *
+ * getSegmentMixtureDensity.
+ *
+ * getSegmentLiquidDensity.
+ *
+ * getSegmentLiquidHoldup.
+ *
+ * getSegmentMixtureReynoldsNumber.
+ *
+ * getSegmentLength.
+ *
+ * getSegmentElevation.
+ * PressureProfile
.
@@ -812,8 +906,6 @@ public ListtemperatureProfile
.
+ * flowRegimeProfile
.
+ * liquidSuperficialVelocityProfile
.
+ * gasSuperficialVelocityProfile
.
+ * mixtureSuperficialVelocityProfile
.
+ * mixtureViscosityProfile
.
+ * mixtureDensityProfile
.
+ * liquidDensityProfile
.
+ * liquidHoldupProfile
.
+ * mixtureReynoldsNumber
.
+ * lengthProfile
.
+ * incrementsProfile
.
+ * elevationProfile
.
+ *
- * Constructor for Pipeline. - *
- */ - @Deprecated - public Pipeline() { - this("Pipeline"); - } - - /** - *- * Constructor for Pipeline. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Pipeline(StreamInterface inStream) { - this("Pipeline", inStream); - } - /** ** Constructor for Pipeline. @@ -95,18 +72,13 @@ public Pipeline(String name, StreamInterface inStream) { super(name, inStream); } + /** {@inheritDoc} */ @Override public void initMechanicalDesign() { pipelineMechanicalDesign = new PipelineMechanicalDesign(this); } - - /** - * {@inheritDoc} - * - * @return a {@link neqsim.processSimulation.mechanicalDesign.pipeline.PipelineMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public PipelineMechanicalDesign getMechanicalDesign() { return pipelineMechanicalDesign; @@ -171,7 +143,7 @@ public void setPipeDiameters(double[] diameter) { * setPipeOuterHeatTransferCoefficients. *
* - * @param heatCoefs an array of {@link double} objects + * @param heatCoefs an array of type double */ public void setPipeOuterHeatTransferCoefficients(double[] heatCoefs) { if (heatCoefs.length != this.numberOfLegs + 1) { @@ -188,7 +160,7 @@ public void setPipeOuterHeatTransferCoefficients(double[] heatCoefs) { * setPipeWallHeatTransferCoefficients. * * - * @param heatCoefs an array of {@link double} objects + * @param heatCoefs an array of type double */ public void setPipeWallHeatTransferCoefficients(double[] heatCoefs) { if (heatCoefs.length != this.numberOfLegs + 1) { @@ -249,7 +221,7 @@ public void setEquilibriumHeatTransfer(boolean test) { /** {@inheritDoc} */ @Override public void run(UUID id) { - system = inStream.getThermoSystem(); + system = inStream.getThermoSystem().clone(); GeometryDefinitionInterface[] pipeGemometry = new PipeData[numberOfLegs + 1]; for (int i = 0; i < pipeDiameters.length; i++) { pipeGemometry[i] = new PipeData(pipeDiameters[i], pipeWallRoughness[i]); @@ -344,4 +316,16 @@ public double getEntropyProduction(String unit) { return outStream.getThermoSystem().getEntropy(unit) - inStream.getThermoSystem().getEntropy(unit); } + + /** + *+ * getOutletPressure. + *
+ * + * @param unit a {@link java.lang.String} object + * @return a double + */ + public double getOutletPressure(String unit) { + return outStream.getPressure(unit); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java index 56700b0527..21eff3508d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/SimpleTPoutPipeline.java @@ -17,30 +17,10 @@ public class SimpleTPoutPipeline extends Pipeline { private static final long serialVersionUID = 1000; boolean setTemperature = false; - protected double temperatureOut = 0, pressureOut = 0.0; + protected double temperatureOut = 0; + protected double pressureOut = 0.0; double dH = 0.0; - /** - *- * Constructor for SimpleTPoutPipeline. - *
- */ - @Deprecated - public SimpleTPoutPipeline() {} - - /** - *- * Constructor for SimpleTPoutPipeline. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleTPoutPipeline(StreamInterface inStream) { - this("SimpleTPoutPipeline", inStream); - } - /** * Constructor for SimpleTPoutPipeline. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java index 97905983eb..14e85b137b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/TwoPhasePipeLine.java @@ -21,28 +21,6 @@ public class TwoPhasePipeLine extends Pipeline { private static final long serialVersionUID = 1000; - /** - *- * Constructor for TwoPhasePipeLine. - *
- */ - @Deprecated - public TwoPhasePipeLine() { - this("TwoPhasePipeLine"); - } - - /** - *- * Constructor for TwoPhasePipeLine. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public TwoPhasePipeLine(StreamInterface inStream) { - this("TwoPhasePipeLine", inStream); - } - /** * Constructor for TwoPhasePipeLine. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java b/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java index 09f1fb903a..5c99d466a8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbine.java @@ -11,6 +11,7 @@ import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; /** @@ -59,25 +60,11 @@ public GasTurbine(String name) { airThermoSystem.createDatabase(true); // airThermoSystem.display(); airStream = new Stream("airStream", airThermoSystem); - airStream.setPressure(1.01325); + airStream.setPressure(ThermodynamicConstantsInterface.referencePressure); airStream.setTemperature(288.15, "K"); airCompressor = new Compressor("airCompressor", airStream); } - /** - *- * Constructor for GasTurbine. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public GasTurbine(StreamInterface inletStream) { - this(); - setInletStream(inletStream); - } - /** *
* Constructor for GasTurbine.
@@ -91,13 +78,7 @@ public GasTurbine(String name, StreamInterface inletStream) {
super(name, inletStream);
}
- /**
- * {@inheritDoc}
- *
- * @return a
- * {@link neqsim.processSimulation.mechanicalDesign.compressor.CompressorMechanicalDesign}
- * object
- */
+ /** {@inheritDoc} */
@Override
public CompressorMechanicalDesign getMechanicalDesign() {
return new CompressorMechanicalDesign(this);
@@ -132,6 +113,7 @@ public double getPower() {
* Setter for the field inletStream
.
*
- * calcIdealAirGasRatio + * Calculates ideal air fuel ratio [kg air/kg fuel]. *
- * Calculates ideal air fuel ratio [kg air/kg fuel] + * + * @return ideal air fuel ratio [kg air/kg fuel] */ public double calcIdealAirFuelRatio() { thermoSystem = inStream.getThermoSystem().clone(); @@ -220,8 +201,8 @@ public double calcIdealAirFuelRatio() { elementsH += thermoSystem.getComponent(i).getz() * thermoSystem.getComponent(i).getElements().getNumberOfElements("H"); } - } + if (sumHC < 1e-100) { return 0.0; } else { @@ -235,5 +216,4 @@ public double calcIdealAirFuelRatio() { double AFR = A * (32.0 + 3.76 * 28.0) / 1000.0 / molMassHC * wtFracHC; return AFR; } - } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java b/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java index 02ce2e55b4..2c62a55b78 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pump/Pump.java @@ -9,8 +9,10 @@ import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; +import com.google.gson.GsonBuilder; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.PumpResponse; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -40,30 +42,6 @@ public class Pump extends TwoPortEquipment implements PumpInterface { private String pressureUnit = "bara"; private PumpChart pumpChart = new PumpChart(); - /** - *- * Constructor for Pump. - *
- */ - @Deprecated - public Pump() { - super("Pump"); - } - - /** - *- * Constructor for Pump. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Pump(StreamInterface inletStream) { - this(); - setInletStream(inletStream); - } - /** * Constructor for Pump. * @@ -86,13 +64,6 @@ public Pump(String name, StreamInterface inletStream) { super(name, inletStream); } - /** {@inheritDoc} */ - @Override - public void setInletStream(StreamInterface stream) { - this.inStream = stream; - this.outStream = stream.clone(); - } - /** {@inheritDoc} */ @Override public void setOutletPressure(double pressure) { @@ -169,7 +140,7 @@ public void run(UUID id) { thermoOps.TPflash(); thermoSystem.init(3); } else { - if (calculateAsCompressor) { + if (!pumpChart.isUsePumpChart() && calculateAsCompressor) { thermoSystem = inStream.getThermoSystem().clone(); thermoSystem.setPressure(pressure, pressureUnit); // System.out.println("entropy inn.." + entropy); @@ -185,6 +156,7 @@ public void run(UUID id) { thermoOps = new ThermodynamicOperations(getThermoSystem()); thermoOps.PHflash(hout, 0); } else if (pumpChart.isUsePumpChart()) { + thermoSystem = inStream.getThermoSystem().clone(); double pumpHead = 0.0; pumpHead = getPumpChart().getHead(thermoSystem.getFlowRate("m3/hr"), getSpeed()); isentropicEfficiency = @@ -424,6 +396,19 @@ public void setPressure(double pressure, String unit) { pressureUnit = unit; } + /** + *
+ * Setter for the field pressure
.
+ *
* Setter for the field speed
.
@@ -456,4 +441,11 @@ public double getSpeed() {
public PumpChart getPumpChart() {
return pumpChart;
}
+
+ /** {@inheritDoc} */
+ @Override
+ public String toJson() {
+ return new GsonBuilder().serializeSpecialFloatingPointValues().create()
+ .toJson(new PumpResponse(this));
+ }
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpChartInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpChartInterface.java
index efe3d72ec4..9123c23cc2 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpChartInterface.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpChartInterface.java
@@ -13,20 +13,20 @@ public interface PumpChartInterface extends Cloneable {
* This method is used add a curve to the CompressorChart object.
*
* @param speed a double
- * @param flow an array of {@link double} objects
- * @param head an array of {@link double} objects
- * @param efficiency an array of {@link double} objects
+ * @param flow an array of type double
+ * @param head an array of type double
+ * @param efficiency an array of type double
*/
public void addCurve(double speed, double[] flow, double[] head, double[] efficiency);
/**
* This method is used add a set of curves to the CompressorChart object.
*
- * @param chartConditions an array of {@link double} objects
- * @param speed an array of {@link double} objects
- * @param flow an array of {@link double} objects
- * @param head an array of {@link double} objects
- * @param polyEff an array of {@link double} objects
+ * @param chartConditions an array of type double
+ * @param speed an array of type double
+ * @param flow an array of type double
+ * @param head an array of type double
+ * @param polyEff an array of type double
*/
public void setCurves(double[] chartConditions, double[] speed, double[][] flow, double[][] head,
double[][] polyEff);
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpCurve.java b/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpCurve.java
index dc209a04d4..3d5d364bde 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpCurve.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/pump/PumpCurve.java
@@ -32,9 +32,9 @@ public PumpCurve() {
*
+ * ReservoirCVDsim class. + *
+ * + * @author Even Solbraa + * @version $Id: ReservoirCVDsim.java 1234 2024-05-31 10:00:00Z esolbraa $ + */ +public class ReservoirCVDsim extends ProcessEquipmentBaseClass { + private static final long serialVersionUID = 1000; + + /** + *+ * Constructor for ReservoirCVDsim. + *
+ * + * @param name a {@link java.lang.String} object + * @param reservoirFluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public ReservoirCVDsim(String name, SystemInterface reservoirFluid) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) {} +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirDiffLibsim.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirDiffLibsim.java new file mode 100644 index 0000000000..18037be550 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirDiffLibsim.java @@ -0,0 +1,33 @@ +package neqsim.processSimulation.processEquipment.reservoir; + +import java.util.UUID; +import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.thermo.system.SystemInterface; + +/** + *+ * ReservoirDiffLibsim class. + *
+ * + * @author Even Solbraa + * @version $Id: ReservoirDiffLibsim.java 1234 2024-05-31 10:00:00Z esolbraa $ + */ +public class ReservoirDiffLibsim extends ProcessEquipmentBaseClass { + private static final long serialVersionUID = 1000; + + /** + *+ * Constructor for ReservoirDiffLibsim. + *
+ * + * @param name a {@link java.lang.String} object + * @param reservoirFluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public ReservoirDiffLibsim(String name, SystemInterface reservoirFluid) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) {} +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirTPsim.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirTPsim.java new file mode 100644 index 0000000000..4829206a64 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirTPsim.java @@ -0,0 +1,149 @@ +package neqsim.processSimulation.processEquipment.reservoir; + +import java.util.UUID; +import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + *+ * ReservoirTPsim class. + *
+ * + * @author Even Solbraa + * @version $Id: ReservoirTPsim.java 1234 2024-05-31 10:00:00Z esolbraa $ + */ +public class ReservoirTPsim extends ProcessEquipmentBaseClass { + private static final long serialVersionUID = 1000; + + private SystemInterface reservoirFluid = null; + private StreamInterface outStream = null; + + private double pressure = 100.0; + private double temperature = 100.0; + private double flowRate = 100.0; + private String flowUnit = "kg/hr"; + private String tUnit = "K"; + private String pUnit = "bar"; + + private String prodPhaseName = "gas"; + + /** + *+ * getReserervourFluid. + *
+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getReserervourFluid() { + return reservoirFluid; + } + + /** + *+ * Constructor for ReservoirTPsim. + *
+ * + * @param name a {@link java.lang.String} object + * @param reservoirFluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public ReservoirTPsim(String name, SystemInterface reservoirFluid) { + super(name); + this.reservoirFluid = reservoirFluid; + outStream = new Stream(getName() + "_out", reservoirFluid.clone()); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface fluid1 = ((SystemInterface) reservoirFluid).clone(); + fluid1.setTemperature(temperature, tUnit); + fluid1.setPressure(pressure, pUnit); + fluid1.setTotalFlowRate(flowRate, flowUnit); + + ThermodynamicOperations operations = new ThermodynamicOperations(fluid1); + operations.TPflash(); + + if (prodPhaseName.equals("gas") && fluid1.hasPhaseType("gas")) { + outStream.setFluid(fluid1.phaseToSystem("gas")); + } else if (prodPhaseName.equals("oil") && fluid1.hasPhaseType("oil")) { + outStream.setFluid(fluid1.phaseToSystem("oil")); + } else { + outStream.setFluid(fluid1.phaseToSystem(1)); + } + } + + /** + *
+ * Getter for the field outStream
.
+ *
+ * Setter for the field pressure
.
+ *
+ * Setter for the field temperature
.
+ *
+ * Getter for the field prodPhaseName
.
+ *
+ * Setter for the field prodPhaseName
.
+ *
+ * Setter for the field flowRate
.
+ *
@@ -48,16 +50,6 @@ public class SimpleReservoir extends ProcessEquipmentBaseClass { double reservoirVolume = 0.0; double lowPressureLimit = 50.0; - /** - *
- * Constructor for SimpleReservoir. - *
- */ - @Deprecated - public SimpleReservoir() { - this("SimpleReservoir"); - } - /** ** Constructor for SimpleReservoir. @@ -82,9 +74,7 @@ public SystemInterface getReservoirFluid() { /* * public StreamInterface getGasOutStream() { return gasOutStream; } - * - * - * + * * public StreamInterface getOilOutStream() { return oilOutStream; } */ @@ -190,7 +180,7 @@ public StreamInterface addGasInjector(String name) { public double getGasInPlace(String unit) { SystemInterface locStream = (thermoSystem).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); locStream.initProperties(); @@ -215,7 +205,7 @@ public double getGasInPlace(String unit) { public double getOilInPlace(String unit) { SystemInterface locStream = (thermoSystem).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); locStream.initProperties(); @@ -323,66 +313,41 @@ public void setReservoirFluid(SystemInterface thermoSystem, double gasVolume, do this.gasVolume = gasVolume; this.waterVolume = waterVolume; - if (gasVolume > 1e-10 && oilVolume > 1e-10) { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + + if (waterVolume > 1e-10 && !thermoSystem.hasPhaseType("aqueous")) { + thermoSystem.addComponent("water", thermoSystem.getTotalNumberOfMoles()); ops.TPflash(); - thermoSystem.initProperties(); - SystemInterface thermoSystem2 = thermoSystem.clone(); - thermoSystem.setEmptyFluid(); - for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { - double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - if (j >= 1) { - if (j == 1) { - relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); - } else if (j == 2) { - relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - // totalliquidVolume += waterVolume / - // thermoSystem2.getPhase(j).getMolarVolume(); - } - } - for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { - thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); - } + } + + thermoSystem.initProperties(); + SystemInterface thermoSystem2 = thermoSystem.clone(); + thermoSystem.setEmptyFluid(); + for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { + String phaseType = thermoSystem.getPhase(j).getPhaseTypeName(); + double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + if (phaseType.equals("oil")) { + relFact = oilVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + // totalliquidVolume += oilVolume / thermoSystem2.getPhase(j).getMolarVolume(); + } else if (phaseType.equals("aqueous")) { + relFact = waterVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); + } else { + relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); } - } else { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); - ops.TPflash(); - thermoSystem.initProperties(); - SystemInterface thermoSystem2 = thermoSystem.clone(); - thermoSystem.setEmptyFluid(); - double relFact = (gasVolume + oilVolume) / (thermoSystem2.getPhase("oil").getVolume("m3")); - for (int i = 0; i < thermoSystem.getNumberOfComponents(); i++) { - thermoSystem.addComponent(thermoSystem.getComponent(i).getComponentNumber(), - relFact * thermoSystem2.getComponent(i).getNumberOfMolesInPhase()); + for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { + thermoSystem.addComponent(thermoSystem.getPhase(j).getComponent(i).getComponentNumber(), + relFact * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); } - double relFactWater = (waterVolume) / (thermoSystem2.getPhase("aqueous").getVolume("m3")); - thermoSystem.addComponent("water", relFactWater - * thermoSystem2.getPhase("aqueous").getComponent("water").getNumberOfMolesInPhase()); } - /* - * if (thermoSystem.hasPhaseType("gas")) { thermoSystem.setBeta(gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() / (gasVolume / - * thermoSystem2.getPhase(0).getMolarVolume() + oilVolume / - * thermoSystem2.getPhase(1).getMolarVolume())); } - */ ThermodynamicOperations ops2 = new ThermodynamicOperations(thermoSystem); ops2.TPflash(); thermoSystem.initProperties(); - // thermoSystem.display(); - // gasOutStream = new Stream(); - // gasOutStream.setFluid(thermoSystem.phaseToSystem("gas")); reservoirVolume = gasVolume + oilVolume + waterVolume; - OOIP = - - getOilInPlace("Sm3"); + OOIP = getOilInPlace("Sm3"); OGIP = getGasInPlace("Sm3"); - // oilOutStream = new Stream(); - // oilOutStream.setFluid(thermoSystem.phaseToSystem("oil")); - lowPressureLimit = 50.0; } @@ -847,14 +812,35 @@ public double getOGIP(String unit) { return OGIP; } + /** {@inheritDoc} */ + @Override + public double getTime() { + return time; + } + /** *
- * Getter for the field time
.
+ * Setter for the field lowPressureLimit
.
*
+ * Getter for the field lowPressureLimit
.
+ *
- * Constructor for Well. - *
- * - * @deprecated use {@link #Well(String)} instead - */ - @Deprecated - public Well() { - this("Well"); - } + double x; + double y; + double z; /** *@@ -74,7 +65,7 @@ public void setStream(StreamInterface stream) { public double getGOR() { SystemInterface locStream = (stream.getFluid()).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); double GOR = Double.NaN; @@ -94,7 +85,7 @@ public double getGOR() { public double getStdGasProduction() { SystemInterface locStream = (stream.getFluid()).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); double volume = 0; @@ -114,7 +105,7 @@ public double getStdGasProduction() { public double getStdOilProduction() { SystemInterface locStream = (stream.getFluid()).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); double volume = 0; @@ -134,7 +125,7 @@ public double getStdOilProduction() { public double getStdWaterProduction() { SystemInterface locStream = (stream.getFluid()).clone(); locStream.setTemperature(288.15); - locStream.setPressure(1.01325); + locStream.setPressure(ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations ops = new ThermodynamicOperations(locStream); ops.TPflash(); double volume = 0; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java index b6a438c12d..2ab8e994cf 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/WellFlow.java @@ -1,5 +1,12 @@ package neqsim.processSimulation.processEquipment.reservoir; +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.valve.ThrottlingValve; +import neqsim.thermo.system.SystemInterface; + /** *
* WellFlow class. @@ -8,5 +15,96 @@ * @author asmund * @version $Id: $Id */ -public class WellFlow { +public class WellFlow extends TwoPortEquipment { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ThrottlingValve.class); + SystemInterface thermoSystem; + private double wellProductionIndex = 0; + double pressureOut = 1.0; + String pressureUnit = "bara"; + boolean useWellProductionIndex = false; + boolean calcpressure = true; + + /** + *
+ * Constructor for WellFlow. + *
+ * + * @param name a {@link java.lang.String} object + */ + public WellFlow(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + thermoSystem = getInletStream().getThermoSystem().clone(); + thermoSystem.setPressure(pressureOut, pressureUnit); + outStream.setThermoSystem(thermoSystem); + if (useWellProductionIndex) { + if (calcpressure) { + double presout = 1.0; + if (Math.pow(getInletStream().getPressure("bara"), 2.0) + - getInletStream().getFlowRate("MSm3/day") / wellProductionIndex > 0) { + presout = Math.sqrt(Math.pow(getInletStream().getPressure("bara"), 2.0) + - getInletStream().getFlowRate("MSm3/day") / wellProductionIndex); + } else { + logger.error("pressure lower that 0"); + throw new RuntimeException( + new neqsim.util.exception.InvalidInputException("WellFlow", "run: calcOutletPressure", + "pressure", "- Outlet pressure is negative" + pressureOut)); + } + // System.out.println("out pres " + presout); + outStream.setPressure(presout, "bara"); + } else { + double flow = wellProductionIndex * (Math.pow(getInletStream().getPressure("bara"), 2.0) + - Math.pow(thermoSystem.getPressure("bara"), 2.0)); + outStream.setFlowRate(flow, "MSm3/day"); + } + } else { + wellProductionIndex = getInletStream().getFlowRate("MSm3/day") + / (Math.pow(getInletStream().getPressure("bara"), 2.0) + - Math.pow(thermoSystem.getPressure("bara"), 2.0)); + } + outStream.run(); + } + + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + if (getCalculateSteadyState()) { + run(id); + increaseTime(dt); + return; + } + double flow = wellProductionIndex * (Math.pow(getInletStream().getPressure("bara"), 2.0) + - Math.pow(thermoSystem.getPressure("bara"), 2.0)); + + outStream.setFlowRate(flow, "MSm3/day"); + outStream.run(); + } + + /** + *
+ * Getter for the field wellProductionIndex
.
+ *
+ * Setter for the field wellProductionIndex
.
+ *
@@ -25,40 +20,6 @@
public class GasScrubber extends Separator {
private static final long serialVersionUID = 1000;
- SystemInterface thermoSystem;
-
- SystemInterface gasSystem;
- SystemInterface waterSystem;
- SystemInterface liquidSystem;
- SystemInterface thermoSystemCloned;
-
- ArrayList
- * Constructor for GasScrubber.
- *
- * Constructor for GasScrubber.
- *
- * Setter for the field
- * addScrubberSection.
- *
- * Constructor for GasScrubberSimple.
- *
- * Constructor for GasScrubberSimple.
- * inletStream
.
- * inletStream
.
*
- * Constructor for Hydrocyclone. - *
- */ - @Deprecated - public Hydrocyclone() { - this("Hydrocyclone"); - } - - /** - *- * Constructor for Hydrocyclone. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Hydrocyclone(StreamInterface inletStream) { - this("Hydrocyclone", inletStream); - } - /** * Constructor for Hydrocyclone. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java index 75b8e212f8..c16e85a580 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/NeqGasScrubber.java @@ -32,29 +32,6 @@ public class NeqGasScrubber extends Separator { ArrayList- * Constructor for NeqGasScrubber. - *
- */ - @Deprecated - public NeqGasScrubber() { - this("NeqGasScrubber"); - } - - /** - *- * Constructor for NeqGasScrubber. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public NeqGasScrubber(StreamInterface inletStream) { - this("NeqGasScrubber", inletStream); - } - /** * Constructor for NeqGasScrubber. * @@ -79,13 +56,7 @@ public NeqGasScrubber(String name, StreamInterface inletStream) { this.setOrientation("vertical"); } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public GasScrubberMechanicalDesign getMechanicalDesign() { return new GasScrubberMechanicalDesign(this); @@ -98,6 +69,7 @@ public GasScrubberMechanicalDesign getMechanicalDesign() { * Setter for the fieldinletStream
.
*
*/
+ @Override
public void setInletStream(StreamInterface inletStream) {
this.inletStream = inletStream;
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
index e3ababd76a..4e3e322e15 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java
@@ -11,6 +11,7 @@
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import com.google.gson.GsonBuilder;
import neqsim.processSimulation.mechanicalDesign.separator.SeparatorMechanicalDesign;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.mixer.Mixer;
@@ -21,6 +22,7 @@
import neqsim.processSimulation.processEquipment.separator.sectionType.ValveSection;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
+import neqsim.processSimulation.util.monitor.SeparatorResponse;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
@@ -60,36 +62,17 @@ public class Separator extends ProcessEquipmentBaseClass implements SeparatorInt
/** Inner diameter/height of separator volume. */
private double internalDiameter = 1.0;
- double liquidVolume = 1.0;
- double gasVolume = 18.0;
-
/** LiquidLevel as volume fraction of liquidvolume/(liquid + gas volume). */
- private double liquidLevel = liquidVolume / (liquidVolume + gasVolume);
+ private double liquidLevel = 0.5;
+ double liquidVolume =
+ Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * liquidLevel;
+ double gasVolume =
+ Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * (1.0 - liquidLevel);
private double designLiquidLevelFraction = 0.8;
ArrayList
* Getter for the field liquidLevel
.
@@ -499,7 +514,7 @@ public void setInternalDiameter(double diameter) {
* @return a double
*/
public double getGasSuperficialVelocity() {
- return thermoSystem.getPhase(0).getTotalVolume() / 1e5
+ return thermoSystem.getPhase(0).getVolume("m3")
/ (neqsim.thermo.ThermodynamicConstantsInterface.pi * getInternalDiameter()
* getInternalDiameter() / 4.0);
}
@@ -554,7 +569,7 @@ public double getDeRatedGasLoadFactor() {
if (surfaceTension < 10.0e-3) {
derating = 1.0 - 0.5 * (10.0e-3 - surfaceTension) / 10.0e-3;
}
- System.out.println("derating " + derating);
+ // System.out.println("derating " + derating);
double term1 = (thermoSystem.getPhase(1).getPhysicalProperties().getDensity()
- thermoSystem.getPhase(0).getPhysicalProperties().getDensity())
/ thermoSystem.getPhase(0).getPhysicalProperties().getDensity();
@@ -577,7 +592,7 @@ public double getDeRatedGasLoadFactor(int phase) {
if (surfaceTension < 10.0e-3) {
derating = 1.0 - 0.5 * (10.0e-3 - surfaceTension) / 10.0e-3;
}
- System.out.println("derating " + derating);
+ // System.out.println("derating " + derating);
double term1 = (thermoSystem.getPhase(phase).getPhysicalProperties().getDensity()
- thermoSystem.getPhase(0).getPhysicalProperties().getDensity())
/ thermoSystem.getPhase(0).getPhysicalProperties().getDensity();
@@ -658,7 +673,7 @@ public SeparatorSection getSeparatorSection(String name) {
return sec;
}
}
- System.out.println("no section with name: " + name + " found.....");
+ // System.out.println("no section with name: " + name + " found.....");
return null;
}
@@ -830,10 +845,27 @@ public boolean equals(Object obj) {
&& Objects.equals(waterSystem, other.waterSystem);
}
+ /**
+ *
+ * getFeedStream. + *
+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getFeedStream() { + return inletStreamMixer.getOutletStream(); + } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new SeparatorResponse(this)); + } + /* * private class SeparatorReport extends Object{ public Double gasLoadFactor; SeparatorReport(){ * gasLoadFactor = getGasLoadFactor(); } } - * + * * public SeparatorReport getReport(){ return this.new SeparatorReport(); } */ } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java index 39982d1a6c..c0024e5c4e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/SeparatorInterface.java @@ -35,4 +35,13 @@ public interface SeparatorInterface extends SimulationInterface { * @param diam a double */ public void setInternalDiameter(double diam); + + /** + *
+ * Setter for the field liquidLevel
.
+ *
- * Constructor for ThreePhaseSeparator. - *
- */ - @Deprecated - public ThreePhaseSeparator() { - this("ThreePhaseSeparator"); - } - - /** - *- * Constructor for ThreePhaseSeparator. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ThreePhaseSeparator(StreamInterface inletStream) { - this("ThreePhaseSeparator", inletStream); - } + boolean useTempMultiPhaseCheck = false; /** * Constructor for ThreePhaseSeparator. @@ -160,9 +141,15 @@ public void run(UUID id) { inletStreamMixer.run(id); thermoSystem = inletStreamMixer.getOutletStream().getThermoSystem().clone(); - thermoSystem.setMultiPhaseCheck(true); + if (!thermoSystem.doMultiPhaseCheck()) { + useTempMultiPhaseCheck = true; + thermoSystem.setMultiPhaseCheck(true); + } ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoOps.TPflash(); + if (useTempMultiPhaseCheck) { + thermoSystem.setMultiPhaseCheck(false); + } // thermoSystem.display(); thermoSystem.addPhaseFractionToPhase(gasInAqueous, gasInAqueousSpec, specifiedStream, "gas", "aqueous"); @@ -267,4 +254,10 @@ public double getExergyChange(String unit, double surroundingTemperature) { + getOilOutStream().getThermoSystem().getEntropy(unit) + getGasOutStream().getThermoSystem().getExergy(surroundingTemperature, unit) - entrop; } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new SeparatorResponse(this)); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java index 2e9322855c..4dffd02154 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/TwoPhaseSeparator.java @@ -27,29 +27,6 @@ public class TwoPhaseSeparator extends Separator { StreamInterface gasOutStream; StreamInterface liquidOutStream; - /** - *- * Constructor for TwoPhaseSeparator. - *
- */ - @Deprecated - public TwoPhaseSeparator() { - this("TwoPhaseSeparator"); - } - - /** - *- * Constructor for TwoPhaseSeparator. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public TwoPhaseSeparator(StreamInterface inletStream) { - this("TwoPhaseSeparator", inletStream); - } - /** * Constructor for TwoPhaseSeparator. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ManwaySection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ManwaySection.java index dbe8175d1a..0a5b15e854 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ManwaySection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ManwaySection.java @@ -27,13 +27,7 @@ public ManwaySection(String name, String type, Separator sep) { super(name, type, sep); } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.separator.sectionType.MechManwaySection} - * object - */ + /** {@inheritDoc} */ @Override public MechManwaySection getMechanicalDesign() { return new MechManwaySection(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java index 69c90b5213..e330691054 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/MeshSection.java @@ -27,11 +27,7 @@ public MeshSection(String name, String type, Separator sep) { super(name, type, sep); } - /** - * {@inheritDoc} - * - * @return MecMeshSection - */ + /** {@inheritDoc} */ @Override public MecMeshSection getMechanicalDesign() { return new MecMeshSection(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/NozzleSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/NozzleSection.java index e69d3d7a85..3483ec3aef 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/NozzleSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/NozzleSection.java @@ -27,13 +27,7 @@ public NozzleSection(String name, String type, Separator sep) { super(name, type, sep); } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.separator.sectionType.MechNozzleSection} - * object - */ + /** {@inheritDoc} */ @Override public MechNozzleSection getMechanicalDesign() { return new MechNozzleSection(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ValveSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ValveSection.java index 2e199ca34f..847313429f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ValveSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/ValveSection.java @@ -27,13 +27,7 @@ public ValveSection(String name, String type, Separator sep) { super(name, type, sep); } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.separator.sectionType.DistillationTraySection} - * object - */ + /** {@inheritDoc} */ @Override public DistillationTraySection getMechanicalDesign() { return new DistillationTraySection(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/VaneSection.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/VaneSection.java index b94c27d891..350379f2bd 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/VaneSection.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/sectionType/VaneSection.java @@ -27,13 +27,7 @@ public VaneSection(String name, String type, Separator sep) { super(name, type, sep); } - /** - * {@inheritDoc} - * - * @return a - * {@link neqsim.processSimulation.mechanicalDesign.separator.sectionType.MechVaneSection} - * object - */ + /** {@inheritDoc} */ @Override public MechVaneSection getMechanicalDesign() { return new MechVaneSection(this); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java index e772739d8c..ee1cd386b1 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitter.java @@ -64,7 +64,7 @@ public ComponentSplitter(String name, StreamInterface inletStream) { * setSplitFactors. * * - * @param factors an array of {@link double} objects + * @param factors an array of type double */ public void setSplitFactors(double[] factors) { splitFactor = factors; @@ -83,7 +83,8 @@ public void setInletStream(StreamInterface inletStream) { splitStream = new Stream[2]; try { for (int i = 0; i < splitStream.length; i++) { - splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone()); + // todo: why not inletStream.clone("Split Stream_" + i) + splitStream[i] = new Stream("Split Stream_" + i, inletStream.getThermoSystem().clone()); } } catch (Exception ex) { logger.error(ex.getMessage(), ex); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java index 7daf913ba9..c7bc2a9a91 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/splitter/Splitter.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; @@ -33,29 +34,6 @@ public class Splitter extends ProcessEquipmentBaseClass implements SplitterInter double[] flowRates; String flowUnit = "mole/sec"; - /** - *- * Constructor for Splitter. - *
- */ - public Splitter() { - super("Splitter"); - } - - /** - *- * Constructor for Splitter. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Splitter(StreamInterface inletStream) { - this(); - this.setInletStream(inletStream); - } - /** * Constructor for Splitter. * @@ -108,7 +86,7 @@ public void setSplitNumber(int i) { * setSplitFactors. * * - * @param splitFact an array of {@link double} objects + * @param splitFact an array of type double */ public void setSplitFactors(double[] splitFact) { double sum = 0.0; @@ -132,7 +110,7 @@ public void setSplitFactors(double[] splitFact) { * setFlowRates. * * - * @param flowRates an array of {@link double} objects + * @param flowRates an array of type double * @param flowUnit a {@link java.lang.String} object */ public void setFlowRates(double[] flowRates, String flowUnit) { @@ -186,7 +164,7 @@ public void setInletStream(StreamInterface inletStream) { splitStream = new Stream[splitNumber]; try { for (int i = 0; i < splitNumber; i++) { - splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone()); + splitStream[i] = new Stream("Split Stream_" + i, inletStream.getThermoSystem().clone()); } } catch (Exception ex) { logger.error(ex.getMessage(), ex); @@ -241,6 +219,51 @@ public void run(UUID id) { setCalculationIdentifier(id); } + /** {@inheritDoc} */ + @Override + public void runTransient(double dt, UUID id) { + if (getCalculateSteadyState()) { + run(id); + increaseTime(dt); + } else { + Mixer mixer = new Mixer("tmpMixer"); + for (int i = 0; i < splitStream.length; i++) { + splitStream[i].setPressure(inletStream.getPressure()); + splitStream[i].setTemperature(inletStream.getTemperature("C"), "C"); + splitStream[i].run(); + mixer.addStream(splitStream[i]); + } + mixer.run(); + + inletStream.setThermoSystem(mixer.getThermoSystem()); + inletStream.run(); + setCalculationIdentifier(id); + } + } + + /** + *
+ * Getter for the field splitFactor
.
+ *
+ * getSplitFactors. + *
+ * + * @return an array of type double + */ + public double[] getSplitFactors() { + return splitFactor; + } + /** {@inheritDoc} */ @Override public void displayResult() {} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java index 8a3a00078f..cbb831ba9b 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/EquilibriumStream.java @@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.exception.InvalidInputException; /** *@@ -18,38 +19,6 @@ public class EquilibriumStream extends Stream { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(EquilibriumStream.class); - /** - *
- * Constructor for EquilibriumStream. - *
- */ - @Deprecated - public EquilibriumStream() {} - - /** - *- * Constructor for EquilibriumStream. - *
- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public EquilibriumStream(SystemInterface thermoSystem) { - super(thermoSystem); - } - - /** - *- * Constructor for EquilibriumStream. - *
- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - @Deprecated - public EquilibriumStream(StreamInterface stream) { - this("EquilibriumStream", stream.getThermoSystem()); - } - /** * Constructor for EquilibriumStream. * @@ -86,14 +55,31 @@ public EquilibriumStream clone() { return clonedStream; } + /** + * Clone Equilibriumstream object and give it a new name. + * + * @param name Name to set for the cloned object + * @return Cloned EquilibriumStream object + */ + @Override + public EquilibriumStream clone(String name) { + if (this.getName() == name) { + throw new RuntimeException( + new InvalidInputException(this, "clone", "name", "- Same name as in original object")); + } + EquilibriumStream s = this.clone(); + s.setName(name); + return s; + } + /** {@inheritDoc} */ @Override public void run(UUID id) { - System.out.println("start flashing stream... " + streamNumber); + logger.info("start flashing stream... " + streamNumber); ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoOps.TPflash(); - System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - System.out.println("beta: " + thermoSystem.getBeta()); + logger.info("number of phases: " + thermoSystem.getNumberOfPhases()); + logger.info("beta: " + thermoSystem.getBeta()); setCalculationIdentifier(id); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java index e25dfa1e93..8c6ffc06e9 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/IronIonSaturationStream.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.exception.InvalidInputException; /** *@@ -26,40 +27,6 @@ public class IronIonSaturationStream extends Stream { protected SystemInterface reactiveThermoSystem; - /** - *
- * Constructor for IronIonSaturationStream. - *
- */ - @Deprecated - public IronIonSaturationStream() { - this("IronIonSaturationStream"); - } - - /** - *- * Constructor for IronIonSaturationStream. - *
- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public IronIonSaturationStream(SystemInterface thermoSystem) { - this("IronIonSaturationStream", thermoSystem); - } - - /** - *- * Constructor for IronIonSaturationStream. - *
- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - @Deprecated - public IronIonSaturationStream(StreamInterface stream) { - this("IronIonSaturationStream", stream); - } - /** * Constructor for IronIonSaturationStream. * @@ -103,10 +70,27 @@ public IronIonSaturationStream clone() { return clonedSystem; } + /** + * Clone IronIonSaturationStream object and give it a new name. + * + * @param name Name to set for the cloned object + * @return Cloned IronIonSaturationStream object + */ + @Override + public IronIonSaturationStream clone(String name) { + if (this.getName() == name) { + throw new RuntimeException( + new InvalidInputException(this, "clone", "name", "- Same name as in original object")); + } + IronIonSaturationStream s = this.clone(); + s.setName(name); + return s; + } + /** {@inheritDoc} */ @Override public void run(UUID id) { - System.out.println("start flashing stream... " + streamNumber); + logger.info("start flashing stream... " + streamNumber); if (stream != null) { thermoSystem = this.stream.getThermoSystem().clone(); } @@ -122,16 +106,15 @@ public void run(UUID id) { thermoOps.TPflash(); reactiveThermoSystem.display(); try { - System.out - .println("aqueous phase number " + reactiveThermoSystem.getPhaseNumberOfPhase("aqueous")); + logger.info("aqueous phase number " + reactiveThermoSystem.getPhaseNumberOfPhase("aqueous")); thermoOps.addIonToScaleSaturation(reactiveThermoSystem.getPhaseNumberOfPhase("aqueous"), "FeCO3", "Fe++"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } reactiveThermoSystem.display(); - System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); - System.out.println("beta: " + reactiveThermoSystem.getBeta()); + logger.info("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); + logger.info("beta: " + reactiveThermoSystem.getBeta()); setCalculationIdentifier(id); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java index 381aa32c11..d677a9e6cd 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/NeqStream.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; +import neqsim.util.exception.InvalidInputException; /** *@@ -17,40 +18,6 @@ public class NeqStream extends Stream { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(NeqStream.class); - /** - *
- * Constructor for NeqStream. - *
- */ - @Deprecated - public NeqStream() { - super("NeqStream"); - } - - /** - *- * Constructor for NeqStream. - *
- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public NeqStream(SystemInterface thermoSystem) { - super(thermoSystem); - } - - /** - *- * Constructor for NeqStream. - *
- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - @Deprecated - public NeqStream(StreamInterface stream) { - super(stream); - } - /** * Constructor for NeqStream. * @@ -98,10 +65,27 @@ public NeqStream clone() { return clonedStream; } + /** + * Clone NeqStream object and give it a new name. + * + * @param name Name to set for the cloned object + * @return Cloned NeqStream object + */ + @Override + public NeqStream clone(String name) { + if (this.getName() == name) { + throw new RuntimeException( + new InvalidInputException(this, "clone", "name", "- Same name as in original object")); + } + NeqStream s = this.clone(); + s.setName(name); + return s; + } + /** {@inheritDoc} */ @Override public void run(UUID id) { - System.out.println("start flashing stream... " + streamNumber); + logger.info("start flashing stream... " + streamNumber); if (stream != null) { thermoSystem = this.stream.getThermoSystem().clone(); } @@ -110,8 +94,8 @@ public void run(UUID id) { this.thermoSystem.init(3); // thermoOps = new ThermodynamicOperations(thermoSystem); // thermoOps.TPflash(); - System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - System.out.println("beta: " + thermoSystem.getBeta()); + logger.info("number of phases: " + thermoSystem.getNumberOfPhases()); + logger.info("beta: " + thermoSystem.getBeta()); setCalculationIdentifier(id); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java index a269a371df..f15e1e0bc4 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/ScalePotentialCheckStream.java @@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.exception.InvalidInputException; /** *@@ -20,39 +21,6 @@ public class ScalePotentialCheckStream extends Stream { protected SystemInterface reactiveThermoSystem; - /** - *
- * Constructor for ScalePotentialCheckStream. - *
- */ - @Deprecated - public ScalePotentialCheckStream() { - super("ScalePotentialCheckStream"); - } - - /** - *- * Constructor for ScalePotentialCheckStream. - *
- * - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - public ScalePotentialCheckStream(SystemInterface thermoSystem) { - super("ScalePotentialCheckStream", thermoSystem); - } - - /** - *- * Constructor for ScalePotentialCheckStream. - *
- * - * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - @Deprecated - public ScalePotentialCheckStream(StreamInterface stream) { - super("ScalePotentialCheckStream", stream); - } - /** * Constructor for ScalePotentialCheckStream. * @@ -96,10 +64,27 @@ public ScalePotentialCheckStream clone() { return clonedSystem; } + /** + * Clone ScalePotentialCheckStream object and give it a new name. + * + * @param name Name to set for the cloned object + * @return Cloned ScalePotentialCheckStream object + */ + @Override + public ScalePotentialCheckStream clone(String name) { + if (this.getName() == name) { + throw new RuntimeException( + new InvalidInputException(this, "clone", "name", "- Same name as in original object")); + } + ScalePotentialCheckStream s = this.clone(); + s.setName(name); + return s; + } + /** {@inheritDoc} */ @Override public void run(UUID id) { - System.out.println("start flashing stream... " + streamNumber); + logger.info("start flashing stream... " + streamNumber); if (stream != null) { thermoSystem = this.stream.getThermoSystem().clone(); } @@ -111,8 +96,8 @@ public void run(UUID id) { thermoOps.TPflash(); reactiveThermoSystem.init(3); - System.out.println("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); - System.out.println("beta: " + reactiveThermoSystem.getBeta()); + logger.info("number of phases: " + reactiveThermoSystem.getNumberOfPhases()); + logger.info("beta: " + reactiveThermoSystem.getBeta()); setCalculationIdentifier(id); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index 048449415f..41e8da7409 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -6,13 +6,19 @@ package neqsim.processSimulation.processEquipment.stream; +import java.util.ArrayList; +import java.util.HashMap; import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.gson.GsonBuilder; 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; +import neqsim.util.exception.InvalidInputException; /** *
@@ -28,6 +34,8 @@ public class Stream extends ProcessEquipmentBaseClass implements StreamInterface
protected SystemInterface thermoSystem;
+ // todo: is streamNumber ever anything besides 0 and 1? consider removing along with
+ // numberOfStreams?
protected int streamNumber = 0;
/** Constant numberOfStreams=0
. */
protected static int numberOfStreams = 0;
@@ -40,13 +48,12 @@ public class Stream extends ProcessEquipmentBaseClass implements StreamInterface
protected double lastFlowRate = 0.0;
/**
- *
* Constructor for Stream. - *
+ * + * @param name name of stream */ - @Deprecated - public Stream() { - super("Stream"); + public Stream(String name) { + super(name); } /** @@ -54,46 +61,18 @@ public Stream() { * Constructor for Stream. * * - * @param stream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Stream(StreamInterface stream) { - this("Stream", stream); - } - - /** *
- * Constructor for Stream.
+ * NB! This construct uses the input stream object internally, i.e., it is not cloned. Use
+ * streamObject.clone(newName)
rather than
+ * new Stream(newName,streamObject)
*
+ * NB! This construct uses the input thermoSystem object internally, i.e., it is not cloned. + *
+ * + * @param name name of stream + * @param thermoSystem System to use as internal System. */ public Stream(String name, SystemInterface thermoSystem) { super(name); @@ -138,12 +121,12 @@ public void setGasQuality(double gasQuality) { /** {@inheritDoc} */ @Override public double getHydrateEquilibriumTemperature() { - if (!thermoSystem.getPhase(0).hasComponent("water")) { - System.out.println("ny hydrate: no water in stream: " + name); + if (!getFluid().getPhase(0).hasComponent("water")) { + logger.info("no hydrate: no water in stream: " + name); return 0.0; } try { - SystemInterface copySystem = thermoSystem.clone(); + SystemInterface copySystem = getFluid().clone(); copySystem.setHydrateCheck(true); ThermodynamicOperations thermoOps = new ThermodynamicOperations(copySystem); thermoOps.hydrateFormationTemperature(); @@ -163,7 +146,7 @@ public double getHydrateEquilibriumTemperature() { * @return a double */ public double getSolidFormationTemperature(String solidName) { - SystemInterface copySystem = thermoSystem.clone(); + SystemInterface copySystem = getFluid().clone(); try { if (solidName.equals("hydrate")) { @@ -193,56 +176,68 @@ public Stream clone() { ex.printStackTrace(); } if (stream != null) { - clonedSystem.setStream((Stream) stream.clone()); + clonedSystem.setStream(stream.clone()); + } + if (thermoSystem != null) { + clonedSystem.thermoSystem = thermoSystem.clone(); } - clonedSystem.thermoSystem = getThermoSystem().clone(); - return clonedSystem; - } - /** {@inheritDoc} */ - @Override - public double getTemperature() { - return thermoSystem.getTemperature(); + return clonedSystem; } - /** {@inheritDoc} */ + /** + * Clone Stream object and give it a new name. + * + * @param name Name to set for the cloned object + * @return Cloned Stream object + */ @Override - public double getTemperature(String unit) { - return getFluid().getTemperature(unit); + public Stream clone(String name) { + if (this.getName() == name) { + throw new RuntimeException( + new InvalidInputException(this, "clone", "name", "- Same name as in original object")); + } + Stream s = this.clone(); + s.setName(name); + return s; } /** {@inheritDoc} */ @Override - public double getPressure() { - return thermoSystem.getPressure(); + public double getTemperature() { + return getFluid().getTemperature(); } /** {@inheritDoc} */ @Override - public double getPressure(String unit) { - return getFluid().getPressure(unit); + public double getTemperature(String unit) { + return getFluid().getTemperature(unit); } /** {@inheritDoc} */ @Override public double getMolarRate() { - return thermoSystem.getTotalNumberOfMoles(); + return getFluid().getTotalNumberOfMoles(); } /** {@inheritDoc} */ @Override public void setThermoSystem(SystemInterface thermoSystem) { - this.thermoSystem = thermoSystem; - // TODO: when is stream not null? if (stream != null) { stream.setThermoSystem(thermoSystem); + } else { + this.thermoSystem = thermoSystem; } } /** {@inheritDoc} */ @Override public void setFluid(SystemInterface fluid) { - this.setThermoSystem(fluid); + if (stream != null) { + stream.setFluid(fluid); + } else { + this.setThermoSystem(fluid); + } } /** {@inheritDoc} */ @@ -255,10 +250,11 @@ public void setThermoSystemFromPhase(SystemInterface thermoSystem, String phaseT } else if (thermoSystem.hasPhaseType("oil")) { this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("oil")); } else if (thermoSystem.hasPhaseType("aqueous")) { - this.thermoSystem = thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); + this.thermoSystem = + thermoSystem.phaseToSystem(thermoSystem.getPhaseNumberOfPhase("aqueous")); } else { - System.out.println("no phase of type " + phaseTypeName); - System.out.println("...returning empty system "); + logger.warn("no phase of type " + phaseTypeName); + logger.warn("...returning empty system "); setEmptyThermoSystem(thermoSystem); } return; @@ -266,8 +262,8 @@ public void setThermoSystemFromPhase(SystemInterface thermoSystem, String phaseT if (thermoSystem.hasPhaseType(phaseTypeName)) { this.thermoSystem = thermoSystem.phaseToSystem(phaseTypeName); } else { - System.out.println("no phase of type " + phaseTypeName); - System.out.println("...returning empty system "); + logger.warn("no phase of type " + phaseTypeName); + logger.warn("...returning empty system "); setEmptyThermoSystem(thermoSystem); } } @@ -282,13 +278,13 @@ public void setEmptyThermoSystem(SystemInterface thermoSystem) { /** {@inheritDoc} */ @Override public SystemInterface getThermoSystem() { - return this.thermoSystem; + return this.getFluid(); } /** {@inheritDoc} */ @Override public void setFlowRate(double flowrate, String unit) { - this.getFluid().setTotalFlowRate(flowrate, unit); + getFluid().setTotalFlowRate(flowrate, unit); } /** {@inheritDoc} */ @@ -307,12 +303,15 @@ public void setTemperature(double temperature, String unit) { @Override public void runTPflash() { if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); + thermoSystem = stream.getThermoSystem().clone(); } ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoOps.TPflash(); thermoSystem.initProperties(); + if (stream != null) { + stream.setFluid(thermoSystem); + } } /** {@inheritDoc} */ @@ -335,13 +334,12 @@ public boolean needRecalculation() { /** {@inheritDoc} */ @Override public void run(UUID id) { - // System.out.println("start flashing stream... " + streamNumber); - if (stream != null) { - thermoSystem = this.stream.getThermoSystem().clone(); - } + // logger.info("start flashing stream... " + streamNumber); + thermoSystem = getFluid().clone(); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - if (stream != null && getThermoSystem().getNumberOfComponents() == 1 + if (stream != null && thermoSystem.getNumberOfComponents() == 1 && getSpecification().equals("TP")) { setSpecification("PH"); } @@ -368,7 +366,8 @@ && getSpecification().equals("TP")) { double gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy(); double liquidEnthalpy = thermoSystem.getPhase(1).getEnthalpy(); - double enthalpySpec = getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; + double enthalpySpec = + getGasQuality() * gasEnthalpy + (1.0 - getGasQuality()) * liquidEnthalpy; thermoOps.PHflash(enthalpySpec); } catch (Exception ex) { logger.error(ex.getMessage(), ex); @@ -390,7 +389,7 @@ && getSpecification().equals("TP")) { } } else if (getSpecification().equals("PH")) { try { - thermoOps.PHflash(getThermoSystem().getEnthalpy(), 0); + thermoOps.PHflash(thermoSystem.getEnthalpy(), 0); } catch (Exception ex) { logger.error(ex.getMessage(), ex); thermoOps.TPflash(); @@ -401,30 +400,28 @@ && getSpecification().equals("TP")) { thermoSystem.initProperties(); - lastFlowRate = getFluid().getFlowRate("kg/hr"); - lastTemperature = getFluid().getTemperature(); - lastPressure = getFluid().getPressure(); + lastFlowRate = thermoSystem.getFlowRate("kg/hr"); + lastTemperature = thermoSystem.getTemperature(); + lastPressure = thermoSystem.getPressure(); - // System.out.println("number of phases: " + thermoSystem.getNumberOfPhases()); - // System.out.println("beta: " + thermoSystem.getBeta()); + if (stream != null) { + stream.setFluid(thermoSystem); + } + // logger.info("number of phases: " + thermoSystem.getNumberOfPhases()); + // logger.info("beta: " + thermoSystem.getBeta()); setCalculationIdentifier(id); } /** {@inheritDoc} */ @Override public void displayResult() { - thermoSystem.display(name); + getFluid().display(name); } - /** - *- * getResultTable. - *
- * - * @return an array of {@link java.lang.String} objects - */ + /** {@inheritDoc} */ + @Override public String[][] getResultTable() { - return thermoSystem.getResultTable(); + return getFluid().calcResultTable(); } /** {@inheritDoc} */ @@ -458,7 +455,7 @@ public void runController(double dt, UUID id) { /** {@inheritDoc} */ @Override public void flashStream() { - ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ThermodynamicOperations ops = new ThermodynamicOperations(getFluid()); ops.TPflash(); } @@ -468,7 +465,7 @@ public void flashStream() { * */ public void phaseEnvelope() { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -480,7 +477,7 @@ public void phaseEnvelope() { /** {@inheritDoc} */ @Override public double CCB(String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -501,7 +498,7 @@ public double CCB(String unit) { /** {@inheritDoc} */ @Override public double CCT(String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); ops.setRunAsThread(true); ops.calcPTphaseEnvelope(true); @@ -522,20 +519,45 @@ public double CCT(String unit) { /** {@inheritDoc} */ @Override public double TVP(double temperature, String unit) { - SystemInterface localSyst = thermoSystem.clone(); + SystemInterface localSyst = getFluid().clone(); localSyst.setTemperature(temperature, unit); ThermodynamicOperations ops = new ThermodynamicOperations(localSyst); try { ops.bubblePointPressureFlash(false); } catch (Exception ex) { + // todo: not swallow exception } 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) { + // todo: not swallow exception + } + 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() { - return thermoSystem.getResultTable(); + return getFluid().getResultTable(); } /** @@ -544,9 +566,9 @@ public String[][] reportResults() { * * * @param propertyName a {@link java.lang.String} object - * @param unit a {@link java.lang.String} object - * @param phase a {@link java.lang.String} object - * @param component a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object + * @param phase a {@link java.lang.String} object + * @param component a {@link java.lang.String} object * @return a {@link java.lang.Object} object */ public Object getProperty(String propertyName, String unit, String phase, String component) { @@ -554,22 +576,53 @@ public Object getProperty(String propertyName, String unit, String phase, String // if(properties.containsKey(propertyName)) { // } // else + + // todo: throw not implemented error return null; } /** {@inheritDoc} */ @Override public double GCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + Standard_ISO6976 standard = new Standard_ISO6976(getFluid().clone(), 0, 15.55, "volume"); standard.setReferenceState("real"); standard.calculate(); return standard.getValue("GCV") * 1.0e3; } + /** {@inheritDoc} */ + @Override + public double getGCV(String unit, double refTVolume, double refTCombustion) { + Standard_ISO6976 standard = + new Standard_ISO6976(getFluid().clone(), refTVolume, refTCombustion, unit); + standard.setReferenceState("real"); + standard.calculate(); + return standard.getValue("SuperiorCalorificValue") * 1.0e3; + } + + /** {@inheritDoc} */ + @Override + public double getWI(String unit, double refTVolume, double refTCombustion) { + Standard_ISO6976 standard = + new Standard_ISO6976(getFluid().clone(), refTVolume, refTCombustion, unit); + standard.setReferenceState("real"); + standard.calculate(); + return standard.getValue("SuperiorWobbeIndex") * 1.0e3; + } + + /** {@inheritDoc} */ + @Override + public Standard_ISO6976 getISO6976(String unit, double refTVolume, double refTCombustion) { + Standard_ISO6976 standard = + new Standard_ISO6976(getFluid().clone(), refTVolume, refTCombustion, unit); + standard.setReferenceState("real"); + return standard; + } + /** {@inheritDoc} */ @Override public double LCV() { - Standard_ISO6976 standard = new Standard_ISO6976(thermoSystem.clone(), 0, 15.55, "volume"); + Standard_ISO6976 standard = new Standard_ISO6976(getFluid().clone(), 0, 15.55, "volume"); standard.setReferenceState("real"); standard.calculate(); return standard.getValue("InferiorCalorificValue") * 1.0e3; @@ -580,12 +633,69 @@ public double LCV() { * Setter for the fieldstream
.
*
*
- * @param stream a
- * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
- * object
+ * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object
*/
public void setStream(StreamInterface stream) {
this.stream = stream;
}
+ /** {@inheritDoc} */
+ @Override
+ public SystemInterface getFluid() {
+ if (stream != null) {
+ return stream.getFluid();
+ } else {
+ return thermoSystem;
+ }
+ }
+
+ /**
+ * + * getReport. + *
+ * + * @return a String object + */ + public ArrayList+ * TVP. + *
+ * + * @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); + + /** + *+ * TVP. + *
+ * + * @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); + /** ** setFluid. @@ -148,13 +174,24 @@ public default double getFlowRate(String unit) { /** *
- * clone. + * Clone object. *
* * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object */ public StreamInterface clone(); + /** + *+ * Clone object and set a new name. + *
+ * + * @param name Name of cloned object + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface clone(String name); + + /** ** flashStream. @@ -219,6 +256,42 @@ public default double getFlowRate(String unit) { */ public double GCV(); + /** + *
+ * getGCV. + *
+ * + * @param unit a String + * @param refTVolume a double in Celcius + * @param refTCombustion a double in Celcius + * @return a double + */ + public double getGCV(String unit, double refTVolume, double refTCombustion); + + /** + *+ * getWI. + *
+ * + * @param unit a String + * @param refTVolume a double in Celcius + * @param refTCombustion a double in Celcius + * @return a double + */ + public double getWI(String unit, double refTVolume, double refTCombustion); + + /** + *+ * getWI. + *
+ * + * @param unit a String + * @param refTVolume a double in Celcius + * @param refTCombustion a double in Celcius + * @return a Standard_ISO6976 + */ + public Standard_ISO6976 getISO6976(String unit, double refTVolume, double refTCombustion); + /** *
* LCV.
@@ -235,5 +308,4 @@ public default double getFlowRate(String unit) {
/** {@inheritDoc} */
@Override
public int hashCode();
-
}
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/VirtualStream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/VirtualStream.java
index d15edeb02d..af38a63b76 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/stream/VirtualStream.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/VirtualStream.java
@@ -1,10 +1,8 @@
package neqsim.processSimulation.processEquipment.stream;
import java.util.UUID;
-
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
/**
@@ -88,7 +86,7 @@ public void setFlowRate(double rate, String unit) {
* Setter for the field composition
.
*
- * Constructor for SimpleFlowLine. - *
- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SimpleFlowLine(StreamInterface inStream) { - this("SimpleFlowLine", inStream); - - } - /** * Constructor for SimpleFlowLine. * @@ -45,8 +31,7 @@ public SimpleFlowLine(StreamInterface inStream) { */ public SimpleFlowLine(String name, StreamInterface inStream) { super(name); - this.inStream = inStream; - setOutletStream(inStream.clone()); + setInletStream(inStream); pipeline = new AdiabaticTwoPhasePipe("pipeline", inStream); } @@ -76,21 +61,21 @@ public void run(UUID id) { /* * System.out.println("stary P " ); - * + * * SystemInterface fluidIn = (inStream.getFluid()).clone(); fluidIn.initProperties(); - * + * * double density = fluidIn.getDensity("kg/m3"); - * + * * double deltaP = density*getHeight()*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1. * 0e5; - * + * * System.out.println("density " +density + " delta P " + deltaP); - * + * * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); * fluidIn.setTemperature(outletTemperature); - * + * * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); - * + * * getOutletStream().setFluid(fluidIn); */ setCalculationIdentifier(id); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java index 46d5581746..57e5672adc 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SubseaWell.java @@ -21,7 +21,8 @@ public class SubseaWell extends TwoPortEquipment { private static final long serialVersionUID = 1000; - public double height = 1000.0, length = 1200.0; + public double height = 1000.0; + public double length = 1200.0; AdiabaticTwoPhasePipe pipeline; /** @@ -29,14 +30,13 @@ public class SubseaWell extends TwoPortEquipment { * Constructor for SubseaWell. * * + * @param name Name of well * @param instream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} * object */ - @Deprecated - public SubseaWell(StreamInterface instream) { - super("SubseaWell"); - this.inStream = instream; - setOutletStream(instream.clone()); + public SubseaWell(String name, StreamInterface instream) { + super(name); + setInletStream(instream); pipeline = new AdiabaticTwoPhasePipe("pipeline", instream); } @@ -61,17 +61,17 @@ public void run(UUID id) { /* * System.out.println("stary P " ); SystemInterface fluidIn = (inStream.getFluid()).clone(); * fluidIn.initProperties(); - * + * * double density = fluidIn.getDensity("kg/m3"); - * + * * double deltaP = density*height*neqsim.thermo.ThermodynamicConstantsInterface.gravity/1.0e5; - * + * * System.out.println("density " +density + " delta P " + deltaP); - * + * * fluidIn.setPressure(fluidIn.getPressure("bara")-deltaP); - * + * * ThermodynamicOperations ops = new ThermodynamicOperations(fluidIn); ops.TPflash(); - * + * * getOutStream().setFluid(fluidIn); */ setCalculationIdentifier(id); @@ -118,7 +118,8 @@ public static void main(String[] args) { System.out .println("total produced " + reservoirOps.getProductionTotal("MSm3 oe") + " MSm3 oe"); - SubseaWell well1 = new SubseaWell(reservoirOps.getOilProducer("oilproducer_1").getStream()); + SubseaWell well1 = + new SubseaWell("oilproducer_1", reservoirOps.getOilProducer("oilproducer_1").getStream()); well1.getPipeline().setDiameter(0.3); well1.getPipeline().setLength(5500.0); well1.getPipeline().setInletElevation(-1000.0); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java b/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java index c28f10c6b9..65b95f51c8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/tank/Tank.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.tank; import java.util.UUID; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -46,30 +45,6 @@ public class Tank extends ProcessEquipmentBaseClass { private double liquidLevel = liquidVolume / (liquidVolume + gasVolume); - /** - *- * Constructor for Tank. - *
- */ - @Deprecated - public Tank() { - super("Tank"); - setCalculateSteadyState(false); - } - - /** - *- * Constructor for Tank. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Tank(StreamInterface inletStream) { - this("Tank", inletStream); - } - /** * Constructor for Tank. * @@ -77,6 +52,7 @@ public Tank(StreamInterface inletStream) { */ public Tank(String name) { super(name); + setCalculateSteadyState(false); } /** @@ -89,7 +65,7 @@ public Tank(String name) { * object */ public Tank(String name, StreamInterface inletStream) { - super(name); + this(name); setInletStream(inletStream); } @@ -122,7 +98,7 @@ public void setInletStream(StreamInterface inletStream) { */ public void addStream(StreamInterface newStream) { if (numberOfInputStreams == 0) { - setInletStream((Stream) newStream); + setInletStream(newStream); } else { inletStreamMixer.addStream(newStream); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java index ed9e6970ce..fa55ed5e1a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Adjuster.java @@ -23,6 +23,9 @@ public class Adjuster extends ProcessEquipmentBaseClass { ProcessEquipmentInterface targetEquipment = null; String adjustedVariable = ""; + String adjustedVariableUnit = ""; + double maxAdjustedValue = 1e10; + double minAdjustedValue = -1e10; String targetVariable = ""; String targetPhase = ""; String targetComponent = ""; @@ -42,21 +45,28 @@ public class Adjuster extends ProcessEquipmentBaseClass { ** Constructor for Adjuster. *
+ * + * @param name a {@link java.lang.String} object */ - @Deprecated - public Adjuster() { - this("Adjuster"); + public Adjuster(String name) { + super(name); } /** *- * Constructor for Adjuster. + * setAdjustedVariable. *
* - * @param name a {@link java.lang.String} object + * @param adjustedEquipment a + * {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object + * @param adjstedVariable a {@link java.lang.String} object + * @param unit a string */ - public Adjuster(String name) { - super(name); + public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment, + String adjstedVariable, String unit) { + this.adjustedEquipment = adjustedEquipment; + this.adjustedVariable = adjstedVariable; + this.adjustedVariableUnit = unit; } /** @@ -144,6 +154,12 @@ public void run(UUID id) { if (adjustedVariable.equals("mass flow")) { inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate("kg/hr"); + } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) { + inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate(adjustedVariableUnit); + } else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) { + inputValue = ((Stream) adjustedEquipment).getPressure(adjustedVariableUnit); + } else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) { + inputValue = ((Stream) adjustedEquipment).getTemperature(adjustedVariableUnit); } else { inputValue = ((Stream) adjustedEquipment).getThermoSystem().getNumberOfMoles(); } @@ -172,11 +188,20 @@ public void run(UUID id) { double deviation = targetValue - targetValueCurrent; error = deviation; - logger.info("adjuster deviation " + deviation + " inputValue " + inputValue); + if (iterations < 2) { if (adjustedVariable.equals("mass flow")) { ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation, "kg/hr"); + } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate( + inputValue + Math.signum(deviation) * inputValue / 100.0, adjustedVariableUnit); + } else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).setPressure(inputValue + deviation / 10.0, + adjustedVariableUnit); + } else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).setTemperature(inputValue + deviation / 10.0, + adjustedVariableUnit); } else { ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation, "mol/sec"); @@ -184,9 +209,28 @@ public void run(UUID id) { } else { double derivate = (error - oldError) / (inputValue - oldInputValue); double newVal = error / derivate; + if (inputValue - newVal > maxAdjustedValue) { + newVal = inputValue - maxAdjustedValue; + if (Math.abs(oldInputValue - inputValue) < 1e-10) { + error = tolerance * 0.9; + } + } + if (inputValue - newVal < minAdjustedValue) { + newVal = inputValue - minAdjustedValue; + if (Math.abs(oldInputValue - inputValue) < 1e-10) { + error = tolerance * 0.9; + } + } if (adjustedVariable.equals("mass flow")) { ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, "kg/hr"); + } else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, + adjustedVariableUnit); + } else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).setPressure(inputValue - newVal, adjustedVariableUnit); + } else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) { + ((Stream) adjustedEquipment).setTemperature(inputValue - newVal, adjustedVariableUnit); } else { ((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal, "mol/sec"); @@ -272,7 +316,7 @@ public static void main(String[] args) { testSystem.setMixingRule(2); Stream stream_1 = new Stream("Stream1", testSystem); - Adjuster adjuster1 = new Adjuster(); + Adjuster adjuster1 = new Adjuster("adjuster"); adjuster1.setAdjustedVariable(stream_1, "molarFlow"); adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "MSm3/day", ""); @@ -305,4 +349,54 @@ public boolean isActivateWhenLess() { public void setActivateWhenLess(boolean activateWhenLess) { this.activateWhenLess = activateWhenLess; } + + /** + *
+ * Setter for the field maxAdjustedValue
.
+ *
+ * Setter for the field minAdjustedValue
.
+ *
+ * Getter for the field maxAdjustedValue
.
+ *
+ * Getter for the field minAdjustedValue
.
+ *
@@ -72,10 +73,28 @@ public boolean needRecalculation() { return false; } + public void runAntiSurgeCalc(UUID id) { + Compressor compressor = (Compressor) inputVariable.get(0); + double distToSurge = compressor.getDistanceToSurge(); + double flowInAntiSurge = 1e-6; + if (distToSurge < 0) { + flowInAntiSurge = -distToSurge * compressor.getInletStream().getFlowRate("MSm3/day"); + } + + Splitter anitSurgeSplitter = (Splitter) outputVariable; + anitSurgeSplitter.setFlowRates(new double[] {-1, flowInAntiSurge}, "MSm3/day"); + anitSurgeSplitter.run(); + anitSurgeSplitter.setCalculationIdentifier(id); + } + /** {@inheritDoc} */ @Override public void run(UUID id) { double sum = 0.0; + if (name.equals("anti surge calculator")) { + runAntiSurgeCalc(id); + return; + } if (name.equals("MEG makeup calculator")) { for (int i = 0; i < inputVariable.size(); i++) { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/FlowRateAdjuster.java b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowRateAdjuster.java new file mode 100644 index 0000000000..b9ce2603eb --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowRateAdjuster.java @@ -0,0 +1,183 @@ +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.ProcessEquipmentInterface; +import neqsim.processSimulation.processEquipment.TwoPortEquipment; +import neqsim.processSimulation.processEquipment.mixer.Mixer; +import neqsim.processSimulation.processEquipment.mixer.StaticMixer; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + *
+ * Adjuster class. + *
+ * + * @author Even Solbraa + * @version $Id: $Id + */ +public class FlowRateAdjuster extends TwoPortEquipment { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(FlowRateAdjuster.class); + + String name = "Flow Rate Adjuster"; + + public double desiredGasFlow; + public double desiredOilFlow; + public double desiredWaterFlow; + private String unit; + + ProcessEquipmentInterface adjustedEquipment = null; + ProcessEquipmentInterface targetEquipment = null; + + String adjustedVariable = ""; + String adjustedVariableUnit = ""; + double maxAdjustedValue = 1e10; + double minAdjustedValue = -1e10; + String targetVariable = ""; + String targetPhase = ""; + String targetComponent = ""; + + double targetValue = 0.0; + String targetUnit = ""; + private double tolerance = 1e-6; + double inputValue = 0.0; + double oldInputValue = 0.0; + private double error = 1e6; + private double oldError = 1.0e6; + + int iterations = 0; + private boolean activateWhenLess = false; + Stream waterStream; + double waterDensity; + + /** + *+ * Constructor for FlowRateAdjuster. + *
+ * + * @param name a {@link java.lang.String} object + */ + public FlowRateAdjuster(String name) { + super(name); + } + + /** + *+ * Constructor for FlowRateAdjuster. + *
+ * + * @param name a {@link java.lang.String} object + * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public FlowRateAdjuster(String name, StreamInterface inStream) { + super(name, inStream); + } + + /** + *+ * setAdjustedVariable. + *
+ * + * @param desiredGasFlow a {@link java.lang.Double} object + * @param desiredOilFlow a {@link java.lang.Double} object + * @param desiredWaterFlow a {@link java.lang.Double} object + * @param unit a {@link java.lang.String} object + */ + public void setAdjustedFlowRates(Double desiredGasFlow, Double desiredOilFlow, + Double desiredWaterFlow, String unit) { + this.desiredGasFlow = desiredGasFlow; + this.desiredOilFlow = desiredOilFlow; + this.desiredWaterFlow = desiredWaterFlow; + this.unit = unit; + } + + /** + *+ * setAdjustedVariable. + *
+ * + * @param desiredGasFlow a {@link java.lang.Double} object + * @param desiredOilFlow a {@link java.lang.Double} object + * @param unit a {@link java.lang.String} object + */ + public void setAdjustedFlowRates(Double desiredGasFlow, Double desiredOilFlow, String unit) { + this.setAdjustedFlowRates(desiredGasFlow, desiredOilFlow, 0.0, unit); + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface adjustedFluid = inStream.getFluid(); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(adjustedFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + + SystemInterface gasFluid = adjustedFluid.phaseToSystem(0).clone(); + SystemInterface oilFluid = adjustedFluid.phaseToSystem(1).clone(); + + double temperature = inStream.getTemperature("C"); + double pressure = inStream.getPressure("bara"); + + if (desiredWaterFlow > 0.0) { + SystemInterface waterFluid = adjustedFluid.phaseToSystem(2).clone(); + waterFluid.initPhysicalProperties(); + waterDensity = waterFluid.getDensity("kg/m3"); + + waterStream = new Stream("Water Stream", waterFluid); + waterStream.setTemperature(temperature, "C"); + waterStream.setPressure(pressure, "bara"); + } + gasFluid.initPhysicalProperties(); + oilFluid.initPhysicalProperties(); + + double oilDensity = oilFluid.getDensity("kg/m3"); + + Stream gasStream = new Stream("Gas Stream", gasFluid); + gasStream.setTemperature(temperature, "C"); + gasStream.setPressure(pressure, "bara"); + + Stream oilStream = new Stream("Oil Stream", oilFluid); + oilStream.setTemperature(temperature, "C"); + oilStream.setPressure(pressure, "bara"); + + if (unit.equals("Sm3/hr")) { + gasStream.setFlowRate(desiredGasFlow, unit); + oilStream.setFlowRate(desiredOilFlow * oilDensity, "kg/hr"); + if (desiredWaterFlow > 0.0) { + waterStream.setFlowRate(desiredWaterFlow * waterDensity, "kg/hr"); + } + } else { + gasStream.setFlowRate(desiredGasFlow, unit); + oilStream.setFlowRate(desiredOilFlow, unit); + if (desiredWaterFlow > 0.0) { + waterStream.setFlowRate(desiredWaterFlow, unit); + } + } + gasStream.run(); + oilStream.run(); + if (desiredWaterFlow > 0.0) { + waterStream.run(); + } + + Mixer wellStramMixer = new StaticMixer("Stream mixer"); + wellStramMixer.addStream(gasStream); + wellStramMixer.addStream(oilStream); + if (desiredWaterFlow > 0.0) { + wellStramMixer.addStream(waterStream); + } + wellStramMixer.run(); + + outStream.setThermoSystem(wellStramMixer.getOutletStream().getFluid()); + outStream.run(); + outStream.setCalculationIdentifier(id); + } +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java new file mode 100644 index 0000000000..3b16de09c3 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/FlowSetter.java @@ -0,0 +1,424 @@ +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.heatExchanger.Heater; +import neqsim.processSimulation.processEquipment.mixer.Mixer; +import neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.exception.InvalidInputException; + +/** + *+ * FlowSetter class. + *
+ * + * @author esol + * @version $Id: $Id + */ +public class FlowSetter extends TwoPortEquipment { + private static final long serialVersionUID = 1000; + private static final Logger logger = LogManager.getLogger(FlowSetter.class); + double[] pressure = new double[] {1.01325}; + double[] temperature = new double[] {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"; + + ProcessSystem referenceProcess = null; + + @Deprecated + /** + *+ * Constructor for FlowSetter. + *
+ */ + public FlowSetter() { + super("Flow Setter"); + } + + /** + *+ * Constructor for FlowSetter. + *
+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public FlowSetter(StreamInterface stream) { + this("Flow Setter", stream); + } + + /** + *+ * Constructor for FlowSetter. + *
+ * + * @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} + * + *
+ * Setter for the field inletStream
.
+ *
+ * Get setGasFlowRate + *
+ * + * @param flowRate flow rate + * @param flowUnit Supported units are Sm3/sec, Sm3/hr, Sm3/day, MSm3/day + */ + public void setGasFlowRate(double flowRate, String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "Sm3/sec": + conversionFactor = 1.0; + break; + case "Sm3/hr": + conversionFactor = 1.0 / 3600.0; + break; + case "Sm3/day": + conversionFactor = 1.0 / 3600.0 / 24.0; + break; + case "MSm3/day": + conversionFactor = 1.0 / 3600.0 / 24.0 * 1e6; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + gasFlowRate = flowRate * conversionFactor; + } + + /** + *+ * Get getGasFlowRate + *
+ * + * @param flowUnit Supported units are Sm3/sec, Sm3/hr, Sm3/day, MSm3/day + * @return gas flow rate in unit sm3/sec + */ + public double getGasFlowRate(String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "Sm3/sec": + conversionFactor = 1.0; + break; + case "Sm3/hr": + conversionFactor = 1.0 * 3600.0; + break; + case "Sm3/day": + conversionFactor = 1.0 * 3600.0 * 24.0; + break; + case "MSm3/day": + conversionFactor = 1.0 * 3600.0 * 24.0 / 1e6; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + return gasFlowRate * conversionFactor; + } + + /** + *+ * Get setOilFlowRate + *
+ * + * @param flowRate flow rate + * @param flowUnit Supported units are m3/sec, m3/hr, m3/day + */ + public void setOilFlowRate(double flowRate, String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "m3/sec": + conversionFactor = 1.0; + break; + case "m3/hr": + conversionFactor = 1.0 / 3600.0; + break; + case "m3/day": + conversionFactor = 1.0 / 3600.0 / 24.0; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + oilFlowRate = flowRate * conversionFactor; + } + + /** + *+ * Get getOilFlowRate + *
+ * + * @param flowUnit Supported units are m3/sec, m3/hr, m3/day + * @return oil flow rate in unit m3/sec + */ + public double getOilFlowRate(String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "m3/sec": + conversionFactor = 1.0; + break; + case "m3/hr": + conversionFactor = 1.0 * 3600.0; + break; + case "m3/day": + conversionFactor = 1.0 * 3600.0 * 24.0; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + return oilFlowRate * conversionFactor; + } + + /** + *+ * Get setWaterFlowRate + *
+ * + * @param flowRate flow rate + * @param flowUnit Supported units are m3/sec, m3/hr, m3/day + */ + public void setWaterFlowRate(double flowRate, String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "m3/sec": + conversionFactor = 1.0; + break; + case "m3/hr": + conversionFactor = 1.0 / 3600.0; + break; + case "m3/day": + conversionFactor = 1.0 / 3600.0 / 24.0; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + waterFlowRate = flowRate * conversionFactor; + } + + /** + *+ * Get getWaterFlowRate + *
+ * + * @param flowUnit Supported units are m3/sec, m3/hr, m3/day + * @return water flow rate in unit m3/sec + */ + public double getWaterFlowRate(String flowUnit) { + double conversionFactor = 1.0; + switch (flowUnit) { + case "m3/sec": + conversionFactor = 1.0; + break; + case "m3/hr": + conversionFactor = 1.0 * 3600.0; + break; + case "m3/day": + conversionFactor = 1.0 * 3600.0 * 24.0; + break; + default: + throw new RuntimeException("unit not supported " + flowUnit); + } + return waterFlowRate * conversionFactor; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface tempFluid = inStream.getThermoSystem().clone(); + + if (referenceProcess == null) { + referenceProcess = createReferenceProcess(inStream); + } + + if (tempFluid.getFlowRate("kg/sec") < 1e-6) { + outStream.setThermoSystem(tempFluid); + return; + } + + double error = 0.0; + do { + error = 0.0; + ((StreamInterface) referenceProcess.getUnit("feed stream")).setFluid(tempFluid); + referenceProcess.run(); + ((StreamInterface) referenceProcess.getUnit("gas")).getFluid() + .initPhysicalProperties("density"); + ((StreamInterface) referenceProcess.getUnit("oil")).getFluid() + .initPhysicalProperties("density"); + + double[] moleChange = new double[tempFluid.getNumberOfComponents()]; + for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { + moleChange[i] = ((StreamInterface) referenceProcess.getUnit("gas")).getFluid() + .getComponent(i).getNumberOfMolesInPhase() + * (getGasFlowRate("Sm3/hr") + / ((StreamInterface) referenceProcess.getUnit("gas")).getFlowRate("Sm3/hr")) + - ((StreamInterface) referenceProcess.getUnit("gas")).getFluid().getComponent(i) + .getNumberOfMolesInPhase() + + + ((StreamInterface) referenceProcess.getUnit("oil")).getFluid().getComponent(i) + .getNumberOfMolesInPhase() + * (getOilFlowRate("m3/hr") + / ((StreamInterface) referenceProcess.getUnit("oil")).getFlowRate("m3/hr")) + - ((StreamInterface) referenceProcess.getUnit("oil")).getFluid().getComponent(i) + .getNumberOfMolesInPhase(); + error += Math.abs(moleChange[i]); + } + tempFluid.init(0); + for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { + tempFluid.addComponent(i, moleChange[i]); + } + } while (error > ((StreamInterface) referenceProcess.getUnit("feed stream")).getFluid() + .getTotalNumberOfMoles() / 1e6); + + if (waterFlowRate > 0) { + tempFluid.addComponent("water", getWaterFlowRate("m3/hr") * 1000.0, "kg/hr"); + } + + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + + outStream.setThermoSystem(tempFluid); + outStream.run(); + outStream.getFluid().initPhysicalProperties(); + + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** + *+ * createReferenceProcess. + *
+ * + * @param feedStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public ProcessSystem createReferenceProcess(StreamInterface feedStream) { + ProcessSystem referenceProcess = new ProcessSystem(); + + StreamInterface feedStream1 = new Stream("feed stream", feedStream.getFluid()); + feedStream1.setTemperature(temperature[0], unitT); + feedStream1.setPressure(pressure[0], unitP); + referenceProcess.add(feedStream1); + + ThreePhaseSeparator separator1ststage = + new ThreePhaseSeparator("1st stage separator", feedStream1); + referenceProcess.add(separator1ststage); + + Mixer gasMixer = new Mixer("gas mixer"); + gasMixer.addStream(separator1ststage.getGasOutStream()); + + StreamInterface gasExport = new Stream("gas", gasMixer.getOutletStream()); + StreamInterface oilExport = null; + + if (temperature.length == 0 || temperature == null) { + throw new RuntimeException( + new InvalidInputException(this, "getReferenceProcess", "temperature", "can not be null")); + } else if (temperature.length == 1) { + oilExport = new Stream("oil", separator1ststage.getOilOutStream()); + } else if (temperature.length == 2) { + Heater heater2ndstage = new Heater("2nd stage heater", separator1ststage.getOilOutStream()); + heater2ndstage.setOutPressure(pressure[1], unitP); + heater2ndstage.setOutTemperature(temperature[1], unitT); + referenceProcess.add(heater2ndstage); + + ThreePhaseSeparator separator2ndstage = + new ThreePhaseSeparator("2nd stage separator", heater2ndstage.getOutletStream()); + referenceProcess.add(separator2ndstage); + + gasMixer.addStream(separator2ndstage.getGasOutStream()); + oilExport = new Stream("oil", separator2ndstage.getOilOutStream()); + } else if (temperature.length == 3) { + Heater heater2ndstage = new Heater("2nd stage heater", separator1ststage.getOilOutStream()); + heater2ndstage.setOutPressure(pressure[1], unitP); + heater2ndstage.setOutTemperature(temperature[1], unitT); + referenceProcess.add(heater2ndstage); + + ThreePhaseSeparator separator2ndstage = + new ThreePhaseSeparator("2nd stage separator", heater2ndstage.getOutletStream()); + referenceProcess.add(separator2ndstage); + + Heater heater3rdstage = new Heater("3rd stage heater", separator2ndstage.getOilOutStream()); + heater3rdstage.setOutPressure(pressure[2], unitP); + heater3rdstage.setOutTemperature(temperature[2], unitT); + referenceProcess.add(heater3rdstage); + + ThreePhaseSeparator separator3rdstage = + new ThreePhaseSeparator("3rd stage separator", heater3rdstage.getOutletStream()); + referenceProcess.add(separator3rdstage); + + gasMixer.addStream(separator2ndstage.getGasOutStream()); + gasMixer.addStream(separator3rdstage.getGasOutStream()); + oilExport = new Stream("oil", separator3rdstage.getOilOutStream()); + } + + referenceProcess.add(gasMixer); + referenceProcess.add(gasExport); + referenceProcess.add(oilExport); + + return referenceProcess; + } + + /** + *
+ * Getter for the field referenceProcess
.
+ *
+ * setSeparationPT. + *
+ * + * @param pressure an array of type double + * @param unitP a {@link java.lang.String} object + * @param temperature an array of type double + * @param unitT a {@link java.lang.String} object + */ + public void setSeparationPT(double[] pressure, String unitP, double[] temperature, String unitT) { + this.pressure = pressure; + this.unitP = unitP; + this.temperature = temperature; + this.unitT = unitT; + } +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java index 19b1f9f757..4de244c5f0 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/GORfitter.java @@ -5,6 +5,7 @@ import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -20,7 +21,7 @@ public class GORfitter extends TwoPortEquipment { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(GORfitter.class); - double pressure = 1.01325; + double pressure = ThermodynamicConstantsInterface.referencePressure; double temperature = 15.0; private String referenceConditions = "standard"; // "actual"; private boolean fitAsGVF = false; @@ -32,7 +33,9 @@ public class GORfitter extends TwoPortEquipment { @Deprecated /** - *Constructor for GORfitter.
+ *+ * Constructor for GORfitter. + *
*/ public GORfitter() { super("GOR fitter"); @@ -63,7 +66,9 @@ public GORfitter(String name, StreamInterface stream) { } /** - *getGFV.
+ *+ * getGFV. + *
* * @return a double */ @@ -78,6 +83,7 @@ public double getGFV() { * Setter for the fieldinletStream
.
*
*/
+ @Override
public void setInletStream(StreamInterface inletStream) {
this.inStream = inletStream;
try {
@@ -87,13 +93,8 @@ public void setInletStream(StreamInterface inletStream) {
}
}
- /**
- *
- * Getter for the field pressure
.
- *
Getter for the field referenceConditions
.
+ * Getter for the field referenceConditions
.
+ *
Setter for the field referenceConditions
.
+ * Setter for the field referenceConditions
.
+ *
isFitAsGVF.
+ *+ * isFitAsGVF. + *
* * @return the fitAsGVF */ @@ -288,7 +296,9 @@ public boolean isFitAsGVF() { } /** - *Setter for the field fitAsGVF
.
+ * Setter for the field fitAsGVF
.
+ *
+ * GORfitter class. + *
+ * + * @author asmund + * @version $Id: $Id + */ +public class MPFMfitter extends TwoPortEquipment { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(MPFMfitter.class); + + double pressure = ThermodynamicConstantsInterface.referencePressure; + double temperature = 15.0; + private String referenceConditions = "standard"; // "actual"; + private boolean fitAsGVF = false; + + private double GOR = 120.0; + private double GVF; + String unitT = "C"; + String unitP = "bara"; + + SystemInterface referenceFluidPackage = null; + + @Deprecated + /** + *+ * Constructor for MPFMfitter. + *
+ */ + public MPFMfitter() { + super("MPFMfitter fitter"); + } + + /** + *+ * Constructor for MPFMfitter. + *
+ * + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + @Deprecated + public MPFMfitter(StreamInterface stream) { + this("MPFMfitter", stream); + } + + /** + *+ * Constructor for MPFMfitter. + *
+ * + * @param name a {@link java.lang.String} object + * @param stream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public MPFMfitter(String name, StreamInterface stream) { + super(name, stream); + } + + /** + *+ * getGFV. + *
+ * + * @return a double + */ + public double getGFV() { + return GVF; + } + + /** + * {@inheritDoc} + * + *
+ * Setter for the field inletStream
.
+ *
+ * Setter for the field pressure
.
+ *
+ * getTemperature. + *
+ * + * @return a double + */ + public double getTemperature() { + return temperature; + } + + /** + *
+ * Setter for the field temperature
.
+ *
+ * getGOR. + *
+ * + * @return a double + */ + public double getGOR() { + return GOR; + } + + /** + *+ * setGOR. + *
+ * + * @param gOR a double + */ + public void setGOR(double gOR) { + fitAsGVF = false; + this.GOR = gOR; + } + + /** + *+ * setGVF. + *
+ * + * @param gvf a double + */ + public void setGVF(double gvf) { + fitAsGVF = true; + this.GOR = gvf; + } + + /** + *
+ * Getter for the field referenceConditions
.
+ *
+ * Setter for the field referenceConditions
.
+ *
+ * isFitAsGVF. + *
+ * + * @return the fitAsGVF + */ + public boolean isFitAsGVF() { + return fitAsGVF; + } + + /** + *
+ * Setter for the field fitAsGVF
.
+ *
+ * Getter for the field referenceFluidPackage
.
+ *
+ * Setter for the field referenceFluidPackage
.
+ *
inletStream
.
*
*/
+ @Override
public void setInletStream(StreamInterface inletStream) {
this.inStream = inletStream;
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java b/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java
index 87af343110..9ee7a3f63e 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/NeqSimUnit.java
@@ -54,6 +54,7 @@ public NeqSimUnit(StreamInterface inletStream, String equipment, String flowPatt
* Setter for the field inletStream
.
*
*/
+ @Override
public void setInletStream(StreamInterface inletStream) {
this.inStream = inletStream;
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/PressureDrop.java b/src/main/java/neqsim/processSimulation/processEquipment/util/PressureDrop.java
index 38dc472117..95d08817a0 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/util/PressureDrop.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/util/PressureDrop.java
@@ -14,7 +14,7 @@
*
* The pressure drop unit is used to simulate pressure drops in process plant. The proessure drop is
* simulated using a constant enthalpy flash.
- *
+ *
* @author esol
* @version $Id: $Id
*/
@@ -29,13 +29,19 @@ public class PressureDrop extends ThrottlingValve {
* * Constructor for PressureDrop. *
- * + * * @param name the name of the pressure drop unit */ public PressureDrop(String name) { super(name); } + /** + *Setter for the field pressureDrop
.
- * Getter for the field outletStream
.
- *
- * Constructor for StreamSaturatorUtil. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public StreamSaturatorUtil(StreamInterface inletStream) { - this("StreamSaturatorUtil", inletStream); - } - /** * Constructor for StreamSaturatorUtil. * @@ -55,6 +42,7 @@ public StreamSaturatorUtil(String name, StreamInterface inStream) { * Setter for the fieldinletStream
.
*
*/
+ @Override
public void setInletStream(StreamInterface inletStream) {
this.inStream = inletStream;
diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/SafetyValve.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/SafetyValve.java
index a9360349fc..3d94590a77 100644
--- a/src/main/java/neqsim/processSimulation/processEquipment/valve/SafetyValve.java
+++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/SafetyValve.java
@@ -16,29 +16,6 @@ public class SafetyValve extends ThrottlingValve {
private double pressureSpec = 10.0;
private double fullOpenPressure = 10.0;
- /**
- * - * Constructor for SafetyValve. - *
- */ - @Deprecated - public SafetyValve() { - this("SafetyValve"); - } - - /** - *- * Constructor for SafetyValve. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public SafetyValve(StreamInterface inletStream) { - this("SafetyValve", inletStream); - } - /** * Constructor for SafetyValve. * diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java index 6fd0fae3bc..3063231105 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValve.java @@ -1,9 +1,14 @@ package neqsim.processSimulation.processEquipment.valve; import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import com.google.gson.GsonBuilder; import neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.ValveResponse; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -17,7 +22,7 @@ */ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface { private static final long serialVersionUID = 1000; - + static Logger logger = LogManager.getLogger(ThrottlingValve.class); SystemInterface thermoSystem; private boolean valveCvSet = false; @@ -28,34 +33,16 @@ public class ThrottlingValve extends TwoPortEquipment implements ValveInterface private double Cv; private double maxMolarFlow = 1000.0; private double minMolarFlow = 0.0; + private double maxValveOpening = 100.0; + private double minValveOpening = 0.0; private double percentValveOpening = 100.0; double molarFlow = 0.0; private String pressureUnit = "bara"; private boolean acceptNegativeDP = true; ValveMechanicalDesign valveMechanicalDesign; - - /** - *- * Constructor for ThrottlingValve. - *
- */ - public ThrottlingValve() { - this("ThrottlingValve"); - setCalculateSteadyState(false); - } - - /** - *- * Constructor for ThrottlingValve. - *
- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public ThrottlingValve(StreamInterface inletStream) { - this("ThrottlingValve", inletStream); - } + boolean isCalcPressure = false; + private boolean gasValve = true; + private double Fp = 1.0; /** * * Constructor for ThrottlingValve. @@ -64,6 +51,7 @@ public ThrottlingValve(StreamInterface inletStream) { */ public ThrottlingValve(String name) { super(name); + setCalculateSteadyState(false); } /** @@ -76,7 +64,7 @@ public ThrottlingValve(String name) { * object */ public ThrottlingValve(String name, StreamInterface inletStream) { - super(name); + this(name); setInletStream(inletStream); } @@ -92,15 +80,6 @@ public double getDeltaPressure(String unit) { return inStream.getFluid().getPressure(unit) - thermoSystem.getPressure(unit); } - /** {@inheritDoc} */ - @Override - public void setInletStream(StreamInterface stream) { - super.setInletStream(stream); - StreamInterface outStream = stream.clone(); - outStream.setName("outStream"); - super.setOutletStream(outStream); - } - /** {@inheritDoc} */ @Override public double getOutletPressure() { @@ -172,6 +151,264 @@ && getOutletPressure() == getOutletStream().getPressure()) { } } + /** + * Adjusts the flow coefficient (Cv) based on the percentage valve opening. + * + * @param Cv Flow coefficient in US gallons per minute (USG/min). + * @param percentValveOpening Percentage valve opening (0 to 100). + * @return Adjusted flow coefficient (Cv) in US gallons per minute (USG/min). + */ + private static double adjustCv(double Cv, double percentValveOpening) { + return Cv * (percentValveOpening / 100); + } + + /** + * Calculates the mass flow rate through a control valve for a liquid based on the given + * parameters. + * + * @param P1 Upstream pressure in bar. + * @param P2 Downstream pressure in bar. + * @param rho Density of the fluid in kilograms per cubic meter (kg/m³). + * @param Cv Flow coefficient in US gallons per minute (USG/min). + * @param Fp Piping geometry factor (dimensionless). + * @param percentValveOpening Percentage valve opening (0 to 100). + * @return Mass flow rate in kilograms per hour (kg/h). + */ + public static double liquidValveMassFlow(double P1, double P2, double rho, double Cv, double Fp, + double percentValveOpening) { + // Equation unit conversion constant + final double N1 = 0.0865; + + // Convert pressures from bar to Pascals directly in the code + double P1Pa = P1 * 100000; + double P2Pa = P2 * 100000; + + // Adjust Cv based on the percentage valve opening + double adjustedCv = adjustCv(Cv, percentValveOpening); + + // Clip Cv value to be non-negative + double clippedCv = Math.max(adjustedCv, 0); + // Calculate pressure difference and clip to be non-negative + double deltaP = Math.max(P1Pa - P2Pa, 0); + // Calculate mass flow rate + double massFlowRate = clippedCv * N1 * Fp * Math.sqrt(deltaP * rho); + + return massFlowRate; + } + + /** + * Calculates the percent valve opening given the mass flow rate through a valve, upstream + * pressure (P1), downstream pressure (P2), fluid density (rho), flow coefficient (Cv), and piping + * geometry factor (Fp). + * + * @param massFlowRate The mass flow rate through the valve in kg/hr. + * @param P1 The upstream pressure in bar. + * @param P2 The downstream pressure in bar. + * @param rho The density of the fluid in kilograms per cubic meter (kg/m³). + * @param Cv The flow coefficient of the valve in US gallons per minute (USG/min). + * @param Fp The piping geometry factor (dimensionless). + * @return The percent valve opening. + */ + public static double calcPercentValveOpeningLiquid(double massFlowRate, double P1, double P2, + double rho, double Cv, double Fp) { + // Equation unit conversion constant + final double N1 = 0.0865; + + // Convert pressures from bar to Pascals directly in the code + double P1Pa = P1 * 100000; + double P2Pa = P2 * 100000; + + // Calculate pressure difference and clip to be non-negative + double deltaP = Math.max(P1Pa - P2Pa, 0); + + // Calculate the denominator part of the equation + double denominator = Cv * N1 * Fp * Math.sqrt(deltaP * rho); + + // Calculate percent valve opening + double percentValveOpening = (massFlowRate / denominator) * 100; + + return percentValveOpening; + } + + /** + * Calculates the downstream pressure (P2) through a control valve for a liquid based on the given + * parameters. + * + * @param P1 Upstream pressure in bar. + * @param m Mass flow rate in kilograms per hour (kg/h). + * @param rho Density of the fluid in kilograms per cubic meter (kg/m³). + * @param Cv Flow coefficient in US gallons per minute (USG/min). + * @param Fp Piping geometry factor (dimensionless). + * @param percentValveOpening Percentage valve opening (0 to 100). + * @return Downstream pressure in bar. + */ + public static double liquidValvePout(double P1, double m, double rho, double Cv, double Fp, + double percentValveOpening) { + // Equation unit conversion constant + final double N1 = 0.0865; + + // Convert upstream pressure from bar to Pascals directly in the code + double P1Pa = P1 * 100000; + + // Adjust Cv based on the percentage valve opening + double adjustedCv = adjustCv(Cv, percentValveOpening); + + // Clip Cv value to be non-negative + double clippedCv = Math.max(adjustedCv, 0); + // Calculate deltaP from mass flow rate + double deltaP = Math.pow(m / (clippedCv * N1 * Fp), 2) / rho; + // Calculate downstream pressure + double P2Pa = P1Pa - deltaP; + + // Ensure downstream pressure is non-negative + P2Pa = Math.max(P2Pa, 0); + + // Convert downstream pressure from Pascals to bar directly in the code + return P2Pa / 100000; + } + + /** + * Calculates the flow coefficient (Cv) of a control valve for a liquid based on the given + * parameters. + * + * @param P1 Upstream pressure in bar. + * @param P2 Downstream pressure in bar. + * @param rho Density of the fluid in kilograms per cubic meter (kg/m³). + * @param m Mass flow rate in kilograms per hour (kg/h). + * @param Fp Piping geometry factor (dimensionless). + * @param percentValveOpening Percentage valve opening (0 to 100). + * @return Flow coefficient (Cv) in US gallons per minute (USG/min). + */ + public static double liquidValveCv(double P1, double P2, double rho, double m, double Fp, + double percentValveOpening) { + // Equation unit conversion constant + final double N1 = 0.0865; + + // Convert pressures from bar to Pascals directly in the code + double P1Pa = P1 * 100000; + double P2Pa = P2 * 100000; + + // Calculate pressure difference and clip to be non-negative + double deltaP = Math.max(P1Pa - P2Pa, 0); + // Calculate flow coefficient + double Cv = m / (N1 * Fp * Math.sqrt(deltaP * rho)); + + // Adjust Cv based on the percentage valve opening + return Cv / (percentValveOpening / 100); + } + + /** + * Calculates the mass flow rate through a valve given the upstream pressure (Pus), downstream + * pressure (Pds), fluid density (rhous), and flow coefficient (Cv). + * + *+ * The calculation is based on the formula for mass flow through a valve. + *
+ * + * @param Pus The upstream pressure (Pus) in bara. + * @param Pds The downstream pressure (Pds) in bara. + * @param rhous The density of the fluid upstream of the valve in kg/m^3. + * @param Cv The flow coefficient of the valve. + * @param percentValveOpening Opening of valve in % + * @return The mass flow rate through the valve in kg/hr. + */ + public double calcmassflow(double Pus, double Pds, double rhous, double Cv, + double percentValveOpening) { + // Sine of 3417 / 30.0 + double sineFactor = Math.sin(3417 / 30.0); + + // Calculate the mass flow rate + double massFlowRate = 0.0457 * Math.sqrt(Pus * 100.0 * rhous) * sineFactor + * Math.sqrt((Pus - Pds) / Pus) * Cv * percentValveOpening / 100.0; + return massFlowRate; + } + + /** + * Calculates the downstream pressure (Pds) of a valve given the upstream pressure (Pus), fluid + * density (rhous), flow coefficient (Cv), mass flow rate, and the percent valve opening. + * + * The calculation is based on the formula for mass flow through a valve, rearranged to solve for + * Pds. + * + * @param Pus The upstream pressure (Pus) in bara. + * @param rhous The density of the fluid upstream of the valve in kg/m^3. + * @param Cv The flow coefficient of the valve. + * @param massFlowRate The mass flow rate through the valve in kg/hr. + * @param percentValveOpening Opening of valve in % + * @return The downstream pressure (Pds) in bara. + */ + public double calcValvePout(double Pus, double rhous, double Cv, double massFlowRate, + double percentValveOpening) { + // Sine of 3417 / 30.0 + double sineFactor = Math.sin(3417 / 30.0); + + // Calculate the term that involves the mass flow rate, Cv, and percent valve opening + double flowTerm = (massFlowRate / (0.0457 * Math.sqrt(Pus * 100.0 * rhous) * sineFactor * Cv + * (percentValveOpening / 100.0))); + + // Square the flowTerm to eliminate the square root + double flowTermSquared = flowTerm * flowTerm; + + // Calculate Pds + double Pds = Pus * (1 - flowTermSquared); + + return Pds; + } + + /** + * Calculates the flow coefficient (Cv) of a valve given the upstream pressure (Pus), downstream + * pressure (Pds), fluid density (rhous), mass flow rate, and the percent valve opening. + * + * The calculation is based on the formula for mass flow through a valve, rearranged to solve for + * Cv. + * + * @param Pus The upstream pressure (Pus) in bara. + * @param Pds The downstream pressure (Pds) in bara. + * @param rhous The density of the fluid upstream of the valve in kg/m^3. + * @param massFlowRate The mass flow rate through the valve in kg/hr. + * @param percentValveOpening Opening of valve in % + * @return The flow coefficient (Cv) of the valve. + */ + public double calcCv(double Pus, double Pds, double rhous, double massFlowRate, + double percentValveOpening) { + // Sine of 3417 / 30.0 + double sineFactor = Math.sin(3417 / 30.0); + + // Calculate Cv + double Cv = massFlowRate / (0.0457 * Math.sqrt(Pus * 100.0 * rhous) * sineFactor + * Math.sqrt((Pus - Pds) / Pus) * percentValveOpening / 100.0); + + return Cv; + } + + /** + * Calculates the percent valve opening given the upstream pressure (Pus), downstream pressure + * (Pds), fluid density (rhous), flow coefficient (Cv), and mass flow rate. + * + * The calculation is based on the formula for mass flow through a valve, rearranged to solve for + * percent valve opening. + * + * @param Pus The upstream pressure (Pus) in bara. + * @param Pds The downstream pressure (Pds) in bara. + * @param rhous The density of the fluid upstream of the valve in kg/m^3. + * @param Cv The flow coefficient of the valve. + * @param massFlowRate The mass flow rate through the valve in kg/hr. + * @return The percent valve opening. + */ + public double calcPercentValveOpening(double Pus, double Pds, double rhous, double Cv, + double massFlowRate) { + // Sine of 3417 / 30.0 + double sineFactor = Math.sin(3417 / 30.0); + + // Calculate the term that involves the mass flow rate, Pus, rhous, and Cv + double term = massFlowRate / (0.0457 * Math.sqrt(Pus * 100 * rhous) * sineFactor * Cv); + + // Calculate the percent valve opening + double percentValveOpening = term / Math.sqrt(1 - (Pds / Pus)) * 100.0; + + return percentValveOpening; + } + /** {@inheritDoc} */ @Override public void run(UUID id) { @@ -181,6 +418,29 @@ public void run(UUID id) { ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); thermoSystem.init(3); double enthalpy = thermoSystem.getEnthalpy(); + inStream.getThermoSystem().initPhysicalProperties("density"); + double outp = 0.0; + + if (inStream.getThermoSystem().hasPhaseType(PhaseType.GAS) + && inStream.getThermoSystem().getVolumeFraction(0) > 0.9) { + setGasValve(true); + } else { + setGasValve(false); + } + + if (valveCvSet && isCalcPressure) { + if (gasValve) { + outp = calcValvePout(inStream.getThermoSystem().getPressure(), + inStream.getThermoSystem().getDensity("kg/m3"), Cv, inStream.getFlowRate("kg/hr"), + percentValveOpening); + } else { + outp = + liquidValvePout(inStream.getThermoSystem().getPressure(), inStream.getFlowRate("kg/hr"), + inStream.getThermoSystem().getDensity("kg/m3"), Cv, Fp, percentValveOpening); + } + setOutletPressure(outp); + } + if ((thermoSystem.getPressure(pressureUnit) - pressure) < 0) { if (isAcceptNegativeDP()) { thermoSystem.setPressure(pressure, pressureUnit); @@ -207,39 +467,55 @@ public void run(UUID id) { // inletStream.getThermoSystem().getDensity()); if (!valveCvSet) { - // If valve CV is not set, calculate it from inletstream flow, percent opening and + // If valve CV is not set, calculate it from inletstream flow, percent opening + // and // differential pressure over valve. - Cv = inStream.getThermoSystem().getTotalNumberOfMoles() / (getPercentValveOpening() / 100.0 - * Math.sqrt( - (inStream.getThermoSystem().getPressure() - outStream.getThermoSystem().getPressure()) - / thermoSystem.getDensity())); + if (gasValve) { + Cv = calcCv(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), + inStream.getFlowRate("kg/hr"), percentValveOpening); + } else { + Cv = liquidValveCv(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), + inStream.getFlowRate("kg/hr"), Fp, percentValveOpening); + } valveCvSet = true; } + if (gasValve) { + percentValveOpening = calcPercentValveOpening(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), Cv, + inStream.getFlowRate("kg/hr")); + } else { + percentValveOpening = calcPercentValveOpeningLiquid(inStream.getFlowRate("kg/hr"), + inStream.getThermoSystem().getPressure(), outStream.getThermoSystem().getPressure(), + inStream.getFluid().getDensity("kg/m3"), Cv, Fp); + } - percentValveOpening = inStream.getThermoSystem().getTotalNumberOfMoles() / (getCv()) * 100.0 - / Math.sqrt( - (inStream.getThermoSystem().getPressure() - outStream.getThermoSystem().getPressure()) - / thermoSystem.getDensity()); + if (gasValve) { + molarFlow = calcmassflow(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), Cv, + percentValveOpening) / 3600.0 / inStream.getFluid().getMolarMass("kg/mol"); + } else { + molarFlow = liquidValveMassFlow(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), Cv, + Fp, percentValveOpening) / 3600.0 / inStream.getFluid().getMolarMass("kg/mol"); + } - molarFlow = getCv() * getPercentValveOpening() / 100.0 - * Math.sqrt( - (inStream.getThermoSystem().getPressure() - outStream.getThermoSystem().getPressure()) - / thermoSystem.getDensity()); if (Math.abs(pressure - inStream.getThermoSystem().getPressure()) < 1e-6) { molarFlow = inStream.getThermoSystem().getTotalNumberOfMoles(); } - inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); - inStream.getThermoSystem().init(3); + try { + inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); + inStream.getThermoSystem().init(3); + } catch (Exception e) { + logger.error(e.getMessage()); + } // inletStream.run(id); outStream.setThermoSystem(thermoSystem.clone()); outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); outStream.getThermoSystem().init(3); - // outStream.run(id); - // Cv = - // inletStream.getThermoSystem().getTotalNumberOfMoles()/Math.sqrt(inletStream.getPressure()-outStream.getPressure()); - // molarFlow = inletStream.getThermoSystem().getTotalNumberOfMoles(); outStream.setCalculationIdentifier(id); setCalculationIdentifier(id); } @@ -281,33 +557,31 @@ public void runTransient(double dt, UUID id) { } thermoSystem.initPhysicalProperties("density"); outStream.setThermoSystem(thermoSystem); - // if(getPercentValveOpening()<99){ - molarFlow = getCv() * getPercentValveOpening() / 100.0 - * Math.sqrt( - (inStream.getThermoSystem().getPressure() - outStream.getThermoSystem().getPressure()) - / thermoSystem.getDensity()); - // System.out.println("molar flow " + molarFlow); - // System.out.println("Cv " + getCv()); - // System.out.println("density " + inletStream.getThermoSystem().getDensity()); - - // 8 } else { - // molarFlow=inletStream.getThermoSystem().getTotalNumberOfMoles(); - // } - - inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); - inStream.getThermoSystem().init(1); - inStream.run(id); - outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); - outStream.getThermoSystem().init(1); - outStream.run(id); + if (gasValve) { + molarFlow = calcmassflow(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), Cv, + percentValveOpening) / 3600.0 / inStream.getFluid().getMolarMass("kg/mol"); + } else { + molarFlow = liquidValveMassFlow(inStream.getThermoSystem().getPressure(), + outStream.getThermoSystem().getPressure(), inStream.getFluid().getDensity("kg/m3"), Cv, + Fp, percentValveOpening) / 3600.0 / inStream.getFluid().getMolarMass("kg/mol"); + } - // System.out.println("delta p valve " + - // (inletStream.getThermoSystem().getPressure() - - // outStream.getThermoSystem().getPressure())); - // System.out.println("total molar flow out " + molarFlow); - // System.out.println("Total volume flow " + - // outStream.getThermoSystem().getVolume()); + try { + inStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); + inStream.getThermoSystem().init(1); + inStream.run(id); + } catch (Exception e) { + logger.error(e.getMessage()); + } + try { + outStream.getThermoSystem().setTotalNumberOfMoles(molarFlow); + outStream.getThermoSystem().init(1); + outStream.run(id); + } catch (Exception e) { + logger.error(e.getMessage()); + } setCalculationIdentifier(id); } @@ -320,26 +594,47 @@ public void runTransient(double dt, UUID id) { * @param id Calculation identifier */ public void runController(double dt, UUID id) { - if (hasController) { + if (hasController && getController().isActive()) { getController().runTransient(this.percentValveOpening, dt, id); this.percentValveOpening = getController().getResponse(); - if (this.percentValveOpening > 100) { - this.percentValveOpening = 100; + if (this.percentValveOpening > maxValveOpening) { + this.percentValveOpening = maxValveOpening; } - if (this.percentValveOpening < 0) { - this.percentValveOpening = 1e-10; + if (this.percentValveOpening < minValveOpening) { + this.percentValveOpening = minValveOpening; } // System.out.println("valve opening " + this.percentValveOpening + " %"); } setCalculationIdentifier(id); } + /** + *+ * setMinimumValveOpening. + *
+ * + * @param minopen a double + */ + public void setMinimumValveOpening(double minopen) { + minValveOpening = minopen; + } + /** {@inheritDoc} */ @Override public double getCv() { return Cv; } + /** {@inheritDoc} */ + @Override + public double getCv(String unit) { + if (unit.equals("US")) { + return Cv / 54.9; + } else { + return Cv; + } + } + /** {@inheritDoc} */ @Override public void setCv(double cv) { @@ -347,6 +642,17 @@ public void setCv(double cv) { valveCvSet = true; } + /** {@inheritDoc} */ + @Override + public void setCv(double cv, String unit) { + if (unit.equals("US")) { + this.Cv = cv * 54.9; + } else { + this.Cv = cv; + } + valveCvSet = true; + } + /** {@inheritDoc} */ @Override public double getPercentValveOpening() { @@ -433,19 +739,76 @@ public void setAcceptNegativeDP(boolean acceptNegativeDP) { this.acceptNegativeDP = acceptNegativeDP; } + /** {@inheritDoc} */ @Override public void initMechanicalDesign() { valveMechanicalDesign = new ValveMechanicalDesign(this); } + /** {@inheritDoc} */ + @Override + public ValveMechanicalDesign getMechanicalDesign() { + return valveMechanicalDesign; + } /** - * {@inheritDoc} + *+ * setIsCalcOutPressure. + *
* - * @return a {@link neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign} object + * @param isSetPres a boolean */ + public void setIsCalcOutPressure(boolean isSetPres) { + isCalcPressure = isSetPres; + } + + /** {@inheritDoc} */ @Override - public ValveMechanicalDesign getMechanicalDesign() { - return valveMechanicalDesign; + public String toJson() { + return new GsonBuilder().create().toJson(new ValveResponse(this)); + } + + /** + *+ * isGasValve. + *
+ * + * @return a boolean + */ + public boolean isGasValve() { + return gasValve; + } + + /** + *
+ * Setter for the field gasValve
.
+ *
+ * getFp. + *
+ * + * @return a double + */ + public double getFp() { + return Fp; + } + + /** + *+ * setFp. + *
+ * + * @param fp a double + */ + public void setFp(double fp) { + Fp = fp; } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java index 21a4fd1ce2..9de6989699 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/valve/ValveInterface.java @@ -64,6 +64,16 @@ public interface ValveInterface extends ProcessEquipmentInterface, TwoPortInterf */ public double getCv(); + /** + *+ * getCv. + *
+ * + * @param unit can be SI or US SI is unit litre/minute US is gallons per minute + * @return a double + */ + public double getCv(String unit); + /** ** setCv. @@ -73,6 +83,16 @@ public interface ValveInterface extends ProcessEquipmentInterface, TwoPortInterf */ public void setCv(double Cv); + /** + *
+ * setCv. + *
+ * + * @param Cv a double + * @param unit can be SI or US SI is unit litre/minute US is gallons per minute + */ + public void setCv(double Cv, String unit); + /** {@inheritDoc} */ @Override public SystemInterface getThermoSystem(); diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessModule.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessModule.java index 705948fce4..4c9cf560bb 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessModule.java @@ -3,14 +3,13 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; - import org.apache.commons.lang.SerializationUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.SimulationBaseClass; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.util.Recycle; +import neqsim.processSimulation.util.report.Report; /** * A class representing a process module class that can contain unit operations and other modules. @@ -18,9 +17,7 @@ * then run only once. * * @author [seros] - * * @version 1.0 - * */ public class ProcessModule extends SimulationBaseClass { private static final long serialVersionUID = 1000; @@ -59,7 +56,6 @@ public ProcessModule(String name) { * * @param processSystem the process system that contains the unit operations to be added. */ - public void add(ProcessSystem processSystem) { addedUnitOperations.add(processSystem); operationsIndex.add(unitIndex++); @@ -70,7 +66,6 @@ public void add(ProcessSystem processSystem) { * * @param module the process module to be added */ - public void add(ProcessModule module) { addedModules.add(module); modulesIndex.add(unitIndex++); @@ -91,7 +86,6 @@ public List* Create deep copy. @@ -236,4 +244,30 @@ public ProcessModule copy() { ProcessModule copyModule = (ProcessModule) SerializationUtils.deserialize(bytes); return copyModule; } + + /** + *
+ * getReport. + *
+ * + * @return a {@link java.util.ArrayList} object + */ + public ArrayList- * getResultTable. - *
- * - * @return an array of {@link java.lang.String} objects - */ + /** {@inheritDoc} */ + @Override public String[][] getResultTable() { return null; } @@ -238,7 +234,27 @@ public String[][] getResultTable() { * getPressure. * */ + @Override public double getPressure(String unit) { return 1.0; } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return null; + } + + /** + * {@inheritDoc} + * + * @return a String + */ + public String getReport_json() { + return new Report(this).generateJsonReport(); + } + + /** {@inheritDoc} */ + @Override + public void run_step(UUID id) {} } diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java index c32529e658..fc3e1775f9 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java @@ -18,6 +18,7 @@ import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.util.RecycleController; +import neqsim.processSimulation.util.report.Report; import neqsim.thermo.system.SystemInterface; /** @@ -33,7 +34,7 @@ public class ProcessSystem extends SimulationBaseClass { static Logger logger = LogManager.getLogger(ProcessSystem.class); transient Thread thisThread; - String[][] signalDB = new String[1000][100]; + String[][] signalDB = new String[10000][100]; private double surroundingTemperature = 288.15; private int timeStepNumber = 0; private ArrayList- * add. + * Add to end. *
* * @param operation a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} * object */ public void add(ProcessEquipmentInterface operation) { + // Add to end + add(this.getUnitOperations().size(), operation); + } + + /** + *+ * Add to specific position. + *
+ * + * @param position 0-based position + * @param operation a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} + * object + */ + public void add(int position, ProcessEquipmentInterface operation) { ArrayList- * add. + * Add measurementdevice. *
* * @param measurementDevice a @@ -109,7 +123,7 @@ public void add(MeasurementDeviceInterface measurementDevice) { /** *- * add. + * Add multiple process equipment to end. *
* * @param operations an array of @@ -121,10 +135,10 @@ public void add(ProcessEquipmentInterface[] operations) { /** *- * getUnit. + * Get process equipmen by name. *
* - * @param name a {@link java.lang.String} object + * @param name Name of * @return a {@link java.lang.Object} object */ public Object getUnit(String name) { @@ -163,13 +177,13 @@ public boolean hasUnitName(String name) { /** *- * getMeasurementDevice. + * Get MeasureDevice by name. *
* - * @param name a {@link java.lang.String} object - * @return a {@link java.lang.Object} object + * @param name Name of measurement device + * @return a {@link neqsim.processSimulation.measurementDevice.MeasurementDeviceInterface} object */ - public Object getMeasurementDevice(String name) { + public MeasurementDeviceInterface getMeasurementDevice(String name) { for (int i = 0; i < measurementDevices.size(); i++) { if (measurementDevices.get(i).getName().equals(name)) { return measurementDevices.get(i); @@ -372,14 +386,14 @@ public Thread runAsThread() { /** {@inheritDoc} */ @Override public void run(UUID id) { - boolean hasResycle = false; + boolean hasRecycle = false; // boolean hasAdjuster = false; // Initializing recycle controller recycleController.clear(); for (int i = 0; i < unitOperations.size(); i++) { if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { - hasResycle = true; + hasRecycle = true; recycleController.addRecycle((Recycle) unitOperations.get(i)); } if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { @@ -396,9 +410,8 @@ public void run(UUID id) { for (int i = 0; i < unitOperations.size(); i++) { if (!unitOperations.get(i).getClass().getSimpleName().equals("Recycle")) { try { - if (iter == 1 - || ((ProcessEquipmentInterface) unitOperations.get(i)).needRecalculation()) { - ((ProcessEquipmentInterface) unitOperations.get(i)).run(id); + if (iter == 1 || unitOperations.get(i).needRecalculation()) { + unitOperations.get(i).run(id); } } catch (Exception ex) { // String error = ex.getMessage(); @@ -408,7 +421,7 @@ public void run(UUID id) { if (unitOperations.get(i).getClass().getSimpleName().equals("Recycle") && recycleController.doSolveRecycle((Recycle) unitOperations.get(i))) { try { - ((ProcessEquipmentInterface) unitOperations.get(i)).run(id); + unitOperations.get(i).run(id); } catch (Exception ex) { // String error = ex.getMessage(); logger.error(ex.getMessage(), ex); @@ -438,26 +451,55 @@ public void run(UUID id) { /* * signalDB = new String[1000][1 + 3 * measurementDevices.size()]; - * + * * signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; for (int i = 0; i * < measurementDevices.size(); i++) { signalDB[timeStepNumber][0] = Double.toString(time); * signalDB[timeStepNumber][3 * i + 1] = ((MeasurementDeviceInterface) * measurementDevices.get(i)) .getName(); signalDB[timeStepNumber][3 * i + 2] = Double * .toString(((MeasurementDeviceInterface) measurementDevices.get(i)).getMeasuredValue()); * signalDB[timeStepNumber][3 * i + 3] = ((MeasurementDeviceInterface) - * measurementDevices.get(i)) .getUnit(); - * - * } + * measurementDevices.get(i)) .getUnit(); } */ - } while ((!isConverged || (iter < 2 && hasResycle)) && iter < 100); + } while ((!isConverged || (iter < 2 && hasRecycle)) && iter < 100); for (int i = 0; i < unitOperations.size(); i++) { - ((ProcessEquipmentInterface) unitOperations.get(i)).setCalculationIdentifier(id); + unitOperations.get(i).setCalculationIdentifier(id); } setCalculationIdentifier(id); } + /** {@inheritDoc} */ + @Override + public void run_step(UUID id) { + for (int i = 0; i < unitOperations.size(); i++) { + try { + // if (unitOperations.get(i).needRecalculation()) { + unitOperations.get(i).run(id); + // } + } catch (Exception ex) { + // String error = ex.getMessage(); + logger.error(ex.getMessage(), ex); + } + } + for (int i = 0; i < unitOperations.size(); i++) { + unitOperations.get(i).setCalculationIdentifier(id); + } + setCalculationIdentifier(id); + } + + /* + * signalDB = new String[1000][1 + 3 * measurementDevices.size()]; + * + * signalDB[timeStepNumber] = new String[1 + 3 * measurementDevices.size()]; for (int i = 0; i < + * measurementDevices.size(); i++) { signalDB[timeStepNumber][0] = Double.toString(time); + * signalDB[timeStepNumber][3 * i + 1] = ((MeasurementDeviceInterface) measurementDevices.get(i)) + * .getName(); signalDB[timeStepNumber][3 * i + 2] = Double + * .toString(((MeasurementDeviceInterface) measurementDevices.get(i)).getMeasuredValue()); + * signalDB[timeStepNumber][3 * i + 3] = ((MeasurementDeviceInterface) measurementDevices.get(i)) + * .getUnit(); } + */ + /** ** runTransient. @@ -501,13 +543,8 @@ public boolean solved() { return true; } - /** - *
- * Getter for the field time
.
- *
- * Getter for the field name
.
- *
- * Setter for the field name
.
- *
@@ -36,7 +37,9 @@ public class AdsorptionDehydrationlModule extends ProcessModuleBaseClass { double adsorbentFillingHeight = 3.0; /** - *
Constructor for AdsorptionDehydrationlModule.
+ *+ * Constructor for AdsorptionDehydrationlModule. + *
* * @param name a {@link java.lang.String} object */ @@ -107,8 +110,7 @@ public void initializeStreams() { for (int i = 0; i < numberOfAdsorptionBeds; i++) { adsorber[i] = new SimpleAdsorber("SimpleAdsorber_" + i + 1, gasStreamToAdsorber); } - this.gasStreamFromAdsorber = (Stream) this.gasStreamToAdsorber.clone(); - this.gasStreamFromAdsorber.setName("Stream from Adsorber"); + this.gasStreamFromAdsorber = this.gasStreamToAdsorber.clone("Stream from Adsorber"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -160,8 +162,8 @@ public void calcDesign() { double gasVelocity = 67.0 / Math.sqrt(gasDensity); double qa = designFlow / (numberOfAdsorptionBeds - 1.0) / 1440.0 - * (1.01325 / designAdsorptionPressure) * (designAdsorptionTemperature / 288.15) - * tempStream.getThermoSystem().getPhase(0).getZ(); + * (ThermodynamicConstantsInterface.referencePressure / designAdsorptionPressure) + * (designAdsorptionTemperature / 288.15) * tempStream.getThermoSystem().getPhase(0).getZ(); adsorberInternalDiameter = Math.sqrt(4.0 * qa / Math.PI / gasVelocity); double waterLoadingCycle = regenerationCycleTime * designFlow * 42.29489667 diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java index 9352b7e63c..5e480f15d5 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/CO2RemovalModule.java @@ -4,7 +4,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.separator.Separator; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; @@ -26,7 +25,9 @@ public class CO2RemovalModule extends ProcessModuleBaseClass { protected Separator inletSeparator = null; /** - *Constructor for CO2RemovalModule.
+ *+ * Constructor for CO2RemovalModule. + *
* * @param name a {@link java.lang.String} object */ @@ -63,7 +64,7 @@ public void run(UUID id) { } getOperations().run(id); - streamFromAbsorber = (Stream) inletSeparator.getGasOutStream().clone(); + streamFromAbsorber = inletSeparator.getGasOutStream().clone(); streamFromAbsorber.getThermoSystem().addComponent("CO2", -streamFromAbsorber.getThermoSystem() .getPhase(0).getComponent("CO2").getNumberOfMolesInPhase() * 0.99); streamFromAbsorber.getThermoSystem().addComponent("MEG", -streamFromAbsorber.getThermoSystem() @@ -77,11 +78,8 @@ public void run(UUID id) { public void initializeStreams() { isInitializedStreams = true; try { - this.streamFromAbsorber = (Stream) this.streamToAbsorber.clone(); - this.streamFromAbsorber.setName("Stream from ABsorber"); - - this.gasFromCO2Stripper = (Stream) this.streamToAbsorber.clone(); - this.gasFromCO2Stripper.setName("Gas stream from Stripper"); + this.streamFromAbsorber = this.streamToAbsorber.clone("Stream from Absorber"); + this.gasFromCO2Stripper = this.streamToAbsorber.clone("Gas stream from Stripper"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java index 667c230361..f58eb9cc0a 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/DPCUModule.java @@ -1,6 +1,8 @@ package neqsim.processSimulation.processSystem.processModules; import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.compressor.Compressor; import neqsim.processSimulation.processEquipment.distillation.Condenser; import neqsim.processSimulation.processEquipment.distillation.DistillationColumn; @@ -28,16 +30,29 @@ */ public class DPCUModule extends ProcessModuleBaseClass { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ProcessModuleBaseClass.class); + + StreamInterface ethaneOvhComp; + StreamInterface gasDistColumnExit; + StreamInterface liquidDistColumnExit; + StreamInterface feedStream; + StreamInterface gasExitStream; + StreamInterface oilExitStream; + StreamInterface glycolFeedStream; + StreamInterface glycolExitStream; - StreamInterface ethaneOvhComp, gasDistColumnExit, liquidDistColumnExit, feedStream, gasExitStream, - oilExitStream, glycolFeedStream, glycolExitStream; Separator glycolScrubber; Separator inletSeparator; - double inletSepTemperature = 50.00, pressureAfterRedValve = 55.0; // bar' - double gasScrubberTemperature = 30.00, firstStageOutPressure = 110.0, - glycolScrubberTemperature = 20.0, secondStageOutPressure = 200.0; // bar - double glycolInjectionRate = 10.0, exportGasTemperature = 273.15 + 30.0, - liquidPumpPressure = 150.0; // m^3/hr + double inletSepTemperature = 50.00; + double pressureAfterRedValve = 55.0; + double gasScrubberTemperature = 30.00; + double firstStageOutPressure = 110.0; + double glycolScrubberTemperature = 20.0; + double secondStageOutPressure = 200.0; + double glycolInjectionRate = 10.0; + double exportGasTemperature = 273.15 + 30.0; + double liquidPumpPressure = 150.0; + Separator LTseparator; HeatExchanger heatExchanger1; ThrottlingValve valve1; @@ -47,7 +62,9 @@ public class DPCUModule extends ProcessModuleBaseClass { DistillationColumn distColumn; /** - *Constructor for DPCUModule.
+ *+ * Constructor for DPCUModule. + *
* * @param name a {@link java.lang.String} object */ @@ -60,9 +77,10 @@ public DPCUModule(String name) { public void addInputStream(String streamName, StreamInterface stream) { if (streamName.equals("feed stream")) { this.feedStream = stream; - } - if (streamName.equals("glycol feed stream")) { + } else if (streamName.equals("glycol feed stream")) { this.glycolFeedStream = stream; + } else { + logger.info("Stream name " + streamName + "not used."); } } @@ -127,7 +145,7 @@ public void initializeModule() { valve1 = new ThrottlingValve("valve1", LTseparator.getLiquidOutStream()); valve1.setOutletPressure(30.0); - distColumn = new DistillationColumn(10, true, true); + distColumn = new DistillationColumn("distColumn", 10, true, true); distColumn.addFeedStream(valve1.getOutletStream(), 2); // distColumn.setCondenserTemperature(273.15 - 72.0); // distColumn.setReboilerTemperature(273.0+40.0); @@ -150,55 +168,54 @@ public void initializeModule() { /* * Cooler inletCooler = new Cooler("inlet well stream cooler", feedStream); * inletCooler.setOutTemperature(inletSepTemperature + 273.15); - * + * * inletSeparator = new Separator("Inlet separator", inletCooler.getOutStream()); - * + * * Cooler gasCooler = new Cooler("separator gas cooler", inletSeparator.getGasOutStream()); * gasCooler.setOutTemperature(gasScrubberTemperature + 273.15); - * + * * oilPump = new Pump("liquid pump", inletSeparator.getLiquidOutStream()); * oilPump.setOutletPressure(liquidPumpPressure); - * + * * Separator gasScrubber = new Separator("HC dew point control scrubber", * gasCooler.getOutStream()); - * - * Recycle HPliquidRecycle = new Recycle("Resycle"); double tolerance = 1e-2; + * + * Recycle HPliquidRecycle = new Recycle("Recycle"); double tolerance = 1e-2; * HPliquidRecycle.setTolerance(tolerance); * HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); * inletSeparator.addStream(HPliquidRecycle.getOutStream()); - * + * * Compressor firstStageCompressor = new Compressor("1st stage compressor", * gasScrubber.getGasOutStream()); * firstStageCompressor.setOutletPressure(firstStageOutPressure); - * + * * glycolFeedStream.getThermoSystem().setPressure(firstStageOutPressure); - * + * * Mixer glycolMixer = new Mixer("glycol injection mixer"); * glycolMixer.addStream(firstStageCompressor.getOutStream()); * glycolMixer.addStream(glycolFeedStream); - * + * * Cooler mixerAfterCooler = new Cooler("glycol mixer after cooler", * glycolMixer.getOutStream()); mixerAfterCooler.setOutTemperature(glycolScrubberTemperature + * 273.15); - * + * * glycolScrubber = new Separator("Water dew point control scrubber", * mixerAfterCooler.getOutStream()); - * + * * secondStageCompressor = new Compressor("2nd stage compressor", * glycolScrubber.getGasOutStream()); * secondStageCompressor.setOutletPressure(secondStageOutPressure); - * + * * secondStageAfterCooler = new Cooler("second stage after cooler", * secondStageCompressor.getOutStream()); * secondStageAfterCooler.setOutTemperature(exportGasTemperature + 273.15); - * + * * getOperations().add(inletCooler); getOperations().add(inletSeparator); * getOperations().add(gasCooler); getOperations().add(oilPump); * getOperations().add(gasScrubber); getOperations().add(HPliquidRecycle); * getOperations().add(firstStageCompressor); getOperations().add(glycolMixer); * getOperations().add(mixerAfterCooler); getOperations().add(glycolScrubber); * getOperations().add(secondStageCompressor); getOperations().add(secondStageAfterCooler); - * */ } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java index cb369fd0bb..00add8a0b8 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/GlycolDehydrationlModule.java @@ -1,10 +1,8 @@ package neqsim.processSimulation.processSystem.processModules; import java.util.UUID; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.absorber.SimpleTEGAbsorber; import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; @@ -63,7 +61,9 @@ public class GlycolDehydrationlModule extends ProcessModuleBaseClass { double regenerationPressure = 1.4; /** - *Constructor for GlycolDehydrationlModule.
+ *+ * Constructor for GlycolDehydrationlModule. + *
* * @param name a {@link java.lang.String} object */ @@ -158,14 +158,9 @@ public void run(UUID id) { public void initializeStreams() { isInitializedStreams = true; try { - this.gasStreamFromAbsorber = this.gasStreamToAbsorber.clone(); - this.gasStreamFromAbsorber.setName("Stream from TEG Absorber"); - - this.gasFromStripper = this.gasStreamToAbsorber.clone(); - this.gasFromStripper.setName("Gas stream from Stripper"); - - this.leanTEGStreamToAbsorber = this.gasStreamToAbsorber.clone(); - this.leanTEGStreamToAbsorber.setName("lean TEG to absorber"); + this.gasStreamFromAbsorber = this.gasStreamToAbsorber.clone("Stream from TEG Absorber"); + this.gasFromStripper = this.gasStreamToAbsorber.clone("Gas stream from Stripper"); + this.leanTEGStreamToAbsorber = this.gasStreamToAbsorber.clone("lean TEG to absorber"); this.leanTEGStreamToAbsorber.getThermoSystem().setEmptyFluid(); this.leanTEGStreamToAbsorber.getThermoSystem().addComponent("water", @@ -203,7 +198,6 @@ public void initializeModule() { * stripperColumn.addFeedStream(valveMP.getOutStream(), 3); * stripperColumn.setCondenserTemperature(273.15 + 80.0); ((Reboiler) * stripperColumn.getReboiler()).setRefluxRatio(11.7); - * */ Heater reboiler = new Heater("reboiler", valveMP.getOutletStream()); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java index 0eb12202bf..9236518045 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/MEGReclaimerModule.java @@ -39,7 +39,9 @@ public class MEGReclaimerModule extends ProcessModuleBaseClass { double reclaimerPressure = 0.17; /** - *Constructor for MEGReclaimerModule.
+ *+ * Constructor for MEGReclaimerModule. + *
* * @param name a {@link java.lang.String} object */ @@ -73,14 +75,10 @@ public StreamInterface getOutputStream(String streamName) { public void initializeStreams() { isInitializedStreams = true; try { - this.streamToWaterRemoval = (Stream) this.streamToReclaimer.clone(); - this.streamToWaterRemoval.setName("Desalted MEG stream"); - - this.streamFromBoosterCompressor = (Stream) this.streamToReclaimer.clone(); - this.streamFromBoosterCompressor.setName("Stream from Booster Compressor"); - - this.streamWithWaste = (Stream) this.streamToReclaimer.clone(); - this.streamWithWaste.setName("Reclaimer Waste Stream"); + this.streamToWaterRemoval = this.streamToReclaimer.clone("Desalted MEG stream"); + this.streamFromBoosterCompressor = + this.streamToReclaimer.clone("Stream from Booster Compressor"); + this.streamWithWaste = this.streamToReclaimer.clone("Reclaimer Waste Stream"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java index c0ad2f3ac0..1072abe206 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/MixerGasProcessingModule.java @@ -45,7 +45,9 @@ public class MixerGasProcessingModule extends ProcessModuleBaseClass { Cooler secondStageAfterCooler; /** - *Constructor for MixerGasProcessingModule.
+ *+ * Constructor for MixerGasProcessingModule. + *
* * @param name a {@link java.lang.String} object */ @@ -103,7 +105,7 @@ public void initializeModule() { Separator gasScrubber = new Separator("HC dew point control scrubber", gasCooler.getOutletStream()); - Recycle HPliquidRecycle = new Recycle("Resycle"); + Recycle HPliquidRecycle = new Recycle("Recycle"); double tolerance = 1e-2; HPliquidRecycle.setTolerance(tolerance); HPliquidRecycle.addStream(gasScrubber.getLiquidOutStream()); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java index c3883e1cfa..c64241c632 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/PropaneCoolingModule.java @@ -20,7 +20,9 @@ */ public class PropaneCoolingModule extends ProcessModuleBaseClass { /** - *Constructor for PropaneCoolingModule.
+ *+ * Constructor for PropaneCoolingModule. + *
* * @param name a {@link java.lang.String} object */ @@ -82,11 +84,11 @@ public StreamInterface getOutputStream(String streamName) { /** {@inheritDoc} */ @Override public void initializeModule() { - UUID id = UUID.randomUUID(); isInitializedModule = true; refrigerantStream.getThermoSystem().setTemperature(condenserTemperature); ((Stream) refrigerantStream).setSpecification("bubT"); + UUID id = UUID.randomUUID(); refrigerantStream.run(id); ThrottlingValve JTvalve = new ThrottlingValve("JTvalve", refrigerantStream); @@ -111,7 +113,7 @@ public void initializeModule() { Heater condenser = new Heater("propane condenser", compressor1.getOutletStream()); condenser.setPressureDrop(0.07); condenser.setSpecification("out stream"); - condenser.setOutletStream((Stream) refrigerantStream); + condenser.setOutletStream(refrigerantStream); System.out.println("adding operations...."); getOperations().add(refrigerantStream); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java index 5ff7a28849..b01670ef1b 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModule.java @@ -151,7 +151,7 @@ public void initializeModule() { gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); - Recycle HPliquidRecycle = new Recycle("Resycle"); + Recycle HPliquidRecycle = new Recycle("Recycle"); double tolerance = 1e-10; HPliquidRecycle.setTolerance(tolerance); HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); @@ -271,7 +271,7 @@ public static void main(String[] args) { operations.add(wellStream); operations.add(separationModule); // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + // ((Recycle) operations.getUnit("Recycle")).setTolerance(1e-9); operations.run(); @@ -342,8 +342,9 @@ public static void main(String[] args) { * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); * System.out.println("Export gas flow " + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + - * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) + * getTotalNumberOfMoles() * ThermodynamicConstantsInterface.R * (273.15 + 15.0) + * /ThermodynamicConstantsInterface.atm * 3600.0 * 24 / 1.0e6 + " MSm^3/day"); + * System.out.println("oil/water heater duty " + ((Heater) * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); * System.out.println("Export oil cooler duty " + ((Cooler) * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java index 40e1594961..8ae784ed4e 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/SeparationTrainModuleSimple.java @@ -146,7 +146,7 @@ public void initializeModule() { gasInletScrubber = new Separator("HP gas scrubber", inletGasCooler.getOutletStream()); - Recycle HPliquidRecycle = new Recycle("Resycle"); + Recycle HPliquidRecycle = new Recycle("Recycle"); double tolerance = 1e-10; HPliquidRecycle.setTolerance(tolerance); HPliquidRecycle.addStream(gasInletScrubber.getLiquidOutStream()); @@ -267,7 +267,7 @@ public static void main(String[] args) { operations.add(wellStream); operations.add(separationModule); // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + // ((Recycle) operations.getUnit("Recycle")).setTolerance(1e-9); operations.run(); @@ -301,16 +301,17 @@ public static void main(String[] args) { ((ProcessEquipmentInterface) separationModule.getOperations().getUnit("2nd stage recompressor")) .getMechanicalDesign().displayResults(); - //operations.getSystemMechanicalDesign().runDesignCalculation(); - //operations.getSystemMechanicalDesign().getTotalPlotSpace(); - //System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); + // operations.getSystemMechanicalDesign().runDesignCalculation(); + // operations.getSystemMechanicalDesign().getTotalPlotSpace(); + // System.out.println("Modules " + operations.getSystemMechanicalDesign().getTotalVolume()); - //System.out - // .println("Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); - //System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); - //System.out.println("Plot space " + operations.getSystemMechanicalDesign().getTotalPlotSpace()); - //System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); - //System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); + // System.out + // .println("Modules " + operations.getSystemMechanicalDesign().getTotalNumberOfModules()); + // System.out.println("Weight " + operations.getSystemMechanicalDesign().getTotalWeight()); + // System.out.println("Plot space " + + // operations.getSystemMechanicalDesign().getTotalPlotSpace()); + // System.out.println("CAPEX " + operations.getCostEstimator().getWeightBasedCAPEXEstimate()); + // System.out.println("CAPEX " + operations.getCostEstimator().getCAPEXestimate()); /* * separationModule.getOutputStream("Inlet separator").displayResult(); @@ -337,8 +338,9 @@ public static void main(String[] args) { * getPhase(0).getPhysicalProperties().getDensity() * 3600.0 + " m^3/hr"); * System.out.println("Export gas flow " + * separationModule.getOutputStream("gas exit stream").getThermoSystem(). - * getTotalNumberOfMoles() * 8.314 * (273.15 + 15.0) / 101325.0 * 3600.0 * 24 / 1.0e6 + - * " MSm^3/day"); System.out.println("oil/water heater duty " + ((Heater) + * getTotalNumberOfMoles() * ThermodynamicConstantsInterface.R * (273.15 + 15.0) + * /ThermodynamicConstantsInterface.atm * 3600.0 * 24 / 1.0e6 + " MSm^3/day"); + * System.out.println("oil/water heater duty " + ((Heater) * separationModule.getOperations().getUnit("oil/water heater")).getEnergyInput( ) + " W"); * System.out.println("Export oil cooler duty " + ((Cooler) * separationModule.getOperations().getUnit("export oil cooler")).getEnergyInput () + " W"); diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java index a0bf071118..31f769b187 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/WellFluidModule.java @@ -10,6 +10,7 @@ import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *@@ -32,14 +33,16 @@ public class WellFluidModule extends ProcessModuleBaseClass { double gasfactor = 0.1; - double thirdstagePressure = 1.01325; + double thirdstagePressure = ThermodynamicConstantsInterface.referencePressure; double separationTemperature = 273.15 + 15; double exitGasScrubberTemperature = 273.15 + 30; double firstStageCompressorAfterCoolerTemperature = 273.15 + 30; double exportOilTemperature = 273.15 + 30; /** - *
Constructor for WellFluidModule.
+ *+ * Constructor for WellFluidModule. + *
* * @param name a {@link java.lang.String} object */ @@ -243,7 +246,8 @@ public static void main(String[] args) { separationModule.addInputStream("feed stream", wellStream); separationModule.setSpecification("Second stage pressure", 15.0); separationModule.setSpecification("separation temperature", 273.15 + 15.0); - separationModule.setSpecification("Third stage pressure", 1.01325); + separationModule.setSpecification("Third stage pressure", + ThermodynamicConstantsInterface.referencePressure); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -251,7 +255,7 @@ public static void main(String[] args) { operations.add(wellStream); operations.add(separationModule); // separationModule.getUnit("") - // ((Recycle) operations.getUnit("Resycle")).setTolerance(1e-9); + // ((Recycle) operations.getUnit("Recycle")).setTolerance(1e-9); operations.run(); } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java index 15adb97bac..77c2ecea31 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/CompressorResponse.java @@ -3,60 +3,66 @@ import neqsim.processSimulation.processEquipment.compressor.Compressor; /** - *CompressorResponse class.
+ *+ * CompressorResponse class. + *
* * @author asmund * @version $Id: $Id */ public class CompressorResponse { - public String name = "test"; + public String name = "test"; - public Double suctionTemperature; - public Double dischargeTemperature; - public Double suctionPressure; - public Double dischargePressure; - public Double polytropicHead; - public Double polytropicEfficiency; - public Double power; - public Double suctionVolumeFlow; - public Double internalVolumeFlow; - public Double dischargeVolumeFlow; - public Double molarMass; - public Double suctionMassDensity; - public Double dischargeMassDensity; - public Double massflow; - public Integer speed; + public Double suctionTemperature; + public Double dischargeTemperature; + public Double suctionPressure; + public Double dischargePressure; + public Double polytropicHead; + public Double polytropicEfficiency; + public Double power; + public Double suctionVolumeFlow; + public Double internalVolumeFlow; + public Double dischargeVolumeFlow; + public Double molarMass; + public Double suctionMassDensity; + public Double dischargeMassDensity; + public Double massflow; + public Double speed; - /** - *Constructor for CompressorResponse.
- */ - public CompressorResponse() { - } + /** + *+ * Constructor for CompressorResponse. + *
+ */ + public CompressorResponse() {} - /** - *Constructor for CompressorResponse.
- * - * @param inputCompressor a {@link neqsim.processSimulation.processEquipment.compressor.Compressor} object - */ - public CompressorResponse(Compressor inputCompressor){ - name = inputCompressor.getName(); - molarMass = inputCompressor.getInletStream().getFluid().getMolarMass(); - suctionMassDensity = inputCompressor.getInletStream().getFluid().getDensity("kg/m3"); - dischargeMassDensity = inputCompressor.getOutletStream().getFluid().getDensity("kg/m3"); - massflow = inputCompressor.getInletStream().getFluid().getFlowRate("kg/hr"); - suctionVolumeFlow = inputCompressor.getInletStream().getFluid().getFlowRate("m3/hr"); - dischargeVolumeFlow = inputCompressor.getOutletStream().getFluid().getFlowRate("m3/hr"); - suctionPressure = inputCompressor.getInletStream().getPressure("bara"); - suctionTemperature = inputCompressor.getInletStream().getTemperature("C"); - dischargeTemperature = inputCompressor.getOutletStream().getTemperature("C"); - dischargePressure = inputCompressor.getOutletStream().getPressure("bara"); - polytropicHead = inputCompressor.getPolytropicFluidHead(); - polytropicEfficiency = inputCompressor.getPolytropicEfficiency(); - power = inputCompressor.getPower("kW"); - speed = inputCompressor.getSpeed(); - if (inputCompressor.getAntiSurge().isActive()) { - internalVolumeFlow = inputCompressor.getCompressorChart().getSurgeCurve() - .getSurgeFlow(polytropicHead); - } + /** + *+ * Constructor for CompressorResponse. + *
+ * + * @param inputCompressor a + * {@link neqsim.processSimulation.processEquipment.compressor.Compressor} object + */ + public CompressorResponse(Compressor inputCompressor) { + name = inputCompressor.getName(); + molarMass = inputCompressor.getInletStream().getFluid().getMolarMass(); + suctionMassDensity = inputCompressor.getInletStream().getFluid().getDensity("kg/m3"); + dischargeMassDensity = inputCompressor.getOutletStream().getFluid().getDensity("kg/m3"); + massflow = inputCompressor.getInletStream().getFluid().getFlowRate("kg/hr"); + suctionVolumeFlow = inputCompressor.getInletStream().getFluid().getFlowRate("m3/hr"); + dischargeVolumeFlow = inputCompressor.getOutletStream().getFluid().getFlowRate("m3/hr"); + suctionPressure = inputCompressor.getInletStream().getPressure("bara"); + suctionTemperature = inputCompressor.getInletStream().getTemperature("C"); + dischargeTemperature = inputCompressor.getOutletStream().getTemperature("C"); + dischargePressure = inputCompressor.getOutletStream().getPressure("bara"); + polytropicHead = inputCompressor.getPolytropicFluidHead(); + polytropicEfficiency = inputCompressor.getPolytropicEfficiency(); + power = inputCompressor.getPower("kW"); + speed = inputCompressor.getSpeed(); + if (inputCompressor.getAntiSurge().isActive()) { + internalVolumeFlow = + inputCompressor.getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead); } + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/Fluid.java b/src/main/java/neqsim/processSimulation/util/monitor/Fluid.java deleted file mode 100644 index c12dbe9ca3..0000000000 --- a/src/main/java/neqsim/processSimulation/util/monitor/Fluid.java +++ /dev/null @@ -1,120 +0,0 @@ -package neqsim.processSimulation.util.monitor; - -import java.util.HashMap; -import java.util.Map; -import neqsim.thermo.system.SystemInterface; -import neqsim.util.NamedBaseClass; - -/** - *- * Fluid class. - *
- * - * @author asmund - * @version $Id: $Id - */ -public class Fluid extends NamedBaseClass { - private static final long serialVersionUID = 1L; - public Double volumeFlow; - public Double molarMass; - public Double massDensity; - public Double massflow; - - public Map- * Constructor for Fluid. - *
- */ - @Deprecated - public Fluid() { - this("Fluid"); - } - - /** - *- * Constructor for Fluid. Sets name of inputFluid as name. - *
- * - * @param inputFluid a {@link neqsim.thermo.system.SystemInterface} object - */ - public Fluid(SystemInterface inputFluid) { - this(inputFluid.getFluidName(), inputFluid); - } - - /** - * Constructor for Fluid. - * - * @param name name of fluid - */ - public Fluid(String name) { - super(name); - this.definedComponent = new HashMap<>(); - this.oilComponent = new HashMap<>(); - } - - /** - * Constructor for Fluid. - * - * @param name name of fluid - * @param inputFluid input fluid - */ - public Fluid(String name, SystemInterface inputFluid) { - this(name); - - for (int i = 0; i < inputFluid.getNumberOfComponents(); i++) { - compProp = new HashMap<>(); - if (inputFluid.getPhase(0).getComponent(i).isIsTBPfraction()) { - compProp.put("molFraction", inputFluid.getPhase(0).getComponent(i).getz()); - compProp.put("massFlow", inputFluid.getPhase(0).getComponent(i).getFlowRate("kg/hr")); - compProp.put("molarMass", inputFluid.getPhase(0).getComponent(i).getMolarMass()); - compProp.put("normalLiquidDensity", - inputFluid.getPhase(0).getComponent(i).getNormalLiquidDensity()); - oilComponent.put(inputFluid.getPhase(0).getComponent(i).getComponentName(), compProp); - } else { - compProp.put("molFraction", inputFluid.getPhase(0).getComponent(i).getz()); - compProp.put("massFlow", inputFluid.getPhase(0).getComponent(i).getFlowRate("kg/hr")); - definedComponent.put( - inputFluid.getPhase(0).getComponent(i).getComponentName().replaceAll("-", ""), - compProp); - } - } - - molarMass = inputFluid.getMolarMass(); - massDensity = inputFluid.getDensity("kg/m3"); - massflow = inputFluid.getFlowRate("kg/hr"); - volumeFlow = inputFluid.getFlowRate("m3/hr"); - } - - /** - * @return SystemInterface - */ - SystemInterface getNeqSimFluid() { - SystemInterface tempFluid = new neqsim.thermo.system.SystemSrkEos(); - - definedComponent.keySet().forEach(key -> { - tempFluid.addComponent(key, definedComponent.get(key).get("molFraction")); - }); - - oilComponent.keySet().forEach(key -> { - tempFluid.addTBPfraction(key, definedComponent.get(key).get("molFraction"), - definedComponent.get(key).get("molarMass"), - definedComponent.get(key).get("normalLiquidDensity")); - }); - - tempFluid.setMixingRule(2); - - return tempFluid; - } - - /** - *- * print. - *
- */ - public void print() {} -} diff --git a/src/main/java/neqsim/processSimulation/util/monitor/FluidComponentResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/FluidComponentResponse.java new file mode 100644 index 0000000000..0b929c5936 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/monitor/FluidComponentResponse.java @@ -0,0 +1,119 @@ +package neqsim.processSimulation.util.monitor; + +import java.util.HashMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.thermo.component.ComponentInterface; +import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.system.SystemInterface; + +/** + *+ * Fluid class. + *
+ * + * @author asmund + * @version $Id: $Id + */ +public class FluidComponentResponse { + private static final long serialVersionUID = 1L; + static Logger logger = LogManager.getLogger(FluidComponentResponse.class); + public String name; + public HashMap+ * Constructor for FluidComponentResponse. + *
+ */ + @Deprecated + public FluidComponentResponse() { + this("Fluid"); + } + + /** + *+ * Constructor for FluidComponentResponse. Sets name of inputFluid as name. + *
+ * + * @param inputFluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public FluidComponentResponse(SystemInterface inputFluid) { + this(inputFluid.getFluidName(), inputFluid); + } + + /** + * Constructor for FluidComponentResponse. + * + * @param nameinp name of fluid + */ + public FluidComponentResponse(String nameinp) { + this.name = nameinp; + } + + /** + * Constructor for FluidComponentResponse. + * + * @param fluidname name of fluid + * @param fluid input fluid + */ + public FluidComponentResponse(String fluidname, SystemInterface fluid) { + this(fluidname); + name = fluidname; + SystemInterface inputFluid = fluid.clone(); + inputFluid.init(0); + + HashMap+ * print. + *
+ */ + public void print() {} +} diff --git a/src/main/java/neqsim/processSimulation/util/monitor/FluidResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/FluidResponse.java new file mode 100644 index 0000000000..671e128a6f --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/monitor/FluidResponse.java @@ -0,0 +1,207 @@ +package neqsim.processSimulation.util.monitor; + +import java.util.HashMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.thermo.system.SystemInterface; + +/** + *+ * Fluid class. + *
+ * + * @author asmund + * @version $Id: $Id + */ +public class FluidResponse { + private static final long serialVersionUID = 1L; + static Logger logger = LogManager.getLogger(FluidResponse.class); + public String name; + public HashMap+ * Constructor for Fluid. + *
+ */ + @Deprecated + public FluidResponse() { + this("Fluid"); + } + + /** + *+ * Constructor for Fluid. Sets name of inputFluid as name. + *
+ * + * @param inputFluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public FluidResponse(SystemInterface inputFluid) { + this(inputFluid.getFluidName(), inputFluid); + } + + /** + * Constructor for Fluid. + * + * @param nameinp name of fluid + */ + public FluidResponse(String nameinp) { + this.name = nameinp; + } + + /** + * Constructor for Fluid. + * + * @param fluidname name of fluid + * @param inputFluid input fluid + */ + public FluidResponse(String fluidname, SystemInterface inputFluid) { + this(fluidname); + + name = inputFluid.getFluidName(); + + HashMap+ * print. + *
+ */ + public void print() {} +} diff --git a/src/main/java/neqsim/processSimulation/util/monitor/HXResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/HXResponse.java index e1baa98547..926c8f8d09 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/HXResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/HXResponse.java @@ -11,43 +11,43 @@ * @version $Id: $Id */ public class HXResponse { - public String name = "test"; - - public Double feedTemperature1; - public Double dischargeTemperature1; - public Double HXthermalEfectiveness; - - public Double feedTemperature2; - public Double dischargeTemperature2; - - public Double dutyBalance; - - /** - *- * Constructor for HXResponse. - *
- */ - public HXResponse() {} - - /** - *- * Constructor for HXResponse. - *
- * - * @param inputHeatExchenger a - * {@link neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger} object - */ - public HXResponse(HeatExchanger inputHeatExchenger) { - name = inputHeatExchenger.getName(); - - feedTemperature1 = inputHeatExchenger.getInStream(0).getTemperature("C"); - dischargeTemperature1 = inputHeatExchenger.getOutStream(0).getTemperature("C"); - - feedTemperature2 = inputHeatExchenger.getInStream(1).getTemperature("C"); - dischargeTemperature2 = inputHeatExchenger.getOutStream(1).getTemperature("C"); - - HXthermalEfectiveness = inputHeatExchenger.getThermalEffectiveness(); - - dutyBalance = inputHeatExchenger.getHotColdDutyBalance(); - } + public String name = "test"; + + public Double feedTemperature1; + public Double dischargeTemperature1; + public Double HXthermalEfectiveness; + + public Double feedTemperature2; + public Double dischargeTemperature2; + + public Double dutyBalance; + public Double duty; + public Double UAvalue; + + /** + *+ * Constructor for HXResponse. + *
+ */ + public HXResponse() {} + + /** + *+ * Constructor for HXResponse. + *
+ * + * @param inputHeatExchanger a + * {@link neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger} object + */ + public HXResponse(HeatExchanger inputHeatExchanger) { + name = inputHeatExchanger.getName(); + feedTemperature1 = inputHeatExchanger.getInStream(0).getTemperature("C"); + dischargeTemperature1 = inputHeatExchanger.getOutStream(0).getTemperature("C"); + feedTemperature2 = inputHeatExchanger.getInStream(1).getTemperature("C"); + dischargeTemperature2 = inputHeatExchanger.getOutStream(1).getTemperature("C"); + HXthermalEfectiveness = inputHeatExchanger.getThermalEffectiveness(); + dutyBalance = inputHeatExchanger.getHotColdDutyBalance(); + duty = inputHeatExchanger.getDuty(); + UAvalue = inputHeatExchanger.getUAvalue(); + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/HeaterResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/HeaterResponse.java index fde87bc08a..d5c44ffacd 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/HeaterResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/HeaterResponse.java @@ -11,33 +11,25 @@ * @version $Id: $Id */ public class HeaterResponse { - public String name = "test"; + public String name = "test"; - public Double feedTemperature; - public Double dischargeTemperature; - public Double duty; + public Double feedTemperature; + public Double dischargeTemperature; + public Double duty; - /** - *- * Constructor for HeaterResponse. - *
- */ - public HeaterResponse() {} + /** + *+ * Constructor for HeaterResponse. + *
+ * + * @param inputHeater a {@link neqsim.processSimulation.processEquipment.heatExchanger.Heater} object + */ + public HeaterResponse(Heater inputHeater) { + name = inputHeater.getName(); - /** - *- * Constructor for HeaterResponse. - *
- * - * @param inputHeater a {@link neqsim.processSimulation.processEquipment.heatExchanger.Heater} - * object - */ - public HeaterResponse(Heater inputHeater) { - name = inputHeater.getName(); + feedTemperature = inputHeater.getInletStream().getTemperature("C"); + dischargeTemperature = inputHeater.getOutletStream().getTemperature("C"); - feedTemperature = inputHeater.getInletStream().getTemperature("C"); - dischargeTemperature = inputHeater.getOutletStream().getTemperature("C"); - - duty = inputHeater.getDuty(); - } + duty = inputHeater.getDuty(); + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/MPMResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/MPMResponse.java index 727eca9f28..4c50c5a5e0 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/MPMResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/MPMResponse.java @@ -11,23 +11,23 @@ * @version $Id: $Id */ public class MPMResponse { - public String name; - public Double massFLow, GOR, GOR_std, gasDensity, oilDensity, waterDensity; + public String name; + public Double massFLow, GOR, GOR_std, gasDensity, oilDensity, waterDensity; - /** - *- * Constructor for MPMResponse. - *
- * - * @param inputMPM a {@link neqsim.processSimulation.measurementDevice.MultiPhaseMeter} object - */ - public MPMResponse(MultiPhaseMeter inputMPM) { - name = inputMPM.getName(); - massFLow = inputMPM.getMeasuredValue(); - GOR = inputMPM.getMeasuredValue("GOR", ""); - GOR_std = inputMPM.getMeasuredValue("GOR_std", ""); - gasDensity = inputMPM.getMeasuredValue("gasDensity", ""); - oilDensity = inputMPM.getMeasuredValue("oilDensity", ""); - waterDensity = inputMPM.getMeasuredValue("waterDensity", ""); - } + /** + *+ * Constructor for MPMResponse. + *
+ * + * @param inputMPM a {@link neqsim.processSimulation.measurementDevice.MultiPhaseMeter} object + */ + public MPMResponse(MultiPhaseMeter inputMPM) { + name = inputMPM.getName(); + massFLow = inputMPM.getMeasuredValue(); + GOR = inputMPM.getMeasuredValue("GOR", ""); + GOR_std = inputMPM.getMeasuredValue("GOR_std", ""); + gasDensity = inputMPM.getMeasuredValue("gasDensity", ""); + oilDensity = inputMPM.getMeasuredValue("oilDensity", ""); + waterDensity = inputMPM.getMeasuredValue("waterDensity", ""); + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java index 6778269202..3d15e7fe93 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/PumpResponse.java @@ -11,58 +11,53 @@ * @version $Id: $Id */ public class PumpResponse { - public String name = "test"; + public String name = "test"; - public Double suctionTemperature; - public Double dischargeTemperature; - public Double suctionPressure; - public Double dischargePressure; - // public Double polytropicHead; - // public Double polytropicEfficiency; - public Double power; - public Double suctionVolumeFlow; - public Double internalVolumeFlow; - public Double dischargeVolumeFlow; - public Double molarMass; - public Double suctionMassDensity; - public Double dischargeMassDensity; - public Double massflow; - public Integer speed; + public Double suctionTemperature; + public Double dischargeTemperature; + public Double suctionPressure; + public Double dischargePressure; + // public Double polytropicHead; + // public Double polytropicEfficiency; + public Double power; + public Double duty; + public Double suctionVolumeFlow; + public Double internalVolumeFlow; + public Double dischargeVolumeFlow; + public Double molarMass; + public Double suctionMassDensity; + public Double dischargeMassDensity; + public Double massflow; + public Integer speed; - /** - *- * Constructor for PumpResponse. - *
- */ - public PumpResponse() {} + /** + *+ * Constructor for PumpResponse. + *
+ * + * @param inputPump a {@link neqsim.processSimulation.processEquipment.pump.Pump} object + */ + public PumpResponse(Pump inputPump) { + name = inputPump.getName(); + molarMass = inputPump.getInletStream().getFluid().getMolarMass(); + suctionMassDensity = inputPump.getInletStream().getFluid().getDensity("kg/m3"); + dischargeMassDensity = inputPump.getOutletStream().getFluid().getDensity("kg/m3"); + massflow = inputPump.getInletStream().getFluid().getFlowRate("kg/hr"); + suctionVolumeFlow = inputPump.getInletStream().getFluid().getFlowRate("m3/hr"); + dischargeVolumeFlow = inputPump.getOutletStream().getFluid().getFlowRate("m3/hr"); + suctionPressure = inputPump.getInletStream().getPressure("bara"); + suctionTemperature = inputPump.getInletStream().getTemperature("C"); + dischargeTemperature = inputPump.getOutletStream().getTemperature("C"); + dischargePressure = inputPump.getOutletStream().getPressure("bara"); - /** - *- * Constructor for PumpResponse. - *
- * - * @param inputPump a {@link neqsim.processSimulation.processEquipment.pump.Pump} object - */ - public PumpResponse(Pump inputPump) { - name = inputPump.getName(); - molarMass = inputPump.getInletStream().getFluid().getMolarMass(); - suctionMassDensity = inputPump.getInletStream().getFluid().getDensity("kg/m3"); - dischargeMassDensity = inputPump.getOutletStream().getFluid().getDensity("kg/m3"); - massflow = inputPump.getInletStream().getFluid().getFlowRate("kg/hr"); - suctionVolumeFlow = inputPump.getInletStream().getFluid().getFlowRate("m3/hr"); - dischargeVolumeFlow = inputPump.getOutletStream().getFluid().getFlowRate("m3/hr"); - suctionPressure = inputPump.getInletStream().getPressure("bara"); - suctionTemperature = inputPump.getInletStream().getTemperature("C"); - dischargeTemperature = inputPump.getOutletStream().getTemperature("C"); - dischargePressure = inputPump.getOutletStream().getPressure("bara"); - - // polytropicHead = inputCompressor.getPolytropicFluidHead(); - // polytropicEfficiency =inputCompressor.getPolytropicEfficiency(); - power = inputPump.getPower("W"); // "kW"); - // speed = inputPump.getSpeed(); - // if(inputCompressor.getAntiSurge().isActive()){ - // internalVolumeFlow = - // inputCompressor.getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead); - // } - } + // polytropicHead = inputCompressor.getPolytropicFluidHead(); + // polytropicEfficiency =inputCompressor.getPolytropicEfficiency(); + power = inputPump.getPower("W"); // "kW"); + duty = power; + // speed = inputPump.getSpeed(); + // if(inputCompressor.getAntiSurge().isActive()){ + // internalVolumeFlow = + // inputCompressor.getCompressorChart().getSurgeCurve().getSurgeFlow(polytropicHead); + // } + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/SeparatorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/SeparatorResponse.java index 756230a71b..5c3a750a4f 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/SeparatorResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/SeparatorResponse.java @@ -14,15 +14,7 @@ public class SeparatorResponse { public String name; public Double gasLoadFactor; - public Double massflow; - public Fluid gasFluid, liquidFluid, oilFluid, waterFluid; - - /** - *- * Constructor for SeparatorResponse. - *
- */ - public SeparatorResponse() {} + public StreamResponse feed, gas, liquid, oil, water; /** *@@ -34,16 +26,17 @@ public SeparatorResponse() {} */ public SeparatorResponse(ThreePhaseSeparator inputSeparator) { name = inputSeparator.getName(); - massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); gasLoadFactor = inputSeparator.getGasLoadFactor(); + + feed = new StreamResponse(inputSeparator.getFeedStream()); if (inputSeparator.getThermoSystem().hasPhaseType("aqueous")) { - waterFluid = new Fluid(inputSeparator.getWaterOutStream().getFluid()); + water = new StreamResponse(inputSeparator.getWaterOutStream()); } if (inputSeparator.getThermoSystem().hasPhaseType("oil")) { - oilFluid = new Fluid(inputSeparator.getOilOutStream().getFluid()); + oil = new StreamResponse(inputSeparator.getOilOutStream()); } if (inputSeparator.getThermoSystem().hasPhaseType("gas")) { - gasFluid = new Fluid(inputSeparator.getGasOutStream().getFluid()); + gas = new StreamResponse(inputSeparator.getGasOutStream()); } } @@ -57,20 +50,15 @@ public SeparatorResponse(ThreePhaseSeparator inputSeparator) { */ public SeparatorResponse(Separator inputSeparator) { name = inputSeparator.getName(); - massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); gasLoadFactor = inputSeparator.getGasLoadFactor(); - if (inputSeparator.getThermoSystem().hasPhaseType("aqueous")) { - waterFluid = new Fluid(inputSeparator.getThermoSystem().phaseToSystem("aqueous")); - } - if (inputSeparator.getThermoSystem().hasPhaseType("oil")) { - oilFluid = new Fluid(inputSeparator.getThermoSystem().phaseToSystem("oil")); + feed = new StreamResponse(inputSeparator.getFeedStream()); + if (inputSeparator.getThermoSystem().hasPhaseType("aqueous") + || inputSeparator.getThermoSystem().hasPhaseType("liquid") + || inputSeparator.getThermoSystem().hasPhaseType("oil")) { + liquid = new StreamResponse(inputSeparator.getLiquidOutStream()); } if (inputSeparator.getThermoSystem().hasPhaseType("gas")) { - gasFluid = new Fluid(inputSeparator.getGasOutStream().getFluid()); - } - if (inputSeparator.getThermoSystem().hasPhaseType("oil") - || inputSeparator.getThermoSystem().hasPhaseType("aqueous")) { - liquidFluid = new Fluid(inputSeparator.getLiquidOutStream().getFluid()); + gas = new StreamResponse(inputSeparator.getGasOutStream()); } } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/StreamResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/StreamResponse.java index 113f470538..f328f9a1b2 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/StreamResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/StreamResponse.java @@ -1,67 +1,251 @@ package neqsim.processSimulation.util.monitor; +import java.util.HashMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.standards.gasQuality.Standard_ISO6976; /** - *
StreamResponse class.
+ *+ * StreamResponse class. + *
* * @author asmund * @version $Id: $Id */ public class StreamResponse { - public String name; - public Fluid fluid; - public Double temperature; - public Double pressure; - public Double volumeFlow; - public Double molarMass; - public Double massDensity; - public Double massflow; - public Double massflowGas; - public Double massflowOil; - public Double massflowAqueous; - - /** - *Constructor for StreamResponse.
- */ - public StreamResponse() { + static Logger logger = LogManager.getLogger(StreamResponse.class); + public String name; + public HashMap+ * Constructor for StreamResponse. + *
+ * + * @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public StreamResponse(StreamInterface inputStream) { + name = inputStream.getName(); + + HashMapConstructor for StreamResponse.
- * - * @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamResponse(StreamInterface inputStream){ - name = inputStream.getName(); - fluid = new Fluid(inputStream.getFluid()); - temperature = inputStream.getTemperature("C"); - pressure = inputStream.getPressure("bara"); - molarMass = inputStream.getFluid().getMolarMass(); - massDensity = inputStream.getFluid().getDensity("kg/m3"); - massflow = inputStream.getFluid().getFlowRate("kg/hr"); - volumeFlow = inputStream.getFluid().getFlowRate("m3/hr"); - - if (inputStream.getFluid().hasPhaseType("gas")) { - massflowGas = inputStream.getFluid().getPhase("gas").getFlowRate("kg/hr"); - } else { - massflowGas = 0.0; - } - if (inputStream.getFluid().hasPhaseType("aqueous")) { - massflowAqueous = inputStream.getFluid().getPhase("aqueous").getFlowRate("kg/hr"); - } else { - massflowAqueous = 0.0; + name = inputStream.getName(); + newdata = new HashMapprint.
- */ - public void print(){ - } + /** + *+ * print. + *
+ */ + public void print() {} } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/ThreePhaseSeparatorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/ThreePhaseSeparatorResponse.java index abf3b83352..b06ca576ca 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/ThreePhaseSeparatorResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/ThreePhaseSeparatorResponse.java @@ -12,47 +12,38 @@ * @version $Id: $Id */ public class ThreePhaseSeparatorResponse { - public String name; - public Double gasLoadFactor; - public Double massflow; - public Fluid gasFluid, oilFluid; + public String name; + public Double gasLoadFactor; + public Double massflow; + public FluidResponse gasFluid, oilFluid; - /** - *- * Constructor for ThreePhaseSeparatorResponse. - *
- */ - public ThreePhaseSeparatorResponse() {} + /** + *+ * Constructor for ThreePhaseSeparatorResponse. + *
+ * + * @param inputSeparator a {@link neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator} object + */ + public ThreePhaseSeparatorResponse(ThreePhaseSeparator inputSeparator) { + name = inputSeparator.getName(); + massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); + gasLoadFactor = inputSeparator.getGasLoadFactor(); + oilFluid = new FluidResponse(inputSeparator.getOilOutStream().getFluid()); + gasFluid = new FluidResponse(inputSeparator.getGasOutStream().getFluid()); + } - /** - *- * Constructor for ThreePhaseSeparatorResponse. - *
- * - * @param inputSeparator a - * {@link neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator} object - */ - public ThreePhaseSeparatorResponse(ThreePhaseSeparator inputSeparator) { - name = inputSeparator.getName(); - massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); - gasLoadFactor = inputSeparator.getGasLoadFactor(); - oilFluid = new Fluid(inputSeparator.getOilOutStream().getFluid()); - gasFluid = new Fluid(inputSeparator.getGasOutStream().getFluid()); - } - - /** - *- * Constructor for ThreePhaseSeparatorResponse. - *
- * - * @param inputSeparator a {@link neqsim.processSimulation.processEquipment.separator.Separator} - * object - */ - public ThreePhaseSeparatorResponse(Separator inputSeparator) { - name = inputSeparator.getName(); - massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); - gasLoadFactor = inputSeparator.getGasLoadFactor(); - oilFluid = new Fluid(inputSeparator.getLiquidOutStream().getFluid()); - gasFluid = new Fluid(inputSeparator.getGasOutStream().getFluid()); - } + /** + *+ * Constructor for ThreePhaseSeparatorResponse. + *
+ * + * @param inputSeparator a {@link neqsim.processSimulation.processEquipment.separator.Separator} object + */ + public ThreePhaseSeparatorResponse(Separator inputSeparator) { + name = inputSeparator.getName(); + massflow = inputSeparator.getFluid().getFlowRate("kg/hr"); + gasLoadFactor = inputSeparator.getGasLoadFactor(); + oilFluid = new FluidResponse(inputSeparator.getLiquidOutStream().getFluid()); + gasFluid = new FluidResponse(inputSeparator.getGasOutStream().getFluid()); + } } diff --git a/src/main/java/neqsim/processSimulation/util/monitor/Value.java b/src/main/java/neqsim/processSimulation/util/monitor/Value.java new file mode 100644 index 0000000000..46cc0a6d7f --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/monitor/Value.java @@ -0,0 +1,24 @@ +package neqsim.processSimulation.util.monitor; + +/** + * Unit class nested within Units. + * + * @author Even Solbraa + */ +public class Value { + public String value; + public String unit; + + /** + *+ * Constructor for Value. + *
+ * + * @param value a {@link java.lang.String} object + * @param unit a {@link java.lang.String} object + */ + public Value(String value, String unit) { + this.value = value; + this.unit = unit; + } +} diff --git a/src/main/java/neqsim/processSimulation/util/monitor/ValveResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/ValveResponse.java new file mode 100644 index 0000000000..9d20f49589 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/monitor/ValveResponse.java @@ -0,0 +1,44 @@ +package neqsim.processSimulation.util.monitor; + +import java.util.ArrayList; +import neqsim.processSimulation.processEquipment.valve.ValveInterface; + +/** + *+ * StreamResponse class. + *
+ * + * @author asmund + * @version $Id: $Id + */ +public class ValveResponse { + public String name; + public ArrayList+ * Constructor for StreamResponse. + *
+ * + * @param valve a {@link neqsim.processSimulation.processEquipment.valve.ValveInterface} object + */ + public ValveResponse(ValveInterface valve) { + name = valve.getName(); + + data.add(new String[] {"outlet temperature", + Double.toString(valve.getOutletStream() + .getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature")}); + data.add(new String[] {"outlet pressure", + Double.toString( + valve.getOutletStream().getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure")}); + } + + /** + *+ * print. + *
+ */ + public void print() {} +} diff --git a/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java index 30a1bbe6be..e3abbcf165 100644 --- a/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java +++ b/src/main/java/neqsim/processSimulation/util/monitor/WellAllocatorResponse.java @@ -11,20 +11,20 @@ * @version $Id: $Id */ public class WellAllocatorResponse { - public String name; - public Double gasExportRate, oilExportRate, totalExportRate; + public String name; + public Double gasExportRate, oilExportRate, totalExportRate; - /** - *- * Constructor for WellAllocatorResponse. - *
- * - * @param inputAllocator a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object - */ - public WellAllocatorResponse(WellAllocator inputAllocator) { - name = inputAllocator.getName(); - gasExportRate = inputAllocator.getMeasuredValue("gas export rate", "kg/hr"); - oilExportRate = inputAllocator.getMeasuredValue("oil export rate", "kg/hr"); - totalExportRate = inputAllocator.getMeasuredValue("total export rate", "kg/hr"); - } + /** + *+ * Constructor for WellAllocatorResponse. + *
+ * + * @param inputAllocator a {@link neqsim.processSimulation.measurementDevice.WellAllocator} object + */ + public WellAllocatorResponse(WellAllocator inputAllocator) { + name = inputAllocator.getName(); + gasExportRate = inputAllocator.getMeasuredValue("gas export rate", "kg/hr"); + oilExportRate = inputAllocator.getMeasuredValue("oil export rate", "kg/hr"); + totalExportRate = inputAllocator.getMeasuredValue("total export rate", "kg/hr"); + } } diff --git a/src/main/java/neqsim/processSimulation/util/report/Report.java b/src/main/java/neqsim/processSimulation/util/report/Report.java new file mode 100644 index 0000000000..65ee3e199d --- /dev/null +++ b/src/main/java/neqsim/processSimulation/util/report/Report.java @@ -0,0 +1,116 @@ +package neqsim.processSimulation.util.report; + +import java.util.HashMap; +import java.util.Map; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; +import neqsim.processSimulation.processSystem.ProcessModule; +import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemInterface; + +/** + *+ * Report class. + *
+ * + * @author even + * @version $Id: $Id + */ +public class Report { + static Logger logger = LogManager.getLogger(Report.class); + ProcessSystem process = null; + ProcessEquipmentBaseClass processEquipment = null; + SystemInterface fluid = null; + + /** + *Constructor for Report.
+ * + * @param process a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public Report(ProcessSystem process) { + this.process = process; + } + + /** + *Constructor for Report.
+ * + * @param fluid a {@link neqsim.thermo.system.SystemInterface} object + */ + public Report(SystemInterface fluid) { + this.fluid = fluid; + } + + /** + *Constructor for Report.
+ * + * @param processEquipmentBaseClass a {@link neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass} object + */ + public Report(ProcessEquipmentBaseClass processEquipmentBaseClass) { + processEquipment = processEquipmentBaseClass; + } + + /** + *Constructor for Report.
+ * + * @param processModule a {@link neqsim.processSimulation.processSystem.ProcessModule} object + */ + public Report(ProcessModule processModule) { + // TODO Auto-generated constructor stub + } + + /** + *Constructor for Report.
+ * + * @param processModuleBaseClass a {@link neqsim.processSimulation.processSystem.ProcessModuleBaseClass} object + */ + public Report(ProcessModuleBaseClass processModuleBaseClass) { + // TODO Auto-generated constructor stub + } + + /** + *generateJsonReport.
+ * + * @return a {@link java.lang.String} object + */ + public String generateJsonReport() { + Map@@ -37,7 +37,7 @@ public interface StandardInterface { * @param returnParameter a {@link java.lang.String} object * @return a double */ - double getValue(java.lang.String returnParameter); + double getValue(String returnParameter); /** *
@@ -165,5 +165,21 @@ public interface StandardInterface { */ public void setResultTable(String[][] resultTable); + /** + *
+ * Getter for the field referencePressure
.
+ *
+ * Setter for the field referencePressure
.
+ *
+ * Standard_ISO15403 class. + *
+ * + * @author ASMF + */ public class Standard_ISO15403 extends neqsim.standards.Standard { private static final long serialVersionUID = 1L; @@ -42,7 +49,6 @@ public void calculate() { /** {@inheritDoc} */ @Override public double getValue(String returnParameter) { - if (returnParameter.equals("MON")) { return MON; } else if (returnParameter.equals("NM")) { @@ -53,12 +59,11 @@ public double getValue(String returnParameter) { "parameter not supported"); throw new RuntimeException(ex); } - } /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { return getValue(returnParameter); } @@ -73,5 +78,4 @@ public String getUnit(String returnParameter) { public boolean isOnSpec() { return true; } - } diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java index 8847051cc9..c9876907e9 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6578.java @@ -244,7 +244,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { return LNGdensity; } diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java index 87416a6a6f..aa6f15de6d 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; /** @@ -23,12 +24,13 @@ public class Standard_ISO6976 extends neqsim.standards.Standard // metering conditions ArrayList+ * The method can be one of the following: + *
+ *+ * The method should be one of the following: + *
+ *@@ -35,8 +85,8 @@ public Standard_ASTM_D6377(SystemInterface thermoSystem) { /** {@inheritDoc} */ @Override public void calculate() { - this.thermoSystem.setTemperature(273.15 + 37.8); - this.thermoSystem.setPressure(1.01325); + this.thermoSystem.setTemperature(referenceTemperature, "C"); + this.thermoSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); this.thermoOps = new ThermodynamicOperations(thermoSystem); try { this.thermoOps.bubblePointPressureFlash(false); @@ -44,17 +94,35 @@ public void calculate() { logger.error(ex.getMessage(), ex); } - // double TVP = this.thermoSystem.getPressure(); - double liquidVolume = thermoSystem.getVolume(); + TVP = this.thermoSystem.getPressure(); - this.thermoSystem.setPressure(0.9); + this.thermoSystem.setPressure(TVP * 0.9); try { - this.thermoOps.TVflash(liquidVolume * 4.0); + // ASTM D323 -08 method is used for this property calculation. It is defined at the pressure + // at 100°F (37.8°C) at which 80% of the stream by volume is vapor at 100°F. In + this.thermoOps.TVfractionFlash(0.8); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - RVP = (0.752 * (100.0 * this.thermoSystem.getPressure()) + 6.07) / 100.0; + VPCR4 = this.thermoSystem.getPressure(); + RVP_ASTM_D6377 = 0.834 * VPCR4; + RVP_ASTM_D323_82 = (0.752 * (100.0 * this.thermoSystem.getPressure()) + 6.07) / 100.0; + + SystemInterface fluid1 = this.thermoSystem.clone(); + if (fluid1.hasComponent("water")) { + fluid1.removeComponent("water"); + fluid1.init(0); + } + try { + // ASTM D323 -08 method is used for this property calculation. It is defined at the pressure + // at 100°F (37.8°C) at which 80% of the stream by volume is vapor at 100°F. In + this.thermoOps.TVfractionFlash(0.8); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + VPCR4_no_water = this.thermoSystem.getPressure(); + RVP_ASTM_D323_73_79 = VPCR4_no_water; } /** {@inheritDoc} */ @@ -71,14 +139,60 @@ public String getUnit(String returnParameter) { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { - return RVP; + public double getValue(String returnParameter, String returnUnit) { + if (returnParameter == "RVP") { + double RVPlocal = getValue("RVP"); + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(RVPlocal, "bara"); + return presConversion.getValue(returnUnit); + } + if (returnParameter == "TVP") { + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(getValue("TVP"), "bara"); + return presConversion.getValue(returnUnit); + } else { + return RVP; + } } /** {@inheritDoc} */ @Override public double getValue(String returnParameter) { - return RVP; + if (returnParameter.equals("RVP")) { + switch (methodRVP) { + case "RVP_ASTM_D6377": + return RVP_ASTM_D6377; + case "RVP_ASTM_D323_73_79": + return RVP_ASTM_D323_73_79; + case "VPCR4": + return VPCR4; + case "RVP_ASTM_D323_82": + return RVP_ASTM_D323_82; + case "VPCR4_no_water": + return VPCR4_no_water; + default: + return VPCR4; + } + } else if (returnParameter.equals("TVP")) { + return TVP; + } else { + logger.error("returnParameter not supported.. " + returnParameter); + return 0.0; + } + } + + /** + *
+ * setReferenceTemperature. + *
+ * + * @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"); } /** @@ -94,10 +208,14 @@ public static void main(String args[]) { testSystem.addComponent("ethane", 0.006538); testSystem.addComponent("propane", 0.006538); testSystem.addComponent("n-pentane", 0.545); + testSystem.addComponent("water", 0.00545); testSystem.setMixingRule(2); testSystem.init(0); Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem); standard.calculate(); System.out.println("RVP " + standard.getValue("RVP", "bara")); + standard.setMethodRVP("RVP_ASTM_D323_73_79"); + standard.calculate(); + System.out.println("RVP_ASTM_D323_73_79 " + standard.getValue("RVP", "bara")); } } diff --git a/src/main/java/neqsim/standards/salesContract/BaseContract.java b/src/main/java/neqsim/standards/salesContract/BaseContract.java index 70f73082d9..f6c822c6c4 100644 --- a/src/main/java/neqsim/standards/salesContract/BaseContract.java +++ b/src/main/java/neqsim/standards/salesContract/BaseContract.java @@ -91,8 +91,8 @@ public BaseContract(SystemInterface system, String terminal, String country) { Double.parseDouble(dataSet.getString("MAXVALUE")), dataSet.getString("UNIT"), Double.parseDouble(dataSet.getString("ReferenceTdegC")), Double.parseDouble(dataSet.getString("ReferenceTdegC")), referencePressure, ""));// dataSet.getString("Comments")); - System.out.println(dataSet.getString("Comments")); - System.out.println("specification added..." + numb); + // System.out.println(dataSet.getString("Comments")); + // System.out.println("specification added..." + numb); } } catch (Exception ex) { logger.error("error in comp", ex); diff --git a/src/main/java/neqsim/standards/salesContract/ContractInterface.java b/src/main/java/neqsim/standards/salesContract/ContractInterface.java index 24481cd443..fb4bbcb159 100644 --- a/src/main/java/neqsim/standards/salesContract/ContractInterface.java +++ b/src/main/java/neqsim/standards/salesContract/ContractInterface.java @@ -130,10 +130,8 @@ public interface ContractInterface { /** * Prints the contract. - * */ public default void prettyPrint() { neqsim.thermo.util.readwrite.TablePrinter.printTable(getResultTable()); } - } diff --git a/src/main/java/neqsim/standards/salesContract/ContractSpecification.java b/src/main/java/neqsim/standards/salesContract/ContractSpecification.java index 49f9fca59f..5a1b2243e6 100644 --- a/src/main/java/neqsim/standards/salesContract/ContractSpecification.java +++ b/src/main/java/neqsim/standards/salesContract/ContractSpecification.java @@ -25,19 +25,11 @@ public class ContractSpecification extends NamedBaseClass { private String terminal = ""; private double minValue = 0; private double maxValue = 0; - private double referenceTemperatureMeasurement = 0, referenceTemperatureCombustion = 0; + private double referenceTemperatureMeasurement = 0; + private double referenceTemperatureCombustion = 0; private double referencePressure = 0; - private String unit = "", comments = ""; - - @Deprecated - /** - *- * Constructor for ContractSpecification. - *
- */ - public ContractSpecification() { - super("ContractSpecification"); - } + private String unit = ""; + private String comments = ""; /** *
@@ -202,7 +194,7 @@ public void setReferenceTemperatureMeasurement(double referenceTemperature) {
* Getter for the field referencePressure
.
*
referencePressure
.
*
*
- * @param referencePressure a double
+ * @param referencePressure Reference pressure to set in in bara
*/
public void setReferencePressure(double referencePressure) {
this.referencePressure = referencePressure;
diff --git a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java b/src/main/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmoother.java
similarity index 76%
rename from src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java
rename to src/main/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmoother.java
index 680086635e..3923a9ab25 100644
--- a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java
+++ b/src/main/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmoother.java
@@ -1,10 +1,10 @@
/*
- * DataSmoothor.java
+ * DataSmoother.java
*
* Created on 31. januar 2001, 21:27
*/
-package neqsim.statistics.dataAnalysis.dataSmoothing;
+package neqsim.statistics.dataanalysis.datasmoothing;
import Jama.Matrix;
@@ -16,33 +16,35 @@
* @author Even Solbraa
* @version $Id: $Id
*/
-public class DataSmoothor {
- double[] nonSmoothedNumbers, smoothedNumbers, cCoef;
- int nl = 0, nr = 0, ld = 0, m = 0, mm = 0, imj = 0, kk = 0;
+public class DataSmoother {
+ double[] nonSmoothedNumbers;
+ double[] smoothedNumbers;
+ double[] cCoef;
+ int nl = 0;
+ int nr = 0;
+ int ld = 0;
+ int m = 0;
+ int mm = 0;
+ int imj = 0;
+ int kk = 0;
int[] index;
double[][] a;
double[] b;
- double sum = 0, fac = 0;
-
- /**
- * - * Constructor for DataSmoothor. - *
- */ - public DataSmoothor() {} + double sum = 0; + double fac = 0; /** ** Constructor for DataSmoothor. *
* - * @param nonSmoothedNumbers an array of {@link double} objects + * @param nonSmoothedNumbers an array of type double * @param nl a int * @param nr a int * @param ld a int * @param m a int */ - public DataSmoothor(double[] nonSmoothedNumbers, int nl, int nr, int ld, int m) { + public DataSmoother(double[] nonSmoothedNumbers, int nl, int nr, int ld, int m) { this.nonSmoothedNumbers = new double[nonSmoothedNumbers.length]; this.smoothedNumbers = new double[nonSmoothedNumbers.length]; this.cCoef = new double[nonSmoothedNumbers.length]; @@ -152,26 +154,9 @@ public void setSmoothedNumbers() { * Getter for the fieldsmoothedNumbers
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getSmoothedNumbers() {
return smoothedNumbers;
}
-
- /**
- * - * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - double[] numbers = {10, 11, 12, 13, 14, 15, 15.5, 15, 19, 14, 14, 13, 12, 12, 11, 10, 9, 8}; - DataSmoothor test = new DataSmoothor(numbers, 3, 3, 0, 4); - Matrix data = new Matrix(test.getSmoothedNumbers(), 1); - data.print(10, 2); - test.runSmoothing(); - data = new Matrix(test.getSmoothedNumbers(), 1); - data.print(10, 2); - } } diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java index a06fb2a630..8bc5b6458c 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/readDataFromFile/DataReader.java @@ -60,7 +60,6 @@ public void readData() { file.readLine(); } do { - System.out.println("test"); String s = file.readLine(); tokenizer = new StringTokenizer(s); tokenizer.nextToken(); @@ -78,7 +77,8 @@ public void readData() { * Getter for the fieldsampleObjectList
.
*
*
- * @return a {@link java.util.ArrayList} of {@link neqsim.statistics.experimentalSampleCreation.readDataFromFile.DataObject}
+ * @return a {@link java.util.ArrayList} of
+ * {@link neqsim.statistics.experimentalSampleCreation.readDataFromFile.DataObject}
*/
public ArrayListdependentValues
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getDependentValues() {
return dependentValues;
@@ -188,7 +188,7 @@ public double getDependentValue(int i) {
* Setter for the field dependentValues
.
*
*
- * @param vals an array of {@link double} objects
+ * @param vals an array of type double
*/
public void setDependentValues(double[] vals) {
System.arraycopy(vals, 0, this.dependentValues, 0, dependentValues.length);
diff --git a/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java b/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java
index 91a8f3cc8c..f37d205059 100644
--- a/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java
+++ b/src/main/java/neqsim/statistics/parameterFitting/StatisticsBaseClass.java
@@ -178,7 +178,7 @@ public double calcTrueValue(double val, SampleValue sample) {
* setFittingParameters.
*
*
- * @param parameterVals an array of {@link double} objects
+ * @param parameterVals an array of type double
*/
public void setFittingParameters(double[] parameterVals) {
for (int i = 0; i < sampleSet.getLength(); i++) {
@@ -243,7 +243,7 @@ public double calcChiSquare() {
* calcAlphaMatrix.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] calcAlphaMatrix() {
double[][] alpha = new double[sampleSet.getSample(0).getFunction()
@@ -268,7 +268,7 @@ public double[][] calcAlphaMatrix() {
* calcBetaMatrix.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] calcBetaMatrix() {
double[] beta = new double[sampleSet.getSample(0).getFunction().getFittingParams().length];
@@ -287,7 +287,7 @@ public double[] calcBetaMatrix() {
* calcDerivatives.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] calcDerivatives() {
dyda = new double[sampleSet.getLength()][sampleSet.getSample(0).getFunction()
diff --git a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java
index ab0682cd47..64dc6d3ca6 100644
--- a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java
+++ b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardt.java
@@ -124,12 +124,12 @@ public static void main(String[] args) {
/*
* LevenbergMarquardt optim = new LevenbergMarquardt(); TestFunction testFunction = new
* TestFunction(); // optim.setFunction(testFunction);
- *
+ *
* SampleValue[] sample = new SampleValue[3]; double sample1[] = { 6 }; sample[0] = new
* SampleValue(8.5,0.1,sample1); double sample2[] = { 4 }; sample[1] = new
* SampleValue(5.5,0.1,sample2); double sample3[] = { 4 }; sample[2] = new
* SampleValue(5.51,0.1,sample3);
- *
+ *
* SampleSet sampleSet = new SampleSet(sample); sampleSet =
* sampleSet.createNewNormalDistributedSet(); optim.setSampleSet(sampleSet); optim.solve();
* optim.runMonteCarloSimulation();
diff --git a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtFunction.java b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtFunction.java
index 5c3c4cc1d7..15af7533b9 100644
--- a/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtFunction.java
+++ b/src/main/java/neqsim/statistics/parameterFitting/nonLinearParameterFitting/LevenbergMarquardtFunction.java
@@ -53,7 +53,7 @@ public int getNumberOfFittingParams() {
* setFittingParams.
*
*
- * @param value an array of {@link double} objects
+ * @param value an array of type double
*/
public void setFittingParams(double[] value) {
System.arraycopy(value, 0, params, 0, value.length);
diff --git a/src/main/java/neqsim/thermo/Fluid.java b/src/main/java/neqsim/thermo/Fluid.java
index 2670b6b284..d89bb48c19 100644
--- a/src/main/java/neqsim/thermo/Fluid.java
+++ b/src/main/java/neqsim/thermo/Fluid.java
@@ -39,7 +39,7 @@ public neqsim.thermo.system.SystemInterface getFluid() {
}
/**
- *
+ *
*/
private void setThermoModel() {
if (thermoModel.equals("srk")) {
@@ -75,7 +75,7 @@ public neqsim.thermo.system.SystemInterface create2(String[] componentNames) {
*
*
* @param componentNames an array of {@link java.lang.String} objects
- * @param flowrate an array of {@link double} objects
+ * @param flowrate an array of type double
* @param unit a {@link java.lang.String} object
* @return a {@link neqsim.thermo.system.SystemInterface} object
*/
@@ -83,7 +83,7 @@ public neqsim.thermo.system.SystemInterface create2(String[] componentNames, dou
String unit) {
setThermoModel();
createFluid(componentNames, flowrate, unit);
- if (isHasWater() == true) {
+ if (isHasWater()) {
fluid.addComponent("water", 0.1);
}
fluid.createDatabase(true);
@@ -208,7 +208,7 @@ public neqsim.thermo.system.SystemInterface create(String fluidType) {
return null;
}
- if (isHasWater() == true) {
+ if (isHasWater()) {
fluid.addComponent("water", 0.1);
}
fluid.createDatabase(true);
@@ -229,7 +229,7 @@ public neqsim.thermo.system.SystemInterface create(String fluidType) {
*
*
* @param componentNames an array of {@link java.lang.String} objects
- * @param flowrate an array of {@link double} objects
+ * @param flowrate an array of type double
* @param unit a {@link java.lang.String} object
* @return a {@link neqsim.thermo.system.SystemInterface} object
*/
@@ -306,7 +306,6 @@ public boolean isHasWater() {
*/
public void setHasWater(boolean hasWater) {
this.hasWater = hasWater;
-
}
/**
diff --git a/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java b/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java
index 868574c550..7030f54791 100644
--- a/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java
+++ b/src/main/java/neqsim/thermo/ThermodynamicConstantsInterface.java
@@ -1,9 +1,3 @@
-/*
- * ThermodynamicConstantsInterface.java
- *
- * Created on 3. juni 2000, 19:07
- */
-
package neqsim.thermo;
/**
@@ -23,8 +17,6 @@ public interface ThermodynamicConstantsInterface extends java.io.Serializable {
double gravity = 9.80665;
/** Constant avagadroNumber=6.023e23
. */
double avagadroNumber = 6.023e23;
- /** Constant MAX_NUMBER_OF_COMPONENTS=100
. */
- static final int MAX_NUMBER_OF_COMPONENTS = 100;
/** Constant referenceTemperature=273.15
[K]. */
double referenceTemperature = 273.15;
/** Constant referencePressure=1.01325
[bar]. */
diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelSettings.java b/src/main/java/neqsim/thermo/ThermodynamicModelSettings.java
index 57a421da9e..8cbb0574d8 100644
--- a/src/main/java/neqsim/thermo/ThermodynamicModelSettings.java
+++ b/src/main/java/neqsim/thermo/ThermodynamicModelSettings.java
@@ -12,5 +12,5 @@ public interface ThermodynamicModelSettings extends java.io.Serializable {
/** Constant phaseFractionMinimumLimit=1e-12
. */
double phaseFractionMinimumLimit = 1e-12;
/** Constant MAX_NUMBER_OF_COMPONENTS=100
. */
- static final int MAX_NUMBER_OF_COMPONENTS = 100;
+ int MAX_NUMBER_OF_COMPONENTS = 100;
}
diff --git a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
index ba800413ed..e9853dc03a 100644
--- a/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
+++ b/src/main/java/neqsim/thermo/ThermodynamicModelTest.java
@@ -209,11 +209,9 @@ public boolean checkFugacityCoefficientsDP() {
for (int i = 0; i < system.getPhase(j).getNumberOfComponents(); i++) {
temp1 += system.getPhase(j).getComponents()[i].getNumberOfMolesInPhase()
* system.getPhase(j).getComponents()[i].getdfugdp();
-
}
temp1 -= (system.getPhase(j).getZ() - 1.0) * system.getPhase(j).getNumberOfMolesInPhase()
/ system.getPhase(j).getPressure();
-
}
sum = Math.abs(temp1) + Math.abs(temp2);
// logger.info("test fugdp gas : " + temp1);
@@ -424,11 +422,9 @@ public boolean checkNumerically() {
}
/**
- * - * - * @param maxErr Maximum error before test will report failed Set maximum allowed error in model - * check - *
+ * Setter for propertymaxError
.
+ *
+ * @param maxErr before test will report failed Set maximum allowed error in model check
*/
public void setMaxError(double maxErr) {
this.maxError = maxErr;
diff --git a/src/main/java/neqsim/thermo/atomElement/Element.java b/src/main/java/neqsim/thermo/atomElement/Element.java
index 014b3767cc..d82149f7dd 100644
--- a/src/main/java/neqsim/thermo/atomElement/Element.java
+++ b/src/main/java/neqsim/thermo/atomElement/Element.java
@@ -43,7 +43,6 @@ public Element(String name) {
try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase();
java.sql.ResultSet dataSet =
database.getResultSet(("SELECT * FROM element WHERE componentname='" + name + "'"))) {
-
if (!dataSet.next()) {
return;
}
@@ -106,7 +105,7 @@ public double getNumberOfElements(String elementName) {
/**
* Getter for property coefArray.
*
- * @return an array of {@link double} objects. Coefficient corresponding to nameArray.
+ * @return an array of type double. Coefficient corresponding to nameArray.
*/
public double[] getElementCoefs() {
return coefArray;
diff --git a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java
index 4f0b777aa5..256c6d05fd 100644
--- a/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java
+++ b/src/main/java/neqsim/thermo/atomElement/UNIFACgroup.java
@@ -5,6 +5,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.ThermodynamicConstantsInterface;
+import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.component.ComponentGEUnifac;
import neqsim.thermo.phase.PhaseGEUnifac;
@@ -27,7 +28,7 @@ public class UNIFACgroup implements ThermodynamicConstantsInterface, Comparable<
double QComp = 0.0;
double QMix = 0.0;
public double[] QMixdN = null; // , xMixdN = null;
- double[] lnGammaMixdn = new double[MAX_NUMBER_OF_COMPONENTS];
+ double[] lnGammaMixdn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
double lnGammaComp = 0.0;
double lnGammaMix = 0.0;
double lnGammaCompdT = 0.0;
@@ -236,6 +237,7 @@ public int hashCode() {
/** {@inheritDoc} */
// @Override
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -283,7 +285,7 @@ public double calcXComp(ComponentGEUnifac component) {
}
/*
* public double calcXMix(PhaseGEUnifac phase) { double temp = 0.0, temp2 = 0.0, tempVal = 0.0;
- *
+ *
* for (int j = 0; j < phase.getNumberOfComponents(); j++) { for (int i = 0; i <
* ((ComponentGEUnifac) phase.getComponent(j)).getNumberOfUNIFACgroups(); i++) { tempVal =
* phase.getComponent(j).getNumberOfMolesInPhase() * ((ComponentGEUnifac)
@@ -353,7 +355,7 @@ public double calcQMix(PhaseGEUnifac phase) {
*
*
* @param phase a {@link neqsim.thermo.phase.PhaseGEUnifac} object
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] calcQMixdN(PhaseGEUnifac phase) {
setQMixdN(new double[phase.getNumberOfComponents()]);
@@ -408,7 +410,7 @@ public double getQMixdN(int comp) {
}
/*
* public double getXMixdN(int comp) { return xMixdN[comp]; }
- *
+ *
* public void setXMixdN(double[] xMixdN) { this.xMixdN = xMixdN; }
*/
diff --git a/src/main/java/neqsim/thermo/characterization/Characterise.java b/src/main/java/neqsim/thermo/characterization/Characterise.java
index 56c8dfb76b..f46f425a90 100644
--- a/src/main/java/neqsim/thermo/characterization/Characterise.java
+++ b/src/main/java/neqsim/thermo/characterization/Characterise.java
@@ -27,7 +27,9 @@ public class Characterise implements java.io.Serializable, Cloneable {
protected TBPfractionModel TBPfractionModelSelector;
/**
- * Constructor for Characterise.
+ *+ * Constructor for Characterise. + *
*/ public Characterise() {} @@ -154,7 +156,7 @@ public void characterisePlusFraction() { if (plusFractionModel.hasPlusFraction()) { if (plusFractionModel.getMPlus() > plusFractionModel.getMaxPlusMolarMass()) { logger.error("plus fraction molar mass too heavy for " + plusFractionModel.getName()); - plusFractionModel = plusFractionModelSelector.getModel("heavyOil"); + plusFractionModel = plusFractionModelSelector.getModel("Pedersen Heavy Oil"); logger.info("changing to " + plusFractionModel.getName()); } plusFractionModel.characterizePlusFraction(TBPfractionModel); @@ -163,17 +165,13 @@ public void characterisePlusFraction() { } /* - * * public boolean addPlusFraction(int start, int end) { plusFractionModel = new * PlusCharacterize(system); if (TBPCharacterise.hasPlusFraction()) { * TBPCharacterise.groupTBPfractions(); TBPCharacterise.generateTBPFractions(); return true; } * else { System.out.println("not able to generate pluss fraction"); return false; } } * - * * public boolean characterize2() { if (TBPCharacterise.groupTBPfractions()) { * TBPCharacterise.solve(); return true; } else { System.out.println("not able to generate pluss * fraction"); return false; } } - * - * */ } diff --git a/src/main/java/neqsim/thermo/characterization/CharacteriseInterface.java b/src/main/java/neqsim/thermo/characterization/CharacteriseInterface.java index 279e754cb0..f793bc5aba 100644 --- a/src/main/java/neqsim/thermo/characterization/CharacteriseInterface.java +++ b/src/main/java/neqsim/thermo/characterization/CharacteriseInterface.java @@ -120,7 +120,7 @@ public interface CharacteriseInterface { * getCoefs. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getCoefs(); @@ -166,7 +166,7 @@ public interface CharacteriseInterface { * getPlusCoefs. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getPlusCoefs(); @@ -185,7 +185,7 @@ public interface CharacteriseInterface { * setPlusCoefs. * * - * @param plusCoefs an array of {@link double} objects + * @param plusCoefs an array of type double */ public void setPlusCoefs(double[] plusCoefs); @@ -239,7 +239,7 @@ public interface CharacteriseInterface { * setCoefs. * * - * @param coefs an array of {@link double} objects + * @param coefs an array of type double */ public void setCoefs(double[] coefs); diff --git a/src/main/java/neqsim/thermo/characterization/LumpingModel.java b/src/main/java/neqsim/thermo/characterization/LumpingModel.java index b10cdae9e9..56143069bc 100644 --- a/src/main/java/neqsim/thermo/characterization/LumpingModel.java +++ b/src/main/java/neqsim/thermo/characterization/LumpingModel.java @@ -306,6 +306,7 @@ public void generateLumpedComposition(Characterise charac) { system.removeComponent(system.getPhase(0) .getComponent(charac.getPlusFractionModel().getPlusComponentNumber()).getName()); } + system.init(0); } @Override @@ -398,18 +399,18 @@ public void generateLumpedComposition(Characterise charac) { pseudoNumber++; String addName = "C" + Integer.toString(starti) + "-" + Integer.toString(i); getLumpedComponentNames()[k] = addName; - // System.out.println("adding " + addName); + //System.out.println("adding " + addName); fractionOfHeavyEnd[k] = zPlus[k] / molFracTot; - system.addTBPfraction(addName, totalNumberOfMoles * zPlus[k], Maverage / zPlus[k], denstemp1 / denstemp2); k++; - starti = i + 1; + starti = i; } if (charac.getPlusFractionModel().hasPlusFraction()) { system.removeComponent(system.getPhase(0) .getComponent(charac.getPlusFractionModel().getPlusComponentNumber()).getName()); } + system.init(0); } @Override diff --git a/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java b/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java index 1562d31c69..d926fde9a7 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java +++ b/src/main/java/neqsim/thermo/characterization/PlusCharacterize.java @@ -36,7 +36,9 @@ public class PlusCharacterize implements java.io.Serializable, CharacteriseInter SystemInterface system = null; /** - *Constructor for PlusCharacterize.
+ *+ * Constructor for PlusCharacterize. + *
*/ public PlusCharacterize() {} @@ -334,17 +336,6 @@ public int getStartPlus() { return firstPlusFractionNumber; } - /** - * Setter for property firstPlusFractionNumber. - * - * @param startPlus New value of property firstPlusFractionNumber. - * @deprecated use {@link #setFirstPlusFractionNumber(int firstPlusFractionNumber)} instead. - */ - @Deprecated - public void setStartPlus(int startPlus) { - setFirstPlusFractionNumber(startPlus); - } - /** {@inheritDoc} */ @Override public double getMPlus() { @@ -441,7 +432,7 @@ public void removeTBPfraction() { ArrayList* getModel. @@ -308,8 +476,12 @@ public PedersenHeavyOilPlusModel() { * @return a {@link neqsim.thermo.characterization.PlusFractionModelInterface} object */ public PlusFractionModelInterface getModel(String name) { - if (name.equals("heavyOil")) { + if (name.equals("Pedersen")) { + return new PedersenPlusModel(); + } else if (name.equals("Pedersen Heavy Oil")) { return new PedersenHeavyOilPlusModel(); + } else if (name.equals("Whitson Gamma Model")) { + return new WhitsonGammaModel(); } else { return new PedersenPlusModel(); } diff --git a/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java b/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java index 4b760e17eb..bfe437d1ce 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java +++ b/src/main/java/neqsim/thermo/characterization/PlusFractionModelInterface.java @@ -72,6 +72,8 @@ public interface PlusFractionModelInterface extends java.io.Serializable { */ public int getLastPlusFractionNumber(); + public void setLastPlusFractionNumber(int fract); + /** *
* getPlusComponentNumber. @@ -122,7 +124,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable { * getZ. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getZ(); @@ -131,7 +133,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable { * getM. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getM(); @@ -140,7 +142,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable { * getDens. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getDens(); @@ -149,7 +151,7 @@ public interface PlusFractionModelInterface extends java.io.Serializable { * getCoefs. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getCoefs(); diff --git a/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java b/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java index d836ffc01c..31fd1ed4b4 100644 --- a/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java +++ b/src/main/java/neqsim/thermo/characterization/TBPCharacterize.java @@ -62,7 +62,7 @@ public boolean groupTBPfractions() { for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { // if (system.getPhase(0).getComponent(i).getComponentType().equals("HC")) { - double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint(); + double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint("C"); if (boilpoint >= 331.0) { numb = 13; diff --git a/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java b/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java index b5d526a9d7..86e9969e84 100644 --- a/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java +++ b/src/main/java/neqsim/thermo/characterization/TBPfractionModel.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; /** @@ -55,7 +56,7 @@ public double calcAcentricFactorKeslerLee(double molarMass, double density) { double TB = calcTB(molarMass, density); double PC = calcPC(molarMass, density); double TBR = TB / TC; - double PBR = 1.01325 / PC; + double PBR = ThermodynamicConstantsInterface.referencePressure / PC; if (TBR < 0.8) { return (Math.log(PBR) - 5.92714 + 6.09649 / TBR + 1.28862 * Math.log(TBR) - 0.169347 * Math.pow(TBR, 6.0)) @@ -72,7 +73,8 @@ public double calcAcentricFactor(double molarMass, double density) { double TC = calcTC(molarMass, density); double TB = calcTB(molarMass, density); double PC = calcPC(molarMass, density); - return 3.0 / 7.0 * Math.log10(PC / 1.01325) / (TC / TB - 1.0) - 1.0; + return 3.0 / 7.0 * Math.log10(PC / ThermodynamicConstantsInterface.referencePressure) + / (TC / TB - 1.0) - 1.0; } @Override @@ -80,10 +82,11 @@ public double calcCriticalVolume(double molarMass, double density) { double TC = calcTC(molarMass, density); double PC = calcPC(molarMass, density); double acs = calcAcentricFactor(molarMass, density); // thermoSystem.getPhase(thermoSystem.getPhaseIndex(0)).getComponent(0).getAcentricFactor(); - double criticaVol = (0.2918 - 0.0928 * acs) * 8.314 * TC / PC * 10.0; + double criticaVol = + (0.2918 - 0.0928 * acs) * ThermodynamicConstantsInterface.R * TC / PC * 10.0; if (criticaVol < 0) { // logger.info("acentric factor in calc critVol " + acs); - criticaVol = (0.2918 - 0.0928) * 8.314 * TC / PC * 10.0; + criticaVol = (0.2918 - 0.0928) * ThermodynamicConstantsInterface.R * TC / PC * 10.0; } return criticaVol; } @@ -101,6 +104,16 @@ public double calcCriticalViscosity(double molarMass, double density) { * 1e-7; } + @Override + public double calcRacketZ(SystemInterface thermoSystem, double molarMass, double density) { + throw new RuntimeException("calcm() method not defined"); + } + + @Override + public double calcm(double molarMass, double density) { + throw new RuntimeException("calcm() method not defined"); + } + @Override public boolean isCalcm() { return calcm; @@ -142,7 +155,7 @@ public double calcPC(double molarMass, double density) { TBPfractionCoefs = TBPfractionCoefsHeavyOil; } - return 0.01325 + Math.exp(TBPfractionCoefs[1][0] + return Math.exp(0.01325 + TBPfractionCoefs[1][0] + TBPfractionCoefs[1][1] * Math.pow(density, TBPfractionCoefs[1][4]) + TBPfractionCoefs[1][2] / molarMass + TBPfractionCoefs[1][3] / Math.pow(molarMass, 2.0)); } @@ -151,37 +164,21 @@ public double calcPC(double molarMass, double density) { public double calcm(double molarMass, double density) { if (molarMass < 1120) { TBPfractionCoefs = TBPfractionCoefOil; - return TBPfractionCoefs[2][0] + TBPfractionCoefs[2][1] * molarMass - + TBPfractionCoefs[2][2] * density + TBPfractionCoefs[2][3] * Math.pow(molarMass, 2.0); } else { TBPfractionCoefs = TBPfractionCoefsHeavyOil; - return TBPfractionCoefs[2][0] + TBPfractionCoefs[2][1] * Math.log(molarMass) - + TBPfractionCoefs[2][2] * density + TBPfractionCoefs[2][3] * Math.sqrt(molarMass); } + return TBPfractionCoefs[2][0] + TBPfractionCoefs[2][1] * molarMass + + TBPfractionCoefs[2][2] * density + TBPfractionCoefs[2][3] * Math.pow(molarMass, 2.0); } @Override public double calcTB(double molarMass, double density) { - if (molarMass < 90) { - return 273.15 + 84; - } - if (molarMass < 107) { - return 273.15 + 116.6; - } - if (molarMass < 121) { - return 273.15 + 142.2; - } - if (molarMass < 134) { - return 273.15 + 165.8; - } - if (molarMass < 147) { - return 273.15 + 187.2; - } - if (molarMass < 161) { - return 273.15 + 208.3; + if (molarMass < 540) { + return 2E-06 * Math.pow(molarMass, 3) - 0.0035 * Math.pow(molarMass, 2) + 2.4003 * molarMass + + 171.74; + } else { + return 97.58 * Math.pow(molarMass, 0.3323) * Math.pow(density, 0.04609); } - - return 97.58 * Math.pow(molarMass, 0.3323) * Math.pow(density, 0.04609); } @Override @@ -278,7 +275,8 @@ public double calcAcentricFactor2(double molarMass, double density) { double TC = calcTC(molarMass, density); double TB = calcTB(molarMass, density); double PC = calcPC(molarMass, density); - return 3.0 / 7.0 * Math.log10(PC / 1.01325) / (TC / TB - 1.0) - 1.0; + return 3.0 / 7.0 * Math.log10(PC / ThermodynamicConstantsInterface.referencePressure) + / (TC / TB - 1.0) - 1.0; } @Override @@ -295,7 +293,7 @@ public double calcAcentricFactor(double molarMass, double density) { double TB = calcTB(molarMass, density); double PC = calcPC(molarMass, density); double TBR = TB / TC; - double PBR = 1.01325 / PC; + double PBR = ThermodynamicConstantsInterface.referencePressure / PC; if (TBR < 0.8) { return (Math.log(PBR) - 5.92714 + 6.09649 / TBR + 1.28862 * Math.log(TBR) - 0.169347 * Math.pow(TBR, 6.0)) @@ -308,6 +306,166 @@ public double calcAcentricFactor(double molarMass, double density) { } } + /** + * Lee-Kesler property estimation method + */ + public class LeeKesler extends TBPBaseModel { + private static final long serialVersionUID = 1000; + + public LeeKesler() { + calcm = false; + } + + @Override + public double calcTC(double molarMass, double density) { + double sg = density; + double TB = calcTB(molarMass, density); + double TC = + 189.8 + 450.6 * sg + (0.4244 + 0.1174 * sg) * TB + (0.1441 - 1.0069 * sg) * 1e5 / TB; + return TC; + } + + @Override + public double calcPC(double molarMass, double density) { + double sg = density; + double TB = calcTB(molarMass, density); + double logpc = + 3.3864 - 0.0566 / sg - ((0.43639 + 4.1216 / sg + 0.21343 / sg / sg) * 1e-3 * TB) + + ((0.47579 + 1.182 / sg + 0.15302 / sg / sg) * 1e-6 * TB * TB) + - ((2.4505 + 9.9099 / sg / sg) * 1e-10 * TB * TB * TB); + double PC = Math.exp(logpc) * 10; + return PC; + } + + public double calcAcentricFactor(double molarMass, double density) { + return super.calcAcentricFactorKeslerLee(molarMass, density); + } + } + + /** + * Two property estimation method + */ + public class TwuModel extends TBPBaseModel { + private static final long serialVersionUID = 1000; + + public TwuModel() { + calcm = false; + } + + @Override + public double calcTC(double molarMass, double density) { + double sg = density; + double TB = calcTB(molarMass, density); + double MW = solveMW(TB); + double Tcnalkane = TB * 1.0 / (0.533272 + 0.343831e-3 * TB + 2.526167e-7 * TB * TB + - 1.65848e-10 * TB * TB * TB + 4.60774e24 * Math.pow(TB, -13)); + double phi = 1.0 - TB / Tcnalkane; + double SGalkane = + 0.843593 - 0.128624 * phi - 3.36159 * Math.pow(phi, 3) - 13749 * Math.pow(phi, 12); + double PCnalkane = Math.pow(0.318317 + 0.099334 * Math.sqrt(phi) + 2.89698 * phi + + 3.0054 * phi * phi + 8.65163 * Math.pow(phi, 4), 2); + double VCnalkane = Math.pow( + (0.82055 + 0.715468 * phi + 2.21266 * phi * phi * phi + 13411.1 * Math.pow(phi, 14)), -8); + double deltaST = Math.exp(5.0 * (SGalkane - sg)) - 1.0; + double fT = deltaST * (-0.270159 * Math.pow(TB, -0.5) + + (0.0398285 - 0.706691 * Math.pow(TB, -0.5) * deltaST)); + double TC = Tcnalkane * Math.pow(((1 + 2 * fT) / (1 - 2 * fT)), 2); + return TC; + } + + public double calculateTfunc(double MW_alkane, double TB) { + double phi = Math.log(MW_alkane); + return Math + .exp(5.1264 + 2.71579 * phi - 0.28659 * phi * phi - 39.8544 / phi - 0.122488 / phi / phi) + - 13.7512 * phi + 19.6197 * phi * phi - TB; + } + + public double computeGradient(double MW_alkane, double TB) { + double delta = 1; + double TfuncPlus = calculateTfunc(MW_alkane + delta, TB); + double TfuncMinus = calculateTfunc(MW_alkane - delta, TB); + return (TfuncPlus - TfuncMinus) / (2 * delta); + } + + public double solveMW(double TB) { + double MW_alkane = TB / (5.8 - 0.0052 * TB); + double tolerance = 1e-6; + double prevMW_alkane; + double error = 1.0; + int iter = 0; + + do { + iter++; + prevMW_alkane = MW_alkane; + double gradient = computeGradient(MW_alkane, TB); + MW_alkane -= 0.5 * calculateTfunc(MW_alkane, TB) / gradient; + error = Math.abs(MW_alkane - prevMW_alkane); + } while (Math.abs(error) > tolerance && iter < 1000 || iter < 3); + + return MW_alkane; + } + + @Override + public double calcPC(double molarMass, double density) { + double sg = density; + double TB = calcTB(molarMass, density); + double MW = solveMW(TB); + double Tcnalkane = TB * 1.0 / (0.533272 + 0.343831e-3 * TB + 2.526167e-7 * TB * TB + - 1.65848e-10 * TB * TB * TB + 4.60774e24 * Math.pow(TB, -13)); + double phi = 1.0 - TB / Tcnalkane; + double SGalkane = + 0.843593 - 0.128624 * phi - 3.36159 * Math.pow(phi, 3) - 13749 * Math.pow(phi, 12); + double PCnalkane = Math.pow(0.318317 + 0.099334 * Math.sqrt(phi) + 2.89698 * phi + + 3.0054 * phi * phi + 8.65163 * Math.pow(phi, 4), 2); + double VCnalkane = Math.pow( + (0.82055 + 0.715468 * phi + 2.21266 * phi * phi * phi + 13411.1 * Math.pow(phi, 14)), -8); + double deltaST = Math.exp(5.0 * (SGalkane - sg)) - 1.0; + double fT = deltaST * (-0.270159 * Math.pow(TB, -0.5) + + (0.0398285 - 0.706691 * Math.pow(TB, -0.5) * deltaST)); + double TC = Tcnalkane * Math.pow(((1 + 2 * fT) / (1 - 2 * fT)), 2); + double deltaSP = Math.exp(0.5 * (SGalkane - sg)) - 1.0; + double deltaSV = Math.exp(4.0 * (SGalkane * SGalkane - sg * sg)) - 1.0; + double fV = deltaSV + * (0.347776 * Math.pow(TB, -0.5) + (-0.182421 + 2.24890 * Math.pow(TB, -0.5)) * deltaSV); + double VC = VCnalkane * Math.pow(((1 + 2 * fV) / (1 - 2 * fV)), 2); + double fP = deltaSP * ((2.53262 - 34.4321 * Math.pow(TB, -0.5) - 0.00230193 * TB) + + (-11.4277 + 187.934 * Math.pow(TB, -0.5) + 0.00414963 * TB) * deltaSP); + double PC = PCnalkane * (TC / Tcnalkane) * (VCnalkane / VC) + * Math.pow(((1 + 2 * fP) / (1 - 2 * fP)), 2); + return PC * 10.0; // * 10 due to conversion MPa to bar + } + + @Override + public double calcCriticalVolume(double molarMass, double density) { + double sg = density; + double TB = calcTB(molarMass, density); + double MW = solveMW(TB); + double Tcnalkane = TB * 1.0 / (0.533272 + 0.343831e-3 * TB + 2.526167e-7 * TB * TB + - 1.65848e-10 * TB * TB * TB + 4.60774e24 * Math.pow(TB, -13)); + double phi = 1.0 - TB / Tcnalkane; + double SGalkane = + 0.843593 - 0.128624 * phi - 3.36159 * Math.pow(phi, 3) - 13749 * Math.pow(phi, 12); + double PCnalkane = Math.pow(0.318317 + 0.099334 * Math.sqrt(phi) + 2.89698 * phi + + 3.0054 * phi * phi + 8.65163 * Math.pow(phi, 4), 2); + double VCnalkane = Math.pow( + (0.82055 + 0.715468 * phi + 2.21266 * phi * phi * phi + 13411.1 * Math.pow(phi, 14)), -8); + double deltaST = Math.exp(5.0 * (SGalkane - sg)) - 1.0; + double fT = deltaST * (-0.270159 * Math.pow(TB, -0.5) + + (0.0398285 - 0.706691 * Math.pow(TB, -0.5) * deltaST)); + double TC = Tcnalkane * Math.pow(((1 + 2 * fT) / (1 - 2 * fT)), 2); + double deltaSP = Math.exp(0.5 * (SGalkane - sg)) - 1.0; + double deltaSV = Math.exp(4.0 * (SGalkane * SGalkane - sg * sg)) - 1.0; + double fV = deltaSV + * (0.347776 * Math.pow(TB, -0.5) + (-0.182421 + 2.24890 * Math.pow(TB, -0.5)) * deltaSV); + double VC = VCnalkane * Math.pow(((1 + 2 * fV) / (1 - 2 * fV)), 2); + double fP = deltaSP * ((2.53262 - 34.4321 * Math.pow(TB, -0.5) - 0.00230193 * TB) + + (-11.4277 + 187.934 * Math.pow(TB, -0.5) + 0.00414963 * TB) * deltaSP); + double PC = PCnalkane * (TC / Tcnalkane) * (VCnalkane / VC) + * Math.pow(((1 + 2 * fP) / (1 - 2 * fP)), 2); + return VC * 1e3; // m3/mol + } + } + /** ** getModel. @@ -330,6 +488,10 @@ public TBPModelInterface getModel(String name) { return new PedersenTBPModelPRHeavyOil(); } else if (name.equals("RiaziDaubert")) { return new RiaziDaubert(); + } else if (name.equals("Lee-Kesler")) { + return new LeeKesler(); + } else if (name.equals("Twu")) { + return new TwuModel(); } else { // System.out.println("not a valid TBPModelName................."); return new PedersenTBPModelSRK(); diff --git a/src/main/java/neqsim/thermo/characterization/WaxModelInterface.java b/src/main/java/neqsim/thermo/characterization/WaxModelInterface.java index 9e73bffc8a..5775e008db 100644 --- a/src/main/java/neqsim/thermo/characterization/WaxModelInterface.java +++ b/src/main/java/neqsim/thermo/characterization/WaxModelInterface.java @@ -30,7 +30,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * setWaxParameters. *
* - * @param parameters an array of {@link double} objects + * @param parameters an array of type double */ public void setWaxParameters(double[] parameters); @@ -39,7 +39,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * getWaxParameters. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getWaxParameters(); @@ -68,7 +68,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * setParameterWaxHeatOfFusion. * * - * @param parameterWaxHeatOfFusion an array of {@link double} objects + * @param parameterWaxHeatOfFusion an array of type double */ public void setParameterWaxHeatOfFusion(double[] parameterWaxHeatOfFusion); @@ -84,7 +84,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * getParameterWaxHeatOfFusion. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getParameterWaxHeatOfFusion(); @@ -93,7 +93,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * getParameterWaxTriplePointTemperature. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getParameterWaxTriplePointTemperature(); @@ -102,7 +102,7 @@ public interface WaxModelInterface extends java.io.Serializable, Cloneable { * setParameterWaxTriplePointTemperature. * * - * @param parameterWaxTriplePointTemperature an array of {@link double} objects + * @param parameterWaxTriplePointTemperature an array of type double */ public void setParameterWaxTriplePointTemperature(double[] parameterWaxTriplePointTemperature); diff --git a/src/main/java/neqsim/thermo/component/Component.java b/src/main/java/neqsim/thermo/component/Component.java index 8e7c44c825..7417adae32 100644 --- a/src/main/java/neqsim/thermo/component/Component.java +++ b/src/main/java/neqsim/thermo/component/Component.java @@ -9,12 +9,22 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.atomElement.Element; import neqsim.thermo.component.attractiveEosTerm.AttractiveTermInterface; import neqsim.thermo.phase.PhaseInterface; import neqsim.util.database.NeqSimDataBase; +import neqsim.util.unit.PressureUnit; +import neqsim.util.unit.TemperatureUnit; -abstract class Component implements ComponentInterface { +/** + *+ * Abstract Component class. + *
+ * + * @author Even Solbraa + */ +public abstract class Component implements ComponentInterface { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(Component.class); @@ -84,7 +94,6 @@ abstract class Component implements ComponentInterface { protected double criticalTemperature; protected double molarMass; protected double acentricFactor; - protected double normalLiquidDensity = 0; protected double reducedPressure; protected double reducedTemperature; @@ -123,10 +132,17 @@ abstract class Component implements ComponentInterface { protected double paulingAnionicDiameter = 0; private int orginalNumberOfAssociationSites = 0; + + /* Derivative of fugacity wrt temperature */ protected double dfugdt = 0.1; + /* Derivative of fugacity wrt pressure */ protected double dfugdp = 0.1; - protected double[] dfugdn = new double[MAX_NUMBER_OF_COMPONENTS]; - public double[] dfugdx = new double[MAX_NUMBER_OF_COMPONENTS]; + /* Derivative of fugacity wrt mole fraction (of each ) */ + protected double[] dfugdn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; + /* Derivative of fugacity wrt temperature */ + public double[] dfugdx = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; + + // Parameters for Antoine equation double AntoineA = 0; double AntoineB = 0; double AntoineC = 0; @@ -141,14 +157,14 @@ abstract class Component implements ComponentInterface { private double[] CpSolid = new double[5]; private double[] CpLiquid = new double[5]; private double heatOfFusion = 0.0; + double triplePointDensity = 10.0; double triplePointPressure = 0.0; - private double triplePointTemperature = 1000.0; double meltingPointTemperature = 110.0; + private double idealGasEnthalpyOfFormation = 0.0; double idealGasGibbsEnergyOfFormation = 0.0; - double idealGasAbsoluteEntropy = 0.0; double Hsub = 0.0; @@ -186,41 +202,38 @@ public Component(int number, double TC, double PC, double M, double a, double mo * Constructor for Component. * * - * @param component_name Name of component. + * @param name Name of component. * @param moles Total number of moles of component. * @param molesInPhase Number of moles in phase. - * @param compnumber Index number of component in phase object component array. + * @param compIndex Index number of component in phase object component array. */ - public Component(String component_name, double moles, double molesInPhase, int compnumber) { - createComponent(component_name, moles, molesInPhase, compnumber); + public Component(String name, double moles, double molesInPhase, int compIndex) { + createComponent(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @Override - public void createComponent(String component_name, double moles, double molesInPhase, - int compnumber) { - if (component_name == null) { + public void createComponent(String name, double moles, double molesInPhase, int compIndex) { + if (name == null) { throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, - "createComponent", "component_name", "can not be null")); + "createComponent", "name", "can not be null")); } - if (component_name.trim() == "") { + if (name.trim() == "") { throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, - "createComponent", "component_name", "can not be empty")); + "createComponent", "name", "can not be empty")); } - component_name = ComponentInterface.getComponentNameFromAlias(component_name); - componentName = component_name; + name = ComponentInterface.getComponentNameFromAlias(name); + componentName = name; numberOfMoles = moles; numberOfMolesInPhase = molesInPhase; java.sql.ResultSet dataSet = null; try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - if (!component_name.equals("default")) { + if (!name.equals("default")) { try { if (NeqSimDataBase.createTemporaryTables()) { - dataSet = database - .getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comptemp WHERE name='" + name + "'")); } else { - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); } dataSet.next(); dataSet.getString("ID"); @@ -229,9 +242,8 @@ public void createComponent(String component_name, double moles, double molesInP try { dataSet.close(); // logger.info("no parameters in tempcomp -- trying comp.. " + - // component_name); - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + // name); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); } catch (Exception e2) { throw new RuntimeException(e2); @@ -275,10 +287,10 @@ public void createComponent(String component_name, double moles, double molesInP AntoineC = Double.parseDouble(dataSet.getString("ANTOINEC")); // AX AntoineD = Double.parseDouble(dataSet.getString("ANTOINED")); AntoineE = Double.parseDouble(dataSet.getString("ANTOINEE")); - + normalBoilingPoint = Double.parseDouble(dataSet.getString("normboil")) + 273.15; if (AntoineA == 0) { AntoineA = 1.0; - AntoineB = getNormalBoilingPoint(); + AntoineB = getNormalBoilingPoint() - 273.15; } AntoineASolid = Double.parseDouble(dataSet.getString("ANTOINESolidA")); @@ -286,7 +298,7 @@ public void createComponent(String component_name, double moles, double molesInP AntoineCSolid = Double.parseDouble(dataSet.getString("ANTOINESolidC")); debyeDipoleMoment = Double.parseDouble(dataSet.getString("dipolemoment")); - normalBoilingPoint = Double.parseDouble(dataSet.getString("normboil")); + standardDensity = Double.parseDouble(dataSet.getString("stddens")); viscosityCorrectionFactor = Double.parseDouble(dataSet.getString("viscfact")); // BC racketZ = Double.parseDouble(dataSet.getString("racketZ")); // BE @@ -437,7 +449,7 @@ public void createComponent(String component_name, double moles, double molesInP waxFormer = Integer.parseInt(dataSet.getString("waxformer")) == 1; // System.out.println(componentName + " pure component parameters: ok..."); } - componentNumber = compnumber; + componentNumber = compIndex; } catch (Exception ex) { logger.error("error in comp", ex); } @@ -494,13 +506,18 @@ public Component clone() { @Override public void addMolesChemReac(double dn, double totdn) { if (numberOfMoles + totdn < 0 || numberOfMolesInPhase + dn < 0) { - String msg = "will lead to negative number of moles of component in phase for component " - + getComponentName() + " who has " + numberOfMolesInPhase - + " in phase and chage request was " + dn; - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", "dn", msg); - throw new RuntimeException(ex); - // logger.error(ex.getMessage()); + if (Math.abs(dn) < 1e-12) { + dn = 0; + totdn = 0; + } else { + String msg = "will lead to negative number of moles of component in phase for component " + + getComponentName() + " who has " + numberOfMolesInPhase + + " in phase and chage request was " + dn; + neqsim.util.exception.InvalidInputException ex = + new neqsim.util.exception.InvalidInputException(this, "addMolesChemReac", "dn", msg); + throw new RuntimeException(ex); + // logger.error(ex.getMessage()); + } } numberOfMoles += totdn; numberOfMolesInPhase += dn; @@ -519,12 +536,12 @@ public void setProperties(ComponentInterface component) { /** {@inheritDoc} */ @Override public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { + int initType) { if (totalNumberOfMoles == 0) { throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "init", "totalNumberOfMoles", "must be larger than 0")); } - if (type == 0) { + if (initType == 0) { K = Math.exp(Math.log(criticalPressure / pressure) + 5.373 * (1.0 + srkacentricFactor) * (1.0 - criticalTemperature / temperature)); z = numberOfMoles / totalNumberOfMoles; @@ -548,7 +565,7 @@ public Element getElements() { /** {@inheritDoc} */ @Override public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) {} + int numberOfComponents, int initType) {} /** {@inheritDoc} */ @Override @@ -652,18 +669,40 @@ public final double getTC() { return criticalTemperature; } + /** {@inheritDoc} */ + @Override + public final double getTC(String unit) { + neqsim.util.unit.TemperatureUnit tempConversion = + new neqsim.util.unit.TemperatureUnit(criticalTemperature, "K"); + return tempConversion.getValue(unit); + } + /** {@inheritDoc} */ @Override public final void setTC(double val) { criticalTemperature = val; } + /** {@inheritDoc} */ + @Override + public final void setTC(double val, String unit) { + TemperatureUnit inValue = new TemperatureUnit(val, unit); + criticalTemperature = inValue.getValue(val, unit, "K"); + } + /** {@inheritDoc} */ @Override public final void setPC(double val) { criticalPressure = val; } + /** {@inheritDoc} */ + @Override + public final void setPC(double val, String unit) { + PressureUnit inValue = new PressureUnit(val, unit); + criticalPressure = inValue.getValue(val, unit, "bara"); + } + /** {@inheritDoc} */ @Override public final String getComponentName() { @@ -682,6 +721,14 @@ public final double getPC() { return criticalPressure; } + /** {@inheritDoc} */ + @Override + public final double getPC(String unit) { + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(criticalPressure, "bara"); + return presConversion.getValue(unit); + } + /** {@inheritDoc} */ @Override public double getGibbsEnergyOfFormation() { @@ -747,6 +794,73 @@ public double getNormalLiquidDensity() { return normalLiquidDensity; } + /** {@inheritDoc} */ + @Override + public double getNormalLiquidDensity(String unit) { + double refDensity = normalLiquidDensity * 1e3; // density in kg/m3 + double conversionFactor = 1.0; + switch (unit) { + case "kg/m3": + conversionFactor = 1.0; + break; + case "lb/ft3": + conversionFactor = 0.0624279606; + break; + case "kg/Sm3": + return getMolarMass() * ThermodynamicConstantsInterface.atm + / ThermodynamicConstantsInterface.R + / ThermodynamicConstantsInterface.standardStateTemperature; + case "mol/m3": + conversionFactor = 1.0 / getMolarMass(); + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + return refDensity * conversionFactor; + } + + /** {@inheritDoc} */ + @Override + public double getMolarMass(String unit) { + double refMolarMass = getMolarMass(); + double conversionFactor = 1.0; + switch (unit) { + case "kg/mol": + conversionFactor = 1.0; + break; + case "gr/mol": + conversionFactor = 1000.0; + break; + case "lbm/lbmol": + conversionFactor = 1000.0; + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + return refMolarMass * conversionFactor; + } + + /** {@inheritDoc} */ + @Override + public void setMolarMass(double value, String unit) { + double refMolarMass = value; + double conversionFactor = 1.0; + switch (unit) { + case "kg/mol": + conversionFactor = 1.0; + break; + case "gr/mol": + conversionFactor = 1000.0; + break; + case "lbm/lbmol": + conversionFactor = 1000.0; + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + molarMass = refMolarMass * 1.0 / conversionFactor; + } + /** {@inheritDoc} */ @Override public double getViscosityCorrectionFactor() { @@ -1459,7 +1573,7 @@ public final double[] getMatiascopemanParams() { * Getter for the fieldmatiascopemanParamsPR
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public final double[] getMatiascopemanParamsPR() {
return matiascopemanParamsPR;
@@ -1549,6 +1663,14 @@ public double getNormalBoilingPoint() {
return normalBoilingPoint;
}
+ /** {@inheritDoc} */
+ @Override
+ public double getNormalBoilingPoint(String unit) {
+ neqsim.util.unit.TemperatureUnit tempConversion =
+ new neqsim.util.unit.TemperatureUnit(getNormalBoilingPoint(), "K");
+ return tempConversion.getValue(unit);
+ }
+
/** {@inheritDoc} */
@Override
public void setNormalBoilingPoint(double normalBoilingPoint) {
@@ -2177,13 +2299,8 @@ public double getVolumeCorrectionT() {
return volumeCorrectionT;
}
- /**
- * - * getVolumeCorrection. - *
- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double getVolumeCorrection() { return 0.0; } diff --git a/src/main/java/neqsim/thermo/component/ComponentBWRS.java b/src/main/java/neqsim/thermo/component/ComponentBWRS.java index 28f4499992..35179cc583 100644 --- a/src/main/java/neqsim/thermo/component/ComponentBWRS.java +++ b/src/main/java/neqsim/thermo/component/ComponentBWRS.java @@ -39,19 +39,18 @@ public class ComponentBWRS extends ComponentSrk { * Constructor for ComponentBWRS. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentBWRS(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentBWRS(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { java.sql.ResultSet dataSet = null; try { - dataSet = database - .getResultSet(("SELECT * FROM mbwr32param WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM mbwr32param WHERE name='" + name + "'")); dataSet.next(); dataSet.getClob("name"); } catch (Exception ex) { @@ -102,8 +101,8 @@ public ComponentBWRS clone() { /** {@inheritDoc} */ @Override public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - super.init(temperature, pressure, totalNumberOfMoles, beta, type); + int initType) { + super.init(temperature, pressure, totalNumberOfMoles, beta, initType); BP[0] = R * temperature; BP[1] = aBWRS[0] * temperature + aBWRS[1] * Math.sqrt(temperature) + aBWRS[2] diff --git a/src/main/java/neqsim/thermo/component/ComponentCPAInterface.java b/src/main/java/neqsim/thermo/component/ComponentCPAInterface.java index 2f5567e21a..1f0ee6d24d 100644 --- a/src/main/java/neqsim/thermo/component/ComponentCPAInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentCPAInterface.java @@ -16,7 +16,7 @@ public interface ComponentCPAInterface extends ComponentEosInterface { * getXsite. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getXsite(); @@ -25,7 +25,7 @@ public interface ComponentCPAInterface extends ComponentEosInterface { * getXsiteOld. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getXsiteOld(); @@ -34,7 +34,7 @@ public interface ComponentCPAInterface extends ComponentEosInterface { * getXsitedT. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getXsitedT(); @@ -43,7 +43,7 @@ public interface ComponentCPAInterface extends ComponentEosInterface { * getXsitedTdT. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getXsitedTdT(); @@ -83,7 +83,7 @@ public interface ComponentCPAInterface extends ComponentEosInterface { * getXsitedV. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getXsitedV(); diff --git a/src/main/java/neqsim/thermo/component/ComponentCSPsrk.java b/src/main/java/neqsim/thermo/component/ComponentCSPsrk.java index 609b7f5d52..bb537a45e0 100644 --- a/src/main/java/neqsim/thermo/component/ComponentCSPsrk.java +++ b/src/main/java/neqsim/thermo/component/ComponentCSPsrk.java @@ -23,13 +23,13 @@ public class ComponentCSPsrk extends ComponentSrk { * Constructor for ComponentCSPsrk. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentCSPsrk(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentCSPsrk(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** @@ -64,15 +64,15 @@ public ComponentCSPsrk clone() { /** {@inheritDoc} */ @Override public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int type) { - super.init(temperature, pressure, totalNumberOfMoles, beta, type); + int initType) { + super.init(temperature, pressure, totalNumberOfMoles, beta, initType); h_scale_mix_i = Bi / (refPhaseBWRS.getRefBWRSPhase().getB() / refPhaseBWRS.getRefBWRSPhase().getNumberOfMolesInPhase()); double termfi1 = Ai / refPhaseBWRS.getA(); double termfi2 = h_scale_mix_i / refPhaseBWRS.getH_scale_mix(); - double termfi3 = ((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0)) - .getaDiffT() + double termfi3 = + ((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0)).getaDiffT() / ((ComponentEosInterface) refPhaseBWRS.getRefBWRSPhase().getComponent(0)).getaT() * refPhaseBWRS.getRefBWRSPhase().getTemperature() / refPhaseBWRS.getNumberOfMolesInPhase(); diff --git a/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java b/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java index dbd3fe8a64..4b62e6cc26 100644 --- a/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java +++ b/src/main/java/neqsim/thermo/component/ComponentDesmukhMather.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseDesmukhMather; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -24,28 +25,25 @@ public class ComponentDesmukhMather extends ComponentGE { * Constructor for ComponentDesmukhMather. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentDesmukhMather(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentDesmukhMather(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); java.sql.ResultSet dataSet = null; try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - if (!component_name.equals("default")) { + if (!name.equals("default")) { try { - dataSet = - database.getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comptemp WHERE name='" + name + "'")); dataSet.next(); dataSet.getString("FORMULA"); } catch (Exception ex) { dataSet.close(); - logger.info("no parameters in tempcomp -- trying comp.. " + component_name); - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + logger.info("no parameters in tempcomp -- trying comp.. " + name); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); } deshMathIonicDiameter = Double.parseDouble(dataSet.getString("DeshMatIonicDiameter")); @@ -58,9 +56,9 @@ public ComponentDesmukhMather(String component_name, double moles, double molesI /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype); + return getGamma(phase, numberOfComponents, temperature, pressure, pt); } /** @@ -72,11 +70,11 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { double A = 1.174; double B = 3.32384e9; diff --git a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPA.java b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPA.java index 854369e730..cde1830079 100644 --- a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPA.java @@ -28,14 +28,13 @@ public class ComponentElectrolyteCPA extends ComponentModifiedFurstElectrolyteEo * Constructor for ComponentElectrolyteCPA. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentElectrolyteCPA(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentElectrolyteCPA(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); xsite = new double[numberOfAssociationSites]; xsitedni = new double[numberOfAssociationSites][100]; xsitedV = new double[numberOfAssociationSites]; @@ -572,7 +571,7 @@ public double[] getXsiteOld() { /** * Setter for property xsite. * - * @param xsiteOld an array of {@link double} objects + * @param xsiteOld an array of type double */ public void setXsiteOld(double[] xsiteOld) { this.xsiteOld = xsiteOld; diff --git a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAOld.java b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAOld.java index 5890ab468c..8405866e56 100644 --- a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAOld.java +++ b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAOld.java @@ -31,14 +31,13 @@ public class ComponentElectrolyteCPAOld extends ComponentModifiedFurstElectrolyt * Constructor for ComponentElectrolyteCPAOld. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentElectrolyteCPAOld(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentElectrolyteCPAOld(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); xsite = new double[numberOfAssociationSites]; xsitedV = new double[numberOfAssociationSites]; xsiteOld = new double[numberOfAssociationSites]; @@ -271,8 +270,8 @@ public double calc_lngidV(PhaseInterface phase) { return 2.0 * getBi() * (10.0) / ((8.0 * phase.getTotalVolume() - phase.getB()) * (4.0 * phase.getTotalVolume() - phase.getB())) - - 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) * (32 - * Math.pow(phase.getTotalVolume(), 2.0) + - 2.0 * getBi() * (10.0 * phase.getTotalVolume() - phase.getB()) + * (32 * Math.pow(phase.getTotalVolume(), 2.0) - 12.0 * phase.getTotalVolume() * phase.getB() + Math.pow(phase.getB(), 2.0)) / Math.pow(((8.0 * phase.getTotalVolume() - phase.getB()) * (4.0 * phase.getTotalVolume() - phase.getB())), 2.0); @@ -378,7 +377,7 @@ public double[] getXsiteOld() { /** * Setter for property xsite. * - * @param xsiteOld an array of {@link double} objects + * @param xsiteOld an array of type double */ public void setXsiteOld(double[] xsiteOld) { this.xsiteOld = xsiteOld; diff --git a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAstatoil.java b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAstatoil.java index 544c616836..6d37cc2deb 100644 --- a/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAstatoil.java +++ b/src/main/java/neqsim/thermo/component/ComponentElectrolyteCPAstatoil.java @@ -18,14 +18,14 @@ public class ComponentElectrolyteCPAstatoil extends ComponentElectrolyteCPA { * Constructor for ComponentElectrolyteCPAstatoil. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentElectrolyteCPAstatoil(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentElectrolyteCPAstatoil(String name, double moles, double molesInPhase, + int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** diff --git a/src/main/java/neqsim/thermo/component/ComponentEos.java b/src/main/java/neqsim/thermo/component/ComponentEos.java index 00a327def1..b48e16fedf 100644 --- a/src/main/java/neqsim/thermo/component/ComponentEos.java +++ b/src/main/java/neqsim/thermo/component/ComponentEos.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.attractiveEosTerm.AtractiveTermMatCopPRUMRNew; import neqsim.thermo.component.attractiveEosTerm.AttractiveTermCPAstatoil; import neqsim.thermo.component.attractiveEosTerm.AttractiveTermGERG; @@ -32,9 +33,13 @@ import neqsim.thermo.phase.PhaseInterface; /** + *+ * Abstract ComponentEos class. + *
+ * * @author Even Solbraa */ -abstract class ComponentEos extends Component implements ComponentEosInterface { +public abstract class ComponentEos extends Component implements ComponentEosInterface { private static final long serialVersionUID = 1000; public double a = 1; @@ -57,8 +62,8 @@ abstract class ComponentEos extends Component implements ComponentEosInterface { public double aDiffDiffT = 0; - public double[] Aij = new double[MAX_NUMBER_OF_COMPONENTS]; - public double[] Bij = new double[MAX_NUMBER_OF_COMPONENTS]; + public double[] Aij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; + public double[] Bij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; protected double delta1 = 0; protected double delta2 = 0; @@ -75,8 +80,8 @@ abstract class ComponentEos extends Component implements ComponentEosInterface { protected double bDerTn = 0; - protected double[] dAdndn = new double[MAX_NUMBER_OF_COMPONENTS]; - protected double[] dBdndn = new double[MAX_NUMBER_OF_COMPONENTS]; + protected double[] dAdndn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; + protected double[] dBdndn = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; private AttractiveTermInterface attractiveParameter; static Logger logger = LogManager.getLogger(ComponentEos.class); @@ -85,13 +90,13 @@ abstract class ComponentEos extends Component implements ComponentEosInterface { * Constructor for ComponentEos. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentEos(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentEos(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** @@ -105,7 +110,6 @@ public ComponentEos(String component_name, double moles, double molesInPhase, in * @param M Molar mass * @param a Acentric factor * @param moles Number of moles - * */ public ComponentEos(int number, double TC, double PC, double M, double a, double moles) { super(number, TC, PC, M, a, moles); @@ -128,14 +132,14 @@ public ComponentEos clone() { /** {@inheritDoc} */ @Override - public void init(double temp, double pres, double totMoles, double beta, int type) { - super.init(temp, pres, totMoles, beta, type); + public void init(double temp, double pres, double totMoles, double beta, int initType) { + super.init(temp, pres, totMoles, beta, initType); a = calca(); b = calcb(); reducedTemperature = reducedTemperature(temp); reducedPressure = reducedPressure(pres); aT = a * alpha(temp); - if (type >= 2) { + if (initType >= 2) { aDiffT = diffaT(temp); aDiffDiffT = diffdiffaT(temp); } @@ -144,10 +148,10 @@ public void init(double temp, double pres, double totMoles, double beta, int typ /** {@inheritDoc} */ @Override public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) { + int numberOfComponents, int initType) { Bi = phase.calcBi(componentNumber, phase, temp, pres, numberOfComponents); Ai = phase.calcAi(componentNumber, phase, temp, pres, numberOfComponents); - if (type >= 2) { + if (initType >= 2) { AiT = phase.calcAiT(componentNumber, phase, temp, pres, numberOfComponents); } double totVol = phase.getMolarVolume() * phase.getNumberOfMolesInPhase(); @@ -156,7 +160,7 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole / (-R * temp * phase.dFdVdV() - phase.getNumberOfMolesInPhase() * R * temp / (totVol * totVol)); - if (type >= 3) { + if (initType >= 3) { for (int j = 0; j < numberOfComponents; j++) { Aij[j] = phase.calcAij(componentNumber, j, phase, temp, pres, numberOfComponents); Bij[j] = phase.calcBij(componentNumber, j, phase, temp, pres, numberOfComponents); @@ -225,6 +229,8 @@ public AttractiveTermInterface getAttractiveTerm() { } /** + * Get reduced temperature. + * * @param temperature temperature of fluid * @return double reduced temperature T/TC */ @@ -233,6 +239,10 @@ public AttractiveTermInterface getAttractiveTerm() { } /** + *+ * Get reduced pressure. + *
+ * * @param pressure pressure in unit bara * @return double */ @@ -340,7 +350,7 @@ public double fugcoef(PhaseInterface phase) { double pressure = phase.getPressure(); double logFugacityCoefficient = dFdN(phase, phase.getNumberOfComponents(), temperature, pressure) - - Math.log(pressure * phase.getMolarVolume() / (R * temperature)); + - Math.log(pressure * phase.getMolarVolume() / (R * temperature)); fugacityCoefficient = Math.exp(logFugacityCoefficient); return fugacityCoefficient; } diff --git a/src/main/java/neqsim/thermo/component/ComponentEosInterface.java b/src/main/java/neqsim/thermo/component/ComponentEosInterface.java index 5dccf077fc..1e44427f9b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentEosInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentEosInterface.java @@ -180,7 +180,7 @@ public interface ComponentEosInterface extends ComponentInterface { * getDeltaEosParameters. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getDeltaEosParameters(); diff --git a/src/main/java/neqsim/thermo/component/ComponentGE.java b/src/main/java/neqsim/thermo/component/ComponentGE.java index 04aafb72b3..0260c74beb 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGE.java +++ b/src/main/java/neqsim/thermo/component/ComponentGE.java @@ -12,10 +12,11 @@ import neqsim.thermo.phase.PhaseInterface; /** + * Abstract class ComponentGE. * * @author Even Solbraa */ -abstract class ComponentGE extends Component implements ComponentGEInterface { +public abstract class ComponentGE extends Component implements ComponentGEInterface { private static final long serialVersionUID = 1000; protected double gamma = 0; @@ -32,13 +33,13 @@ abstract class ComponentGE extends Component implements ComponentGEInterface { * Constructor for ComponentGE. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGE(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGE(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/component/ComponentGEInterface.java b/src/main/java/neqsim/thermo/component/ComponentGEInterface.java index 109ce50c06..bf09d8b862 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEInterface.java @@ -7,6 +7,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -26,15 +27,15 @@ public interface ComponentGEInterface extends ComponentInterface { * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects - * @param intparam an array of {@link double} objects + * @param pt the PhaseType of the phase + * @param HValpha an array of type double + * @param HVgij an array of type double + * @param intparam an array of type double * @param mixRule an array of {@link java.lang.String} objects * @return a double */ public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule); /** diff --git a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java index 96fae40724..be1f98c343 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedHV.java @@ -7,6 +7,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *
@@ -24,24 +25,23 @@ public class ComponentGENRTLmodifiedHV extends ComponentGeNRTL { * Constructor for ComponentGENRTLmodifiedHV. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGENRTLmodifiedHV(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGENRTLmodifiedHV(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { double[][] HVgijT = new double[numberOfComponents][numberOfComponents]; - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, HValpha, HVgij, - HVgijT, intparam, mixRule); + return getGamma(phase, numberOfComponents, temperature, pressure, pt, HValpha, HVgij, HVgijT, + intparam, mixRule); } /** @@ -53,16 +53,16 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects - * @param HVgijT an array of {@link double} objects - * @param intparam an array of {@link double} objects + * @param pt the PhaseType of the phase + * @param HValpha an array of type double + * @param HVgij an array of type double + * @param HVgijT an array of type double + * @param intparam an array of type double * @param mixRule an array of {@link java.lang.String} objects * @return a double */ public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] HVgijT, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] HVgijT, double[][] intparam, String[][] mixRule) { int type = phase.getInitType(); double A = 0; diff --git a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java index 2c3bbc2989..aa37b657f3 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java +++ b/src/main/java/neqsim/thermo/component/ComponentGENRTLmodifiedWS.java @@ -1,6 +1,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -18,14 +19,13 @@ public class ComponentGENRTLmodifiedWS extends ComponentGeNRTL { * Constructor for ComponentGENRTLmodifiedWS. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGENRTLmodifiedWS(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGENRTLmodifiedWS(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @@ -43,11 +43,11 @@ public double getlnGammadn(int k) { /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, double[][] intparam, + double pressure, PhaseType pt, double[][] WSalpha, double[][] WSgij, double[][] intparam, String[][] mixRule) { double[][] WSgijT = new double[numberOfComponents][numberOfComponents]; - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, WSalpha, WSgij, - WSgijT, intparam, mixRule); + return getGamma(phase, numberOfComponents, temperature, pressure, pt, WSalpha, WSgij, WSgijT, + intparam, mixRule); } /** @@ -59,17 +59,17 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int - * @param WSalpha an array of {@link double} objects - * @param WSgij an array of {@link double} objects - * @param WSgijT an array of {@link double} objects - * @param intparam an array of {@link double} objects + * @param pt the PhaseType of the phase + * @param WSalpha an array of type double + * @param WSgij an array of type double + * @param WSgijT an array of type double + * @param intparam an array of type double * @param mixRule an array of {@link java.lang.String} objects * @return a double */ @SuppressWarnings("unused") public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] WSalpha, double[][] WSgij, double[][] WSgijT, + double pressure, PhaseType pt, double[][] WSalpha, double[][] WSgij, double[][] WSgijT, double[][] intparam, String[][] mixRule) { double type = phase.getInitType(); double A = 0; @@ -233,7 +233,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp - dA6dTetter); /* * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * + * * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } */ // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + @@ -244,7 +244,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp // dlngammadt = (lngammaold-lngamma)/0.002; // phaseny.getExcessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) + // pt) gamma = Math.exp(lngamma); // if derivates.... diff --git a/src/main/java/neqsim/thermo/component/ComponentGERG2004.java b/src/main/java/neqsim/thermo/component/ComponentGERG2004.java index 23cb02840d..18ae7d720a 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGERG2004.java +++ b/src/main/java/neqsim/thermo/component/ComponentGERG2004.java @@ -18,14 +18,13 @@ public class ComponentGERG2004 extends ComponentEos { * Constructor for ComponentGERG2004. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGERG2004(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGERG2004(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java b/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java index fbdc462e3f..8066fee4d5 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUnifac.java @@ -12,6 +12,7 @@ import neqsim.thermo.atomElement.UNIFACgroup; import neqsim.thermo.phase.PhaseGEUnifac; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -38,18 +39,17 @@ public class ComponentGEUnifac extends ComponentGEUniquac { * Constructor for ComponentGEUnifac. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEUnifac(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEUnifac(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); if (!this.getClass().equals(ComponentGEUnifac.class)) { return; } - if (component_name.contains("_PC")) { + if (name.contains("_PC")) { double number = getMolarMass() / 0.014; int intNumb = (int) Math.round(number) - 2; unifacGroups.add(new UNIFACgroup(1, 2)); @@ -61,14 +61,12 @@ public ComponentGEUnifac(String component_name, double moles, double molesInPhas try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { java.sql.ResultSet dataSet = null; try { - dataSet = - database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + name + "'")); dataSet.next(); dataSet.getClob("name"); } catch (Exception ex) { dataSet.close(); - dataSet = - database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + name + "'")); dataSet.next(); } @@ -76,10 +74,9 @@ public ComponentGEUnifac(String component_name, double moles, double molesInPhas int temp = Integer.parseInt(dataSet.getString("sub" + Integer.toString(p))); if (temp > 0) { unifacGroups.add(new UNIFACgroup(p, temp)); - // System.out.println("comp " + component_name + " adding UNIFAC group " + p); + // System.out.println("comp " + name + " adding UNIFAC group " + p); } } - } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -133,10 +130,9 @@ public double getR() { /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - fugacityCoefficient = - (this.getGamma(phase, numberOfComponents, temperature, pressure, phasetype) - * this.getAntoineVaporPressure(temperature) / pressure); + double pressure, PhaseType pt) { + fugacityCoefficient = (this.getGamma(phase, numberOfComponents, temperature, pressure, pt) + * this.getAntoineVaporPressure(temperature) / pressure); return fugacityCoefficient; } @@ -189,7 +185,7 @@ public void calclnGammak(int k, PhaseInterface phase) { /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { double lngammaCombinational = 0.0; double lngammaResidual = 0.0; dlngammadn = new double[numberOfComponents]; @@ -243,39 +239,35 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp /** {@inheritDoc} */ @Override public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - dfugdp = (Math.log(fugcoef(phase, numberOfComponents, temperature, pressure + 0.01, phasetype)) - - Math.log(fugcoef(phase, numberOfComponents, temperature, pressure - 0.01, phasetype))) - / 0.02; + double pressure, PhaseType pt) { + dfugdp = (Math.log(fugcoef(phase, numberOfComponents, temperature, pressure + 0.01, pt)) + - Math.log(fugcoef(phase, numberOfComponents, temperature, pressure - 0.01, pt))) / 0.02; return dfugdp; } /** {@inheritDoc} */ @Override public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - dfugdt = (Math.log(fugcoef(phase, numberOfComponents, temperature + 0.01, pressure, phasetype)) - - Math.log(fugcoef(phase, numberOfComponents, temperature - 0.01, pressure, phasetype))) - / 0.02; + double pressure, PhaseType pt) { + dfugdt = (Math.log(fugcoef(phase, numberOfComponents, temperature + 0.01, pressure, pt)) + - Math.log(fugcoef(phase, numberOfComponents, temperature - 0.01, pressure, pt))) / 0.02; return dfugdt; } /* * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ // NumericalDerivative deriv = new NumericalDerivative(); // + * double pressure, PhaseType pt){ // NumericalDerivative deriv = new NumericalDerivative(); // * System.out.println("dfugdP : " + NumericalDerivative.fugcoefDiffPres(this, phase, - * numberOfComponents, temperature, pressure, phasetype)); return + * numberOfComponents, temperature, pressure, pt)); return * NumericalDerivative.fugcoefDiffPres(this, phase, numberOfComponents, temperature, pressure, - * phasetype); } - * + * pt); } + * * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ NumericalDerivative deriv = new NumericalDerivative(); // + * double pressure, PhaseType pt){ NumericalDerivative deriv = new NumericalDerivative(); // * System.out.println("dfugdT : " + NumericalDerivative.fugcoefDiffTemp(this, phase, - * numberOfComponents, temperature, pressure, phasetype)); return + * numberOfComponents, temperature, pressure, pt)); return * NumericalDerivative.fugcoefDiffTemp(this, phase, numberOfComponents, temperature, pressure, - * phasetype); - * - * } + * pt); } */ /** diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUnifacPSRK.java b/src/main/java/neqsim/thermo/component/ComponentGEUnifacPSRK.java index 37ee6b072b..c5c421dadb 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUnifacPSRK.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUnifacPSRK.java @@ -2,6 +2,7 @@ import neqsim.thermo.phase.PhaseGEUnifac; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -22,14 +23,13 @@ public class ComponentGEUnifacPSRK extends ComponentGEUnifac { * Constructor for ComponentGEUnifacPSRK. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEUnifacPSRK(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEUnifacPSRK(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** @@ -142,7 +142,7 @@ public void calclnGammakdT(int k, PhaseInterface phase) { /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { int initType = phase.getInitType(); double lngammaCombinational = 0.0; double lngammaResidual = 0.0; diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUnifacUMRPRU.java b/src/main/java/neqsim/thermo/component/ComponentGEUnifacUMRPRU.java index 9e453f1659..b2bd488f15 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUnifacUMRPRU.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUnifacUMRPRU.java @@ -6,6 +6,7 @@ import neqsim.thermo.phase.PhaseGEUnifac; import neqsim.thermo.phase.PhaseGEUnifacUMRPRU; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -38,16 +39,15 @@ public class ComponentGEUnifacUMRPRU extends ComponentGEUnifac { * Constructor for ComponentGEUnifacUMRPRU. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEUnifacUMRPRU(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEUnifacUMRPRU(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); // System.out.println("finished reading UNIFAC "); - if (component_name.contains("_PC")) { + if (name.contains("_PC")) { double number = getMolarMass() / 0.014; int intNumb = (int) Math.round(number) - 2; unifacGroups.clear(); @@ -66,14 +66,14 @@ public ComponentGEUnifacUMRPRU(String component_name, double moles, double moles try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { java.sql.ResultSet dataSet = null; try { - dataSet = database - .getResultSet(("SELECT * FROM unifaccompumrpru WHERE Name='" + component_name + "'")); + dataSet = + database.getResultSet(("SELECT * FROM unifaccompumrpru WHERE Name='" + name + "'")); dataSet.next(); // dataSet.getClob("name"); } catch (Exception ex) { dataSet.close(); - dataSet = database - .getResultSet(("SELECT * FROM unifaccompumrpru WHERE Name='" + component_name + "'")); + dataSet = + database.getResultSet(("SELECT * FROM unifaccompumrpru WHERE Name='" + name + "'")); dataSet.next(); logger.error("Something went wrong. Closing database.", ex); } @@ -82,7 +82,7 @@ public ComponentGEUnifacUMRPRU(String component_name, double moles, double moles int temp = Integer.parseInt(dataSet.getString("sub" + Integer.toString(p))); if (temp > 0) { unifacGroups.add(new UNIFACgroup(p, temp)); - // System.out.println("compUMR " + component_name + " adding UNIFAC group " + + // System.out.println("compUMR " + name + " adding UNIFAC group " + // p); } } @@ -353,7 +353,7 @@ public void calclnGammakdTdT(int k, PhaseInterface phase) { /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { int initType = phase.getInitType(); double lngammaCombinational; double lngammaResidual; @@ -399,7 +399,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp lngamma = lngammaResidual + lngammaCombinational; if (Double.isNaN(lngamma)) { - logger.error("gamma NaN......"); + logger.warn("gamma NaN......"); lngamma = 0.0; gamma = 1.0; dlngammadt = 0; @@ -519,22 +519,22 @@ public void calcUnifacGroupParamsdT(PhaseInterface phase) { * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase */ public void calcGammaNumericalDerivatives(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { phase.setInitType(1); for (int i = 0; i < phase.getNumberOfComponents(); i++) { double dn = getNumberOfMolesInPhase() / 1e6; phase.addMoles(getComponentNumber(), dn); x = getNumberOfmoles() / getNumberOfMolesInPhase(); - getGamma(phase, numberOfComponents, temperature, pressure, phasetype); + getGamma(phase, numberOfComponents, temperature, pressure, pt); double oldGamma = lngamma; phase.addMoles(getComponentNumber(), dn); x = getNumberOfmoles() / getNumberOfMolesInPhase(); - getGamma(phase, numberOfComponents, temperature, pressure, phasetype); + getGamma(phase, numberOfComponents, temperature, pressure, pt); double dlnGammadn = (oldGamma - lngamma) / dn; // System.out.println("dlnGammadn " + dlnGammadn); diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java b/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java index 6b4a242f38..752a6746e2 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUniquac.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -30,18 +31,17 @@ public class ComponentGEUniquac extends ComponentGE { * Constructor for ComponentGEUniquac. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEUniquac(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEUniquac(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); if (!this.getClass().equals(ComponentGEUniquac.class)) { return; } - if (component_name.contains("_PC")) { + if (name.contains("_PC")) { // double number = getMolarMass() / 0.014; // int intNumb = (int) Math.round(number) - 2; r = 1.0; @@ -51,14 +51,12 @@ public ComponentGEUniquac(String component_name, double moles, double molesInPha try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { java.sql.ResultSet dataSet = null; try { - dataSet = - database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + name + "'")); dataSet.next(); dataSet.getClob("name"); } catch (Exception ex) { dataSet.close(); - dataSet = - database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM unifaccomp WHERE Name='" + name + "'")); dataSet.next(); } r = Double.parseDouble(dataSet.getString("rUNIQUAQ")); @@ -78,21 +76,20 @@ public ComponentGEUniquac(String component_name, double moles, double molesInPha * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return Fugacity coefficient */ public double fugcoef(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - fugacityCoefficient = - (this.getGamma(phase, numberOfComponents, temperature, pressure, phasetype) - * this.getAntoineVaporPressure(temperature) / pressure); + double pressure, PhaseType pt) { + fugacityCoefficient = (this.getGamma(phase, numberOfComponents, temperature, pressure, pt) + * this.getAntoineVaporPressure(temperature) / pressure); return fugacityCoefficient; } /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { return 0.0; } @@ -106,55 +103,50 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { /* * double V = 0, F = 0, a, gammaC = 0, gammaR = 0, temp1 = 0, temp2 = 0, temp3=0, temp4 = 0, * temp5=0, gamma; int j, k; - * - * + * * ComponentGEInterface[] compArray = (ComponentGEInterface[]) phase.getcomponentArray(); - * - * + * * for (j=0;j< numberOfComponents;j++){ - * + * * temp1 = temp1 + compArray[j].getx()*((ComponentGEUniquac) compArray[j]).getr(); temp2 = temp2 * + (((ComponentGEUniquac) compArray[j]).getq() * compArray[j].getx()); } - * - * + * * V = V + this.getr() / temp1; //System.out.println("V: " + V); F = F + this.getq() / temp2; * //System.out.println("F: " + F); - * + * * gammaC = 1 - V + Math.log(V) - 5 * this.getq() * (1 - V/F + Math.log(V/F)); - * + * * // System.out.println("gammaC: " + gammaC); - * + * * temp1 = 0; temp2 = 0; temp3 = 0; - * + * * for (k=0;k< numberOfComponents;k++){ temp4 = 0; temp4 = * (intparam[compArray[k].getIndex()][this.getIndex()]/temperature); temp1 = temp1 + * compArray[k].getq() * compArray[k].getx() * * Math.exp(-intparam[compArray[k].getIndex()][this.getIndex()]/temperature); temp2 = temp2 + * compArray[k].getq() * compArray[k].getx(); } - * + * * for (k=0;k< numberOfComponents;k++){ temp5 = 0; for (j=0;j< numberOfComponents;j++){ temp5 = * temp5 + compArray[j].getq() * compArray[j].getx() * - * Math.exp(-intparam[compArray[j].getIndex()][compArray[k].getIndex()]/ temperature); - * - * } - * + * Math.exp(-intparam[compArray[j].getIndex()][compArray[k].getIndex()]/ temperature); } + * * temp3 = temp3 + (compArray[k].getq() * compArray[k].getx() * Math.exp(- * intparam[this.getIndex()][compArray[k].getIndex()]/temperature)) / temp5; } - * + * * gammaR = this.getq() * (1 - Math.log(temp1/temp2) - temp3); - * + * * //System.out.println("gammaR: " + gammaR); - * + * * gamma = Math.exp(gammaR + gammaC); - * + * * //System.out.println("comp: " + this.getIndex() + " gamma NRTL : " +gamma); * //System.out.println("gamma: " + gamma); */ @@ -170,14 +162,13 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - dfugdp = (Math.log(fugcoef(phase, numberOfComponents, temperature, pressure + 0.01, phasetype)) - - Math.log(fugcoef(phase, numberOfComponents, temperature, pressure - 0.01, phasetype))) - / 0.02; + double pressure, PhaseType pt) { + dfugdp = (Math.log(fugcoef(phase, numberOfComponents, temperature, pressure + 0.01, pt)) + - Math.log(fugcoef(phase, numberOfComponents, temperature, pressure - 0.01, pt))) / 0.02; return dfugdp; } @@ -190,32 +181,29 @@ public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, doub * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - dfugdt = (Math.log(fugcoef(phase, numberOfComponents, temperature + 0.01, pressure, phasetype)) - - Math.log(fugcoef(phase, numberOfComponents, temperature - 0.01, pressure, phasetype))) - / 0.02; + double pressure, PhaseType pt) { + dfugdt = (Math.log(fugcoef(phase, numberOfComponents, temperature + 0.01, pressure, pt)) + - Math.log(fugcoef(phase, numberOfComponents, temperature - 0.01, pressure, pt))) / 0.02; return dfugdt; } /* * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ // NumericalDerivative deriv = new NumericalDerivative(); // + * double pressure, PhaseType pt){ // NumericalDerivative deriv = new NumericalDerivative(); // * System.out.println("dfugdP : " + NumericalDerivative.fugcoefDiffPres(this, phase, - * numberOfComponents, temperature, pressure, phasetype)); return + * numberOfComponents, temperature, pressure, pt)); return * NumericalDerivative.fugcoefDiffPres(this, phase, numberOfComponents, temperature, pressure, - * phasetype); } - * + * pt); } + * * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ NumericalDerivative deriv = new NumericalDerivative(); // + * double pressure, PhaseType pt){ NumericalDerivative deriv = new NumericalDerivative(); // * System.out.println("dfugdT : " + NumericalDerivative.fugcoefDiffTemp(this, phase, - * numberOfComponents, temperature, pressure, phasetype)); return + * numberOfComponents, temperature, pressure, pt)); return * NumericalDerivative.fugcoefDiffTemp(this, phase, numberOfComponents, temperature, pressure, - * phasetype); - * - * } + * pt); } */ /** diff --git a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java index 76d23e50f8..86d78508fa 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEUniquacmodifiedHV.java @@ -7,8 +7,10 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** + * Abstract class ComponentGEUniquacmodifiedHV * * @author Even Solbraa */ @@ -20,23 +22,23 @@ abstract class ComponentGEUniquacmodifiedHV extends ComponentGEUniquac { * Constructor for ComponentGEUniquacmodifiedHV. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEUniquacmodifiedHV(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEUniquacmodifiedHV(String name, double moles, double molesInPhase, + int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { // PhaseGEInterface phaseny = (PhaseGEInterface) phase.getPhase(); // PhaseGEInterface GEPhase = phaseny.getGEphase(); - return 1; // super.getGamma(GEPhase, numberOfComponents, temperature, pressure, phasetype); + return 1; // super.getGamma(GEPhase, numberOfComponents, temperature, pressure, pt); } } diff --git a/src/main/java/neqsim/thermo/component/ComponentGEWilson.java b/src/main/java/neqsim/thermo/component/ComponentGEWilson.java index 30763b2bb9..6d5aaf3455 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGEWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentGEWilson.java @@ -2,6 +2,7 @@ import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -19,14 +20,13 @@ public class ComponentGEWilson extends ComponentGE { * Constructor for ComponentGEWilson. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGEWilson(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGEWilson(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** @@ -39,14 +39,13 @@ public ComponentGEWilson(String component_name, double moles, double molesInPhas * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return Fugacity coefficient */ public double fugcoef(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { - fugacityCoefficient = - (this.getGamma(phase, numberOfComponents, temperature, pressure, phasetype) - * this.getAntoineVaporPressure(temperature) / pressure); + double pressure, PhaseType pt) { + fugacityCoefficient = (this.getGamma(phase, numberOfComponents, temperature, pressure, pt) + * this.getAntoineVaporPressure(temperature) / pressure); return fugacityCoefficient; } @@ -59,18 +58,18 @@ public double fugcoef(PhaseInterface phase, int numberOfComponents, double tempe * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double */ public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { return getWilsonActivityCoefficient(phase); } /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { return 0.0; } diff --git a/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java b/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java index b38611d6ce..e163d5cfc2 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java +++ b/src/main/java/neqsim/thermo/component/ComponentGeDuanSun.java @@ -2,6 +2,7 @@ import neqsim.thermo.phase.PhaseGE; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -23,22 +24,46 @@ public class ComponentGeDuanSun extends ComponentGE { * Constructor for ComponentGeDuanSun. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGeDuanSun(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGeDuanSun(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); + } + + /** + *+ * getGamma. + *
+ * + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param numberOfComponents a int + * @param temperature a double + * @param pressure a double + * @param pt the PhaseType of the phase + * @param HValpha an array of type double + * @param HVgij an array of type double + * @return a double + */ + public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij) { + if (componentName.equals("CO2")) { + return 0.9; + } else if (componentName.equals("water")) { + return 1.0; + } else { + return 1.0; + } } /** {@inheritDoc} */ @Override public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { - return getGamma(phase, numberOfComponents, temperature, pressure, phasetype, HValpha, HVgij); + return getGamma(phase, numberOfComponents, temperature, pressure, pt, HValpha, HVgij); } /** @@ -50,13 +75,13 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects + * @param pt the PhaseType of the phase + * @param HValpha an array of type double + * @param HVgij an array of type double * @return a double */ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij) { double type = phase.getInitType(); // double ny = 0, Djj = 0, Dii = 0, gij = 0, gjj = 0, gji = 0, gii = 0, F2T = 0, tot2 = 0; double A = 0; @@ -197,7 +222,7 @@ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double - dA6dTetter); /* * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * + * * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } */ // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + @@ -208,7 +233,7 @@ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double // dlngammadt = (lngammaold-lngamma)/0.002; // phaseny.getExcessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) + // pt) gamma = Math.exp(lngamma); // System.out.println("gamma " +gamma); // if derivates.... @@ -262,38 +287,11 @@ public double getGammaNRTL(PhaseInterface phase, int numberOfComponents, double return gamma; } - /** - *- * getGamma. - *
- * - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @param HValpha an array of {@link double} objects - * @param HVgij an array of {@link double} objects - * @return a double - */ - public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij) { - if (componentName.equals("CO2")) { - return 0.9; - } else if (componentName.equals("water")) { - return 1.0; - } else { - return 1.0; - } - } - /* * public double getHenryCoef(double temperature) { // System.out.println("henry " + // * Math.exp(henryCoefParameter[0]+henryCoefParameter[1]/temperature+ * henryCoefParameter[2]*Math.log(temperature)+henryCoefParameter[3]*temperature )*100*0.01802); - * if (componentName.equals("CO2")) { // return } return super.getHenryCoef(temperature); - * - * } + * if (componentName.equals("CO2")) { // return } return super.getHenryCoef(temperature); } */ /** {@inheritDoc} */ @@ -458,12 +456,12 @@ public double fugcoef(PhaseInterface phase) { * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @param salinity a double * @return a double */ public double getGammaPitzer(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double salinity) { + double pressure, PhaseType pt, double salinity) { double P = pressure; double T = temperature; double S = salinity; @@ -518,14 +516,14 @@ public double getGammaPitzer(PhaseInterface phase, int numberOfComponents, doubl ///////////////////////////////////////////////////// /* * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, - * temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, numberOfComponents, - * temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } - * + * double pressure, PhaseType pt){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure+0.01, pt))-Math.log(fugcoef(phase, numberOfComponents, temperature, + * pressure-0.01, pt)))/0.02; return dfugdp; } + * * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, - * temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, numberOfComponents, - * temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } + * double pressure, PhaseType pt){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, + * temperature+0.01, pressure, pt))-Math.log(fugcoef(phase, numberOfComponents, temperature-0.01, + * pressure, pt)))/0.02; return dfugdt; } */ /** diff --git a/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java b/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java index 5bff0116b8..0e64f3926d 100644 --- a/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java +++ b/src/main/java/neqsim/thermo/component/ComponentGeNRTL.java @@ -1,6 +1,7 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -22,20 +23,20 @@ public class ComponentGeNRTL extends ComponentGE { * Constructor for ComponentGeNRTL. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentGeNRTL(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentGeNRTL(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @Override @SuppressWarnings("unused") public double getGamma(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype, double[][] HValpha, double[][] HVgij, double[][] intparam, + double pressure, PhaseType pt, double[][] HValpha, double[][] HVgij, double[][] intparam, String[][] mixRule) { double type = phase.getInitType(); double A = 0; @@ -189,7 +190,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp - dA6dTetter); /* * if(w==0){ dlngammadtold = dlngammadt; temperature +=0.0001; } - * + * * if(w==1){ lngammaold = lngamma; temperature -=0.0002; } } */ // System.out.println("deriv: " + lngammaold + " " + lngamma + " " + @@ -200,7 +201,7 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp // dlngammadt = (lngammaold-lngamma)/0.002; // phaseny.getExcessGibbsEnergy(numberOfComponents, temperature, pressure, - // phasetype) + // pt) gamma = Math.exp(lngamma); // System.out.println("gamma " +gamma); // if derivates.... @@ -256,14 +257,14 @@ public double getGamma(PhaseInterface phase, int numberOfComponents, double temp /* * public double fugcoefDiffPres(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, - * temperature, pressure+0.01, phasetype))-Math.log(fugcoef(phase, numberOfComponents, - * temperature, pressure-0.01, phasetype)))/0.02; return dfugdp; } - * + * double pressure, PhaseType pt){ dfugdp = (Math.log(fugcoef(phase, numberOfComponents, + * temperature, pressure+0.01, pt))-Math.log(fugcoef(phase, numberOfComponents, temperature, + * pressure-0.01, pt)))/0.02; return dfugdp; } + * * public double fugcoefDiffTemp(PhaseInterface phase, int numberOfComponents, double temperature, - * double pressure, int phasetype){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, - * temperature+0.01, pressure, phasetype))-Math.log(fugcoef(phase, numberOfComponents, - * temperature-0.01, pressure, phasetype)))/0.02; return dfugdt; } + * double pressure, PhaseType pt){ dfugdt = (Math.log(fugcoef(phase, numberOfComponents, + * temperature+0.01, pressure, pt))-Math.log(fugcoef(phase, numberOfComponents, temperature-0.01, + * pressure, pt)))/0.02; return dfugdt; } */ /** diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrate.java b/src/main/java/neqsim/thermo/component/ComponentHydrate.java index 0ce2f812f2..d93bacf47d 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrate.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrate.java @@ -2,7 +2,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -32,8 +34,7 @@ public class ComponentHydrate extends Component { // double[] dHfHydrate = {-292714.5, -292016.0}; double[] dGfHydrate = {-235557, -235614}; double[] dHfHydrate = {-291786, -292016}; - double[] reffug = - new double[neqsim.thermo.ThermodynamicConstantsInterface.MAX_NUMBER_OF_COMPONENTS]; + double[] reffug = new double[neqsim.thermo.ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; private double sphericalCoreRadiusHydrate = 0.0; private double lennardJonesEnergyParameterHydrate = 0.0; private double lennardJonesMolecularDiameterHydrate = 0.0; @@ -44,14 +45,13 @@ public class ComponentHydrate extends Component { * Constructor for ComponentHydrate. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int - */ - public ComponentHydrate(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. + */ + public ComponentHydrate(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); coordNumb[0][0] = 20.0; coordNumb[0][1] = 24.0; cavRadius[0][0] = 3.95; @@ -73,24 +73,22 @@ public ComponentHydrate(String component_name, double moles, double molesInPhase reffug[0] = 10.0; reffug[1] = 1.0; - java.sql.ResultSet dataSet = null; - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - if (!component_name.equals("default")) { + if (!name.equals("default")) { + java.sql.ResultSet dataSet = null; + try (neqsim.util.database.NeqSimDataBase database = + new neqsim.util.database.NeqSimDataBase()) { try { if (NeqSimDataBase.createTemporaryTables()) { - dataSet = database - .getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comptemp WHERE name='" + name + "'")); } else { - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); } dataSet.next(); dataSet.getString("FORMULA"); } catch (Exception ex) { dataSet.close(); - logger.info("no parameters in tempcomp -- trying comp.. " + component_name); - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + logger.info("no parameters in tempcomp -- trying comp.. " + name); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); } lennardJonesMolecularDiameterHydrate = @@ -98,16 +96,16 @@ public ComponentHydrate(String component_name, double moles, double molesInPhase lennardJonesEnergyParameterHydrate = Double.parseDouble(dataSet.getString("LJepsHYDRATE")); sphericalCoreRadiusHydrate = Double.parseDouble(dataSet.getString("SphericalCoreRadiusHYDRATE")); - } - } catch (Exception ex) { - logger.error("error in comp", ex); - } finally { - try { - if (dataSet != null) { - dataSet.close(); - } } catch (Exception ex) { - logger.error("error closing database.....", ex); + logger.error("error in comp", ex); + } finally { + try { + if (dataSet != null) { + dataSet.close(); + } + } catch (Exception ex) { + logger.error("error closing database.....", ex); + } } } } @@ -224,8 +222,10 @@ public double getEmptyHydrateStructureVapourPressure(int type, double temperatur if (type == -1) { return getSolidVaporPressure(temperature); } else { - return Math.exp(getEmptyHydrateVapourPressureConstant(type, 0) - + getEmptyHydrateVapourPressureConstant(type, 1) / temperature) * 1.01325; + return Math + .exp(getEmptyHydrateVapourPressureConstant(type, 0) + + getEmptyHydrateVapourPressureConstant(type, 1) / temperature) + * ThermodynamicConstantsInterface.referencePressure; } } @@ -477,7 +477,7 @@ public double delt(double n, double radius, int struccture, int cavityType, * Getter for the fielddGfHydrate
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getDGfHydrate() {
return dGfHydrate;
@@ -488,7 +488,7 @@ public double[] getDGfHydrate() {
* Setter for the field dGfHydrate
.
*
*
- * @param dGfHydrate an array of {@link double} objects
+ * @param dGfHydrate an array of type double
*/
public void setDGfHydrate(double[] dGfHydrate) {
this.dGfHydrate = dGfHydrate;
@@ -508,25 +508,25 @@ public void setDGfHydrate(double dGfHydrate, int i) {
/**
*
- * Setter for the field dHfHydrate
.
+ * Getter for the field dHfHydrate
.
*
- * Getter for the field dHfHydrate
.
+ * Setter for the field dHfHydrate
.
*
dHfHydrate
.
*
*
- * @param dHfHydrate an array of {@link double} objects
+ * @param dHfHydrate an array of type double
*/
public void setDHfHydrate(double[] dHfHydrate) {
this.dHfHydrate = dHfHydrate;
@@ -657,7 +657,7 @@ public void setSolidRefFluidPhase(PhaseInterface phase) {
refPhase.setTemperature(273.0);
refPhase.setPressure(1.0);
refPhase.addComponent("water", 10.0, 10.0, 0);
- refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, 1, 1.0);
+ refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0);
} catch (Exception ex) {
logger.error("error occured", ex);
}
@@ -684,17 +684,20 @@ public void setSolidRefFluidPhase(PhaseInterface phase) {
// Math.exp(par1_struc1*Math.log(temperature)+par2_struc1/temperature+par3_struc1+par4_struc1*temperature)/1.0e5;
// }
// if(type==1){
- // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325;
+ // return
+ // Math.exp(par1_struc2+par2_struc2/temperature)*ThermodynamicConstantsInterface.referencePressure;
// } else return 0.0;
// }
// public double getEmptyHydrateStructureVapourPressure(int type, double
// temperature){
// if(type==0){
- // return Math.exp(par1_struc1+par2_struc1/temperature)*1.01325;
+ // return
+ // Math.exp(par1_struc1+par2_struc1/temperature)*ThermodynamicConstantsInterface.referencePressure;
// }
// if(type==1){
- // return Math.exp(par1_struc2+par2_struc2/temperature)*1.01325;
+ // return
+ // Math.exp(par1_struc2+par2_struc2/temperature)*ThermodynamicConstantsInterface.referencePressure;
// } else return 0.0;
// }
@@ -728,10 +731,9 @@ public double getCavprwat(int structure, int cavityType) {
* Getter for the field cavprwat
.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[][] getCavprwat() {
return cavprwat;
}
}
-
diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java b/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java
index d8df593216..ccf6890e5d 100644
--- a/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java
+++ b/src/main/java/neqsim/thermo/component/ComponentHydrateBallard.java
@@ -3,6 +3,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import neqsim.thermo.phase.PhaseInterface;
+import neqsim.thermo.phase.PhaseType;
/**
* @@ -21,14 +22,13 @@ public class ComponentHydrateBallard extends ComponentHydrate { * Constructor for ComponentHydrateBallard. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentHydrateBallard(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentHydrateBallard(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); coordNumb[0][0] = 20.0; coordNumb[0][1] = 24.0; cavRadius[0][0] = 3.908; @@ -48,20 +48,13 @@ public ComponentHydrateBallard(String component_name, double moles, double moles cavprwat[1][1] = 1.0 / 17.0; } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { if (componentName.equals("water")) { refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); double refWaterFugacity = refPhase.getComponent("water").fugcoef(refPhase) * pres; double alphaWater = reffug[getComponentNumber()]; double wateralphaRef = Math.log(refWaterFugacity / alphaWater); diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java b/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java index 652522e8da..51732ea42b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateGF.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -14,40 +15,37 @@ */ public class ComponentHydrateGF extends ComponentHydrate { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ComponentHydrateGF.class); double[][] Ak = new double[2][2]; // [structure][cavitytype] double[][] Bk = new double[2][2]; // [structure][cavitytype] - static Logger logger = LogManager.getLogger(ComponentHydrateGF.class); /** *
* Constructor for ComponentHydrateGF. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentHydrateGF(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentHydrateGF(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); java.sql.ResultSet dataSet = null; - if (!component_name.equals("default")) { + if (!name.equals("default")) { try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { // System.out.println("reading GF hydrate parameters .............."); try { - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); dataSet.getString("ID"); } catch (Exception ex) { - logger.info("no parameters in tempcomp -- trying comp.. " + component_name); + logger.info("no parameters in tempcomp -- trying comp.. " + name); dataSet.close(); - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); } Ak[0][0] = Double.parseDouble(dataSet.getString("A1_SmallGF")); @@ -72,13 +70,6 @@ public ComponentHydrateGF(String component_name, double moles, double molesInPha } } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { @@ -94,7 +85,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); double refWaterFugacityCoef = Math.log(refPhase.getComponent("water").fugcoef(refPhase)); double dhf = 6010.0; @@ -143,7 +134,6 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub * (getEmptyHydrateStructureVapourPressure(hydrateStructure, temp) * Math.exp(solvol / (R * * temp) * (pres - getEmptyHydrateStructureVapourPressure(hydrateStructure, temp)) * * 1e5))); - * */ // System.out.println("pointing " // +(Math.exp(solvol/(R*temp)*((pres-getEmptyHydrateStructureVapourPressure(hydrateStruct,temp))*1e5)))); diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java b/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java index 4cd86beda9..be9c652bd1 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateKluda.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; /** @@ -14,6 +15,7 @@ */ public class ComponentHydrateKluda extends Component { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ComponentHydrateKluda.class); double par1_struc1 = 17.44; double par2_struc1 = -6003.9; @@ -25,21 +27,19 @@ public class ComponentHydrateKluda extends Component { double[][] cavNumb = new double[2][2]; // [structure][cavitytype] double[][] cavprwat = new double[2][2]; // [structure][cavitytype] double[] reffug = new double[20]; - static Logger logger = LogManager.getLogger(ComponentHydrateKluda.class); /** ** Constructor for ComponentHydrateKluda. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentHydrateKluda(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentHydrateKluda(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); coordNumb[0][0][0] = 20.0; coordNumb[0][0][1] = 24.0; cavRadius[0][0][0] = 3.906; @@ -67,13 +67,6 @@ public ComponentHydrateKluda(String component_name, double moles, double molesIn cavprwat[1][1] = 1.0 / 17.0; } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - /** ** Calculate, set and return fugacity coefficient. @@ -178,7 +171,8 @@ public double getEmptyHydrateStructureVapourPressure(int type, double temperatur + par4_struc1 * temperature) / 1.0e5; } if (type == 1) { - return Math.exp(par1_struc2 + par2_struc2 / temperature) * 1.01325; + return Math.exp(par1_struc2 + par2_struc2 / temperature) + * ThermodynamicConstantsInterface.referencePressure; } else { return 0.0; } diff --git a/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java b/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java index c5f4a5a4ea..df26d9e1f8 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydratePVTsim.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -25,35 +26,31 @@ public class ComponentHydratePVTsim extends ComponentHydrate { * Constructor for ComponentHydratePVTsim. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentHydratePVTsim(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentHydratePVTsim(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); java.sql.ResultSet dataSet = null; - if (!component_name.equals("default")) { + if (!name.equals("default")) { try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { logger.info("reading hydrate parameters .............."); try { if (NeqSimDataBase.createTemporaryTables()) { - dataSet = database - .getResultSet(("SELECT * FROM comptemp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comptemp WHERE name='" + name + "'")); } else { - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); } dataSet.next(); } catch (Exception ex) { dataSet.close(); - logger.info("no parameters in tempcomp -- trying comp.. " + component_name); - dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + component_name + "'")); + logger.info("no parameters in tempcomp -- trying comp.. " + name); + dataSet = database.getResultSet(("SELECT * FROM comp WHERE name='" + name + "'")); dataSet.next(); } Ak[0][0] = Double.parseDouble(dataSet.getString("HydrateA1Small")); @@ -71,19 +68,12 @@ public ComponentHydratePVTsim(String component_name, double moles, double molesI try { dataSet.close(); } catch (Exception ex2) { - logger.error("error closing comp hydrate database....." + component_name); + logger.error("error closing comp hydrate database....." + name); } } } } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { @@ -95,7 +85,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub stableStructure = -1; refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); double refWaterFugacityCoef = Math.log(refPhase.getComponent("water").fugcoef(refPhase)); @@ -125,7 +115,7 @@ public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, doub if (componentName.equals("water")) { refPhase.setTemperature(temp); refPhase.setPressure(pres); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 3, PhaseType.byValue(0), 1.0); double refWaterFugacity = refPhase.getComponent("water").fugcoef(refPhase) * pres; diff --git a/src/main/java/neqsim/thermo/component/ComponentHydrateStatoil.java b/src/main/java/neqsim/thermo/component/ComponentHydrateStatoil.java index d07fa2f956..3715194981 100644 --- a/src/main/java/neqsim/thermo/component/ComponentHydrateStatoil.java +++ b/src/main/java/neqsim/thermo/component/ComponentHydrateStatoil.java @@ -26,14 +26,13 @@ public class ComponentHydrateStatoil extends ComponentHydrate { * Constructor for ComponentHydrateStatoil. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentHydrateStatoil(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentHydrateStatoil(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); coordNumb[0][0] = 20.0; coordNumb[0][1] = 24.0; cavRadius[0][0] = 3.95; @@ -53,13 +52,6 @@ public ComponentHydrateStatoil(String component_name, double moles, double moles cavprwat[1][1] = 1.0 / 17.0; } - /** {@inheritDoc} */ - @Override - public double fugcoef(PhaseInterface phase) { - return fugcoef(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure()); - } - /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase, int numberOfComps, double temp, double pres) { diff --git a/src/main/java/neqsim/thermo/component/ComponentInterface.java b/src/main/java/neqsim/thermo/component/ComponentInterface.java index 52b31d65c6..ded1f2c0da 100644 --- a/src/main/java/neqsim/thermo/component/ComponentInterface.java +++ b/src/main/java/neqsim/thermo/component/ComponentInterface.java @@ -26,13 +26,12 @@ public interface ComponentInterface extends ThermodynamicConstantsInterface, Clo * Helper function to create component. Typically called from constructors. * * - * @param component_name Name of component. + * @param name Name of component. * @param moles Total number of moles of component in system. * @param molesInPhase Number of moles in phase. - * @param compnumber Index number of component in phase object component array. + * @param compIndex Index number of component in phase object component array. */ - public void createComponent(String component_name, double moles, double molesInPhase, - int compnumber); + public void createComponent(String name, double moles, double molesInPhase, int compIndex); /** *@@ -536,7 +535,7 @@ public double fugcoefDiffTempNumeric(PhaseInterface phase, int numberOfComponent *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return an array of {@link double} objects + * @return an array of type double */ public double[] logfugcoefdN(PhaseInterface phase); @@ -605,19 +604,6 @@ public double fugcoefDiffTempNumeric(PhaseInterface phase, int numberOfComponent */ public double getTriplePointDensity(); - /** - *- * getTripplePointDensity. - *
- * - * @return a double - * @deprecated Replaced by {@link getTriplePointDensity} - */ - @Deprecated - public default double getTripplePointDensity() { - return getTriplePointDensity(); - } - /** ** getCriticalCompressibilityFactor. @@ -645,6 +631,16 @@ public default double getTripplePointDensity() { */ public void setMolarMass(double molarMass); + /** + *
+ * setMolarMass. + *
+ * + * @param molarMass a double + * @param unit a String + */ + public void setMolarMass(double molarMass, String unit); + /** ** calcActivity. @@ -766,25 +762,21 @@ public default void addMolesChemReac(double dn) { /** *
- * getIdealGasGibsEnergyOfFormation. + * getIdealGasGibbsEnergyOfFormation. *
* * @return a double - * @deprecated Replaced by {@link getIdealGasGibbsEnergyOfFormation} */ - @Deprecated - public default double getIdealGasGibsEnergyOfFormation() { - return getIdealGasGibbsEnergyOfFormation(); - } + public double getIdealGasGibbsEnergyOfFormation(); /** *- * getIdealGasGibsEnergyOfFormation. + * setTC. *
* - * @return a double + * @param val a double */ - public double getIdealGasGibbsEnergyOfFormation(); + public void setTC(double val); /** *@@ -792,8 +784,9 @@ public default double getIdealGasGibsEnergyOfFormation() { *
* * @param val a double + * @param unit a String */ - public void setTC(double val); + public void setTC(double val, String unit); /** *@@ -804,6 +797,16 @@ public default double getIdealGasGibsEnergyOfFormation() { */ public void setPC(double val); + /** + *
+ * setPC. + *
+ * + * @param val a double + * @param unit a String + */ + public void setPC(double val, String unit); + /** *
* getDiElectricConstantdTdT.
@@ -842,10 +845,11 @@ public default double getIdealGasGibsEnergyOfFormation() {
* @param pressure Pressure in unit ?. Used to calculate K
.
* @param totalNumberOfMoles Total number of moles of component.
* @param beta Beta value, i.e.,
- * @param type Init type. Calculate K
, z
, x
if type == 0.
+ * @param initType Init type. Calculate K
, z
, x
if type ==
+ * 0.
*/
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
- int type);
+ int initType);
/**
*
@@ -858,10 +862,10 @@ public void init(double temperature, double pressure, double totalNumberOfMoles, * @param totalNumberOfMoles a double * @param beta a double * @param numberOfComponents a int - * @param type a int + * @param initType a int */ public void Finit(PhaseInterface phase, double temperature, double pressure, - double totalNumberOfMoles, double beta, int numberOfComponents, int type); + double totalNumberOfMoles, double beta, int numberOfComponents, int initType); /** *
@@ -898,37 +902,68 @@ public void Finit(PhaseInterface phase, double temperature, double pressure, * Returns the critical temperature of the component. *
* - * @return The critical temperature of the component. + * @return The critical temperature of the component */ public double getTC(); + /** + *+ * Returns the critical temperature of the component. + *
+ * + * @param unit Unit of return temperature + * @return The critical temperature of the component + */ + public double getTC(String unit); + /** ** Getter for property NormalBoilingPoint. *
* - * @return The normal boiling point of the component. + * @return The normal boiling point of the component with unit Kelvin */ public double getNormalBoilingPoint(); + /** + *+ * Getter for property NormalBoilingPoint. + *
+ * + * @param unit Unit of return pressure + * + * @return The normal boiling point of the component + */ + public double getNormalBoilingPoint(String unit); + /** ** setNormalBoilingPoint. *
* - * @param normalBoilingPoint a double + * @param normalBoilingPoint a double with unit Kelvin */ public void setNormalBoilingPoint(double normalBoilingPoint); /** *- * getPC. + * Returns the critical pressure of the component. *
* - * @return a double + * @return The critical pressure of the component */ public double getPC(); + /** + *+ * Returns the critical pressure of the component. + *
+ * + * @param unit Unit of return pressure + * @return The critical pressure of the component + */ + public double getPC(String unit); + /** ** setViscosityAssociationFactor. @@ -985,6 +1020,16 @@ public void Finit(PhaseInterface phase, double temperature, double pressure, */ public double getNormalLiquidDensity(); + /** + *
+ * getNormalLiquidDensity. + *
+ * + * @param unit i String with unit of return return a double + * @return a double + */ + public double getNormalLiquidDensity(String unit); + /** *
* Getter for property componentName
.
@@ -1229,6 +1274,14 @@ public default double getLogFugacityCoefficient() {
*/
public double getMolarMass();
+ /**
+ * Get molar mass of component.
+ *
+ * @param unit a String
+ * @return molar mass in unit kg/mol
+ */
+ public double getMolarMass(String unit);
+
/**
*
* getLennardJonesMolecularDiameter. @@ -1442,7 +1495,7 @@ public default double getLogFugacityCoefficient() { /** *
- * getName.
+ * Getter for property componentName
, i.e., normalized component name.
*
solidCheck
.
*
*
- * @param checkForSolids Set true to check for solid phase and do solid phase calculations.
+ * @param checkForSolids Set true to do solid phase check and calculations
*/
public void setSolidCheck(boolean checkForSolids);
@@ -1939,7 +1992,7 @@ public default double getLogFugacityCoefficient() {
* getHenryCoefParameter.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getHenryCoefParameter();
@@ -1948,7 +2001,7 @@ public default double getLogFugacityCoefficient() {
* setHenryCoefParameter.
*
*
- * @param henryCoefParameter an array of {@link double} objects
+ * @param henryCoefParameter an array of type double
*/
public void setHenryCoefParameter(double[] henryCoefParameter);
@@ -1978,7 +2031,7 @@ public default double getLogFugacityCoefficient() {
* getMatiascopemanSolidParams.
*
*
- * @return an array of {@link double} objects
+ * @return an array of type double
*/
public double[] getMatiascopemanSolidParams();
diff --git a/src/main/java/neqsim/thermo/component/ComponentKentEisenberg.java b/src/main/java/neqsim/thermo/component/ComponentKentEisenberg.java
index 1822885f22..a80f5c84a0 100644
--- a/src/main/java/neqsim/thermo/component/ComponentKentEisenberg.java
+++ b/src/main/java/neqsim/thermo/component/ComponentKentEisenberg.java
@@ -18,14 +18,13 @@ public class ComponentKentEisenberg extends ComponentGeNRTL {
* Constructor for ComponentKentEisenberg.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
*/
- public ComponentKentEisenberg(String component_name, double moles, double molesInPhase,
- int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ public ComponentKentEisenberg(String name, double moles, double molesInPhase, int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
}
/** {@inheritDoc} */
diff --git a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java
index a540514c71..c78ab76363 100644
--- a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java
+++ b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEos.java
@@ -69,20 +69,21 @@ public class ComponentModifiedFurstElectrolyteEos extends ComponentSrk {
* Constructor for ComponentModifiedFurstElectrolyteEos.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
- */
- public ComponentModifiedFurstElectrolyteEos(String component_name, double moles,
- double molesInPhase, int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
+ */
+ public ComponentModifiedFurstElectrolyteEos(String name, double moles, double molesInPhase,
+ int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
ionicCoVolume = this.getIonicDiameter();
if (ionicCharge != 0) {
setIsIon(true);
}
- b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
- * Math.pow(getIonicDiameter(), 3.0)
+ b = ionicCharge != 0
+ ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
+ * Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
a = ionicCharge != 0 ? 1.0e-35 : a;
@@ -118,8 +119,9 @@ public ComponentModifiedFurstElectrolyteEos(int number, double TC, double PC, do
*
*/
public void initFurstParam() {
- b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
- * Math.pow(getIonicDiameter(), 3.0)
+ b = ionicCharge != 0
+ ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
+ * Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
lennardJonesMolecularDiameter =
@@ -163,7 +165,7 @@ public double calcb() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
- int numberOfComponents, int type) {
+ int numberOfComponents, int initType) {
Wi = ((PhaseModifiedFurstElectrolyteEos) phase).calcWi(componentNumber, phase, temp, pres,
numberOfComponents);
WiT = ((PhaseModifiedFurstElectrolyteEos) phase).calcWiT(componentNumber, phase, temp, pres,
@@ -209,7 +211,7 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
if (getLennardJonesMolecularDiameter() > 0) {
XBorni = ionicCharge * ionicCharge / (getLennardJonesMolecularDiameter() * 1e-10);
}
- super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
+ super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
}
/**
diff --git a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java
index d01d9cd8c2..077727cad0 100644
--- a/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java
+++ b/src/main/java/neqsim/thermo/component/ComponentModifiedFurstElectrolyteEosMod2004.java
@@ -69,20 +69,21 @@ public class ComponentModifiedFurstElectrolyteEosMod2004 extends ComponentSrk {
* Constructor for ComponentModifiedFurstElectrolyteEosMod2004.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
- */
- public ComponentModifiedFurstElectrolyteEosMod2004(String component_name, double moles,
- double molesInPhase, int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
+ */
+ public ComponentModifiedFurstElectrolyteEosMod2004(String name, double moles, double molesInPhase,
+ int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
ionicCoVolume = this.getIonicDiameter();
if (ionicCharge != 0) {
setIsIon(true);
}
- b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
- * Math.pow(getIonicDiameter(), 3.0)
+ b = ionicCharge != 0
+ ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
+ * Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
a = ionicCharge != 0 ? 1.0e-35 : a;
@@ -118,8 +119,9 @@ public ComponentModifiedFurstElectrolyteEosMod2004(int number, double TC, double
*
*/
public void initFurstParam() {
- b = ionicCharge != 0 ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
- * Math.pow(getIonicDiameter(), 3.0)
+ b = ionicCharge != 0
+ ? (neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[0]
+ * Math.pow(getIonicDiameter(), 3.0)
+ neqsim.thermo.util.constants.FurstElectrolyteConstants.furstParams[1]) * 1e5
: b;
lennardJonesMolecularDiameter =
@@ -155,7 +157,7 @@ public double calcb() {
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
- int numberOfComponents, int type) {
+ int numberOfComponents, int initType) {
Wi = ((PhaseModifiedFurstElectrolyteEosMod2004) phase).calcWi(componentNumber, phase, temp,
pres, numberOfComponents);
WiT = ((PhaseModifiedFurstElectrolyteEosMod2004) phase).calcWiT(componentNumber, phase, temp,
@@ -183,7 +185,8 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 2.0)
* R * temp * temp)
* diElectricdn
- + 2.0 * electronCharge * electronCharge * avagadroNumber / (vacumPermittivity
+ + 2.0 * electronCharge * electronCharge * avagadroNumber
+ / (vacumPermittivity
* Math.pow(
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 3.0)
* R * temp)
@@ -194,7 +197,8 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
.pow(((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 2.0) * R
* temp)
* diElectricdndV
- + 2.0 * electronCharge * electronCharge * avagadroNumber / (vacumPermittivity
+ + 2.0 * electronCharge * electronCharge * avagadroNumber
+ / (vacumPermittivity
* Math.pow(
((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstant(), 3.0)
* R * temp)
@@ -202,7 +206,7 @@ public void Finit(PhaseInterface phase, double temp, double pres, double totMole
* ((PhaseModifiedFurstElectrolyteEosMod2004) phase).getDiElectricConstantdV();
XLRi = calcXLRdN(phase, numberOfComponents, temp, pres);
XBorni = ionicCharge * ionicCharge / (getLennardJonesMolecularDiameter() * 1e-10);
- super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
+ super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
}
/**
diff --git a/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java b/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java
index dcc35032ba..17fb6c4dc1 100644
--- a/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java
+++ b/src/main/java/neqsim/thermo/component/ComponentPCSAFT.java
@@ -38,13 +38,13 @@ public class ComponentPCSAFT extends ComponentSrk {
* Constructor for ComponentPCSAFT.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
*/
- public ComponentPCSAFT(String component_name, double moles, double molesInPhase, int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ public ComponentPCSAFT(String name, double moles, double molesInPhase, int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
}
/**
@@ -79,16 +79,16 @@ public ComponentPCSAFT clone() {
/** {@inheritDoc} */
@Override
public void init(double temperature, double pressure, double totalNumberOfMoles, double beta,
- int type) {
+ int initType) {
setdSAFTi(getSigmaSAFTi() * (1.0 - 0.12 * Math.exp(-3.0 * getEpsikSAFT() / temperature)));
- super.init(temperature, pressure, totalNumberOfMoles, beta, type);
+ super.init(temperature, pressure, totalNumberOfMoles, beta, initType);
}
/** {@inheritDoc} */
@Override
public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta,
- int numberOfComponents, int type) {
- super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type);
+ int numberOfComponents, int initType) {
+ super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType);
setDnSAFTdi(calcdnSAFTdi(phase, numberOfComponents, temp, pres));
setDghsSAFTdi(calcdghsSAFTdi(phase, numberOfComponents, temp, pres));
setDlogghsSAFTdi(1.0 / ((PhasePCSAFT) phase).getGhsSAFT() * getDghsSAFTdi());
diff --git a/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java b/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java
index 70317e4cc4..370db747b4 100644
--- a/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java
+++ b/src/main/java/neqsim/thermo/component/ComponentPCSAFTa.java
@@ -26,14 +26,13 @@ public class ComponentPCSAFTa extends ComponentPCSAFT implements ComponentCPAInt
* Constructor for ComponentPCSAFTa.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
*/
- public ComponentPCSAFTa(String component_name, double moles, double molesInPhase,
- int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ public ComponentPCSAFTa(String name, double moles, double molesInPhase, int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
xsite = new double[numberOfAssociationSites];
xsitedV = new double[numberOfAssociationSites];
xsiteOld = new double[numberOfAssociationSites];
@@ -281,7 +280,7 @@ public double[] getXsiteOld() {
/**
* Setter for property xsite.
*
- * @param xsiteOld an array of {@link double} objects
+ * @param xsiteOld an array of type double
*/
public void setXsiteOld(double[] xsiteOld) {
this.xsiteOld = xsiteOld;
diff --git a/src/main/java/neqsim/thermo/component/ComponentPR.java b/src/main/java/neqsim/thermo/component/ComponentPR.java
index e59c2f7f17..239f4d2b2a 100644
--- a/src/main/java/neqsim/thermo/component/ComponentPR.java
+++ b/src/main/java/neqsim/thermo/component/ComponentPR.java
@@ -18,13 +18,13 @@ public class ComponentPR extends ComponentEos {
* Constructor for ComponentPR.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
*/
- public ComponentPR(String component_name, double moles, double molesInPhase, int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ public ComponentPR(String name, double moles, double molesInPhase, int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
a = .45724333333 * R * R * criticalTemperature * criticalTemperature / criticalPressure;
b = .077803333 * R * criticalTemperature / criticalPressure;
diff --git a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
index df3135d20f..b4abaf4883 100644
--- a/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
+++ b/src/main/java/neqsim/thermo/component/ComponentPRvolcor.java
@@ -6,6 +6,7 @@
package neqsim.thermo.component;
+import neqsim.thermo.ThermodynamicModelSettings;
import neqsim.thermo.phase.PhaseInterface;
import neqsim.thermo.phase.PhasePrEosvolcor;
@@ -21,7 +22,7 @@ public class ComponentPRvolcor extends ComponentPR {
private static final long serialVersionUID = 1000;
private double c;
// private double calcc;
- public double[] Cij = new double[MAX_NUMBER_OF_COMPONENTS];
+ public double[] Cij = new double[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
public double Ci = 0;
/**
@@ -83,27 +84,31 @@ public double calccTT() {
* Constructor for ComponentPRvolcor.
*
*
- * @param component_name a {@link java.lang.String} object
- * @param moles a double
- * @param molesInPhase a double
- * @param compnumber a int
+ * @param name Name of component.
+ * @param moles Total number of moles of component.
+ * @param molesInPhase Number of moles in phase.
+ * @param compIndex Index number of component in phase object component array.
*/
- public ComponentPRvolcor(String component_name, double moles, double molesInPhase,
- int compnumber) {
- super(component_name, moles, molesInPhase, compnumber);
+ public ComponentPRvolcor(String name, double moles, double molesInPhase, int compIndex) {
+ super(name, moles, molesInPhase, compIndex);
c = (0.1154 - 0.4406 * (0.29056 - 0.08775 * getAcentricFactor())) * R * criticalTemperature
/ criticalPressure;
-
}
/** {@inheritDoc} */
@Override
- public void init(double temp, double pres, double totMoles, double beta, int type) {
- super.init(temp, pres, totMoles, beta, type);
+ public void init(double temp, double pres, double totMoles, double beta, int initType) {
+ super.init(temp, pres, totMoles, beta, initType);
c = calcc();
}
- /** {@inheritDoc} */
+ /**
+ * + * getc. + *
+ * + * @return a double + */ public double getc() { return c; } @@ -123,14 +128,14 @@ public double getcT() { /** {@inheritDoc} */ @Override public void Finit(PhaseInterface phase, double temp, double pres, double totMoles, double beta, - int numberOfComponents, int type) { - super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, type); + int numberOfComponents, int initType) { + super.Finit(phase, temp, pres, totMoles, beta, numberOfComponents, initType); Ci = ((PhasePrEosvolcor) phase).calcCi(componentNumber, phase, temp, pres, numberOfComponents); - if (type >= 2) { + if (initType >= 2) { ((PhasePrEosvolcor) phase).calcCiT(componentNumber, phase, temp, pres, numberOfComponents); } - if (type >= 3) { + if (initType >= 3) { for (int j = 0; j < numberOfComponents; j++) { Cij[j] = ((PhasePrEosvolcor) phase).calcCij(componentNumber, j, phase, temp, pres, numberOfComponents); diff --git a/src/main/java/neqsim/thermo/component/ComponentPrCPA.java b/src/main/java/neqsim/thermo/component/ComponentPrCPA.java index d4f5851575..2f42683da4 100644 --- a/src/main/java/neqsim/thermo/component/ComponentPrCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentPrCPA.java @@ -4,6 +4,7 @@ import neqsim.thermo.phase.PhaseInterface; /** + * Abstract class ComponentPrCPA. * * @author Even Solbraa */ @@ -18,13 +19,13 @@ abstract class ComponentPrCPA extends ComponentPR implements ComponentCPAInterfa * Constructor for ComponentPrCPA. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentPrCPA(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentPrCPA(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); xsite = new double[numberOfAssociationSites]; if ((numberOfAssociationSites != 0 || Math.abs(aCPA) > 1e-6) && cpaon == 1) { // System.out.println("ass sites: " + numberOfAssociationSites); diff --git a/src/main/java/neqsim/thermo/component/ComponentRK.java b/src/main/java/neqsim/thermo/component/ComponentRK.java index 3e29d03359..c6a1f46ac0 100644 --- a/src/main/java/neqsim/thermo/component/ComponentRK.java +++ b/src/main/java/neqsim/thermo/component/ComponentRK.java @@ -18,13 +18,13 @@ public class ComponentRK extends ComponentEos { * Constructor for ComponentRK. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentRK(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentRK(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); a = 1.0 / (9.0 * (Math.pow(2.0, 1.0 / 3.0) - 1.0)) * R * R * criticalTemperature * criticalTemperature / criticalPressure; diff --git a/src/main/java/neqsim/thermo/component/ComponentSolid.java b/src/main/java/neqsim/thermo/component/ComponentSolid.java index 16c10f2e91..daf1c3d071 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSolid.java +++ b/src/main/java/neqsim/thermo/component/ComponentSolid.java @@ -7,6 +7,8 @@ package neqsim.thermo.component; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; +import neqsim.util.database.NeqSimDataBase; /** *@@ -35,13 +37,13 @@ public class ComponentSolid extends ComponentSrk { * Constructor for ComponentSolid. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentSolid(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentSolid(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** @@ -108,7 +110,7 @@ public double fugcoef(double temp, double pres) { refPhase.setTemperature(temp); refPhase.setPressure(PvapSolid); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 1, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(1), 1.0); refPhase.getComponent(0).fugcoef(refPhase); // System.out.println("ref co2 fugcoef " + @@ -138,7 +140,11 @@ public double fugcoef(double temp, double pres) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + try { + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); + } catch (Exception ex) { + logger.error(ex.getMessage()); + } refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = @@ -229,22 +235,28 @@ public double getMolarVolumeSolid() { */ public void setSolidRefFluidPhase(PhaseInterface phase) { try { - if ((!isTBPfraction && !isPlusFraction) - || neqsim.util.database.NeqSimDataBase.createTemporaryTables()) { - refPhase = phase.getClass().getDeclaredConstructor().newInstance(); - refPhase.setTemperature(273.0); - refPhase.setPressure(1.0); - try { + // if ((!isTBPfraction && !isPlusFraction) + // || neqsim.util.database.NeqSimDataBase.createTemporaryTables()) { + refPhase = phase.getClass().getDeclaredConstructor().newInstance(); + refPhase.setTemperature(273.0); + refPhase.setPressure(1.0); + try { + if (NeqSimDataBase.hasComponent(componentName) + || NeqSimDataBase.hasTempComponent(componentName)) { refPhase.addComponent(componentName, 10.0, 10.0, 0); - } catch (Exception ex) { - logger.error("error occured in setSolidRefFluidPhase ", ex); + } else { refPhase.addComponent("methane", 10.0, 10.0, 0); refPhase.getComponent("methane").setComponentName(componentName); } - refPhase.getComponent(componentName) - .setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, 1, 1.0); + } catch (Exception ex) { + logger.error("error occured in setSolidRefFluidPhase ", ex); + refPhase.addComponent("methane", 10.0, 10.0, 0); + refPhase.getComponent("methane").setComponentName(componentName); } + refPhase.getComponent(componentName) + .setAttractiveTerm(phase.getComponent(componentName).getAttractiveTermNumber()); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 0, PhaseType.byValue(1), 1.0); + // } } catch (Exception ex) { logger.error("error occured", ex); } diff --git a/src/main/java/neqsim/thermo/component/ComponentSrk.java b/src/main/java/neqsim/thermo/component/ComponentSrk.java index 873e8a2e14..691123b0a6 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSrk.java +++ b/src/main/java/neqsim/thermo/component/ComponentSrk.java @@ -21,13 +21,13 @@ public class ComponentSrk extends ComponentEos { * Constructor for ComponentSrk. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentSrk(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentSrk(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); a = 1.0 / (9.0 * (Math.pow(2.0, 1.0 / 3.0) - 1.0)) * R * R * criticalTemperature * criticalTemperature / criticalPressure; diff --git a/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java b/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java index dcaf814cd9..37649b61d7 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentSrkCPA.java @@ -28,13 +28,13 @@ public class ComponentSrkCPA extends ComponentSrk implements ComponentCPAInterfa * Constructor for ComponentSrkCPA. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentSrkCPA(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentSrkCPA(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); xsite = new double[numberOfAssociationSites]; xsitedni = new double[numberOfAssociationSites][100]; xsitedV = new double[numberOfAssociationSites]; @@ -505,7 +505,6 @@ public double calc_lngij(int j, PhaseInterface phase) { + ((ComponentEosInterface) phase.getComponent(j)).getBi() * temp3 * (temp1 + temp2)) / temp1 / temp1 / temp2 / temp2; return 2.0 * (getBij(j) * temp + getBi() * tempj); - } /** {@inheritDoc} */ @@ -574,7 +573,7 @@ public double[] getXsiteOld() { /** * Setter for property xsite. * - * @param xsiteOld an array of {@link double} objects + * @param xsiteOld an array of type double */ public void setXsiteOld(double[] xsiteOld) { this.xsiteOld = xsiteOld; diff --git a/src/main/java/neqsim/thermo/component/ComponentSrkCPAs.java b/src/main/java/neqsim/thermo/component/ComponentSrkCPAs.java index 88283a02a6..7c4f380d00 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSrkCPAs.java +++ b/src/main/java/neqsim/thermo/component/ComponentSrkCPAs.java @@ -18,14 +18,13 @@ public class ComponentSrkCPAs extends ComponentSrkCPA { * Constructor for ComponentSrkCPAs. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentSrkCPAs(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentSrkCPAs(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** diff --git a/src/main/java/neqsim/thermo/component/ComponentSrkPeneloux.java b/src/main/java/neqsim/thermo/component/ComponentSrkPeneloux.java index c9c98f54f6..7fb974526f 100644 --- a/src/main/java/neqsim/thermo/component/ComponentSrkPeneloux.java +++ b/src/main/java/neqsim/thermo/component/ComponentSrkPeneloux.java @@ -20,14 +20,13 @@ public class ComponentSrkPeneloux extends ComponentSrk { * Constructor for ComponentSrkPeneloux. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentSrkPeneloux(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentSrkPeneloux(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); a = 1.0 / (9.0 * (Math.pow(2.0, 1.0 / 3.0) - 1.0)) * R * R * criticalTemperature * criticalTemperature / criticalPressure; diff --git a/src/main/java/neqsim/thermo/component/ComponentTST.java b/src/main/java/neqsim/thermo/component/ComponentTST.java index 77d5466385..769b5abc34 100644 --- a/src/main/java/neqsim/thermo/component/ComponentTST.java +++ b/src/main/java/neqsim/thermo/component/ComponentTST.java @@ -18,13 +18,13 @@ public class ComponentTST extends ComponentEos { * Constructor for ComponentTST. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentTST(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentTST(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); a = 0.427481 * R * R * criticalTemperature * criticalTemperature / criticalPressure; b = .086641 * R * criticalTemperature / criticalPressure; diff --git a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java index 05c9b9e196..84c59ec625 100644 --- a/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java +++ b/src/main/java/neqsim/thermo/component/ComponentUMRCPA.java @@ -28,13 +28,13 @@ public class ComponentUMRCPA extends ComponentPR implements ComponentCPAInterfac * Constructor for ComponentSrkCPA. * * - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentUMRCPA(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentUMRCPA(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); xsite = new double[numberOfAssociationSites]; xsitedni = new double[numberOfAssociationSites][100]; xsitedV = new double[numberOfAssociationSites]; @@ -102,9 +102,8 @@ public ComponentUMRCPA(int number, double TC, double PC, double M, double a, dou /** {@inheritDoc} */ @Override - public void createComponent(String component_name, double moles, double molesInPhase, - int compnumber) { - super.createComponent(component_name, moles, molesInPhase, compnumber); + public void createComponent(String name, double moles, double molesInPhase, int compIndex) { + super.createComponent(name, moles, molesInPhase, compIndex); // criticalTemperature = 305.4; // criticalPressure = 135.62; // acentricFactor = 0.1609; @@ -576,7 +575,7 @@ public double[] getXsiteOld() { /** * Setter for property xsite. * - * @param xsiteOld an array of {@link double} objects + * @param xsiteOld an array of type double */ public void setXsiteOld(double[] xsiteOld) { this.xsiteOld = xsiteOld; diff --git a/src/main/java/neqsim/thermo/component/ComponentWax.java b/src/main/java/neqsim/thermo/component/ComponentWax.java index c30d2dff22..7f37d81e8b 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWax.java @@ -1,12 +1,9 @@ -/* - * SolidComponent.java - * - * Created on 18. august 2001, 12:45 - */ - package neqsim.thermo.component; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -18,19 +15,20 @@ */ public class ComponentWax extends ComponentSolid { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ComponentWax.class); /** *
* Constructor for ComponentWax. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentWax(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentWax(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @@ -54,7 +52,7 @@ public double fugcoef2(PhaseInterface phase1) { logger.error(ex.getMessage(), ex); } refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java index 5a7948be9d..a1b79e5702 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java +++ b/src/main/java/neqsim/thermo/component/ComponentWaxWilson.java @@ -1,7 +1,10 @@ package neqsim.thermo.component; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -13,23 +16,23 @@ */ public class ComponentWaxWilson extends ComponentSolid { private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(ComponentWaxWilson.class); /** *
* Constructor for ComponentWaxWilson. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentWaxWilson(String component_name, double moles, double molesInPhase, - int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentWaxWilson(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } - /** * {@inheritDoc} */ + /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase1) { if (!isWaxFormer()) { @@ -45,7 +48,7 @@ public double fugcoef(PhaseInterface phase1) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/component/ComponentWonWax.java b/src/main/java/neqsim/thermo/component/ComponentWonWax.java index 74bfcaa1f5..0b46ae5c61 100644 --- a/src/main/java/neqsim/thermo/component/ComponentWonWax.java +++ b/src/main/java/neqsim/thermo/component/ComponentWonWax.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *@@ -21,20 +22,21 @@ public class ComponentWonWax extends ComponentSolid { * Constructor for ComponentWonWax. *
* - * @param component_name a {@link java.lang.String} object - * @param moles a double - * @param molesInPhase a double - * @param compnumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public ComponentWonWax(String component_name, double moles, double molesInPhase, int compnumber) { - super(component_name, moles, molesInPhase, compnumber); + public ComponentWonWax(String name, double moles, double molesInPhase, int compIndex) { + super(name, moles, molesInPhase, compIndex); } /** {@inheritDoc} */ @Override public double fugcoef(PhaseInterface phase1) { if (!isWaxFormer()) { - return 1.0e30; + fugacityCoefficient = 1.0e30; + return fugacityCoefficient; } return fugcoef2(phase1); @@ -45,7 +47,7 @@ public double fugcoef(PhaseInterface phase1) { public double fugcoef2(PhaseInterface phase1) { refPhase.setTemperature(phase1.getTemperature()); refPhase.setPressure(phase1.getPressure()); - refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, 0, 1.0); + refPhase.init(refPhase.getNumberOfMolesInPhase(), 1, 1, PhaseType.byValue(0), 1.0); refPhase.getComponent(0).fugcoef(refPhase); double liquidPhaseFugacity = diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java index 13e126c281..d2acf67d07 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AtractiveTermMatCopPRUMRNew.java @@ -36,7 +36,7 @@ public AtractiveTermMatCopPRUMRNew(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AtractiveTermMatCopPRUMRNew(ComponentEosInterface component, double[] params) { this(component); diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCop.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCop.java index abba15d977..c99ffc08b9 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCop.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCop.java @@ -34,7 +34,7 @@ public AttractiveTermMatCop(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermMatCop(ComponentEosInterface component, double[] params) { this(component); @@ -103,14 +103,14 @@ public double diffalphaT(double temperature) { public double diffdiffalphaT(double temperature) { double Tr = temperature / getComponent().getTC(); double TC = getComponent().getTC(); - return 2.0 * Math.pow(-parameters[0] / Math.sqrt(Tr) / TC / 2.0 - - parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr) / TC + return 2.0 + * Math.pow(-parameters[0] / Math.sqrt(Tr) / TC / 2.0 + - parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr) / TC - 3.0 / 2.0 * parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) / Math.sqrt(Tr) / TC, 2.0) - + 2.0 - * (1.0 + parameters[0] * (1.0 - Math.sqrt(Tr)) - + parameters[1] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) - + parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 3.0)) + + 2.0 * (1.0 + parameters[0] * (1.0 - Math.sqrt(Tr)) + + parameters[1] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) + + parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 3.0)) * (parameters[0] / Math.sqrt(Tr * Tr * Tr) / (TC * TC) / 4.0 + parameters[1] / temperature / TC / 2.0 + parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr * Tr * Tr) / (TC * TC) / 2.0 diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPR.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPR.java index 2ac6c10d03..fbda40b094 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPR.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPR.java @@ -46,7 +46,7 @@ public AttractiveTermMatCopPR(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermMatCopPR(ComponentEosInterface component, double[] params) { this(component); @@ -136,7 +136,8 @@ public double diffdiffalphaT(double temperature) { double Tr = temperature / getComponent().getTC(); double TC = getComponent().getTC(); double rootTR = 1.0 - Math.sqrt(Tr); - return 2.0 * Math.pow( + return 2.0 + * Math.pow( -parameters[0] / Math.sqrt(Tr) / TC / 2.0 - parameters[1] * rootTR / Math.sqrt(Tr) / TC - 3.0 / 2.0 * parameters[2] * rootTR * rootTR / Math.sqrt(Tr) / TC, 2.0) diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPRUMR.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPRUMR.java index 33afef6ed2..dd48e4f4de 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPRUMR.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMatCopPRUMR.java @@ -47,7 +47,7 @@ public AttractiveTermMatCopPRUMR(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermMatCopPRUMR(ComponentEosInterface component, double[] params) { this(component); @@ -136,14 +136,14 @@ public double diffdiffalphaT(double temperature) { double Tr = temperature / getComponent().getTC(); double TC = getComponent().getTC(); - return 2.0 * Math.pow(-parameters[0] / Math.sqrt(Tr) / TC / 2.0 - - parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr) / TC + return 2.0 + * Math.pow(-parameters[0] / Math.sqrt(Tr) / TC / 2.0 + - parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr) / TC - 3.0 / 2.0 * parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) / Math.sqrt(Tr) / TC, 2.0) - + 2.0 - * (1.0 + parameters[0] * (1.0 - Math.sqrt(Tr)) - + parameters[1] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) - + parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 3.0)) + + 2.0 * (1.0 + parameters[0] * (1.0 - Math.sqrt(Tr)) + + parameters[1] * Math.pow(1.0 - Math.sqrt(Tr), 2.0) + + parameters[2] * Math.pow(1.0 - Math.sqrt(Tr), 3.0)) * (parameters[0] / Math.sqrt(Tr * Tr * Tr) / (TC * TC) / 4.0 + parameters[1] / temperature / TC / 2.0 + parameters[1] * (1.0 - Math.sqrt(Tr)) / Math.sqrt(Tr * Tr * Tr) / (TC * TC) / 2.0 diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMollerup.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMollerup.java index b447d46f39..6b0d436642 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMollerup.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermMollerup.java @@ -30,7 +30,7 @@ public AttractiveTermMollerup(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermMollerup(ComponentEosInterface component, double[] params) { this(component); diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermPr1978.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermPr1978.java index dc4ecb222b..441bd62ce3 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermPr1978.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermPr1978.java @@ -32,6 +32,22 @@ public AttractiveTermPr1978(ComponentEosInterface component) { } } + /** {@inheritDoc} */ + @Override + public void setm(double val) { + this.m = val; + neqsim.MathLib.nonLinearSolver.newtonRhapson solve = + new neqsim.MathLib.nonLinearSolver.newtonRhapson(); + solve.setOrder(2); + double[] acentricConstants = {-0.26992, 1.54226, (0.37464 - this.m)}; + if (this.m > 0.49) { + solve.setOrder(3); + acentricConstants = new double[] {0.01666, -0.164423, 1.48503, (0.379642 - this.m)}; + } + solve.setConstants(acentricConstants); + getComponent().setAcentricFactor(solve.solve(0.2)); + } + /** {@inheritDoc} */ @Override public AttractiveTermPr1978 clone() { diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermSchwartzentruber.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermSchwartzentruber.java index 8f3411780c..38cad498c5 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermSchwartzentruber.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermSchwartzentruber.java @@ -35,7 +35,7 @@ public AttractiveTermSchwartzentruber(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermSchwartzentruber(ComponentEosInterface component, double[] params) { this(component); @@ -72,9 +72,11 @@ public double alpha(double temperature) { // parameters[0]*(1.0-temperature/component.getTC()) * // (1.0+parameters[1]*temperature/component.getTC()+parameters[2] * // Math.pow(temperature/component.getTC(),2.0)),2.0)); - return Math.pow(1.0 + m * (1.0 - Math.sqrt(temperature / getComponent().getTC())) - - parameters[0] * (1.0 - temperature / getComponent().getTC()) - * (1.0 + parameters[1] * temperature / getComponent().getTC() + return Math + .pow( + 1.0 + m * (1.0 - Math.sqrt(temperature / getComponent().getTC())) + - parameters[0] * (1.0 - temperature / getComponent().getTC()) + * (1.0 + parameters[1] * temperature / getComponent().getTC() + parameters[2] * Math.pow(temperature / getComponent().getTC(), 2.0)), 2.0); } @@ -150,8 +152,9 @@ public double diffalphaT(double temperature) { /** {@inheritDoc} */ @Override public double diffdiffalphaT(double temperature) { - return 2.0 * Math.pow(-m / Math.sqrt(temperature / getComponent().getTC()) - / getComponent().getTC() / 2.0 + return 2.0 + * Math + .pow(-m / Math.sqrt(temperature / getComponent().getTC()) / getComponent().getTC() / 2.0 + parameters[0] / getComponent().getTC() * (1.0 + parameters[1] * temperature / getComponent().getTC() + parameters[2] * temperature * temperature @@ -161,11 +164,11 @@ public double diffdiffalphaT(double temperature) { / (getComponent().getTC() * getComponent().getTC())), 2.0) + 2.0 - * (1.0 + m * (1.0 - Math.sqrt(temperature / getComponent().getTC())) - - parameters[0] * (1.0 - temperature / getComponent().getTC()) - * (1.0 + parameters[1] * temperature / getComponent().getTC() - + parameters[2] * temperature * temperature - / (getComponent().getTC() * getComponent().getTC()))) + * (1.0 + m * (1.0 - Math.sqrt(temperature / getComponent().getTC())) - parameters[0] + * (1.0 - temperature / getComponent().getTC()) + * (1.0 + parameters[1] * temperature / getComponent().getTC() + + parameters[2] * temperature * temperature + / (getComponent().getTC() * getComponent().getTC()))) * (m / Math.sqrt(temperature * temperature * temperature / (getComponent().getTC() * getComponent().getTC() * getComponent().getTC())) / (getComponent().getTC() * getComponent().getTC()) / 4.0 diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonParam.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonParam.java index 628c0f2120..264ebfbcd8 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonParam.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonParam.java @@ -37,7 +37,7 @@ public AttractiveTermTwuCoonParam(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermTwuCoonParam(ComponentEosInterface component, double[] params) { this(component); diff --git a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonStatoil.java b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonStatoil.java index f609c5d93b..59a0567663 100644 --- a/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonStatoil.java +++ b/src/main/java/neqsim/thermo/component/attractiveEosTerm/AttractiveTermTwuCoonStatoil.java @@ -37,7 +37,7 @@ public AttractiveTermTwuCoonStatoil(ComponentEosInterface component) { * * * @param component a {@link neqsim.thermo.component.ComponentEosInterface} object - * @param params an array of {@link double} objects + * @param params an array of type double */ public AttractiveTermTwuCoonStatoil(ComponentEosInterface component, double[] params) { this(component); diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java index f7f505971a..7cd7faa3bf 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRules.java @@ -22,6 +22,7 @@ import neqsim.thermo.phase.PhaseGEUnifacPSRK; import neqsim.thermo.phase.PhaseGEUnifacUMRPRU; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.util.database.NeqSimDataBase; /** @@ -132,6 +133,13 @@ public double getBinaryInteractionParameter(int i, int j) { return intparam[i][j]; } + @Override + public double[][] getBinaryInteractionParameters() { + return intparam; + } + + public void prettyPrintKij() {} + @Override public double getBinaryInteractionParameterT1(int i, int j) { if (i == j) { @@ -1004,7 +1012,7 @@ public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, / (1.0 + compArray[0].getDeltaEosParameters()[0])); gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, mixRule, intparam); gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure(), 1); + phase.getPressure(), PhaseType.byValue(1)); gePhase.setProperties(phase); } @@ -1018,7 +1026,7 @@ public SRKHuronVidal(PhaseInterface phase, double[][] HValpha, double[][] HVDij, / (1.0 + compArray[0].getDeltaEosParameters()[0])); gePhase = new PhaseGENRTLmodifiedHV(orgPhase, HValpha, HVDij, HVDijT, mixRule, intparam); gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), phase.getTemperature(), - phase.getPressure(), 1); + phase.getPressure(), PhaseType.byValue(1)); gePhase.setProperties(phase); } @@ -1083,7 +1091,7 @@ public double calcA(PhaseInterface phase, double temperature, double pressure, i } A = calcB(phase, temperature, pressure, numbcomp) * (A - phase.getNumberOfMolesInPhase() * gePhase.getExcessGibbsEnergy(phase, phase.getNumberOfComponents(), - phase.getTemperature(), phase.getPressure(), 0) + phase.getTemperature(), phase.getPressure(), PhaseType.byValue(0)) / gePhase.getNumberOfMolesInPhase() / hwfc); Atot = A; return A; @@ -1301,8 +1309,7 @@ public void init(PhaseInterface phase, double temperature, double pressure, int gePhase.setParams(phase, HValpha, HVDij, HVDijT, classicOrHV, intparam); if (mixingRuleGEModel.equals("NRTL")) { - gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getType().getValue()); + gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getType()); } else { gePhase.init((phase.getNumberOfMolesInPhase() / phase.getBeta()), phase.getNumberOfComponents(), phase.getInitType(), phase.getType(), phase.getBeta()); @@ -1609,8 +1616,7 @@ public void init(PhaseInterface phase, double temperature, double pressure, int gePhase.setProperties(phase); if (mixingRuleGEModel.equals("NRTL")) { - gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, - phase.getType().getValue()); + gePhase.getExcessGibbsEnergy(phase, numbcomp, temperature, pressure, phase.getType()); } else { gePhase.init(phase.getNumberOfMolesInPhase(), phase.getNumberOfComponents(), 3, phase.getType(), phase.getBeta()); @@ -2599,7 +2605,7 @@ public void setMixingRuleGEModel(java.lang.String GEmodel) { * getSRKbinaryInteractionParameters. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getSRKbinaryInteractionParameters() { return intparam; diff --git a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java index 781396b92b..6332ab9778 100644 --- a/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java +++ b/src/main/java/neqsim/thermo/mixingRule/EosMixingRulesInterface.java @@ -275,6 +275,14 @@ public double calcAiT(int compNumb, PhaseInterface phase, double temperature, do */ public PhaseInterface getGEPhase(); + /** + *+ * getBinaryInteractionParameters. + *
+ * + * @return an array of type double + */ + public double[][] getBinaryInteractionParameters(); // double calcA2(PhaseInterface phase, double temperature, double pressure, int // numbcomp); // double calcB2(PhaseInterface phase, double temperature, double pressure, int diff --git a/src/main/java/neqsim/thermo/phase/Phase.java b/src/main/java/neqsim/thermo/phase/Phase.java index 8b5d875ad0..0076a36481 100644 --- a/src/main/java/neqsim/thermo/phase/Phase.java +++ b/src/main/java/neqsim/thermo/phase/Phase.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger; import neqsim.physicalProperties.PhysicalPropertyHandler; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.system.SystemInterface; import neqsim.util.exception.InvalidInputException; @@ -20,8 +21,10 @@ * * @author Even Solbraa */ -abstract class Phase implements PhaseInterface { +public abstract class Phase implements PhaseInterface { + /** Serialization version UID. */ private static final long serialVersionUID = 1000; + /** Logger object for class. */ static Logger logger = LogManager.getLogger(Phase.class); public int numberOfComponents = 0; @@ -50,6 +53,7 @@ abstract class Phase implements PhaseInterface { * not known to the phase. */ double beta = 1.0; + /** * Number of moles in phase.numberOfMolesInPhase = numberOfMolesInSystem*beta
. NB!
* numberOfMolesInSystem is not known to the phase.
@@ -70,7 +74,7 @@ abstract class Phase implements PhaseInterface {
*
*/
public Phase() {
- componentArray = new ComponentInterface[MAX_NUMBER_OF_COMPONENTS];
+ componentArray = new ComponentInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS];
}
/** {@inheritDoc} */
@@ -98,28 +102,48 @@ public Phase clone() {
/**
* - * addcomponent. Increase number of components and add moles to phase. + * Increase number of components and add moles to phase. + * + * NB! Does not actually add component to componentarray. *
* * @param name Name of component to add. * @param moles Number of moles of component to add to phase. + * @param compNumber component number in fluid */ - public void addComponent(String name, double moles) { + public void addComponent(String name, double moles, int compNumber) { if (name == null) { // Will fail anyhow creating component with no name throw new RuntimeException( new InvalidInputException(this, "addcomponent", "name", "can not be null")); } + if (name.equals("")) { + throw new RuntimeException( + new InvalidInputException(this, "addcomponent", "name", "can not be empty.")); + } + + if (this.hasComponent(name)) { + // shall use addMoles/addMolesChemreac to adding/subtracting moles for + // component. + throw new RuntimeException(new InvalidInputException(this, "addComponent", "name", + "component with same name already exists in phase. Use addMoles or addMolesChemreac.")); + } + if (moles < 0) { - // should use addMoles/addMolesChemreac if subtracting moles. throw new RuntimeException( new InvalidInputException(this, "addComponent", "moles", "can not be negative")); } - if (this.hasComponent(name)) { - // should use addMoles/addMolesChemreac if adding/subtracting moles for component. - throw new RuntimeException("Component already exists in phase"); + if (compNumber < 0 || compNumber >= ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS) { + throw new RuntimeException(new InvalidInputException(this, "addComponent", "compNumber", + " must be valid index, i.e., between 0 and " + + ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS + ".")); + } + + if (componentArray[compNumber] != null) { + throw new RuntimeException(new InvalidInputException(this, "addComponent", "compNumber", + "number is already in use.")); } this.numberOfMolesInPhase += moles; @@ -128,7 +152,7 @@ public void addComponent(String name, double moles) { /** {@inheritDoc} */ @Override - public void removeComponent(String name, double moles, double molesInPhase, int compNumber) { + public void removeComponent(String name, double moles, double molesInPhase) { name = ComponentInterface.getComponentNameFromAlias(name); ArrayListthermoPropertyModelName
.
*
*
- * @return a {@link String} object
+ * @return a {@link java.lang.String} object
*/
public String getThermoPropertyModelName() {
return thermoPropertyModelName;
@@ -2189,4 +2320,10 @@ public double getIsothermalCompressibility() {
public double getIsobaricThermalExpansivity() {
return getIsothermalCompressibility() * getdPdTVn();
}
+
+ /** {@inheritDoc} */
+ @Override
+ public String getModelName() {
+ return thermoPropertyModelName;
+ }
}
diff --git a/src/main/java/neqsim/thermo/phase/PhaseBWRSEos.java b/src/main/java/neqsim/thermo/phase/PhaseBWRSEos.java
index a6a7060c4c..8d9c89ed7c 100644
--- a/src/main/java/neqsim/thermo/phase/PhaseBWRSEos.java
+++ b/src/main/java/neqsim/thermo/phase/PhaseBWRSEos.java
@@ -51,17 +51,17 @@ public void addComponent(String name, double moles, double molesInPhase, int com
/** {@inheritDoc} */
@Override
- public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase,
+ public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
double oldMolDens = 0;
- if (type == 0) {
- super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta);
- super.init(totalNumberOfMoles, numberOfComponents, 3, phase, beta);
+ if (initType == 0) {
+ super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
+ super.init(totalNumberOfMoles, numberOfComponents, 3, pt, beta);
return;
}
do {
oldMolDens = getMolarDensity();
- super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta);
+ super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
} while (Math.abs((getMolarDensity() - oldMolDens) / oldMolDens) > 1e-10);
getF();
// calcPVT();
@@ -413,7 +413,7 @@ public void calcPVT() {
@Override
public double getF() {
// System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " +
- // super.getF() + " phasetype " +getType());
+ // super.getF() + " pt " +getType());
return (getFpol() + getFexp()) * 1e3;
}
@@ -439,7 +439,7 @@ public double getdFdN() {
getComponent(0).addMoles(dn);
init(numberOfMolesInPhase, numberOfComponents, 3, 1.0);
// System.out.println("F " + getFpol()*1e3+ " "+ getFexp()*1e3 + " super " +
- // super.getF() + " phasetype " +getType());
+ // super.getF() + " pt " +getType());
return (fold - fnew) / (2 * dn);
}
@@ -456,11 +456,11 @@ public double dFdT() {
// temperature = temperature + dv;
// init(numberOfMolesInPhase, numberOfComponents, 3, pt.getValue(), 1.0);
// System.out.println("dFdT " + ((fold-fnew)/(2*dv)) + " super " +
- // (getFpoldT()+getFexpdT())*1e3+ " phasetype " +getType());
+ // (getFpoldT()+getFexpdT())*1e3+ " pt " +getType());
return (getFpoldT() + getFexpdT()) * 1e3; // (fold-fnew)/(2*dv);
// // System.out.println("FT " + getFpoldT()*1e3+ " "+ getFexpdT()*1e3 + " super
- // " + super.dFdT() + " phasetype " +getType());
+ // " + super.dFdT() + " pt " +getType());
// return (getFpoldT()+getFexpdT())*1e3;
}
@@ -505,10 +505,10 @@ public double dFdV() {
// molarVolume = molarVolume + dv;
// System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+
- // " phasetype " +getType());
+ // " pt " +getType());
// // return (fold-fnew)/(2*dv);
// System.out.println("dFdV " + ((getFpoldV()+getFexpdV()))*1e3*1e-5 + " super "
- // + super.dFdV()+ " phasetype " +getType());
+ // + super.dFdV()+ " pt " +getType());
// System.out.println("dFdV " + getFpoldV()+getFexpdV()*1e3*1e-5);
return (getFpoldV() + getFexpdV()) * 1e3 * 1e-5;
}
@@ -525,7 +525,7 @@ public double dFdVdV() {
setMolarVolume(getMolarVolume() + dv);
// System.out.println("dFdV " + ((fold-fnew)/(2*dv)) + " super " + super.dFdV()+
- // " phasetype " +getType());
+ // " pt " +getType());
return (fold - fnew) / (2 * dv);
// return (getFpoldVdV()+getFexpdVdV())*1e3*1e-10;
}
@@ -536,11 +536,12 @@ public double dFdVdV() {
/** {@inheritDoc} */
@Override
- public double molarVolume2(double pressure, double temperature, double A, double B, int phase)
+ public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt)
throws neqsim.util.exception.IsNaNException,
neqsim.util.exception.TooManyIterationsException {
- double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature())
- : pressure * getB() / (numberOfMolesInPhase * temperature * R);
+ double BonV =
+ pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature())
+ : pressure * getB() / (numberOfMolesInPhase * temperature * R);
double Btemp = getB();
setMolarVolume(1.0 / BonV * Btemp); // numberOfMolesInPhase;
int iterations = 0;
diff --git a/src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java b/src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java
index a437a19f3e..79d1d28e25 100644
--- a/src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java
+++ b/src/main/java/neqsim/thermo/phase/PhaseCSPsrkEos.java
@@ -58,24 +58,24 @@ public PhaseCSPsrkEos clone() {
/** {@inheritDoc} */
@Override
public void addComponent(String name, double moles, double molesInPhase, int compNumber) {
- super.addComponent(name, molesInPhase);
+ super.addComponent(name, molesInPhase, compNumber);
componentArray[compNumber] = new ComponentCSPsrk(name, moles, molesInPhase, compNumber);
((ComponentCSPsrk) componentArray[compNumber]).setRefPhaseBWRS(this);
}
/** {@inheritDoc} */
@Override
- public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase,
+ public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt,
double beta) {
double oldtemp = temperature;
- if (type == 0) {
- refBWRSPhase.init(1.0, 1, 0, phase, 1.0);
- refBWRSPhase.init(1.0, 1, 3, phase, 1.0);
+ if (initType == 0) {
+ refBWRSPhase.init(1.0, 1, 0, pt, 1.0);
+ refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
} else {
- refBWRSPhase.init(1.0, 1, 3, phase, 1.0);
+ refBWRSPhase.init(1.0, 1, 3, pt, 1.0);
}
do {
- super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta);
+ super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta);
oldtemp = refBWRSPhase.getTemperature();
h_scale_mix = getNumberOfMolesInPhase() * getb() / brefBWRSPhase;
double term1 = getA() / ((ComponentEosInterface) refBWRSPhase.getComponent(0)).getaT();
@@ -84,7 +84,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph
refBWRSPhase.setMolarVolume(getTotalVolume() / h_scale_mix);
// refBWRSPhase.setPressure(refBWRSPhase.calcPressure());
refBWRSPhase.setPressure(pressure * h_scale_mix / f_scale_mix);
- refBWRSPhase.init(1.0, 1, type, phase, 1.0);
+ refBWRSPhase.init(1.0, 1, initType, pt, 1.0);
} while (Math.abs((oldtemp - refBWRSPhase.getTemperature()) / oldtemp) > 1e-8);
}
@@ -211,11 +211,12 @@ public void setRefBWRSPhase(neqsim.thermo.phase.PhaseBWRSEos refBWRSPhase) {
/** {@inheritDoc} */
@Override
- public double molarVolume(double pressure, double temperature, double A, double B, int phase)
+ public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws neqsim.util.exception.IsNaNException,
neqsim.util.exception.TooManyIterationsException {
- double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature())
- : pressure * getB() / (numberOfMolesInPhase * temperature * R);
+ double BonV =
+ pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature())
+ : pressure * getB() / (numberOfMolesInPhase * temperature * R);
if (BonV < 0) {
BonV = 0.0;
}
diff --git a/src/main/java/neqsim/thermo/phase/PhaseDefault.java b/src/main/java/neqsim/thermo/phase/PhaseDefault.java
index 063884d170..cd93312e95 100644
--- a/src/main/java/neqsim/thermo/phase/PhaseDefault.java
+++ b/src/main/java/neqsim/thermo/phase/PhaseDefault.java
@@ -48,7 +48,7 @@ public void setComponentType(ComponentInterface comp) {
/** {@inheritDoc} */
@Override
public void addComponent(String name, double moles, double molesInPhase, int compNumber) {
- super.addComponent(name, moles);
+ super.addComponent(name, moles, compNumber);
try {
componentArray[compNumber] = defComponent.getClass().getDeclaredConstructor().newInstance();
} catch (Exception ex) {
@@ -59,10 +59,10 @@ public void addComponent(String name, double moles, double molesInPhase, int com
/** {@inheritDoc} */
@Override
- public double molarVolume(double pressure, double temperature, double A, double B, int phase)
+ public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws neqsim.util.exception.IsNaNException,
neqsim.util.exception.TooManyIterationsException {
- return 1.0;
+ throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
}
/** {@inheritDoc} */
@@ -72,7 +72,7 @@ public void resetMixingRule(int type) {}
/** {@inheritDoc} */
@Override
public double getMolarVolume() {
- return 1.0;
+ throw new UnsupportedOperationException("Unimplemented method 'getMolarVolume'");
}
/** {@inheritDoc} */
@@ -85,4 +85,10 @@ public double getGibbsEnergy() {
}
return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase);
}
+
+ /** {@inheritDoc} */
+ @Override
+ public double getSoundSpeed() {
+ return Double.NaN;
+ }
}
diff --git a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java
index 911d0c8c7c..b40d6006e4 100644
--- a/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java
+++ b/src/main/java/neqsim/thermo/phase/PhaseDesmukhMather.java
@@ -4,6 +4,8 @@
import org.apache.logging.log4j.Logger;
import neqsim.thermo.component.ComponentDesmukhMather;
import neqsim.thermo.component.ComponentGEInterface;
+import neqsim.util.exception.IsNaNException;
+import neqsim.util.exception.TooManyIterationsException;
/**
* @@ -33,18 +35,17 @@ public PhaseDesmukhMather() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentDesmukhMather(name, moles, molesInPhase, compNumber); } /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); if (initType != 0) { - setType(phase); - // phaseTypeName = phase == 0 ? "liquid" : "gas"; + setType(pt); } setMolarVolume(0.980e-3 * getMolarMass() * 1e5); Z = pressure * getMolarVolume() / (R * temperature); @@ -96,12 +97,31 @@ && getComponents()[k].getComponentName().equals("MDEA")) { } } + /** {@inheritDoc} */ + @Override + public void setAlpha(double[][] alpha) { + throw new UnsupportedOperationException("Unimplemented method 'setAlpha'"); + } + + /** + *
+ * Getter for the field aij
.
+ *
* Setter for the field aij
.
*
bij
.
*
*
- * @param Dij an array of {@link double} objects
+ * @param Bij an array of type double
*/
- public void setBij(double[][] Dij) {
- for (int i = 0; i < Dij.length; i++) {
- System.arraycopy(bij[i], 0, this.bij[i], 0, Dij[0].length);
+ public void setBij(double[][] Bij) {
+ for (int i = 0; i < Bij.length; i++) {
+ System.arraycopy(bij[i], 0, this.bij[i], 0, Bij[0].length);
}
}
+ /** {@inheritDoc} */
+ @Override
+ public void setDij(double[][] Dij) {
+ throw new UnsupportedOperationException("Unimplemented method 'setDij'");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setDijT(double[][] DijT) {
+ throw new UnsupportedOperationException("Unimplemented method 'setDijT'");
+ }
+
/**
* * getBetaDesMatij. @@ -135,19 +167,6 @@ public double getBetaDesMatij(int i, int j) { return aij[i][j] + bij[i][j] * temperature; } - /** - *
- * Getter for the field aij
.
- *
* Getter for the field bij
.
@@ -171,21 +190,20 @@ public double getGibbsEnergy() {
@Override
public double getExcessGibbsEnergy() {
// double GE = getExcessGibbsEnergy(this, numberOfComponents, temperature,
- // pressure, phaseType);
+ // pressure, pt);
return GE;
}
/** {@inheritDoc} */
@Override
public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents,
- double temperature, double pressure, int phasetype) {
+ double temperature, double pressure, PhaseType pt) {
GE = 0;
for (int i = 0; i < numberOfComponents; i++) {
GE += phase.getComponents()[i].getx() * Math.log(((ComponentDesmukhMather) componentArray[i])
- .getGamma(phase, numberOfComponents, temperature, pressure, phasetype));
+ .getGamma(phase, numberOfComponents, temperature, pressure, pt));
}
- // System.out.println("ge " + GE);
- return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()*
+ return R * temperature * numberOfMolesInPhase * GE;
}
/** {@inheritDoc} */
@@ -263,4 +281,11 @@ public double getSolventMolarMass() {
}
return molesMass / moles;
}
+
+ /** {@inheritDoc} */
+ @Override
+ public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
+ throws IsNaNException, TooManyIterationsException {
+ throw new UnsupportedOperationException("Unimplemented method 'molarVolume'");
+ }
}
diff --git a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java
index 00af4cc77f..0af4f441e5 100644
--- a/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java
+++ b/src/main/java/neqsim/thermo/phase/PhaseDuanSun.java
@@ -1,6 +1,8 @@
package neqsim.thermo.phase;
import neqsim.thermo.component.ComponentGeDuanSun;
+import neqsim.util.exception.IsNaNException;
+import neqsim.util.exception.TooManyIterationsException;
/**
*
@@ -31,7 +33,7 @@ public PhaseDuanSun() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGeDuanSun(name, moles, molesInPhase, compNumber); } @@ -59,18 +61,24 @@ public void setDij(double[][] Dij) { } } + /** {@inheritDoc} */ + @Override + public void setDijT(double[][] DijT) { + throw new UnsupportedOperationException("Unimplemented method 'setDijT'"); + } + /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy() { // double GE = getExcessGibbsEnergy(this, numberOfComponents, temperature, - // pressure, phaseType); + // pressure, pt); return GE; } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { GE = 0; double salinity = 0.0; // double k=0.0; @@ -98,12 +106,12 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, for (int i = 0; i < numberOfComponents; i++) { // GE += phase.getComponents()[i].getx()*Math.log(((ComponentGeDuanSun) // componentArray[i]).getGammaNRTL(phase, numberOfComponents, temperature, pressure, - // phasetype, alpha, Dij)); + // pt, alpha, Dij)); GE += phase.getComponents()[i].getx() * Math.log(((ComponentGeDuanSun) componentArray[i]) - .getGammaPitzer(phase, numberOfComponents, temperature, pressure, phasetype, salinity)); + .getGammaPitzer(phase, numberOfComponents, temperature, pressure, pt, salinity)); } - return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* + return R * temperature * numberOfMolesInPhase * GE; } /** {@inheritDoc} */ @@ -111,4 +119,11 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, public double getGibbsEnergy() { return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) + throws IsNaNException, TooManyIterationsException { + throw new UnsupportedOperationException("Unimplemented method 'molarVolume'"); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java index 080cde69b7..a1e4f3a556 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java @@ -104,9 +104,9 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type == 0) { + if (initType == 0) { setTotalNumberOfAccociationSites(0); selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; @@ -182,12 +182,12 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType > 0 && isConstantPhaseVolume()) { volInit(); calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); @@ -195,17 +195,17 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph gcpavvv = calc_lngVVV(); } - if (type > 0) { + if (initType > 0) { hcpatot = calc_hCPA(); } - if (type > 1) { + if (initType > 1) { volInit(); - initCPAMatrix(type); + initCPAMatrix(initType); // hcpatotdT = calc_hCPAdT(); - // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + // super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } /** @@ -827,17 +827,17 @@ public double getGcpa() { * calcRootVolFinder. *
* - * @param phase a int + * @param pt the PhaseType of the phase * @return a double */ - public double calcRootVolFinder(int phase) { + public double calcRootVolFinder(PhaseType pt) { double solvedBonVHigh = 0.0; double solvedBonVlow = 1.0; double oldh = 1; // double[][] matrix = new double[2][2000]; double BonV = 1.0 - 1e-10; try { - // molarVolume(pressure, temperature, A, B, phaseType); + // molarVolume(pressure, temperature, A, B, pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -868,12 +868,12 @@ public double calcRootVolFinder(int phase) { if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { if (solvedBonVlow < 1e-3) { solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { + if (pt == PhaseType.GAS) { break; } } else { solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { + if (pt == PhaseType.LIQUID) { break; } } @@ -891,7 +891,7 @@ public double calcRootVolFinder(int phase) { // file.setValues(matrix); // file.setOutputFileName("D:/temp/temp2.txt"); // file.createFile(); - if (phase == 1) { + if (pt == PhaseType.GAS) { return solvedBonVlow; } else { return solvedBonVHigh; @@ -900,11 +900,12 @@ public double calcRootVolFinder(int phase) { /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-8; } @@ -967,7 +968,7 @@ public double molarVolume2(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -981,7 +982,7 @@ public double molarVolume2(double pressure, double temperature, double A, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -990,7 +991,7 @@ public double molarVolume2(double pressure, double temperature, double A, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1025,16 +1026,17 @@ public double molarVolume2(double pressure, double temperature, double A, double /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // if (pressure > 1000) { // BonV = 0.9999; // } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // double calcRooBonVtVolFinder = calcRootVolFinder(pt); // BonV = calcRooBonVtVolFinder; // double BonVInit = BonV; if (BonV <= 0) { @@ -1097,7 +1099,7 @@ public double molarVolume(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1111,9 +1113,9 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1121,8 +1123,8 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1135,7 +1137,7 @@ public double molarVolume(double pressure, double temperature, double A, double if (Math.abs(h) > 1e-9) { // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " // BonV " + BonV); - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1167,18 +1169,18 @@ public double molarVolume(double pressure, double temperature, double A, double * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // double BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); - double BonV = calcRootVolFinder(phasetype); + double BonV = calcRootVolFinder(pt); // double BonVInit = BonV; if (BonV < 0) { BonV = 1.0e-8; @@ -1240,7 +1242,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1254,7 +1256,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1263,7 +1265,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1276,8 +1278,8 @@ public double molarVolumeChangePhase(double pressure, double temperature, double } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); - * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } + * if (Math.abs(h) > 1e-8) { if (pt == 0) { molarVolume(pressure, temperature, A, B, 1); } else + * { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1355,9 +1357,9 @@ public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) * croeneckerProduct. * * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + * @param a an array of type double + * @param b an array of type double + * @return an array of type double */ public double[][] croeneckerProduct(double[][] a, double[][] b) { int aLength = a.length; diff --git a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java index 557ff36021..1658ef37ee 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java +++ b/src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPAOld.java @@ -67,9 +67,9 @@ public PhaseElectrolyteCPAOld clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type == 0) { + if (initType == 0) { selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; for (int i = 0; i < numberOfComponents; i++) { @@ -80,11 +80,11 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph } } do { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } while (!solveX()); // System.out.println("test1 " + dFCPAdT()); - if (type > 1) { + if (initType > 1) { // calcXsitedT(); // System.out.println("test2 " + dFCPAdT()); hcpatotdT = calc_hCPAdT(); @@ -536,16 +536,17 @@ public double getGcpa() { * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ - public double molarVolume3(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume3(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-8; @@ -599,7 +600,7 @@ public double molarVolume3(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * -h / d1; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -634,11 +635,12 @@ public double molarVolume3(double pressure, double temperature, double A, double /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-8; @@ -701,7 +703,7 @@ public double molarVolume(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * -h / d1; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -738,10 +740,10 @@ public double molarVolume(double pressure, double temperature, double A, double /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + Z = pt == PhaseType.LIQUID ? 1.0 : 1.0e-5; setMolarVolume(Z * R * temperature / pressure); // super.molarVolume(pressure,temperature, A, B, phase); int iterations = 0; diff --git a/src/main/java/neqsim/thermo/phase/PhaseEos.java b/src/main/java/neqsim/thermo/phase/PhaseEos.java index db48eac349..94cb29f774 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEos.java @@ -8,15 +8,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentEosInterface; import neqsim.thermo.mixingRule.EosMixingRules; import neqsim.thermo.mixingRule.EosMixingRulesInterface; /** + * Abstract class PhaseEos. * * @author Even Solbraa */ -abstract class PhaseEos extends Phase implements PhaseEosInterface { +public abstract class PhaseEos extends Phase implements PhaseEosInterface { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(PhaseEos.class); @@ -57,7 +59,7 @@ public PhaseEos clone() { public PhaseEos() { super(); mixSelect = new EosMixingRules(); - componentArray = new ComponentEosInterface[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentEosInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; mixRule = mixSelect.getMixingRule(1); // solver = new newtonRhapson(); } @@ -76,18 +78,18 @@ public void displayInteractionCoefficients(String intType) { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (phase.getValue() > 1) { - phase = PhaseType.LIQUID; + if (pt != PhaseType.GAS) { + pt = PhaseType.LIQUID; } if (!mixingRuleDefined) { setMixingRule(1); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); - if (type != 0) { + if (initType != 0) { loc_B = calcB(this, temperature, pressure, numberOfComponents); loc_A = calcA(this, temperature, pressure, numberOfComponents); } @@ -97,15 +99,16 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph pressure = calcPressure(); } - if (type != 0) { + if (initType != 0) { try { if (calcMolarVolume) { molarVolume = molarVolume(pressure, temperature, getA() / numberOfMolesInPhase / numberOfMolesInPhase, getB() / numberOfMolesInPhase, - phase.getValue()); + pt); } } catch (Exception ex) { - logger.error("Failed to solve for molarVolume within the iteration limit."); + logger.warn("Failed to solve for molarVolume within the iteration limit."); + logger.error(ex.getMessage()); throw new RuntimeException(ex); // logger.error("too many iterations in volume calc!", ex); // logger.info("moles " + numberOfMolesInPhase); @@ -118,13 +121,13 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph Z = pressure * getMolarVolume() / (R * temperature); for (int i = 0; i < numberOfComponents; i++) { componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, - numberOfComponents, type); + numberOfComponents, initType); } f_loc = calcf(); g = calcg(); - if (type >= 2) { + if (initType >= 2) { loc_AT = calcAT(this, temperature, pressure, numberOfComponents); loc_ATT = calcATT(this, temperature, pressure, numberOfComponents); } @@ -132,8 +135,10 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph double sumHydrocarbons = 0.0; double sumAqueous = 0.0; for (int i = 0; i < numberOfComponents; i++) { - if (getComponent(i).isHydrocarbon() || getComponent(i).isInert() - || getComponent(i).isIsTBPfraction()) { + if ((getComponent(i).isHydrocarbon() || getComponent(i).isInert() + || getComponent(i).isIsTBPfraction()) + && !getComponent(i).getName().equals("water") + && !getComponent(i).getName().equals("water_PC")) { sumHydrocarbons += getComponent(i).getx(); } else { sumAqueous += getComponent(i).getx(); @@ -192,16 +197,17 @@ public void resetMixingRule(int type) { * @param temperature a double * @param A a double * @param B a double - * @param phase a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 0.0; } @@ -281,11 +287,12 @@ public double molarVolume2(double pressure, double temperature, double A, double /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-4; @@ -334,7 +341,7 @@ public double molarVolume(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -357,7 +364,7 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations > 150 && error > errorOld && !changeFase) { changeFase = true; BonVold = 10.0; - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } @@ -776,7 +783,7 @@ public double fv() { } // NYE metoder fredag 25.08.public double dFdN(PhaseInterface phase, int - // numberOfComponents, double temperature, double pressure, int phasetype){ + // numberOfComponents, double temperature, double pressure, PhaseType pt){ /** {@inheritDoc} */ @Override public double FnV() { @@ -1049,7 +1056,7 @@ public double getdUdSdVn(PhaseInterface phase) { * getdTVndSVnJaobiMatrix. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getdTVndSVnJaobiMatrix() { double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; @@ -1072,7 +1079,7 @@ public double[][] getdTVndSVnJaobiMatrix() { * getGradientVector. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getGradientVector() { double[] gradientVector = new double[2 + numberOfComponents]; @@ -1086,7 +1093,7 @@ public double[] getGradientVector() { * getUSVHessianMatrix. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getUSVHessianMatrix() { double[][] jacobiMatrix = new double[2 + numberOfComponents][2 + numberOfComponents]; @@ -1109,7 +1116,7 @@ public double[][] getUSVHessianMatrix() { * dFdxMatrixSimple. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] dFdxMatrixSimple() { double[] matrix = new double[numberOfComponents + 2]; @@ -1140,7 +1147,7 @@ public double[] dFdxMatrixSimple() { * dFdxMatrix. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] dFdxMatrix() { double[] matrix = new double[numberOfComponents + 2]; @@ -1159,7 +1166,7 @@ public double[] dFdxMatrix() { * dFdxdxMatrixSimple. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] dFdxdxMatrixSimple() { double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; @@ -1209,7 +1216,7 @@ public double[][] dFdxdxMatrixSimple() { * dFdxdxMatrix. * * - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] dFdxdxMatrix() { double[][] matrix = new double[numberOfComponents + 2][numberOfComponents + 2]; diff --git a/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java b/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java index 4420be0b23..0fbab32499 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseEosInterface.java @@ -35,7 +35,7 @@ public interface PhaseEosInterface extends PhaseInterface { * getMixingRuleName. * * - * @return a {@link String} object + * @return a {@link java.lang.String} object */ public String getMixingRuleName(); @@ -80,7 +80,7 @@ public interface PhaseEosInterface extends PhaseInterface { * displayInteractionCoefficients. * * - * @param intType a {@link String} object + * @param intType a {@link java.lang.String} object */ public void displayInteractionCoefficients(String intType); // public double getA(); diff --git a/src/main/java/neqsim/thermo/phase/PhaseGE.java b/src/main/java/neqsim/thermo/phase/PhaseGE.java index c11a2b4dbe..974adffbe6 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGE.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGE.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentGEInterface; import neqsim.thermo.mixingRule.EosMixingRules; import neqsim.thermo.mixingRule.EosMixingRulesInterface; @@ -21,7 +22,7 @@ * @author Even Solbraa * @version $Id: $Id */ -public class PhaseGE extends Phase implements PhaseGEInterface { +public abstract class PhaseGE extends Phase implements PhaseGEInterface { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(PhaseGE.class); @@ -36,7 +37,7 @@ public class PhaseGE extends Phase implements PhaseGEInterface { public PhaseGE() { super(); setType(PhaseType.LIQUID); - componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentGEInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; useVolumeCorrection = false; } @@ -50,19 +51,20 @@ public PhaseGE() { * @param totalNumberOfMoles a double * @param beta a double * @param numberOfComponents a int - * @param type a int + * @param pt the PhaseType of the phase * @param phase a int */ public void init(double temperature, double pressure, double totalNumberOfMoles, double beta, - int numberOfComponents, int type, int phase) { + int numberOfComponents, PhaseType pt, int phase) { if (totalNumberOfMoles <= 0) { new neqsim.util.exception.InvalidInputException(this, "init", "totalNumberOfMoles", "must be larger than zero."); } for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type); + // todo: Conflating init type and phase type? + componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, pt.getValue()); } - this.getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, type); + this.getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt); double sumHydrocarbons = 0.0; double sumAqueous = 0.0; @@ -84,11 +86,11 @@ public void init(double temperature, double pressure, double totalNumberOfMoles, /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, initType, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); if (initType != 0) { - getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, phase.getValue()); + getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt); } double sumHydrocarbons = 0.0; @@ -131,84 +133,6 @@ public void resetMixingRule(int type) { mixRuleEos = mixSelect.resetMixingRule(2, this); } - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) { - return 1; - } - - /** - *- * molarVolumeAnalytic. - *
- * - * @param pressure a double - * @param temperature a double - * @param A a double - * @param B a double - * @param phase a int - * @return a double - */ - public double molarVolumeAnalytic(double pressure, double temperature, double A, double B, - int phase) { - return 1; - } - - /** {@inheritDoc} */ - @Override - public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); - // TODO: compNumber not in use - } - - /** - *- * setAlpha. - *
- * - * @param alpha an array of {@link double} objects - */ - public void setAlpha(double[][] alpha) {} - - /** - *- * setDij. - *
- * - * @param Dij an array of {@link double} objects - */ - public void setDij(double[][] Dij) {} - - /** {@inheritDoc} */ - @Override - public double getExcessGibbsEnergy() { - logger.error("this getExcessGibbsEnergy should never be used......."); - return 0; - } - - /** {@inheritDoc} */ - @Override - public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - logger.error("this getExcessGibbsEnergy should never be used......."); - return 0; - } - - /** {@inheritDoc} */ - @Override - public double getGibbsEnergy() { - return 0; - } - - /** - *- * setDijT. - *
- * - * @param DijT an array of {@link double} objects - */ - public void setDijT(double[][] DijT) {} - /** {@inheritDoc} */ @Override public double getActivityCoefficientSymetric(int k) { @@ -238,7 +162,7 @@ public double getActivityCoefficientInfDilWater(int k, int p) { refPhase[k].setPressure(pressure); refPhase[k].init(refPhase[k].getNumberOfMolesInPhase(), 2, 1, this.getType(), 1.0); ((PhaseGEInterface) refPhase[k]).getExcessGibbsEnergy(refPhase[k], 2, - refPhase[k].getTemperature(), refPhase[k].getPressure(), refPhase[k].getType().getValue()); + refPhase[k].getTemperature(), refPhase[k].getPressure(), refPhase[k].getType()); return ((ComponentGEInterface) refPhase[k].getComponent(0)).getGamma(); } @@ -251,13 +175,13 @@ public double getActivityCoefficientInfDilWater(int k, int p) { * @return a double */ public double getActivityCoefficientInfDil(int k) { - PhaseInterface dilphase = (PhaseInterface) this.clone(); + PhaseInterface dilphase = this.clone(); dilphase.addMoles(k, -(1.0 - 1e-10) * dilphase.getComponent(k).getNumberOfMolesInPhase()); dilphase.getComponent(k).setx(1e-10); dilphase.init(dilphase.getNumberOfMolesInPhase(), dilphase.getNumberOfComponents(), 1, dilphase.getType(), 1.0); ((PhaseGEInterface) dilphase).getExcessGibbsEnergy(dilphase, 2, dilphase.getTemperature(), - dilphase.getPressure(), dilphase.getType().getValue()); + dilphase.getPressure(), dilphase.getType()); return ((ComponentGEInterface) dilphase.getComponent(0)).getGamma(); } @@ -293,7 +217,8 @@ public double getCv() { /** {@inheritDoc} */ @Override public double getZ() { - double densityIdealGas = pressure * 1e5 / 8.314 / temperature * getMolarMass(); + double densityIdealGas = + pressure * 1e5 / ThermodynamicConstantsInterface.R / temperature * getMolarMass(); return densityIdealGas / getDensity("kg/m3"); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java index 9401b6da82..ccb91d60c9 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEInterface.java @@ -17,35 +17,43 @@ public interface PhaseGEInterface { /** *- * getExessGibbsEnergy. + * getExcessGibbsEnergy. *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double - * @deprecated Replaced by {@link getExcessGibbsEnergy}. */ - @Deprecated - public default double getExessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { - return getExcessGibbsEnergy(phase, numberOfComponents, temperature, pressure, phasetype); - } + public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, + double temperature, double pressure, PhaseType pt); /** *- * getExcessGibbsEnergy. + * setAlpha. *
* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param numberOfComponents a int - * @param temperature a double - * @param pressure a double - * @param phasetype a int - * @return a double + * @param alpha an array of type double */ - public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype); + public void setAlpha(double[][] alpha); + + /** + *+ * setDij. + *
+ * + * @param Dij an array of type double + */ + public void setDij(double[][] Dij); + + /** + *+ * setDijT. + *
+ * + * @param DijT an array of type double + */ + public void setDijT(double[][] DijT); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java index 6d2b38b84b..8bd014d5f7 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTL.java @@ -8,6 +8,8 @@ import neqsim.thermo.component.ComponentGEInterface; import neqsim.thermo.component.ComponentGeNRTL; +import neqsim.util.exception.IsNaNException; +import neqsim.util.exception.TooManyIterationsException; /** *@@ -41,10 +43,10 @@ public PhaseGENRTL() { *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGENRTL(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -67,7 +69,7 @@ public PhaseGENRTL(PhaseInterface phase, double[][] alpha, double[][] Dij, Strin /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGeNRTL(name, moles, molesInPhase, compNumber); } @@ -97,26 +99,32 @@ public void setDij(double[][] Dij) { } } + /** {@inheritDoc} */ + @Override + public void setDijT(double[][] DijT) { + throw new UnsupportedOperationException("Unimplemented method 'setDijT'"); + } + /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy() { // double GE = getExcessGibbsEnergy(this, numberOfComponents, temperature, - // pressure, phaseType); + // pressure, pt); return GE; } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, pt, alpha, Dij, intparam, mixRule)); } - return R * temperature * numberOfMolesInPhase * GE; // phase.getNumberOfMolesInPhase()* + return R * temperature * numberOfMolesInPhase * GE; } /** {@inheritDoc} */ @@ -124,4 +132,11 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, public double getGibbsEnergy() { return R * temperature * numberOfMolesInPhase * (GE + Math.log(pressure)); } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) + throws IsNaNException, TooManyIterationsException { + throw new UnsupportedOperationException("Unimplemented method 'molarVolume'"); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java index 7bdcce29c4..6ddb386f36 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHV.java @@ -39,10 +39,10 @@ public PhaseGENRTLmodifiedHV() { * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -63,11 +63,11 @@ public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param DijT an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param DijT an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, String[][] mixRule, double[][] intparam) { @@ -86,7 +86,7 @@ public PhaseGENRTLmodifiedHV(PhaseInterface phase, double[][] alpha, double[][] /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGENRTLmodifiedHV(name, moles, molesInPhase, compNumber); } @@ -125,20 +125,20 @@ public void setDijT(double[][] DijT) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { if (type == 0) { - GE += phase.getComponents()[i].getx() * Math - .log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + GE += phase.getComponents()[i].getx() + * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, + numberOfComponents, temperature, pressure, pt, alpha, Dij, intparam, mixRule)); } else if (type == 1) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGENRTLmodifiedHV) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, DijT, intparam, mixRule)); + temperature, pressure, pt, alpha, Dij, DijT, intparam, mixRule)); } } - return (R * phase.getTemperature() * GE) * phase.getNumberOfMolesInPhase(); + return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE; } /** {@inheritDoc} */ @@ -149,7 +149,7 @@ public double getGibbsEnergy() { val += getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient()); // +Math.log(getComponent(i).getx()*getComponent(i).getAntoineVaporPressure(temperature))); } - return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); + return R * temperature * numberOfMolesInPhase * (val + Math.log(pressure)); } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java index 6d00c6b526..5d0704d8bb 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWS.java @@ -29,10 +29,10 @@ public PhaseGENRTLmodifiedWS() { * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGENRTLmodifiedWS(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -53,11 +53,11 @@ public PhaseGENRTLmodifiedWS(PhaseInterface phase, double[][] alpha, double[][] * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param DijT an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param DijT an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGENRTLmodifiedWS(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, String[][] mixRule, double[][] intparam) { @@ -84,7 +84,7 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGENRTLmodifiedWS(name, moles, molesInPhase, compNumber); } @@ -92,20 +92,20 @@ public void addComponent(String name, double moles, double molesInPhase, int com /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { + // TODO: why is GE a local variable? double GE = 0; for (int i = 0; i < numberOfComponents; i++) { if (type == 0) { - GE += phase.getComponents()[i].getx() * Math - .log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); - } - if (type == 1) { + GE += phase.getComponents()[i].getx() + * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, + numberOfComponents, temperature, pressure, pt, alpha, Dij, intparam, mixRule)); + } else if (type == 1) { GE += phase.getComponents()[i].getx() * Math .log(((ComponentGENRTLmodifiedWS) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, DijT, intparam, mixRule)); + temperature, pressure, pt, alpha, Dij, DijT, intparam, mixRule)); } } - return R * temperature * GE * numberOfMolesInPhase; + return R * temperature * numberOfMolesInPhase * GE; } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGERG2004Eos.java b/src/main/java/neqsim/thermo/phase/PhaseGERG2004Eos.java index 30bdedd5e2..40a998a4e8 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGERG2004Eos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGERG2004Eos.java @@ -1,5 +1,6 @@ package neqsim.thermo.phase; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.component.ComponentGERG2004; import neqsim.thermo.util.JNI.GERG2004EOS; @@ -59,7 +60,7 @@ public PhaseGERG2004Eos clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGERG2004(name, moles, molesInPhase, compNumber); } @@ -80,17 +81,17 @@ public void setxFracGERG() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - IPHASE = phase.getValue() == 0 ? -1 : -2; - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + IPHASE = pt == PhaseType.LIQUID ? -1 : -2; + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); setxFracGERG(); if (!okVolume) { - IPHASE = phase.getValue() == 0 ? -2 : -1; - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + IPHASE = pt == PhaseType.LIQUID ? -2 : -1; + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } - if (type >= 1) { + if (initType >= 1) { double[] temp = new double[18]; temp = GERG2004EOS.SPHIOTPX(temperature, pressure / 10.0, xFracGERG[0], xFracGERG[1], xFracGERG[2], xFracGERG[3], xFracGERG[4], xFracGERG[5], xFracGERG[6], xFracGERG[7], @@ -136,7 +137,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph // xFracGERG[0],xFracGERG[1],xFracGERG[2],xFracGERG[3],xFracGERG[4],xFracGERG[5],xFracGERG[6],xFracGERG[7],xFracGERG[8],xFracGERG[9],xFracGERG[10],xFracGERG[11],xFracGERG[12],xFracGERG[13],xFracGERG[14],xFracGERG[15],xFracGERG[16],xFracGERG[17],IPHASE); CvGERG = alloTPX[5]; // gergEOS.CPOTPX(temperature,pressure/10.0, // xFracGERG[0],xFracGERG[1],xFracGERG[2],xFracGERG[3],xFracGERG[4],xFracGERG[5],xFracGERG[6],xFracGERG[7],xFracGERG[8],xFracGERG[9],xFracGERG[10],xFracGERG[11],xFracGERG[12],xFracGERG[13],xFracGERG[14],xFracGERG[15],xFracGERG[16],xFracGERG[17],IPHASE); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } } @@ -184,19 +185,20 @@ public double getCv() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double temp = - GERG2004EOS.ZOTPX(temperature, pressure / 10.0, xFracGERG[0], xFracGERG[1], xFracGERG[2], - xFracGERG[3], xFracGERG[4], xFracGERG[5], xFracGERG[6], xFracGERG[7], xFracGERG[8], - xFracGERG[9], xFracGERG[10], xFracGERG[11], xFracGERG[12], xFracGERG[13], xFracGERG[14], - xFracGERG[15], xFracGERG[16], xFracGERG[17], IPHASE) * 8.314 * temperature / (pressure); + double temp = GERG2004EOS.ZOTPX(temperature, pressure / 10.0, xFracGERG[0], xFracGERG[1], + xFracGERG[2], xFracGERG[3], xFracGERG[4], xFracGERG[5], xFracGERG[6], xFracGERG[7], + xFracGERG[8], xFracGERG[9], xFracGERG[10], xFracGERG[11], xFracGERG[12], xFracGERG[13], + xFracGERG[14], xFracGERG[15], xFracGERG[16], xFracGERG[17], IPHASE) + * ThermodynamicConstantsInterface.R * temperature / (pressure); temp = GERG2004EOS.ZOTPX(temperature, pressure / 10.0, xFracGERG[0], xFracGERG[1], xFracGERG[2], xFracGERG[3], xFracGERG[4], xFracGERG[5], xFracGERG[6], xFracGERG[7], xFracGERG[8], xFracGERG[9], xFracGERG[10], xFracGERG[11], xFracGERG[12], xFracGERG[13], xFracGERG[14], - xFracGERG[15], xFracGERG[16], xFracGERG[17], IPHASE) * 8.314 * temperature / (pressure); + xFracGERG[15], xFracGERG[16], xFracGERG[17], IPHASE) * ThermodynamicConstantsInterface.R + * temperature / (pressure); okVolume = !(Math.abs(2222 + temp) < 0.1 || Math.abs(1111 + temp) < 0.1); return temp; } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java index 6256d8d4c6..8275d73433 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifac.java @@ -4,6 +4,7 @@ import java.util.Arrays; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.atomElement.UNIFACgroup; import neqsim.thermo.component.ComponentGEUnifac; import neqsim.thermo.component.ComponentGEUniquac; @@ -32,7 +33,7 @@ public class PhaseGEUnifac extends PhaseGEUniquac { */ public PhaseGEUnifac() { super(); - componentArray = new ComponentGEUnifac[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentGEUnifac[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; } /** @@ -41,10 +42,10 @@ public PhaseGEUnifac() { * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGEUnifac(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -61,7 +62,7 @@ public PhaseGEUnifac(PhaseInterface phase, double[][] alpha, double[][] Dij, Str /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGEUnifac(name, moles, molesInPhase, compNumber); } @@ -78,12 +79,12 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { // if(type==0) calcaij(); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type == 0) { - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType == 0) { + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); } } @@ -180,19 +181,19 @@ public void checkGroups() { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy() { - return getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt.getValue()); + return getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, pt); } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { double GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, pt)); } - return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); + return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE; } /** {@inheritDoc} */ @@ -203,7 +204,7 @@ public double getGibbsEnergy() { val += getComponent(i).getNumberOfMolesInPhase() * (getComponent(i).getLogFugacityCoefficient()); } - return R * temperature * ((val) + Math.log(pressure) * numberOfMolesInPhase); + return R * temperature * numberOfMolesInPhase * (val + Math.log(pressure)); } /** diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java index 22ae671fa3..9629aa678e 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacPSRK.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentGEUnifac; import neqsim.thermo.component.ComponentGEUnifacPSRK; import neqsim.thermo.component.ComponentGEUniquac; @@ -25,7 +26,7 @@ public class PhaseGEUnifacPSRK extends PhaseGEUnifac { */ public PhaseGEUnifacPSRK() { super(); - componentArray = new ComponentGEUnifacPSRK[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentGEUnifacPSRK[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; } /** @@ -34,10 +35,10 @@ public PhaseGEUnifacPSRK() { * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGEUnifacPSRK(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -55,7 +56,7 @@ public PhaseGEUnifacPSRK(PhaseInterface phase, double[][] alpha, double[][] Dij, /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGEUnifacPSRK(name, moles, molesInPhase, compNumber); } @@ -73,13 +74,13 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { double GE = 0.0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, pt)); } - return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); // phase.getNumberOfMolesInPhase()* + return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE; } /** diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java index f760d2279b..1c99290b90 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRU.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentGEUnifac; import neqsim.thermo.component.ComponentGEUnifacUMRPRU; import neqsim.thermo.component.ComponentGEUniquac; @@ -31,7 +32,8 @@ public class PhaseGEUnifacUMRPRU extends PhaseGEUnifac { */ public PhaseGEUnifacUMRPRU() { super(); - componentArray = new ComponentGEUnifacUMRPRU[MAX_NUMBER_OF_COMPONENTS]; + componentArray = + new ComponentGEUnifacUMRPRU[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; } /** @@ -40,10 +42,10 @@ public PhaseGEUnifacUMRPRU() { * * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGEUnifacUMRPRU(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -66,10 +68,10 @@ public PhaseGEUnifacUMRPRU(PhaseInterface phase, double[][] alpha, double[][] Di * @param numberOfComponents a int * @param temperature a double * @param pressure a double - * @param phasetype a int + * @param pt the PhaseType of the phase */ public void calcCommontemp(PhaseInterface phase, int numberOfComponents, double temperature, - double pressure, int phasetype) { + double pressure, PhaseType pt) { FCommontemp = 0; VCommontemp = 0; ComponentGEUnifac[] compArray = (ComponentGEUnifac[]) phase.getcomponentArray(); @@ -80,10 +82,20 @@ public void calcCommontemp(PhaseInterface phase, int numberOfComponents, double } } + /** + *getVCommontemp.
+ * + * @return a double + */ public double getVCommontemp() { return VCommontemp; } + /** + *getFCommontemp.
+ * + * @return a double + */ public double getFCommontemp() { return FCommontemp; } @@ -91,7 +103,7 @@ public double getFCommontemp() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGEUnifacUMRPRU(name, moles, molesInPhase, compNumber); } @@ -109,11 +121,11 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { double GE = 0.0; - calcCommontemp(phase, numberOfComponents, temperature, pressure, phasetype); + calcCommontemp(phase, numberOfComponents, temperature, pressure, pt); // ((ComponentGEUnifacUMRPRU) phase.getComponents()[0]).commonInit(phase, numberOfComponents, - // temperature, pressure, phasetype); + // temperature, pressure, pt); initQmix(); if (getInitType() > 2) { @@ -121,9 +133,9 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, } for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEUniquac) componentArray[i]) - .getGamma(phase, numberOfComponents, temperature, pressure, phasetype)); + .getGamma(phase, numberOfComponents, temperature, pressure, pt)); } - return R * phase.getTemperature() * GE * phase.getNumberOfMolesInPhase(); + return R * phase.getTemperature() * phase.getNumberOfMolesInPhase() * GE; } /** @@ -161,7 +173,7 @@ public void initQmixdN() { * getQmix. * * - * @param name a {@link String} object + * @param name a {@link java.lang.String} object * @return a double */ public double getQmix(String name) { @@ -179,8 +191,8 @@ public double getQmix(String name) { * getQmixdN. * * - * @param name a {@link String} object - * @return an array of {@link double} objects + * @param name a {@link java.lang.String} object + * @return an array of type double */ public double[] getQmixdN(String name) { // int test = ((ComponentGEUnifac) componentArray[0]).getUnifacGroups().length; diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java index 899c18dc9f..ce2b236542 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquac.java @@ -6,8 +6,11 @@ package neqsim.thermo.phase; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentGEInterface; import neqsim.thermo.component.ComponentGEUniquac; +import neqsim.util.exception.IsNaNException; +import neqsim.util.exception.TooManyIterationsException; /** *@@ -33,7 +36,7 @@ public class PhaseGEUniquac extends PhaseGE { */ public PhaseGEUniquac() { super(); - componentArray = new ComponentGEInterface[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentGEInterface[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; } /** @@ -42,10 +45,10 @@ public PhaseGEUniquac() { *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGEUniquac(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -64,10 +67,28 @@ public PhaseGEUniquac(PhaseInterface phase, double[][] alpha, double[][] Dij, St } } + /** {@inheritDoc} */ + @Override + public void setAlpha(double[][] alpha) { + throw new UnsupportedOperationException("Unimplemented method 'setAlpha'"); + } + + /** {@inheritDoc} */ + @Override + public void setDij(double[][] Dij) { + throw new UnsupportedOperationException("Unimplemented method 'setDij'"); + } + + /** {@inheritDoc} */ + @Override + public void setDijT(double[][] DijT) { + throw new UnsupportedOperationException("Unimplemented method 'setDijT'"); + } + /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGEUniquac(name, moles, molesInPhase, compNumber); } @@ -81,21 +102,28 @@ public double getGibbsEnergy() { @Override public double getExcessGibbsEnergy() { // GE = getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, - // phaseType); + // pt); return GE; } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() * Math.log(((ComponentGEInterface) componentArray[i]).getGamma(phase, numberOfComponents, - temperature, pressure, phasetype, alpha, Dij, intparam, mixRule)); + temperature, pressure, pt, alpha, Dij, intparam, mixRule)); } return R * temperature * numberOfMolesInPhase * GE; } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) + throws IsNaNException, TooManyIterationsException { + throw new UnsupportedOperationException("Unimplemented method 'molarVolume'"); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java index 89a8834938..7a9b713151 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEUniquacmodifiedHV.java @@ -29,7 +29,8 @@ public PhaseGEUniquacmodifiedHV() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); + // todo: does not work? does not add component. // componentArray[compNumber] = new ComponentGEUniquacmodifiedHV(name, moles, molesInPhase, // compNumber); // creates PhaseGEUniquac type component @@ -38,15 +39,14 @@ public void addComponent(String name, double moles, double molesInPhase, int com /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { double GE = 0; /* * ComponentGEInterface[] comp_Array = (ComponentGEInterface[]) this.getcomponentArray(); - * + * * for (int i = 0; i < numberOfComponents; i++) { GE = GE + comp_Array[i].getx() * - * Math.log(comp_Array[i].getGamma(phase, numberOfComponents, temperature, pressure, - * phasetype)); } + * Math.log(comp_Array[i].getGamma(phase, numberOfComponents, temperature, pressure, pt)); } */ return R * temperature * GE * numberOfMolesInPhase; diff --git a/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java b/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java index 593584acda..d79b79a1ea 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java +++ b/src/main/java/neqsim/thermo/phase/PhaseGEWilson.java @@ -1,6 +1,9 @@ package neqsim.thermo.phase; +import neqsim.thermo.ThermodynamicModelSettings; import neqsim.thermo.component.ComponentGEWilson; +import neqsim.util.exception.IsNaNException; +import neqsim.util.exception.TooManyIterationsException; /** *@@ -22,7 +25,7 @@ public class PhaseGEWilson extends PhaseGE { */ public PhaseGEWilson() { super(); - componentArray = new ComponentGEWilson[MAX_NUMBER_OF_COMPONENTS]; + componentArray = new ComponentGEWilson[ThermodynamicModelSettings.MAX_NUMBER_OF_COMPONENTS]; } /** @@ -31,10 +34,10 @@ public PhaseGEWilson() { *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public PhaseGEWilson(PhaseInterface phase, double[][] alpha, double[][] Dij, String[][] mixRule, double[][] intparam) { @@ -49,10 +52,28 @@ public PhaseGEWilson(PhaseInterface phase, double[][] alpha, double[][] Dij, Str } } + /** {@inheritDoc} */ + @Override + public void setAlpha(double[][] alpha) { + throw new UnsupportedOperationException("Unimplemented method 'setAlpha'"); + } + + /** {@inheritDoc} */ + @Override + public void setDij(double[][] Dij) { + throw new UnsupportedOperationException("Unimplemented method 'setDij'"); + } + + /** {@inheritDoc} */ + @Override + public void setDijT(double[][] DijT) { + throw new UnsupportedOperationException("Unimplemented method 'setDijT'"); + } + /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentGEWilson(name, moles, molesInPhase, compNumber); } @@ -72,14 +93,14 @@ public double getGibbsEnergy() { @Override public double getExcessGibbsEnergy() { // GE = getExcessGibbsEnergy(this, numberOfComponents, temperature, pressure, - // phaseType); + // pt); return GE; } /** {@inheritDoc} */ @Override public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, - double temperature, double pressure, int phasetype) { + double temperature, double pressure, PhaseType pt) { GE = 0; for (int i = 0; i < numberOfComponents; i++) { GE += phase.getComponents()[i].getx() @@ -88,4 +109,11 @@ public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, return R * temperature * numberOfMolesInPhase * GE; } + + /** {@inheritDoc} */ + @Override + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) + throws IsNaNException, TooManyIterationsException { + throw new UnsupportedOperationException("Unimplemented method 'molarVolume'"); + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseHydrate.java b/src/main/java/neqsim/thermo/phase/PhaseHydrate.java index 240639a53a..e49a1ddefd 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseHydrate.java +++ b/src/main/java/neqsim/thermo/phase/PhaseHydrate.java @@ -36,7 +36,7 @@ public PhaseHydrate() { * Constructor for PhaseHydrate. * * - * @param fluidModel a {@link String} object + * @param fluidModel a {@link java.lang.String} object */ public PhaseHydrate(String fluidModel) { if (fluidModel.isEmpty()) { @@ -64,7 +64,7 @@ public PhaseHydrate clone() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { double sum = 1.0; @@ -83,7 +83,7 @@ public double molarVolume(double pressure, double temperature, double A, double /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); // componentArray[compNumber] = new ComponentHydrateStatoil(name, moles, molesInPhase, // compNumber); if (hydrateModel.equals("CPAHydrateModel")) { @@ -102,9 +102,9 @@ public void addComponent(String name, double moles, double molesInPhase, int com /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); setType(PhaseType.HYDRATE); } @@ -126,4 +126,10 @@ public void setSolidRefFluidPhase(PhaseInterface refPhase) { } } } + + /** {@inheritDoc} */ + @Override + public double getSoundSpeed() { + return Double.NaN; + } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseInterface.java b/src/main/java/neqsim/thermo/phase/PhaseInterface.java index 01c9147c19..c2861712b0 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseInterface.java +++ b/src/main/java/neqsim/thermo/phase/PhaseInterface.java @@ -21,38 +21,22 @@ public interface PhaseInterface extends ThermodynamicConstantsInterface, Cloneable { /** *- * addcomponent. + * Add component to component array and update moles variables. *
* * @param name Name of component. - * @param moles a double - * @param molesInPhase a double - * @param compNumber a int + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. + * @param compIndex Index number of component in phase object component array. */ - public void addComponent(String name, double moles, double molesInPhase, int compNumber); - - /** - *- * addcomponent. - *
- * - * @param name Name of component. - * @param moles a double - * @param molesInPhase a double - * @param compNumber a int - * @deprecated Replaced by {@link addComponent} - */ - @Deprecated - public default void addcomponent(String name, double moles, double molesInPhase, int compNumber) { - this.addComponent(name, moles, molesInPhase, compNumber); - } + public void addComponent(String name, double moles, double molesInPhase, int compIndex); /** ** setMoleFractions. *
* - * @param x an array of {@link double} objects + * @param x an array of type double */ public void setMoleFractions(double[] x); @@ -109,7 +93,7 @@ public default void addcomponent(String name, double moles, double molesInPhase, /** * Returns the mole composition vector in unit mole fraction. * - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMolarComposition(); @@ -227,10 +211,13 @@ public default double getGamma2() { /** *- * init. + * Init using current phase properties. *
*/ - public void init(); + public default void init() { + init(getNumberOfMolesInPhase() / getBeta(), getNumberOfComponents(), getInitType(), getType(), + getBeta()); + } /** *@@ -239,12 +226,12 @@ public default double getGamma2() { * * @param totalNumberOfMoles Total number of moles in all phases of Stream. * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. + * @param initType a int. Use 0 to init, and 1 to reset. * @param beta Mole fraction of this phase in system. */ - public default void init(double totalNumberOfMoles, int numberOfComponents, int type, + public default void init(double totalNumberOfMoles, int numberOfComponents, int initType, double beta) { - init(totalNumberOfMoles, numberOfComponents, type, getType(), beta); + init(totalNumberOfMoles, numberOfComponents, initType, getType(), beta); } /** @@ -254,31 +241,13 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * * @param totalNumberOfMoles Total number of moles in all phases of Stream. * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. + * @param initType a int. Use 0 to init, and 1 to reset. * @param pt Type of phase. * @param beta Mole fraction of this phase in system. */ - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta); - /** - *
- * init. - *
- * - * @param totalNumberOfMoles Total number of moles in system. - * @param numberOfComponents Number of components in system. - * @param type a int. Use 0 to init, and 1 to reset. - * @param ptNumber Phase type index. - * @param beta Mole fraction of this phase in system. - * @deprecated Replace with init-function using PhaseType input. - */ - @Deprecated - public default void init(double totalNumberOfMoles, int numberOfComponents, int type, - int ptNumber, double beta) { - init(totalNumberOfMoles, numberOfComponents, type, PhaseType.byValue(ptNumber), beta); - } - /** ** initPhysicalProperties. @@ -291,7 +260,7 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * initPhysicalProperties. *
* - * @param type a {@link String} object + * @param type a {@link java.lang.String} object */ public void initPhysicalProperties(String type); @@ -360,13 +329,20 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int /** *- * getcomponentArray. + * Get component array of Phase. *
* * @return an array of {@link neqsim.thermo.component.ComponentInterface} objects */ public ComponentInterface[] getcomponentArray(); + /** + * Get normalized names of components in phase. + * + * @return Array of names of components in phase. + */ + public String[] getComponentNames(); + /** ** getMass. @@ -393,6 +369,14 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int */ public double getMolarVolume(); + /** + * method to return molar volume of the fluid: eventual volume correction included. + * + * @param unit Supported units are m3/mol, litre/mol + * @return molar volume volume in unit + */ + public double getMolarVolume(String unit); + /** * method to return flow rate of a phase. * @@ -423,7 +407,7 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * method to get GERG properties of a phase using the GERG-2008 EoS. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getProperties_GERG2008(); @@ -444,15 +428,14 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int /** *- * removeComponent. + * Remove component from Phase. *
* - * @param name a {@link String} object - * @param moles a double - * @param molesInPhase a double - * @param compNumber a int + * @param name Name of component. + * @param moles Total number of moles of component. + * @param molesInPhase Number of moles in phase. */ - public void removeComponent(String name, double moles, double molesInPhase, int compNumber); + public void removeComponent(String name, double moles, double molesInPhase); /** *@@ -469,7 +452,7 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int * getFugacity. *
* - * @param compName a {@link String} object + * @param compName a {@link java.lang.String} object * @return a double */ public double getFugacity(String compName); @@ -527,33 +510,6 @@ public default void init(double totalNumberOfMoles, int numberOfComponents, int */ public double getMixGibbsEnergy(); - /** - *- * getExessGibbsEnergy. - *
- * - * @return a double - * @deprecated Replaced by {@link getExcessGibbsEnergy}. - */ - @Deprecated - public default double getExessGibbsEnergy() { - return getExcessGibbsEnergy(); - } - - /** - *- * getExessGibbsEnergySymetric. - *
- * - * - * @return a double - * @deprecated Replace by {@link getExcessGibbsEnergySymetric}. - */ - @Deprecated - public default double getExessGibbsEnergySymetric() { - return getExcessGibbsEnergySymetric(); - } - /** ** getExcessGibbsEnergy. @@ -652,7 +608,7 @@ public default double getExessGibbsEnergySymetric() { * getWtFrac. *
* - * @param componentName a {@link String} object + * @param componentName a {@link java.lang.String} object * @return a double */ public double getWtFrac(String componentName); @@ -662,7 +618,7 @@ public default double getExessGibbsEnergySymetric() { * setMixingRuleGEModel. * * - * @param name a {@link String} object + * @param name a {@link java.lang.String} object */ public void setMixingRuleGEModel(String name); @@ -767,9 +723,9 @@ public default double getExessGibbsEnergySymetric() { *
* Change the number of moles of component of phase,i.e., numberOfMolesInPhase
but do
* not change the total number of moles of component in system.
- *
+ *
* NB! Phase fraction beta
is not updated by this method. Must be done separately to
- * keep consistency between phase and component calculation of of total number of moles in system.
+ * keep consistency between phase and component calculation of total number of moles in system.
*
numberOfMolesInPhase
, and
* total number of moles of component in system, i.e., numberOfMoles
with the same
* amount.
- *
+ *
* NB! Phase fraction beta
is not updated by this method. Must be done separately to
- * keep consistency between phase and component calculation of of total number of moles in system.
+ * keep consistency between phase and component calculation of total number of moles in system.
*
*
* @param component Component number to change
@@ -802,9 +758,9 @@ public default void addMolesChemReac(int component, double dn) {
* Component
properties for the number of moles of component of phase, i.e.,
* numberOfMolesInPhase
, and total number of moles of component in system, i.e.,
* numberOfMoles
with separate amounts.
- *
+ *
* NB! Phase fraction beta
is not updated by this method. Must be done separately to
- * keep consistency between phase and component calculation of of total number of moles in system.
+ * keep consistency between phase and component calculation of total number of moles in system.
*
*
* @param component Component number to change
@@ -889,12 +845,12 @@ public default void addMolesChemReac(int component, double dn) {
* @param temperature a double
* @param A a double
* @param B a double
- * @param phase a int
+ * @param pt the PhaseType of the phase
* @return a double
* @throws neqsim.util.exception.IsNaNException if any.
* @throws neqsim.util.exception.TooManyIterationsException if any.
*/
- double molarVolume(double pressure, double temperature, double A, double B, int phase)
+ double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt)
throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException;
/**
@@ -1081,7 +1037,7 @@ public default void addMolesChemReac(int component, double dn) {
/**
* method to return phase enthalpy in a specified unit.
*
- * @param unit Supported units are J, J/mol, J/kg and kJ/kg
+ * @param unit Supported units are J, J/mol, kJ/kmol, J/kg and kJ/kg
* @return enthalpy in specified unit
*/
public double getEnthalpy(String unit);
@@ -1109,32 +1065,13 @@ public default void addMolesChemReac(int component, double dn) {
public double getViscosity();
/**
- * method to return viscosity og the phase in a specified unit.
+ * method to return viscosity of the phase in a specified unit.
*
- * @param unit Supported units are kg/msec, cP (centipoise)
+ * @param unit Supported units are kg/msec, Pas, cP (centipoise)
* @return viscosity in specified unit
*/
public double getViscosity(String unit);
- /**
- * method to return conductivity of a phase.
- *
- * @return conductivity in unit W/m*K
- * @deprecated use {@link #getThermalConductivity()} instead.
- */
- @Deprecated
- public double getConductivity();
-
- /**
- * method to return conductivity in a specified unit.
- *
- * @param unit Supported units are W/mK, W/cmK
- * @return conductivity in specified unit
- * @deprecated use {@link #getThermalConductivity(String unit)} instead.
- */
- @Deprecated
- public double getConductivity(String unit);
-
/**
* method to return conductivity of a phase.
*
@@ -1422,6 +1359,14 @@ public default void addMolesChemReac(int component, double dn) {
*/
public double getTemperature();
+ /**
+ * method to return temperature in a specified unit.
+ *
+ * @param unit Supported units are K, C, R
+ * @return temperature in specified unit
+ */
+ public double getTemperature(String unit);
+
/**
* Get pressure of phase.
*
@@ -1432,7 +1377,7 @@ public default void addMolesChemReac(int component, double dn) {
/**
* Get pressure of phase in a specified unit.
*
- * @param unit Supported units are bara, barg, Pa and MPa
+ * @param unit Supported units are bara, barg, Pa, MPa, psi, psia, psig
* @return pressure in specified unit
*/
public double getPressure(String unit);
@@ -1444,6 +1389,14 @@ public default void addMolesChemReac(int component, double dn) {
*/
public double getMolarMass();
+ /**
+ * method to get molar mass of a fluid phase.
+ *
+ * @param unit Supported units are kg/mol, gr/mol
+ * @return molar mass in specified unit
+ */
+ public double getMolarMass(String unit);
+
/**
* * getInternalEnergy. @@ -1890,11 +1843,11 @@ public default void addMolesChemReac(int component, double dn) { *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param alpha an array of {@link double} objects - * @param Dij an array of {@link double} objects - * @param DijT an array of {@link double} objects - * @param mixRule an array of {@link String} objects - * @param intparam an array of {@link double} objects + * @param alpha an array of type double + * @param Dij an array of type double + * @param DijT an array of type double + * @param mixRule an array of {@link java.lang.String} objects + * @param intparam an array of type double */ public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, double[][] DijT, String[][] mixRule, double[][] intparam); @@ -1913,38 +1866,12 @@ public void setParams(PhaseInterface phase, double[][] alpha, double[][] Dij, do */ public void setType(PhaseType pt); - /** - *- * Getter for property phasetype as int. - *
- * - * @return a int - * @deprecated Replace with {@link getType} - */ - @Deprecated - public default int getPhaseType() { - return getType().getValue(); - } - - /** - *- * Setter for property phaseType. - *
- * - * @param phaseType Phasetype as int. - * @deprecated Replace with {@link setType} - */ - @Deprecated - public default void setPhaseType(int phaseType) { - setType(PhaseType.byValue(phaseType)); - } - /** ** Getter for property phaseTypeName. *
* - * @return a {@link String} object + * @return a {@link java.lang.String} object */ public default String getPhaseTypeName() { return getType().getDesc(); @@ -1955,7 +1882,7 @@ public default String getPhaseTypeName() { * Setter for property phaseTypeName. * * - * @param phaseTypeName a {@link String} object + * @param phaseTypeName a {@link java.lang.String} object */ public default void setPhaseTypeName(String phaseTypeName) { setType(PhaseType.byDesc(phaseTypeName)); @@ -2000,14 +1927,23 @@ public default void setPhaseTypeName(String phaseTypeName) { public double getActivityCoefficientUnSymetric(int k); /** - *- * hasComponent. - *
+ * Verify if phase has a component. * - * @param name a {@link String} object - * @return a boolean + * @param name Name of component to look for. NB! Converts name to normalized name. + * @return True if component is found. + */ + public default boolean hasComponent(String name) { + return hasComponent(name, true); + } + + /** + * Verify if phase has a component. + * + * @param name Name of component to look for. + * @param normalized Set true to convert input name to normalized component name. + * @return True if component is found. */ - public boolean hasComponent(String name); + public boolean hasComponent(String name, boolean normalized); /** *@@ -2044,4 +1980,27 @@ public default void setPhaseTypeName(String phaseTypeName) { * @return speed of sound in m/s */ public double getSoundSpeed(); + + /** + * method to get the speed of sound of a system. The sound speed is implemented based on a molar + * average over the phases + * + * @param unit Supported units are m/s, km/h + * @return speed of sound in m/s + */ + public double getSoundSpeed(String unit); + + /** + * method to return name of thermodynamic model + * + * @return String model name + */ + public String getModelName(); + + /** + * method to return Z volume corrected gas compressibility + * + * @return double Z volume corrected + */ + public double getZvolcorr(); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseKentEisenberg.java b/src/main/java/neqsim/thermo/phase/PhaseKentEisenberg.java index 3821437f96..dce22ef66f 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseKentEisenberg.java +++ b/src/main/java/neqsim/thermo/phase/PhaseKentEisenberg.java @@ -25,7 +25,7 @@ public PhaseKentEisenberg() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentKentEisenberg(name, moles, molesInPhase, compNumber); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java index d4b0f09030..6a5c9f3752 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEos.java @@ -92,10 +92,10 @@ public void reInitFurstParam() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type == 0) { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType == 0) { electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); } } @@ -192,7 +192,7 @@ public void volInit() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentModifiedFurstElectrolyteEos(name, moles, molesInPhase, compNumber); } @@ -410,7 +410,7 @@ public double calcXLR() { * @return a double */ public double calcGammaLRdV() { - if (pt.getValue() == 1) { + if (pt == PhaseType.GAS) { return 0.0; } // return 0.0; // problem ved ren komponent @@ -432,7 +432,7 @@ public double calcGammaLRdV() { * @return a double */ public double calcShieldingParameter() { - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; double df = 0; double f = 0; int ions = 0; @@ -467,7 +467,7 @@ public double calcShieldingParameter() { } // public double calcShieldingParameter2(){ - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; // double df=0, f=0; // int ions=0; @@ -497,12 +497,12 @@ public double calcShieldingParameter() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { // double BonV = phase== 0 ? // 2.0/(2.0+temperature/getPseudoCriticalTemperature()):0.1*pressure*getB()/(numberOfMolesInPhase*temperature*R); - double BonV = phase == 0 ? 0.99 : 1e-5; + double BonV = pt == PhaseType.LIQUID ? 0.99 : 1e-5; if (BonV < 0) { BonV = 1.0e-6; @@ -547,7 +547,7 @@ public double molarVolume(double pressure, double temperature, double A, double double hnew = h + d2 * -h / d1; if (Math.abs(hnew) > Math.abs(h)) { logger.info("volume correction needed...."); - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -573,8 +573,8 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + - // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " + // if(pt==0) System.out.println("density " + getDensity()); //"BonV: " + + // BonV + " "+" itert: " + iterations +" " + " phase " + pt+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); @@ -947,7 +947,7 @@ public double XLRdndn(int i, int j) { * @return a double */ public double XLRdGammaLR() { - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; double ans = 0.0; double ans2 = 0.0; for (int i = 0; i < numberOfComponents; i++) { @@ -1719,7 +1719,7 @@ public double getDielectricConstant() { * setFurstIonicCoefficient. *
* - * @param params an array of {@link double} objects + * @param params an array of type double */ public void setFurstIonicCoefficient(double[] params) {} diff --git a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java index c612b3ba24..de1b666e99 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java +++ b/src/main/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004.java @@ -108,10 +108,10 @@ public PhaseModifiedFurstElectrolyteEosMod2004 clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type == 0) { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType == 0) { electrolyteMixingRule = mixSelect.getElectrolyteMixingRule(this); } } @@ -192,7 +192,7 @@ public void volInit() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new neqsim.thermo.component.ComponentModifiedFurstElectrolyteEosMod2004(name, moles, molesInPhase, compNumber); @@ -411,7 +411,7 @@ public double calcXLR() { * @return a double */ public double calcGammaLRdV() { - if (pt.getValue() == 1) { + if (pt == PhaseType.GAS) { return 0.0; } // return 0.0; // problem ved ren komponent @@ -433,7 +433,7 @@ public double calcGammaLRdV() { * @return a double */ public double calcShieldingParameter() { - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; double df = 0; double f = 0; int ions = 0; @@ -468,7 +468,7 @@ public double calcShieldingParameter() { } // public double calcShieldingParameter2(){ - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; // double df=0, f=0; // int ions=0; @@ -503,12 +503,12 @@ public double calcShieldingParameter() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { // double BonV = phase== 0 ? // 2.0/(2.0+temperature/getPseudoCriticalTemperature()):0.1*pressure*getB()/(numberOfMolesInPhase*temperature*R); - double BonV = phase == 0 ? 0.99 : 1e-5; + double BonV = pt == PhaseType.LIQUID ? 0.99 : 1e-5; if (BonV < 0) { BonV = 1.0e-6; @@ -553,7 +553,7 @@ public double molarVolume(double pressure, double temperature, double A, double double hnew = h + d2 * -h / d1; if (Math.abs(hnew) > Math.abs(h)) { logger.info("volume correction needed...."); - BonV = phase == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -579,8 +579,8 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + - // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " + // if(pt==0) System.out.println("density " + getDensity()); //"BonV: " + + // BonV + " "+" itert: " + iterations +" " + " phase " + pt+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); @@ -951,7 +951,7 @@ public double XLRdndn(int i, int j) { * @return a double */ public double XLRdGammaLR() { - // if(phaseType==1) return 0.0; + // if(pt==1) return 0.0; double ans = 0.0; double ans2 = 0.0; for (int i = 0; i < numberOfComponents; i++) { @@ -1723,7 +1723,7 @@ public double getDielectricConstant() { * setFurstIonicCoefficient. * * - * @param params an array of {@link double} objects + * @param params an array of type double */ public void setFurstIonicCoefficient(double[] params) {} diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java index cacc66cb4c..6952f1c3a1 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFT.java @@ -40,43 +40,43 @@ public class PhasePCSAFT extends PhaseSrkEos { int useDISP1 = 1; int useDISP2 = 1; - private double[][] aConstSAFT = { + protected double[][] aConstSAFT = { {0.9105631445, 0.6361281449, 2.6861347891, -26.547362491, 97.759208784, -159.59154087, 91.297774084}, {-0.3084016918, 0.1860531159, -2.5030047259, 21.419793629, -65.255885330, 83.318680481, -33.746922930}, {-0.0906148351, 0.4527842806, 0.5962700728, -1.7241829131, -4.1302112531, 13.776631870, -8.6728470368}}; - private double[][] bConstSAFT = { + protected double[][] bConstSAFT = { {0.7240946941, 2.2382791861, -4.0025849485, -21.003576815, 26.855641363, 206.55133841, -355.60235612}, {-0.5755498075, 0.6995095521, 3.8925673390, -17.215471648, 192.67226447, -161.82646165, -165.20769346}, {0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077, -29.666905585}}; - private double F1dispVolTerm = 1.0; - private double F1dispSumTerm = 1.0; - private double F1dispI1 = 1.0; - private double F2dispI2 = 1.0; - private double F2dispZHC = 1.0; - private double F2dispZHCdN = 1.0; - private double F2dispZHCdm = 1.0; - private double F2dispZHCdV = 1.0; - private double F2dispI2dVdV = 0.0; - private double F2dispZHCdVdV = 0.0; - private double F1dispI1dNdN = 1.0; - private double F1dispVolTermdV = 1.0; - private double F1dispVolTermdVdV = 1.0; - private double F1dispI1dN = 1.0; - private double F1dispI1dm = 1.0; - private double F1dispI1dV = 1.0; - private double F2dispI2dV = 1.0; - private double F2dispI2dN = 1.0; - private double F2dispI2dm = 1.0; - private double F2dispSumTerm = 0.0; - private double F2dispZHCdNdN = 1.0; - private double F2dispI2dNdN = 1.0; - private double F1dispI1dVdV = 0.0; + protected double F1dispVolTerm = 1.0; + protected double F1dispSumTerm = 1.0; + protected double F1dispI1 = 1.0; + protected double F2dispI2 = 1.0; + protected double F2dispZHC = 1.0; + protected double F2dispZHCdN = 1.0; + protected double F2dispZHCdm = 1.0; + protected double F2dispZHCdV = 1.0; + protected double F2dispI2dVdV = 0.0; + protected double F2dispZHCdVdV = 0.0; + protected double F1dispI1dNdN = 1.0; + protected double F1dispVolTermdV = 1.0; + protected double F1dispVolTermdVdV = 1.0; + protected double F1dispI1dN = 1.0; + protected double F1dispI1dm = 1.0; + protected double F1dispI1dV = 1.0; + protected double F2dispI2dV = 1.0; + protected double F2dispI2dN = 1.0; + protected double F2dispI2dm = 1.0; + protected double F2dispSumTerm = 0.0; + protected double F2dispZHCdNdN = 1.0; + protected double F2dispI2dNdN = 1.0; + protected double F1dispI1dVdV = 0.0; /** *@@ -103,21 +103,21 @@ public PhasePCSAFT clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentPCSAFT(name, moles, molesInPhase, compNumber); } /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type > 0) { + if (initType > 0) { for (int i = 0; i < numberOfComponents; i++) { componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, - numberOfComponents, type); + numberOfComponents, initType); } } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } /** @@ -334,7 +334,6 @@ public double calcmSAFT() { */ public double calcF1dispSumTerm() { double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { temp1 += @@ -358,7 +357,6 @@ public double calcF1dispSumTerm() { */ public double calcF2dispSumTerm() { double temp1 = 0.0; - for (int i = 0; i < numberOfComponents; i++) { for (int j = 0; j < numberOfComponents; j++) { temp1 += getComponent(i).getNumberOfMolesInPhase() @@ -499,7 +497,7 @@ public double calcF2dispI2() { * * @param i a int * @param m a double - * @param ab an array of {@link double} objects + * @param ab an array of type double * @return a double */ public double getaSAFT(int i, double m, double[][] ab) { @@ -513,7 +511,7 @@ public double getaSAFT(int i, double m, double[][] ab) { * * @param i a int * @param m a double - * @param ab an array of {@link double} objects + * @param ab an array of type double * @return a double */ public double getaSAFTdm(int i, double m, double[][] ab) { @@ -1155,11 +1153,12 @@ public double molarVolume22(double pressure, double temperature, double A, doubl /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // double BonV = phase== 0 ? 0.99:1e-5; if (BonV < 0) { BonV = 1.0e-6; @@ -1216,8 +1215,8 @@ public double molarVolume(double pressure, double temperature, double A, double throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); } - // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + - // BonV + " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " + // if(pt==0) System.out.println("density " + getDensity()); //"BonV: " + + // BonV + " "+" itert: " + iterations +" " + " phase " + pt+ " " + h + " // " +dh + " B " + Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" // + fVV()); diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java index 7333e46b5e..505e7005ec 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFTRahmat.java @@ -15,128 +15,31 @@ */ public class PhasePCSAFTRahmat extends PhasePCSAFT { private static final long serialVersionUID = 1000; - - double nSAFT = 1.0; - double dnSAFTdV = 1.0; - - double dnSAFTdVdV = 1.0; + static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class); double dnSAFTdVdVdV = 1.0; - double dmeanSAFT = 0.0; - double dSAFT = 1.0; - double mSAFT = 1.0; - double mdSAFT = 1.0; - double nmSAFT = 1.0; - double mmin1SAFT = 1.0; - double ghsSAFT = 1.0; - double aHSSAFT = 1.0; - double volumeSAFT = 1.0; - double daHCSAFTdN = 1.0; - double daHSSAFTdN = 1.0; - - double dgHSSAFTdN = 1.0; - - double daHSSAFTdNdN = 1.0; - - double dgHSSAFTdNdN = 1.0; - double daHSSAFTdNdNdN = 1.0; - double dgHSSAFTdNdNdN = 1.0; // by Rahmat double dNSAFTdT = 1.0; double dF1dispVolTermdT = 0.0; double dF1dispI1dT = 1.0; - double dF2dispI2dT = 1.0; - double dF2dispZHCdT = 1.0; double dF1dispSumTermdT = 1.0; - double dF2dispSumTermdT = 1.0; - - int useHS = 1; - - int useDISP1 = 1; - - int useDISP2 = 1; - - private double[][] aConstSAFT = { - {0.9105631445, 0.6361281449, 2.6861347891, -26.547362491, 97.759208784, -159.59154087, - 91.297774084}, - {-0.3084016918, 0.1860531159, -2.5030047259, 21.419793629, -65.255885330, 83.318680481, - -33.746922930}, - {-0.0906148351, 0.4527842806, 0.5962700728, -1.7241829131, -4.1302112531, 13.776631870, - -8.6728470368}}; - private double[][] bConstSAFT = { - {0.7240946941, 2.2382791861, -4.0025849485, -21.003576815, 26.855641363, 206.55133841, - -355.60235612}, - {-0.5755498075, 0.6995095521, 3.8925673390, -17.215471648, 192.67226447, -161.82646165, - -165.20769346}, - {0.0976883116, -0.2557574982, -9.1558561530, 20.642075974, -38.804430052, 93.626774077, - -29.666905585}}; - private double F1dispVolTerm = 1.0; - - private double F1dispSumTerm = 1.0; - - private double F1dispI1 = 1.0; - - private double F2dispI2 = 1.0; - - private double F2dispZHC = 1.0; - - private double F2dispZHCdN = 1.0; - - private double F2dispZHCdm = 1.0; - - private double F2dispZHCdV = 1.0; - - private double F2dispI2dVdV; - - private double F2dispI2dVdVdV = 0.0; - - private double F2dispZHCdVdV = 1.0; - - private double F2dispZHCdVdVdV = 1.0; - - private double F1dispI1dNdN = 1.0; - - private double F1dispI1dNdNdN = 1.0; - - private double F1dispVolTermdV = 1.0; - - private double F1dispVolTermdVdV = 1.0; - - private double F1dispI1dN = 1.0; - - private double F1dispI1dm = 1.0; - - private double F1dispI1dV = 1.0; - - private double F2dispI2dV = 1.0; - - private double F2dispI2dN = 1.0; - - private double F2dispI2dm = 1.0; - - private double F2dispSumTerm = 0.0; - - private double F2dispZHCdNdN = 1.0; - - private double F2dispZHCdNdNdN = 1.0; - - private double F2dispI2dNdN = 1.0; - - private double F2dispI2dNdNdN = 1.0; - - private double F1dispI1dVdV = 1.0; - - private double F1dispI1dVdVdV = 1.0; - - private double F1dispVolTermdVdVdV = 1.0; - static Logger logger = LogManager.getLogger(PhasePCSAFTRahmat.class); + protected double F2dispI2dVdV; + protected double F2dispI2dVdVdV = 0.0; + protected double F2dispZHCdVdV = 1.0; + protected double F2dispZHCdVdVdV = 1.0; + protected double F1dispI1dNdNdN = 1.0; + protected double F2dispZHCdNdNdN = 1.0; + protected double F2dispI2dNdNdN = 1.0; + protected double F1dispI1dVdV = 1.0; + protected double F1dispI1dVdVdV = 1.0; + protected double F1dispVolTermdVdVdV = 1.0; /** *
@@ -163,19 +66,22 @@ public PhasePCSAFTRahmat clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentPCSAFT(name, moles, molesInPhase, compNumber); } /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { + // missing? + // if (initType > 0) { for (int i = 0; i < numberOfComponents; i++) { componentArray[i].Finit(this, temperature, pressure, totalNumberOfMoles, beta, - numberOfComponents, type); + numberOfComponents, initType); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + // } + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } /** {@inheritDoc} */ @@ -858,42 +764,6 @@ public double calcdSAFT() { return temp1 / getNumberOfMolesInPhase(); } - /** {@inheritDoc} */ - @Override - public double getNSAFT() { - return nSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setNSAFT(double nSAFT) { - this.nSAFT = nSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getDSAFT() { - return dSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setDSAFT(double dSAFT) { - this.dSAFT = dSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getGhsSAFT() { - return ghsSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setGhsSAFT(double ghsSAFT) { - this.ghsSAFT = ghsSAFT; - } - /** {@inheritDoc} */ @Override public double F_HC_SAFT() { @@ -1217,84 +1087,6 @@ public double dFdVdVdV() { + useDISP2 * dF_DISP2_SAFTdVdVdV()) * 1.0e-20; } - /** {@inheritDoc} */ - @Override - public double getmdSAFT() { - return mdSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setmdSAFT(double mdSAFT) { - this.mdSAFT = mdSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getmSAFT() { - return mSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setmSAFT(double mSAFT) { - this.mSAFT = mSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getAHSSAFT() { - return aHSSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setAHSSAFT(double aHSSAFT) { - this.aHSSAFT = aHSSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getMmin1SAFT() { - return mmin1SAFT; - } - - /** {@inheritDoc} */ - @Override - public void setMmin1SAFT(double mmin1SAFT) { - this.mmin1SAFT = mmin1SAFT; - } - - /** {@inheritDoc} */ - @Override - public double getVolumeSAFT() { - return volumeSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setVolumeSAFT(double volumeSAFT) { - this.volumeSAFT = volumeSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getDgHSSAFTdN() { - return dgHSSAFTdN; - } - - /** {@inheritDoc} */ - @Override - public void setDgHSSAFTdN(double dgHSSAFTdN) { - this.dgHSSAFTdN = dgHSSAFTdN; - } - - /** {@inheritDoc} */ - @Override - public double getDnSAFTdV() { - return dnSAFTdV; - } - // added by rahmat /** *
@@ -1319,79 +1111,13 @@ public double getdDSAFTdT() { /** {@inheritDoc} */ @Override - public void setDnSAFTdV(double dnSAFTdV) { - this.dnSAFTdV = dnSAFTdV; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispVolTerm() { - return F1dispVolTerm; - } - - /** {@inheritDoc} */ - @Override - public void setF1dispVolTerm(double F1dispVolTerm) { - this.F1dispVolTerm = F1dispVolTerm; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispSumTerm() { - return F1dispSumTerm; - } - - /** {@inheritDoc} */ - @Override - public double getF1dispI1() { - return F1dispI1; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispI2() { - return F2dispI2; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispI2(double F2dispI2) { - this.F2dispI2 = F2dispI2; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHC() { - return F2dispZHC; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispZHC(double F2dispZHC) { - this.F2dispZHC = F2dispZHC; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHCdN() { - return F2dispZHCdN; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispZHCdm() { - return F2dispZHCdm; - } - - /** {@inheritDoc} */ - @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // double BonV = phase== 0 ? 0.99:1e-5; - if (BonV < 0) { BonV = 1.0e-6; } @@ -1433,28 +1159,26 @@ public double molarVolume(double pressure, double temperature, double A, double * = 1.0 + Btemp/Math.pow(BonVold,2.0)*(Btemp/numberOfMolesInPhase*dFdVdV()); //dhh = * -2.0*Btemp/Math.pow(BonV,3.0)*(Btemp/numberOfMolesInPhase*dFdVdV())-Math.pow( * Btemp,2.0)/Math.pow(BonV,4.0)*(Btemp/numberOfMolesInPhase*dFdVdVdV()); - * + * * //made by Rahmat - * + * * BonV = BonVold - 0.5* (2* h * dh / ((2* Math.pow(dh,2) - h * dhh))); - * + * * double dBonV = BonV - BonVold; dhh = (dh - dhOld)/ dBonV; dhOld = dh; - * + * * hOld = h; - * - * + * * //d1 = - h/dh; //d2 = - dh/dhh; //BonV += d1; //*(1.0+0.5*-1.0); /* * if(Math.abs(d1/d2)<=1.0){ BonV += d1*(1.0+0.5*d1/d2); } else if(d1/d2<-1){ BonV += * d1*(1.0+0.5*-1.0); } else if(d1/d2>1){ BonV += d2; double hnew = h +d2*-h/d1; * if(Math.abs(hnew)>Math.abs(h)){ System.out.println("volume correction needed...."); BonV = * phase== 1 ? 2.0/(2.0+temperature/getPseudoCriticalTemperature()):pressure*getB()/( * numberOfMolesInPhase*temperature*R); } } - * + * * if(BonV>1){ BonV=1.0-1.0e-6; BonVold=10; } if (BonV < 0) { BonV = 1.0e-16; BonVold = 10; } */ // setMolarVolume(1.0 / BonV * Btemp / numberOfMolesInPhase); Z = pressure * getMolarVolume() / (R * temperature); - // System.out.println("BonV " + BonV); } while (Math.abs((oldMolarVolume - getMolarVolume()) / oldMolarVolume) > 1.0e-10 && iterations < 100); // while(Math.abs((BonV-BonVold)/BonV)>1.0e-10 && iterations<500); @@ -1464,57 +1188,14 @@ public double molarVolume(double pressure, double temperature, double A, double // System.out.println("iterations " + iterations); /* * if(BonV<0){ BonV = pressure*getB()/(numberOfMolesInPhase*temperature*R); setMolarVolume(1.0 / - * BonV * Btemp / numberOfMolesInPhase); Z = pressure*getMolarVolume()/(R*temperature); - * - * } if(iterations>=6000) throw new util.exception.TooManyIterationsException(); + * BonV * Btemp / numberOfMolesInPhase); Z = pressure*getMolarVolume()/(R*temperature); } + * if(iterations>=6000) throw new util.exception.TooManyIterationsException(); * if(Double.isNaN(getMolarVolume())) throw new util.exception.IsNaNException(); - * - * // if(phaseType==0) System.out.println("density " + getDensity()); //"BonV: " + BonV + - * " "+" itert: " + iterations +" " + " phase " + phaseType+ " " + h + " " +dh + " B " + - * Btemp + " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); + * + * // if(pt==0) System.out.println("density " + getDensity()); //"BonV: " + BonV + + * " "+" itert: " + iterations +" " + " phase " + pt+ " " + h + " " +dh + " B " + Btemp + + * " D " + Dtemp + " gv" + gV() + " fv " + fv() + " fvv" + fVV()); */ return getMolarVolume(); } - - /** {@inheritDoc} */ - @Override - public double getDmeanSAFT() { - return dmeanSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setDmeanSAFT(double dmeanSAFT) { - this.dmeanSAFT = dmeanSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getNmSAFT() { - return nmSAFT; - } - - /** {@inheritDoc} */ - @Override - public void setNmSAFT(double nmSAFT) { - this.nmSAFT = nmSAFT; - } - - /** {@inheritDoc} */ - @Override - public double getF2dispSumTerm() { - return F2dispSumTerm; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispSumTerm(double F2dispSumTerm) { - this.F2dispSumTerm = F2dispSumTerm; - } - - /** {@inheritDoc} */ - @Override - public void setF2dispZHCdm(double F2dispZHCdm) { - this.F2dispZHCdm = F2dispZHCdm; - } } diff --git a/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java b/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java index 82362a6b7e..c9e56ab833 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java +++ b/src/main/java/neqsim/thermo/phase/PhasePCSAFTa.java @@ -81,9 +81,9 @@ public void volInit() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type == 0) { + if (initType == 0) { selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; for (int i = 0; i < numberOfComponents; i++) { @@ -94,7 +94,7 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph } } do { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } while (!solveX()); } @@ -373,11 +373,12 @@ public double calc_lngni(int comp) { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phase) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phase == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // double BonV = phase== 0 ? 0.99:1e-5; if (BonV < 0) { @@ -453,12 +454,12 @@ public double molarVolume(double pressure, double temperature, double A, double } if (Double.isNaN(getMolarVolume())) { throw new neqsim.util.exception.IsNaNException(this, "molarVolume", "Molar volume"); - // if(phaseType==0) + // if(pt==0) // System.out.println("density " + // getDensity()); //"BonV: " + BonV + " // "+" itert: " + // iterations +" " + " phase " + - // phaseType+ " " + h + + // pt+ " " + h + // " +dh + " B " + Btemp + " D " + // Dtemp + " gv" + gV() // + " fv " + fv() + " fvv" + fVV()); diff --git a/src/main/java/neqsim/thermo/phase/PhasePrCPA.java b/src/main/java/neqsim/thermo/phase/PhasePrCPA.java index 113f687cb9..8a1bd7e72a 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePrCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhasePrCPA.java @@ -57,12 +57,12 @@ public PhasePrCPA clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { boolean Xsolved = true; int totiter = 0; do { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); // if(getPhaseType()==1) cpaon=0; totiter++; if (cpaon == 1) { @@ -75,14 +75,14 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph gcpavv = calc_lngVV(); gcpavvv = calc_lngVVV(); } - } while (Xsolved != true && totiter < 5); + } while (!Xsolved && totiter < 5); - if (type > 1) { + if (initType > 1) { hcpatotdT = calc_hCPAdT(); hcpatotdTdT = calc_hCPAdTdT(); } // System.out.println("tot iter " + totiter); - if (type == 0) { + if (initType == 0) { selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; for (int i = 0; i < numberOfComponents; i++) { @@ -404,7 +404,7 @@ public boolean solveX() { double err = .0; int iter = 0; try { - molarVolume(pressure, temperature, getA(), getB(), pt.getValue()); + molarVolume(pressure, temperature, getA(), getB(), pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } diff --git a/src/main/java/neqsim/thermo/phase/PhasePrEos.java b/src/main/java/neqsim/thermo/phase/PhasePrEos.java index cf6ffbf286..714f24e7fd 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePrEos.java +++ b/src/main/java/neqsim/thermo/phase/PhasePrEos.java @@ -43,7 +43,7 @@ public PhasePrEos clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentPR(name, moles, molesInPhase, compNumber); } } diff --git a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java index 2d24c5f368..02641bde54 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java +++ b/src/main/java/neqsim/thermo/phase/PhasePrEosvolcor.java @@ -10,7 +10,9 @@ import neqsim.thermo.component.ComponentPRvolcor; /** - *
PhasePrEosvolcor class.
+ *+ * PhasePrEosvolcor class. + *
* * @author Even Solbraa * @version $Id: $Id @@ -32,16 +34,17 @@ public PhasePrEosvolcor() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); loc_C = calcC(this, temperature, pressure, numberOfComponents); CT = calcCT(this, temperature, pressure, numberOfComponents); - } /** - *getCT.
+ *+ * getCT. + *
* * @return a double */ @@ -50,7 +53,9 @@ public double getCT() { } /** - *getCTT.
+ *+ * getCTT. + *
* * @return a double */ @@ -77,14 +82,15 @@ public double calcf() { public double dFdV() { // return super.dFdV(); return -numberOfMolesInPhase * gV() - getA() / temperature * fv(); - } // note that in future the next thre lines should be modified to handle various mixing rules for // the translation /** - *getcij.
+ *+ * getcij. + *
* * @param compArray a {@link neqsim.thermo.component.ComponentEosInterface} object * @param compArray2 a {@link neqsim.thermo.component.ComponentEosInterface} object @@ -96,7 +102,9 @@ public double getcij(ComponentEosInterface compArray, ComponentEosInterface comp } /** - *getcijT.
+ *+ * getcijT. + *
* * @param compArray a {@link neqsim.thermo.component.ComponentEosInterface} object * @param compArray2 a {@link neqsim.thermo.component.ComponentEosInterface} object @@ -108,7 +116,9 @@ public double getcijT(ComponentEosInterface compArray, ComponentEosInterface com } /** - *getcijTT.
+ *+ * getcijTT. + *
* * @param compi a {@link neqsim.thermo.component.ComponentPRvolcor} object * @param compj a {@link neqsim.thermo.component.ComponentPRvolcor} object @@ -121,7 +131,9 @@ public double getcijTT(ComponentPRvolcor compi, ComponentPRvolcor compj) { // @Override /** - *calcCi.
+ *+ * calcCi. + *
* * @param compNumb a int * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object @@ -145,7 +157,9 @@ public double calcCi(int compNumb, PhaseInterface phase, double temperature, dou } /** - *calcCij.
+ *+ * calcCij. + *
* * @param compNumb a int * @param compNumbj a int @@ -166,7 +180,9 @@ public double calcCij(int compNumb, int compNumbj, PhaseInterface phase, double } /** - *calcCiT.
+ *+ * calcCiT. + *
* * @param compNumb a int * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object @@ -190,7 +206,9 @@ public double calcCiT(int compNumb, PhaseInterface phase, double temperature, do } /** - *calcCT.
+ *+ * calcCT. + *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double @@ -203,7 +221,9 @@ public double calcCT(PhaseInterface phase, double temperature, double pressure, } /** - *calcC.
+ *+ * calcC. + *
* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param temperature a double @@ -231,7 +251,9 @@ private double loc_C() { } /** - *getc.
+ *+ * getc. + *
* * @return a double */ @@ -240,7 +262,9 @@ public double getc() { } /** - *getC.
+ *+ * getC. + *
* * @return a double */ @@ -272,11 +296,8 @@ public double gVV() { // return -1.0 / (val2 * val2) + 1.0 / (val1 * val1); } - /** - *gVVV.
- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double gVVV() { double val1 = numberOfMolesInPhase * getMolarVolume(); double val2 = val1 + getC() - getB(); @@ -305,11 +326,8 @@ public double fVV() { // return 1.0 / (R * loc_B * (delta1 - delta2)) * (-1.0 / (val1 * val1) + 1.0 / (val2 * val2)); } - /** - *fVVV.
- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double fVVV() { double val1 = numberOfMolesInPhase * molarVolume + getB() * delta1 + getC(); double val2 = numberOfMolesInPhase * molarVolume + getB() * delta2 + getC(); @@ -336,7 +354,9 @@ public double gb() { // derivative of small g with regards to c /** - *gc.
+ *+ * gc. + *
* * @return a double */ @@ -347,7 +367,9 @@ public double gc() { // derivative of small f with regards to c-->equal to fv /** - *fc.
+ *+ * fc. + *
* * @return a double */ @@ -364,7 +386,9 @@ public double fb() { // second derivative of small f with regards to cc-->equal to fvv /** - *fcc.
+ *+ * fcc. + *
* * @return a double */ @@ -374,7 +398,9 @@ public double fcc() { // second derivative of small f with regards to bc-->equal to fvv /** - *fbc.
+ *+ * fbc. + *
* * @return a double */ @@ -384,7 +410,9 @@ public double fbc() { // second derivative of small f with regards to cv-->equal to fvv /** - *fcv.
+ *+ * fcv. + *
* * @return a double */ @@ -424,7 +452,9 @@ public double gBB() { // second derivative of small g with regards to bc--> /** - *gBC.
+ *+ * gBC. + *
* * @return a double */ @@ -435,7 +465,9 @@ public double gBC() { // second derivative of small g with regards to cv--> /** - *gCV.
+ *+ * gCV. + *
* * @return a double */ @@ -446,7 +478,9 @@ public double gCV() { // second derivative of small g with regards to cc--> /** - *gCC.
+ *+ * gCC. + *
* * @return a double */ @@ -466,7 +500,9 @@ public double F() { // derivative of big F with regards to C // @Override /** - *FC.
+ *+ * FC. + *
* * @return a double */ @@ -475,7 +511,9 @@ public double FC() { } /** - *FnC.
+ *+ * FnC. + *
* * @return a double */ @@ -484,7 +522,9 @@ public double FnC() { } /** - *FTC.
+ *+ * FTC. + *
* * @return a double */ @@ -493,7 +533,9 @@ public double FTC() { } /** - *FBC.
+ *+ * FBC. + *
* * @return a double */ @@ -502,7 +544,9 @@ public double FBC() { } /** - *FCV.
+ *+ * FCV. + *
* * @return a double */ @@ -511,7 +555,9 @@ public double FCV() { } /** - *FCC.
+ *+ * FCC. + *
* * @return a double */ @@ -520,7 +566,9 @@ public double FCC() { } /** - *FCD.
+ *+ * FCD. + *
* * @return a double */ @@ -575,7 +623,7 @@ public PhasePrEosvolcor clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentPRvolcor(name, moles, molesInPhase, compNumber); } } diff --git a/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java b/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java index 493f6dc85e..16ca81896e 100644 --- a/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java +++ b/src/main/java/neqsim/thermo/phase/PhasePureComponentSolid.java @@ -24,7 +24,6 @@ public class PhasePureComponentSolid extends PhaseSolid { */ public PhasePureComponentSolid() { super(); - setType(PhaseType.SOLID); } /** {@inheritDoc} */ @@ -39,12 +38,4 @@ public PhasePureComponentSolid clone() { return clonedPhase; } - - /** {@inheritDoc} */ - @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, - double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - setType(PhaseType.SOLID); - } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseRK.java b/src/main/java/neqsim/thermo/phase/PhaseRK.java index d700fa7f33..76d8d82af9 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseRK.java +++ b/src/main/java/neqsim/thermo/phase/PhaseRK.java @@ -43,7 +43,7 @@ public PhaseRK clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentRK(name, moles, molesInPhase, compNumber); } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSolid.java b/src/main/java/neqsim/thermo/phase/PhaseSolid.java index fceeba8b86..a82c2299ba 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSolid.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSolid.java @@ -27,6 +27,7 @@ public abstract class PhaseSolid extends PhaseSrkEos { public PhaseSolid() { super(); setType(PhaseType.SOLID); + calcMolarVolume = false; } /** {@inheritDoc} */ @@ -38,21 +39,27 @@ public PhaseSolid clone() { } catch (Exception ex) { logger.error("Cloning failed.", ex); } + return clonedPhase; } /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + try { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + getDensityTemp(); + } catch (Exception ex) { + logger.error(ex.getMessage()); + } setType(PhaseType.SOLID); } /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentSolid(name, moles, molesInPhase, compNumber); } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSolidComplex.java b/src/main/java/neqsim/thermo/phase/PhaseSolidComplex.java index 77f865ca18..855527c27f 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSolidComplex.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSolidComplex.java @@ -36,9 +36,9 @@ public PhaseSolidComplex clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); setType(PhaseType.SOLIDCOMPLEX); } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java index 694187913f..cdeca294d1 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java @@ -119,11 +119,11 @@ public PhaseSrkCPA clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { boolean changedAssosiationStatus = false; - if (type == 0) { + if (initType == 0) { activeAccosComp = new int[numberOfComponents]; for (int i = 0; i < numberOfComponents; i++) { if (componentArray[i].getNumberOfmoles() < 1e-50) { @@ -226,28 +226,28 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph if (cpamix == null) { cpamix = cpaSelect.getMixingRule(1, this); } - if (type > 0) { + if (initType > 0) { calcDelta(); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); - if (type > 0 && isConstantPhaseVolume()) { + if (initType > 0 && isConstantPhaseVolume()) { solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); gcpav = calc_lngV(); gcpavv = calc_lngVV(); gcpavvv = calc_lngVVV(); } - if (type > 0) { + if (initType > 0) { hcpatot = calc_hCPA(); } - if (type > 1) { - initCPAMatrix(type); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (initType > 1) { + initCPAMatrix(initType); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } } @@ -679,11 +679,12 @@ public double dFCPAdTdV() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-8; @@ -744,11 +745,11 @@ public double molarVolume(double pressure, double temperature, double A, double } else if (d1 / d2 < -1) { BonV += 0.5 * d1; } else if (d1 > d2) { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV += d2; // double hnew = h + d2 * dh; // if (Math.abs(hnew) > Math.abs(h)) { - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); // } @@ -763,7 +764,7 @@ public double molarVolume(double pressure, double temperature, double A, double // System.out.println(iterations + " BonV " + BonV); BonV = (BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); } } @@ -771,19 +772,17 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); } } /* * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { // BonV - * = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, temperature, A, - * B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * = calcRootVolFinder(pt); // BonV = molarVolumeChangePhase(pressure, temperature, A, B, pt); + * // BonV = 0.9999; // BonV = pt == 1 ? 2.0 / (2.0 + temperature / * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * - * R); } - * - * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; } else - * { // BonV = calcRootVolFinder(phasetype); // return molarVolumeChangePhase(pressure, - * temperature, A, B, phasetype); // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * R); } } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; + * } else { // BonV = calcRootVolFinder(pt); // return molarVolumeChangePhase(pressure, + * temperature, A, B, pt); // BonV = pt == 1 ? 2.0 / (2.0 + temperature / * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * * R); } } */ @@ -797,8 +796,8 @@ public double molarVolume(double pressure, double temperature, double A, double // if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + // " BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1139,17 +1138,17 @@ public double getGcpa() { * calcRootVolFinder. * * - * @param phase a int + * @param pt the PhaseType of the phase * @return a double */ - public double calcRootVolFinder(int phase) { + public double calcRootVolFinder(PhaseType pt) { double solvedBonVHigh = 0.0; double solvedBonVlow = 1.0; double oldh = 1; // double[][] matrix = new double[2][2000]; double BonV = 1.0 - 1e-10; try { - // molarVolume(pressure, temperature, A, B, phaseType); + // molarVolume(pressure, temperature, A, B, pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -1182,12 +1181,12 @@ public double calcRootVolFinder(int phase) { if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { if (solvedBonVlow < 1e-3) { solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { + if (pt == PhaseType.GAS) { break; } } else { solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { + if (pt == PhaseType.LIQUID) { break; } } @@ -1205,7 +1204,7 @@ public double calcRootVolFinder(int phase) { // file.setValues(matrix); // file.setOutputFileName("D:/temp/temp2.txt"); // file.createFile(); - if (phase == 1) { + if (pt == PhaseType.GAS) { return solvedBonVlow; } else { return solvedBonVHigh; @@ -1221,17 +1220,17 @@ public double calcRootVolFinder(int phase) { * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + double BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double BonV = calcRootVolFinder(phasetype); + // double BonV = calcRootVolFinder(pt); // double BonVInit = BonV; if (BonV < 0) { BonV = 1.0e-8; @@ -1293,7 +1292,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1307,7 +1306,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1316,7 +1315,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1329,8 +1328,8 @@ public double molarVolumeChangePhase(double pressure, double temperature, double } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); - * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } + * if (Math.abs(h) > 1e-8) { if (pt == 0) { molarVolume(pressure, temperature, A, B, 1); } else + * { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1408,9 +1407,9 @@ public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) * croeneckerProduct. * * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + * @param a an array of type double + * @param b an array of type double + * @return an array of type double */ public double[][] croeneckerProduct(double[][] a, double[][] b) { int aLength = a.length; @@ -1450,10 +1449,10 @@ public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) * @param totalNumberOfMoles a double * @param numberOfComponents a int * @param type a int - * @param phase a int + * @param pt the PhaseType of the phase * @param beta a double */ - public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, int phase, + public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt, double beta) { // type = 0 start init, type = 1 gi nye betingelser if (type == 0) { @@ -1531,11 +1530,11 @@ public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta); if (type > 0 && isConstantPhaseVolume()) { calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); @@ -1556,10 +1555,10 @@ public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + Z = pt == PhaseType.LIQUID ? 1.0 : 1.0e-5; setMolarVolume(Z * R * temperature / pressure); // super.molarVolume(pressure,temperature, A, B, phase); int iterations = 0; @@ -2006,21 +2005,22 @@ public boolean solveX2Old(int maxIter) { * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeOld(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // if (pressure > 1000) { // BonV = 0.9999; // } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // double calcRooBonVtVolFinder = calcRootVolFinder(pt); // BonV = calcRooBonVtVolFinder; // double BonVInit = BonV; if (BonV < 0) { @@ -2084,7 +2084,7 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -2098,9 +2098,9 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -2108,8 +2108,8 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -2122,7 +2122,7 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java index c35709b315..eed767d7d3 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatrices.java @@ -146,9 +146,9 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type == 0) { + if (initType == 0) { setTotalNumberOfAccociationSites(0); selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; @@ -223,11 +223,11 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType > 0 && isConstantPhaseVolume()) { calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); @@ -235,12 +235,12 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph gcpavvv = calc_lngVVV(); } - if (type > 0) { + if (initType > 0) { hcpatot = calc_hCPA(); } - if (type > 1) { - initCPAMatrix(type); + if (initType > 1) { + initCPAMatrix(initType); // hcpatotdT = calc_hCPAdT(); // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); } @@ -1031,17 +1031,17 @@ public double getGcpa() { * calcRootVolFinder. * * - * @param phase a int + * @param pt the PhaseType of the phase * @return a double */ - public double calcRootVolFinder(int phase) { + public double calcRootVolFinder(PhaseType pt) { double solvedBonVHigh = 0.0; double solvedBonVlow = 1.0; double oldh = 1; // double[][] matrix = new double[2][2000]; double BonV = 1.0 - 1e-10; try { - // molarVolume(pressure, temperature, A, B, phaseType); + // molarVolume(pressure, temperature, A, B, pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -1074,12 +1074,12 @@ public double calcRootVolFinder(int phase) { if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { if (solvedBonVlow < 1e-3) { solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { + if (pt == PhaseType.GAS) { break; } } else { solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { + if (pt == PhaseType.LIQUID) { break; } } @@ -1097,7 +1097,7 @@ public double calcRootVolFinder(int phase) { // file.setValues(matrix); // file.setOutputFileName("D:/temp/temp2.txt"); // file.createFile(); - if (phase == 1) { + if (pt == PhaseType.GAS) { return solvedBonVlow; } else { return solvedBonVHigh; @@ -1106,16 +1106,17 @@ public double calcRootVolFinder(int phase) { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // if (pressure > 1000) { // BonV = 0.9999; // } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // double calcRooBonVtVolFinder = calcRootVolFinder(pt); // BonV = calcRooBonVtVolFinder; // double BonVInit = BonV; if (BonV < 0) { @@ -1176,7 +1177,7 @@ public double molarVolume(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1190,9 +1191,9 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1200,8 +1201,8 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1214,7 +1215,7 @@ public double molarVolume(double pressure, double temperature, double A, double if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1246,18 +1247,18 @@ public double molarVolume(double pressure, double temperature, double A, double * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // double BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); - double BonV = calcRootVolFinder(phasetype); + double BonV = calcRootVolFinder(pt); // double BonVInit = BonV; if (BonV < 0) { BonV = 1.0e-8; @@ -1319,7 +1320,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1333,7 +1334,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1342,7 +1343,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1355,8 +1356,8 @@ public double molarVolumeChangePhase(double pressure, double temperature, double } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); - * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } + * if (Math.abs(h) > 1e-8) { if (pt == 0) { molarVolume(pressure, temperature, A, B, 1); } else + * { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1382,10 +1383,10 @@ public double molarVolumeChangePhase(double pressure, double temperature, double /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + Z = pt == PhaseType.LIQUID ? 1.0 : 1.0e-5; setMolarVolume(Z * R * temperature / pressure); // super.molarVolume(pressure,temperature, A, B, phase); int iterations = 0; @@ -1481,9 +1482,9 @@ public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) * croeneckerProduct. * * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + * @param a an array of type double + * @param b an array of type double + * @return an array of type double */ public double[][] croeneckerProduct(double[][] a, double[][] b) { int aLength = a.length; diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java index 3cbe825ea3..e1aec5200b 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkCPAojAlgo.java @@ -122,9 +122,9 @@ public void setMixingRule(int type) { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - if (type == 0) { + if (initType == 0) { setTotalNumberOfAccociationSites(0); selfAccociationScheme = new int[numberOfComponents][0][0]; crossAccociationScheme = new int[numberOfComponents][numberOfComponents][0][0]; @@ -199,11 +199,11 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); - if (type > 0 && isConstantPhaseVolume()) { + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); + if (initType > 0 && isConstantPhaseVolume()) { calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); @@ -211,12 +211,12 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph gcpavvv = calc_lngVVV(); } - if (type > 0) { + if (initType > 0) { hcpatot = calc_hCPA(); } - if (type > 1) { - initCPAMatrix(type); + if (initType > 1) { + initCPAMatrix(initType); // hcpatotdT = calc_hCPAdT(); // super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); } @@ -928,17 +928,17 @@ public double getGcpa() { * calcRootVolFinder. * * - * @param phase a int + * @param pt the PhaseType of the phase * @return a double */ - public double calcRootVolFinder(int phase) { + public double calcRootVolFinder(PhaseType pt) { double solvedBonVHigh = 0.0; double solvedBonVlow = 1.0; double oldh = 1; // double[][] matrix = new double[2][2000]; double BonV = 1.0 - 1e-10; try { - // molarVolume(pressure, temperature, A, B, phaseType); + // molarVolume(pressure, temperature, A, B, pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -970,12 +970,12 @@ public double calcRootVolFinder(int phase) { if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { if (solvedBonVlow < 1e-3) { solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { + if (pt == PhaseType.GAS) { break; } } else { solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { + if (pt == PhaseType.LIQUID) { break; } } @@ -993,7 +993,7 @@ public double calcRootVolFinder(int phase) { // file.setValues(matrix); // file.setOutputFileName("D:/temp/temp2.txt"); // file.createFile(); - if (phase == 1) { + if (pt == PhaseType.GAS) { return solvedBonVlow; } else { return solvedBonVHigh; @@ -1002,16 +1002,17 @@ public double calcRootVolFinder(int phase) { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // if (pressure > 1000) { // BonV = 0.9999; // } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // double calcRooBonVtVolFinder = calcRootVolFinder(pt); // BonV = calcRooBonVtVolFinder; // double BonVInit = BonV; if (BonV < 0) { @@ -1075,7 +1076,7 @@ public double molarVolume(double pressure, double temperature, double A, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1089,9 +1090,9 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1099,8 +1100,8 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -1113,7 +1114,7 @@ public double molarVolume(double pressure, double temperature, double A, double if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1145,18 +1146,18 @@ public double molarVolume(double pressure, double temperature, double A, double * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - // double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // double BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); - double BonV = calcRootVolFinder(phasetype); + double BonV = calcRootVolFinder(pt); // double BonVInit = BonV; if (BonV < 0) { BonV = 1.0e-8; @@ -1218,7 +1219,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1232,7 +1233,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1241,7 +1242,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1254,8 +1255,8 @@ public double molarVolumeChangePhase(double pressure, double temperature, double } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); - * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } + * if (Math.abs(h) > 1e-8) { if (pt == 0) { molarVolume(pressure, temperature, A, B, 1); } else + * { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1281,10 +1282,10 @@ public double molarVolumeChangePhase(double pressure, double temperature, double /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + Z = pt == PhaseType.LIQUID ? 1.0 : 1.0e-5; setMolarVolume(Z * R * temperature / pressure); // super.molarVolume(pressure,temperature, A, B, phase); int iterations = 0; @@ -1380,9 +1381,9 @@ public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) * croeneckerProduct. * * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + * @param a an array of type double + * @param b an array of type double + * @return an array of type double */ public double[][] croeneckerProduct(double[][] a, double[][] b) { int aLength = a.length; diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java b/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java index c45dde1adb..a6aa1e5b8a 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkEos.java @@ -50,8 +50,7 @@ public PhaseSrkEos clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentSrk(name, moles, molesInPhase, compNumber); } } - diff --git a/src/main/java/neqsim/thermo/phase/PhaseSrkPenelouxEos.java b/src/main/java/neqsim/thermo/phase/PhaseSrkPenelouxEos.java index a0e046f27f..5221925e54 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseSrkPenelouxEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseSrkPenelouxEos.java @@ -38,7 +38,7 @@ public PhaseSrkPenelouxEos clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentSrkPeneloux(name, moles, molesInPhase, compNumber); } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseTSTEos.java b/src/main/java/neqsim/thermo/phase/PhaseTSTEos.java index 2e2a32b621..16b0fd8a7c 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseTSTEos.java +++ b/src/main/java/neqsim/thermo/phase/PhaseTSTEos.java @@ -42,7 +42,7 @@ public PhaseTSTEos clone() { /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentTST(name, moles, molesInPhase, compNumber); } } diff --git a/src/main/java/neqsim/thermo/phase/PhaseType.java b/src/main/java/neqsim/thermo/phase/PhaseType.java index 359d497d27..d3dce468d7 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseType.java +++ b/src/main/java/neqsim/thermo/phase/PhaseType.java @@ -1,16 +1,17 @@ package neqsim.thermo.phase; -import java.io.Serializable; import neqsim.util.exception.InvalidInputException; /** * Types of phases. + * + * @author ASMF */ -public enum PhaseType implements Serializable{ +public enum PhaseType { LIQUID("liquid", 0), GAS("gas", 1), OIL("oil", 2), AQUEOUS("aqueous", 3), HYDRATE("hydrate", 4), WAX("wax", 5), SOLID("solid", 6), SOLIDCOMPLEX("solidComplex", 7); - /** Holder for old style integer phasetype. */ + /** Holder for old style integer pt. */ private final int value; /** Holder for old style string phasetypename. */ private final String desc; @@ -35,6 +36,7 @@ private PhaseType(String desc, int value) { * * @return Numeric index of phase type */ + @Deprecated public int getValue() { return this.value; } diff --git a/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java b/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java index 62537b2d51..f96a292ea4 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java +++ b/src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java @@ -119,11 +119,11 @@ public PhaseUMRCPA clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { boolean changedAssosiationStatus = false; - if (type == 0) { + if (initType == 0) { activeAccosComp = new int[numberOfComponents]; for (int i = 0; i < numberOfComponents; i++) { if (componentArray[i].getNumberOfmoles() < 1e-50) { @@ -226,28 +226,28 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph if (cpamix == null) { cpamix = cpaSelect.getMixingRule(1, this); } - if (type > 0) { + if (initType > 0) { calcDelta(); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); - if (type > 0 && isConstantPhaseVolume()) { + if (initType > 0 && isConstantPhaseVolume()) { solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); gcpav = calc_lngV(); gcpavv = calc_lngVV(); gcpavvv = calc_lngVVV(); } - if (type > 0) { + if (initType > 0) { hcpatot = calc_hCPA(); } - if (type > 1) { - initCPAMatrix(type); - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + if (initType > 1) { + initCPAMatrix(initType); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); } } @@ -679,11 +679,12 @@ public double dFCPAdTdV() { /** {@inheritDoc} */ @Override - public double molarVolume(double pressure, double temperature, double A, double B, int phasetype) + public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); if (BonV < 0) { BonV = 1.0e-8; @@ -744,11 +745,11 @@ public double molarVolume(double pressure, double temperature, double A, double } else if (d1 / d2 < -1) { BonV += 0.5 * d1; } else if (d1 > d2) { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV += d2; // double hnew = h + d2 * dh; // if (Math.abs(hnew) > Math.abs(h)) { - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); // } @@ -763,7 +764,7 @@ public double molarVolume(double pressure, double temperature, double A, double // System.out.println(iterations + " BonV " + BonV); BonV = (BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); } } @@ -771,19 +772,17 @@ public double molarVolume(double pressure, double temperature, double A, double if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { - return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + return molarVolumeChangePhase(pressure, temperature, A, B, pt); } } /* * if (BonV > 0.9999) { if (iterations < 10) { BonV = (BonVold + BonV) / 2.0; } else { // BonV - * = calcRootVolFinder(phasetype); // BonV = molarVolumeChangePhase(pressure, temperature, A, - * B, phasetype); // BonV = 0.9999; // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * = calcRootVolFinder(pt); // BonV = molarVolumeChangePhase(pressure, temperature, A, B, pt); + * // BonV = 0.9999; // BonV = pt == 1 ? 2.0 / (2.0 + temperature / * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * - * R); } - * - * } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; } else - * { // BonV = calcRootVolFinder(phasetype); // return molarVolumeChangePhase(pressure, - * temperature, A, B, phasetype); // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + * R); } } else if (BonV < 0) { if (iterations < 10) { BonV = Math.abs(BonVold + BonV) / 2.0; + * } else { // BonV = calcRootVolFinder(pt); // return molarVolumeChangePhase(pressure, + * temperature, A, B, pt); // BonV = pt == 1 ? 2.0 / (2.0 + temperature / * getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * * R); } } */ @@ -797,8 +796,8 @@ public double molarVolume(double pressure, double temperature, double A, double // if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + h + " Z" + Z + " iterations " + iterations + // " BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1139,17 +1138,17 @@ public double getGcpa() { * calcRootVolFinder. * * - * @param phase a int + * @param pt the PhaseType of the phase * @return a double */ - public double calcRootVolFinder(int phase) { + public double calcRootVolFinder(PhaseType pt) { double solvedBonVHigh = 0.0; double solvedBonVlow = 1.0; double oldh = 1; // double[][] matrix = new double[2][2000]; double BonV = 1.0 - 1e-10; try { - // molarVolume(pressure, temperature, A, B, phaseType); + // molarVolume(pressure, temperature, A, B, pt); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -1182,12 +1181,12 @@ public double calcRootVolFinder(int phase) { if (Math.signum(h) * Math.signum(oldh) < 0 && i > 2) { if (solvedBonVlow < 1e-3) { solvedBonVlow = (BonV + BonVold) / 2.0; - if (phase == 1) { + if (pt == PhaseType.GAS) { break; } } else { solvedBonVHigh = (BonV + BonVold) / 2.0; - if (phase == 0) { + if (pt == PhaseType.LIQUID) { break; } } @@ -1205,7 +1204,7 @@ public double calcRootVolFinder(int phase) { // file.setValues(matrix); // file.setOutputFileName("D:/temp/temp2.txt"); // file.createFile(); - if (phase == 1) { + if (pt == PhaseType.GAS) { return solvedBonVlow; } else { return solvedBonVHigh; @@ -1221,17 +1220,17 @@ public double calcRootVolFinder(int phase) { * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeChangePhase(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + double BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); - // double BonV = calcRootVolFinder(phasetype); + // double BonV = calcRootVolFinder(pt); // double BonVInit = BonV; if (BonV < 0) { BonV = 1.0e-8; @@ -1293,7 +1292,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -1307,7 +1306,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1316,7 +1315,7 @@ public double molarVolumeChangePhase(double pressure, double temperature, double if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } @@ -1329,8 +1328,8 @@ public double molarVolumeChangePhase(double pressure, double temperature, double } while ((Math.abs((BonV - BonVold) / BonV) > 1.0e-10) && iterations < 100); /* - * if (Math.abs(h) > 1e-8) { if (phasetype == 0) { molarVolume(pressure, temperature, A, B, 1); - * } else { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } + * if (Math.abs(h) > 1e-8) { if (pt == 0) { molarVolume(pressure, temperature, A, B, 1); } else + * { molarVolume(pressure, temperature, A, B, 0); } return getMolarVolume(); } */ // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); @@ -1408,9 +1407,9 @@ public int getCrossAssosiationScheme(int comp1, int comp2, int site1, int site2) * croeneckerProduct. * * - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @return an array of {@link double} objects + * @param a an array of type double + * @param b an array of type double + * @return an array of type double */ public double[][] croeneckerProduct(double[][] a, double[][] b) { int aLength = a.length; @@ -1450,10 +1449,10 @@ public void setTotalNumberOfAccociationSites(int totalNumberOfAccociationSites) * @param totalNumberOfMoles a double * @param numberOfComponents a int * @param type a int - * @param phase a int + * @param pt a int * @param beta a double */ - public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType pt, double beta) { // type = 0 start init, type = 1 gi ny betingelser if (type == 0) { @@ -1531,11 +1530,11 @@ public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type cpamix = cpaSelect.getMixingRule(1, this); } - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, type, pt, beta); if (type > 0 && isConstantPhaseVolume()) { calcDelta(); solveX(); - super.init(totalNumberOfMoles, numberOfComponents, 1, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, 1, pt, beta); gcpa = calc_g(); // lngcpa = Math.log(gcpa); setGcpav(calc_lngV()); @@ -1556,10 +1555,10 @@ public void initOld2(double totalNumberOfMoles, int numberOfComponents, int type /** {@inheritDoc} */ @Override - public double molarVolume2(double pressure, double temperature, double A, double B, int phase) + public double molarVolume2(double pressure, double temperature, double A, double B, PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - Z = phase == 0 ? 1.0 : 1.0e-5; + Z = pt == PhaseType.LIQUID ? 1.0 : 1.0e-5; setMolarVolume(Z * R * temperature / pressure); // super.molarVolume(pressure,temperature, A, B, phase); int iterations = 0; @@ -2006,21 +2005,22 @@ public boolean solveX2Old(int maxIter) { * @param temperature a double * @param A a double * @param B a double - * @param phasetype a int + * @param pt the PhaseType of the phase * @return a double * @throws neqsim.util.exception.IsNaNException if any. * @throws neqsim.util.exception.TooManyIterationsException if any. */ public double molarVolumeOld(double pressure, double temperature, double A, double B, - int phasetype) throws neqsim.util.exception.IsNaNException, + PhaseType pt) throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException { - double BonV = phasetype == 0 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) - : pressure * getB() / (numberOfMolesInPhase * temperature * R); + double BonV = + pt == PhaseType.LIQUID ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + : pressure * getB() / (numberOfMolesInPhase * temperature * R); // if (pressure > 1000) { // BonV = 0.9999; // } - // double calcRooBonVtVolFinder = calcRootVolFinder(phasetype); + // double calcRooBonVtVolFinder = calcRootVolFinder(pt); // BonV = calcRooBonVtVolFinder; // double BonVInit = BonV; if (BonV < 0) { @@ -2084,7 +2084,7 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub BonV += d2; double hnew = h + d2 * dh; if (Math.abs(hnew) > Math.abs(h)) { - BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) + BonV = pt == PhaseType.GAS ? 2.0 / (2.0 + temperature / getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * temperature * R); } } else { @@ -2098,9 +2098,9 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (iterations < 3) { BonV = (BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); // BonV = 0.9999; - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -2108,8 +2108,8 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (iterations < 3) { BonV = Math.abs(BonVold + BonV) / 2.0; } else { - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); - // BonV = phasetype == 1 ? 2.0 / (2.0 + temperature / + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); + // BonV = pt == 1 ? 2.0 / (2.0 + temperature / // getPseudoCriticalTemperature()) : pressure * getB() / (numberOfMolesInPhase * // temperature * R); } @@ -2122,7 +2122,7 @@ public double molarVolumeOld(double pressure, double temperature, double A, doub if (Math.abs(h) > 1e-12) { // System.out.println("h failed " + "Z" + Z + " iterations " + iterations + " // BonV " + BonV); - // return molarVolumeChangePhase(pressure, temperature, A, B, phasetype); + // return molarVolumeChangePhase(pressure, temperature, A, B, pt); } // System.out.println("Z" + Z + " iterations " + iterations + " BonV " + BonV); // System.out.println("pressure " + Z*R*temperature/getMolarVolume()); diff --git a/src/main/java/neqsim/thermo/phase/PhaseWax.java b/src/main/java/neqsim/thermo/phase/PhaseWax.java index 16f0ef8ed5..1b900a059c 100644 --- a/src/main/java/neqsim/thermo/phase/PhaseWax.java +++ b/src/main/java/neqsim/thermo/phase/PhaseWax.java @@ -38,16 +38,16 @@ public PhaseWax clone() { /** {@inheritDoc} */ @Override - public void init(double totalNumberOfMoles, int numberOfComponents, int type, PhaseType phase, + public void init(double totalNumberOfMoles, int numberOfComponents, int initType, PhaseType pt, double beta) { - super.init(totalNumberOfMoles, numberOfComponents, type, phase, beta); + super.init(totalNumberOfMoles, numberOfComponents, initType, pt, beta); setType(PhaseType.WAX); } /** {@inheritDoc} */ @Override public void addComponent(String name, double moles, double molesInPhase, int compNumber) { - super.addComponent(name, molesInPhase); + super.addComponent(name, molesInPhase, compNumber); componentArray[compNumber] = new ComponentWax(name, moles, molesInPhase, compNumber); // componentArray[compNumber] = new ComponentWaxWilson(componentName, moles, // molesInPhase, compNumber); diff --git a/src/main/java/neqsim/thermo/phase/StateOfMatter.java b/src/main/java/neqsim/thermo/phase/StateOfMatter.java index ccf16bd1ab..8ce4150c92 100644 --- a/src/main/java/neqsim/thermo/phase/StateOfMatter.java +++ b/src/main/java/neqsim/thermo/phase/StateOfMatter.java @@ -2,6 +2,8 @@ /** * States of matter, a way of relating the PhaseTypes to classical states of matter. + * + * @author ASMF */ public enum StateOfMatter { GAS, LIQUID, SOLID; diff --git a/src/main/java/neqsim/thermo/system/SystemBWRSEos.java b/src/main/java/neqsim/thermo/system/SystemBWRSEos.java index cd6d3f7020..49ab6bb1de 100644 --- a/src/main/java/neqsim/thermo/system/SystemBWRSEos.java +++ b/src/main/java/neqsim/thermo/system/SystemBWRSEos.java @@ -46,8 +46,7 @@ public SystemBWRSEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemBWRSEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "BWRS-EOS"; attractiveTermNumber = 0; @@ -83,11 +82,6 @@ public SystemBWRSEos clone() { logger.error("Cloning failed.", ex); } - // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone(); - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java b/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java index 7311950752..446deb6ad3 100644 --- a/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemCSPsrkEos.java @@ -44,11 +44,11 @@ public SystemCSPsrkEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemCSPsrkEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "CSPsrk-EOS"; attractiveTermNumber = 0; + // Recreates phases created in super constructor SystemSrkEos for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseCSPsrkEos(); phaseArray[i].setTemperature(T); diff --git a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java index 9f35793817..492ac3ba15 100644 --- a/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java +++ b/src/main/java/neqsim/thermo/system/SystemDesmukhMather.java @@ -44,8 +44,7 @@ public SystemDesmukhMather(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemDesmukhMather(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "Desmukh-Mather-model"; diff --git a/src/main/java/neqsim/thermo/system/SystemDuanSun.java b/src/main/java/neqsim/thermo/system/SystemDuanSun.java index 710f908841..1b2c883733 100644 --- a/src/main/java/neqsim/thermo/system/SystemDuanSun.java +++ b/src/main/java/neqsim/thermo/system/SystemDuanSun.java @@ -3,7 +3,6 @@ import neqsim.thermo.phase.PhaseDuanSun; import neqsim.thermo.phase.PhasePureComponentSolid; import neqsim.thermo.phase.PhaseSrkEos; -import neqsim.thermodynamicOperations.ThermodynamicOperations; /** * This class defines a thermodynamic system using the Duan Sun method used for CO2. @@ -48,8 +47,7 @@ public SystemDuanSun(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemDuanSun(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "Duan-Sun-model"; @@ -83,29 +81,4 @@ public SystemDuanSun clone() { return clonedSystem; } - - /** - *- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface fluid1 = new SystemSrkCPA(298.15, 10.0); - - fluid1.addComponent("CO2", 1.0); - fluid1.addComponent("nitrogen", 1.0); - fluid1.addComponent("water", 1.0); - fluid1.addComponent("NaCl", 1.0); - fluid1.setMixingRule(2); - - try { - ThermodynamicOperations testOps = new ThermodynamicOperations(fluid1); - testOps.TPflash(); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - fluid1.display(); - } } diff --git a/src/main/java/neqsim/thermo/system/SystemElectrolyteCPA.java b/src/main/java/neqsim/thermo/system/SystemElectrolyteCPA.java index 5cfc63c2e5..04512328a9 100644 --- a/src/main/java/neqsim/thermo/system/SystemElectrolyteCPA.java +++ b/src/main/java/neqsim/thermo/system/SystemElectrolyteCPA.java @@ -52,10 +52,6 @@ public SystemElectrolyteCPA clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] =(PhaseElectrolyteCPA) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemElectrolyteCPAstatoil.java b/src/main/java/neqsim/thermo/system/SystemElectrolyteCPAstatoil.java index 43b369d2e7..28e77b58e4 100644 --- a/src/main/java/neqsim/thermo/system/SystemElectrolyteCPAstatoil.java +++ b/src/main/java/neqsim/thermo/system/SystemElectrolyteCPAstatoil.java @@ -52,10 +52,6 @@ public SystemElectrolyteCPAstatoil clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] =(PhaseElectrolyteCPA) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemEos.java b/src/main/java/neqsim/thermo/system/SystemEos.java index a855262ab7..8eca58b132 100644 --- a/src/main/java/neqsim/thermo/system/SystemEos.java +++ b/src/main/java/neqsim/thermo/system/SystemEos.java @@ -1,10 +1,11 @@ package neqsim.thermo.system; /** + * Base class for system with EOS. * * @author Even Solbraa */ -abstract class SystemEos extends neqsim.thermo.system.SystemThermo { +public abstract class SystemEos extends neqsim.thermo.system.SystemThermo { private static final long serialVersionUID = 1000; /** @@ -23,13 +24,9 @@ public SystemEos() { * * @param T The temperature in unit Kelvin * @param P The pressure in unit bara (absolute pressure) + * @param checkForSolids Set true to do solid phase check and calculations */ - public SystemEos(double T, double P) { - this(T, P, false); - } - public SystemEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids; + super(T, P, checkForSolids); } } diff --git a/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEos.java b/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEos.java index 536cf9b538..49d898963c 100644 --- a/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEos.java +++ b/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEos.java @@ -3,7 +3,6 @@ import neqsim.thermo.phase.PhaseModifiedFurstElectrolyteEos; /** - * * This class defines a thermodynamic system using the electrolyte the Furst Electrolyte Eos. * * @author Even Solbraa @@ -50,12 +49,6 @@ public SystemFurstElectrolyteEos clone() { logger.error("Cloning failed.", ex); } - // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone(); - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseModifiedFurstElectrolyteEos) - // phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEosMod2004.java b/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEosMod2004.java index aaa74e07e9..dd452464d3 100644 --- a/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEosMod2004.java +++ b/src/main/java/neqsim/thermo/system/SystemFurstElectrolyteEosMod2004.java @@ -50,12 +50,6 @@ public SystemFurstElectrolyteEosMod2004 clone() { logger.error("Cloning failed.", ex); } - // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone(); - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseModifiedFurstElectrolyteEos) - // phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java b/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java index 3141e6db26..e803e4e095 100644 --- a/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java +++ b/src/main/java/neqsim/thermo/system/SystemGERG2004Eos.java @@ -44,8 +44,7 @@ public SystemGERG2004Eos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemGERG2004Eos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "GERG2004-EOS"; for (int i = 0; i < numberOfPhases; i++) { diff --git a/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java b/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java index 9ca02ff647..e648660800 100644 --- a/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java +++ b/src/main/java/neqsim/thermo/system/SystemGERGwaterEos.java @@ -44,11 +44,11 @@ public SystemGERGwaterEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemGERGwaterEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "GERG-water-EOS"; attractiveTermNumber = 10; + // Recreates phases created in super constructor SystemPrEos for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhasePrEos(); phaseArray[i].setTemperature(T); @@ -81,11 +81,6 @@ public SystemGERGwaterEos clone() { logger.error("Cloning failed.", ex); } - // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone(); - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemGEWilson.java b/src/main/java/neqsim/thermo/system/SystemGEWilson.java index 56a3d18f32..0ed121ac99 100644 --- a/src/main/java/neqsim/thermo/system/SystemGEWilson.java +++ b/src/main/java/neqsim/thermo/system/SystemGEWilson.java @@ -44,8 +44,7 @@ public SystemGEWilson(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemGEWilson(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "UNIFAC-GE-model"; @@ -77,10 +76,6 @@ public SystemGEWilson clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 3825a6a00c..5f34696c82 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -18,77 +18,130 @@ */ public interface SystemInterface extends Cloneable, java.io.Serializable { /** - *- * saveFluid. - *
+ * return two fluid added as a new fluid. * - * @param id a int + * @param addFluid1 first fluid to add + * @param addFluid2 second fluid o add + * @return new fluid */ - public void saveFluid(int id); + public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterface addFluid2) { + SystemInterface newFluid = addFluid1.clone(); + newFluid.addFluid(addFluid2); + return newFluid; + } /** *- * saveFluid. + * addCapeOpenProperty. *
* - * @param id a int - * @param text a {@link java.lang.String} object + * @param propertyName a {@link java.lang.String} object */ - public void saveFluid(int id, String text); + public void addCapeOpenProperty(String propertyName); /** *- * getComponentNameTag. + * addCharacterized. *
* - * @return a {@link java.lang.String} object + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of type double + * @param molarMass an array of type double + * @param relativedensity an array of type double */ - public String getComponentNameTag(); + public void addCharacterized(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity); /** - *- * setComponentNameTag. - *
+ * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. * - * @param nameTag a {@link java.lang.String} object + * @param inComponent Component object to add. */ - public void setComponentNameTag(String nameTag); + public void addComponent(ComponentInterface inComponent); /** *- * setComponentNameTagOnNormalComponents. + * addComponent. *
* - * @param nameTag a {@link java.lang.String} object + * @param index Component number to add + * @param moles number of moles (per second) of the component to be added to the fluid */ - public void setComponentNameTagOnNormalComponents(String nameTag); + public void addComponent(int index, double moles); /** *- * addPhaseFractionToPhase. + * addComponent. *
* - * @param fraction a double - * @param specification a {@link java.lang.String} object - * @param fromPhaseName a {@link java.lang.String} object - * @param toPhaseName a {@link java.lang.String} object + * @param index Component number to add + * @param moles number of moles (per second) of the component to be added to the fluid + * @param phaseNumber Number of the phase to add the component to */ - public void addPhaseFractionToPhase(double fraction, String specification, String fromPhaseName, - String toPhaseName); + public void addComponent(int index, double moles, int phaseNumber); + + /** + * add a component to a fluid with no moles. + * + * @param name Name of the component to add. See NeqSim database for component in the database. + */ + public default void addComponent(String name) { + addComponent(name, 0); + } + + /** + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. + * + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param moles number of moles (per second) of the component to be added to the fluid + */ + public void addComponent(String name, double moles); /** *- * addPhaseFractionToPhase. + * addComponent. *
* - * @param fraction a double - * @param specification a {@link java.lang.String} object - * @param specifiedStream a {@link java.lang.String} object - * @param fromPhaseName a {@link java.lang.String} object - * @param toPhaseName a {@link java.lang.String} object + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param moles number of moles (per second) of the component to be added to the fluid + * @param TC Critical temperature + * @param PC Critical pressure + * @param acs a double */ - public void addPhaseFractionToPhase(double fraction, String specification, String specifiedStream, - String fromPhaseName, String toPhaseName); + public void addComponent(String name, double moles, double TC, double PC, double acs); + + /** + * add a component to a fluid. If component already exists, the moles will be added to the + * existing component. + * + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param moles number of moles (per second) of the component to be added to the fluid + * @param phaseNumber Number of the phase to add the component to + */ + public void addComponent(String name, double moles, int phaseNumber); + + /** + * add a component to a fluid. If component already exists, the amount will be added to the + * existing component. + * + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param value The amount. + * @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 .. + */ + public void addComponent(String name, double value, String unitName); + + /** + * add a component to a fluid. I component already exists, it will be added to the component + * + * @param name Name of the component to add. See NeqSim database for component in the database. + * @param value rate of the component to add to the fluid + * @param unitName the unit of the flow rate (eg. mol/sec, kg/sec, etc.) + * @param phaseNumber Number of the phase to add the component to + */ + public void addComponent(String name, double value, String unitName, int phaseNumber); /** * Add named components to a System. Does nothing if components already exist in System. @@ -118,959 +171,903 @@ public default void addComponents(String[] names, double[] moles) { /** *- * renameComponent. + * addFluid. *
* - * @param oldName a {@link java.lang.String} object - * @param newName a {@link java.lang.String} object + * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object + * @return SystemInterface */ - public void renameComponent(String oldName, String newName); + public SystemInterface addFluid(SystemInterface addSystem); /** *- * calcResultTable. + * addFluid. *
* - * @return an array of {@link java.lang.String} objects + * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object + * @param phase phase number of phase to add fluid to + * @return SystemInterface */ - public default String[][] calcResultTable() { - return createTable(""); - } + public SystemInterface addFluid(SystemInterface addSystem, int phase); /** *- * getKinematicViscosity. + * addGasToLiquid. *
* - * @return a double - */ - public double getKinematicViscosity(); - - /** - * method to return kinematic viscosity in a specified unit. - * - * @param unit Supported units are m2/sec - * @return kinematic viscosity in specified unit + * @param fraction a double */ - public double getKinematicViscosity(String unit); + public void addGasToLiquid(double fraction); /** *- * Get number of components added to System. + * addLiquidToGas. *
* - * @return the number of components in System. - */ - public int getNumberOfComponents(); - - /** - * This method is used to set the total molar composition of a plus fluid. The total flow rate - * will be kept constant. The input mole fractions will be normalized. - * - * @param molefractions is a double array taking the molar fraction of the components in the - * fluid. THe last molfraction is the mole fraction of the plus component + * @param fraction a double */ - public void setMolarCompositionPlus(double[] molefractions); + public void addLiquidToGas(double fraction); /** - * This method is used to set the total molar composition of a characterized fluid. The total flow - * rate will be kept constant. The input mole fractions will be normalized. + *+ * addCharacterized. + *
* - * @param molefractions is a double array taking the molar fraction of the components in the - * fluid. THe last fraction in the array is the total molefraction of the characterized - * components. + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of type double + * @param molarMass an array of type double + * @param relativedensity an array of type double + * @param lastIsPlusFraction True if last fraction is a Plus fraction */ - public void setMolarCompositionOfPlusFluid(double[] molefractions); + public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity, boolean lastIsPlusFraction); /** - * method to return exergy defined as (h1-T0*s1) in a unit Joule. + *+ * addCharacterized. + *
* - * @param temperatureOfSurroundings in Kelvin - * @return a double + * @param charNames an array of {@link java.lang.String} objects + * @param charFlowrate an array of type double + * @param molarMass an array of type double + * @param relativedensity an array of type double + * @param lastIsPlusFraction True if last fraction is a Plus fraction + * @param lumpComponents True if component should be lumped + * @param numberOfPseudoComponents number of pseudo components */ - public double getExergy(double temperatureOfSurroundings); + public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity, boolean lastIsPlusFraction, boolean lumpComponents, + int numberOfPseudoComponents); /** - * method to return exergy in a specified unit. - * - * @param temperatureOfSurroundings in Kelvin - * @param exergyUnit a {@link java.lang.String} object - * @return exergy in specified unit + * Add phase to SystemInterface object. */ - public double getExergy(double temperatureOfSurroundings, String exergyUnit); + public void addPhase(); /** - * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis - * average + *+ * addPhaseFractionToPhase. + *
* - * @return Joule Thomson coefficient in K/bar + * @param fraction a double + * @param specification a {@link java.lang.String} object + * @param fromPhaseName a {@link java.lang.String} object + * @param toPhaseName a {@link java.lang.String} object */ - public double getJouleThomsonCoefficient(); + public void addPhaseFractionToPhase(double fraction, String specification, String fromPhaseName, + String toPhaseName); /** - * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis - * average. + *+ * addPhaseFractionToPhase. + *
* - * @param unit Supported units are K/bar, C/bar - * @return Joule Thomson coefficient in specified unit + * @param fraction a double + * @param specification a {@link java.lang.String} object + * @param specifiedStream a {@link java.lang.String} object + * @param fromPhaseName a {@link java.lang.String} object + * @param toPhaseName a {@link java.lang.String} object */ - public double getJouleThomsonCoefficient(String unit); + public void addPhaseFractionToPhase(double fraction, String specification, String specifiedStream, + String fromPhaseName, String toPhaseName); /** - * method to return mass of fluid. + *+ * addPlusFraction. + *
* - * @param unit Supported units are kg, gr, tons - * @return mass in specified unit + * @param componentName a {@link java.lang.String} object + * @param numberOfMoles a double + * @param molarMass a double + * @param density a double */ - public double getMass(String unit); + public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, + double density); /** *- * Get sum of mole fractions for all components. NB! init(0) must be called first. + * addSalt. *
* - * @return a double + * @param componentName a {@link java.lang.String} object + * @param value a double */ - public double getMoleFractionsSum(); + public void addSalt(String componentName, double value); /** - * method to get the speed of sound of a system. The sound speed is implemented based on a molar - * average over the phases + *+ * addSolidComplexPhase. + *
* - * @param unit Supported units are m/s, km/h - * @return speed of sound in m/s + * @param type a {@link java.lang.String} object */ - public double getSoundSpeed(String unit); + public void addSolidComplexPhase(String type); /** - * method to get the speed of sound of a system. The sound speed is implemented based on a molar - * average over the phases + * method to add true boiling point fraction. * - * @return speed of sound in m/s + * @param componentName selected name of the component to be added + * @param numberOfMoles number of moles to be added + * @param molarMass molar mass of the component in kg/mol + * @param density density of the component in g/cm3 */ - public double getSoundSpeed(); + public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, + double density); /** *- * removePhaseKeepTotalComposition. + * addTBPfraction. *
* - * @param specPhase a int - */ - public void removePhaseKeepTotalComposition(int specPhase); - - /** - * Init physical properties for all phases and interfaces. - */ - public void initPhysicalProperties(); - - /** - * Calculates physical properties of type propertyName. - * - * @param propertyName a {@link java.lang.String} object - */ - public void initPhysicalProperties(String propertyName); - - /** - * Calculates thermodynamic and physical properties of a fluid using initThermoProperties() and - * initPhysicalProperties(). + * @param componentName a {@link java.lang.String} object + * @param numberOfMoles a double + * @param molarMass a double + * @param density a double + * @param criticalTemperature a double + * @param criticalPressure a double + * @param acentricFactor a double */ - public void initProperties(); + public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, + double density, double criticalTemperature, double criticalPressure, double acentricFactor); /** - * return two fluid added as a new fluid. + * Add to component names. * - * @param addFluid1 first fluid to add - * @param addFluid2 second fluid o add - * @return new fluid + * @param name Component name to add */ - public static SystemInterface addFluids(SystemInterface addFluid1, SystemInterface addFluid2) { - SystemInterface newFluid = addFluid1.clone(); - newFluid.addFluid(addFluid2); - return newFluid; - } - + public void addToComponentNames(String name); /** - * method to return interfacial tension between two phases. + *+ * Getter for property allowPhaseShift. + *
* - * @param phase1 phase type of phase1 as string (valid phases are gas, oil, aqueous) - * @param phase2 phase type of phase2 as string (valid phases are gas, oil, aqueous) - * @return interfacial tension with unit N/m. If one or both phases does not exist - the method - * will return NaN + * @return a boolean */ - public double getInterfacialTension(String phase1, String phase2); + public boolean allowPhaseShift(); /** - * method to return interfacial tension between two phases. + *+ * Setter for property allowPhaseShift. + *
* - * @param phase1 phase number of phase1 - * @param phase2 phase number of phase2 - * @return interfacial tension with unit N/m + * @param allowPhaseShift a boolean */ - public double getInterfacialTension(int phase1, int phase2); + public void allowPhaseShift(boolean allowPhaseShift); /** *- * getInterfacialTension. + * autoSelectMixingRule. *
- * - * @param phase1 phase number of phase1 - * @param phase2 phase number of phase2 - * @param unit a {@link java.lang.String} object - * @return interfacial tension with specified unit */ - public double getInterfacialTension(int phase1, int phase2, String unit); + public void autoSelectMixingRule(); /** - * method to return heat capacity ratio calculated as Cp/(Cp-R). + *+ * autoSelectModel. + *
* - * @return kappa + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public default double getGamma2() { - return getCp() / (getCp() - ThermodynamicConstantsInterface.R * getTotalNumberOfMoles()); - } + public SystemInterface autoSelectModel(); /** - * method to return heat capacity ratio/adiabatic index/Poisson constant. - * - * @return kappa + *+ * calc_x_y. + *
*/ - public double getGamma(); + public void calc_x_y(); /** - * method to return fluid volume. - * - * @return volume in unit m3*1e5 + *+ * calc_x_y_nonorm. + *
*/ - public double getVolume(); + public void calc_x_y_nonorm(); /** - * method to return fluid volume. + *+ * calcHenrysConstant. + *
* - * @param unit Supported units are m3, litre, m3/kg, m3/mol - * @return volume in specified unit + * @param component a {@link java.lang.String} object + * @return a double */ - public double getVolume(String unit); + public double calcHenrysConstant(String component); /** - * method to return flow rate of fluid. - * - * @param flowunit Supported units are kg/sec, kg/min, kg/hr, kg/day, m3/sec, m3/min, m3/hr, - * idSm3/hr, Sm3/sec, Sm3/hr, Sm3/day, MSm3/day, mole/sec, mole/min, mole/hr - * @return flow rate in specified unit + *+ * calcInterfaceProperties. + *
*/ - public double getFlowRate(String flowunit); + public void calcInterfaceProperties(); /** - * method to set the pressure of a fluid (same pressure for all phases). + *+ * calcKIJ. + *
* - * @param pres pressure in unit bara (absolute pressure in bar) + * @param ok a boolean */ - public void setPressure(double pres); + public void calcKIJ(boolean ok); /** - * method to set the pressure of a fluid (same pressure for all phases). + *+ * calcResultTable. + *
* - * @param newPressure in specified unit - * @param unit unit can be bar, bara, barg or atm + * @return an array of {@link java.lang.String} objects */ - public void setPressure(double newPressure, String unit); + public default String[][] calcResultTable() { + return createTable(""); + } /** *- * method to set the temperature of a fluid (same temperature for all phases). + * changeComponentName. *
* - * @param temp a double + * @param name a {@link java.lang.String} object + * @param newName a {@link java.lang.String} object */ - public void setTemperature(double temp); + public void changeComponentName(String name, String newName); /** *- * setTemperature. + * checkStability. *
* - * @param newTemperature a double - * @param phaseNumber a int + * @return a boolean */ - public void setTemperature(double newTemperature, int phaseNumber); + public boolean checkStability(); /** - * method to set the temperature of a fluid (same temperature for all phases). + *+ * checkStability. + *
* - * @param newTemperature in specified unit - * @param unit unit can be C or K (Celsius or Kelvin) + * @param val a boolean */ - public void setTemperature(double newTemperature, String unit); + public void checkStability(boolean val); /** - * method to return the volume fraction of a phase note: without Peneloux volume correction. - * - * @param phaseNumber number of the phase to get volume fraction for - * @return volume fraction + *+ * chemicalReactionInit. + *
*/ - public double getVolumeFraction(int phaseNumber); + public void chemicalReactionInit(); /** - * method to return the volume fraction of a phase note: with Peneloux volume correction. - * - * @param phaseNumber number of the phase to get volume fraction for - * @return volume fraction + *+ * clearAll. + *
*/ - public double getCorrectedVolumeFraction(int phaseNumber); + public void clearAll(); /** *- * getHeatOfVaporization. + * clone. *
* - * @return a double + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public double getHeatOfVaporization(); + public SystemInterface clone(); /** - * method to return internal energy (U) in unit J. + * method to read pure component and interaction parameters from the NeqSim database and create + * temporary tables with parameters for active fluid. * - * @return internal energy in unit Joule (J) + * @param reset If reset is set to true, new temporary tables with parameters for the added + * components will be created. When parameters are needed (eg. when adding components or + * when setting a mixing rule) it will try to find them in the temporary tables first eg. + * COMPTEMP (for pure component parameters) and INTERTEMP (for interaction parameters). If + * reset is set to false it will not create new temporary tables. If a fluid is created + * with the same components many times, performance improvements will be obtained, if + * temporary tables are created the first time (reset=true), and then the same tables is + * used when creating new fluids with the same temporary tables (reset=false) */ - public double getInternalEnergy(); + public void createDatabase(boolean reset); /** - * method to return internal energy (U) in a specified unit. + *+ * createTable. + *
* - * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' - * @return enthalpy in specified unit + * @param name a {@link java.lang.String} object + * @return an array of {@link java.lang.String} objects */ - public double getInternalEnergy(String unit); + public String[][] createTable(String name); /** *- * isForcePhaseTypes. + * deleteFluidPhase. *
* - * @return a boolean + * @param phase a int */ - public boolean isForcePhaseTypes(); + public void deleteFluidPhase(int phase); /** *- * setForcePhaseTypes. + * display. *
- * - * @param forcePhaseTypes a boolean */ - public void setForcePhaseTypes(boolean forcePhaseTypes); + public default void display() { + display(this.getFluidName()); + } /** - * Set the flow rate of all components to zero. + *+ * display. + *
* - * @deprecated use {@link #setEmptyFluid()} instead. + * @param name a {@link java.lang.String} object */ - @Deprecated - public default void removeMoles() { - setEmptyFluid(); - } + public void display(String name); /** - * Set the flow rate (moles) of all components to zero. + *
+ * Getter for property multiPhaseCheck
.
+ *
- * setMolarFlowRates. + * doSolidPhaseCheck. *
* - * @param moles an array of {@link double} objects + * @return a boolean */ - public void setMolarFlowRates(double[] moles); + public boolean doSolidPhaseCheck(); + + /** {@inheritDoc} */ + @Override + public boolean equals(Object o); /** *
- * setComponentNames.
+ * Getter for property beta
.
+ *
+ * Gets value for heaviest phase.
*
- * calc_x_y_nonorm.
+ * Getter for property beta
for a specific phase.
*
- * saveObjectToFile. + * getCapeOpenProperties10. *
* - * @param filePath a {@link java.lang.String} object - * @param fluidName a {@link java.lang.String} object + * @return an array of {@link java.lang.String} objects */ - public void saveObjectToFile(String filePath, String fluidName); + public String[] getCapeOpenProperties10(); /** *- * readObjectFromFile. + * getCapeOpenProperties11. *
* - * @param filePath a {@link java.lang.String} object - * @param fluidName a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return an array of {@link java.lang.String} objects */ - public SystemInterface readObjectFromFile(String filePath, String fluidName); + public String[] getCapeOpenProperties11(); /** *- * getLiquidVolume. + * getCASNumbers. *
* - * @return a double + * @return an array of {@link java.lang.String} objects */ - public double getLiquidVolume(); + public String[] getCASNumbers(); /** *- * resetPhysicalProperties. + * Getter for property characterization. *
+ * + * @return a {@link neqsim.thermo.characterization.Characterise} object */ - public void resetPhysicalProperties(); + public neqsim.thermo.characterization.Characterise getCharacterization(); /** *- * phaseToSystem. + * getChemicalReactionOperations. *
* - * @param phaseNumber a int - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object */ - public SystemInterface phaseToSystem(int phaseNumber); + public ChemicalReactionOperations getChemicalReactionOperations(); /** *- * phaseToSystem. + * getCompFormulaes. *
* - * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return an array of {@link java.lang.String} objects */ - public SystemInterface phaseToSystem(PhaseInterface newPhase); + public String[] getCompFormulaes(); /** *- * phaseToSystem. + * getCompIDs. *
* - * @param phaseName a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return an array of {@link java.lang.String} objects */ - public SystemInterface phaseToSystem(String phaseName); + public String[] getCompIDs(); /** - *- * phaseToSystem. - *
+ * Get normalized names of all components in System. * - * @param phaseNumber1 a int - * @param phaseNumber2 a int - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return Array of names of components in System. */ - public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2); + public String[] getCompNames(); /** *- * changeComponentName. + * Get component by index. *
* - * @param name a {@link java.lang.String} object - * @param newName a {@link java.lang.String} object + * @param i Component index + * @return a {@link neqsim.thermo.component.ComponentInterface} object */ - public void changeComponentName(String name, String newName); + public default ComponentInterface getComponent(int i) { + return getPhase(0).getComponent(i); + } /** *- * getWaxModel. + * Get component by name. *
* - * @return a {@link neqsim.thermo.characterization.WaxModelInterface} object + * @param name Name of component + * @return a {@link neqsim.thermo.component.ComponentInterface} object */ - public WaxModelInterface getWaxModel(); + public default ComponentInterface getComponent(String name) { + return getPhase(0).getComponent(name); + } /** - *- * getWaxCharacterisation. - *
+ * Get normalized names of components in System. * - * @return a {@link neqsim.thermo.characterization.WaxCharacterise} object + * @return Array of names of components in system. */ - public neqsim.thermo.characterization.WaxCharacterise getWaxCharacterisation(); + public default String[] getComponentNames() { + return getPhase(0).getComponentNames(); + } /** - * method to get the total molar flow rate of individual components in a fluid. + *+ * getComponentNameTag. + *
* - * @return molar flow of individual components in unit mol/sec + * @return a {@link java.lang.String} object */ - public double[] getMolarRate(); + public String getComponentNameTag(); /** - * Returns true if phase exists and is not null. + * method to return fluid volume with Peneloux volume correction. * - * @param i Phase number - * @return True if phase exists, false if not. - * @deprecated use {@link #isPhase(int i)} instead + * @return volume in unit m3 */ - @Deprecated - public default boolean IsPhase(int i) { - return isPhase(i); - } + public double getCorrectedVolume(); /** - * Returns true if phase exists and is not null. + * method to return the volume fraction of a phase note: with Peneloux volume correction. * - * @param i Phase number - * @return True if phase exists, false if not. + * @param phaseNumber number of the phase to get volume fraction for + * @return volume fraction */ - public boolean isPhase(int i); + public double getCorrectedVolumeFraction(int phaseNumber); /** - * Get phase number i from SystemInterface object. + * method to return specific heat capacity (Cp). * - * @param i Phase number - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @return Cp in unit J/K */ - public PhaseInterface getPhase(int i); + public double getCp(); /** - *- * getPhase. - *
+ * method to return specific heat capacity (Cp) in a specified unit. * - * @param phaseTypeName a {@link java.lang.String} object - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + * @return Cp in specified unit */ - public PhaseInterface getPhase(String phaseTypeName); + public double getCp(String unit); /** - *- * getPhase. - *
+ * method to return specific heat capacity (Cv). * - * @param pt a {@link neqsim.thermo.phase.PhaseType} object - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @return Cv in unit J/K */ - public PhaseInterface getPhase(PhaseType pt); + public double getCv(); /** - *- * Indexed getter for property phaseIndex. - *
+ * method to return specific heat capacity (Cp) in a specified unit. * - * @param i Phase number - * @return PhaseIndex to index into phaseArray. + * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK + * @return Cp in specified unit */ - public int getPhaseIndex(int i); + public double getCv(String unit); /** - * Get property phaseIndex corresponding to a phase. + * method to get density of a fluid note: without Peneloux volume correction. * - * @param phase Phase object to search for. - * @return PhaseIndex to index into phaseArray. + * @return density with unit kg/m3 */ - public int getPhaseIndex(PhaseInterface phase); + public double getDensity(); /** - *- * Get property phaseIndex corresponding to a phase. - *
+ * method to get density of a fluid note: with Peneloux volume correction. * - * @param phaseTypeName a {@link java.lang.String} object - * @return PhaseIndex to index into phaseArray. + * @param unit Supported units are kg/m3, mol/m3 + * @return density in specified unit */ - public int getPhaseIndex(String phaseTypeName); + public double getDensity(String unit); /** *- * setTotalFlowRate. + * getdVdPtn. *
* - * @param flowRate a double - * @param flowunit a {@link java.lang.String} object. flow units are: kg/sec, kg/min, kg/hr - * m3/sec, m3/min, m3/hr, mole/sec, mole/min, mole/hr, Sm3/hr, Sm3/day, idSm3/hr, idSm3/day + * @return a double */ - public void setTotalFlowRate(double flowRate, String flowunit); + public double getdVdPtn(); /** *- * Returns the overall mole composition vector in unit mole fraction. + * getdVdTpn. *
* - * @return an array of {@link double} objects + * @return a double */ - public double[] getMolarComposition(); + public double getdVdTpn(); /** *- * getNumberOfOilFractionComponents. + * getEmptySystemClone. *
* - * @return a int + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public int getNumberOfOilFractionComponents(); + public SystemInterface getEmptySystemClone(); /** - *- * setHeavyTBPfractionAsPlusFraction. - *
+ * method to get the total enthalpy of a fluid. * - * @return a boolean + * @return molar mass in unit J (Joule) */ - public boolean setHeavyTBPfractionAsPlusFraction(); + public double getEnthalpy(); /** - *- * getCapeOpenProperties11. - *
+ * method to return total enthalpy in a specified unit. * - * @return an array of {@link java.lang.String} objects + * @param unit Supported units are 'J', 'J/mol', 'kJ/kmol', 'J/kg' and 'kJ/kg' + * @return enthalpy in specified unit */ - public String[] getCapeOpenProperties11(); + public double getEnthalpy(String unit); /** - *- * getCapeOpenProperties10. - *
+ * method to return total entropy of the fluid. * - * @return an array of {@link java.lang.String} objects + * @return entropy in unit J/K (Joule/Kelvin) */ - public String[] getCapeOpenProperties10(); + public double getEntropy(); /** - *- * getLowestGibbsEnergyPhase. - *
+ * method to return total entropy of the fluid. * - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @param unit unit supported units are J/K, J/molK, J/kgK and kJ/kgK + * @return entropy in specified unit */ - public PhaseInterface getLowestGibbsEnergyPhase(); + public double getEntropy(String unit); /** - *- * getOilFractionNormalBoilingPoints. - *
+ * method to return exergy defined as (h1-T0*s1) in a unit Joule. * - * @return an array of {@link double} objects + * @param temperatureOfSurroundings in Kelvin + * @return a double */ - public double[] getOilFractionNormalBoilingPoints(); + public double getExergy(double temperatureOfSurroundings); /** - *- * getOilFractionLiquidDensityAt25C. - *
+ * method to return exergy in a specified unit. * - * @return an array of {@link double} objects + * @param temperatureOfSurroundings in Kelvin + * @param exergyUnit a {@link java.lang.String} object + * @return exergy in specified unit */ - public double[] getOilFractionLiquidDensityAt25C(); + public double getExergy(double temperatureOfSurroundings, String exergyUnit); /** - *- * getOilFractionMolecularMass. - *
+ * method to return flow rate of fluid. * - * @return an array of {@link double} objects + * @param flowunit Supported units are kg/sec, kg/min, kg/hr, kg/day, m3/sec, m3/min, m3/hr, + * idSm3/hr, Sm3/sec, Sm3/hr, Sm3/day, MSm3/day, mole/sec, mole/min, mole/hr + * @return flow rate in specified unit */ - public double[] getOilFractionMolecularMass(); + public double getFlowRate(String flowunit); /** *- * getOilFractionIDs. + * Getter for property info. *
* - * @return an array of {@link int} objects + * @return a {@link java.lang.String} object */ - public int[] getOilFractionIDs(); + public String getFluidInfo(); /** *- * getMoleFraction. + * getFluidName. *
* - * @param phaseNumber a int - * @return a double + * @return a {@link java.lang.String} object */ - public double getMoleFraction(int phaseNumber); + public String getFluidName(); /** - * method to return specific heat capacity (Cv). + * method to return heat capacity ratio/adiabatic index/Poisson constant. * - * @return Cv in unit J/K + * @return kappa */ - public double getCv(); + public double getGamma(); /** - * method to return specific heat capacity (Cp) in a specified unit. + * method to return heat capacity ratio calculated as Cp/(Cp-R). * - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - * @return Cp in specified unit + * @return kappa */ - public double getCv(String unit); + public default double getGamma2() { + return getCp() / (getCp() - ThermodynamicConstantsInterface.R * getTotalNumberOfMoles()); + } /** *- * Getter for property characterization. + * getGasPhase. *
* - * @return a {@link neqsim.thermo.characterization.Characterise} object + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public neqsim.thermo.characterization.Characterise getCharacterization(); + public PhaseInterface getGasPhase(); /** *- * readObject. + * getGibbsEnergy. *
* - * @param ID a int - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @return a double */ - public SystemInterface readObject(int ID); + public double getGibbsEnergy(); /** *- * getCompIDs. + * getHeatOfVaporization. *
* - * @return an array of {@link java.lang.String} objects + * @return a double */ - public String[] getCompIDs(); + public double getHeatOfVaporization(); /** *- * saveObject. + * getHelmholtzEnergy. *
* - * @param ID a int - * @param text a {@link java.lang.String} object - */ - public void saveObject(int ID, String text); - - /** - * Set mole fractions of all components to 0. + * @return a double */ - public void reset(); + public double getHelmholtzEnergy(); /** *- * getCASNumbers. + * Getter for property hydrateCheck. *
* - * @return an array of {@link java.lang.String} objects + * @return a boolean */ - public String[] getCASNumbers(); + public boolean getHydrateCheck(); /** - *- * getMolecularWeights. - *
+ * Get ideal liquid density of fluid in given unit. * - * @return an array of {@link double} objects + * @param unit {@link java.lang.String} Supported units are kg/m3 and gr/cm3 + * @return a double */ - public double[] getMolecularWeights(); + public double getIdealLiquidDensity(String unit); /** *- * getNormalBoilingPointTemperatures. + * Getter for property initType. *
* - * @return an array of {@link double} objects + * @return a int */ - public double[] getNormalBoilingPointTemperatures(); + public int getInitType(); /** - * Get names of all components in System. + * method to return interfacial tension between two phases. * - * @return an array of {@link java.lang.String} objects + * @param phase1 phase number of phase1 + * @param phase2 phase number of phase2 + * @return interfacial tension with unit N/m */ - public String[] getCompNames(); + public double getInterfacialTension(int phase1, int phase2); /** *- * getCompFormulaes. + * getInterfacialTension. *
* - * @return an array of {@link java.lang.String} objects + * @param phase1 phase number of phase1 + * @param phase2 phase number of phase2 + * @param unit a {@link java.lang.String} object + * @return interfacial tension with specified unit */ - public String[] getCompFormulaes(); + public double getInterfacialTension(int phase1, int phase2, String unit); /** - *- * getWtFraction. - *
+ * method to return interfacial tension between two phases. * - * @param phaseNumber a int - * @return a double + * @param phase1 phase type of phase1 as string (valid phases are gas, oil, aqueous) + * @param phase2 phase type of phase2 as string (valid phases are gas, oil, aqueous) + * @return interfacial tension with unit N/m. If one or both phases does not exist - the method + * will return NaN */ - public double getWtFraction(int phaseNumber); + public double getInterfacialTension(String phase1, String phase2); /** - *- * isMultiphaseWaxCheck. - *
+ * method to return internal energy (U) in unit J. * - * @return a boolean + * @return internal energy in unit Joule (J) */ - public boolean isMultiphaseWaxCheck(); + public double getInternalEnergy(); /** - *- * setMultiphaseWaxCheck. - *
+ * method to return internal energy (U) in a specified unit. * - * @param multiphaseWaxCheck a boolean + * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' + * @return enthalpy in specified unit */ - public void setMultiphaseWaxCheck(boolean multiphaseWaxCheck); + public double getInternalEnergy(String unit); /** *- * This method is used to set the total molar composition of a fluid. The total flow rate will be - * kept constant. The input mole fractions will be normalized. + * getInterphaseProperties. *
* - * @param moles an array of {@link double} objects + * @return a {@link neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface} + * object */ - public void setMolarComposition(double[] moles); + public InterphasePropertiesInterface getInterphaseProperties(); /** - * return the phase of to specified type if the phase does not exist, the method will return null. + * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis + * average * - * @param phaseTypeName the phase type to be returned (gas, oil, aqueous, wax, hydrate are - * supported) - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @return Joule Thomson coefficient in K/bar */ - public PhaseInterface getPhaseOfType(String phaseTypeName); + public double getJouleThomsonCoefficient(); /** - *- * setUseTVasIndependentVariables. - *
+ * method to get the Joule Thomson Coefficient of a system. Based on a phase mole fraction basis + * average. * - * @param useTVasIndependentVariables a boolean + * @param unit Supported units are K/bar, C/bar + * @return Joule Thomson coefficient in specified unit */ - public void setUseTVasIndependentVariables(boolean useTVasIndependentVariables); + public double getJouleThomsonCoefficient(String unit); /** - * method to add true boiling point fraction. + * method to return heat capacity ratio/adiabatic index/Poisson constant. * - * @param componentName selected name of the component to be added - * @param numberOfMoles number of moles to be added - * @param molarMass molar mass of the component in kg/mol - * @param density density of the component in g/cm3 + * @return kappa */ - public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, - double density); + public double getKappa(); /** *- * addTBPfraction. + * getKinematicViscosity. *
* - * @param componentName a {@link java.lang.String} object - * @param numberOfMoles a double - * @param molarMass a double - * @param density a double - * @param criticalTemperature a double - * @param criticalPressure a double - * @param acentricFactor a double + * @return a double */ - public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, - double density, double criticalTemperature, double criticalPressure, double acentricFactor); + public double getKinematicViscosity(); /** - *- * addPlusFraction. - *
+ * method to return kinematic viscosity in a specified unit. * - * @param componentName a {@link java.lang.String} object - * @param numberOfMoles a double - * @param molarMass a double - * @param density a double + * @param unit Supported units are m2/sec + * @return kinematic viscosity in specified unit */ - public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, - double density); + public double getKinematicViscosity(String unit); /** *- * addSalt. + * getLiquidPhase. *
* - * @param componentName a {@link java.lang.String} object - * @param value a double + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public void addSalt(String componentName, double value); + public PhaseInterface getLiquidPhase(); /** *- * deleteFluidPhase. + * getLiquidVolume. *
* - * @param phase a int + * @return a double */ - public void deleteFluidPhase(int phase); + public double getLiquidVolume(); /** *- * setBmixType. + * getLowestGibbsEnergyPhase. *
* - * @param bmixType a int - */ - public void setBmixType(int bmixType); - - /** - * Verify if system has a phase of a specific type. - * - * @param pt PhaseType to look for - * @return True if system contains a phase of requested type + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public boolean hasPhaseType(PhaseType pt); + public PhaseInterface getLowestGibbsEnergyPhase(); /** - * Verify if system has a phase of a specific type. + * method to return mass of fluid. * - * @param phaseTypeName PhaseType to look for - * @return True if system contains a phase of requested type + * @param unit Supported units are kg, gr, tons + * @return mass in specified unit */ - public default boolean hasPhaseType(String phaseTypeName) { - return hasPhaseType(PhaseType.byDesc(phaseTypeName)); - } + public double getMass(String unit); /** *
- * hasSolidPhase.
+ * Getter for property maxNumberOfPhases
.
*
- * addSolidComplexPhase. + * getMixingRule. *
* - * @param type a {@link java.lang.String} object - */ - public void addSolidComplexPhase(String type); - - /** - *- * resetCharacterisation. - *
+ * @return a int */ - public void resetCharacterisation(); + public int getMixingRule(); /** *@@ -1092,1540 +1089,1527 @@ public default boolean hasSolidPhase() { /** *
- * tuneModel. + * Returns the overall mole composition vector in unit mole fraction. *
* - * @param model a {@link java.lang.String} object - * @param val a double - * @param phase a int + * @return an array of type double */ - public void tuneModel(String model, double val, int phase); + public double[] getMolarComposition(); /** - * add a component to a fluid. If component already exists, the moles will be added to the - * existing component. + * Get molar mass of system. * - * @param inComponent Component object to add. + * @return molar mass in unit kg/mol */ - public void addComponent(ComponentInterface inComponent); + public double getMolarMass(); /** - * add a component to a fluid. If component already exists, the moles will be added to the - * existing component. + * method to get molar mass of a fluid phase. * - * @param name Name of the component to add. See NeqSim database for component in the database. + * @param unit Supported units are kg/mol, gr/mol + * @return molar mass in specified unit */ - public void addComponent(String name); + public double getMolarMass(String unit); /** - * add a component to a fluid. If component already exists, the moles will be added to the - * existing component. + * method to get the total molar flow rate of individual components in a fluid. * - * @param moles number of moles (per second) of the component to be added to the fluid - * @param name Name of the component to add. See NeqSim database for component in the database. + * @return molar flow of individual components in unit mol/sec */ - public void addComponent(String name, double moles); + public double[] getMolarRate(); /** - * add a component to a fluid. If component already exists, the moles will be added to the - * existing component. + * method to return molar volume of the fluid note: without Peneloux volume correction. * - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param value The amount - * @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 .. + * @return molar volume volume in unit m3/mol*1e5 */ - public void addComponent(String name, double value, String unitName); + public double getMolarVolume(); + + /** + * method to return molar volume of the fluid: eventual volume correction included. + * + * @param unit Supported units are m3/mol, litre/mol + * @return molar volume volume in unit + */ + public double getMolarVolume(String unit); /** *- * addComponent. + * getMolecularWeights. *
* - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param moles number of moles (per second) of the component to be added to the fluid - * @param TC Critical temperature - * @param PC Critical pressure - * @param acs a double + * @return an array of type double */ - public void addComponent(String name, double moles, double TC, double PC, double acs); + public double[] getMolecularWeights(); /** - * add a component to a fluid. If component already exists, the moles will be added to the - * existing component. + *+ * getMoleFraction. + *
* - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param moles number of moles (per second) of the component to be added to the fluid - * @param phaseNumber Number of the phase to add the component to + * @param phaseNumber a int + * @return a double */ - public void addComponent(String name, double moles, int phaseNumber); + public double getMoleFraction(int phaseNumber); /** - * add a component to a fluid. I component already exists, it will be added to the component + *+ * Get sum of mole fractions for all components. NB! init(0) must be called first. + *
* - * @param name Name of the component to add. See NeqSim database for component in the database. - * @param value rate of the component to add to the fluid - * @param unitName the unit of the flow rate (eg. mol/sec, kg/sec, etc.) - * @param phaseNumber Number of the phase to add the component to + * @return a double */ - public void addComponent(String name, double value, String unitName, int phaseNumber); + public double getMoleFractionsSum(); + + /** + *+ * getNormalBoilingPointTemperatures. + *
+ * + * @return an array of type double + */ + public double[] getNormalBoilingPointTemperatures(); + + /** + *+ * Get number of components added to System. + *
+ * + * @return the number of components in System. + */ + public int getNumberOfComponents(); /** *
- * addComponent.
+ * Getter for property numberOfMoles
.
*
- * addComponent. + * getNumberOfOilFractionComponents. *
* - * @param index Component number to add - * @param moles number of moles (per second) of the component to be added to the fluid - * @param phaseNumber Number of the phase to add the component to + * @return a int */ - public void addComponent(int index, double moles, int phaseNumber); + public int getNumberOfOilFractionComponents(); /** *
- * removeComponent.
+ * Getter for property numberOfPhases
.
*
- * Getter for property beta
.
- *
- * Gets value for heaviest phase.
+ * getOilFractionIDs.
*
- * Getter for property beta
for a specific phase.
+ * getOilFractionLiquidDensityAt25C.
*
- * Setter for property beta
. NB! Sets beta = b for first phase and 1-b for second
- * phase, not for multiphase systems.
+ * getOilFractionMolecularMass.
*
- * Setter for property beta
for a given phase.
+ * getOilFractionNormalBoilingPoints.
*
- * Save System object to file.
+ * Getter for property PC
.
*
- * setModel. + * getPhase. *
* - * @param model a {@link java.lang.String} object - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param pt a {@link neqsim.thermo.phase.PhaseType} object + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public SystemInterface setModel(String model); + public PhaseInterface getPhase(PhaseType pt); /** - * method to set mixing rule used for the fluid. + *+ * getPhase. + *
* - * @param type The type of mixing rule to be used for the fluid. 1 - classic mixing rule with all - * kij set to zero 2 -classic mixing rule with kij from NeqSim database 3- classic mixing - * rule with temperature dependent kij 4- Huron Vidal mixing rule with parameters from - * NeqSim database 7 -classic mixing rule with kij of CPA from NeqSim Database 9 - * -classicmixing rule with temperature dependent kij of CPA from NeqSim database - * 10-classic mixing rule with temperature and composition dependent kij of CPA from NeqSim - * database + * @param phaseTypeName a {@link java.lang.String} object + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public void setMixingRule(int type); + public PhaseInterface getPhase(String phaseTypeName); /** - * method to set the mixing rule for the fluid. + * method to return phase fraction of selected phase. * - * @param typename a {@link java.lang.String} object + * @param phaseTypeName gas/oil/aqueous + * @param unit mole/volume/weight + * @return phase: fraction in specified unit */ - public void setMixingRule(String typename); + public double getPhaseFraction(String phaseTypeName, String unit); /** *- * setMixingRule. + * Indexed getter for property phaseIndex. *
* - * @param typename a {@link java.lang.String} object - * @param GEmodel a {@link java.lang.String} object + * @param i Phase number + * @return PhaseIndex to index into phaseArray. */ - public void setMixingRule(String typename, String GEmodel); + public int getPhaseIndex(int i); /** - *- * normalizeBeta. - *
+ * Get property phaseIndex corresponding to a phase. + * + * @param phase Phase object to search for. + * @return PhaseIndex to index into phaseArray. */ - public void normalizeBeta(); + public int getPhaseIndex(PhaseInterface phase); /** *- * Setter for property initType. + * Get property phaseIndex corresponding to a phase. *
* - * @param initType a int + * @param phaseTypeName a {@link java.lang.String} object + * @return PhaseIndex to index into phaseArray. */ - public void setInitType(int initType); + public int getPhaseIndex(String phaseTypeName); /** *- * checkStability. + * Get phase number of phase of specific type. *
* - * @return a boolean + * @param pt Phase type to look for. + * @return Phase number */ - public boolean checkStability(); + public int getPhaseNumberOfPhase(PhaseType pt); /** *- * checkStability. + * Get phase number of phase of specific type. * *
* - * @param val a boolean + * @param phaseTypeName Name of phase type to look for + * @return Phase number */ - public void checkStability(boolean val); + public default int getPhaseNumberOfPhase(String phaseTypeName) { + return getPhaseNumberOfPhase(PhaseType.byDesc(phaseTypeName)); + } /** - *- * Getter for property hasPlusFraction. - *
+ * return the phase of to specified type if the phase does not exist, the method will return null. * - * @return a boolean + * @param phaseTypeName the phase type to be returned (gas, oil, aqueous, wax, hydrate are + * supported) + * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public boolean hasPlusFraction(); + public PhaseInterface getPhaseOfType(String phaseTypeName); /** *- * Getter for property initType. + * getPhases. *
* - * @return a int + * @return an array of {@link neqsim.thermo.phase.PhaseInterface} objects */ - public int getInitType(); + public PhaseInterface[] getPhases(); + + /** + * method to return pressure. + * + * @return pressure in unit bara + */ + public double getPressure(); /** *- * invertPhaseTypes. + * method to return pressure of phase. *
+ * + * @param phaseNumber Number of the phase to get pressure for + * @return pressure in unit bara */ - public void invertPhaseTypes(); + public double getPressure(int phaseNumber); /** - * method to return fluid volume with Peneloux volume correction. + * method to return pressure in a specified unit. * - * @return volume in unit m3 + * @param unit Supported units are bara, barg, Pa, MPa, psi, psia, psig + * @return pressure in specified unit */ - public double getCorrectedVolume(); + public double getPressure(String unit); /** - *- * readFluid. - *
+ * Get physical properties of System. * - * @param fluidName a {@link java.lang.String} object + * @return System properties */ - public void readFluid(String fluidName); + public SystemProperties getProperties(); /** *- * calcKIJ. + * getProperty. *
* - * @param ok a boolean + * @param prop a {@link java.lang.String} object + * @return a double */ - public void calcKIJ(boolean ok); + public double getProperty(String prop); /** *- * write. + * getProperty. *
* - * @param name a {@link java.lang.String} object - * @param filename a {@link java.lang.String} object - * @param newfile a boolean + * @param prop a {@link java.lang.String} object + * @param phase a int + * @return a double */ - public void write(String name, String filename, boolean newfile); + public double getProperty(String prop, int phase); /** *- * useVolumeCorrection. + * getProperty. *
* - * @param volcor a boolean + * @param prop a {@link java.lang.String} object + * @param compName a {@link java.lang.String} object + * @param phase a int + * @return a double */ - public void useVolumeCorrection(boolean volcor); + public double getProperty(String prop, String compName, int phase); /** *- * Getter for property numericDerivatives. + * getResultTable. *
* - * @return a boolean + * @return an array of {@link java.lang.String} objects */ - public boolean isNumericDerivatives(); + public String[][] getResultTable(); /** - *- * Setter for property numericDerivatives. - *
+ * method to get the speed of sound of a system. The sound speed is implemented based on a molar + * average over the phases * - * @param numericDerivatives a boolean + * @return speed of sound in m/s */ - public void setNumericDerivatives(boolean numericDerivatives); + public double getSoundSpeed(); /** - *- * Getter for property info. - *
+ * method to get the speed of sound of a system. The sound speed is implemented based on a molar + * average over the phases * - * @return a {@link java.lang.String} object + * @param unit Supported units are m/s, km/h + * @return speed of sound in m/s */ - public String getFluidInfo(); + public double getSoundSpeed(String unit); /** *- * Setter for property info. . + * Getter for property standard. *
* - * @param info a {@link java.lang.String} object + * @return a {@link neqsim.standards.StandardInterface} object */ - public void setFluidInfo(String info); + public neqsim.standards.StandardInterface getStandard(); /** *
- * Indexed setter for property phaseIndex
.
- * this.phaseIndex[index] = phaseIndex;
+ * Getter for property standard.
*
- * Set phaseArray[phaseIndex] = phase
. NB! Transfers the pressure and temperature
- * from the currently existing phase object at index numb
+ * Getter for property TC
.
*
- * resetDatabase. + * method to return temperature. *
+ * + * @param phaseNumber phase to get temperature of + * @return temperature in unit Kelvin */ - public void resetDatabase(); + public double getTemperature(int phaseNumber); /** - *- * Setter for property solidPhaseCheck. - *
+ * method to return temperature in a specified unit. * - * @param test a boolean + * @param unit Supported units are K, C, R + * @return temperature in specified unit */ - public void setSolidPhaseCheck(boolean test); + public double getTemperature(String unit); /** - *- * setSolidPhaseCheck. - *
+ * method to return conductivity of a fluid. * - * @param solidComponent a {@link java.lang.String} object + * @return conductivity in unit W/mK */ - public void setSolidPhaseCheck(String solidComponent); + public double getThermalConductivity(); /** - *- * doSolidPhaseCheck. - *
+ * method to return thermal conductivity in a specified unit. * - * @return a boolean + * @param unit Supported units are W/mK, W/cmK + * @return conductivity in specified unit */ - public boolean doSolidPhaseCheck(); + public double getThermalConductivity(String unit); /** - *
- * Getter for property multiPhaseCheck
.
- *
totalNumberOfMoles
.
*
- * @return a boolean
+ * @return Total molar flow rate of fluid in unit mol/sec
*/
- public boolean doMultiPhaseCheck();
+ public double getTotalNumberOfMoles();
/**
- * method to specify if calculations should check for more than two fluid phases.
+ * method to return viscosity of a fluid.
*
- * @param doMultiPhaseCheck Specify if the calculations should check for more than two fluid
- * phases. Default is two fluid phases (gas and liquid). If set to true the program will
- * check for gas and multiple liquid phases (eg. gas-oil-aqueous).
+ * @return viscosity in unit kg/msec
*/
- public void setMultiPhaseCheck(boolean doMultiPhaseCheck);
+ public double getViscosity();
/**
- * Calculate thermodynamic properties of the fluid using the init type set in fluid.
+ * method to return viscosity in a specified unit.
*
- * @see getInitType
+ * @param unit Supported units are kg/msec, cP (centipoise), Pas (Pascal*second)
+ * @return viscosity in specified unit
*/
- public default void init() {
- this.init(this.getInitType());
- }
+ public double getViscosity(String unit);
/**
- * method to calculate thermodynamic properties of the fluid. The temperature, pressure, number of
- * phases and composition of the phases will be used as basis for calculation.
+ * method to return fluid volume.
*
- * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition for all phases. 1:
- * Calculation of density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy,
- * Cp, Cv, and most other thermodynamic properties 3: 1+2 + Calculation of composition
- * derivatives of fugacity coefficients.
+ * @return volume in unit m3*1e5
*/
- public void init(int number);
+ public double getVolume();
/**
- * method to calculate thermodynamic properties of the selected phase. The temperature, pressure,
- * number of phases and composition of the phase will be used as basis for calculation.
+ * method to return fluid volume.
*
- * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition. 1: Calculation of
- * density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy, Cp, Cv, and
- * most other thermodynamic properties 3: 1+2 + Calculation of composition derivatives of
- * fugacity coefficients.
- * @param phase a int
+ * @param unit Supported units are m3, litre, m3/kg, m3/mol
+ * @return volume in specified unit
*/
- public void init(int number, int phase);
+ public double getVolume(String unit);
/**
- * Calculates thermodynamic properties of a fluid using the init(2) method.
+ * method to return the volume fraction of a phase note: without Peneloux volume correction.
+ *
+ * @param phaseNumber number of the phase to get volume fraction for
+ * @return volume fraction
*/
- public default void initThermoProperties() {
- init(2);
- }
+ public double getVolumeFraction(int phaseNumber);
/**
- * initNumeric.
+ * + * getWaxCharacterisation. + *
+ * + * @return a {@link neqsim.thermo.characterization.WaxCharacterise} object */ - public void initNumeric(); + public neqsim.thermo.characterization.WaxCharacterise getWaxCharacterisation(); /** *- * display. + * getWaxModel. *
+ * + * @return a {@link neqsim.thermo.characterization.WaxModelInterface} object */ - public void display(); + public WaxModelInterface getWaxModel(); /** *- * display. + * getWtFraction. *
* - * @param name a {@link java.lang.String} object + * @param phaseNumber a int + * @return a double */ - public void display(String name); + public double getWtFraction(int phaseNumber); /** - * Prints the fluid in a visually appealing way. + * method to return compressibility factor of a fluid compressibility factor is defined in EoS + * from PV=ZnRT where V is total volume of fluid. * + * @return compressibility factor Z */ - public default void prettyPrint() { - neqsim.thermo.util.readwrite.TablePrinter.printTable(createTable(getFluidName())); + public double getZ(); + + /** + * method to return Z volume corrected gas compressibility + * + * @return double Z volume corrected + */ + public double getZvolcorr(); + + /** + * Verify if system has a component. + * + * @param name Name of component to look for. NB! Converts name to normalized name. + * @return True if component is found. + */ + public default boolean hasComponent(String name) { + return hasComponent(name, true); } /** - *- * addFluid. - *
+ * Verify if system has a component. * - * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object - * @return SystemInterface + * @param name Name of component to look for. + * @param normalized Set true to convert input name to normalized component name. + * @return True if component is found. */ - public SystemInterface addFluid(SystemInterface addSystem); + public default boolean hasComponent(String name, boolean normalized) { + return getPhase(0).hasComponent(name, normalized); + } + + /** {@inheritDoc} */ + @Override + public int hashCode(); /** - *- * addFluid. - *
+ * Verify if system has a phase of a specific type. * - * @param addSystem a {@link neqsim.thermo.system.SystemInterface} object - * @param phase phase number of phase to add fluid to - * @return SystemInterface + * @param pt PhaseType to look for + * @return True if system contains a phase of requested type */ - public SystemInterface addFluid(SystemInterface addSystem, int phase); + public boolean hasPhaseType(PhaseType pt); /** - *- * Getter for property hydrateCheck. - *
+ * Verify if system has a phase of a specific type. * - * @return a boolean + * @param phaseTypeName PhaseType to look for + * @return True if system contains a phase of requested type */ - @Deprecated - public boolean doHydrateCheck(); + public default boolean hasPhaseType(String phaseTypeName) { + return hasPhaseType(PhaseType.byDesc(phaseTypeName)); + } /** *- * Getter for property hydrateCheck. + * Getter for property hasPlusFraction. *
* * @return a boolean */ - public boolean getHydrateCheck(); + public boolean hasPlusFraction(); /** *- * createTable. + * hasSolidPhase. *
* - * @param name a {@link java.lang.String} object - * @return an array of {@link java.lang.String} objects + * @return True if system contains a solid phase */ - public String[][] createTable(String name); + public default boolean hasSolidPhase() { + return hasPhaseType(PhaseType.SOLID); // || hasPhaseType(PhaseType.SOLIDCOMPLEX); + } /** - *- * setHydrateCheck. - *
+ * Calculate thermodynamic properties of the fluid using the init type set in fluid. * - * @param hydrateCheck a boolean + * @see getInitType */ - public void setHydrateCheck(boolean hydrateCheck); + public default void init() { + this.init(this.getInitType()); + } /** - *- * calcBeta. For simple gas liquid systems. - *
+ * method to calculate thermodynamic properties of the fluid. The temperature, pressure, number of + * phases and composition of the phases will be used as basis for calculation. * - * @return Beta Mole fraction contained in the heaviest phase, i.e., liquid phase. - * @throws neqsim.util.exception.IsNaNException if any. - * @throws neqsim.util.exception.TooManyIterationsException if any. + * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition for all phases. 1: + * Calculation of density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy, + * Cp, Cv, and most other thermodynamic properties 3: 1+2 + Calculation of composition + * derivatives of fugacity coefficients. */ - public double calcBeta() - throws neqsim.util.exception.IsNaNException, neqsim.util.exception.TooManyIterationsException; + public void init(int number); + + // public void setPressure(double newPressure, int phaseNumber); /** - *- * setAllComponentsInPhase. - *
+ * method to calculate thermodynamic properties of the selected phase. The temperature, pressure, + * number of phases and composition of the phase will be used as basis for calculation. * + * @param number - The number can be 0, 1, 2 or 3. 0: Set feed composition. 1: Calculation of + * density, fugacities and Z-factor 2: 1 + calculation of enthalpy, entropy, Cp, Cv, and + * most other thermodynamic properties 3: 1+2 + Calculation of composition derivatives of + * fugacity coefficients. * @param phase a int */ - public void setAllComponentsInPhase(int phase); + public void init(int number, int phase); /** *- * initTotalNumberOfMoles. + * init_x_y. *
- * - * @param change a double */ - public void initTotalNumberOfMoles(double change); + public void init_x_y(); /** *- * calc_x_y. + * Calculate system beta values using Phase.getNumberOfMolesInPhase and getTotalNumberOfMoles. *
*/ - public void calc_x_y(); + public void initBeta(); /** - *- * reset_x_y. - *
+ * initNumeric. */ - public void reset_x_y(); + public void initNumeric(); /** - * Add phase to SystemInterface object. + * Init physical properties for all phases and interfaces. */ - public void addPhase(); + public void initPhysicalProperties(); /** - *- * setAttractiveTerm. - *
+ * Calculates physical properties of type propertyName. * - * @param i a int + * @param propertyName a {@link java.lang.String} object */ - public void setAttractiveTerm(int i); + public void initPhysicalProperties(String propertyName); /** - *- * removePhase. - *
- * - * @param specPhase a int + * Calculates thermodynamic and physical properties of a fluid using initThermoProperties() and + * initPhysicalProperties(). */ - public void removePhase(int specPhase); - - // public void setPressure(double newPressure, int phaseNumber); + public void initProperties(); /** - * method to return pressure. - * - * @return pressure in unit bara + *+ * initRefPhases. + *
*/ - public double getPressure(); + public void initRefPhases(); /** - * method to return pressure in a specified unit. - * - * @param unit Supported units are bara, barg, Pa and MPa - * @return pressure in specified unit + * Calculates thermodynamic properties of a fluid using the init(2) method. */ - public double getPressure(String unit); + public default void initThermoProperties() { + init(2); + } /** *- * method to return pressure of phase. + * initTotalNumberOfMoles. *
* - * @param phaseNumber Number of the phase to get pressure for - * @return pressure in unit bara + * @param change a double */ - public double getPressure(int phaseNumber); + public void initTotalNumberOfMoles(double change); /** *- * reInitPhaseType. + * invertPhaseTypes. *
*/ - public void reInitPhaseType(); + public void invertPhaseTypes(); /** - * Set the physical property model type for each phase of the System. + *+ * isChemicalSystem. + *
* - * @param type 0 Orginal/default 1 Water 2 Glycol 3 Amine 4 CO2Water 6 Basic + * @return a boolean */ - public void setPhysicalPropertyModel(int type); + public boolean isChemicalSystem(); /** *- * clearAll. + * isChemicalSystem. *
+ * + * @param temp a boolean */ - public void clearAll(); + public void isChemicalSystem(boolean temp); /** - * method to get density of a fluid note: without Peneloux volume correction. + *+ * isForcePhaseTypes. + *
* - * @return density with unit kg/m3 + * @return a boolean */ - public double getDensity(); + public boolean isForcePhaseTypes(); /** - * method to get density of a fluid note: with Peneloux volume correction. + *+ * isImplementedCompositionDeriativesofFugacity. + *
* - * @param unit Supported units are kg/m3, mol/m3 - * @return density in specified unit + * @return a boolean */ - public double getDensity(String unit); + public boolean isImplementedCompositionDeriativesofFugacity(); /** *- * getChemicalReactionOperations. + * isImplementedCompositionDeriativesofFugacity. *
* - * @return a {@link neqsim.chemicalReactions.ChemicalReactionOperations} object + * @param isImpl a boolean */ - public ChemicalReactionOperations getChemicalReactionOperations(); + public void isImplementedCompositionDeriativesofFugacity(boolean isImpl); /** *- * isChemicalSystem. + * isImplementedPressureDeriativesofFugacity. *
* * @return a boolean */ - public boolean isChemicalSystem(); + public boolean isImplementedPressureDeriativesofFugacity(); /** *- * isChemicalSystem. + * isImplementedTemperatureDeriativesofFugacity. *
* - * @param temp a boolean + * @return a boolean */ - public void isChemicalSystem(boolean temp); + public boolean isImplementedTemperatureDeriativesofFugacity(); /** - * method to return molar volume of the fluid note: without Peneloux volume correction. + *+ * isMultiphaseWaxCheck. + *
* - * @return molar volume volume in unit m3/mol*1e5 + * @return a boolean */ - public double getMolarVolume(); + public boolean isMultiphaseWaxCheck(); /** - * Get molar mass of system. + *+ * Getter for property numericDerivatives. + *
* - * @return molar mass in unit kg/mol + * @return a boolean */ - public double getMolarMass(); + public boolean isNumericDerivatives(); /** - * method to get molar mass of a fluid phase. + * Returns true if phase exists and is not null. * - * @param unit Supported units are kg/mol, gr/mol - * @return molar mass in specified unit + * @param i Phase number + * @return True if phase exists, false if not. */ - public double getMolarMass(String unit); + public boolean isPhase(int i); /** - * method to get the total enthalpy of a fluid. - * - * @return molar mass in unit J (Joule) + *+ * normalizeBeta. + *
*/ - public double getEnthalpy(); + public void normalizeBeta(); /** - * method to return total enthalpy in a specified unit. - * - * @param unit Supported units are 'J', 'J/mol', 'J/kg' and 'kJ/kg' - * @return enthalpy in specified unit + * Order phases by density. */ - public double getEnthalpy(String unit); + public void orderByDensity(); /** *- * calcInterfaceProperties. + * phaseToSystem. *
+ * + * @param phaseNumber a int + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public void calcInterfaceProperties(); + public SystemInterface phaseToSystem(int phaseNumber); /** *- * getInterphaseProperties. + * phaseToSystem. *
* - * @return a {@link neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface} - * object + * @param phaseNumber1 a int + * @param phaseNumber2 a int + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public InterphasePropertiesInterface getInterphaseProperties(); + public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2); /** *- * Calculate system beta values using Phase.getNumberOfMolesInPhase and getTotalNumberOfMoles. + * phaseToSystem. *
+ * + * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public void initBeta(); + public SystemInterface phaseToSystem(PhaseInterface newPhase); /** *- * init_x_y. + * phaseToSystem. *
+ * + * @param phaseName a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public void init_x_y(); + public SystemInterface phaseToSystem(String phaseName); /** - * method to return total entropy of the fluid. - * - * @return entropy in unit J/K (Joule/Kelvin) + * Prints the fluid in a visually appealing way. */ - public double getEntropy(); + public default void prettyPrint() { + neqsim.thermo.util.readwrite.TablePrinter.printTable(createTable(getFluidName())); + } /** - * method to return total entropy of the fluid. + *+ * readFluid. + *
* - * @param unit unit supported units are J/K, J/molK, J/kgK and kJ/kgK - * @return entropy in specified unit + * @param fluidName a {@link java.lang.String} object */ - public double getEntropy(String unit); + public void readFluid(String fluidName); /** - * method to return temperature. + *+ * readObject. + *
* - * @return temperature in unit Kelvin + * @param ID a int + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public double getTemperature(); + public SystemInterface readObject(int ID); /** - * method to return temperature in a specified unit. + *+ * readObjectFromFile. + *
* - * @param unit Supported units are K, C, R - * @return temperature in specified unit + * @param filePath a {@link java.lang.String} object + * @param fluidName a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public double getTemperature(String unit); + public SystemInterface readObjectFromFile(String filePath, String fluidName); /** *- * method to return temperature. + * reInitPhaseType. *
- * - * @param phaseNumber phase to get temperature of - * @return temperature in unit Kelvin */ - public double getTemperature(int phaseNumber); + public void reInitPhaseType(); /** *- * chemicalReactionInit. + * removeComponent. *
+ * + * @param name Name of the component to remove. See NeqSim database for component in the database. */ - public void chemicalReactionInit(); - - // public double getdfugdt(int i, int j); + public void removeComponent(String name); /** - * Change the phase type of a given phase. + *+ * removePhase. + *
* - * @param phaseToChange the phase number of the phase to set phase type - * @param newPhaseType the phasetype number to set - * @deprecated Replaced by {@link setPhaseType} + * @param specPhase a int */ - @Deprecated - public default void setPhaseType(int phaseToChange, int newPhaseType) { - setPhaseType(phaseToChange, PhaseType.byValue(newPhaseType)); - } + public void removePhase(int specPhase); /** - * Change the phase type of a given phase. + *+ * removePhaseKeepTotalComposition. + *
* - * @param phaseToChange the phase number of the phase to set phase type - * @param phaseTypeName the phase type name, see PhaseTypes + * @param specPhase a int */ - public default void setPhaseType(int phaseToChange, String phaseTypeName) { - setPhaseType(phaseToChange, PhaseType.byDesc(phaseTypeName)); - } + public void removePhaseKeepTotalComposition(int specPhase); /** - * Change the phase type of a given phase. + *+ * renameComponent. + *
* - * @param phaseToChange the phase number of the phase to set phase type - * @param pt PhaseType to set + * @param oldName a {@link java.lang.String} object + * @param newName a {@link java.lang.String} object */ - public void setPhaseType(int phaseToChange, PhaseType pt); + public void renameComponent(String oldName, String newName); /** - * Set phase type of all phases. + *+ * replacePhase. + *
* - * @param phases Set to "all" to set all phases, else nothing happens. - * @param newPhaseType the phasetype number to set - * @deprecated Replaced by {@link setAllPhaseType} + * @param repPhase a int + * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object */ - @Deprecated - public void setPhaseType(String phases, int newPhaseType); + public void replacePhase(int repPhase, PhaseInterface newPhase); /** - * Set phase type of all phases. - * - * @param pt PhaseType to set phases as. + * Set mole fractions of all components to 0. */ - public void setAllPhaseType(PhaseType pt); + public void reset(); /** *
- * Getter for property TC
.
+ * reset_x_y.
*
- * Getter for property TC
.
+ * resetCharacterisation.
*
- * Getter for property PC
.
+ * resetDatabase.
*
- * Getter for property PC
.
+ * resetPhysicalProperties.
*
- * getPhases. + * Save System object to file. *
* - * @return an array of {@link neqsim.thermo.phase.PhaseInterface} objects + * @param name File path to save to. */ - public PhaseInterface[] getPhases(); + public void save(String name); /** *
- * Getter for property numberOfPhases
.
+ * saveFluid.
*
- * Setter for property numberOfPhases
.
+ * saveFluid.
*
- * Getter for property maxNumberOfPhases
.
+ * saveObject.
*
- * Setter for property maxNumberOfPhases
.
+ * saveObjectToFile.
*
- * getGibbsEnergy. + * saveToDataBase. *
- * - * @return a double */ - public double getGibbsEnergy(); + public void saveToDataBase(); /** *- * getHelmholtzEnergy. + * setAllComponentsInPhase. *
* - * @return a double + * @param phase a int */ - public double getHelmholtzEnergy(); + public void setAllComponentsInPhase(int phase); /** - *
- * Getter for property componentNames
.
- *
- * Get component by name. + * setAttractiveTerm. *
* - * @param name Name of component - * @return a {@link neqsim.thermo.component.ComponentInterface} object + * @param i a int */ - public default ComponentInterface getComponent(String name) { - return getPhase(0).getComponent(name); - } + public void setAttractiveTerm(int i); /** *
- * Get component by index.
+ * Setter for property beta
. NB! Sets beta = b for first phase and 1-b for second
+ * phase, not for multiphase systems.
*
- * clone.
+ * Setter for property beta
for a given phase.
*
- * getdVdPtn. + * setBmixType. *
* - * @return a double + * @param bmixType a int */ - public double getdVdPtn(); + public void setBmixType(int bmixType); /** *- * getdVdTpn. + * setComponentNames. *
* - * @return a double + * @param componentNames an array of {@link java.lang.String} objects */ - public double getdVdTpn(); + public void setComponentNames(String[] componentNames); /** - * method to return specific heat capacity (Cp). + *+ * setComponentNameTag. + *
* - * @return Cp in unit J/K + * @param nameTag a {@link java.lang.String} object */ - public double getCp(); + public void setComponentNameTag(String nameTag); /** - * method to return specific heat capacity (Cp) in a specified unit. + *+ * setComponentNameTagOnNormalComponents. + *
* - * @param unit Supported units are J/K, J/molK, J/kgK and kJ/kgK - * @return Cp in specified unit + * @param nameTag a {@link java.lang.String} object */ - public double getCp(String unit); + public void setComponentNameTagOnNormalComponents(String nameTag); /** - * method to return heat capacity ratio/adiabatic index/Poisson constant. - * - * @return kappa + * Set the flow rate (moles) of all components to zero. */ - public double getKappa(); + public void setEmptyFluid(); /** *- * replacePhase. + * Setter for property info. . *
* - * @param repPhase a int - * @param newPhase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param info a {@link java.lang.String} object */ - public void replacePhase(int repPhase, PhaseInterface newPhase); + public void setFluidInfo(String info); /** *- * getGasPhase. + * setFluidName. *
* - * @return a {@link neqsim.thermo.phase.PhaseInterface} object + * @param fluidName a {@link java.lang.String} object */ - public PhaseInterface getGasPhase(); + public void setFluidName(String fluidName); /** *- * getLiquidPhase. + * setForcePhaseTypes. *
* - * @return a {@link neqsim.thermo.phase.PhaseInterface} object - */ - public PhaseInterface getLiquidPhase(); - - /** - * method to return compressibility factor of a fluid compressibility factor is defined in EoS - * from PV=ZnRT where V is total volume of fluid. - * - * @return compressibility factor Z - */ - public double getZ(); - - /** - * method to return viscosity of a fluid. - * - * @return viscosity in unit kg/msec + * @param forcePhaseTypes a boolean */ - public double getViscosity(); + public void setForcePhaseTypes(boolean forcePhaseTypes); /** - * method to return viscosity in a specified unit. + *+ * setHeavyTBPfractionAsPlusFraction. + *
* - * @param unit Supported units are kg/msec, cP (centipoise) - * @return viscosity in specified unit + * @return a boolean */ - public double getViscosity(String unit); + public boolean setHeavyTBPfractionAsPlusFraction(); /** - * method to return thermal conductivity. + *+ * setHydrateCheck. + *
* - * @return conductivity in unit W/mK - * @deprecated use {@link #getThermalConductivity()} instead. + * @param hydrateCheck a boolean */ - @Deprecated - public double getConductivity(); + public void setHydrateCheck(boolean hydrateCheck); /** - * method to return thermal conductivity in a specified unit. + *+ * setImplementedCompositionDeriativesofFugacity. + *
* - * @param unit Supported units are W/mK, W/cmK - * @return conductivity in specified unit - * @deprecated use {@link #getThermalConductivity(String unit)} instead. + * @param implementedCompositionDeriativesofFugacity a boolean */ - @Deprecated - public double getConductivity(String unit); + public void setImplementedCompositionDeriativesofFugacity( + boolean implementedCompositionDeriativesofFugacity); /** - * method to return conductivity of a fluid. + *+ * setImplementedPressureDeriativesofFugacity. + *
* - * @return conductivity in unit W/mK + * @param implementedPressureDeriativesofFugacity a boolean */ - public double getThermalConductivity(); + public void setImplementedPressureDeriativesofFugacity( + boolean implementedPressureDeriativesofFugacity); /** - * method to return thermal conductivity in a specified unit. + *+ * setImplementedTemperatureDeriativesofFugacity. + *
* - * @param unit Supported units are W/mK, W/cmK - * @return conductivity in specified unit + * @param implementedTemperatureDeriativesofFugacity a boolean */ - public double getThermalConductivity(String unit); + public void setImplementedTemperatureDeriativesofFugacity( + boolean implementedTemperatureDeriativesofFugacity); /** *- * initRefPhases. + * Setter for property initType. *
+ * + * @param initType a int */ - public void initRefPhases(); + public void setInitType(int initType); /** *
- * getFluidName.
+ * Setter for property maxNumberOfPhases
.
*
- * setFluidName. - *
+ * method to set mixing rule used for the fluid. * - * @param fluidName a {@link java.lang.String} object + * @param type The type of mixing rule to be used for the fluid. 1 - classic mixing rule with all + * kij set to zero 2 -classic mixing rule with kij from NeqSim database 3- classic mixing + * rule with temperature dependent kij 4- Huron Vidal mixing rule with parameters from + * NeqSim database 7 -classic mixing rule with kij of CPA from NeqSim Database 9 + * -classicmixing rule with temperature dependent kij of CPA from NeqSim database + * 10-classic mixing rule with temperature and composition dependent kij of CPA from NeqSim + * database */ - public void setFluidName(String fluidName); + public void setMixingRule(int type); /** - *- * Getter for property allowPhaseShift. - *
+ * method to set the mixing rule for the fluid. * - * @return a boolean + * @param typename a {@link java.lang.String} object */ - public boolean allowPhaseShift(); + public void setMixingRule(String typename); /** *- * Setter for property allowPhaseShift. + * setMixingRule. *
* - * @param allowPhaseShift a boolean + * @param typename a {@link java.lang.String} object + * @param GEmodel a {@link java.lang.String} object */ - public void allowPhaseShift(boolean allowPhaseShift); + public void setMixingRule(String typename, String GEmodel); /** - * method to return phase fraction of selected phase. + *+ * setModel. + *
* - * @param phaseTypeName gas/oil/aqueous - * @param unit mole/volume/weight - * @return phase: fraction in specified unit + * @param model a {@link java.lang.String} object + * @return a {@link neqsim.thermo.system.SystemInterface} object */ - public double getPhaseFraction(String phaseTypeName, String unit); + public SystemInterface setModel(String model); /** *- * getProperty. + * This method is used to set the total molar composition of a fluid. The total flow rate will be + * kept constant. The input mole fractions will be normalized. *
* - * @param prop a {@link java.lang.String} object - * @param compName a {@link java.lang.String} object - * @param phase a int - * @return a double + * @param moles an array of type double */ - public double getProperty(String prop, String compName, int phase); + public void setMolarComposition(double[] moles); /** - *- * getProperty. - *
+ * This method is used to set the total molar composition of a characterized fluid. The total flow + * rate will be kept constant. The input mole fractions will be normalized. * - * @param prop a {@link java.lang.String} object - * @param phase a int - * @return a double + * @param molefractions is a double array taking the molar fraction of the components in the + * fluid. THe last fraction in the array is the total molefraction of the characterized + * components. */ - public double getProperty(String prop, int phase); + public void setMolarCompositionOfPlusFluid(double[] molefractions); /** - *- * getProperty. - *
+ * This method is used to set the total molar composition of a plus fluid. The total flow rate + * will be kept constant. The input mole fractions will be normalized. * - * @param prop a {@link java.lang.String} object - * @return a double + * @param molefractions is a double array taking the molar fraction of the components in the + * fluid. THe last molfraction is the mole fraction of the plus component */ - public double getProperty(String prop); + public void setMolarCompositionPlus(double[] molefractions); /** *- * Getter for property standard. + * setMolarFlowRates. *
* - * @return a {@link neqsim.standards.StandardInterface} object + * @param moles an array of type double */ - public neqsim.standards.StandardInterface getStandard(); + public void setMolarFlowRates(double[] moles); /** - *- * Getter for property standard. - *
+ * method to specify if calculations should check for more than two fluid phases. * - * @param standardName a {@link java.lang.String} object - * @return a {@link neqsim.standards.StandardInterface} object + * @param doMultiPhaseCheck Specify if the calculations should check for more than two fluid + * phases. Default is two fluid phases (gas and liquid). If set to true the program will + * check for gas and multiple liquid phases (eg. gas-oil-aqueous). */ - public neqsim.standards.StandardInterface getStandard(String standardName); + public void setMultiPhaseCheck(boolean doMultiPhaseCheck); /** *- * Setter for property standard. + * setMultiphaseWaxCheck. *
* - * @param standardName a {@link java.lang.String} object + * @param multiphaseWaxCheck a boolean */ - public void setStandard(String standardName); + public void setMultiphaseWaxCheck(boolean multiphaseWaxCheck); /** *
- * saveToDataBase.
+ * Setter for property numberOfPhases
.
*
- * getMixingRule. + * Setter for property numericDerivatives. *
* - * @return a int + * @param numericDerivatives a boolean */ - public int getMixingRule(); + public void setNumericDerivatives(boolean numericDerivatives); /** *
- * getResultTable.
+ * Getter for property PC
.
*
- * autoSelectModel.
+ * Set phaseArray[phaseIndex] = phase
. NB! Transfers the pressure and temperature
+ * from the currently existing phase object at index numb
*
- * autoSelectMixingRule.
+ * Indexed setter for property phaseIndex
.
+ * this.phaseIndex[index] = phaseIndex;
*
- * addLiquidToGas. - *
+ * Change the phase type of a given phase. * - * @param fraction a double + * @param phaseToChange the phase number of the phase to set phase type + * @param phaseName String to set */ - public void addLiquidToGas(double fraction); + public void setPhaseType(int phaseToChange, String phaseName); /** - *- * addGasToLiquid. - *
+ * Set the physical property model type for each phase of the System. * - * @param fraction a double + * @param type 0 Orginal/default 1 Water 2 Glycol 3 Amine 4 CO2Water 6 Basic */ - public void addGasToLiquid(double fraction); + public void setPhysicalPropertyModel(int type); /** - * Getter for propertytotalNumberOfMoles
.
+ * method to set the pressure of a fluid (same pressure for all phases).
*
- * @return Total molar flow rate of fluid in unit mol/sec
+ * @param pres pressure in unit bara (absolute pressure in bar)
*/
- public double getTotalNumberOfMoles();
+ public void setPressure(double pres);
/**
- *
- * Getter for property numberOfMoles
.
- *
- * Setter for property totalNumberOfMoles
.
+ * Setter for property solidPhaseCheck.
*
- * Get phase number of phase of specific type. + * setSolidPhaseCheck. *
* - * @param pt Phase type to look for. - * @return Phase number + * @param solidComponent a {@link java.lang.String} object */ - public int getPhaseNumberOfPhase(PhaseType pt); + public void setSolidPhaseCheck(String solidComponent); /** *- * Get phase number of phase of specific type. * + * Setter for property standard. *
* - * @param phaseTypeName Name of phase type to look for - * @return Phase number + * @param standardName a {@link java.lang.String} object */ - public default int getPhaseNumberOfPhase(String phaseTypeName) { - return getPhaseNumberOfPhase(PhaseType.byDesc(phaseTypeName)); - } + public void setStandard(String standardName); /** *
- * getEmptySystemClone.
+ * Getter for property TC
.
*
- * calcHenrysConstant. + * method to set the temperature of a fluid (same temperature for all phases). *
* - * @param component a {@link java.lang.String} object - * @return a double + * @param temp a double */ - public double calcHenrysConstant(String component); + public void setTemperature(double temp); /** *- * isImplementedTemperatureDeriativesofFugacity. + * setTemperature. *
* - * @return a boolean + * @param newTemperature a double + * @param phaseNumber a int */ - public boolean isImplementedTemperatureDeriativesofFugacity(); + public void setTemperature(double newTemperature, int phaseNumber); /** - *- * setImplementedTemperatureDeriativesofFugacity. - *
+ * method to set the temperature of a fluid (same temperature for all phases). * - * @param implementedTemperatureDeriativesofFugacity a boolean + * @param newTemperature in specified unit + * @param unit unit can be C or K (Celsius or Kelvin) */ - public void setImplementedTemperatureDeriativesofFugacity( - boolean implementedTemperatureDeriativesofFugacity); + public void setTemperature(double newTemperature, String unit); /** *- * isImplementedPressureDeriativesofFugacity. + * setTotalFlowRate. *
* - * @return a boolean + * @param flowRate a double + * @param flowunit a {@link java.lang.String} object. flow units are: kg/sec, kg/min, kg/hr + * m3/sec, m3/min, m3/hr, mole/sec, mole/min, mole/hr, Sm3/hr, Sm3/day, idSm3/hr, idSm3/day */ - public boolean isImplementedPressureDeriativesofFugacity(); + public void setTotalFlowRate(double flowRate, String flowunit); /** *
- * setImplementedPressureDeriativesofFugacity.
+ * Setter for property totalNumberOfMoles
.
*
- * isImplementedCompositionDeriativesofFugacity. + * setUseTVasIndependentVariables. *
* - * @return a boolean + * @param useTVasIndependentVariables a boolean */ - public boolean isImplementedCompositionDeriativesofFugacity(); + public void setUseTVasIndependentVariables(boolean useTVasIndependentVariables); /** *- * isImplementedCompositionDeriativesofFugacity. + * tuneModel. *
* - * @param isImpl a boolean + * @param model a {@link java.lang.String} object + * @param val a double + * @param phase a int */ - public void isImplementedCompositionDeriativesofFugacity(boolean isImpl); + public void tuneModel(String model, double val, int phase); /** *- * setImplementedCompositionDeriativesofFugacity. + * useVolumeCorrection. *
* - * @param implementedCompositionDeriativesofFugacity a boolean + * @param volcor a boolean */ - public void setImplementedCompositionDeriativesofFugacity( - boolean implementedCompositionDeriativesofFugacity); + public void useVolumeCorrection(boolean volcor); /** *- * addCapeOpenProperty. + * write. *
* - * @param propertyName a {@link java.lang.String} object - */ - public void addCapeOpenProperty(String propertyName); - - /** - * Get physical properties of System. - * - * @return System properties - */ - public SystemProperties getProperties(); - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o); - - /** {@inheritDoc} */ - @Override - public int hashCode(); - - /** - * Add to component names. - * - * @param name Component name to add + * @param name a {@link java.lang.String} object + * @param filename a {@link java.lang.String} object + * @param newfile a boolean */ - public void addToComponentNames(String name); + public void write(String name, String filename, boolean newfile); /** *- * addCharacterized. + * getKvector - return vector of equilibrium constants. *
* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects - * @param lastIsPlusFraction True if last fraction is a Plus fraction + * @return an array of type double */ - public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, - double[] relativedensity, boolean lastIsPlusFraction); + public double[] getKvector(); /** *- * addCharacterized. + * getzvector - return vector of total molar composition. *
* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects - * @param lastIsPlusFraction True if last fraction is a Plus fraction - * @param lumpComponents True if component should be lumped - * @param numberOfPseudoComponents number of pseudo components + * @return an array of type double */ - public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, - double[] relativedensity, boolean lastIsPlusFraction, boolean lumpComponents, - int numberOfPseudoComponents); + public double[] getzvector(); /** *- * addCharacterized. + * toJson - return String with json inormation of fluid. *
* - * @param charNames an array of {@link java.lang.String} objects - * @param charFlowrate an array of {@link double} objects - * @param molarMass an array of {@link double} objects - * @param relativedensity an array of {@link double} objects + * @return a {@link java.lang.String} object */ - public void addCharacterized(String[] charNames, double[] charFlowrate, double[] molarMass, - double[] relativedensity); + public String toJson(); /** - * Get ideal liquid density of fluid in given unit. + *+ * toCompJson - return String with json inormation of pure component properties of fluid. + *
* - * @param unit {@link java.lang.String} Supported units are kg/m3 and gr/cm3 - * @return a double + * @return a {@link java.lang.String} object */ - public double getIdealLiquidDensity(String unit); + public String toCompJson(); } diff --git a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java index 110e0b1372..220cba6746 100644 --- a/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java +++ b/src/main/java/neqsim/thermo/system/SystemKentEisenberg.java @@ -44,8 +44,7 @@ public SystemKentEisenberg(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemKentEisenberg(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "Kent Eisenberg-model"; @@ -77,10 +76,6 @@ public SystemKentEisenberg clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemNRTL.java b/src/main/java/neqsim/thermo/system/SystemNRTL.java index 9cb9bb31ba..fa201b69dc 100644 --- a/src/main/java/neqsim/thermo/system/SystemNRTL.java +++ b/src/main/java/neqsim/thermo/system/SystemNRTL.java @@ -44,8 +44,7 @@ public SystemNRTL(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemNRTL(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "NRTL-GE-model"; @@ -77,10 +76,6 @@ public SystemNRTL clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } } diff --git a/src/main/java/neqsim/thermo/system/SystemPCSAFT.java b/src/main/java/neqsim/thermo/system/SystemPCSAFT.java index 907b13dd5b..83fecbbf86 100644 --- a/src/main/java/neqsim/thermo/system/SystemPCSAFT.java +++ b/src/main/java/neqsim/thermo/system/SystemPCSAFT.java @@ -13,8 +13,8 @@ * @version $Id: $Id */ public class SystemPCSAFT extends SystemSrkEos { - private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(SystemPCSAFT.class); + private static final long serialVersionUID = 1000; /** *@@ -47,11 +47,11 @@ public SystemPCSAFT(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemPCSAFT(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "PCSAFT-EOS"; attractiveTermNumber = 0; + // Recreates phases created in super constructor SystemSrkEos for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhasePCSAFTRahmat(); phaseArray[i].setTemperature(T); @@ -76,24 +76,6 @@ public SystemPCSAFT(double T, double P, boolean checkForSolids) { this.useVolumeCorrection(false); } - /** {@inheritDoc} */ - @Override - public SystemPCSAFT clone() { - SystemPCSAFT clonedSystem = null; - try { - clonedSystem = (SystemPCSAFT) super.clone(); - } catch (Exception ex) { - logger.error("Cloning failed.", ex); - } - - // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone(); - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - - return clonedSystem; - } - /** {@inheritDoc} */ @Override public void addTBPfraction(String componentName2, double numberOfMoles, double molarMass, @@ -119,6 +101,19 @@ public void addTBPfraction(String componentName2, double numberOfMoles, double m } } + /** {@inheritDoc} */ + @Override + public SystemPCSAFT clone() { + SystemPCSAFT clonedSystem = null; + try { + clonedSystem = (SystemPCSAFT) super.clone(); + } catch (Exception ex) { + logger.error("Cloning failed.", ex); + } + + return clonedSystem; + } + /** *
* commonInitialization.
diff --git a/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java b/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java
index b152f88740..ef03b2f1e0 100644
--- a/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java
+++ b/src/main/java/neqsim/thermo/system/SystemPCSAFTa.java
@@ -44,11 +44,11 @@ public SystemPCSAFTa(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPCSAFTa(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
modelName = "PCSAFTa-EOS";
attractiveTermNumber = 0;
+ // Recreates phases created in super constructor SystemSrkEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePCSAFTa();
phaseArray[i].setTemperature(T);
@@ -82,11 +82,6 @@ public SystemPCSAFTa clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrCPA.java b/src/main/java/neqsim/thermo/system/SystemPrCPA.java
index d2a6442e43..1d2d2ab100 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrCPA.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrCPA.java
@@ -44,10 +44,10 @@ public SystemPrCPA(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrCPA(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
modelName = "CPA-PR-EOS";
+ // Recreates phases created in super constructor SystemPrEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePrCPA();
phaseArray[i].setTemperature(T);
@@ -80,10 +80,6 @@ public SystemPrCPA clone() {
logger.error("Cloning failed.", ex);
}
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrDanesh.java b/src/main/java/neqsim/thermo/system/SystemPrDanesh.java
index 11685c3b60..c42a3d7419 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrDanesh.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrDanesh.java
@@ -44,11 +44,11 @@ public SystemPrDanesh(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrDanesh(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
modelName = "PR-Danesh-EOS";
attractiveTermNumber = 9;
+ // Recreates phases created in super constructor SystemPrEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePrEos();
phaseArray[i].setTemperature(T);
@@ -81,11 +81,6 @@ public SystemPrDanesh clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos.java b/src/main/java/neqsim/thermo/system/SystemPrEos.java
index fe5a946047..ff5827532a 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrEos.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrEos.java
@@ -38,8 +38,7 @@ public SystemPrEos(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrEos(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
attractiveTermNumber = 1;
modelName = "PR-EOS";
getCharacterization().setTBPModel("PedersenPR");
@@ -76,10 +75,6 @@ public SystemPrEos clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrEos1978.java b/src/main/java/neqsim/thermo/system/SystemPrEos1978.java
index 02824f42f4..5c987bcc33 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrEos1978.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrEos1978.java
@@ -1,16 +1,12 @@
package neqsim.thermo.system;
-import neqsim.thermo.phase.PhaseHydrate;
-import neqsim.thermo.phase.PhasePrEos;
-import neqsim.thermo.phase.PhasePureComponentSolid;
-
/**
* This class defines a thermodynamic system using the Peng Robinson v. 1978 equation of state
*
* @author Even Solbraa
* @version $Id: $Id
*/
-public class SystemPrEos1978 extends SystemEos {
+public class SystemPrEos1978 extends SystemPrEos {
private static final long serialVersionUID = 1000;
/**
@@ -44,31 +40,9 @@ public SystemPrEos1978(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrEos1978(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
- attractiveTermNumber = 13;
- modelName = "PR1978-EOS";
-
- for (int i = 0; i < numberOfPhases; i++) {
- phaseArray[i] = new PhasePrEos();
- phaseArray[i].setTemperature(T);
- phaseArray[i].setPressure(P);
- }
-
- if (solidPhaseCheck) {
- setNumberOfPhases(5);
- phaseArray[numberOfPhases - 1] = new PhasePureComponentSolid();
- phaseArray[numberOfPhases - 1].setTemperature(T);
- phaseArray[numberOfPhases - 1].setPressure(P);
- phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase());
- }
-
- if (hydrateCheck) {
- phaseArray[numberOfPhases - 1] = new PhaseHydrate();
- phaseArray[numberOfPhases - 1].setTemperature(T);
- phaseArray[numberOfPhases - 1].setPressure(P);
- phaseArray[numberOfPhases - 1].setRefPhase(phaseArray[1].getRefPhase());
- }
+ super(T, P, checkForSolids);
+ attractiveTermNumber = 6;
+ modelName = "PR78-EoS";
}
/** {@inheritDoc} */
@@ -81,11 +55,6 @@ public SystemPrEos1978 clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrEosDelft1998.java b/src/main/java/neqsim/thermo/system/SystemPrEosDelft1998.java
index 2bbc21c333..f33eee0feb 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrEosDelft1998.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrEosDelft1998.java
@@ -45,11 +45,11 @@ public SystemPrEosDelft1998(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrEosDelft1998(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
modelName = "PR Delft1998 EOS";
attractiveTermNumber = 7;
+ // Recreates phases created in super constructor SystemPrEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePrEos();
phaseArray[i].setTemperature(T);
@@ -81,11 +81,6 @@ public SystemPrEosDelft1998 clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java b/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java
index 10df84ce53..1f83e2167d 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrGassemEos.java
@@ -44,11 +44,11 @@ public SystemPrGassemEos(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrGassemEos(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
modelName = "PR-Gassem-EOS";
attractiveTermNumber = 8;
+ // Recreates phases created in super constructor SystemPrEos
for (int i = 0; i < numberOfPhases; i++) {
phaseArray[i] = new PhasePrEos();
phaseArray[i].setTemperature(T);
@@ -81,11 +81,6 @@ public SystemPrGassemEos clone() {
logger.error("Cloning failed.", ex);
}
- // clonedSystem.phaseArray = (PhaseInterface[]) phaseArray.clone();
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemPrMathiasCopeman.java b/src/main/java/neqsim/thermo/system/SystemPrMathiasCopeman.java
index 2b047e3ecd..19ba254b87 100644
--- a/src/main/java/neqsim/thermo/system/SystemPrMathiasCopeman.java
+++ b/src/main/java/neqsim/thermo/system/SystemPrMathiasCopeman.java
@@ -40,8 +40,7 @@ public SystemPrMathiasCopeman(double T, double P) {
* @param checkForSolids Set true to do solid phase check and calculations
*/
public SystemPrMathiasCopeman(double T, double P, boolean checkForSolids) {
- super(T, P);
- this.solidPhaseCheck = checkForSolids;;
+ super(T, P, checkForSolids);
attractiveTermNumber = 13;
modelName = "Mathias-Copeman-PR-EOS";
}
@@ -56,10 +55,6 @@ public SystemPrMathiasCopeman clone() {
logger.error("Cloning failed.", ex);
}
- // for(int i = 0; i < numberOfPhases; i++) {
- // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone();
- // }
-
return clonedSystem;
}
}
diff --git a/src/main/java/neqsim/thermo/system/SystemProperties.java b/src/main/java/neqsim/thermo/system/SystemProperties.java
index 3a7f2858ff..d1f8b06a6a 100644
--- a/src/main/java/neqsim/thermo/system/SystemProperties.java
+++ b/src/main/java/neqsim/thermo/system/SystemProperties.java
@@ -11,10 +11,20 @@
* @version $Id: $Id
*/
public class SystemProperties {
- private Double[] values;
- private String[] names;
/** Constant
@@ -159,8 +156,9 @@ public SystemThermo() {
*
* @param T The temperature in unit Kelvin
* @param P The pressure in unit bara (absolute pressure)
+ * @param checkForSolids Set true to do solid phase check and calculations
*/
- public SystemThermo(double T, double P) {
+ public SystemThermo(double T, double P, boolean checkForSolids) {
this();
if (T < 0.0) {
neqsim.util.exception.InvalidInputException ex =
@@ -175,591 +173,580 @@ public SystemThermo(double T, double P) {
"SystemThermo", "P", "is negative");
throw new RuntimeException(ex);
}
+
+ this.solidPhaseCheck = checkForSolids;
}
/** {@inheritDoc} */
@Override
- public int getNumberOfComponents() {
- return getComponentNames().length;
+ public void addCapeOpenProperty(String propertyName) {
+ String[] tempString = new String[CapeOpenProperties11.length + 1];
+ System.arraycopy(CapeOpenProperties11, 0, tempString, 0, CapeOpenProperties11.length);
+ tempString[CapeOpenProperties11.length] = propertyName;
+ CapeOpenProperties11 = tempString;
+
+ tempString = new String[CapeOpenProperties10.length + 1];
+ System.arraycopy(CapeOpenProperties10, 0, tempString, 0, CapeOpenProperties10.length);
+ tempString[CapeOpenProperties10.length] = propertyName;
+ CapeOpenProperties10 = tempString;
}
/** {@inheritDoc} */
@Override
- public void clearAll() {
- setTotalNumberOfMoles(0);
- phaseType[0] = PhaseType.byValue(1);
- phaseType[1] = PhaseType.byValue(0);
- numberOfComponents = 0;
- setNumberOfPhases(2);
- beta[0] = 1.0;
- beta[1] = 1.0;
- beta[2] = 1.0;
- beta[3] = 1.0;
- beta[4] = 1.0;
- beta[5] = 1.0;
- chemicalSystem = false;
-
- double oldTemp = phaseArray[0].getTemperature();
- double oldPres = phaseArray[0].getPressure();
-
- for (int i = 0; i < getMaxNumberOfPhases(); i++) {
- try {
- phaseArray[i] = phaseArray[i].getClass().getDeclaredConstructor().newInstance();
- } catch (Exception ex) {
- logger.error("err ", ex);
- }
- phaseArray[i].setTemperature(oldTemp);
- phaseArray[i].setPressure(oldPres);
+ public void addCharacterized(String[] charNames, double[] charFlowrate, double[] molarMass,
+ double[] relativedensity) {
+ if (charNames.length != charFlowrate.length) {
+ logger.error("component names and mole fractions need to be same length...");
+ }
+ for (int i = 0; i < charNames.length; i++) {
+ addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]);
}
}
/** {@inheritDoc} */
@Override
- public void resetCharacterisation() {
- int numberOfLumpedComps = characterization.getLumpingModel().getNumberOfLumpedComponents();
- characterization = new Characterise(this);
- characterization.getLumpingModel().setNumberOfLumpedComponents(numberOfLumpedComps);
+ public void addComponent(ComponentInterface inComponent) {
+ if (inComponent.isIsTBPfraction()) {
+ addTBPfraction(inComponent.getComponentName(), inComponent.getNumberOfmoles(),
+ inComponent.getMolarMass(), inComponent.getNormalLiquidDensity());
+ String componentName = inComponent.getComponentName();
+ changeComponentName(componentName + "_PC", componentName.replaceFirst("_PC", ""));
+ for (int i = 0; i < numberOfPhases; i++) {
+ getPhase(i).getComponent(componentName)
+ .setAttractiveTerm(inComponent.getAttractiveTermNumber());
+ getPhase(i).getComponent(componentName).setTC(inComponent.getTC());
+ getPhase(i).getComponent(componentName).setPC(inComponent.getPC());
+ getPhase(i).getComponent(componentName).setMolarMass(inComponent.getMolarMass());
+ getPhase(i).getComponent(componentName).setComponentType("TBPfraction");
+ getPhase(i).getComponent(componentName)
+ .setNormalLiquidDensity(inComponent.getNormalLiquidDensity());
+ getPhase(i).getComponent(componentName)
+ .setNormalBoilingPoint(inComponent.getNormalBoilingPoint());
+ getPhase(i).getComponent(componentName).setAcentricFactor(inComponent.getAcentricFactor());
+ getPhase(i).getComponent(componentName).setCriticalVolume(inComponent.getCriticalVolume());
+ getPhase(i).getComponent(componentName).setRacketZ(inComponent.getRacketZ());
+ getPhase(i).getComponent(componentName).setRacketZCPA(inComponent.getRacketZCPA());
+ getPhase(i).getComponent(componentName).setIsTBPfraction(true);
+ getPhase(i).getComponent(componentName)
+ .setParachorParameter(inComponent.getParachorParameter());
+ getPhase(i).getComponent(componentName)
+ .setTriplePointTemperature(inComponent.getTriplePointTemperature());
+ getPhase(i).getComponent(componentName)
+ .setIdealGasEnthalpyOfFormation(inComponent.getIdealGasEnthalpyOfFormation());
+ getPhase(i).getComponent(componentName).setCpA(inComponent.getCpA());
+ getPhase(i).getComponent(componentName).setCpB(inComponent.getCpB());
+ getPhase(i).getComponent(componentName).setCpC(inComponent.getCpC());
+ getPhase(i).getComponent(componentName).setCpD(inComponent.getCpD());
+ }
+ } else {
+ addComponent(inComponent.getComponentName(), inComponent.getNumberOfmoles());
+ }
}
/** {@inheritDoc} */
@Override
- public SystemInterface addFluid(SystemInterface addSystem) {
- boolean addedNewComponent = false;
- int index = -1;
- for (int i = 0; i < addSystem.getPhase(0).getNumberOfComponents(); i++) {
- if (!getPhase(0).hasComponent(addSystem.getPhase(0).getComponent(i).getComponentName())) {
- index = -1;
- addedNewComponent = true;
- } else {
- index = getPhase(0).getComponent(addSystem.getPhase(0).getComponent(i).getComponentName())
- .getComponentNumber();
- }
+ public void addComponent(int index, double moles) {
+ if (index >= getPhase(0).getNumberOfComponents()) {
+ logger.error("componentIndex higher than number of components in system");
+ return;
+ }
- if (index != -1) {
- addComponent(index, addSystem.getPhase(0).getComponent(i).getNumberOfmoles());
- } else if (addSystem.getPhase(0).getComponent(i).isIsTBPfraction()) {
- addTBPfraction(
- addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", ""),
- addSystem.getPhase(0).getComponent(i).getNumberOfmoles(),
- addSystem.getPhase(0).getComponent(i).getMolarMass(),
- addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity());
- } else {
- if (addSystem.getPhase(0).getComponent(i).isIsTBPfraction()) {
- addTBPfraction(
- addSystem.getPhase(0).getComponent(i).getComponentName().replaceFirst("_PC", ""),
- addSystem.getPhase(0).getComponent(i).getNumberOfmoles(),
- addSystem.getPhase(0).getComponent(i).getMolarMass(),
- addSystem.getPhase(0).getComponent(i).getNormalLiquidDensity());
- } else {
- addComponent(addSystem.getComponent(i));
- }
+ for (PhaseInterface tmpPhase : phaseArray) {
+ // TODO: adding moles to all phases, not just the active ones.
+ if (tmpPhase != null) {
+ tmpPhase.addMolesChemReac(index, moles, moles);
}
}
- if (addedNewComponent) {
- createDatabase(true);
- setMixingRule(getMixingRule());
- init(0);
- }
- return this;
+ setTotalNumberOfMoles(getTotalNumberOfMoles() + moles);
}
/** {@inheritDoc} */
@Override
- public SystemInterface addFluid(SystemInterface addSystem, int phase) {
- for (int i = 0; i < addSystem.getPhase(0).getNumberOfComponents(); i++) {
- addComponent(addSystem.getPhase(0).getComponent(i).getComponentName(),
- addSystem.getPhase(0).getComponent(i).getNumberOfmoles(), phase);
+ public void addComponent(int index, double moles, int phaseNumber) {
+ if (index >= getPhase(0).getNumberOfComponents()) {
+ logger.error("componentIndex higher than number of components in system");
+ return;
}
- return this;
+ double k = 1.0;
+
+ for (int i = 0; i < getMaxNumberOfPhases(); i++) {
+ if (phaseNumber == i) {
+ k = 1.0;
+ } else {
+ k = 0.0;
+ }
+ phaseArray[phaseIndex[i]].addMolesChemReac(index, moles * k, moles);
+ }
+
+ setTotalNumberOfMoles(getTotalNumberOfMoles() + moles);
}
/** {@inheritDoc} */
@Override
- public void addPhase() {
- /*
- * if (maxNumberOfPhases < 6 && !hydrateCheck) { ArrayList phaseList = new ArrayList(0); for
- * (int i = 0; i < numberOfPhases; i++) { phaseList.add(phaseArray[i]); } // add the new phase
- * phaseList.add(phaseArray[0].clone()); beta[phaseList.size() - 1] = 1.0e-8; // beta[1] -=
- * beta[1]/1.0e5;
- *
- * PhaseInterface[] phaseArray2 = new PhaseInterface[numberOfPhases + 1];
- *
- * for (int i = 0; i < numberOfPhases + 1; i++) { phaseArray2[i] = (PhaseInterface)
- * phaseList.get(i); }
- *
- * phaseArray = phaseArray2;
- *
- * System.out.println("number of phases " + numberOfPhases); if (maxNumberOfPhases <
- * numberOfPhases) { maxNumberOfPhases = numberOfPhases; } }
- */
- numberOfPhases++;
- }
+ public void addComponent(String componentName, double moles) {
+ componentName = ComponentInterface.getComponentNameFromAlias(componentName);
- /**
- *
- * addSolidPhase.
- *
- * addHydratePhase.
- *
- * addHydratePhase2.
- *
+ * addHydratePhase.
+ *
+ * addHydratePhase2.
+ *
+ * addSolidPhase.
+ *
+ * getAntoineVaporPressure.
+ *
- * initAnalytic.
- *
- * initAnalytic.
+ * need to call initPhysicalProperties() before this method is called
*
- * initNumeric.
- *
- * initNumeric.
- *
- * getAntoineVaporPressure.
- *
- * setMixingRuleGEmodel.
- *
- * need to call initPhysicalProperties() before this method is called
- *
+ * hasTBPFraction.
+ *
+ * initAnalytic.
+ *
- * write.
+ * initAnalytic.
*
+ * initNumeric.
+ *
+ * initNumeric.
+ *
- * setLastTBPasPlus.
- *
- * hasTBPFraction.
- *
- * useTVasIndependentVariables.
- *
+ * setLastTBPasPlus.
+ *
+ * setMixingRuleGEmodel.
+ *
+ * useTVasIndependentVariables.
+ *
+ * write.
+ *
- * sq.
- *
+ * sq.
+ *
+ * MolarMassDetail.
+ *
- * MolarMassDetail.
- *
+ * PressureDetail.
+ *
- * PressureDetail.
- *
+ * DensityDetail.
+ *
- * DensityDetail.
- *
- * PropertiesDetail.
- *
+ * PropertiesDetail.
+ *
- * SetupDetail.
- *
+ * SetupDetail.
+ *
- * main.
- *
+ * main.
+ *
* MolarMassGERG.
* nCols=(16 * 4) + 6
. */
public static final int nCols = (16 * 4) + 6;
+ /**
+ * Get names of properties.
+ *
+ * @return Array of names of properties
+ */
+ public static String[] getPropertyNames() {
+ SystemProperties p = new SystemProperties(new SystemSrkEos());
+ return p.names;
+ }
+ private String[] names;
+
+ private Double[] values;
/**
* Constructur for SystemProperties.
@@ -204,14 +214,4 @@ public HashMapbeta
values.
+ *
+ * @return Sum of beta
beta values
+ */
+ public final double getSumBeta() {
+ double sum = 0;
+ for (int k = 0; k < numberOfPhases; k++) {
+ sum += getBeta(k);
+ }
+ return sum;
}
/** {@inheritDoc} */
@Override
- public InterphasePropertiesInterface getInterphaseProperties() {
- return interfaceProp;
+ public final double getTC() {
+ return criticalTemperature;
}
/** {@inheritDoc} */
@Override
- public double getInterfacialTension(int phase1, int phase2) {
- return interfaceProp.getSurfaceTension(phase1, phase2);
+ public final double getTemperature() {
+ return phaseArray[0].getTemperature();
}
/** {@inheritDoc} */
@Override
- public double getInterfacialTension(int phase1, int phase2, String unit) {
- return interfaceProp.getSurfaceTension(phase1, phase2, unit);
+ public double getTemperature(int phaseNumber) {
+ return getPhase(phaseIndex[phaseNumber]).getTemperature();
}
/** {@inheritDoc} */
@Override
- public double getInterfacialTension(String phase1, String phase2) {
- if (hasPhaseType(phase1) && hasPhaseType(phase2)) {
- return interfaceProp.getSurfaceTension(getPhaseNumberOfPhase(phase1),
- getPhaseNumberOfPhase(phase2));
- } else {
- return Double.NaN;
- }
+ public final double getTemperature(String unit) {
+ neqsim.util.unit.TemperatureUnit tempConversion =
+ new neqsim.util.unit.TemperatureUnit(getTemperature(), "K");
+ return tempConversion.getValue(unit);
}
/** {@inheritDoc} */
@Override
- public void normalizeBeta() {
- double tot = 0.0;
- for (int i = 0; i < numberOfPhases; i++) {
- tot += beta[phaseIndex[i]];
- }
+ public double getThermalConductivity() {
+ double cond = 0;
for (int i = 0; i < numberOfPhases; i++) {
- beta[phaseIndex[i]] /= tot;
+ cond += beta[phaseIndex[i]] * getPhase(i).getPhysicalProperties().getConductivity();
}
+ return cond;
}
/** {@inheritDoc} */
@Override
- public String[][] createTable(String name) {
-
- if (!isInitialized) {
- init_x_y();
+ public double getThermalConductivity(String unit) {
+ double refConductivity = getThermalConductivity(); // conductivity in W/m*K
+ double conversionFactor = 1.0;
+ switch (unit) {
+ case "W/mK":
+ case "J/sec-m-K":
+ conversionFactor = 1.0;
+ break;
+ case "W/cmK":
+ conversionFactor = 0.01;
+ break;
+ case "Btu/hr-ft-F":
+ conversionFactor = 0.5781759824;
+ break;
+ default:
+ throw new RuntimeException("unit not supported " + unit);
}
- initProperties();
-
- java.text.DecimalFormat nf = new java.text.DecimalFormat();
-
- java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols();
- symbols.setDecimalSeparator('.');
- nf.setDecimalFormatSymbols(symbols);
-
- nf.setMaximumFractionDigits(5);
- nf.applyPattern("#.#####E0");
+ return refConductivity * conversionFactor;
+ }
- // String[][] table = new String[getPhases()[0].getNumberOfComponents() +
- // 30][7];
- // String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4",
- // "Unit"};
- String[][] table = new String[getPhases()[0].getNumberOfComponents() + 30][7];
- table[0][0] = ""; // getPhases()[0].getType(); //"";
+ /** {@inheritDoc} */
+ @Override
+ public double getTotalNumberOfMoles() {
+ return this.totalNumberOfMoles;
+ }
- for (int i = 0; i < getPhases()[0].getNumberOfComponents() + 30; i++) {
- for (int j = 0; j < 7; j++) {
- table[i][j] = "";
- }
- }
- table[0][1] = "total";
+ /** {@inheritDoc} */
+ @Override
+ public double getViscosity() {
+ double visc = 0;
for (int i = 0; i < numberOfPhases; i++) {
- table[0][i + 2] = getPhase(i).getType().toString();
+ visc += beta[phaseIndex[i]] * getPhase(i).getPhysicalProperties().getViscosity();
}
+ return visc;
+ }
- StringBuffer buf = new StringBuffer();
- FieldPosition test = new FieldPosition(0);
- for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) {
- buf = new StringBuffer();
- table[j + 1][1] = nf.format(getPhase(0).getComponents()[j].getz(), buf, test).toString();
+ /** {@inheritDoc} */
+ @Override
+ public double getViscosity(String unit) {
+ double refViscosity = getViscosity(); // viscosity in kg/msec
+ double conversionFactor = 1.0;
+ switch (unit) {
+ case "kg/msec":
+ conversionFactor = 1.0;
+ break;
+ case "cP":
+ conversionFactor = 1.0e3;
+ break;
+ case "Pas":
+ conversionFactor = 1.0;
+ break;
+ default:
+ throw new RuntimeException("unit not supported " + unit);
}
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 4][1] =
- nf.format(getMolarMass() * 1000, buf, test).toString();
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 9][1] =
- nf.format(getEnthalpy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test)
- .toString();
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 10][1] =
- nf.format(getEntropy() / (getTotalNumberOfMoles() * getMolarMass() * 1000), buf, test)
- .toString();
+ return refViscosity * conversionFactor;
+ }
+ /** {@inheritDoc} */
+ @Override
+ public final double getVolume() {
+ double volume = 0.0;
for (int i = 0; i < numberOfPhases; i++) {
- for (int j = 0; j < getPhases()[0].getNumberOfComponents(); j++) {
- table[j + 1][0] = getPhases()[0].getComponents()[j].getName();
- buf = new StringBuffer();
- table[j + 1][i + 2] =
- nf.format(getPhase(i).getComponents()[j].getx(), buf, test).toString();
- table[j + 1][6] = "[mole fraction]";
- }
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 2][0] = "Density";
- table[getPhases()[0].getNumberOfComponents() + 2][i + 2] =
- nf.format(getPhase(i).getPhysicalProperties().getDensity(), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 2][6] = "[kg/m^3]";
-
- // Double.longValue(system.getPhase(i).getBeta());
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 3][0] = "PhaseFraction";
- table[getPhases()[0].getNumberOfComponents() + 3][i + 2] =
- nf.format(getPhase(i).getBeta(), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 4][0] = "MolarMass";
- table[getPhases()[0].getNumberOfComponents() + 4][i + 2] =
- nf.format(getPhase(i).getMolarMass() * 1000, buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 4][6] = "[kg/kmol]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor";
- table[getPhases()[0].getNumberOfComponents() + 5][i + 2] =
- nf.format(getPhase(i).getZ(), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 6][0] = "Heat Capacity (Cp)";
- table[getPhases()[0].getNumberOfComponents() + 6][i + 2] = nf.format(
- (getPhase(i).getCp()
- / (getPhase(i).getNumberOfMolesInPhase() * getPhase(i).getMolarMass() * 1000)),
- buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 6][6] = "[kJ/kg*K]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 7][0] = "Heat Capacity (Cv)";
- table[getPhases()[0].getNumberOfComponents() + 7][i + 2] = nf.format(
- (getPhase(i).getCv()
- / (getPhase(i).getNumberOfMolesInPhase() * getPhase(i).getMolarMass() * 1000)),
- buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 7][6] = "[kJ/kg*K]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound";
- table[getPhases()[0].getNumberOfComponents() + 8][i + 2] =
- nf.format((getPhase(i).getSoundSpeed()), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 8][6] = "[m/sec]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 9][0] = "Enthalpy";
- table[getPhases()[0].getNumberOfComponents() + 9][i + 2] = nf.format(
- (getPhase(i).getEnthalpy()
- / (getPhase(i).getNumberOfMolesInPhase() * getPhase(i).getMolarMass() * 1000)),
- buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 9][6] = "[kJ/kg]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 10][0] = "Entropy";
- table[getPhases()[0].getNumberOfComponents() + 10][i + 2] = nf.format(
- (getPhase(i).getEntropy()
- / (getPhase(i).getNumberOfMolesInPhase() * getPhase(i).getMolarMass() * 1000)),
- buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 10][6] = "[kJ/kg*K]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient";
- table[getPhases()[0].getNumberOfComponents() + 11][i + 2] =
- nf.format((getPhase(i).getJouleThomsonCoefficient()), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 11][6] = "[K/bar]";
-
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity";
- table[getPhases()[0].getNumberOfComponents() + 13][i + 2] =
- nf.format((getPhase(i).getPhysicalProperties().getViscosity()), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 13][6] = "[kg/m*sec]";
+ volume += getPhase(i).getMolarVolume() * getPhase(i).getNumberOfMolesInPhase();
+ }
+ return volume;
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 14][0] = "Conductivity";
- table[getPhases()[0].getNumberOfComponents() + 14][i + 2] =
- nf.format(getPhase(i).getPhysicalProperties().getConductivity(), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 14][6] = "[W/m*K]";
+ /** {@inheritDoc} */
+ @Override
+ public double getVolume(String unit) {
+ double conversionFactor = 1.0;
+ switch (unit) {
+ case "m3":
+ conversionFactor = 1.0;
+ break;
+ case "m3/kg":
+ conversionFactor = 1.0 / getMass("kg");
+ break;
+ case "litre":
+ conversionFactor = 1000.0;
+ break;
+ case "m3/mol":
+ conversionFactor = 1.0 / getTotalNumberOfMoles();
+ break;
+ default:
+ throw new RuntimeException("unit not supported " + unit);
+ }
+ return conversionFactor * getVolume() / 1.0e5;
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 15][0] = "SurfaceTension";
- try {
- if (i < numberOfPhases - 1) {
- table[getPhases()[0].getNumberOfComponents() + 15][2] =
- nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString();
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 15][3] =
- nf.format(getInterphaseProperties().getSurfaceTension(0, 1), buf, test).toString();
- buf = new StringBuffer();
- if (i == 1) {
- table[getPhases()[0].getNumberOfComponents() + 17][2] =
- nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString();
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 17][4] =
- nf.format(getInterphaseProperties().getSurfaceTension(0, 2), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 17][6] = "[N/m]";
- }
- if (i == 1) {
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 16][3] =
- nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString();
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 16][4] =
- nf.format(getInterphaseProperties().getSurfaceTension(1, 2), buf, test).toString();
- table[getPhases()[0].getNumberOfComponents() + 16][6] = "[N/m]";
- }
- }
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- table[getPhases()[0].getNumberOfComponents() + 15][6] = "[N/m]";
+ /** {@inheritDoc} */
+ @Override
+ public double getVolumeFraction(int phaseNumber) {
+ return getPhase(phaseNumber).getVolume() / getVolume();
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure";
- table[getPhases()[0].getNumberOfComponents() + 19][i + 2] =
- Double.toString(getPhase(i).getPressure());
- table[getPhases()[0].getNumberOfComponents() + 19][6] = "[bar]";
+ /** {@inheritDoc} */
+ @Override
+ public neqsim.thermo.characterization.WaxCharacterise getWaxCharacterisation() {
+ return waxCharacterisation;
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature";
- table[getPhases()[0].getNumberOfComponents() + 20][i + 2] =
- Double.toString(getPhase(i).getTemperature());
- table[getPhases()[0].getNumberOfComponents() + 20][6] = "[K]";
- Double.toString(getPhase(i).getTemperature());
+ /** {@inheritDoc} */
+ @Override
+ public WaxModelInterface getWaxModel() {
+ if (waxCharacterisation == null) {
+ waxCharacterisation = new WaxCharacterise(this);
+ }
+ return waxCharacterisation.getModel();
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 22][0] = "Model";
- table[getPhases()[0].getNumberOfComponents() + 22][i + 2] = getModelName();
- table[getPhases()[0].getNumberOfComponents() + 22][6] = "-";
+ /** {@inheritDoc} */
+ @Override
+ public double getWtFraction(int phaseNumber) {
+ return getPhase(phaseNumber).getWtFraction(this);
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 23][0] = "Mixing Rule";
- try {
- table[getPhases()[0].getNumberOfComponents() + 23][i + 2] =
- ((PhaseEosInterface) getPhase(i)).getMixingRuleName();
- } catch (Exception ex) {
- table[getPhases()[0].getNumberOfComponents() + 23][i + 2] = "?";
- // logger.error(ex.getMessage(),e);
+ /** {@inheritDoc} */
+ @Override
+ public double getZ() {
+ double Z = 0;
+ for (int i = 0; i < numberOfPhases; i++) {
+ Z += beta[phaseIndex[i]] * getPhase(i).getZ();
+ }
+ return Z;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public double getZvolcorr() {
+ return getPressure("Pa") * getMolarMass() / neqsim.thermo.ThermodynamicConstantsInterface.R
+ / getTemperature() / getDensity("kg/m3");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean hasPhaseType(PhaseType pt) {
+ for (int i = 0; i < numberOfPhases; i++) {
+ if (getPhase(i) == null) {
+ continue;
}
- table[getPhases()[0].getNumberOfComponents() + 23][6] = "-";
+ if (getPhase(i).getType() == pt) {
+ return true;
+ }
+ if (getPhase(i).getPhaseTypeName().equals(pt.getDesc())) {
+ logger.error(
+ "Bug in setting phasetype somewhere. Phasetype and phasetypename should be the same.");
+ return true;
+ }
+ }
+ return false;
+ }
- buf = new StringBuffer();
- table[getPhases()[0].getNumberOfComponents() + 25][0] = "Stream";
- table[getPhases()[0].getNumberOfComponents() + 25][i + 2] = name;
- table[getPhases()[0].getNumberOfComponents() + 25][6] = "-";
+ /** {@inheritDoc} */
+ @Override
+ public boolean hasPlusFraction() {
+ for (int i = 0; i < numberOfComponents; i++) {
+ if (getPhase(0).getComponent(i).isIsPlusFraction()) {
+ return true;
+ }
}
- resultTable = table;
+ return false;
+ }
- return table;
+ /**
+ *
- * Constructor for FurstElectrolyteConstants. - *
+ * Dummy constructor, not for use. Class is to be considered static. */ - public FurstElectrolyteConstants() {} + private FurstElectrolyteConstants() {} /** *diff --git a/src/main/java/neqsim/thermo/util/empiric/BukacekWaterInGas.java b/src/main/java/neqsim/thermo/util/empiric/BukacekWaterInGas.java index e2d25a1580..0695911184 100644 --- a/src/main/java/neqsim/thermo/util/empiric/BukacekWaterInGas.java +++ b/src/main/java/neqsim/thermo/util/empiric/BukacekWaterInGas.java @@ -1,70 +1,85 @@ package neqsim.thermo.util.empiric; +import neqsim.thermo.ThermodynamicConstantsInterface; + /** - *
BukacekWaterInGas class.
+ *+ * BukacekWaterInGas class. + *
* * @author asmund * @version $Id: $Id */ public class BukacekWaterInGas { - /* - * Calculates the ppm(mol) water content of a gas at its water dew point - */ - /** - *getWaterInGas.
- * - * @param temperature a double - * @param pressure a double - * @return a double - */ - public static double getWaterInGas(double temperature, double pressure) { - double TCwater = 393.99+273.15, PCwater = 220.64; - double tau = (TCwater-temperature)/TCwater; - - double temp = (-7.85823*tau + 1.83991*Math.pow(tau, 1.5) - 11.7811*Math.pow(tau, 3.0) - + 22.67*Math.pow(tau, 3.5) - 15.9393*Math.pow(tau, 4.0) + 1.77516*Math.pow(tau, 7.5))/(1.0-tau); - double psw = PCwater*Math.exp(temp); - - double mgwaterSm3 = 761900.42*psw/pressure + 16.016*Math.pow(10.0, -1716.26/(temperature) + 6.69449); - - double molarMassGas = 0.6*28.0*1000.0; // mgr/mol - - double ans = mgwaterSm3/molarMassGas; // mol water /Sm3 gas - - double molgasSm3 = 101325.0/(8.314*288.15); // mol gas/ Sm3 - - return ans / molgasSm3; - } - - /** - *waterDewPointTemperature.
- * - * @param moleFractionWaterInGas a double - * @param pressure a double - * @return a double - */ - public static double waterDewPointTemperature(double moleFractionWaterInGas, double pressure) { - int iter = 0; - double newppm, newTemp = 273.15; - do { - iter++; + /* + * Calculates the ppm(mol) water content of a gas at its water dew point + */ + /** + *+ * getWaterInGas. + *
+ * + * @param temperature a double + * @param pressure a double + * @return a double + */ + public static double getWaterInGas(double temperature, double pressure) { + double TCwater = 393.99 + 273.15, PCwater = 220.64; + double tau = (TCwater - temperature) / TCwater; + + double temp = (-7.85823 * tau + 1.83991 * Math.pow(tau, 1.5) - 11.7811 * Math.pow(tau, 3.0) + + 22.67 * Math.pow(tau, 3.5) - 15.9393 * Math.pow(tau, 4.0) + 1.77516 * Math.pow(tau, 7.5)) + / (1.0 - tau); + double psw = PCwater * Math.exp(temp); + + double mgwaterSm3 = + 761900.42 * psw / pressure + 16.016 * Math.pow(10.0, -1716.26 / (temperature) + 6.69449); + + double molarMassGas = 0.6 * 28.0 * 1000.0; // mgr/mol + + double ans = mgwaterSm3 / molarMassGas; // mol water /Sm3 gas + + double molgasSm3 = + ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15); // mol + // gas/ + // Sm3 + + return ans / molgasSm3; + } + + /** + *+ * waterDewPointTemperature. + *
+ * + * @param moleFractionWaterInGas a double + * @param pressure a double + * @return a double + */ + public static double waterDewPointTemperature(double moleFractionWaterInGas, double pressure) { + int iter = 0; + double newppm, newTemp = 273.15; + do { + iter++; - newppm = getWaterInGas(newTemp, pressure); - newTemp -= (newppm - moleFractionWaterInGas) * 1e5; - } while (Math.abs((newppm - moleFractionWaterInGas) / moleFractionWaterInGas) > 1e-8 - && iter < 1000); - return newTemp; - } + newppm = getWaterInGas(newTemp, pressure); + newTemp -= (newppm - moleFractionWaterInGas) * 1e5; + } while (Math.abs((newppm - moleFractionWaterInGas) / moleFractionWaterInGas) > 1e-8 + && iter < 1000); + return newTemp; + } - /** - *main.
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - System.out.println("water in gas " + BukacekWaterInGas.getWaterInGas(273.15 - 18.0, 70.0)); + /** + *+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + System.out.println("water in gas " + BukacekWaterInGas.getWaterInGas(273.15 - 18.0, 70.0)); - System.out.println("water dew point temperature " - + (BukacekWaterInGas.waterDewPointTemperature(20.0e-6, 70.0) - 273.15)); - } + System.out.println("water dew point temperature " + + (BukacekWaterInGas.waterDewPointTemperature(20.0e-6, 70.0) - 273.15)); + } } diff --git a/src/main/java/neqsim/thermo/util/empiric/DuanSun.java b/src/main/java/neqsim/thermo/util/empiric/DuanSun.java index 0059b9a19f..9484f333ed 100644 --- a/src/main/java/neqsim/thermo/util/empiric/DuanSun.java +++ b/src/main/java/neqsim/thermo/util/empiric/DuanSun.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemElectrolyteCPAstatoil; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -69,7 +70,7 @@ public double bublePointPressure(double temperature, double x_CO2, double salini // System.out.println(SUMY); // System.out.println(y[0]); - double R = 8.314 * Math.pow(10.0, -2.0); + double R = ThermodynamicConstantsInterface.R * Math.pow(10.0, -2.0); // Calculate A and B of pure compound double[] Tr = {0.0, 0.0}; @@ -267,13 +268,13 @@ public double bublePointPressure(double temperature, double x_CO2, double salini double VCO2INF = 0.0; - VCO2INF = (-159751499.972988 * Math.pow(10.0, -10.0)) - + (101831855.926854 * Math.pow(10.0, -10)) * S - + (18075168.978622 * Math.pow(10.0, -11.0)) * T - - (787538191.939352 * Math.pow(10.0, -13.0)) * S * T - - (192886808.345857 * Math.pow(10.0, -11.0)) * (Math.pow(S, 2.0)) - + 142830810.095592 * Math.pow(10.0, -15.0) * S * (Math.pow(T, 2.0)) - + (123450785.102997 * Math.pow(10.0, -13.0)) * T * (Math.pow(S, 2.0)) + VCO2INF = + (-159751499.972988 * Math.pow(10.0, -10.0)) + (101831855.926854 * Math.pow(10.0, -10)) * S + + (18075168.978622 * Math.pow(10.0, -11.0)) * T + - (787538191.939352 * Math.pow(10.0, -13.0)) * S * T + - (192886808.345857 * Math.pow(10.0, -11.0)) * (Math.pow(S, 2.0)) + + 142830810.095592 * Math.pow(10.0, -15.0) * S * (Math.pow(T, 2.0)) + + (123450785.102997 * Math.pow(10.0, -13.0)) * T * (Math.pow(S, 2.0)) - (220053285.910771 * Math.pow(10.0, -16.0)) * (Math.pow(S, 2.0)) * (Math.pow(T, 2.0)) - 35351000.350961 * Math.pow(10.0, -17.0) * (Math.pow(T, 3.0)); diff --git a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java index 3abba71149..ab4f296a96 100644 --- a/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java +++ b/src/main/java/neqsim/thermo/util/readwrite/EclipseFluidReadWrite.java @@ -4,8 +4,11 @@ import java.io.File; import java.io.FileReader; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseEosInterface; import neqsim.thermo.system.SystemInterface; @@ -24,7 +27,9 @@ public class EclipseFluidReadWrite { public static String pseudoName = ""; /** - *setComposition.
+ *+ * setComposition. + *
* * @param fluid a {@link neqsim.thermo.system.SystemInterface} object * @param inputFile a {@link java.lang.String} object @@ -36,7 +41,9 @@ public static void setComposition(SystemInterface fluid, String inputFile, Strin } /** - *setComposition.
+ *+ * setComposition. + *
* * @param fluid a {@link neqsim.thermo.system.SystemInterface} object * @param inputFile a {@link java.lang.String} object @@ -107,7 +114,9 @@ public static void setComposition(SystemInterface fluid, String inputFile) { } /** - *read.
+ *+ * read. + *
* * @param inputFile a {@link java.lang.String} object * @param pseudoNameIn a {@link java.lang.String} object @@ -127,8 +136,8 @@ public static SystemInterface read(String inputFile, String pseudoNameIn) { * @return a {@link neqsim.thermo.system.SystemInterface} object */ public static SystemInterface read(String inputFile) { - neqsim.thermo.system.SystemInterface fluid = - new neqsim.thermo.system.SystemSrkEos(288.15, 1.01325); + neqsim.thermo.system.SystemInterface fluid = new neqsim.thermo.system.SystemSrkEos(288.15, + ThermodynamicConstantsInterface.referencePressure); double[][] kij = null; try (BufferedReader br = new BufferedReader(new FileReader(new File(inputFile)))) { @@ -140,28 +149,37 @@ public static SystemInterface read(String inputFile) { ArrayList+ * TVfractionFlash. + *
+ * + * @param Vspec a double volume fraction of first/lightest phase + */ + public void TVfractionFlash(double Vspec) { + operation = new neqsim.thermodynamicOperations.flashOps.TVfractionFlash(system, Vspec); + getOperation().run(); + } + /** ** PVrefluxFlash. @@ -802,7 +814,7 @@ public void waterPrecipitationTemperature() throws Exception { // system.getTemperature(); // } - // if(system.doHydrateCheck()){ + // if(system.getHydrateCheck()){ // hydrateFormationTemperature(1); // if(system.getTemperature()>lowTemperature) lowTemperature = // system.getTemperature(); @@ -995,9 +1007,9 @@ public void calcSolidComlexTemperature(String comp1, String comp2) throws Except * calcImobilePhaseHydrateTemperature. *
* - * @param temperature an array of {@link double} objects - * @param pressure an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperature an array of type double + * @param pressure an array of type double + * @return an array of type double */ public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[] pressure) { double[] hydTemps = new double[temperature.length]; @@ -1012,7 +1024,6 @@ public double[] calcImobilePhaseHydrateTemperature(double[] temperature, double[ * systemTemp.init(0); systemTemp.display(); try { opsTemp.hydrateFormationTemperature(); } * catch (Exception ex) { logger.error(ex.getMessage(),e); } systemTemp.display(); hydTemps[i] * = systemTemp.getTemperature(); - * */ opsTemp = new ThermodynamicOperations(systemTemp); systemTemp.setTemperature(temperature[i]); @@ -1207,9 +1218,9 @@ public void hydrateEquilibriumLine(double minimumPressure, double maximumPressur * calcCricoP. * * - * @param cricondenBar an array of {@link double} objects - * @param cricondenBarX an array of {@link double} objects - * @param cricondenBarY an array of {@link double} objects + * @param cricondenBar an array of type double + * @param cricondenBarX an array of type double + * @param cricondenBarY an array of type double */ public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { double phasefraction = 1.0 - 1e-10; @@ -1225,9 +1236,9 @@ public void calcCricoP(double[] cricondenBar, double[] cricondenBarX, double[] c * calcCricoT. * * - * @param cricondenTherm an array of {@link double} objects - * @param cricondenThermX an array of {@link double} objects - * @param cricondenThermY an array of {@link double} objects + * @param cricondenTherm an array of type double + * @param cricondenThermX an array of type double + * @param cricondenThermY an array of type double */ public void calcCricoT(double[] cricondenTherm, double[] cricondenThermX, double[] cricondenThermY) { @@ -1303,15 +1314,20 @@ public void bubblePointPressureFlash() throws Exception { */ public void bubblePointPressureFlash(boolean derivatives) throws Exception { ConstantDutyFlashInterface operation = null; - if (derivatives == true) { + if (derivatives) { operation = new bubblePointPressureFlashDer(system); } else { operation = new bubblePointPressureFlash(system); } - operation.run(); + try { + operation.run(); + } catch (Exception e) { + logger.error(e.getMessage()); + } if (Double.isNaN(system.getPressure()) || operation.isSuperCritical()) { - throw new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), - "bubblePointPressureFlash", "Could not find solution - possible no dew point exists"); + Exception e = new neqsim.util.exception.IsNaNException(this.getClass().getSimpleName(), + "bubblePointPressureFlash", "Could not find solution - possible no bubble point exists"); + logger.error(e.getMessage()); } } @@ -1529,6 +1545,23 @@ public void calcPTphaseEnvelope() { getOperation().run(); } + // public void dewPointPressureFlash(){ + // constantDutyFlashInterface operation = new constantDutyPressureFlash(system); + // operation.setBeta((1-1e-7)); + // operation.run(); + // } + /** + *+ * calcPTphaseEnvelopeNew. + *
+ */ + public void calcPTphaseEnvelope2() { + operation = new pTphaseEnvelopeNew2(system, fileName, (1.0 - 1e-10), 1.0, false); + // thisThread = new Thread(operation); + // thisThread.start(); + getOperation().run(); + } + /** ** calcPTphaseEnvelope. @@ -1706,7 +1739,7 @@ public void printToFile(String name) { * getData. *
* - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getData() { return getOperation().getPoints(0); @@ -1797,6 +1830,10 @@ public void setResultTable(String[][] resultTable) { * */ public void display() { + if (resultTable == null) { + return; + } + JFrame dialog = new JFrame("System-Report"); Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); @@ -1818,7 +1855,7 @@ public void display() { * * * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects + * @return an array of type double */ public double[] get(String name) { return getOperation().get(name); @@ -1885,7 +1922,7 @@ public void setThermoOperationThread(Thread thermoOperationThread) { * * * @param name a {@link java.lang.String} object - * @param data an array of {@link double} objects + * @param data an array of type double */ public void addData(String name, double[][] data) { operation.addData(name, data); @@ -1899,7 +1936,7 @@ public void addData(String name, double[][] data) { * @param phaseNumber a int */ public void calcIonComposition(int phaseNumber) { - operation = new calcIonicComposition(system, phaseNumber); + operation = new CalcIonicComposition(system, phaseNumber); getOperation().run(); resultTable = getOperation().getResultTable(); } @@ -1975,9 +2012,22 @@ public CalculationResult propertyFlash(List- * calcIonicComposition class. + * CalcIonicComposition class. *
* * @author even solbraa * @version $Id: $Id */ -public class calcIonicComposition extends Flash { +public class CalcIonicComposition extends Flash { private static final long serialVersionUID = 1000; - Logger logger = LogManager.getLogger(calcIonicComposition.class); + Logger logger = LogManager.getLogger(CalcIonicComposition.class); int phaseNumber; String[][] resultTable = null; /** *- * Constructor for calcIonicComposition. + * Constructor for CalcIonicComposition. *
* * @param system a {@link neqsim.thermo.system.SystemInterface} object * @param phase a int */ - public calcIonicComposition(SystemInterface system, int phase) { + public CalcIonicComposition(SystemInterface system, int phase) { this.system = system; phaseNumber = phase; } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java index 59dc3555e7..76f7cc08f8 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/Flash.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.BaseOperation; @@ -17,7 +18,7 @@ * * @author Even Solbraa */ -abstract class Flash extends BaseOperation { +public abstract class Flash extends BaseOperation { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(Flash.class); @@ -46,7 +47,7 @@ abstract class Flash extends BaseOperation { double[] tm; int lowestGibbsEnergyPhase = 0; sysNewtonRhapsonTPflash secondOrderSolver; - /** Set true to check for solid phase and do solid phase calculations. */ + /** Set true to do solid phase check and calculations */ protected boolean solidCheck = false; protected boolean stabilityCheck = false; protected boolean findLowestGibbsPhaseIsChecked = false; @@ -342,18 +343,24 @@ public boolean stabilityCheck() { system.setNumberOfPhases(1); if (lowestGibbsEnergyPhase == 0) { - system.setPhaseType(0, 1); + system.setPhaseType(0, PhaseType.byValue(1)); } else { - system.setPhaseType(0, 0); + system.setPhaseType(0, PhaseType.byValue(0)); } system.init(1); if (solidCheck && !system.doMultiPhaseCheck()) { this.solidPhaseFlash(); } } else { + RachfordRice rachfordRice = new RachfordRice(); try { - system.calcBeta(); + system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); } catch (Exception ex) { + if (!Double.isNaN(rachfordRice.getBeta()[0])) { + system.setBeta(rachfordRice.getBeta()[0]); + } else { + system.setBeta(Double.NaN); + } logger.error(ex.getMessage(), ex); } system.calc_x_y(); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashSingleComp.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashSingleComp.java index b30115a77b..7a84d17f97 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashSingleComp.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PHflashSingleComp.java @@ -41,7 +41,11 @@ public void run() { try { bubOps.TPflash(); if (system.getPhase(0).getType() == PhaseType.GAS) { - bubOps.dewPointTemperatureFlash(); + try { + bubOps.dewPointTemperatureFlash(); + } catch (Exception e) { + system.setTemperature(298.0); + } } else { bubOps.bubblePointTemperatureFlash(); } @@ -62,11 +66,11 @@ public void run() { /* * double solidEnthalpy = 0.0; - * + * * if (system.doSolidPhaseCheck()) { system.init(3, 3); solidEnthalpy = * system.getPhases()[3].getEnthalpy() / system.getPhases()[3].getNumberOfMolesInPhase() * system.getTotalNumberOfMoles(); - * + * * if (Hspec < liqEnthalpy && Hspec > solidEnthalpy) { double solidbeta = (Hspec - liqEnthalpy) * / (gasEnthalpy - liqEnthalpy); } } */ diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java index 648184a5a7..99752dedef 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008.java @@ -105,6 +105,5 @@ public void run() { } solveQ(); system.init(3); - return; } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java new file mode 100644 index 0000000000..415717ce61 --- /dev/null +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/RachfordRice.java @@ -0,0 +1,507 @@ +/* + * RachfordRice.java + * + * Created on 1.april 2024 + */ + +package neqsim.thermodynamicOperations.flashOps; + +import java.io.Serializable; +import neqsim.thermo.component.ComponentInterface; +import neqsim.thermo.system.SystemInterface; + +/** + * RachfordRice classes. + * + * @author Even Solbraa + */ +public class RachfordRice implements Serializable { + private static final long serialVersionUID = 1000; + private double[] beta = new double[2]; + private static String method = "Michelsen2001"; // alternative use Nielsen2023 + + /** + *
+ * Getter for the field method
.
+ *
+ * Setter for the field method
.
+ *
+ * calcBeta. For gas liquid systems. Method used is defined in method String variable + *
+ * + * @param K an array of type double + * @param z an array of type double + * @return Beta Mole fraction of gas phase + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double calcBeta(double[] K, double[] z) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + if (method.equals("Michelsen2001")) { + return calcBetaMichelsen2001(K, z); + } else if (method.equals("Nielsen2023")) { + return calcBetaNielsen2023(K, z); + } else { + return calcBetaMichelsen2001(K, z); + } + } + + /** + *+ * calcBeta. For gas liquid systems. Method based on Michelsen Mollerup, 2001 + *
+ * + * @param K an array of type double + * @param z an array of type double + * @return Beta Mole fraction of gas phase + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double calcBetaMichelsen2001(double[] K, double[] z) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + int i; + double tolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + double midler = 0; + double minBeta = tolerance; + double maxBeta = 1.0 - tolerance; + double g0 = -1.0; + double g1 = 1.0; + + for (i = 0; i < K.length; i++) { + midler = (K[i] * z[i] - 1.0) / (K[i] - 1.0); + if ((midler > minBeta) && (K[i] > 1.0)) { + minBeta = midler; + } + midler = (1.0 - z[i]) / (1.0 - K[i]); + if ((midler < maxBeta) && (K[i] < 1.0)) { + maxBeta = midler; + } + g0 += z[i] * K[i]; + g1 += -z[i] / K[i]; + } + + if (g0 < 0) { + return tolerance; + } + if (g1 > 0) { + return 1.0 - tolerance; + } + + double nybeta = (minBeta + maxBeta) / 2.0; + double gtest = 0.0; + for (i = 0; i < K.length; i++) { + gtest += z[i] * (K[i] - 1.0) / (1.0 - nybeta + nybeta * K[i]); + } + + if (gtest >= 0) { + minBeta = nybeta; + } else { + maxBeta = nybeta; + } + + if (gtest < 0) { + double minold = minBeta; + minBeta = 1.0 - maxBeta; + maxBeta = 1.0 - minold; + } + + int iterations = 0; + int maxIterations = 300; + double step = 1.0; + double gbeta = 0.0; + double deriv = 0.0; + double betal = 1.0 - nybeta; + do { + iterations++; + if (gtest >= 0) { + deriv = 0.0; + gbeta = 0.0; + + for (i = 0; i < K.length; i++) { + double temp1 = (K[i] - 1.0); + double temp2 = 1.0 + temp1 * nybeta; + deriv += -(z[i] * temp1 * temp1) / (temp2 * temp2); + gbeta += z[i] * (K[i] - 1.0) / (1.0 + (K[i] - 1.0) * nybeta); + } + + if (gbeta >= 0) { + minBeta = nybeta; + } else { + maxBeta = nybeta; + } + nybeta -= (gbeta / deriv); + + if (nybeta > maxBeta) { + nybeta = maxBeta; + } + if (nybeta < minBeta) { + nybeta = minBeta; + } + } else { + deriv = 0.0; + gbeta = 0.0; + + for (i = 0; i < K.length; i++) { + deriv -= (z[i] * (K[i] - 1.0) * (1.0 - K[i])) / Math.pow((betal + (1 - betal) * K[i]), 2); + gbeta += z[i] * (K[i] - 1.0) / (betal + (-betal + 1.0) * K[i]); + } + + if (gbeta < 0) { + minBeta = betal; + } else { + maxBeta = betal; + } + + betal -= (gbeta / deriv); + + if (betal > maxBeta) { + betal = maxBeta; + } + if (betal < minBeta) { + betal = minBeta; + } + nybeta = 1.0 - betal; + } + step = gbeta / deriv; + } while (Math.abs(step) >= 1.5e-10 && iterations < maxIterations); + if (nybeta <= tolerance) { + nybeta = tolerance; + } else if (nybeta >= 1.0 - tolerance) { + nybeta = 1.0 - tolerance; + } + beta[0] = nybeta; + beta[1] = 1.0 - nybeta; + + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(new RachfordRice(), "calcBeta", + maxIterations); + } + if (Double.isNaN(nybeta)) { + throw new neqsim.util.exception.IsNaNException(new RachfordRice(), "calcBeta", "beta"); + } + return nybeta; + } + + /** + *+ * calcBetaNielsen2023. For gas liquid systems. Method based on Avoiding round-off error in the + * Rachford–Rice equation, Nielsen, Lia, 2023 + *
+ * + * @param K an array of type double + * @param z an array of type double + * @return Beta Mole fraction of gas phase + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public double calcBetaNielsen2023(double[] K, double[] z) + throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + double tolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + double g0 = -1.0; + double g1 = 1.0; + + for (int i = 0; i < K.length; i++) { + g0 += z[i] * K[i]; + g1 += -z[i] / K[i]; + } + + if (g0 < 0) { + return tolerance; + } + if (g1 > 0) { + return 1.0 - tolerance; + } + + double V = 0.5; + double h = 0.0; + + for (int i = 0; i < K.length; i++) { + h += z[i] * (K[i] - 1.0) / (1.0 + V * (K[i] - 1.0)); + } + if (h > 0) { + for (int i = 0; i < K.length; i++) { + K[i] = 1.0 / K[i]; + } + } + + double Kmax = K[0]; + double Kmin = K[0]; + + for (int i = 1; i < K.length; i++) { + if (K[i] < Kmin) { + Kmin = K[i]; + } else if (K[i] > Kmax) { + Kmax = K[i]; + } + } + + double alphaMin = 1.0 / (1.0 - Kmax); + double alphaMax = 1.0 / (1.0 - Kmin); + + double alpha = V; + + double a = (alpha - alphaMin) / (alphaMax - alpha); + double b = 1.0 / (alpha - alphaMin); + + double[] c = new double[K.length]; + double[] d = new double[K.length]; + for (int i = 0; i < K.length; i++) { + c[i] = 1.0 / (1.0 - K[i]); + d[i] = (alphaMin - c[i]) / (alphaMax - alphaMin); + } + + double hb = 0.0; + double amax = alpha; + double bmax = 1e20; + double amin = 0; + double bmin = 1.0 / (alphaMax - alphaMin); + int iter = 0; + int maxIterations = 300; + do { + iter++; + double funk = 0; + double funkder = 0.0; + hb = 0.0; + double hbder = 0.0; + for (int i = 0; i < K.length; i++) { + funk -= z[i] * a * (1.0 + a) / (d[i] + a * (1.0 + d[i])); + funkder -= + z[i] * (a * a + (1.0 + a) * (1.0 + a) * d[i]) / Math.pow(d[i] + a * (1.0 + d[i]), 2.0); + hb += z[i] * b / (1.0 + b * (alphaMin - c[i])); + hbder += z[i] / Math.pow(1.0 + b * (alphaMin - c[i]), 2.0); + } + if (funk > 0) { + amax = a; + } else { + amin = a; + } + if (hb > 0) { + bmax = b; + } else { + bmin = b; + } + a = a - funk / funkder; + if (a > amax || a < amin) { + a = (amax + amin) / 2.0; + } + b = b - hb / hbder; + if (b > bmax || b < bmin) { + b = (bmax + bmin) / 2.0; + } + } while (Math.abs(hb) > 1e-10 && iter < maxIterations); + + V = -((1 / b) / a - alphaMax); + + if (h > 0) { + V = 1 - V; + } + + if (V <= tolerance) { + V = tolerance; + } else if (V >= 1.0 - tolerance) { + V = 1.0 - tolerance; + } + + beta[0] = V; + beta[1] = 1.0 - V; + + if (iter >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(new RachfordRice(), "calcBeta", + maxIterations); + } + if (Double.isNaN(V)) { + throw new neqsim.util.exception.IsNaNException(new RachfordRice(), "calcBeta", "beta"); + } + + return V; + } + + /** + *
+ * Getter for the field beta
.
+ *
+ * calcBetaS. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @return a double + * @throws neqsim.util.exception.IsNaNException if any. + * @throws neqsim.util.exception.TooManyIterationsException if any. + */ + public final double calcBetaS(SystemInterface system) throws neqsim.util.exception.IsNaNException, + neqsim.util.exception.TooManyIterationsException { + ComponentInterface[] compArray = system.getPhase(0).getComponents(); + + int i; + double tolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + double midler = 0; + double minBeta = tolerance; + double maxBeta = 1.0 - tolerance; + double g0 = -1.0; + double g1 = 1.0; + + for (i = 0; i < system.getNumberOfComponents(); i++) { + midler = (compArray[i].getK() * compArray[i].getz() - 1.0) / (compArray[i].getK() - 1.0); + if ((midler > minBeta) && (compArray[i].getK() > 1.0)) { + minBeta = midler; + } + midler = (1.0 - compArray[i].getz()) / (1.0 - compArray[i].getK()); + if ((midler < maxBeta) && (compArray[i].getK() < 1.0)) { + maxBeta = midler; + } + g0 += compArray[i].getz() * compArray[i].getK(); + g1 += -compArray[i].getz() / compArray[i].getK(); + } + + if (g0 < 0) { + this.beta[1] = 1.0 - tolerance; + this.beta[0] = tolerance; + return this.beta[0]; + } + if (g1 > 0) { + this.beta[1] = tolerance; + this.beta[0] = 1.0 - tolerance; + return this.beta[0]; + } + + double nybeta = (minBeta + maxBeta) / 2.0; + + double gtest = 0.0; + for (i = 0; i < system.getNumberOfComponents(); i++) { + gtest += compArray[i].getz() * (compArray[i].getK() - 1.0) + / (1.0 - nybeta + nybeta * compArray[i].getK()); + } + + if (gtest >= 0) { + minBeta = nybeta; + } else { + maxBeta = nybeta; + } + + if (gtest < 0) { + double minold = minBeta; + minBeta = 1.0 - maxBeta; + maxBeta = 1.0 - minold; + } + + int iterations = 0; + int maxIterations = 300; + double step = 1.0; + double deriv = 0.0; + double gbeta = 0.0; + double betal = 1.0 - nybeta; + + do { + iterations++; + if (gtest >= 0) { + deriv = 0.0; + gbeta = 0.0; + + for (i = 0; i < system.getNumberOfComponents(); i++) { + double temp1 = (compArray[i].getK() - 1.0); + double temp2 = 1.0 + temp1 * nybeta; + deriv += -(compArray[i].getz() * temp1 * temp1) / (temp2 * temp2); + gbeta += compArray[i].getz() * (compArray[i].getK() - 1.0) + / (1.0 + (compArray[i].getK() - 1.0) * nybeta); + } + + if (gbeta >= 0) { + minBeta = nybeta; + } else { + maxBeta = nybeta; + } + nybeta -= (gbeta / deriv); + + if (nybeta > maxBeta) { + nybeta = maxBeta; + } + if (nybeta < minBeta) { + nybeta = minBeta; + } + } else { + deriv = 0.0; + gbeta = 0.0; + + for (i = 0; i < system.getNumberOfComponents(); i++) { + deriv -= (compArray[i].getz() * (compArray[i].getK() - 1.0) * (1.0 - compArray[i].getK())) + / Math.pow((betal + (1 - betal) * compArray[i].getK()), 2); + gbeta += compArray[i].getz() * (compArray[i].getK() - 1.0) + / (betal + (-betal + 1.0) * compArray[i].getK()); + } + + if (gbeta < 0) { + minBeta = betal; + } else { + maxBeta = betal; + } + + betal -= (gbeta / deriv); + + if (betal > maxBeta) { + betal = maxBeta; + } + if (betal < minBeta) { + betal = minBeta; + } + + nybeta = 1.0 - betal; + } + step = gbeta / deriv; + } while (Math.abs(step) >= 1.0e-10 && iterations < maxIterations); // && + + if (nybeta <= tolerance) { + // this.phase = 1; + nybeta = tolerance; + } else if (nybeta >= 1.0 - tolerance) { + // this.phase = 0; + nybeta = 1.0 - tolerance; + // superheated vapour + } else { + // this.phase = 2; + } // two-phase liquid-gas + + this.beta[0] = nybeta; + this.beta[1] = 1.0 - nybeta; + + if (iterations >= maxIterations) { + throw new neqsim.util.exception.TooManyIterationsException(this, "calcBeta", maxIterations); + } + if (Double.isNaN(beta[1])) { + /* + * for (i = 0; i < numberOfComponents; i++) { System.out.println("K " + compArray[i].getK()); + * System.out.println("z " + compArray[i].getz()); } + */ + throw new neqsim.util.exception.IsNaNException(this, "calcBeta", "beta"); + } + return this.beta[0]; + } +} diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWater.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWater.java index d90e84886b..0a785033b9 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWater.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWater.java @@ -37,17 +37,19 @@ public SaturateWithWater(SystemInterface system) { @Override public void run() { if (!system.getPhase(0).hasComponent("water")) { - system.addComponent("water", system.getTotalNumberOfMoles()); - system.createDatabase(true); + system.addComponent("water", system.getTotalNumberOfMoles() / 100.0); system.setMixingRule(system.getMixingRule()); - if (system.doMultiPhaseCheck()) { - system.setMultiPhaseCheck(true); - } - system.init(0); } - double dn = 1.0; - int i = 0; + boolean changedMultiPhase = false; + if (system.doMultiPhaseCheck() == false) { + system.setMultiPhaseCheck(true); + changedMultiPhase = true; + } + + if (system.getComponent("water").getNumberOfmoles() < system.getTotalNumberOfMoles() / 2.0) { + system.addComponent("water", system.getTotalNumberOfMoles()); + } this.tpFlash = new TPflash(system); tpFlash.run(); boolean hasAq = false; @@ -56,32 +58,37 @@ public void run() { } double lastdn = 0.0; if (system.hasPhaseType(PhaseType.AQUEOUS)) { - lastdn = system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase(); + lastdn = system.getPhase(PhaseType.AQUEOUS).getNumberOfMolesInPhase(); } else { - lastdn = system.getPhase(0).getNumberOfMolesInPhase() / 100.0; + lastdn = system.getPhase(0).getNumberOfMolesInPhase(); } - + double dn = 1.0; + int i = 0; do { i++; - - if (!hasAq) { - system.addComponent("water", lastdn * 0.5); - lastdn *= 0.8; + if (system.getNumberOfPhases() == 1 && hasAq) { + lastdn = -system.getComponent("water").getNumberOfmoles() * 0.1; + } else if (!hasAq) { + lastdn = Math.abs(lastdn) * 1.05; } else { - lastdn = system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase(); - dn = lastdn / system.getNumberOfMoles(); - system.addComponent("water", -lastdn); + lastdn = + -system.getPhaseOfType("aqueous").getComponent("water").getNumberOfMolesInPhase() * 0.9; } + dn = lastdn / system.getNumberOfMoles(); + system.addComponent("water", lastdn); tpFlash.run(); - // system.display(); - hasAq = system.hasPhaseType("aqueous"); - } while ((i < 50 && Math.abs(dn) > 1e-7) || !hasAq && i <= 50); + hasAq = system.hasPhaseType(PhaseType.AQUEOUS); + } while (Math.abs(dn) > 1e-7 && i <= 50); if (i == 50) { logger.error("could not find solution - in water saturate : dn " + dn); } - // logger.info("i " + i + " dn " + dn); - system.removePhase(system.getNumberOfPhases() - 1); - tpFlash.run(); + if (system.hasPhaseType(PhaseType.AQUEOUS)) { + system.removePhase(system.getNumberOfPhases() - 1); + tpFlash.run(); + } + if (changedMultiPhase) { + system.setMultiPhaseCheck(false); + } } /** @@ -116,7 +123,7 @@ public static void main(String[] args) { // testSystem.display(); // testSystem.addComponent("water", 1); // testOps.saturateWithWater(); - testSystem.display(); + // testSystem.display(); // testOps.TPflash(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash.java index 99683110e4..ceac27e312 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; /** @@ -55,7 +56,7 @@ public void setSolidComponent(int i) { * * * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param checkForSolids Set true to check for solid phase and do solid phase calculations. + * @param checkForSolids Set true to do solid phase check and calculations */ public SolidFlash(SystemInterface system, boolean checkForSolids) { super(system, checkForSolids); @@ -291,16 +292,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); } else { - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); } system.init(1); } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1.java index f39e08a2b9..be08aea275 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -336,16 +337,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); } else { - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); } system.init(1); } @@ -392,6 +393,7 @@ public void run() { system.setSolidPhaseCheck(true); if (checkAndAddSolidPhase() == 0) { + system.init(1); return; } if (system.getPhase(0).getNumberOfComponents() == 1) { diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java index 691c64e870..48f6b0a910 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/SolidFlash12.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -263,16 +264,16 @@ public void checkGibbs() { double gibbs1 = 0; double gibbs2 = 0; for (int i = 0; i < system.getNumberOfPhases() - 1; i++) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); system.init(1); gibbs1 = system.getPhase(i).getGibbsEnergy(); - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); system.init(1); gibbs2 = system.getPhase(i).getGibbsEnergy(); if (gibbs1 < gibbs2) { - system.setPhaseType(i, 0); + system.setPhaseType(i, PhaseType.byValue(0)); } else { - system.setPhaseType(i, 1); + system.setPhaseType(i, PhaseType.byValue(1)); } system.init(1); } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java index c1f3232b00..9c2dfe83ca 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPflash.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -30,8 +29,7 @@ public class TPflash extends Flash { * Constructor for TPflash. * */ - public TPflash() { - } + public TPflash() {} /** *@@ -57,7 +55,7 @@ public TPflash(SystemInterface system) { *
* * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param checkForSolids Set true to check for solid phase and do solid phase calculations. + * @param checkForSolids Set true to do solid phase check and calculations */ public TPflash(SystemInterface system, boolean checkForSolids) { this(system); @@ -92,8 +90,11 @@ public void sucsSubs() { } double oldBeta = system.getBeta(); + + RachfordRice rachfordRice = new RachfordRice(); try { - system.calcBeta(); + system.setBeta(rachfordRice.calcBetaS(system)); + //system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); } catch (IsNaNException ex) { logger.warn("Not able to calculate beta. Value is NaN"); system.setBeta(oldBeta); @@ -134,13 +135,16 @@ public void accselerateSucsSubs() { system.getPhase(1).getComponent(i).setK(Math.exp(lnK[i])); } double oldBeta = system.getBeta(); + RachfordRice rachfordRice = new RachfordRice(); try { - system.calcBeta(); + system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); } catch (Exception ex) { + system.setBeta(rachfordRice.getBeta()[0]); if (system.getBeta() > 1.0 - betaTolerance || system.getBeta() < betaTolerance) { system.setBeta(oldBeta); } - logger.info("temperature " + system.getTemperature() + " pressure " + system.getPressure()); + // logger.info("temperature " + system.getTemperature() + " pressure " + + // system.getPressure()); logger.error(ex.getMessage(), ex); } @@ -180,7 +184,8 @@ public void resetK() { system.getPhase(1).getComponents()[i].setK(Math.exp(lnK[i])); } try { - system.calcBeta(); + RachfordRice rachfordRice = new RachfordRice(); + system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); system.calc_x_y(); system.init(1); } catch (Exception ex) { @@ -251,7 +256,8 @@ public void run() { // Calculates phase fractions and initial composition based on Wilson K-factors try { - system.calcBeta(); + RachfordRice rachfordRice = new RachfordRice(); + system.setBeta(rachfordRice.calcBeta(system.getKvector(), system.getzvector())); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } @@ -364,12 +370,12 @@ public void run() { // Checks if gas or oil is the most stable phase double gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 0); + system.setPhaseType(0, PhaseType.byValue(0)); system.init(1, 0); double liqgib = system.getPhase(0).getGibbsEnergy(); if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, 1); + system.setPhaseType(0, PhaseType.byValue(1)); } system.init(1); @@ -461,18 +467,18 @@ public void run() { // Checks if gas or oil is the most stable phase if (system.getPhase(0).getType() == PhaseType.GAS) { gasgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 0); + system.setPhaseType(0, PhaseType.byValue(0)); system.init(1, 0); liqgib = system.getPhase(0).getGibbsEnergy(); } else { liqgib = system.getPhase(0).getGibbsEnergy(); - system.setPhaseType(0, 1); + system.setPhaseType(0, PhaseType.byValue(1)); system.init(1, 0); gasgib = system.getPhase(0).getGibbsEnergy(); } if (gasgib * (1.0 - Math.signum(gasgib) * 1e-8) < liqgib) { - system.setPhaseType(0, 1); + system.setPhaseType(0, PhaseType.byValue(1)); } system.init(1); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java index 2815c0972b..3d1d0337df 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash.java @@ -59,7 +59,7 @@ public TPmultiflash(SystemInterface system) { * * * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param checkForSolids Set true to check for solid phase and do solid phase calculations. + * @param checkForSolids Set true to do solid phase check and calculations */ public TPmultiflash(SystemInterface system, boolean checkForSolids) { super(system, checkForSolids); @@ -258,7 +258,7 @@ public void stabilityAnalysis() { * for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if * (system.getPhase(0).getComponent(i).getx() < 1e-100) { clonedSystem.add(null); continue; } * double numb = 0; clonedSystem.add(system.clone()); - * + * * // (clonedSystem.get(i)).init(0); commented out sept 2005, Even S. for (int j = 0; j < * system.getPhase(0).getNumberOfComponents(); j++) { numb = i == j ? 1.0 : 1.0e-12; // set to 0 * by Even Solbraa 23.01.2013 - chaged back to 1.0e-12 27.04.13 if @@ -275,7 +275,7 @@ public void stabilityAnalysis() { * minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { if (!(( * clonedSystem.get(k)) == null)) { sumw[k] += ( * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx(); } } } - * + * * for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { for * (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { if (!(( * clonedSystem.get(k)) == null) && system.getPhase(0).getComponent(k).getx() > 1e-100) { ( @@ -370,13 +370,367 @@ public void stabilityAnalysis() { // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).isInert()) break; int iter = 0; double errOld = 1.0e100; + boolean useaccsubst = true; + int maxsucssubiter = 150; + int maxiter = 200; do { errOld = err; iter++; err = 0; - if (iter <= 150 || !system.isImplementedCompositionDeriativesofFugacity()) { - if (iter % 7 == 0) { + if (iter <= maxsucssubiter || !system.isImplementedCompositionDeriativesofFugacity()) { + if (iter % 7 == 0 && useaccsubst) { + double vec1 = 0.0; + + double vec2 = 0.0; + double prod1 = 0.0; + double prod2 = 0.0; + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + vec1 = oldDeltalogWi[i] * oldoldDeltalogWi[i]; + vec2 = Math.pow(oldoldDeltalogWi[i], 2.0); + prod1 += vec1 * vec2; + prod2 += vec2 * vec2; + } + + double lambda = prod1 / prod2; + // logger.info("lambda " + lambda); + for (i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + logWi[i] += lambda / (1.0 - lambda) * deltalogWi[i]; + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + } + } else { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; + } + clonedSystem.get(0).init(1, 1); + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + // oldlogw[i] = logWi[i]; + if (!Double.isInfinite( + clonedSystem.get(0).getPhase(1).getComponents()[i].getLogFugacityCoefficient()) + && system.getPhase(0).getComponent(i).getx() > 1e-100) { + logWi[i] = d[i] - clonedSystem.get(0).getPhase(1).getComponents()[i] + .getLogFugacityCoefficient(); + if (clonedSystem.get(0).getPhase(1).getComponents()[i].getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + } + deltalogWi[i] = logWi[i] - oldlogw[i]; + err += Math.abs(logWi[i] - oldlogw[i]); + Wi[j][i] = Math.exp(logWi[i]); + useaccsubst = true; + } + if (iter > 2 && err > errOld) { + useaccsubst = false; + } + } + } else { + SimpleMatrix f = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), 1); + SimpleMatrix df = null; + SimpleMatrix identitytimesConst = null; + // if (!secondOrderStabilityAnalysis) { + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + oldoldoldlogw[i] = oldoldlogw[i]; + oldoldlogw[i] = oldlogw[i]; + oldlogw[i] = logWi[i]; + oldoldDeltalogWi[i] = oldoldlogw[i] - oldoldoldlogw[i]; + oldDeltalogWi[i] = oldlogw[i] - oldoldlogw[i]; + } + clonedSystem.get(0).init(3, 1); + alpha = new double[clonedSystem.get(0).getPhases()[0].getNumberOfComponents()]; + df = new SimpleMatrix(system.getPhases()[0].getNumberOfComponents(), + system.getPhases()[0].getNumberOfComponents()); + identitytimesConst = SimpleMatrix.identity(system.getPhases()[0].getNumberOfComponents()); + // , + // system.getPhases()[0].getNumberOfComponents()); + // secondOrderStabilityAnalysis = true; + // } + + for (int i = 0; i < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); i++) { + alpha[i] = 2.0 * Math.sqrt(Wi[j][i]); + } + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + f.set(i, 0, + Math.sqrt(Wi[j][i]) + * (Math.log(Wi[j][i]) + clonedSystem.get(0).getPhases()[1].getComponents()[i] + .getLogFugacityCoefficient() - d[i])); + } + for (int k = 0; k < clonedSystem.get(0).getPhases()[0].getNumberOfComponents(); k++) { + double kronDelt = (i == k) ? 1.0 : 0.0; + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + df.set(i, k, kronDelt + Math.sqrt(Wi[j][k] * Wi[j][i]) + * clonedSystem.get(0).getPhases()[1].getComponents()[i].getdfugdn(k)); + // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } else { + df.set(i, k, 0); + // * clonedSystem.getPhases()[j].getNumberOfMolesInPhase()); + } + } + } + + // f.print(10, 10); + // df.print(10, 10); + SimpleMatrix dx = null; + try { + dx = df.plus(identitytimesConst).solve(f).negative(); + } catch (Exception e) { + dx = df.plus(identitytimesConst.scale(0.5)).solve(f).negative(); + } + + // dx.print(10, 10); + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + double alphaNew = alpha[i] + dx.get(i, 0); + Wi[j][i] = Math.pow(alphaNew / 2.0, 2.0); + if (system.getPhase(0).getComponent(i).getz() > 1e-100) { + logWi[i] = Math.log(Wi[j][i]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + logWi[i] = -1000.0; + } + err += Math.abs((logWi[i] - oldlogw[i]) / oldlogw[i]); + } + + // logger.info("err newton " + err); + } + // logger.info("err: " + err); + sumw[j] = 0; + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + sumw[j] += Math.exp(logWi[i]); + } + + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + clonedSystem.get(0).getPhase(1).getComponents()[i].setx(Math.exp(logWi[i]) / sumw[j]); + } + if (system.getPhase(0).getComponent(i).getIonicCharge() != 0) { + clonedSystem.get(0).getPhase(1).getComponents()[i].setx(1e-50); + } + } + } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < maxiter); + // logger.info("err: " + err + " ITER " + iter); + double xTrivialCheck0 = 0.0; + double xTrivialCheck1 = 0.0; + + tm[j] = 1.0; + + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + if (system.getPhase(0).getComponent(i).getx() > 1e-100) { + tm[j] -= Math.exp(logWi[i]); + } + x[j][i] = clonedSystem.get(0).getPhase(1).getComponents()[i].getx(); + // logger.info("txji: " + x[j][i]); + + xTrivialCheck0 += Math.abs(x[j][i] - system.getPhase(0).getComponent(i).getx()); + xTrivialCheck1 += Math.abs(x[j][i] - system.getPhase(1).getComponent(i).getx()); + } + if (iter >= maxiter) { + // logger.info("iter > maxiter multiphase stability "); + // logger.info("error " + Math.abs(err)); + // logger.info("tm: " + tm[j]); + } + + if (Math.abs(xTrivialCheck0) < 1e-4 || Math.abs(xTrivialCheck1) < 1e-4) { + tm[j] = 10.0; + } + + if (tm[j] < -1e-8) { + break; + } + } + + int unstabcomp = 0; + for (int k = system.getPhase(0).getNumberOfComponents() - 1; k >= 0; k--) { + if (tm[k] < -1e-8 && !(Double.isNaN(tm[k]))) { + system.addPhase(); + unstabcomp = k; + for (int i = 0; i < system.getPhase(1).getNumberOfComponents(); i++) { + system.getPhase(system.getNumberOfPhases() - 1).getComponents()[i].setx(x[k][i]); + } + system.getPhases()[system.getNumberOfPhases() - 1].normalize(); + multiPhaseTest = true; + system.setBeta(system.getNumberOfPhases() - 1, + system.getPhase(0).getComponent(unstabcomp).getz()); + system.init(1); + system.normalizeBeta(); + + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + k + " "+ tm[k]); + // system.display(); + return; + } + } + + system.normalizeBeta(); + // logger.info("STABILITY ANALYSIS: "); + // logger.info("tm1: " + tm[0] + " tm2: " + tm[1]); + // system.display(); + } + + /** + *+ * stabilityAnalysis3. + *
+ */ + public void stabilityAnalysis3() { + double[] logWi = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] Wi = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + + double[] deltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldDeltalogWi = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] sumw = new double[system.getPhase(0).getNumberOfComponents()]; + double err = 0; + double[] oldlogw = new double[system.getPhase(0).getNumberOfComponents()]; + double[] oldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] oldoldoldlogw = new double[system.getPhases()[0].getNumberOfComponents()]; + double[] d = new double[system.getPhase(0).getNumberOfComponents()]; + double[][] x = new double[system.getPhase(0).getNumberOfComponents()][system.getPhase(0) + .getNumberOfComponents()]; + tm = new double[system.getPhase(0).getNumberOfComponents()]; + + double[] alpha = null; + // SystemInterface minimumGibbsEnergySystem; + ArrayList- * calcdQdVV. + * calcdQdVP. *
* * @return a double */ - public double calcdQdVV() { - double dQdVV = 0.0; + public double calcdQdVdP() { + double dQdVP = 0.0; for (int i = 0; i < system.getNumberOfPhases(); i++) { - dQdVV += 1.0 / (system.getPhase(i).getVolume() / system.getVolume()) * 1.0 - / system.getPhase(i).getdPdVTn(); // *system.getPhase(i).getdVdP();system.getPhase(i).getVolume()/system.getVolume()* + dQdVP += 1.0 / system.getPhase(i).getdPdVTn(); } - return dQdVV; + return dQdVP; } /** @@ -75,22 +74,41 @@ public double solveQ() { double oldPres = system.getPressure(); double nyPres = system.getPressure(); double iterations = 1; + double error = 100.0; + double numericdQdVdP = 0.0; + double dQdV = 0.0; + double olddQdV = 0.0; + double pressureStep = 1.0; do { iterations++; oldPres = nyPres; system.init(3); - nyPres = oldPres - (iterations) / (iterations + 10.0) * calcdQdV() / calcdQdVV(); + double dQDVdP = calcdQdVdP(); + + numericdQdVdP = (calcdQdV() - olddQdV) / pressureStep; + + if (iterations < 5) { + nyPres = oldPres - 1.0 / 10.0 * calcdQdV() / dQDVdP; + } else { + nyPres = oldPres - 1.0 * calcdQdV() / numericdQdVdP; + } if (nyPres <= 0.0) { - nyPres = oldPres / 2.0; + nyPres = oldPres * 0.9; } if (nyPres >= oldPres * 2) { nyPres = oldPres * 2.0; } + pressureStep = nyPres - oldPres; + + olddQdV = calcdQdV(); system.setPressure(nyPres); tpFlash.run(); - // System.out.println(" dQdv " + calcdQdV() + " new pressure " + nyPres + " error " + - // Math.abs((nyPres-oldPres)/(nyPres)) + " numberofphases "+system.getNumberOfPhases()); - } while (Math.abs((nyPres - oldPres) / (nyPres)) > 1e-9 && iterations < 1000 || iterations < 3); + error = Math.abs(calcdQdV()) / system.getVolume(); + // System.out.println("error " + error + "iteration " + iterations + " dQdv " + calcdQdV() + // + " new pressure " + nyPres + " error " + Math.abs((nyPres - oldPres) / (nyPres)) + // + " numberofphases " + system.getNumberOfPhases() + " dQDVdP " + dQDVdP + " dQDVdPnumeric" + // + numericdQdVdP); + } while ((error > 1e-9 && iterations < 200) || iterations < 3); return nyPres; } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVfractionFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVfractionFlash.java new file mode 100644 index 0000000000..f722505207 --- /dev/null +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVfractionFlash.java @@ -0,0 +1,129 @@ +/* + * TVflash.java + * + * Created on 8. mars 2001, 10:56 + */ + +package neqsim.thermodynamicOperations.flashOps; + +import neqsim.thermo.system.SystemInterface; + +/** + *+ * TVflash class. + *
+ * + * @author even solbraa + * @version $Id: $Id + */ +public class TVfractionFlash extends Flash { + private static final long serialVersionUID = 1000; + + double Vfractionspec = 0; + Flash tpFlash; + + /** + *+ * Constructor for TVflash. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param Vfractionspec a double + */ + public TVfractionFlash(SystemInterface system, double Vfractionspec) { + this.system = system; + this.tpFlash = new TPflash(system); + this.Vfractionspec = Vfractionspec; + } + + /** + *+ * calcdQdVP. + *
+ * + * @return a double + */ + public double calcdQdVdP() { + double dQdVP = 0.0; + dQdVP = 1.0 / system.getPhase(i).getdPdVTn() / system.getVolume(); + return dQdVP; + } + + /** + *+ * calcdQdV. + *
+ * + * @return a double + */ + public double calcdQdV() { + double dQ = system.getPhase(0).getVolume() / system.getVolume() - Vfractionspec; + return dQ; + } + + /** + *+ * solveQ. + *
+ * + * @return a double + */ + public double solveQ() { + double oldPres = system.getPressure(); + double nyPres = system.getPressure(); + double iterations = 1; + double error = 100.0; + double numericdQdVdP = 0.0; + double dQdV = 0.0; + double olddQdV = 0.0; + double pressureStep = 1.0; + do { + iterations++; + oldPres = nyPres; + system.init(3); + double dQDVdP = calcdQdVdP(); + + numericdQdVdP = (calcdQdV() - olddQdV) / pressureStep; + + if (iterations < 5) { + nyPres = oldPres - 1.0 / 10.0 * calcdQdV() / dQDVdP; + } else { + nyPres = oldPres - 1.0 * calcdQdV() / numericdQdVdP; + } + if (nyPres <= 0.0) { + nyPres = oldPres * 0.9; + } + if (nyPres >= oldPres * 2) { + nyPres = oldPres * 2.0; + } + pressureStep = nyPres - oldPres; + + olddQdV = calcdQdV(); + system.setPressure(nyPres); + tpFlash.run(); + error = Math.abs(calcdQdV()) / system.getVolume(); + // System.out.println("error " + error + "iteration " + iterations + " dQdv " + calcdQdV() + // + " new pressure " + nyPres + " error " + Math.abs((nyPres - oldPres) / (nyPres)) + // + " numberofphases " + system.getNumberOfPhases() + " dQDVdP " + dQDVdP + " dQDVdPnumeric" + // + numericdQdVdP); + } while ((error > 1e-9 && iterations < 200) || iterations < 3); + return nyPres; + } + + /** {@inheritDoc} */ + @Override + public void run() { + tpFlash.run(); + // System.out.println("enthalpy: " + system.getEnthalpy()); + solveQ(); + + // System.out.println("volume: " + system.getVolume()); + // System.out.println("Temperature: " + system.getTemperature()); + } + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } +} diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java index 32827b182f..dc0c4aea58 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FreezeOut.java @@ -6,6 +6,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkSchwartzentruberEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -83,7 +84,7 @@ public void run() { SystemInterface testSystem2 = new SystemSrkSchwartzentruberEos(216, 1); ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); testSystem2.addComponent(testSystem.getPhase(0).getComponent(k).getComponentName(), 1); - testSystem2.setPhaseType(0, 1); + testSystem2.setPhaseType(0, PhaseType.byValue(1)); noFreezeliq = true; SolidFug = 0.0; FluidFug = 0.0; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java index 9bca127769..98676e2491 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/FugTestConstP.java @@ -4,6 +4,7 @@ import org.apache.logging.log4j.Logger; import neqsim.dataPresentation.JFreeChart.graph2b; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkSchwartzentruberEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -69,7 +70,7 @@ public FugTestConstP(SystemInterface system, double pres) { public void initTestSystem2(int K) { this.testSystem2 = new SystemSrkSchwartzentruberEos(temp, pres); this.testSystem2.addComponent(compName, 1); - this.testSystem2.setPhaseType(0, 1); + this.testSystem2.setPhaseType(0, PhaseType.byValue(1)); this.testOps2 = new ThermodynamicOperations(testSystem2); } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java index 9c1d517a08..8dec603b87 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlash.java @@ -2,8 +2,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; -import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -75,22 +75,24 @@ public void run() { system.init(1); ops.TPflash(); double wtp = 0.0; - if (system.hasPhaseType("aqueous")) { - wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - / (system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - + system.getPhase("aqueous").getComponent("water").getx() - * system.getPhase("aqueous").getComponent("water").getMolarMass()); + if (system.hasPhaseType(PhaseType.AQUEOUS)) { + // TODO: is this correct? seems to multplying and factoring with the same numbers twice + wtp = system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getMolarMass() + / (system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getMolarMass() + + system.getPhase(PhaseType.AQUEOUS).getComponent("water").getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent("water").getMolarMass()); } else { system.addComponent(inhibitor, system.getTotalNumberOfMoles()); ops.TPflash(); - wtp = system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - / (system.getPhase("aqueous").getComponent(inhibitor).getx() - * system.getPhase("aqueous").getComponent(inhibitor).getMolarMass() - + system.getPhase("aqueous").getComponent("water").getx() - * system.getPhase("aqueous").getComponent("water").getMolarMass()); + // TODO: is this correct? seems to multplying and factoring with the same numbers twice + wtp = system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getMolarMass() + / (system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent(inhibitor).getMolarMass() + + system.getPhase(PhaseType.AQUEOUS).getComponent("water").getx() + * system.getPhase(PhaseType.AQUEOUS).getComponent("water").getMolarMass()); } error = -(wtp - wtfrac); @@ -99,51 +101,9 @@ public void run() { logger.error(ex.getMessage(), ex); } } while ((Math.abs(error) > 1e-5 && iter < 100) || iter < 3); - // system.display(); } /** {@inheritDoc} */ @Override public void printToFile(String name) {} - - /** - *- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 0, 100.0); - - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - - testSystem.addComponent("nitrogen", 79.0); - testSystem.addComponent("oxygen", 21.0); - // testSystem.addComponent("ethane", 0.10); - // testSystem.addComponent("propane", 0.050); - // testSystem.addComponent("i-butane", 0.0050); - testSystem.addComponent("MEG", 0.000001); - testSystem.addComponent("water", 0.0010); - testSystem.createDatabase(true); - testSystem.setMixingRule(10); - - testSystem.init(0); - testSystem.setMultiPhaseCheck(true); - testSystem.setHydrateCheck(true); - - try { - testOps.hydrateInhibitorConcentrationSet("MEG", 0.99); - double cons = 100 * testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - / (testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("MEG").getMolarMass() - + testSystem.getPhase(0).getComponent("water").getNumberOfmoles() - * testSystem.getPhase(0).getComponent("water").getMolarMass()); - logger.info("hydrate inhibitor concentration " + cons + " wt%"); - } catch (Exception ex) { - ex.toString(); - } - testSystem.display(); - } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java index be0bd63172..abcd7d84c4 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureNoDer.java @@ -151,7 +151,6 @@ public void run() { && Math.abs(system.getPhases()[1].getComponents()[0].getFugacityCoefficient() / system.getPhases()[0].getComponents()[0].getFugacityCoefficient() - 1.0) < 1e-20) { setSuperCritical(true); - return; } } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java index 26cb22a203..ceb45933af 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/constantDutyFlash.java @@ -38,6 +38,9 @@ public abstract class constantDutyFlash implements ConstantDutyFlashInterface { double[] tm = { 1, 1 }; int lowestGibbsEnergyPhase = 0; // lowestGibbsEnergyPhase + /** + *Constructor for constantDutyFlash.
+ */ public constantDutyFlash() { } diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java index aebaa69bb0..8c7d17d6f8 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/cricondenBarTemp1.java @@ -196,7 +196,7 @@ public org.jfree.chart.JFreeChart getJFreeChart(String name) { * * * @param name a {@link java.lang.String} object - * @return an array of {@link double} objects + * @return an array of type double */ public double[] get(String name) { return new double[0]; @@ -224,7 +224,7 @@ public void displayResult() {} * * * @param i a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getPoints(int i) { return null; diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/freezingPointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/freezingPointTemperatureFlash.java index 5c5e25b584..bc700a7806 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/freezingPointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/freezingPointTemperatureFlash.java @@ -169,7 +169,7 @@ public void run() { * * @param name a {@link java.lang.String} object * @param FCompNames an array of {@link java.lang.String} objects - * @param FCompTemp an array of {@link double} objects + * @param FCompTemp an array of type double */ public void printToFile(String name, String[] FCompNames, double[] FCompTemp) { for (int n = 0; n < system.getPhases()[0].getNumberOfComponents(); n++) { diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureFlash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureFlash.java index e663713db2..4ab87f72aa 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/saturationOps/waterDewPointTemperatureFlash.java @@ -74,7 +74,7 @@ public void run() { * Math.pow(system.getPhases()[0].getComponents()[k] .getFugacityCoefficient(), 2.0) + * system.getPhases()[1].getComponents()[k].getdfugdt() / * system.getPhases()[i].getComponents()[k] .getFugacityCoefficient()); - * + * * system.setTemperature(system.getTemperature() - funk/deriv); */ diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenBarFlash.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenBarFlash.java index f034148f34..3e39689f6d 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenBarFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenBarFlash.java @@ -56,9 +56,9 @@ public class CricondenBarFlash extends pTphaseEnvelope { * @param system a {@link neqsim.thermo.system.SystemInterface} object * @param name a {@link java.lang.String} object * @param phaseFraction a double - * @param cricondenBar an array of {@link double} objects - * @param cricondenBarX an array of {@link double} objects - * @param cricondenBarY an array of {@link double} objects + * @param cricondenBar an array of type double + * @param cricondenBarX an array of type double + * @param cricondenBarY an array of type double */ public CricondenBarFlash(SystemInterface system, String name, double phaseFraction, double[] cricondenBar, double[] cricondenBarX, double[] cricondenBarY) { @@ -94,11 +94,11 @@ public void run() { setNewX(); /* * //iter X for (int iterX=0 ; iterX <= 10000 ; iterX++ ){ - * + * * system.setTemperature(T); system.setPressure(P); - * + * * uold = u.copy(); init(); setNewK(); setNewX(); - * + * * double sumK=0.; for (int i=0 ; i < numberOfComponents ; i++ ){ sumK= * sumK+(uold.get(i,0)-u.get(i,0))*(uold.get(i,0)-u.get(i,0)); } if (iterX == 10000 ){ ITERX=-1; * u=uini.copy(); setNewX(); break; } if (sumK <= 1E-7){ ITERX=iterX; setNewX(); break; } } @@ -198,7 +198,7 @@ public void run() { * System.out.println("dfuncdT : " + dfuncdT); System.out.println("dfuncdP : " + * dfuncdP); System.out.println("funcT : " + funcT); System.out.println("funcP : " + * funcP); - * + * * System.out.println(ITERX); System.out.println(ITER); System.out.println(ITERT); * System.out.println(ITERP); */ @@ -300,7 +300,7 @@ public void funcT() { /* * double voll=system.getPhase(0).getMolarVolume(); double * volv=system.getPhase(1).getMolarVolume(); - * + * * double T=system.getPhase(0).getPressure(); double P=system.getPhase(1).getTemperature() ; */ double fugl = system.getPhase(0).getComponent(j).getLogFugacityCoefficient(); diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenThermFlash.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenThermFlash.java index 6f438d8dd5..68c699a01a 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenThermFlash.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/CricondenThermFlash.java @@ -55,9 +55,9 @@ public class CricondenThermFlash extends pTphaseEnvelope { * @param system a {@link neqsim.thermo.system.SystemInterface} object * @param name a {@link java.lang.String} object * @param phaseFraction a double - * @param cricondenTherm an array of {@link double} objects - * @param cricondenThermX an array of {@link double} objects - * @param cricondenThermY an array of {@link double} objects + * @param cricondenTherm an array of type double + * @param cricondenThermX an array of type double + * @param cricondenThermY an array of type double */ public CricondenThermFlash(SystemInterface system, String name, double phaseFraction, double[] cricondenTherm, double[] cricondenThermX, double[] cricondenThermY) { @@ -92,15 +92,14 @@ public void run() { setNewX(); /* * //iter X for (int iterX=0 ; iterX <= 10000 ; iterX++ ){ - * + * * system.setTemperature(T); system.setPressure(P); - * + * * uold = u.copy(); init(); setNewK(); setNewX(); - * + * * double sumK=0.; for (int i=0 ; i < numberOfComponents ; i++ ){ sumK= * sumK+(uold.get(i,0)-u.get(i,0))*(uold.get(i,0)-u.get(i,0)); } if (iterX == 10000 ){ ITERX=-1; * u=uini.copy(); setNewX(); break; } if (sumK <= 1E-7){ ITERX=iterX; setNewX(); break; } } - * */ // starting loops for (int iter = 0; iter < 1000; iter++) { @@ -196,7 +195,7 @@ public void run() { * System.out.println("dfuncdT : " + dfuncdT); System.out.println("dfuncdP : " + * dfuncdP); System.out.println("funcT : " + funcT); System.out.println("funcP : " + * funcP); - * + * * System.out.println(ITERX); System.out.println(ITER); System.out.println(ITERT); * System.out.println(ITERP); */ @@ -298,7 +297,7 @@ public void funcT() { /* * double voll=system.getPhase(0).getMolarVolume(); double * volv=system.getPhase(1).getMolarVolume(); - * + * * double T=system.getPhase(0).getPressure(); double P=system.getPhase(1).getTemperature() ; */ double fugl = system.getPhase(0).getComponent(j).getLogFugacityCoefficient(); diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java index 5b0fda66b9..8d24a775a6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope.java @@ -7,14 +7,11 @@ package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps; import java.text.DecimalFormat; - import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JProgressBar; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.dataPresentation.JFreeChart.graph2b; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.BaseOperation; @@ -108,8 +105,7 @@ public class pTphaseEnvelope extends BaseOperation { * Constructor for pTphaseEnvelope. * */ - public pTphaseEnvelope() { - } + public pTphaseEnvelope() {} /** *@@ -160,11 +156,11 @@ public void run() { continue; } if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] + if (bubblePointFirst && system.getPhase(0).getComponents()[speceq] .getTC() > system.getPhase(0).getComponents()[i].getTC()) { speceq = system.getPhase(0).getComponent(i).getComponentNumber(); } - if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] + if (!bubblePointFirst && system.getPhase(0).getComponents()[speceq] .getTC() < system.getPhase(0).getComponents()[i].getTC()) { speceq = system.getPhase(0).getComponent(i).getComponentNumber(); } @@ -223,6 +219,7 @@ public void run() { new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); startPres = system.getPressure(); nonLinSolver.setu(); + for (np = 1; np < 9980; np++) { try { // solves the np point of the envelope @@ -295,7 +292,7 @@ public void run() { // System.out.println(np + " " + system.getTemperature() + " " + // system.getPressure() + " " + densV + " " + densL ); - if ((nonLinSolver.etterCP == false)) { + if (!nonLinSolver.etterCP) { if (Kvallc < 1.05 && Kvalhc > 0.95) { // close to the critical point // invert phase types and find the CP Temp and Press @@ -512,7 +509,7 @@ public void run() { * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); - * + * * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); @@ -521,6 +518,7 @@ public void run() { */ } catch (Exception ex) { logger.error(ex.getMessage(), ex); + throw ex; } } diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java index fed3e2a99f..72e6bbe0b2 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelope1.java @@ -315,7 +315,7 @@ public void run() { * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); - * + * * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java index 7aa341c63b..cf3b526e2a 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeMay.java @@ -129,11 +129,11 @@ public void run() { // based on the desired first point, dew/bubble for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { - if (bubblePointFirst == true && system.getPhase(0).getComponents()[speceq] + if (bubblePointFirst && system.getPhase(0).getComponents()[speceq] .getTC() > system.getPhase(0).getComponents()[i].getTC()) { speceq = system.getPhase(0).getComponent(i).getComponentNumber(); } - if (bubblePointFirst == false && system.getPhase(0).getComponents()[speceq] + if (!bubblePointFirst && system.getPhase(0).getComponents()[speceq] .getTC() < system.getPhase(0).getComponents()[i].getTC()) { speceq = system.getPhase(0).getComponent(i).getComponentNumber(); } @@ -252,7 +252,7 @@ public void run() { // System.out.println(np + " " + system.getTemperature() + " " + // system.getPressure() + " " + densV + " " + densL ); - if ((nonLinSolver.etterCP == false)) { + if (!nonLinSolver.etterCP) { if (Kvallc < 1.05 && Kvalhc > 0.95) { // close to the critical point // invert phase types and find the CP Temp and Press @@ -466,7 +466,7 @@ public void run() { * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); - * + * * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java index 56af56dd9f..208a35ecf6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew.java @@ -252,7 +252,7 @@ public void run() { * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file1.setOutputFileName(name1); file1.setXvalues(points2[2], "temp", "sec"); * file1.setYvalues(points2[3], "pres", "meter"); file1.createFile(); - * + * * String name2 = new String(); name2 = fileName + "Bub.nc"; file2 = new * neqsim.dataPresentation.fileHandeling.createNetCDF.netCDF2D.NetCdf2D(); * file2.setOutputFileName(name2); file2.setXvalues(points2[0], "temp", "sec"); diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew2.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew2.java new file mode 100644 index 0000000000..a28b8e31bc --- /dev/null +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/pTphaseEnvelopeNew2.java @@ -0,0 +1,602 @@ +/* + * pTphaseEnvelope.java + * + * Created on 14. oktober 2000, 21:59 Updated on May 2019, by Nefeli + */ + +package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps; + +import java.util.ArrayList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicOperations.BaseOperation; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + *
+ * pTphaseEnvelopeNew2 class. + *
+ * + * @author asmund + * @version $Id: $Id + */ +public class pTphaseEnvelopeNew2 extends BaseOperation { + private static final long serialVersionUID = 1000; + static Logger logger = LogManager.getLogger(pTphaseEnvelopeNew2.class); + + double maxPressure = 1000.0; + double minPressure = 1.0; + SystemInterface system; + boolean bubblePointFirst = true; + boolean calculatesDewPoint = true; + double[] cricondenTherm = new double[3]; + double[] cricondenBar = new double[3]; + double[] cricondenThermX = new double[100]; + double[] cricondenThermY = new double[100]; + double[] cricondenBarX = new double[100]; + double[] cricondenBarY = new double[100]; + double phaseFraction = 1e-10; + int i; + int j = 0; + int nummer = 0; + int iterations = 0; + int maxNumberOfIterations = 10000; + double gibbsEnergy = 0; + double gibbsEnergyOld = 0; + double Kold; + double deviation = 0; + double g0 = 0; + double g1 = 0; + double lowPres = 1.0; + double[] lnOldOldK; + double[] lnK; + boolean outputToFile = false; + double[] lnOldK; + double[] lnKwil; + double[] oldDeltalnK; + double[] deltalnK; + double[] tm = {1, 1}; + double beta = 1e-5; + int lowestGibbsEnergyPhase = 0; + String fileName = "c:/file"; + double temp = 0; + double pres = 0; + double startPres = 0; + boolean moreLines = false; + boolean restart = true; + int np = 0; + // points[2] = new double[1000]; + int speceq = 0; + double Tcfirst; + double Pcfirst; + double Tmin = 0.0; + + ArrayList+ * Constructor for pTphaseEnvelope. + *
+ */ + public pTphaseEnvelopeNew2() {} + + /** + *+ * Constructor for pTphaseEnvelope. + *
+ * + * @param system a {@link neqsim.thermo.system.SystemInterface} object + * @param name a {@link java.lang.String} object + * @param phaseFraction a double + * @param lowPres a double + * @param bubfirst a boolean + */ + public pTphaseEnvelopeNew2(SystemInterface system, String name, double phaseFraction, + double lowPres, boolean bubfirst) { + this.bubblePointFirst = bubfirst; + if (name != null) { + outputToFile = true; + fileName = name; + } + this.system = system; + this.phaseFraction = phaseFraction; + lnOldOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnOldK = new double[system.getPhase(0).getNumberOfComponents()]; + lnK = new double[system.getPhase(0).getNumberOfComponents()]; + this.lowPres = lowPres; + oldDeltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + deltalnK = new double[system.getPhase(0).getNumberOfComponents()]; + } + + /** {@inheritDoc} */ + @Override + public void run() { + speceq = 0; // initialization + try { + system.init(0); // initialization + + // selects the most volatile and least volatile component based on Tc values + // afterwards it uses them to define the speceq of the first point + // based on the desired first point, dew/bubble + for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { + if (system.getComponent(i).getz() < 1e-10) { + continue; + } + if (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { + if (bubblePointFirst && system.getPhase(0).getComponents()[speceq] + .getTC() > system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + if (!bubblePointFirst && system.getPhase(0).getComponents()[speceq] + .getTC() < system.getPhase(0).getComponents()[i].getTC()) { + speceq = system.getPhase(0).getComponent(i).getComponentNumber(); + } + } + } + + // initialized the first step of the phase envelope + // pressure is already defined + // temperature is the antoine vapor pressure of the selected component + // (least or most volatile. + pres = lowPres; + // temp = + // system.getPhase(0).getComponent(speceq).getAntoineVaporTemperature(pres); + temp = tempKWilson(phaseFraction, pres); + + if (Double.isNaN(temp)) { + temp = system.getPhase(0).getComponent(speceq).getTC() - 20.0; + } + system.setTemperature(temp); + system.setPressure(pres); + + ThermodynamicOperations testOps = new ThermodynamicOperations(system); + + // this part converges the first phase envelope point. + // if the plasefraction is more than 0.5 it does a dew point initiallization + // else a bubble point initiallization + + for (int i = 0; i < 5; i++) { + try { + if (phaseFraction < 0.5) { + temp += i * 2; + system.setTemperature(temp); + testOps.bubblePointTemperatureFlash(); + } else { + temp += i * 2; + system.setTemperature(temp); + testOps.dewPointTemperatureFlash(); + } + } catch (Exception ex) { + // ex.toString(); + } + double tempNy = system.getTemperature(); + + if (!Double.isNaN(tempNy)) { + temp = tempNy; + break; + } + } + + // this part sets the first envelope point into the system + system.setBeta(phaseFraction); + system.setPressure(pres); + system.setTemperature(temp); + + sysNewtonRhapsonPhaseEnvelope nonLinSolver = + new sysNewtonRhapsonPhaseEnvelope(system, 2, system.getPhase(0).getNumberOfComponents()); + startPres = system.getPressure(); + nonLinSolver.setu(); + + for (np = 1; np < 9980; np++) { + try { + // solves the np point of the envelope + nonLinSolver.calcInc(np); + nonLinSolver.solve(np); + + // this catches the exceptions + // double TT = system.getPhase(0).getTemperature(); + // double PP = system.getPhase(0).getPressure(); + } catch (Exception e0) { + // the envelope crushed. + // this part keeps the old values + // restarts the envelope from the other side + // and then stops + + if (restart) { + calculatesDewPoint = false; + restart = !restart; + Tcfirst = system.getTC(); + Pcfirst = system.getPC(); + + cricondenBarfirst = cricondenBar; + cricondenBarXfirst = cricondenBarX; + cricondenBarYfirst = cricondenBarY; + + cricondenThermfirst = cricondenTherm; + cricondenThermXfirst = cricondenThermX; + cricondenThermYfirst = cricondenThermY; + + // new settings + phaseFraction = 1.0 - phaseFraction; + bubblePointFirst = !bubblePointFirst; + run(); + /**/ + break; + } else { + np = np - 1; + break; + } + } + + // check for critical point + double Kvallc = system.getPhase(0).getComponent(nonLinSolver.lc).getx() + / system.getPhase(1).getComponent(nonLinSolver.lc).getx(); + double Kvalhc = system.getPhase(0).getComponent(nonLinSolver.hc).getx() + / system.getPhase(1).getComponent(nonLinSolver.hc).getx(); + // double densV = system.getPhase(0).getDensity(); + // double densL = system.getPhase(1).getDensity(); + + // System.out.println(np + " " + system.getTemperature() + " " + + // system.getPressure() + " " + densV + " " + densL ); + + if (!nonLinSolver.etterCP) { + if (Kvallc < 1.05 && Kvalhc > 0.95) { + // close to the critical point + // invert phase types and find the CP Temp and Press + + // System.out.println("critical point"); + nonLinSolver.npCrit = np; + system.invertPhaseTypes(); + nonLinSolver.etterCP = true; + calculatesDewPoint = false; + // the critical point is found from interpolation polynomials based on K=1 of + // the most or least volatile component + nonLinSolver.calcCrit(); + } + } + + // stores critondenbar and cricondentherm + // HERE the new cricoT and crico P values will be called instead + if (system.getTemperature() > cricondenTherm[0]) { + cricondenTherm[1] = system.getPressure(); + cricondenTherm[0] = system.getTemperature(); + for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { + cricondenThermX[ii] = system.getPhase(1).getComponent(ii).getx(); + cricondenThermY[ii] = system.getPhase(0).getComponent(ii).getx(); + } + } else { + nonLinSolver.ettercricoT = true; + } + if (system.getPressure() > cricondenBar[1]) { + cricondenBar[0] = system.getTemperature(); + cricondenBar[1] = system.getPressure(); + for (int ii = 0; ii < nonLinSolver.numberOfComponents; ii++) { + cricondenBarX[ii] = system.getPhase(1).getComponent(ii).getx(); + cricondenBarY[ii] = system.getPhase(0).getComponent(ii).getx(); + } + } + + // Exit criteria + if ((system.getPressure() < minPressure && nonLinSolver.ettercricoT)) { + break; + } + if (system.getPressure() > maxPressure) { + break; + } + if (system.getTemperature() < Tmin) { + break; + } + + if (system.getTemperature() > 1e-6 && system.getPressure() > 1e-6 + && !(Double.isNaN(system.getTemperature()) || Double.isNaN(system.getPressure()))) { + if (calculatesDewPoint) { + dewPointTemperature.add(system.getTemperature()); + dewPointPressure.add(system.getPressure()); + dewPointEnthalpy + .add(system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3); + dewPointVolume.add(system.getPhase(1).getDensity()); + dewPointEntropy + .add(system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3); + } else { + bubblePointTemperature.add(system.getTemperature()); + bubblePointPressure.add(system.getPressure()); + bubblePointEnthalpy + .add(system.getPhase(1).getEnthalpy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3); + bubblePointVolume.add(system.getPhase(1).getDensity()); + bubblePointEntropy + .add(system.getPhase(1).getEntropy() / system.getPhase(1).getNumberOfMolesInPhase() + / system.getPhase(1).getMolarMass() / 1e3); + } + } + } + + system.setTemperature(system.getTC()); + system.setPressure(system.getPC()); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + throw ex; + } + + dewPointTemperatureArray = new double[dewPointTemperature.size()]; + dewPointPressureArray = new double[dewPointPressure.size()]; + dewPointEnthalpyArray = new double[dewPointTemperature.size()]; + dewPointVolumeArray = new double[dewPointPressure.size()]; + dewPointEntropyArray = new double[dewPointPressure.size()]; + + bubblePointTemperatureArray = new double[bubblePointTemperature.size()]; + bubblePointPressureArray = new double[bubblePointPressure.size()]; + bubblePointEnthalpyArray = new double[bubblePointPressure.size()]; + bubblePointVolumeArray = new double[bubblePointPressure.size()]; + bubblePointEntropyArray = new double[bubblePointPressure.size()]; + + for (int i = 0; i < dewPointTemperature.size(); i++) { + dewPointTemperatureArray[i] = dewPointTemperature.get(i); + dewPointPressureArray[i] = dewPointPressure.get(i); + dewPointEnthalpyArray[i] = dewPointEnthalpy.get(i); + dewPointVolumeArray[i] = dewPointVolume.get(i); + dewPointEntropyArray[i] = dewPointEntropy.get(i); + } + + for (int i = 0; i < bubblePointTemperature.size(); i++) { + bubblePointTemperatureArray[i] = bubblePointTemperature.get(i); + bubblePointPressureArray[i] = bubblePointPressure.get(i); + bubblePointEnthalpyArray[i] = bubblePointEnthalpy.get(i); + bubblePointEntropyArray[i] = bubblePointEntropy.get(i); + bubblePointVolumeArray[i] = bubblePointVolume.get(i); + } + } + + /** + *+ * calcHydrateLine. + *
+ */ + public void calcHydrateLine() { + ThermodynamicOperations opsHyd = new ThermodynamicOperations(system); + try { + opsHyd.hydrateEquilibriumLine(10.0, 300.0); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + + // double[][] hydData = opsHyd.getData(); + } + + /** {@inheritDoc} */ + @Override + public void printToFile(String name) {} + + /** {@inheritDoc} */ + @Override + public double[] get(String name) { + if (name.equals("dewT")) { + return dewPointTemperatureArray; + } + if (name.equals("dewP")) { + return dewPointPressureArray; + } + if (name.equals("bubT")) { + return bubblePointTemperatureArray; + } + if (name.equals("bubP")) { + return bubblePointPressureArray; + } + + if (name.equals("dewH")) { + return dewPointEnthalpyArray; + } + if (name.equals("dewDens")) { + return dewPointVolumeArray; + } + if (name.equals("dewS")) { + return dewPointEntropyArray; + } + if (name.equals("bubH")) { + return bubblePointEnthalpyArray; + } + if (name.equals("bubDens")) { + return bubblePointVolumeArray; + } + if (name.equals("bubS")) { + return bubblePointEntropyArray; + } + if (name.equals("cricondentherm")) { + return cricondenTherm; + } + if (name.equals("cricondenthermX")) { + return cricondenThermX; + } + if (name.equals("cricondenthermY")) { + return cricondenThermY; + } + if (name.equals("cricondenbar")) { + return cricondenBar; + } + if (name.equals("cricondenbarX")) { + return cricondenBarX; + } + if (name.equals("cricondenbarY")) { + return cricondenBarY; + } + if (name.equals("criticalPoint1")) { + return new double[] {system.getTC(), system.getPC()}; + } + if (name.equals("criticalPoint2")) { + return new double[] {0, 0}; + } else { + return null; + } + } + + /** + * Getter for property bubblePointFirst. + * + * @return Value of property bubblePointFirst. + */ + public boolean isBubblePointFirst() { + return bubblePointFirst; + } + + /** + * Setter for property bubblePointFirst. + * + * @param bubblePointFirst New value of property bubblePointFirst. + */ + public void setBubblePointFirst(boolean bubblePointFirst) { + this.bubblePointFirst = bubblePointFirst; + } + + /** {@inheritDoc} */ + @Override + public String[][] getResultTable() { + return null; + } + + /** + *+ * tempKWilson. + *
+ * + * @param beta a double + * @param P a double + * @return a double + */ + public double tempKWilson(double beta, double P) { + // Initiallizes the temperature of a saturation point for given pressure + // based on K values of Wilson + // see Michelsen book thermodynamics & computational aspects + + double initTc = 0.; + double initPc = 0.; + double initAc = 0.; + double Tstart = 0.; + double Tstartold = 0.; + double initT = 0; + double dinitT = 0; + int numberOfComponents = system.getPhase(0).getNumberOfComponents(); + int lc = 0; + int hc = 0; + + double[] Kwil = new double[numberOfComponents]; + + double min = 100000.; + double max = 0.; + + for (int i = 0; i < numberOfComponents; i++) { + if (system.getPhase(0).getComponents()[i].getTC() > max) { + max = system.getPhase(0).getComponents()[i].getTC(); + hc = i; + } + if (system.getPhase(0).getComponents()[i].getTC() < min) { + min = system.getPhase(0).getComponents()[i].getTC(); + lc = i; + } + } + + try { + if (beta <= 0.5) { + // closer to bubble point get the lightest component + + initTc = system.getPhase(0).getComponents()[lc].getTC(); + initPc = system.getPhase(0).getComponents()[lc].getPC(); + initAc = system.getPhase(0).getComponents()[lc].getAcentricFactor(); + } else if (beta > 0.5) { + // closer to dew point get the heaviest component + initTc = system.getPhase(0).getComponents()[hc].getTC(); + initPc = system.getPhase(0).getComponents()[hc].getPC(); + initAc = system.getPhase(0).getComponents()[hc].getAcentricFactor(); + } + + // initial T based on the lightest/heaviest component + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + + // solve for Tstart with Newton + for (int i = 0; i < 1000; i++) { + initT = 0.; + dinitT = 0.; + for (int j = 0; j < numberOfComponents; j++) { + Kwil[j] = system.getPhase(0).getComponents()[j].getPC() / P + * Math.exp(5.373 * (1. + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * (1. - system.getPhase(0).getComponents()[j].getTC() / Tstart)); + // system.getPhases()[0].getComponents()[j].setK(Kwil[j]); + } + + for (int j = 0; j < numberOfComponents; j++) { + if (beta < 0.5) { + initT = initT + system.getPhase(0).getComponents()[j].getz() * Kwil[j]; + dinitT = dinitT + system.getPhase(0).getComponents()[j].getz() * Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } else { + initT = initT + system.getPhase(0).getComponents()[j].getz() / Kwil[j]; + dinitT = dinitT - system.getPhase(0).getComponents()[j].getz() / Kwil[j] * 5.373 + * (1 + system.getPhase(0).getComponents()[j].getAcentricFactor()) + * system.getPhase(0).getComponents()[j].getTC() / (Tstart * Tstart); + } + } + + initT = initT - 1.; + if (Math.abs(initT / dinitT) > 0.1 * Tstart) { + Tstart = Tstart - 0.001 * initT / dinitT; + } else { + Tstart = Tstart - initT / dinitT; + } + if (Math.abs(Tstart - Tstartold) < 1.e-5) { + return Tstart; + } + Tstartold = Tstart; + } + } catch (Exception ex) { + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + } + if (Double.isNaN(Tstart) || Double.isInfinite(Tstart)) { + Tstart = initTc * 5.373 * (1 + initAc) / (5.373 * (1 + initAc) - Math.log(P / initPc)); + } + return Tstart; + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} + + /** {@inheritDoc} */ + @Override + public org.jfree.chart.JFreeChart getJFreeChart(String name) { + return null; + } +} diff --git a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java index 62b6bf06ea..6ae23169a3 100644 --- a/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java +++ b/src/main/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/sysNewtonRhapsonPhaseEnvelope.java @@ -413,28 +413,8 @@ public void calcInc(int np) { // calculate the dxds of the system dxds = Jac.solve(fvec); - // check for critical point - - // check density - // double densV = system.getPhase(0).getDensity(); - // double densL = system.getPhase(1).getDensity(); - // check the proximity to the critical point by adding the lnKs and finding the highest - double Kvallc = - system.getPhase(0).getComponent(lc).getx() / system.getPhase(1).getComponent(lc).getx(); - double Kvalhc = - system.getPhase(0).getComponent(hc).getx() / system.getPhase(1).getComponent(hc).getx(); - - if ((etterCP == false)) { - if (Kvallc < 1.05 && Kvalhc > 0.95) { - calcCP = true; - etterCP = true; - npCrit = np; - system.invertPhaseTypes(); - // System.out.println("critical point"); - } - } - - // manipulate stepsize according to the number of iterations of the previous point + // manipulate stepsize according to the number of iterations of the previous + // point if (iter > 6) { ds *= 0.5; } else { @@ -663,38 +643,7 @@ public void solve(int np) { } while (norm > 1.e-5); init(); - findSpecEq(); - // check density for direction - volold2 = volold; - volold = vol; - vol = system.getPhase(0).getMolarVolume(); uold = u.copy(); - - if (volold < vol) { - /* - * volold=volold2; ds=-ds; u = uold.copy(); calcInc2(np); solve(np); - */ - } - - /* - * try { Matrix utest = u.copy(); } catch (Exception e0) { double nef = 0.; } - */ - } - - /** - *- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - /* - * sysNewtonRhapson test=new sysNewtonRhapson(); double[] constants = new double[]{0.4,0.4}; - * test.setx(constants); while (test.nonsol()>1.0e-8) { constants=test.getx(); - * logger.info(constants[0]+" "+constants[1]); } test.nonsol(); constants=test.getf(); - * logger.info(constants[0]+" "+constants[1]); System.exit(0); - */ } } diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGenerator.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGenerator.java index 89bff51de1..c6cc760de7 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGenerator.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGenerator.java @@ -7,6 +7,7 @@ import java.io.Writer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -161,8 +162,8 @@ public void run() { } if (!thermoSystem.hasPhaseType("gas")) { - // TODO: here is a bug, calling with input oil does nothing. - thermoSystem.setPhaseType("oil", 1); + thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.OIL), + PhaseType.byValue(1)); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); @@ -171,8 +172,8 @@ public void run() { } if (!thermoSystem.hasPhaseType("oil")) { - // TODO: here is a bug, calling with input gas does nothing. - thermoSystem.setPhaseType("gas", 1); + thermoSystem.setPhaseType(thermoSystem.getPhaseNumberOfPhase(PhaseType.GAS), + PhaseType.byValue(1)); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); @@ -181,7 +182,7 @@ public void run() { } if (!thermoSystem.hasPhaseType("aqueous")) { - thermoSystem.setPhaseType(1, 1); + thermoSystem.setPhaseType(1, PhaseType.byValue(1)); thermoSystem.init(3); thermoSystem.initPhysicalProperties(); diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorKeywordFormat.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorKeywordFormat.java index 670260bd48..dd8ea2e0af 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorKeywordFormat.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorKeywordFormat.java @@ -7,6 +7,7 @@ import java.io.Writer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -25,7 +26,7 @@ public class OLGApropertyTableGeneratorKeywordFormat SystemInterface thermoSystem = null; ThermodynamicOperations thermoOps = null; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; double stdPresATM = 1; double stdTemp = 288.15; double[] molfracs; @@ -144,8 +145,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcBubP(double[] temperatures) { double[] bubP = new double[temperatures.length]; @@ -169,8 +170,8 @@ public double[] calcBubP(double[] temperatures) { * calcDewP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcDewP(double[] temperatures) { double[] dewP = new double[temperatures.length]; @@ -194,8 +195,8 @@ public double[] calcDewP(double[] temperatures) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubT = new double[pressures.length]; diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java index fc6edbf503..def27913b0 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWater.java @@ -10,6 +10,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermo.system.SystemSrkEos; @@ -168,8 +170,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcBubP(double[] temperatures) { double[] bubP = new double[temperatures.length]; @@ -193,8 +195,8 @@ public double[] calcBubP(double[] temperatures) { * calcDewP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcDewP(double[] temperatures) { double[] dewP = new double[temperatures.length]; @@ -218,8 +220,8 @@ public double[] calcDewP(double[] temperatures) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubTemps = new double[pressures.length]; @@ -243,7 +245,7 @@ public double[] calcBubT(double[] pressures) { */ public void initCalc() { double stdTemp = 288.15; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; // double GOR, GLR; double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; @@ -572,7 +574,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, 0); + oilSystem.setPhaseType(0, PhaseType.byValue(0)); oilSystem.setTemperature(temperatures[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -710,7 +712,7 @@ public void run() { } else { waterSystem.setTemperature(temperatures[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); + waterSystem.setPhaseType(0, PhaseType.byValue(0)); waterSystem.init(3); waterSystem.initPhysicalProperties(); diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java index 2df3f6599a..e2ea191777 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterEven.java @@ -7,6 +7,7 @@ import java.io.Writer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -132,8 +133,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcBubP(double[] temperatures) { double[] bubP = new double[temperatures.length]; @@ -157,8 +158,8 @@ public double[] calcBubP(double[] temperatures) { * calcDewP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcDewP(double[] temperatures) { double[] dewP = new double[temperatures.length]; @@ -182,8 +183,8 @@ public double[] calcDewP(double[] temperatures) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubTemps = new double[pressures.length]; @@ -207,7 +208,7 @@ public double[] calcBubT(double[] pressures) { */ public void initCalc() { double stdTemp = 288.15; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; // double GOR, GLR; double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; @@ -414,9 +415,9 @@ public void run() { * { aMatrix.set(ii, 0, 1.0); aMatrix.set(ii, 1, pressures[i - ii]); aMatrix.set(ii, 2, * pressures[i - ii] * pressures[i - ii]); aMatrix.set(ii, 3, pressures[i - ii] * * pressures[i - ii] * pressures[i - ii]); } - * + * * for (int jj = 0; jj < 9; jj++) { Matrix xg = XMatrixgas.getMatrix(jj, jj, 0, 3); - * + * * try { xcoef[jj] = aMatrix.solve(xg.transpose()); } catch (Exception ex) { * logger.error(ex.getMessage(),e); } // logger.info("xcoef " + j); // xcoef.print(10, 10); * //logger.info("dss: " +ds * dxds.get(speceq, 0)); // specVal = xcoef.get(0, 0) + sny * diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterKeywordFormat.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterKeywordFormat.java index e1647e3f51..7ae34f92ad 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterKeywordFormat.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterKeywordFormat.java @@ -7,6 +7,7 @@ import java.io.Writer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -25,7 +26,7 @@ public class OLGApropertyTableGeneratorWaterKeywordFormat SystemInterface thermoSystem = null; ThermodynamicOperations thermoOps = null; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; double stdPresATM = 1; double stdTemp = 288.15; double[] molfracs; @@ -146,8 +147,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcBubP(double[] temperatures) { double[] bubP = new double[temperatures.length]; @@ -171,8 +172,8 @@ public double[] calcBubP(double[] temperatures) { * calcDewP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcDewP(double[] temperatures) { double[] dewP = new double[temperatures.length]; @@ -196,8 +197,8 @@ public double[] calcDewP(double[] temperatures) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubT = new double[pressures.length]; diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java index 5132b0b2ea..4cf8638415 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudents.java @@ -8,6 +8,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermo.system.SystemSrkEos; @@ -177,8 +179,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcBubP(double[] temperatures) { double[] bubP = new double[temperatures.length]; @@ -203,8 +205,8 @@ public double[] calcBubP(double[] temperatures) { * calcDewP. * * - * @param temperatures an array of {@link double} objects - * @return an array of {@link double} objects + * @param temperatures an array of type double + * @return an array of type double */ public double[] calcDewP(double[] temperatures) { double[] dewP = new double[temperatures.length]; @@ -230,8 +232,8 @@ public double[] calcDewP(double[] temperatures) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubTemps = new double[pressures.length]; @@ -255,7 +257,7 @@ public double[] calcBubT(double[] pressures) { */ public void initCalc() { double stdTemp = 288.15; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; // double GOR, GLR; double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; @@ -730,7 +732,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, 0); + oilSystem.setPhaseType(0, PhaseType.byValue(0)); oilSystem.setTemperature(temperatures[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -930,7 +932,7 @@ public void run() { } else { waterSystem.setTemperature(temperatures[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); + waterSystem.setPhaseType(0, PhaseType.byValue(0)); waterSystem.init(3); waterSystem.initPhysicalProperties(); @@ -1200,7 +1202,7 @@ public void run() { * (temperatures[j] - temperatures[j - 1]))); if * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { * props[k][i][j] = 25.0e-3; LWS=1; } - * + * * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { * props[k][i][j] = 80.0e-3; LWS=1; } } */ @@ -1235,7 +1237,7 @@ public void run() { * / (pressures[i - 1] - pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { * props[k][i][j] = 25.0e-3; LWS=1; } - * + * * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { * props[k][i][j] = 80.0e-3; LWS=1; } } */ diff --git a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java index ee015defa8..9fb65b8ef6 100644 --- a/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java +++ b/src/main/java/neqsim/thermodynamicOperations/propertyGenerator/OLGApropertyTableGeneratorWaterStudentsPH.java @@ -8,6 +8,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import Jama.Matrix; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermo.system.SystemSrkEos; @@ -175,8 +177,8 @@ public void calcPhaseEnvelope() { * calcBubP. * * - * @param enthalpies an array of {@link double} objects - * @return an array of {@link double} objects + * @param enthalpies an array of type double + * @return an array of type double */ public double[] calcBubP(double[] enthalpies) { double[] bubP = new double[enthalpies.length]; @@ -201,8 +203,8 @@ public double[] calcBubP(double[] enthalpies) { * calcDewP. * * - * @param enthalpies an array of {@link double} objects - * @return an array of {@link double} objects + * @param enthalpies an array of type double + * @return an array of type double */ public double[] calcDewP(double[] enthalpies) { double[] dewP = new double[enthalpies.length]; @@ -228,8 +230,8 @@ public double[] calcDewP(double[] enthalpies) { * calcBubT. * * - * @param pressures an array of {@link double} objects - * @return an array of {@link double} objects + * @param pressures an array of type double + * @return an array of type double */ public double[] calcBubT(double[] pressures) { double[] bubTemps = new double[pressures.length]; @@ -253,7 +255,7 @@ public double[] calcBubT(double[] pressures) { */ public void initCalc() { double stdTemp = 288.15; - double stdPres = 1.01325; + double stdPres = ThermodynamicConstantsInterface.referencePressure; // double GOR, GLR; double[] molfracs = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; double[] MW = new double[thermoSystem.getPhase(0).getNumberOfComponents()]; @@ -729,7 +731,7 @@ public void run() { } while (k < 17); // names[k] = "GAS DENSITY"; // units[k] = "KG/M3"; } else { - oilSystem.setPhaseType(0, 0); + oilSystem.setPhaseType(0, PhaseType.byValue(0)); // oilSystem.setTemperature(enthalpies[j]); oilSystem.setPressure(pressures[i]); oilSystem.init(3); @@ -923,7 +925,7 @@ public void run() { } else { waterSystem.setTemperature(enthalpies[j]); waterSystem.setPressure(pressures[i]); - waterSystem.setPhaseType(0, 0); + waterSystem.setPhaseType(0, PhaseType.byValue(0)); waterSystem.init(3); waterSystem.initPhysicalProperties(); @@ -1185,7 +1187,7 @@ public void run() { * 3]) / (enthalpies[j - 1] - enthalpies[j - 3]) * (enthalpies[j] - enthalpies[j - * 1]))); if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < * 10.0e-3) { props[k][i][j] = 25.0e-3; LWS=1; } - * + * * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { * props[k][i][j] = 80.0e-3; LWS=1; } } */ @@ -1220,7 +1222,7 @@ public void run() { * / (pressures[i - 1] - pressures[i - 3]) * (pressures[i] - pressures[i - 1]))); if * (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] < 10.0e-3) { * props[k][i][j] = 25.0e-3; LWS=1; } - * + * * if (names[k].equals("LIQUID-WATER SURFACE TENSION") && props[k][i][j] > 120.0e-3) { * props[k][i][j] = 80.0e-3; LWS=1; } } */ diff --git a/src/main/java/neqsim/util/NamedInterface.java b/src/main/java/neqsim/util/NamedInterface.java index 8b9f26845a..be92b528c2 100644 --- a/src/main/java/neqsim/util/NamedInterface.java +++ b/src/main/java/neqsim/util/NamedInterface.java @@ -1,23 +1,29 @@ package neqsim.util; /** - *NamedInterface interface.
+ *+ * NamedInterface interface. + *
* * @author ASMF * @version $Id: $Id */ public interface NamedInterface { - /** - * Getter for property Name. - * - * @return a {@link java.lang.String} object - */ - public String getName(); + /** + *
+ * Getter for the field name
.
+ *
+ * Setter for the field name
.
+ *
+ * initH2DatabaseFromCSVfiles. + *
+ */ public static void initH2DatabaseFromCSVfiles() { h2IsInitalizing = true; neqsim.util.database.NeqSimContractDataBase.connectionString = diff --git a/src/main/java/neqsim/util/database/NeqSimDataBase.java b/src/main/java/neqsim/util/database/NeqSimDataBase.java index 47b8401a7e..635797436d 100644 --- a/src/main/java/neqsim/util/database/NeqSimDataBase.java +++ b/src/main/java/neqsim/util/database/NeqSimDataBase.java @@ -55,10 +55,6 @@ public class NeqSimDataBase * */ public NeqSimDataBase() { - // Fill tables from csv-files if not initialized and not currently being initialized. - if (dataBaseType == "H2fromCSV" && !h2IsInitialized && !h2IsInitalizing) { - initH2DatabaseFromCSVfiles(); - } setDataBaseType(dataBaseType); try { @@ -230,6 +226,7 @@ public ResultSet getResultSet(String sqlString) { } } + /** {@inheritDoc} */ @Override public void close() throws Exception { if (databaseConnection != null) { @@ -295,6 +292,12 @@ public static void setDataBaseType(String aDataBaseType) { public static void setDataBaseType(String aDataBaseType, String connectionString) { dataBaseType = aDataBaseType; + // Fill tables from csv-files if not initialized and not currently being + // initialized. + if (dataBaseType == "H2fromCSV" && !h2IsInitialized && !h2IsInitalizing) { + initH2DatabaseFromCSVfiles(); + } + if (connectionString != null) { NeqSimDataBase.connectionString = connectionString; } @@ -392,17 +395,15 @@ public static String[] getComponentNames() { } /** - *- * hasComponent. - *
+ * Verify if database has a component. * - * @param compName a {@link java.lang.String} object - * @return a boolean + * @param name Name of component to look for. + * @return True if component is found. */ - public static boolean hasComponent(String compName) { + public static boolean hasComponent(String name) { try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); java.sql.ResultSet dataSet = - database.getResultSet("select count(*) from comp WHERE NAME='" + compName + "'")) { + database.getResultSet("select count(*) from comp WHERE NAME='" + name + "'")) { dataSet.next(); int size = dataSet.getInt(1); if (size == 0) { @@ -416,8 +417,30 @@ public static boolean hasComponent(String compName) { } /** - * Drops and re-creates table from contents in csv file. - * + * Verify if database has a component. + * + * @param name Name of component to look for. + * @return True if component is found. + */ + public static boolean hasTempComponent(String name) { + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = + database.getResultSet("select count(*) from comptemp WHERE NAME='" + name + "'")) { + dataSet.next(); + int size = dataSet.getInt(1); + if (size == 0) { + return false; + } else { + return true; + } + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * Drops and re-creates table from contents in default csv file. + * * @param tableName Name of table to replace */ public static void updateTable(String tableName) { @@ -426,9 +449,9 @@ public static void updateTable(String tableName) { /** * Drops and re-creates table from contents in csv file. - * + * * @param tableName Name of table to replace - * @param path Path to csv file to + * @param path Path to csv file to get table data from */ public static void updateTable(String tableName, String path) { URL url = NeqSimDataBase.class.getClassLoader().getResource(path); @@ -445,6 +468,30 @@ public static void updateTable(String tableName, String path) { } } + /** + * Drops and re-creates table from contents in csv file. + * + * @param tableName Name of table to replace + * @param path Path to csv file to + */ + public static void replaceTable(String tableName, String path) { + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { + database.execute("DROP TABLE IF EXISTS " + tableName); + String sqlString = "CREATE TABLE " + tableName + " AS SELECT * FROM CSVREAD('" + path + "')"; + database.execute(sqlString); + } catch (Exception ex) { + updateTable(tableName); + logger.error("Failed updating table " + tableName, ex); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException("NeqSimDataBase", + "replaceTable", "path", "- Resource " + path + " not found")); + } + } + + /** + *+ * initH2DatabaseFromCSVfiles. + *
+ */ public static void initH2DatabaseFromCSVfiles() { h2IsInitalizing = true; neqsim.util.database.NeqSimDataBase.connectionString = @@ -480,9 +527,13 @@ public static void initH2DatabaseFromCSVfiles() { updateTable("UNIFACInterParamC_UMRMC"); updateTable("MBWR32param"); updateTable("COMPSALT"); - // TODO: missing tables: ionicData, reactiondatakenteisenberg, purecomponentvapourpressures, + updateTable("PIPEDATA"); + + // TODO: missing tables: ionicData, reactiondatakenteisenberg, + // purecomponentvapourpressures, // binarysystemviscosity, binaryliquiddiffusioncoefficientdata, - // purecomponentconductivitydata, purecomponentdensity, purecomponentsurfacetension2, + // purecomponentconductivitydata, purecomponentdensity, + // purecomponentsurfacetension2, // BinaryComponentSurfaceTension, purecomponentsurfacetension, // purecomponentviscosity,PureComponentVapourPressures // technicalrequirements, technicalrequirements_process, materialpipeproperties, diff --git a/src/main/java/neqsim/util/database/NeqSimProcessDesignDataBase.java b/src/main/java/neqsim/util/database/NeqSimProcessDesignDataBase.java index fbec4591ef..00da2647b2 100644 --- a/src/main/java/neqsim/util/database/NeqSimProcessDesignDataBase.java +++ b/src/main/java/neqsim/util/database/NeqSimProcessDesignDataBase.java @@ -13,8 +13,7 @@ * @author Even Solbraa * @version June 2023 */ -public class NeqSimProcessDesignDataBase extends NeqSimDataBase -{ +public class NeqSimProcessDesignDataBase extends NeqSimDataBase { private static final long serialVersionUID = 1000; static Logger logger = LogManager.getLogger(NeqSimProcessDesignDataBase.class); @@ -62,17 +61,16 @@ public NeqSimProcessDesignDataBase() { } } - - /** - * Drops and re-creates table from contents in csv file. - * - * @param tableName Name of table to replace - */ + /** {@inheritDoc} */ public static void updateTable(String tableName) { updateTable(tableName, "designdata/" + tableName + ".csv"); } - + /** + *+ * initH2DatabaseFromCSVfiles. + *
+ */ public static void initH2DatabaseFromCSVfiles() { h2IsInitalizing = true; neqsim.util.database.NeqSimProcessDesignDataBase.connectionString = diff --git a/src/main/java/neqsim/util/exception/InvalidInputException.java b/src/main/java/neqsim/util/exception/InvalidInputException.java index ed593c5ed9..9be4a15823 100644 --- a/src/main/java/neqsim/util/exception/InvalidInputException.java +++ b/src/main/java/neqsim/util/exception/InvalidInputException.java @@ -22,7 +22,9 @@ public InvalidInputException(String msg) { } /** - * Constructs anInvalidInputException
with a default message.
+ * Constructs an InvalidInputException
with a default message like:
+ *
+ * Input " + inputName + " was invalid.
*
* @param className Class that exception is raised from
* @param methodName Method that exception is raised from
@@ -33,7 +35,9 @@ public InvalidInputException(String className, String methodName, String inputNa
}
/**
- * Constructs an InvalidInputException
with the specified detail message.
+ * Constructs an InvalidInputException
with a message like:
+ *
+ * "Input " + inputName + " " + msg
*
* @param className Class that exception is raised from
* @param methodName Method that exception is raised from
diff --git a/src/main/java/neqsim/util/exception/InvalidOutputException.java b/src/main/java/neqsim/util/exception/InvalidOutputException.java
new file mode 100644
index 0000000000..2c6f231f13
--- /dev/null
+++ b/src/main/java/neqsim/util/exception/InvalidOutputException.java
@@ -0,0 +1,69 @@
+package neqsim.util.exception;
+
+/**
+ * + * InvalidOutputException class. + *
+ * + * @author Even Solbraa + * @version $Id: $Id + */ +public class InvalidOutputException extends neqsim.util.exception.ThermoException { + private static final long serialVersionUID = 1000; + + /** + * Constructs anInvalidOutputException
with the specified detail message.
+ *
+ * @param msg the detail message.
+ */
+ @Deprecated
+ public InvalidOutputException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs an InvalidOutputException
with a default message.
+ *
+ * @param className Class that exception is raised from
+ * @param methodName Method that exception is raised from
+ * @param outputName Name of invalid output
+ */
+ public InvalidOutputException(String className, String methodName, String outputName) {
+ super(className, methodName, "output " + outputName + " was invalid.");
+ }
+
+ /**
+ * Constructs an InvalidOutputException
with the specified detail message.
+ *
+ * @param className Class that exception is raised from
+ * @param methodName Method that exception is raised from
+ * @param outputName Name of invalid output
+ * @param msg error message detailing output problem
+ */
+ public InvalidOutputException(String className, String methodName, String outputName, String msg) {
+ super(className, methodName, "output " + outputName + " " + msg);
+ }
+
+ /**
+ * Constructs an InvalidOutputException
with a default message.
+ *
+ * @param obj Object that exception is raised from
+ * @param methodName Method that exception is raised from
+ * @param outputName Name of invalid output
+ */
+ public InvalidOutputException(Object obj, String methodName, String outputName) {
+ this(obj.getClass().getSimpleName(), methodName, outputName);
+ }
+
+ /**
+ * Constructs an InvalidOutputException
with a default message.
+ *
+ * @param obj Object that exception is raised from
+ * @param methodName Method that exception is raised from
+ * @param outputName Name of invalid output
+ * @param msg error message detailing output problem
+ */
+ public InvalidOutputException(Object obj, String methodName, String outputName, String msg) {
+ this(obj.getClass().getSimpleName(), methodName, outputName, msg);
+ }
+}
diff --git a/src/main/java/neqsim/util/exception/NotImplementedException.java b/src/main/java/neqsim/util/exception/NotImplementedException.java
new file mode 100644
index 0000000000..8b6856e9d0
--- /dev/null
+++ b/src/main/java/neqsim/util/exception/NotImplementedException.java
@@ -0,0 +1,32 @@
+package neqsim.util.exception;
+
+/**
+ * + * NotImplementedException class. + *
+ * + * @author Ã…smund VÃ¥ge Fannemel + */ +public class NotImplementedException extends neqsim.util.exception.ThermoException { + private static final long serialVersionUID = 1000; + + /** + * Constructs aNotImplementedException
with a standard error message.
+ *
+ * @param className Class that exception is raised from
+ * @param methodName Method that exception is raised from
+ */
+ public NotImplementedException(String className, String methodName) {
+ super(className, methodName, "Function not implemented");
+ }
+
+ /**
+ * Constructs a NotImplementedException
with a standard error message.
+ *
+ * @param obj object that exception is raised from
+ * @param methodName method that exception is raised from
+ */
+ public NotImplementedException(Object obj, String methodName) {
+ this(obj.getClass().getSimpleName(), methodName);
+ }
+}
diff --git a/src/main/java/neqsim/util/exception/ThermoException.java b/src/main/java/neqsim/util/exception/ThermoException.java
index c574e49b0d..11a59874fc 100644
--- a/src/main/java/neqsim/util/exception/ThermoException.java
+++ b/src/main/java/neqsim/util/exception/ThermoException.java
@@ -14,7 +14,7 @@
* @author Even Solbraa
* @version $Id: $Id
*/
-public class ThermoException extends java.lang.Exception {
+public abstract class ThermoException extends java.lang.Exception {
private static final long serialVersionUID = 1000;
/**
diff --git a/src/main/java/neqsim/util/exception/TooManyIterationsException.java b/src/main/java/neqsim/util/exception/TooManyIterationsException.java
index a7e7d41de4..1452843f8f 100644
--- a/src/main/java/neqsim/util/exception/TooManyIterationsException.java
+++ b/src/main/java/neqsim/util/exception/TooManyIterationsException.java
@@ -9,27 +9,27 @@
* @version $Id: $Id
*/
public class TooManyIterationsException extends neqsim.util.exception.ThermoException {
- private static final long serialVersionUID = 1000;
+ private static final long serialVersionUID = 1000;
- /**
- * Constructs a TooManyIterationsException
with a standard error message.
- *
- * @param className Class that exception is raised from
- * @param methodName Method that exception is raised from
- * @param maxIterations the maximum number of iterations
- */
- public TooManyIterationsException(String className, String methodName, long maxIterations) {
- super(className, methodName, "Exceeded maximum iterations " + maxIterations);
- }
+ /**
+ * Constructs a TooManyIterationsException
with a standard error message.
+ *
+ * @param className Class that exception is raised from
+ * @param methodName Method that exception is raised from
+ * @param maxIterations the maximum number of iterations
+ */
+ public TooManyIterationsException(String className, String methodName, long maxIterations) {
+ super(className, methodName, "Exceeded maximum iterations " + maxIterations);
+ }
- /**
- * Constructs a TooManyIterationsException
with a standard error message.
- *
- * @param obj object that exception is raised from
- * @param methodName method that exception is raised from
- * @param maxIterations the maximum number of iterations
- */
- public TooManyIterationsException(Object obj, String methodName, long maxIterations) {
- this(obj.getClass().getSimpleName(), methodName, maxIterations);
- }
+ /**
+ * Constructs a TooManyIterationsException
with a standard error message.
+ *
+ * @param obj object that exception is raised from
+ * @param methodName method that exception is raised from
+ * @param maxIterations the maximum number of iterations
+ */
+ public TooManyIterationsException(Object obj, String methodName, long maxIterations) {
+ this(obj.getClass().getSimpleName(), methodName, maxIterations);
+ }
}
diff --git a/src/main/java/neqsim/util/generator/PropertyGenerator.java b/src/main/java/neqsim/util/generator/PropertyGenerator.java
index e51f4fc183..e4ba9a856b 100644
--- a/src/main/java/neqsim/util/generator/PropertyGenerator.java
+++ b/src/main/java/neqsim/util/generator/PropertyGenerator.java
@@ -23,8 +23,8 @@ public class PropertyGenerator {
*
*
* @param fluid a {@link neqsim.thermo.system.SystemInterface} object
- * @param temperatures an array of {@link double} objects
- * @param pressures an array of {@link double} objects
+ * @param temperatures an array of type double
+ * @param pressures an array of type double
*/
public PropertyGenerator(SystemInterface fluid, double[] temperatures, double[] pressures) {
this.fluid = fluid;
@@ -129,7 +129,7 @@ public HashMap- * Constructor for BaseUnit. - *
- */ - public BaseUnit() {} - - /** - *- * Constructor for BaseUnit. - *
- * - * @param value a double - * @param name a {@link java.lang.String} object - */ - public BaseUnit(double value, String name) { - this.invalue = value; - this.inunit = name; - } - - /** {@inheritDoc} */ - @Override - public double getSIvalue() { - return SIvalue; - } - - /** {@inheritDoc} */ - @Override - public double getValue(String fromunit) { - return 0.0; - } - - /** {@inheritDoc} */ - @Override - public double getValue(double val, String fromunit, String tounit) { - return 0.0; - } +public abstract class BaseUnit implements Unit, neqsim.thermo.ThermodynamicConstantsInterface { + private static final long serialVersionUID = 1000; + + /** Process value in SI units */ + protected double SIvalue = 0.0; + + /** Process value in given unit */ + protected double invalue = 0.0; + /** Unit of process value */ + protected String inunit = null; + + /** Conversion factor */ + protected double factor = 1.0; + + /** + *+ * Constructor for BaseUnit. + *
+ * + * @param value a double + * @param name a {@link java.lang.String} object + */ + public BaseUnit(double value, String name) { + this.invalue = value; + this.inunit = name; + } + + /** {@inheritDoc} */ + @Override + public double getSIvalue() { + return SIvalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(double val, String fromunit, String tounit) { + throw new UnsupportedOperationException("Unimplemented method 'getValue'"); + } + + /** {@inheritDoc} */ + @Override + public double getValue(String fromunit) { + throw new UnsupportedOperationException("Unimplemented method 'getValue'"); + } } diff --git a/src/main/java/neqsim/util/unit/LengthUnit.java b/src/main/java/neqsim/util/unit/LengthUnit.java index 8eb5b2538c..867650ab9b 100644 --- a/src/main/java/neqsim/util/unit/LengthUnit.java +++ b/src/main/java/neqsim/util/unit/LengthUnit.java @@ -21,6 +21,11 @@ public class LengthUnit extends neqsim.util.unit.BaseUnit { ** Constructor for LengthUnit. *
+ * + * @param value Numeric value + * @param name Name of unit */ - public LengthUnit() {} + public LengthUnit(double value, String name) { + super(value, name); + } } diff --git a/src/main/java/neqsim/util/unit/NeqSimUnitSet.java b/src/main/java/neqsim/util/unit/NeqSimUnitSet.java index dd0531045a..aa050d6e09 100644 --- a/src/main/java/neqsim/util/unit/NeqSimUnitSet.java +++ b/src/main/java/neqsim/util/unit/NeqSimUnitSet.java @@ -9,96 +9,96 @@ * @version $Id: $Id */ public class NeqSimUnitSet { - /** - *
- * Getter for the field componentConcentrationUnit
.
- *
- * Setter for the field componentConcentrationUnit
.
- *
- * Getter for the field flowRateUnit
.
- *
- * Setter for the field flowRateUnit
.
- *
- * Getter for the field pressureUnit
.
- *
+ * Getter for the field componentConcentrationUnit
.
+ *
- * Setter for the field pressureUnit
.
- *
+ * Getter for the field flowRateUnit
.
+ *
- * Getter for the field temperatureUnit
.
- *
+ * Getter for the field pressureUnit
.
+ *
- * Setter for the field temperatureUnit
.
- *
+ * Getter for the field temperatureUnit
.
+ *
+ * Setter for the field componentConcentrationUnit
.
+ *
+ * Setter for the field flowRateUnit
.
+ *
+ * Setter for the field pressureUnit
.
+ *
+ * Setter for the field temperatureUnit
.
+ *
* getConversionFactor. @@ -69,14 +47,26 @@ public double getConversionFactor(String name) { conversionFactor = 1.0; break; case "psi": - conversionFactor = 0.06894757; + conversionFactor = 0.0689475729317831; + break; + case "psia": + conversionFactor = 0.0689475729317831; + break; + case "psig": + conversionFactor = 0.0689475729317831; break; case "Pa": conversionFactor = 1.0e-5; break; + case "kPa": + conversionFactor = 1.0e-2; + break; case "MPa": conversionFactor = 10.0; break; + case "atm": + conversionFactor = 1.0; + break; default: throw new RuntimeException( new InvalidInputException(this, "getConversionFactor", name, "unit not supproted")); @@ -84,4 +74,34 @@ public double getConversionFactor(String name) { return conversionFactor; } + + /** {@inheritDoc} */ + @Override + public double getValue(double val, String fromunit, String tounit) { + invalue = val; + return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + if (tounit.equals("barg")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + - ThermodynamicConstantsInterface.referencePressure; + } else if (tounit.equals("psig")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue * 14.503773773 + - 14.7; + } else if (inunit.equals("barg")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + + ThermodynamicConstantsInterface.referencePressure; + } else if (tounit.equals("atm")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + / ThermodynamicConstantsInterface.referencePressure; + } else if (inunit.equals("atm")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + * ThermodynamicConstantsInterface.referencePressure; + } else { + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } + } } diff --git a/src/main/java/neqsim/util/unit/RateUnit.java b/src/main/java/neqsim/util/unit/RateUnit.java index 15d47b6e12..88da94593c 100644 --- a/src/main/java/neqsim/util/unit/RateUnit.java +++ b/src/main/java/neqsim/util/unit/RateUnit.java @@ -45,18 +45,6 @@ public RateUnit(double value, String name, double molarmass, double stddens, dou this.boilp = boilp; } - /** {@inheritDoc} */ - @Override - public double getSIvalue() { - return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; - } - - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } - /** *
* getConversionFactor. @@ -67,9 +55,11 @@ public double getValue(String tounit) { */ public double getConversionFactor(String name) { double mol_m3 = 0.0; - double mol_Sm3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); + double mol_Sm3 = ThermodynamicConstantsInterface.atm + / (ThermodynamicConstantsInterface.R * standardStateTemperature); if (boilp < 25) { - mol_m3 = 101325.0 / (ThermodynamicConstantsInterface.R * standardStateTemperature); + mol_m3 = ThermodynamicConstantsInterface.atm + / (ThermodynamicConstantsInterface.R * standardStateTemperature); } else { mol_m3 = 1.0 / (molarmass) * stddens * 1000; } @@ -113,6 +103,8 @@ public double getConversionFactor(String name) { factor = 1.0 / molarmass / 3600.0 * stddens; } else if (name.equals("idSm3/day")) { factor = 1.0 / molarmass / (3600.0 * 24.0) * stddens; + } else if (name.equals("gallons/min")) { + factor = 1.0 / molarmass / 60.0 * stddens / 10.0 * 3.78541178; } else { throw new RuntimeException( new InvalidInputException(this, "getConversionFactor", "unit", "not supported")); @@ -120,4 +112,16 @@ public double getConversionFactor(String name) { return factor; } + + /** {@inheritDoc} */ + @Override + public double getSIvalue() { + return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } } diff --git a/src/main/java/neqsim/util/unit/TemperatureUnit.java b/src/main/java/neqsim/util/unit/TemperatureUnit.java index 71e36972f8..14b23d6253 100644 --- a/src/main/java/neqsim/util/unit/TemperatureUnit.java +++ b/src/main/java/neqsim/util/unit/TemperatureUnit.java @@ -9,54 +9,96 @@ * @version $Id: $Id */ public class TemperatureUnit extends neqsim.util.unit.BaseUnit { - private static final long serialVersionUID = 1000; - - /** - *
- * Constructor for TemperatureUnit. - *
- * - * @param value a double - * @param name a {@link java.lang.String} object - */ - public TemperatureUnit(double value, String name) { - super(value, name); + private static final long serialVersionUID = 1000; + + /** + *+ * Constructor for TemperatureUnit. + *
+ * + * @param value a double + * @param name a {@link java.lang.String} object + */ + public TemperatureUnit(double value, String name) { + super(value, name); + } + + /** + * Get conversion factor for temperature unit conversions to Kelvin. Note: This is primarily for + * understanding scale, not for direct conversions including offsets. + * + * @param name a {@link java.lang.String} object representing the temperature unit + * @return a double representing the conversion factor relative to Kelvin + */ + public double getConversionFactor(String name) { + switch (name) { + case "K": + return 1.0; + case "C": + return 1.0; // Same scale as Kelvin + case "F": + return 5.0 / 9.0; // Scale factor for Fahrenheit to Kelvin + case "R": + return 5.0 / 9.0; // Scale factor for Rankine to Kelvin + default: + throw new IllegalArgumentException("Unknown unit: " + name); } + } - /** {@inheritDoc} */ - @Override - public double getValue(double val, String fromunit, String tounit) { - invalue = val; - return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; + /** {@inheritDoc} */ + @Override + public double getValue(double value, String fromUnit, String toUnit) { + if (fromUnit.equals(toUnit)) { + return value; } - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - if (tounit.equals("C")) { - return getConversionFactor(inunit) / getConversionFactor("K") * invalue - 273.15; - } - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + // Convert input to Kelvin first + double tempInKelvin = value; + if (fromUnit.equals("C")) { + tempInKelvin += 273.15; + } else if (fromUnit.equals("F")) { + tempInKelvin = (value - 32) * 5.0 / 9.0 + 273.15; + } else if (fromUnit.equals("R")) { + tempInKelvin = value * 5.0 / 9.0; } - /** - *- * getConversionFactor. - *
- * - * @param name a {@link java.lang.String} object - * @return a double - */ - public double getConversionFactor(String name) { - double conversionFactor = 1.0; - switch (name) { - case "K": - conversionFactor = 1.0; - break; - case "R": - conversionFactor = 5.0 / 9.0; - break; - } - return conversionFactor; + // Convert from Kelvin to target unit + if (toUnit.equals("K")) { + return tempInKelvin; + } else if (toUnit.equals("C")) { + return tempInKelvin - 273.15; + } else if (toUnit.equals("F")) { + return (tempInKelvin - 273.15) * 9.0 / 5.0 + 32; + } else if (toUnit.equals("R")) { + return tempInKelvin * 9.0 / 5.0; + } + + throw new IllegalArgumentException("Unsupported unit: " + toUnit); + } + + /** + * {@inheritDoc} + * + * Convert a given temperature value from Kelvin to a specified unit. + */ + @Override + public double getValue(String toUnit) { + switch (toUnit) { + case "K": + // Convert from Kelvin to Kelvin + return invalue; + case "C": + // Convert from Kelvin to Celsius + return invalue - 273.15; + case "F": + // Convert from Kelvin to Fahrenheit + return invalue * 9.0 / 5.0 - 459.67; + case "R": + // Convert from Kelvin to Rankine + return invalue * 9.0 / 5.0; + default: + // Handle unsupported units + throw new IllegalArgumentException("Unsupported conversion unit: " + toUnit); } + } } diff --git a/src/main/java/neqsim/util/unit/TimeUnit.java b/src/main/java/neqsim/util/unit/TimeUnit.java index f02de44c77..bb5aff3a7c 100644 --- a/src/main/java/neqsim/util/unit/TimeUnit.java +++ b/src/main/java/neqsim/util/unit/TimeUnit.java @@ -21,6 +21,11 @@ public class TimeUnit extends neqsim.util.unit.BaseUnit { ** Constructor for TimeUnit. *
+ * + * @param value Numeric value + * @param name Name of unit */ - public TimeUnit() {} + public TimeUnit(double value, String name) { + super(value, name); + } } diff --git a/src/main/java/neqsim/util/unit/Unit.java b/src/main/java/neqsim/util/unit/Unit.java index 77306bd9f9..cace1cae71 100644 --- a/src/main/java/neqsim/util/unit/Unit.java +++ b/src/main/java/neqsim/util/unit/Unit.java @@ -26,23 +26,23 @@ public interface Unit { /** *- * getValue. + * Convert value from a specified unit to a specified unit. *
* + * @param val a double + * @param fromunit a {@link java.lang.String} object * @param tounit a {@link java.lang.String} object * @return a double */ - double getValue(String tounit); + double getValue(double val, String fromunit, String tounit); /** *- * getValue. + * Get process value in specified unit. *
* - * @param val a double - * @param fromunit a {@link java.lang.String} object - * @param tounit a {@link java.lang.String} object - * @return a double + * @param tounit Unit to get process value in. + * @return Value converted to the specified unit. */ - double getValue(double val, String fromunit, String tounit); + double getValue(String tounit); } diff --git a/src/main/java/neqsim/util/unit/Units.java b/src/main/java/neqsim/util/unit/Units.java new file mode 100644 index 0000000000..9070de11bf --- /dev/null +++ b/src/main/java/neqsim/util/unit/Units.java @@ -0,0 +1,239 @@ +package neqsim.util.unit; + +import java.util.HashMap; + +/** + *+ * Units class. + *
+ * + * @author even + * @version $Id: $Id + */ +public class Units { + /** + * Unit class nested within Units. + */ + public class UnitDescription { + public String symbol; + public String symbolName; + + public UnitDescription(String symbol, String symbolName) { + this.symbol = symbol; + this.symbolName = symbolName; + } + } + + /** ConstantactiveUnits
*/
+ public static HashMapdefaultUnits
*/
+ public static HashMapmetricUnits
*/
+ public static HashMap+ * Constructor for Units. + *
+ */ + public Units() { + if (activeUnits.size() == 0) { + activeUnits.put("temperature", new UnitDescription("C", "Celsius")); + activeUnits.put("pressure", new UnitDescription("bara", "bar absolute")); + activeUnits.put("enthalpy", new UnitDescription("J/kg", "Joule per kg")); + activeUnits.put("entropy", new UnitDescription("J/kgK", "Joule per kg and Kelvin")); + activeUnits.put("density", new UnitDescription("kg/m3", "kg per cubic meter")); + activeUnits.put("viscosity", new UnitDescription("kg/msec", "kg per meter and second")); + activeUnits.put("surface tension", new UnitDescription("N/m", "newton per meter")); + activeUnits.put("thermal conductivity", + new UnitDescription("W/mK", "watts per meter and Kelvin")); + activeUnits.put("JT coefficient", new UnitDescription("C/bar", "Celsius per bar")); + activeUnits.put("speed of sound", new UnitDescription("m/sec", "meter per second")); + activeUnits.put("Heat Capacity (Cv)", + new UnitDescription("kJ/kgK", "kilo joule per kg and Kelvin")); + activeUnits.put("Heat Capacity (Cp)", + new UnitDescription("kJ/kgK", "kilo joule per kg and Kelvin")); + activeUnits.put("Molar Mass", new UnitDescription("kg/mol", "kilo gram per kilo mole")); + activeUnits.put("molar volume", new UnitDescription("m3/mol", "cubic metre per mole")); + activeUnits.put("mass flow", new UnitDescription("kg/hr", "kg per hour")); + activeUnits.put("molar flow", new UnitDescription("mole/hr", "mole per hour")); + activeUnits.put("volume flow", new UnitDescription("m3/hr", "cubic metre per hour")); + activeUnits.put("standard volume flow", + new UnitDescription("Sm3/hr", "standard cubic metre per hour")); + + metricUnits.putAll(activeUnits); + metricUnits.put("Molar Mass", new UnitDescription("gr/mol", "gr/mol")); + metricUnits.put("molar volume", new UnitDescription("cm3/mol", "cm3/mol")); + metricUnits.put("viscosity", new UnitDescription("Pas", "Pascal per second")); + + siUnits.putAll(activeUnits); // Makes a copy of activeUnits + siUnits.put("temperature", new UnitDescription("K", "Kelvin")); + siUnits.put("pressure", new UnitDescription("Pa", "Pascal")); + siUnits.put("enthalpy", new UnitDescription("J/mol", "Joule per mole")); + siUnits.put("density", new UnitDescription("kg/m3", "kg per cubic meter")); + siUnits.put("JT coefficient", new UnitDescription("K/Pa", "Kelvin per Pascal")); + siUnits.put("thermal conductivity", + new UnitDescription("J/sec-m-K", "Joule per second meter and Kelvin")); + + fieldUnits.putAll(activeUnits); // Makes a copy of activeUnits + fieldUnits.put("temperature", new UnitDescription("F", "Fahrenheit")); + fieldUnits.put("pressure", new UnitDescription("psia", "pounds per square inch absolute")); + fieldUnits.put("enthalpy", new UnitDescription("Btu/lbmol", "Btu per lbmol")); + fieldUnits.put("density", new UnitDescription("lb/ft3", "pound per cubic foot")); + fieldUnits.put("Molar Mass", new UnitDescription("lbm/lbmol", "pound-mass per pound-mole")); + fieldUnits.put("Heat Capacity (Cv)", new UnitDescription("btu/lbmole-F", "Btu/lbmole-F")); + fieldUnits.put("Heat Capacity (Cp)", new UnitDescription("btu/lbmole-F", "Btu/lbmole-F")); + fieldUnits.put("thermal conductivity", new UnitDescription("Btu/hr-ft-F", "Btu/hr-ft-F")); + fieldUnits.put("viscosity", new UnitDescription("cP", "centypoise")); + fieldUnits.put("entropy", new UnitDescription("btu/lb-F", "btu/lb-F")); + fieldUnits.put("JT coefficient", + new UnitDescription("F/psi", "Farenheit per pounds per square inch")); + fieldUnits.put("speed of sound", new UnitDescription("ft/sec", "ft/sec")); + fieldUnits.put("molar volume", + new UnitDescription("ft3/lbmole", "cubic foot per pound-mass-mole")); + fieldUnits.put("mass flow", new UnitDescription("lb/hr", "lb/hr")); + fieldUnits.put("molar flow", new UnitDescription("lbmole/hr", "lbmole/hr")); + fieldUnits.put("volume flow", new UnitDescription("barrel/day", "barrel/day")); + + defaultUnits.putAll(activeUnits); // Makes a copy of activeUnits + } + } + + /** + *+ * activateSIUnits. + *
+ */ + public static void activateSIUnits() { + if (activeUnits.size() == 0) { + new Units(); + } + activeUnits = new HashMap<>(siUnits); + } + + /** + *+ * activateFieldUnits. + *
+ */ + public static void activateFieldUnits() { + if (activeUnits.size() == 0) { + new Units(); + } + activeUnits = new HashMap<>(fieldUnits); + } + + /** + *+ * activateMetricUnits. + *
+ */ + public static void activateMetricUnits() { + if (activeUnits.size() == 0) { + new Units(); + } + activeUnits = new HashMap<>(metricUnits); + } + + /** + *+ * activateDefaultUnits. + *
+ */ + public static void activateDefaultUnits() { + if (activeUnits.size() == 0) { + new Units(); + } + activeUnits = new HashMap<>(defaultUnits); // Reassign with a copy + } + + /** + *+ * getSymbol. + *
+ * + * @param name a {@link java.lang.String} object + * @return a {@link java.lang.String} object + */ + public static String getSymbol(String name) { + if (activeUnits.size() == 0) { + new Units(); + } + return activeUnits.get(name).symbol; + } + + /** + *+ * getSymbolName. + *
+ * + * @param name a {@link java.lang.String} object + * @return a {@link java.lang.String} object + */ + public static String getSymbolName(String name) { + if (activeUnits.size() == 0) { + new Units(); + } + return activeUnits.get(name).symbolName; + } + + /** + *+ * setUnit. + *
+ * + * @param name a {@link java.lang.String} object + * @param symbol a {@link java.lang.String} object + * @param symbolName a {@link java.lang.String} object + */ + public static void setUnit(String name, String symbol, String symbolName) { + if (activeUnits.size() == 0) { + new Units(); + } + UnitDescription unit = activeUnits.get(name); + if (unit != null) { + unit.symbol = symbol; + unit.symbolName = symbolName; + } + } + + /** + *
+ * Getter for the field temperatureUnits
.
+ *
+ * Getter for the field pressureUnits
.
+ *
+ * Getter for the field molarVolumeUnits
.
+ *
- * set. + * doubleValue. *
* - * @param val a double + * @return a double */ - public void set(double val) { - doubleValue = val; + public double doubleValue() { + return doubleValue; } /** *- * doubleValue. + * set. *
* - * @return a double + * @param val a double */ - public double doubleValue() { - return doubleValue; + public void set(double val) { + doubleValue = val; } } diff --git a/src/main/resources/META-INF/native-image/predefined-classes-config.json b/src/main/resources/META-INF/native-image/predefined-classes-config.json new file mode 100644 index 0000000000..e88b8fac52 --- /dev/null +++ b/src/main/resources/META-INF/native-image/predefined-classes-config.json @@ -0,0 +1,8 @@ +[ + { + "type":"agent-extracted", + "classes":[ + ] + } +] + diff --git a/src/main/resources/META-INF/native-image/proxy-config.json b/src/main/resources/META-INF/native-image/proxy-config.json new file mode 100644 index 0000000000..11f8e7ea70 --- /dev/null +++ b/src/main/resources/META-INF/native-image/proxy-config.json @@ -0,0 +1,2 @@ +[ +] diff --git a/src/main/resources/META-INF/native-image/reflect-config.json b/src/main/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 0000000000..6e696f4d97 --- /dev/null +++ b/src/main/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,1128 @@ +[ +{ + "name":"[B" +}, +{ + "name":"[C" +}, +{ + "name":"[D" +}, +{ + "name":"[F" +}, +{ + "name":"[I" +}, +{ + "name":"[J" +}, +{ + "name":"[Ljava.lang.String;" +}, +{ + "name":"[Ljavax.management.openmbean.CompositeData;" +}, +{ + "name":"[S" +}, +{ + "name":"[Z" +}, +{ + "name":"com.fasterxml.jackson.databind.ObjectMapper" +}, +{ + "name":"com.ibm.icu.text.Collator" +}, +{ + "name":"com.sun.management.GarbageCollectorMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.GcInfo", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.HotSpotDiagnosticMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.OperatingSystemMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.ThreadMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.VMOption", + "queryAllPublicMethods":true +}, +{ + "name":"com.sun.management.internal.GarbageCollectorExtImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"com.sun.management.internal.HotSpotDiagnostic", + "queryAllPublicConstructors":true +}, +{ + "name":"com.sun.management.internal.HotSpotThreadImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"com.sun.management.internal.OperatingSystemImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"jakarta.servlet.Servlet" +}, +{ + "name":"java.lang.Boolean", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Byte", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Character", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Deprecated", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.Double", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Float", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Integer", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Long", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Short", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.StackTraceElement", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.String", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.Thread", + "fields":[{"name":"threadLocalRandomProbe"}] +}, +{ + "name":"java.lang.Void", + "fields":[{"name":"TYPE"}] +}, +{ + "name":"java.lang.management.BufferPoolMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.ClassLoadingMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.CompilationMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.LockInfo", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.ManagementPermission", + "methods":[{"name":"+ * checkSaturationTemperatureToPhaseEnvelope. + *
+ * + * @throws Exception + */ + @Test + @DisplayName("calculate phase envelope using UMR") + public void checkSaturationTemperatureToPhaseEnvelope() throws Exception { + SystemUMRPRUMCEos testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem.addComponent("N2", 0.00675317857); + testSystem.addComponent("CO2", .02833662296); + testSystem.addComponent("methane", 0.8363194562); + testSystem.addComponent("ethane", 0.06934307324); + testSystem.addComponent("propane", 0.03645246567); + testSystem.addComponent("i-butane", 0.0052133558); + testSystem.addComponent("n-butane", 0.01013260919); + testSystem.addComponent("i-pentane", 0.00227310164); + testSystem.addComponent("n-pentane", 0.00224658464); + testSystem.addComponent("2-m-C5", 0.00049491); + testSystem.addComponent("3-m-C5", 0.00025783); + testSystem.addComponent("n-hexane", 0.00065099); + testSystem.addComponent("c-hexane", .00061676); + testSystem.addComponent("n-heptane", 0.00038552); + testSystem.addComponent("benzene", 0.00016852); + testSystem.addComponent("n-octane", 0.00007629); + testSystem.addComponent("c-C7", 0.0002401); + testSystem.addComponent("toluene", 0.0000993); + testSystem.addComponent("n-nonane", 0.00001943); + testSystem.addComponent("c-C8", 0.00001848); + testSystem.addComponent("m-Xylene", 0.00002216); + testSystem.addComponent("nC10", 0.00000905); + testSystem.addComponent("nC11", 0.000000001); + testSystem.addComponent("nC12", 0.000000001); + + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.calcPTphaseEnvelope(); + } catch (Exception ex) { + assertTrue(false); + throw new Exception(ex); } + assertEquals((testOps.get("cricondentherm")[0] - 273.15), 23.469, 0.02); + assertEquals(testOps.get("cricondentherm")[1], 46.9326702068279, 0.02); + + testSystem.setPressure(testOps.get("cricondentherm")[1], "bara"); + SaturationTemperature satTempSim = new SaturationTemperature(testSystem); + satTempSim.run(); + assertEquals(satTempSim.getThermoSystem().getTemperature() - 273.15, 23.469396812206867, 0.001); + } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SeparatorTestTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SeparatorTestTest.java index de15436844..cb5b7c580e 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/SeparatorTestTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/SeparatorTestTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -39,10 +40,11 @@ void testRunCalc() { SeparatorTest sepSim = new SeparatorTest(tempSystem); double[] temps = {313.15, 313.15, 313.15, 313.15, 313.15, 313.15, 313.15}; - double[] pres = {500, 400, 200, 100, 50.0, 5.0, 1.01325}; + double[] pres = + {500, 400, 200, 100, 50.0, 5.0, ThermodynamicConstantsInterface.referencePressure}; sepSim.setSeparatorConditions(temps, pres); sepSim.runCalc(); - assertEquals(1.1245991497229437, sepSim.getBofactor()[4], 0.0001); + assertEquals(1.1224612120760051, sepSim.getBofactor()[4], 0.0001); } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SlimTubeSimTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SlimTubeSimTest.java index c56a0a62b0..37694696ab 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/SlimTubeSimTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/SlimTubeSimTest.java @@ -30,7 +30,7 @@ void testRun() { oilSystem.addTBPfraction("C17", 0.17, 234.0 / 1000.0, 0.84); oilSystem.addTBPfraction("C18", 0.13, 251.0 / 1000.0, 0.844); oilSystem.addTBPfraction("C19", 0.13, 270.0 / 1000.0, 0.854); - oilSystem.addPlusFraction("C20", 10.62, 381.0 / 1000.0, 0.88); + oilSystem.addPlusFraction("C20", 20.62, 381.0 / 1000.0, 0.88); oilSystem.getCharacterization().characterisePlusFraction(); oilSystem.setMixingRule(2); diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ViscositySimTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ViscositySimTest.java index 30be13d56e..9c36e0f946 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ViscositySimTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ViscositySimTest.java @@ -24,6 +24,6 @@ void testRunCalc() { sepSim.setExperimentalData(expData); // sepSim.runTuning(); sepSim.runCalc(); - assertEquals(4.420762033045493E-4, sepSim.getOilViscosity()[0], 0.000001); + assertEquals(4.443002015621749E-4, sepSim.getOilViscosity()[0], 0.000001); } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/WaxFractionSimTest.java b/src/test/java/neqsim/PVTsimulation/simulation/WaxFractionSimTest.java index c50ba1bcc9..84cad879d2 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/WaxFractionSimTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/WaxFractionSimTest.java @@ -26,7 +26,7 @@ void testRunCalc() { double[] pres = {5, 5, 5.0, 5.0, 5.0, 5.0, 5.0}; sepSim.setTemperaturesAndPressures(temps, pres); sepSim.runCalc(); - assertEquals(0.17060460831376567, sepSim.getThermoSystem().getPhaseFraction("wax", "wt"), + assertEquals(0.2683853533110433, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"), 0.001); } @@ -51,6 +51,7 @@ void testRunCalc2() { sepSim.setTemperaturesAndPressures(temps, pres); sepSim.runCalc(); NeqSimDataBase.setCreateTemporaryTables(false); - assertEquals(0.168406528706, sepSim.getThermoSystem().getPhaseFraction("wax", "wt"), 0.001); + assertEquals(0.24895564649970403, sepSim.getThermoSystem().getPhaseFraction("wax", "mass"), + 0.001); } } diff --git a/src/test/java/neqsim/chemicalReactions/ChemicalReactionOperationsTest.java b/src/test/java/neqsim/chemicalReactions/ChemicalReactionOperationsTest.java new file mode 100644 index 0000000000..607c49bfb8 --- /dev/null +++ b/src/test/java/neqsim/chemicalReactions/ChemicalReactionOperationsTest.java @@ -0,0 +1,25 @@ +package neqsim.chemicalReactions; + +import org.junit.jupiter.api.BeforeAll; +import neqsim.thermo.system.SystemSrkEos; + +public class ChemicalReactionOperationsTest { + static SystemSrkEos testSystem; + + @BeforeAll + public void setUp() { + testSystem = new SystemSrkEos(303.3, 2.8); + + testSystem.addComponent("methane", 5.0, "kg/sec"); + // testSystem.addComponent("nitrogen", 100.0, "kg/sec"); + testSystem.addComponent("oxygen", 40.0, "kg/sec"); + testSystem.chemicalReactionInit(); + + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + testSystem.init(0); + testSystem.setMaxNumberOfPhases(1); + testSystem.setNumberOfPhases(1); + testSystem.getChemicalReactionOperations().solveChemEq(0, 0); + } +} diff --git a/src/test/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/StratifiedFlowNodeTest.java b/src/test/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/StratifiedFlowNodeTest.java index 3aa7fc878c..13867a9b0c 100644 --- a/src/test/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/StratifiedFlowNodeTest.java +++ b/src/test/java/neqsim/fluidMechanics/flowNode/twoPhaseNode/twoPhasePipeFlowNode/StratifiedFlowNodeTest.java @@ -1,5 +1,6 @@ package neqsim.fluidMechanics.flowNode.twoPhaseNode.twoPhasePipeFlowNode; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.fluidMechanics.geometryDefinitions.pipe.PipeData; import neqsim.thermo.phase.PhaseType; @@ -127,15 +128,10 @@ void testInit2() { // "flux methane " + test3.getFluidBoundary().getInterphaseMolarFlux(0) + " [mol/m2*sec]"); // System.out.println( // "flux nC10 " + test3.getFluidBoundary().getInterphaseMolarFlux(1) + " [mol/m2*sec]"); - - } - - @Test void testInit3() { - SystemInterface[] gasPhases = new SystemInterface[10]; SystemInterface[] oilPhases = new SystemInterface[10]; StratifiedFlowNode[] nodes = new StratifiedFlowNode[10]; @@ -165,7 +161,6 @@ void testInit3() { } for (int time = 0; time < 100; time++) { - for (int i = 0; i < 9; i++) { fluids[i] = new SystemSrkEos(278.3, 100.01325); fluids[i].addFluid(gasPhases[i], 0); @@ -212,7 +207,6 @@ void testInit3() { } for (int time = 0; time < 20; time++) { - for (int i = 0; i < 9; i++) { fluids[i] = new SystemSrkEos(278.3, 100.01325); fluids[i].addFluid(gasPhases[i], 0); @@ -256,7 +250,12 @@ void testInit3() { // + " liquid " // + nodes[0].getBulkSystem().getPhase(1).getComponent(1).getNumberOfMolesInPhase()); } - } + @Test + @Disabled + void testDisplay() { + StratifiedFlowNode node = new StratifiedFlowNode(); + node.display(); + } } diff --git a/src/test/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGshipTest.java b/src/test/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGshipTest.java new file mode 100644 index 0000000000..1287735344 --- /dev/null +++ b/src/test/java/neqsim/fluidMechanics/flowSystem/twoPhaseFlowSystem/shipSystem/LNGshipTest.java @@ -0,0 +1,61 @@ +package neqsim.fluidMechanics.flowSystem.twoPhaseFlowSystem.shipSystem; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; + +class LNGshipTest { + LNGship testShip; + SystemInterface testSystem; + + @BeforeEach + void setUp() { + testSystem = new neqsim.thermo.system.SystemSrkEos(100, 1.0); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("nitrogen", 0.1); + testSystem.init(0); + + testShip = new LNGship(testSystem, 1_000_000, 0.01); + } + + @Test + void createSystem() { + assertEquals(0.7, testShip.getLiquidDensity()); + assertEquals(0.0, testShip.dailyBoilOffVolume); + assertEquals(0.0, testShip.initialNumberOffMoles); + testShip.createSystem(); + assertEquals(474.3293447569919, testShip.getLiquidDensity()); + assertEquals(10_000.0, testShip.dailyBoilOffVolume); + assertEquals(2.7513223265419292E10, testShip.initialNumberOffMoles); + } + + @Test + public void testSolveSteadyState() { + assertEquals(-173.15, testShip.getThermoSystem().getTemperature("C"), 1e-2); + testShip.createSystem(); + testShip.solveSteadyState(1, null); + assertEquals(-176.43, testShip.getThermoSystem().getTemperature("C"), 1e-2); + assertEquals(testSystem.getPhase("oil").getComponent("nitrogen").getx(), + testShip.getThermoSystem().getPhase("oil").getComponent("nitrogen").getx(), 1e-4); + assertEquals(testSystem.getPhase("oil").getComponent("methane").getx(), + testShip.getThermoSystem().getPhase("oil").getComponent("methane").getx(), 1e-4); + } + + @Test + void solveTransient() { + assertNull(testShip.volume); + assertEquals(0.0, testShip.endVolume); + assertEquals(1_000_000, testShip.totalTankVolume); // Initial cargo volume + + testShip.createSystem(); + testShip.solveSteadyState(0, null); + testShip.solveTransient(0, null); + + assertEquals(testShip.numberOffTimeSteps, testShip.tankTemperature.length); // Check that the + // results have + // correct length + assertEquals(600_000.0, testShip.endVolume); + } +} diff --git a/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/FrictionTheoryViscosityMethodTest.java b/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/FrictionTheoryViscosityMethodTest.java index 6c81b6d35c..07bf52556f 100644 --- a/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/FrictionTheoryViscosityMethodTest.java +++ b/src/test/java/neqsim/physicalProperties/physicalPropertyMethods/commonPhasePhysicalProperties/viscosity/FrictionTheoryViscosityMethodTest.java @@ -5,25 +5,25 @@ import org.junit.jupiter.api.Test; import neqsim.thermodynamicOperations.ThermodynamicOperations; -public class FrictionTheoryViscosityMethodTest extends neqsim.NeqSimTest{ - static neqsim.thermo.system.SystemInterface testSystem = null; - - @BeforeAll - public static void setUp() { - testSystem = new neqsim.thermo.system.SystemSrkEos(273.15 + 25.0, 42.0); - testSystem.addComponent("methane", 0.5); - testSystem.addComponent("ethane", 0.5); - testSystem.setMixingRule("classic"); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - } +public class FrictionTheoryViscosityMethodTest extends neqsim.NeqSimTest { + static neqsim.thermo.system.SystemInterface testSystem = null; - @Test - void testCalcViscosity() { - testSystem.getPhase("gas").getPhysicalProperties().setViscosityModel("friction theory"); - testSystem.initProperties(); - double expected = 1.11212E-5; - double actual = testSystem.getPhase("gas").getViscosity("kg/msec"); - assertEquals(expected, actual, 1e-6); - } + @BeforeAll + public static void setUp() { + testSystem = new neqsim.thermo.system.SystemSrkEos(273.15 + 25.0, 42.0); + testSystem.addComponent("methane", 0.5); + testSystem.addComponent("ethane", 0.5); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + } + + @Test + void testCalcViscosity() { + testSystem.getPhase("gas").getPhysicalProperties().setViscosityModel("friction theory"); + testSystem.initProperties(); + double expected = 1.11212E-5; + double actual = testSystem.getPhase("gas").getViscosity("kg/msec"); + assertEquals(expected, actual, 1e-6); + } } diff --git a/src/test/java/neqsim/physicalProperties/util/examples/TestCondensate.java b/src/test/java/neqsim/physicalProperties/util/examples/TestCondensate.java index 94779034af..915c06c25e 100644 --- a/src/test/java/neqsim/physicalProperties/util/examples/TestCondensate.java +++ b/src/test/java/neqsim/physicalProperties/util/examples/TestCondensate.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemPrEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -26,8 +27,10 @@ public class TestCondensate { * @param args an array of {@link java.lang.String} objects */ public static void main(String args[]) { - // SystemInterface testSystem = new SystemSrkEos(273.15 + 15.0, 1.01325); - SystemInterface testSystem = new SystemPrEos(273.15 + 15.0, 1.01325); + // SystemInterface testSystem = new SystemSrkEos(273.15 + 15.0, + // ThermodynamicConstantsInterface.referencePressure); + SystemInterface testSystem = + new SystemPrEos(273.15 + 15.0, ThermodynamicConstantsInterface.referencePressure); // testSystem.getCharacterization().setTBPModel("PedersenSRKHeavyOil"); testSystem.setFluidName("Condensate1"); diff --git a/src/test/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClassTest.java b/src/test/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClassTest.java new file mode 100644 index 0000000000..5325a1ccf6 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClassTest.java @@ -0,0 +1,97 @@ +package neqsim.processSimulation.controllerDevice; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class ControllerDeviceBaseClassTest { + static ControllerDeviceBaseClass c; + + @BeforeAll + static void setUp() { + c = new ControllerDeviceBaseClass("testPID"); + } + + @Test + void testSetControllerParameters() { + double zero = 0; + double positive = 9.9; + double negative = -0.1; + + c.setControllerParameters(zero, zero, zero); + + Assertions.assertEquals(zero, c.getKp()); + Assertions.assertEquals(zero, c.getTd()); + Assertions.assertEquals(zero, c.getTi()); + + c.setControllerParameters(positive, positive, positive); + Assertions.assertEquals(positive, c.getKp()); + Assertions.assertEquals(positive, c.getTd()); + Assertions.assertEquals(positive, c.getTi()); + + c.setControllerParameters(negative, positive, positive); + Assertions.assertEquals(positive, c.getKp()); + Assertions.assertEquals(positive, c.getTd()); + Assertions.assertEquals(positive, c.getTi()); + + c.setControllerParameters(positive, negative, positive); + Assertions.assertEquals(positive, c.getKp()); + Assertions.assertEquals(positive, c.getTd()); + Assertions.assertEquals(positive, c.getTi()); + + c.setControllerParameters(positive, positive, negative); + Assertions.assertEquals(positive, c.getKp()); + Assertions.assertEquals(positive, c.getTd()); + Assertions.assertEquals(positive, c.getTi()); + } + + @Test + void testGetKp() { + double kp = c.getKp(); + Assertions.assertEquals(c.getKp(), kp); + } + + @Test + void testGetTd() { + double td = c.getTd(); + Assertions.assertEquals(c.getTd(), td); + } + + @Test + void testGetTi() { + double ti = c.getTi(); + Assertions.assertEquals(c.getTi(), ti); + } + + @Test + void testGetUnit() { + String unit = c.getUnit(); + Assertions.assertEquals(c.getUnit(), unit); + } + + @Test + void testIsReverseActing() { + boolean isReverse = c.isReverseActing(); + Assertions.assertEquals(isReverse, c.isReverseActing()); + } + + @Test + void testSetReverseActing() { + boolean testValue = true; + boolean oldValue = c.isReverseActing(); + c.setReverseActing(testValue); + Assertions.assertEquals(testValue, c.isReverseActing()); + c.setReverseActing(oldValue); + Assertions.assertEquals(oldValue, c.isReverseActing()); + } + + @Test + void testSetUnit() { + String testUnit = "test"; + String oldUnit = c.getUnit(); + c.setUnit(testUnit); + Assertions.assertEquals(testUnit, c.getUnit()); + c.setUnit(oldUnit); + Assertions.assertEquals(oldUnit, c.getUnit()); + } +} diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/FLowInducedVibrationTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/FLowInducedVibrationTest.java new file mode 100644 index 0000000000..a4fc226def --- /dev/null +++ b/src/test/java/neqsim/processSimulation/measurementDevice/FLowInducedVibrationTest.java @@ -0,0 +1,121 @@ +package neqsim.processSimulation.measurementDevice; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.util.FlowRateAdjuster; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class FLowInducedVibrationTest extends neqsim.NeqSimTest { + static ProcessSystem process1; + static FlowInducedVibrationAnalyser flowInducedVibrationAnalyser; + static FlowInducedVibrationAnalyser flowInducedVibrationAnalyserFRMS; + + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception {} + + @Test + public void testSetUnit() { + double pressure = 58.3 + 1.01325; // bara of the separator + double temperature = 90; // temperature of the separator + double gas_flow_rate = 54559.25; // Sm3/hr + double oil_flow_rate = 50.66; // Sm3/hr + double water_flow_rate = 22.0; // Sm3/hr + + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); + + testSystem.addComponent("H2S", 0.00016); + testSystem.addComponent("nitrogen", 0.0032); + testSystem.addComponent("CO2", 0.06539); + testSystem.addComponent("methane", 0.5686); + testSystem.addComponent("ethane", 0.073); + testSystem.addComponent("propane", 0.04149); + testSystem.addComponent("i-butane", 0.005189); + testSystem.addComponent("n-butane", 0.015133); + testSystem.addComponent("i-pentane", 0.004601); + testSystem.addComponent("n-pentane", 0.006); + testSystem.addTBPfraction("C6", 0.0077, 86.1800003051758 / 1000, + 86.1800003051758 / (1000 * 0.131586722637079)); + testSystem.addTBPfraction("C7", 0.0132, 94.8470001220703 / 1000, + 94.8470001220703 / (1000 * 0.141086913827126)); + testSystem.addTBPfraction("C8", 0.0138, 106.220001220703 / 1000, + 106.220001220703 / (1000 * 0.141086913827126)); + testSystem.addTBPfraction("C9", 0.009357, 120.457000732422 / 1000, + 120.457000732422 / (1000 * 0.156630031108116)); + testSystem.addTBPfraction("C10_C11", 0.0062, 140.369003295898 / 1000, + 140.369003295898 / (1000 * 0.178710051949529)); + testSystem.addTBPfraction("C12_C13", 0.0089, 167.561996459961 / 1000, + 167.561996459961 / (1000 * 0.208334072812978)); + testSystem.addTBPfraction("C14_C15", 0.0069, 197.501007080078 / 1000, + 197.501007080078 / (1000 * 0.240670271622303)); + testSystem.addTBPfraction("C16_C17", 0.0053, 229.033996582031 / 1000, + 229.033996582031 / (1000 * 0.274302534479916)); + testSystem.addTBPfraction("C18_C20", 0.0047, 262.010986328125 / 1000, + 262.010986328125 / (1000 * 0.308134346902454)); + testSystem.addTBPfraction("C21_C23", 0.004295, 303.558990478516 / 1000, + 303.558990478516 / (1000 * 0.350224115520606)); + testSystem.addTBPfraction("C24_C28", 0.003374, 355.920013427734 / 1000, + 355.920013427734 / (1000 * 0.402198101307449)); + testSystem.addTBPfraction("C29_C35", 0.005, 437.281005859375 / 1000, + 437.281005859375 / (1000 * 0.481715346021770)); + testSystem.addComponent("water", 0.127294); + testSystem.setMixingRule(2); + testSystem.init(0); + testSystem.useVolumeCorrection(true); + testSystem.setPressure(pressure, "bara"); + testSystem.setTemperature(temperature, "C"); + testSystem.setTotalFlowRate(100.0, "kg/hr"); + testSystem.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initPhysicalProperties(); + + Stream stream_1 = new Stream("Stream1", testSystem); + stream_1.setFlowRate(100.0, "kg/hr"); + + FlowRateAdjuster flowRateAdj = new FlowRateAdjuster("Flow rate adjuster", stream_1); + flowRateAdj.setAdjustedFlowRates(gas_flow_rate, oil_flow_rate, water_flow_rate, "Sm3/hr"); + + PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipe1 ", flowRateAdj.getOutletStream()); + pipe.setPipeWallRoughness(1e-6); + pipe.setLength(25); + pipe.setElevation(0.0); + pipe.setPipeSpecification(8.0, "LD201"); + pipe.setNumberOfIncrements(10); + + flowInducedVibrationAnalyser = + new FlowInducedVibrationAnalyser("Flow Induced Vibrations Analyzer 1", pipe); + flowInducedVibrationAnalyser.setMethod("LOF"); + + flowInducedVibrationAnalyserFRMS = + new FlowInducedVibrationAnalyser("Flow Induced Vibrations Analyzer FRMS", pipe); + flowInducedVibrationAnalyserFRMS.setMethod("FRMS"); + pipe.getOutletStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(flowRateAdj); + operations.add(pipe); + operations.add(flowInducedVibrationAnalyser); + operations.add(flowInducedVibrationAnalyserFRMS); + operations.run(); + + double LOF = ((FlowInducedVibrationAnalyser) operations + .getMeasurementDevice("Flow Induced Vibrations Analyzer 1")).getMeasuredValue(); + Assertions.assertEquals(LOF, 0.161, 0.05); + + double FRMS = ((FlowInducedVibrationAnalyser) operations + .getMeasurementDevice("Flow Induced Vibrations Analyzer FRMS")).getMeasuredValue(); + Assertions.assertEquals(FRMS, 176, 5); + } +} diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeterTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeterTest.java index 28daf4f5f4..d63036d0c9 100644 --- a/src/test/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeterTest.java +++ b/src/test/java/neqsim/processSimulation/measurementDevice/MultiPhaseMeterTest.java @@ -39,8 +39,8 @@ void testMain() { operations.add(multiPhaseMeter); operations.run(); - Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""), 1e-12); + Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""), 1e-5); Assertions.assertEquals(3106.770827796345, multiPhaseMeter.getMeasuredValue("GOR_std", ""), - 1e-12); + 1e-2); } } diff --git a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java index 89b3ca0969..c5571daaf0 100644 --- a/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java +++ b/src/test/java/neqsim/processSimulation/measurementDevice/WellAllocatorTest.java @@ -12,7 +12,6 @@ /** * @author ESOL - * */ class WellAllocatorTest extends neqsim.NeqSimTest { static Logger logger = LogManager.getLogger(WellAllocatorTest.class); @@ -62,8 +61,7 @@ void testGetMeasuredValueString() { sep1.addStream(stream_2); Stream stream_gasExp = new Stream("gasexp", sep1.getGasOutStream()); - - Stream stream_oilExp = new Stream("gasexp", sep1.getLiquidOutStream()); + Stream stream_oilExp = new Stream("oilexp", sep1.getLiquidOutStream()); WellAllocator wellAlloc = new WellAllocator("alloc", stream_1); wellAlloc.setExportGasStream(stream_gasExp); diff --git a/src/test/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesignTest.java b/src/test/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesignTest.java index e26e9228f7..9836650e21 100644 --- a/src/test/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesignTest.java +++ b/src/test/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesignTest.java @@ -4,11 +4,13 @@ import org.junit.jupiter.api.Test; import neqsim.processSimulation.costEstimation.CostEstimateBaseClass; import neqsim.processSimulation.mechanicalDesign.pipeline.PipelineMechanicalDesign; +import neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign; import neqsim.processSimulation.mechanicalDesign.separator.SeparatorMechanicalDesign; import neqsim.processSimulation.mechanicalDesign.valve.ValveMechanicalDesign; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; import neqsim.processSimulation.processEquipment.pipeline.AdiabaticPipe; import neqsim.processSimulation.processEquipment.pump.Pump; +import neqsim.processSimulation.processEquipment.separator.GasScrubber; import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; @@ -76,8 +78,7 @@ static void createProcess() { ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream()); valve2.setOutletPressure(2.7); - StreamInterface recircstream1 = valve2.getOutletStream().clone(); - recircstream1.setName("oilRecirc1"); + StreamInterface recircstream1 = valve2.getOutletStream().clone("oilRecirc1"); recircstream1.setFlowRate(1e-6, "kg/hr"); neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage = @@ -152,6 +153,32 @@ void testRunDesignCalculationforSeparator() { System.out.println("separator weight structual steel " + sepMechDesign.weightStructualSteel); } + @Test + void testRunDesignCalculationforGasScrubber() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 120.0); + thermoSystem.addComponent("nitrogen", 1.0); + thermoSystem.addComponent("methane", 99.0); + thermoSystem.setMixingRule("classic"); + + Stream inlets = new Stream("inlet stream", thermoSystem); + inlets.setTemperature(20.0, "C"); + inlets.setPressure(120.0, "bara"); + inlets.setFlowRate(15.0, "MSm3/day"); + inlets.run(); + + GasScrubber sep1 = new GasScrubber("scrubber1", inlets); + sep1.run(); + + GasScrubberMechanicalDesign sepMechDesign = new GasScrubberMechanicalDesign(sep1); + sepMechDesign.setMaxOperationPressure(180); + sepMechDesign.calcDesign(); + System.out.println("separator inner diameter " + sepMechDesign.innerDiameter); + System.out.println("separator weight vessel shell " + sepMechDesign.weigthVesselShell); + System.out.println("separator weight structual steel " + sepMechDesign.weightStructualSteel); + sep1.addSeparatorSection("first mesh", "meshpad"); + sepMechDesign.calcDesign(); + } + @Test void testRunDesignCalculationforValve() { ValveMechanicalDesign valve1MechDesign = @@ -162,7 +189,6 @@ void testRunDesignCalculationforValve() { @Test void testRunDesignForPipeline() { - AdiabaticPipe pipe = new AdiabaticPipe("pipe1", ((neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator) operations .getUnit("1st stage separator")).getGasOutStream()); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java b/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java index 154a7b4f0f..4bb8f6725f 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/absorber/SimpleAbsorberTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.stream.Stream; -public class SimpleAbsorberTest extends neqsim.NeqSimTest{ +public class SimpleAbsorberTest extends neqsim.NeqSimTest { neqsim.thermo.system.SystemFurstElectrolyteEos testSystem; @BeforeEach @@ -31,7 +31,7 @@ void testRun() { * neqsim.processSimulation.processSystem.ProcessSystem operations = new * neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(stream_Hot); * operations.add(absorber1); - * + * * operations.run(); */ // operations.displayResult(); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java b/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java index 5225d9c6aa..e77f00adb6 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/adsorber/SimpleAdsorberTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.stream.Stream; -public class SimpleAdsorberTest extends neqsim.NeqSimTest{ +public class SimpleAdsorberTest extends neqsim.NeqSimTest { neqsim.thermo.system.SystemFurstElectrolyteEos testSystem; @BeforeEach @@ -16,7 +16,7 @@ void setUp() { testSystem.createDatabase(true); testSystem.setMixingRule(4); } - + @Disabled("Disabled until neqsim.processSimulation.processEquipment.adsorber.SimpleAdsorber is fixed") @Test void testRun() { @@ -31,7 +31,7 @@ void testRun() { * neqsim.processSimulation.processSystem.ProcessSystem operations = new * neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(stream_Hot); * operations.add(adsorber1); - * + * * operations.run(); */ // operations.displayResult(); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java index 8e5d162d59..923d2268ec 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartTest.java @@ -132,7 +132,7 @@ public void test_Run() { * comp1.getPolytropicHead()); logger.info("Polytropic eff from curve:" + * comp1.getPolytropicEfficiency() * 100.0); logger.info("flow " + * stream_1.getThermoSystem().getFlowRate("m3/hr")); - * + * * logger.info("speed " + comp1.getCompressorChart().getSpeed( * stream_1.getThermoSystem().getFlowRate("m3/hr") + 10.0, comp1.getPolytropicHead())); * logger.info("pressure out " + comp1.getOutletPressure()); logger.info("temperature out " + diff --git a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java index f52bce181b..6ce02199c4 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/compressor/CompressorTest.java @@ -216,15 +216,14 @@ public void testCompressorWithGERG2008_2() { compressor1.setUsePolytropicCalc(true); compressor1.setUseGERG2008(true); compressor1.run(); - double head = compressor1.getPolytropicHead("kJ/kg"); - logger.info("gerg power " + compressor1.getPower() + " W"); + // double head = compressor1.getPolytropicHead("kJ/kg"); + // logger.info("gerg power " + compressor1.getPower() + " W"); // assertEquals(compressor1.getPolytropicHead("kJ/kg"), 89.464626, 0.01); compressor1.setUseGERG2008(false); compressor1.run(); - double head2 = compressor1.getPolytropicHead("kJ/kg"); - logger.info("gerg power " + compressor1.getPower() + " W"); + // double head2 = compressor1.getPolytropicHead("kJ/kg"); + // logger.info("gerg power " + compressor1.getPower() + " W"); assertEquals(compressor1.getPolytropicHead("kJ/kg"), 94.32923841459161, 0.01); - } /** diff --git a/src/test/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumnTest.java b/src/test/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumnTest.java index f7d1f555a0..0e2701be34 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumnTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/distillation/DistillationColumnTest.java @@ -6,13 +6,11 @@ import neqsim.processSimulation.processEquipment.stream.StreamInterface; public class DistillationColumnTest { - /** * @throws java.lang.Exception */ @Test public void DistillationColumnTest() throws Exception { - neqsim.thermo.system.SystemInterface richTEG = new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); richTEG.addComponent("nitrogen", 0.0003884521907420086); @@ -69,8 +67,7 @@ public void DistillationColumnTest() throws Exception { gasToReboilerStream.setPressure(1.12, "bara"); gasToReboilerStream.run(); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(richTEGStream, 1); column.getReboiler().setOutTemperature(273.15 + 202); column.getCondenser().setOutTemperature(273.15 + 88.165861); @@ -101,26 +98,22 @@ public void DistillationColumnTest() throws Exception { * column.getLiquidOutStream().getFluid().getComponent("water").getMolarMass() * column.getLiquidOutStream().getFluid().getComponent("water").getz(); - double totalWaterIn = waterFlowRateInColumn2 + waterFlowRateInColumnGasToReb; double totalWaterOut = waterFlowRateOutColumn + waterFlowRateOutColumnLeanTEG; /* * System.out.println("Column in is " + totalWaterIn + " kg/hr"); * System.out.println("Column out is " + totalWaterOut + " kg/hr"); * System.out.println("Column is solved " + column.solved()); - * - * - * + * * System.out.println("Calc Water Flow rate via fluid component " + waterFlowRateInColumn); * System.out.println("Calc Water Flow rate via molar mass and flow rate total " + * waterFlowRateInColumn2 + " kg/hr"); - * + * * System.out .println("condenser temperature " + * column.getCondenser().getFluid().getTemperature("C")); System.out.println("condenser duty " + * ((Condenser) column.getCondenser()).getDuty()); */ assertEquals(totalWaterIn, totalWaterOut, 1.0); - } /** @@ -149,8 +142,7 @@ public void deethanizerTest() throws Exception { // gasToDeethanizerStream.getFluid().prettyPrint(); - DistillationColumn column = new DistillationColumn(5, true, false); - column.setName("Deethanizer"); + DistillationColumn column = new DistillationColumn("Deethanizer", 5, true, false); column.addFeedStream(gasToDeethanizerStream, 5); column.getReboiler().setOutTemperature(105.0 + 273.15); column.setTopPressure(30.0); @@ -195,8 +187,7 @@ public void debutanizerTest() throws Exception { // gasToDebutanizerStream.getFluid().prettyPrint(); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("Deethanizer"); + DistillationColumn column = new DistillationColumn("Deethanizer", 1, true, true); column.addFeedStream(gasToDebutanizerStream, 1); ((Condenser) column.getCondenser()).setRefluxRatio(0.1); ((Condenser) column.getCondenser()).setTotalCondenser(true); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java index 0b6def2de3..ee52fde752 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeatExchangerTest.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processEquipment.heatExchanger; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.separator.Separator; @@ -36,14 +37,19 @@ void setUp() { @Test void testRun1() { Stream stream_Hot = new Stream("Stream1", testSystem); + stream_Hot.setTemperature(100.0, "C"); + stream_Hot.setFlowRate(1000.0, "kg/hr"); Stream stream_Cold = new Stream("Stream2", testSystem.clone()); + stream_Cold.setTemperature(20.0, "C"); + stream_Cold.setFlowRate(310.0, "kg/hr"); - HeatExchanger heatEx = new HeatExchanger("heatEx"); - heatEx.setFeedStream(0, stream_Hot); - heatEx.setFeedStream(1, stream_Cold); // resyc.getOutStream()); + HeatExchanger heatEx = new HeatExchanger("heatEx", stream_Hot, stream_Cold); + // heatEx.setFeedStream(0, stream_Hot); + // heatEx.setFeedStream(1, stream_Cold); // resyc.getOutStream()); + heatEx.setGuessOutTemperature(80.0, "C"); + heatEx.setUAvalue(1000); Separator sep = new Separator("sep", stream_Hot); - Stream oilOutStream = new Stream("oilOutStream", sep.getLiquidOutStream()); ThrottlingValve valv1 = new ThrottlingValve("valv1", oilOutStream); @@ -56,6 +62,7 @@ void testRun1() { neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(stream_Hot); + operations.add(stream_Cold); operations.add(heatEx); operations.add(sep); operations.add(oilOutStream); @@ -63,7 +70,6 @@ void testRun1() { operations.add(resyc); operations.run(); - // heatEx.getOutStream(0).displayResult(); // resyc.getOutStream().displayResult(); } @@ -94,8 +100,18 @@ void testRun2() { operations.add(heatExchanger1); operations.run(); - // operations.displayResult(); - // heatExchanger1.getOutStream(0).displayResult(); - // heatExchanger1.getOutStream(1).displayResult(); + assertEquals(heatExchanger1.getDuty(), -9674.051890272862, 1e-1); + + heatExchanger1.setDeltaT(1.0); + heatExchanger1.run(); + + assertEquals(15780.77130, heatExchanger1.getUAvalue(), 1e-3); + + heatExchanger1 = new neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger( + "heatEx", stream_Hot, stream_Cold); + heatExchanger1.setDeltaT(1.0); + heatExchanger1.run(); + + assertEquals(15780.77130, heatExchanger1.getUAvalue(), 1e-3); } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeaterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeaterTest.java index e1f70a8795..7e82f77113 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeaterTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/heatExchanger/HeaterTest.java @@ -23,8 +23,7 @@ public void setUpBeforeClass() throws Exception { testSystem = new SystemSrkEos(298.0, 10.0); testSystem.addComponent("methane", 100.0); processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); @@ -47,6 +46,5 @@ void testNeedRecalculation() { assertTrue(((Heater) processOps.getUnit("heater 1")).needRecalculation()); processOps.run(); assertFalse(((Heater) processOps.getUnit("heater 1")).needRecalculation()); - } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/manifold/ManifoldTest.java b/src/test/java/neqsim/processSimulation/processEquipment/manifold/ManifoldTest.java index 451ff3d914..73ee08dcaf 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/manifold/ManifoldTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/manifold/ManifoldTest.java @@ -9,7 +9,6 @@ public class ManifoldTest { @Test void testRun() { - SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); testSystem.addComponent("methane", 100.0); testSystem.addComponent("ethane", 10.0); @@ -18,15 +17,13 @@ void testRun() { SystemSrkEos testSystem2 = testSystem.clone(); testSystem2.setMolarComposition(new double[] {0.1, 0.4, 0.4}); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(10.0, "bara"); inletStream.setTemperature(20.0, "C"); inletStream.setFlowRate(3.0, "MSm3/day"); inletStream.run(); - Stream inletStream2 = new Stream("inletStream", testSystem2); - inletStream2.setName("inlet stream"); + Stream inletStream2 = new Stream("inlet stream", testSystem2); inletStream2.setPressure(10.0, "bara"); inletStream2.setTemperature(20.0, "C"); inletStream2.setFlowRate(2.0, "MSm3/day"); @@ -46,7 +43,6 @@ void testRun() { @Test void testRun2() { - SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); testSystem.addComponent("methane", 100.0); testSystem.addComponent("ethane", 10.0); @@ -57,14 +53,12 @@ void testRun2() { ProcessSystem processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(10.0, "bara"); inletStream.setTemperature(20.0, "C"); inletStream.setFlowRate(3.0, "MSm3/day"); - Stream inletStream2 = new Stream("inletStream", testSystem2); - inletStream2.setName("inlet stream"); + Stream inletStream2 = new Stream("inlet stream 2", testSystem2); inletStream2.setPressure(10.0, "bara"); inletStream2.setTemperature(20.0, "C"); inletStream2.setFlowRate(2.0, "MSm3/day"); @@ -88,8 +82,5 @@ void testRun2() { assertEquals(stream1FromManifold.getFluid().getComponent(0).getx(), manifold1.getSplitStream(0).getFluid().getComponent(0).getx(), 1e-6); assertEquals(5.0, manifold1.getMixedStream().getFlowRate("MSm3/day"), 0.01); - - - } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java index 9aa6257e64..4e156d1e81 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/mixer/MixerTest.java @@ -11,7 +11,6 @@ /** * @author ESOL - * */ class MixerTest { static neqsim.thermo.system.SystemInterface testSystem; diff --git a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java index 88faa5f747..c25a6c86d3 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java @@ -3,13 +3,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; public class BeggsAndBrillsPipeTest { @Test public void testFlowNoVolumeCorrection() { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 15), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 15), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("nC10", 50, "MSm^3/day"); testSystem.setMixingRule(2); @@ -21,13 +22,13 @@ public void testFlowNoVolumeCorrection() { testSystem.initPhysicalProperties(); Assertions.assertEquals(testSystem.getPhase("oil").getFlowRate("m3/hr"), - testSystem.getFlowRate("m3/hr"), 1e-4); + testSystem.getFlowRate("m3/hr"), 1); } @Test public void testFlowVolumeCorrection() { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 15), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 15), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("nC10", 50, "MSm^3/day"); testSystem.setMixingRule(2); @@ -39,18 +40,17 @@ public void testFlowVolumeCorrection() { testSystem.initPhysicalProperties(); Assertions.assertEquals(testSystem.getPhase("oil").getFlowRate("m3/hr"), - testSystem.getFlowRate("m3/hr"), 1e-4); + testSystem.getFlowRate("m3/hr"), 1); } @Test public void testPipeLineBeggsAndBrills() { - double pressure = 50; // bara double temperature = 40; // C double massFlowRate = 1100000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.5); testSystem.addComponent("nC10", 0.5); @@ -68,12 +68,13 @@ public void testPipeLineBeggsAndBrills() { Stream stream_1 = new Stream("Stream1", testSystem); stream_1.setFlowRate(massFlowRate, "kg/hr"); - PipeBeggsAndBrills pipe = new PipeBeggsAndBrills(stream_1); + PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipe1", stream_1); pipe.setPipeWallRoughness(5e-6); pipe.setLength(10.0); pipe.setAngle(0); pipe.setDiameter(0.125); pipe.setNumberOfIncrements(20); + pipe.setRunIsothermal(false); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -84,21 +85,20 @@ public void testPipeLineBeggsAndBrills() { double pressureOut = pipe.getOutletPressure(); double temperatureOut = pipe.getOutletTemperature() - 273.15; - Assertions.assertEquals(pressureOut, 27.5402, 1e-4); - Assertions.assertEquals(temperatureOut, 39.3374, 1e-4); - + Assertions.assertEquals(pressureOut, 27.5402, 1); + Assertions.assertEquals(temperatureOut, 39.3374, 1); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); } - @Test public void testPipeLineBeggsAndBrills2() { - double pressure = 50; // bara double temperature = 40; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.5); testSystem.addComponent("nC10", 0.5); @@ -122,6 +122,7 @@ public void testPipeLineBeggsAndBrills2() { pipe.setAngle(90); pipe.setDiameter(0.125); pipe.setNumberOfIncrements(50); + pipe.setRunIsothermal(false); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -131,23 +132,21 @@ public void testPipeLineBeggsAndBrills2() { double pressureOut = pipe.getOutletPressure(); double temperatureOut = pipe.getOutletTemperature() - 273.15; - - Assertions.assertEquals(pressureOut, 13.735508907175728, 1e-4); - Assertions.assertEquals(temperatureOut, 38.82331519652632, 1e-4); - + Assertions.assertEquals(pressureOut, 13.366143179275166, 1); + Assertions.assertEquals(temperatureOut, 38.8, 0.1); + Assertions.assertEquals(pipe.getFlowRegime(), "INTERMITTENT"); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); } - - @Test public void testPipeLineBeggsAndBrills3() { - double pressure = 50; // bara double temperature = 80; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.3); testSystem.addComponent("nC10", 0.4); @@ -167,12 +166,13 @@ public void testPipeLineBeggsAndBrills3() { Stream stream_1 = new Stream("Stream1", testSystem); stream_1.setFlowRate(massFlowRate, "kg/hr"); - PipeBeggsAndBrills pipe = new PipeBeggsAndBrills(stream_1); + PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipe1", stream_1); pipe.setPipeWallRoughness(0); pipe.setLength(410.0); pipe.setElevation(300); pipe.setDiameter(0.125); pipe.setNumberOfIncrements(10); + pipe.setRunIsothermal(false); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -190,18 +190,22 @@ public void testPipeLineBeggsAndBrills3() { Assertions.assertEquals(pipe.getSegmentPressureDrop(10), 1.5468048987983438, 1.0); Assertions.assertEquals(pipe.getSegmentTemperature(10) - 273.15, 79.80343029302054, 1.0); Assertions.assertEquals(pipe.getSegmentFlowRegime(10), "INTERMITTENT"); - Assertions.assertEquals(pipe.getSegmentMixtureDensity(10), 233.1155792052253, 1.0); + Assertions.assertEquals(pipe.getSegmentMixtureDensity(10), 224.31571593591167, 20.0); Assertions.assertEquals(pipe.getSegmentLiquidSuperficialVelocity(10), 3.357338501138603, 1.0); Assertions.assertEquals(pipe.getSegmentGasSuperficialVelocity(10), 7.109484383317198, 1.0); Assertions.assertEquals(pipe.getSegmentMixtureSuperficialVelocity(10), 10.466822884455802, 1.0); Assertions.assertEquals(pipe.getSegmentMixtureViscosity(10), 0.14329203901478244, 1.0); Assertions.assertEquals(pipe.getSegmentLiquidHoldup(10), 0.42601098053163294, 1.0); - Assertions.assertEquals(pipe.getSegmentMixtureReynoldsNumber(10), 2127138.3343691113, 1.0); Assertions.assertEquals(pipe.getSegmentLength(10), 410.0, 1.0); Assertions.assertEquals(pipe.getSegmentElevation(10), 300, 1.0); - } - + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); + pipe.setRunIsothermal(true); + pipe.run(); + Assertions.assertEquals(pipe.getSegmentPressure(10), 34.4716898025371, 1.0); + Assertions.assertEquals(pipe.getOutletStream().getTemperature() - 273.15, 80, 1.0); + } @Test public void testPipeLineBeggsAndBrills4() { @@ -210,8 +214,8 @@ public void testPipeLineBeggsAndBrills4() { double temperature = 80; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 1); testSystem.setMixingRule(2); @@ -225,12 +229,13 @@ public void testPipeLineBeggsAndBrills4() { Stream stream_1 = new Stream("Stream1", testSystem); stream_1.setFlowRate(massFlowRate, "kg/hr"); - PipeBeggsAndBrills pipe = new PipeBeggsAndBrills(stream_1); + PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipe1", stream_1); pipe.setPipeWallRoughness(0); pipe.setLength(1500.0); pipe.setElevation(-1000); pipe.setDiameter(0.125); pipe.setNumberOfIncrements(10); + pipe.setRunIsothermal(false); // test with only water phase neqsim.processSimulation.processSystem.ProcessSystem operations = @@ -242,12 +247,30 @@ public void testPipeLineBeggsAndBrills4() { double pressureOut = pipe.getOutletPressure(); double temperatureOut = pipe.getOutletTemperature() - 273.15; - Assertions.assertEquals(temperatureOut, 75.0748, 1e-4); - Assertions.assertEquals(pressureOut, 124.04439, 1e-4); - + Assertions.assertEquals(temperatureOut, 75.0748, 1); + Assertions.assertEquals(pressureOut, 124.04439, 1); + + Assertions.assertEquals(pipe.getPressureDrop(), 25.955604559293917, 1.0); + Assertions.assertEquals(pipe.getSegmentPressure(10), 124.04439544070608, 1.0); + Assertions.assertEquals(pipe.getSegmentPressure(0), 150, 1.0); + Assertions.assertEquals(pipe.getSegmentPressureDrop(10), 2.9204245897598162, 1.0); + Assertions.assertEquals(pipe.getSegmentTemperature(10) - 273.15, 75.07486781297496, 1.0); + Assertions.assertEquals(pipe.getSegmentFlowRegime(10), "Single Phase"); + Assertions.assertEquals(pipe.getSegmentMixtureDensity(10), 73.54613545016805, 1.0); + Assertions.assertEquals(pipe.getSegmentLiquidSuperficialVelocity(10), 0.0, 1.0); + Assertions.assertEquals(pipe.getSegmentGasSuperficialVelocity(10), 33.85480591912372, 1.0); + Assertions.assertEquals(pipe.getSegmentMixtureSuperficialVelocity(10), 33.85480591912372, 1.0); + Assertions.assertEquals(pipe.getSegmentMixtureViscosity(10), 0.14329203901478244, 1.0); + Assertions.assertEquals(pipe.getSegmentLiquidHoldup(10), 0.0, 0.01); + Assertions.assertEquals(pipe.getSegmentMixtureReynoldsNumber(10), 2.014803001851525E7, 1.0); + Assertions.assertEquals(pipe.getSegmentLength(10), 1500.0, 1.0); + Assertions.assertEquals(pipe.getSegmentElevation(10), -1000, 1.0); + Assertions.assertEquals(pipe.getNumberOfIncrements(), 10, 0.1); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem2.addComponent("water", 1); testSystem2.setMixingRule(2); @@ -261,12 +284,13 @@ public void testPipeLineBeggsAndBrills4() { Stream stream_2 = new Stream("Stream1", testSystem2); stream_2.setFlowRate(massFlowRate, "kg/hr"); - PipeBeggsAndBrills pipe2 = new PipeBeggsAndBrills(stream_2); + PipeBeggsAndBrills pipe2 = new PipeBeggsAndBrills("pipe2", stream_2); pipe2.setPipeWallRoughness(0); pipe2.setLength(1500.0); pipe2.setElevation(-1000); pipe2.setDiameter(0.125); pipe2.setNumberOfIncrements(10); + pipe2.setRunIsothermal(false); neqsim.processSimulation.processSystem.ProcessSystem operations2 = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -276,13 +300,10 @@ public void testPipeLineBeggsAndBrills4() { double pressureOut2 = pipe2.getOutletPressure(); + Assertions.assertEquals(pressureOut2, 238.8205556280226, 1); - Assertions.assertEquals(pressureOut2, 238.8205556280226, 1e-4); - - - - neqsim.thermo.system.SystemInterface testSystem3 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), 1.01325); + neqsim.thermo.system.SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem3.addComponent("ethane", 1); testSystem3.setMixingRule(2); @@ -302,12 +323,13 @@ public void testPipeLineBeggsAndBrills4() { Stream stream_3 = new Stream("Stream1", testSystem3); stream_3.setFlowRate(massFlowRate, "kg/hr"); - PipeBeggsAndBrills pipe3 = new PipeBeggsAndBrills(stream_3); + PipeBeggsAndBrills pipe3 = new PipeBeggsAndBrills("pipe3", stream_3); pipe3.setPipeWallRoughness(0); pipe3.setLength(10000.0); pipe3.setElevation(1500); pipe3.setDiameter(0.125); pipe3.setNumberOfIncrements(10); + pipe3.setRunIsothermal(false); neqsim.processSimulation.processSystem.ProcessSystem operations3 = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -320,9 +342,7 @@ public void testPipeLineBeggsAndBrills4() { Assertions.assertEquals(testSystem3.hasPhaseType("gas"), true); - Assertions.assertEquals(temperatureOut3, -11.04463, 1e-4); - Assertions.assertEquals(pressureOut3, 18.3429, 1e-4); - + Assertions.assertEquals(temperatureOut3, -11.04463, 1); + Assertions.assertEquals(pressureOut3, 18.3429, 1); } - } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java new file mode 100644 index 0000000000..d50b406fd6 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/PipelineTest.java @@ -0,0 +1,71 @@ +package neqsim.processSimulation.processEquipment.pipeline; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; + +public class PipelineTest { + @Test + public void testMain() { + double flow = 60.0; + double temperature = 20.0; + double pressure = 200.0; + + double diameter = 1.0; + double length = 700000.0; + double elevation = 0; + double wallroughness = 5e-6; + + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + temperature), pressure); + testSystem.addComponent("methane", 0.9); + testSystem.addComponent("ethane", 0.1); + testSystem.setMixingRule("classic"); + + Stream stream_1 = new Stream("Stream1", testSystem); + stream_1.setFlowRate(flow, "MSm3/day"); + stream_1.setTemperature(temperature, "C"); + stream_1.setPressure(pressure, "bara"); + + stream_1.run(); + OnePhasePipeLine pipeline = new OnePhasePipeLine("pipeline", stream_1); + pipeline.setNumberOfLegs(1); + pipeline.setPipeDiameters(new double[] {diameter, diameter}); + pipeline.setLegPositions(new double[] {0, length}); + pipeline.setHeightProfile(new double[] {0, elevation}); + pipeline.setPipeWallRoughness(new double[] {wallroughness, wallroughness}); + pipeline.setOuterTemperatures(new double[] {temperature + 273.15, temperature + 273.15}); + pipeline.setPipeOuterHeatTransferCoefficients(new double[] {15.0, 15.0}); + pipeline.setPipeWallHeatTransferCoefficients(new double[] {15.0, 15.0}); + + AdiabaticPipe simplePipeline = new AdiabaticPipe("simplePipeline", stream_1); + simplePipeline.setDiameter(diameter); + simplePipeline.setLength(length); + simplePipeline.setPipeWallRoughness(wallroughness); + simplePipeline.setInletElevation(0); + simplePipeline.setOutletElevation(elevation); + + PipeBeggsAndBrills beggsBrilsPipe = new PipeBeggsAndBrills("simplePipeline 2", stream_1); + beggsBrilsPipe.setPipeWallRoughness(wallroughness); + beggsBrilsPipe.setLength(length); + beggsBrilsPipe.setElevation(elevation); + beggsBrilsPipe.setDiameter(diameter); + beggsBrilsPipe.setRunIsothermal(false); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(pipeline); + operations.add(simplePipeline); + operations.add(beggsBrilsPipe); + operations.run(); + + // pipeline.run(); + + System.out.println(beggsBrilsPipe.getOutletStream().getTemperature()); + + Assertions.assertEquals(123.876927, pipeline.getOutletPressure("bara"), 0.1); + Assertions.assertEquals(120.711887695240, simplePipeline.getOutletPressure(), 0.1); + Assertions.assertEquals(113.983562217178, beggsBrilsPipe.getOutletPressure(), 0.1); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbineTest.java b/src/test/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbineTest.java index d5fe5667a6..1fd56cbc56 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbineTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/powerGeneration/GasTurbineTest.java @@ -54,7 +54,6 @@ void testRun() { @Test void testIdealAiFuelRatio() { - testSystem = new SystemSrkEos(298.15, 1.0); testSystem.addComponent("nitrogen", 1.0); testSystem.addComponent("CO2", 2.0); @@ -76,6 +75,5 @@ void testIdealAiFuelRatio() { gasturb.setInletStream(gasStream); double AFR = gasturb.calcIdealAirFuelRatio(); assertEquals(15.8430086719654, AFR, 0.0001); - } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/pump/PumpTest.java b/src/test/java/neqsim/processSimulation/processEquipment/pump/PumpTest.java index bf1a16bf28..7a652fec80 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/pump/PumpTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/pump/PumpTest.java @@ -1,70 +1,102 @@ package neqsim.processSimulation.processEquipment.pump; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import neqsim.processSimulation.processEquipment.stream.Stream; /** - *PumpTest class.
+ *+ * PumpTest class. + *
* * @author asmund * @version $Id: $Id * @since 2.2.3 */ -public class PumpTest extends neqsim.NeqSimTest{ - @Test - void testRun() { - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkEos(273.15 + 20.0, 10.00); - feedGas.addComponent("water", 1.0); +public class PumpTest extends neqsim.NeqSimTest { + @Test + void testRun() { + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkEos(273.15 + 20.0, 10.00); + feedGas.addComponent("water", 1.0); - Stream feedGasStream = new Stream("feed fluid", feedGas); - feedGasStream.setFlowRate(4000.0 * 1000, "kg/hr"); - feedGasStream.setTemperature(20.0, "C"); - feedGasStream.setPressure(1.0, "bara"); - feedGasStream.run(); + Stream feedGasStream = new Stream("feed fluid", feedGas); + feedGasStream.setFlowRate(4000.0 * 1000, "kg/hr"); + feedGasStream.setTemperature(20.0, "C"); + feedGasStream.setPressure(1.0, "bara"); + feedGasStream.run(); - Pump pump1 = new Pump("pump1", feedGasStream); - pump1.setOutletPressure(12.6); - pump1.calculateAsCompressor(false); + Pump pump1 = new Pump("pump1", feedGasStream); + pump1.setOutletPressure(12.6); + pump1.calculateAsCompressor(false); - pump1.run(); - double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; - double[] speed = new double[] {350.0, 1000.0}; - double[][] flow = new double[][] { - {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, - 5661.0331}, - {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, - 5387.4952}}; - double[][] head = new double[][] { - {80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, - {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, - {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, - {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, - {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, - {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, - {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, - {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; - double[][] polyEff = new double[][] { - {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, - 79.2210931638144, 75.4719133864634, 69.6034181197298, 58.7322388482707}, - {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, - 79.5313242980328, 75.5912622896367, 69.6846136362097, 60.0043057990909}, - {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, - 78.8532389102705, 73.6664774270613, 66.2735600426727, 57.671664571658}, - {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, - 75.380928428817, 69.5332969549779, 63.7997587622339, 58.8120614497758}, - {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, - 78.0462158225426, 73.0403707523258, 66.5572286338589, 59.8624822515064}, - {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, - 76.3814534404405, 70.8027503005902, 64.6437367160571, 60.5299349982342}, - {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, - 76.1983240929369, 69.289982774309, 60.8567149372229}, - {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, - 75.2170936751143, 70.3105081673411, 65.5507568533569, - 61.0391468300337}}; - pump1.getPumpChart().setCurves(chartConditions, speed, flow, head, polyEff); - pump1.getPumpChart().setHeadUnit("meter"); - pump1.setSpeed(500); - pump1.run(); - } + pump1.run(); + double[] chartConditions = new double[] {0.3, 1.0, 1.0, 1.0}; + double[] speed = new double[] {350.0, 1000.0}; + double[][] flow = new double[][] { + {2789.1285, 3174.0375, 3689.2288, 4179.4503, 4570.2768, 4954.7728, 5246.0329, 5661.0331}, + {2571.1753, 2943.7254, 3440.2675, 3837.4448, 4253.0898, 4668.6643, 4997.1926, 5387.4952}}; + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}, + {72.2122, 71.8369, 68.9009, 65.8341, 60.7167, 54.702, 47.2749, 35.7471}, + {65.1576, 64.5253, 62.6118, 59.1619, 54.0455, 47.0059, 39.195, 31.6387}, + {58.6154, 56.9627, 54.6647, 50.4462, 44.4322, 38.4144, 32.9084, 28.8109}, + {52.3295, 51.0573, 49.5283, 46.3326, 42.3685, 37.2502, 31.4884, 25.598}, + {40.6578, 39.6416, 37.6008, 34.6603, 30.9503, 27.1116, 23.2713, 20.4546}, + {35.2705, 34.6359, 32.7228, 31.0645, 27.0985, 22.7482, 18.0113}, + {32.192, 31.1756, 29.1329, 26.833, 23.8909, 21.3324, 18.7726, 16.3403},}; + double[][] polyEff = new double[][] { + {77.2452238409573, 79.4154186459363, 80.737960012489, 80.5229826589649, 79.2210931638144, + 75.4719133864634, 69.6034181197298, 58.7322388482707}, + {77.0107837113504, 79.3069974136389, 80.8941189021135, 80.7190194665918, 79.5313242980328, + 75.5912622896367, 69.6846136362097, 60.0043057990909}, + {77.0043065299874, 79.1690958847856, 80.8038169975675, 80.6543975614197, 78.8532389102705, + 73.6664774270613, 66.2735600426727, 57.671664571658}, + {77.0716623789093, 80.4629750233093, 81.1390811169072, 79.6374242667478, 75.380928428817, + 69.5332969549779, 63.7997587622339, 58.8120614497758}, + {76.9705872525642, 79.8335492585324, 80.9468133671171, 80.5806471927835, 78.0462158225426, + 73.0403707523258, 66.5572286338589, 59.8624822515064}, + {77.5063036680357, 80.2056198362559, 81.0339108025933, 79.6085962687939, 76.3814534404405, + 70.8027503005902, 64.6437367160571, 60.5299349982342}, + {77.8175271586685, 80.065165942218, 81.0631362122632, 79.8955051771299, 76.1983240929369, + 69.289982774309, 60.8567149372229}, + {78.0924334304045, 80.9353551568667, 80.7904437766234, 78.8639325223295, 75.2170936751143, + 70.3105081673411, 65.5507568533569, 61.0391468300337}}; + pump1.getPumpChart().setCurves(chartConditions, speed, flow, head, polyEff); + pump1.getPumpChart().setHeadUnit("meter"); + pump1.setSpeed(500); + pump1.run(); + } + + @Test + void testSimplePumpCurve() { + neqsim.thermo.system.SystemInterface feedDecane = + new neqsim.thermo.system.SystemSrkEos(273.15 + 20.0, 10.00); + feedDecane.addComponent("n-pentane", 0.5, "kg/sec"); + feedDecane.addComponent("n-hexane", 0.5, "kg/sec"); + + Stream feedC10Stream = new Stream("feed decane", feedDecane); + feedC10Stream.setFlowRate(30000, "kg/hr"); + feedC10Stream.setTemperature(30.0, "C"); + feedC10Stream.setPressure(1.0, "bara"); + feedC10Stream.run(); + + System.out.println("flow " + feedC10Stream.getFlowRate("m3/hr")); + double[] chartConditions = new double[] {}; + double[] speed = new double[] {500.0}; + double[][] flow = + new double[][] {{27.1285, 31.0375, 36.2288, 41.4503, 45.2768, 49.7728, 52.0329, 56.0331}}; + double[][] head = + new double[][] {{80.0375, 78.8934, 76.2142, 71.8678, 67.0062, 60.6061, 53.0499, 39.728}}; + double[][] polyEff = new double[][] {{77.2452238409573, 79.4154186459363, 80.737960012489, + 80.5229826589649, 79.2210931638144, 75.4719133864634, 69.6034181197298, 58.7322388482707}}; + + Pump pump1 = new Pump("pump1", feedC10Stream); + pump1.getPumpChart().setCurves(chartConditions, speed, flow, head, polyEff); + pump1.getPumpChart().setHeadUnit("meter"); + pump1.setSpeed(500); + pump1.run(); + + Assertions.assertEquals(7.274237081101, pump1.getOutletPressure(), 1e-5); + } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoirTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoirTest.java index b26f243b70..5189d934de 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoirTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoirTest.java @@ -58,7 +58,12 @@ void testRun2() { for (int i = 0; i < 10; i++) { reservoirOps.runTransient(deltaTime); } - Assertions.assertEquals(352.274030, reservoirOps.getReservoirFluid().getPressure("bara"), 0.1); + Assertions.assertEquals(355.19330033985693 + , reservoirOps.getReservoirFluid().getPressure("bara"), 0.1); Assertions.assertEquals(11.698, reservoirOps.getWaterProdution("Sm3/day"), 0.1); + + reservoirOps.setLowPressureLimit(52.0e5, "Pa"); + Assertions.assertEquals(52.0, reservoirOps.getLowPressureLimit("bara"), 0.1); + Assertions.assertEquals(52.0e5, reservoirOps.getLowPressureLimit("Pa"), 0.1); } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java new file mode 100644 index 0000000000..d17887bdb0 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/reservoir/WellFlowTest.java @@ -0,0 +1,249 @@ +package neqsim.processSimulation.processEquipment.reservoir; + +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processEquipment.util.Adjuster; +import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.processSimulation.processSystem.ProcessSystem; + +public class WellFlowTest { + @Test + void testRun() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemPrEos(373.15, 100.0); + fluid1.addComponent("water", 3.599); + fluid1.addComponent("nitrogen", 0.599); + fluid1.addComponent("CO2", 0.51); + fluid1.addComponent("methane", 62.8); + fluid1.addComponent("n-heptane", 12.8); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(fluid1, 1e9, 10.0, 10.0e7); + + StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1"); + producedGasStream.setFlowRate(1.0, "MSm3/day"); + + WellFlow wellflow = new WellFlow("well flow unit"); + wellflow.setInletStream(producedGasStream); + wellflow.setWellProductionIndex(5.000100751427403E-4); + + ProcessSystem process = new ProcessSystem(); + process.add(reservoirOps); + process.add(wellflow); + + process.run(); + /* + * System.out.println("production index " + wellflow.getWellProductionIndex() + + * " MSm3/day/bar^2"); System.out.println("reservoir pressure " + + * producedGasStream.getPressure("bara")); System.out .println("pres bottomhole " + + * wellflow.getOutletStream().getPressure("bara") + " bara"); + */ + } + + @Test + void testRunTransientRes2() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemPrEos(298.15, 38.0); + fluid1.addComponent("water", 3.599); + fluid1.addComponent("nitrogen", 0.599); + fluid1.addComponent("CO2", 0.51); + fluid1.addComponent("methane", 99.8); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + + double producxtionIndex = 10.000100751427403E-3; + + neqsim.processSimulation.processEquipment.reservoir.SimpleReservoir reservoirOps = + new neqsim.processSimulation.processEquipment.reservoir.SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(fluid1.clone(), 700000000.0, 1.0, 10.0e7); + reservoirOps.setLowPressureLimit(10.0, "bara"); + + StreamInterface producedGasStream = reservoirOps.addGasProducer("SLP_A32566GI"); + producedGasStream.setFlowRate(9.0, "MSm3/day"); + + neqsim.processSimulation.processEquipment.reservoir.WellFlow wellflow = + new neqsim.processSimulation.processEquipment.reservoir.WellFlow("well flow unit"); + wellflow.setInletStream(producedGasStream); + wellflow.setWellProductionIndex(producxtionIndex); + + neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills pipe = + new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills("pipe", + wellflow.getOutletStream()); + pipe.setPipeWallRoughness(5e-6); + pipe.setLength(170.0); + pipe.setElevation(170); + pipe.setDiameter(0.625); + + neqsim.processSimulation.processEquipment.compressor.Compressor compressor = + new neqsim.processSimulation.processEquipment.compressor.Compressor("subcomp"); + compressor.setInletStream(pipe.getOutletStream()); + compressor.setUsePolytropicCalc(true); + compressor.setPolytropicEfficiency(0.6); + compressor.setCompressionRatio(2.0); + + neqsim.processSimulation.processEquipment.heatExchanger.Cooler intercooler = + new neqsim.processSimulation.processEquipment.heatExchanger.Cooler("cooler", + compressor.getOutletStream()); + intercooler.setOutTemperature(25.0, "C"); + + neqsim.processSimulation.processEquipment.compressor.Compressor compressor2 = + new neqsim.processSimulation.processEquipment.compressor.Compressor("subcomp2"); + compressor2.setInletStream(intercooler.getOutletStream()); + compressor2.setUsePolytropicCalc(true); + compressor2.setPolytropicEfficiency(0.6); + compressor2.setCompressionRatio(2.0); + + neqsim.processSimulation.processEquipment.heatExchanger.Heater cooler1 = + new neqsim.processSimulation.processEquipment.heatExchanger.Heater("cooler 1", + compressor2.getOutletStream()); + cooler1.setOutTemperature(30.0, "C"); + + neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills pipeline = + new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills("pipeline", + cooler1.getOutletStream()); + pipeline.setPipeWallRoughness(50e-6); + pipeline.setLength(50 * 1e3); + pipeline.setElevation(0); + pipeline.setDiameter(17.0 * 0.0254); + double richgas_inlet_pressure = 150.0; + double max_gas_production = 9.0; + + neqsim.processSimulation.processEquipment.util.Adjuster adjuster = + new neqsim.processSimulation.processEquipment.util.Adjuster("adjuster"); + adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure", richgas_inlet_pressure, + "bara"); + adjuster.setAdjustedVariable(producedGasStream, "flow", "MSm3/day"); + adjuster.setMaxAdjustedValue(max_gas_production); + adjuster.setMinAdjustedValue(1.0); + + neqsim.processSimulation.processSystem.ProcessSystem process = + new neqsim.processSimulation.processSystem.ProcessSystem(); + process.add(reservoirOps); + process.add(wellflow); + process.add(pipe); + process.add(compressor); + process.add(intercooler); + process.add(compressor2); + process.add(cooler1); + process.add(pipeline); + process.add(adjuster); + process.run(); + + System.out + .println("gas production " + reservoirOps.getGasProdution("Sm3/day") / 1e6 + " MSm3/day"); + } + + @Test + void testRunTransient() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemPrEos(298.15, 60.0); + fluid1.addComponent("water", 3.599); + fluid1.addComponent("nitrogen", 0.599); + fluid1.addComponent("CO2", 0.51); + fluid1.addComponent("methane", 62.8); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(fluid1, 7e8, 1.0, 10.0e7); + reservoirOps.setLowPressureLimit(10.0, "bara"); + + StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1"); + producedGasStream.setFlowRate(9.0, "MSm3/day"); + + WellFlow wellflow = new WellFlow("well flow unit"); + wellflow.setInletStream(producedGasStream); + wellflow.setWellProductionIndex(10.000100751427403E-3); + + PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("pipe", wellflow.getOutletStream()); + pipe.setPipeWallRoughness(5e-6); + pipe.setLength(300.0); + pipe.setElevation(300); + pipe.setDiameter(0.625); + + PipeBeggsAndBrills pipeline = new PipeBeggsAndBrills("pipeline", pipe.getOutletStream()); + pipeline.setPipeWallRoughness(5e-6); + pipeline.setLength(60000.0); + pipeline.setElevation(200); + pipeline.setDiameter(0.725); + + ThrottlingValve chokeValve = new ThrottlingValve("chocke"); + chokeValve.setInletStream(pipeline.getOutletStream()); + chokeValve.setOutletPressure(5.0, "bara"); + + Adjuster adjuster = new Adjuster("adjuster"); + adjuster.setTargetVariable(pipeline.getOutletStream(), "pressure", + chokeValve.getOutletPressure(), "bara"); + adjuster.setAdjustedVariable(producedGasStream, "flow", "MSm3/day"); + adjuster.setMaxAdjustedValue(9.0); + adjuster.setMinAdjustedValue(1.0); + + ProcessSystem process = new ProcessSystem(); + process.add(reservoirOps); + process.add(wellflow); + process.add(pipe); + process.add(pipeline); + process.add(adjuster); + process.run(); + /* + * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); + * System.out.println("production index " + wellflow.getWellProductionIndex() + + * " MSm3/day/bar^2"); System.out.println("reservoir pressure " + + * producedGasStream.getPressure("bara")); System.out .println("pres bottomhole " + + * wellflow.getOutletStream().getPressure("bara") + " bara"); + * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + " bara"); + * System.out .println("top side pressure " + pipeline.getOutletStream().getPressure("bara") + + * " bara"); + */ + // process.setTimeStep(60 * 60 * 24 * 365); + + for (int i = 0; i < 8; i++) { + reservoirOps.runTransient(60 * 60 * 365); + process.run(); + if (pipeline.getOutletStream().getPressure("bara") < 5.0) { + continue; + } + /* + * System.out.println("production flow rate " + producedGasStream.getFlowRate("MSm3/day")); + * System.out.println("reservoir pressure " + wellflow.getInletStream().getPressure("bara")); + * System.out .println("pres bottomhole " + wellflow.getOutletStream().getPressure("bara") + + * " bara"); + * + * System.out.println("xmas pressure " + pipe.getOutletStream().getPressure("bara") + + * " bara"); System.out .println("top side pressure " + + * pipeline.getOutletStream().getPressure("bara") + " bara"); System.out + * .println("Total produced gas " + reservoirOps.getGasProductionTotal("GMSm3") + " GMSm3"); + * System.out.println("gas velocity " + pipeline.getInletSuperficialVelocity()); + */ + } + } + + @Test + void testCalcWellFlow() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemPrEos(373.15, 100.0); + fluid1.addComponent("water", 3.599); + fluid1.addComponent("nitrogen", 0.599); + fluid1.addComponent("CO2", 0.51); + fluid1.addComponent("methane", 62.8); + fluid1.setMixingRule(2); + fluid1.setMultiPhaseCheck(true); + + SimpleReservoir reservoirOps = new SimpleReservoir("Well 1 reservoir"); + reservoirOps.setReservoirFluid(fluid1, 1e9, 1.0, 10.0e7); + reservoirOps.setLowPressureLimit(10.0, "bara"); + + StreamInterface producedGasStream = reservoirOps.addGasProducer("gasproducer_1"); + producedGasStream.setFlowRate(9.0, "MSm3/day"); + + WellFlow wellflow = new WellFlow("well flow unit"); + wellflow.setInletStream(producedGasStream); + + double permeability = 50.0; // milli darcy + // wellflow.setDarcyLawParameters(permeability, ); + // wellflow.setWellProductionIndex(10.000100751427403E-3); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java b/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java index 0e0c60f2c5..7f7664f6c7 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/separator/SeparatorTest.java @@ -11,7 +11,6 @@ /** * @author ESOL - * */ class SeparatorTest extends neqsim.NeqSimTest { static neqsim.thermo.system.SystemInterface testSystem = null; @@ -50,10 +49,10 @@ public void setUpBeforeClass() throws Exception { @Test public void testFlow() { LevelTransmitter lt = new LevelTransmitter("levelTransmitter", sep); - Assertions.assertEquals(0.05263157894736842, lt.getMeasuredValue(), 1e-12); + Assertions.assertEquals(0.5, lt.getMeasuredValue(), 1e-12); ((StreamInterface) processOps.getUnit("inlet stream")).setFlowRate(0.01, "MSm3/day"); processOps.run(); - Assertions.assertEquals(0.052631578947368494, lt.getMeasuredValue(), 1e-12); + Assertions.assertEquals(0.5, lt.getMeasuredValue(), 1e-12); Assertions.assertEquals(lt.getMeasuredValue() * 100, lt.getMeasuredPercentValue(), 1e-12); } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java index 478e7dff8c..60c232b49e 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/splitter/ComponentSplitterTest.java @@ -30,8 +30,7 @@ public void setUpBeforeClass() throws Exception { testSystem.addComponent("ethane", 10.0); testSystem.addComponent("propane", 10.0); processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); @@ -55,8 +54,7 @@ public void configSplitter() { testSystem.addComponent("ethane", 10.0); testSystem.addComponent("propane", 10.0); processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); @@ -87,8 +85,7 @@ public void testRunSplitter() { testSystem.addComponent("ethane", 10.0); testSystem.addComponent("propane", 10.0); processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); @@ -133,13 +130,12 @@ public void testRunSplitter2() { processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(55.0, "bara"); inletStream.setTemperature(25.0, "C"); inletStream.setFlowRate(5.0, "MSm3/day"); - Stream streamresycl = inletStream.clone(); + Stream streamresycl = inletStream.clone("recycle stream"); Mixer mixer1 = new Mixer("mixer 1"); mixer1.addStream(inletStream); @@ -149,7 +145,6 @@ public void testRunSplitter2() { compressor1.setOutletPressure(100.0); Stream compressedStream = (Stream) compressor1.getOutletStream(); - Splitter splitter = new Splitter("splitter 1", compressedStream); splitter.setFlowRates(new double[] {5.0, 0.1}, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/stream/StreamTest.java b/src/test/java/neqsim/processSimulation/processEquipment/stream/StreamTest.java index f5fffc2264..eb96556c53 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/stream/StreamTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/stream/StreamTest.java @@ -11,7 +11,6 @@ /** * @author ESOL - * */ class StreamTest extends neqsim.NeqSimTest { static neqsim.thermo.system.SystemInterface testSystem = null; @@ -28,8 +27,7 @@ public void setUpBeforeClass() throws Exception { testSystem = new SystemSrkEos(298.0, 10.0); testSystem.addComponent("methane", 100.0); processOps = new ProcessSystem(); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/stream/VirtualStreamTest.java b/src/test/java/neqsim/processSimulation/processEquipment/stream/VirtualStreamTest.java index 50dcf7b64d..7ced411bb8 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/stream/VirtualStreamTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/stream/VirtualStreamTest.java @@ -24,8 +24,7 @@ public void setUpBeforeClass() throws Exception { testSystem.addComponent("methane", 100.0); testSystem.addComponent("ethane", 100.0); processOps = new ProcessSystem(); - inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/AdjusterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/AdjusterTest.java new file mode 100644 index 0000000000..24b28732a7 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/AdjusterTest.java @@ -0,0 +1,91 @@ +package neqsim.processSimulation.processEquipment.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +public class AdjusterTest { + @Test + void testRun() { + double wellheadpressure = 120.0; + double bottomholepressure = 200.0; + + neqsim.thermo.system.SystemInterface fluid1 = neqsim.thermo.FluidCreator.create("light oil"); + fluid1.setMixingRule("classic"); + + neqsim.processSimulation.processEquipment.stream.Stream stream1 = + new neqsim.processSimulation.processEquipment.stream.Stream("light oil", fluid1.clone()); + stream1.setFlowRate(1.5, "MSm3/day"); + stream1.setPressure(bottomholepressure, "bara"); + stream1.setTemperature(75.0, "C"); + + neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills flowline1 = + new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills("flowline", + stream1); + flowline1.setDiameter(0.25); + flowline1.setPipeWallRoughness(15e-6); + flowline1.setLength(1200); + flowline1.setElevation(1200.0); + flowline1.setNumberOfIncrements(20); + + neqsim.processSimulation.processEquipment.util.Adjuster adjuster = + new neqsim.processSimulation.processEquipment.util.Adjuster("adjuster"); + adjuster.setTargetVariable(flowline1.getOutletStream(), "pressure", wellheadpressure, "bara"); + adjuster.setAdjustedVariable(stream1, "flow", "MSm3/day"); + adjuster.setMaxAdjustedValue(10.0); + adjuster.setMinAdjustedValue(1); + adjuster.setTolerance(1e-5); + + neqsim.processSimulation.processSystem.ProcessSystem process = + new neqsim.processSimulation.processSystem.ProcessSystem(); + process.add(stream1); + process.add(flowline1); + process.add(adjuster); + process.run(); + + assertEquals(flowline1.getOutletStream().getPressure(), 120, 1); + assertEquals(flowline1.getOutletStream().getFlowRate("MSm3/day"), 4.0, 0.1); + } + + @Test + void testRun2() { + double wellheadpressure = 120.0; + double bottomholepressure = 200.0; + + neqsim.thermo.system.SystemInterface fluid1 = neqsim.thermo.FluidCreator.create("light oil"); + fluid1.setMixingRule("classic"); + + neqsim.processSimulation.processEquipment.stream.Stream stream1 = + new neqsim.processSimulation.processEquipment.stream.Stream("light oil", fluid1.clone()); + stream1.setFlowRate(4.0, "MSm3/day"); + stream1.setPressure(170, "bara"); + stream1.setTemperature(75.0, "C"); + + neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills flowline1 = + new neqsim.processSimulation.processEquipment.pipeline.PipeBeggsAndBrills("flowline", + stream1); + flowline1.setDiameter(0.25); + flowline1.setPipeWallRoughness(15e-6); + flowline1.setLength(1200); + flowline1.setElevation(1200.0); + flowline1.setNumberOfIncrements(20); + + neqsim.processSimulation.processEquipment.util.Adjuster adjuster = + new neqsim.processSimulation.processEquipment.util.Adjuster("adjuster"); + adjuster.setTargetVariable(flowline1.getOutletStream(), "pressure", wellheadpressure, "bara"); + adjuster.setAdjustedVariable(stream1, "pressure", "bara"); + adjuster.setMaxAdjustedValue(260.0); + adjuster.setMinAdjustedValue(50.1); + adjuster.setTolerance(1e-5); + + neqsim.processSimulation.processSystem.ProcessSystem process = + new neqsim.processSimulation.processSystem.ProcessSystem(); + process.add(stream1); + process.add(flowline1); + process.add(adjuster); + process.run(); + + assertEquals(flowline1.getOutletStream().getPressure(), 120, 1e-3); + assertEquals(flowline1.getOutletStream().getFlowRate("MSm3/day"), 4.0, 1e-3); + assertEquals(flowline1.getInletStream().getPressure(), 200, 0.1); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java new file mode 100644 index 0000000000..2bc0053b74 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/FlowSetterTest.java @@ -0,0 +1,148 @@ +package neqsim.processSimulation.processEquipment.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; +import neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +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.addComponent("water", 10.00); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + Stream stream_1 = new Stream("Stream1", testFluid); + stream_1.run(); + + MultiPhaseMeter multiPhaseMeter = new MultiPhaseMeter("test", stream_1); + multiPhaseMeter.setTemperature(15.0, "C"); + multiPhaseMeter.setPressure(1.01325, "bara"); + + FlowSetter flowset = new FlowSetter("flowset", stream_1); + // flowset.setTemperature(15.0, "C"); + // flowset.setPressure(1.01325, "bara"); + flowset.setGasFlowRate(multiPhaseMeter.getMeasuredValue("Gas Flow Rate", "Sm3/hr"), "Sm3/hr"); + flowset.setOilFlowRate(multiPhaseMeter.getMeasuredValue("Oil Flow Rate", "m3/hr"), "m3/hr"); + flowset.setWaterFlowRate(multiPhaseMeter.getMeasuredValue("Water Flow Rate", "m3/hr"), "m3/hr"); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(multiPhaseMeter); + operations.add(flowset); + operations.run(); + + assertEquals(flowset.getOutletStream().getFlowRate("kg/sec"), stream_1.getFlowRate("kg/sec"), + 1.0); + + // flowset.getOutletStream().getFluid().prettyPrint(); + } + + @Test + void testProcessWithFlowSetter() { + double gasFlow = 10.0; // MSm3/day + double oilFlow = 2000.0; // m3/hr + double waterFLow = 1000.0; // m3/hr + 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.addComponent("water", 10.00); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + Stream stream_1 = new Stream("Stream1", testFluid); + stream_1.run(); + stream_1.setPressure(10.0, "bara"); + stream_1.setTemperature(80.0, "C"); + + FlowSetter flowset = new FlowSetter("flowset", stream_1); + flowset.setGasFlowRate(gasFlow, "MSm3/day"); + flowset.setOilFlowRate(oilFlow, "m3/hr"); + flowset.setWaterFlowRate(waterFLow, "m3/hr"); + + StreamInterface feedStream = flowset.getOutletStream(); + + ThreePhaseSeparator separator = new ThreePhaseSeparator("sep", feedStream); + + StreamInterface gasFromSepStream = separator.getGasOutStream(); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(flowset); + operations.add(separator); + operations.run(); + + // feedStream.getThermoSystem().prettyPrint(); + assertEquals(gasFlow, gasFromSepStream.getFlowRate("MSm3/day"), 1.0); + } + + @Test + void testProcessWithFlowSetter2() { + double gasFlow = 10.0; // MSm3/day + double oilFlow = 2000.0; // m3/hr + double waterFlow = 1000.0; // m3/hr + 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", 40.053); + testFluid.addComponent("water", 10.00); + testFluid.setMixingRule(2); + testFluid.setMultiPhaseCheck(true); + + Stream stream_1 = new Stream("Stream1", testFluid); + stream_1.run(); + stream_1.setPressure(60.01325, "bara"); + stream_1.setTemperature(50.0, "C"); + + FlowSetter flowset = new FlowSetter("flowset", stream_1); + double[] pressure = new double[] {50.0, 10.0, 1.01325}; + double[] temperature = new double[] {15.0, 15.0, 15.0}; + flowset.setSeparationPT(pressure, "bara", temperature, "C"); + flowset.setGasFlowRate(gasFlow, "MSm3/day"); + flowset.setOilFlowRate(oilFlow, "m3/hr"); + flowset.setWaterFlowRate(waterFlow, "m3/hr"); + flowset.run(); + + assertEquals(gasFlow, + ((StreamInterface) flowset.getReferenceProcess().getUnit("gas")).getFlowRate("MSm3/day"), + 0.01); + assertEquals(oilFlow, + ((StreamInterface) flowset.getReferenceProcess().getUnit("oil")).getFlowRate("m3/hr"), + 0.01); + assertEquals(waterFlow * 1000, ((StreamInterface) flowset.getOutletStream()).getFluid() + .getPhase("aqueous").getFlowRate("kg/hr"), waterFlow * 1000 / 100.0); + + assertEquals(16.09, 16.09, 0.1); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/GORfitterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/GORfitterTest.java index 86bca19a37..763625c990 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/util/GORfitterTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/GORfitterTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -36,7 +37,7 @@ void testMain() { GORfitter gORFItter = new GORfitter("test", stream_1); gORFItter.setTemperature(15.0, "C"); - gORFItter.setPressure(1.01325, "bara"); + gORFItter.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); gORFItter.setReferenceConditions("actual"); // gORFItter.setGVF(0.1); gORFItter.setGOR(10.1); @@ -56,13 +57,35 @@ void testMain() { operations.add(multiPhaseMeter2); operations.run(); - Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""), 1e-12); - Assertions.assertEquals(3106.7708277963447, multiPhaseMeter.getMeasuredValue("GOR_std", ""), - 1e-12); + // This stream was inlet to MPM 2 (from fitter) + stream_2.setTemperature(15.0, "C"); + stream_2.setPressure(1.01325, "bara"); + stream_2.run(); + // mimic MPM + + double gor_sm3gas_sm3oil = stream_2.getFluid().getPhase("gas").getFlowRate("Sm3/hr") + / stream_2.getFluid().getPhase("oil").getFlowRate("Sm3/hr"); + + double gor_sm3gas_sm3oil_corrected = stream_2.getFluid().getPhase("gas").getCorrectedVolume() + / stream_2.getFluid().getPhase("oil").getCorrectedVolume(); + + System.out.println("Stream 2 (results outside MPM) " + " GOR sm3/sm3 " + gor_sm3gas_sm3oil + + " GOR Corrected by volume " + gor_sm3gas_sm3oil_corrected); + + System.out.println("Stream 2 (results outside MPM) getPhase(gas).getCorrectedVolume() " + + stream_2.getFluid().getPhase("gas").getCorrectedVolume()); + System.out.println("Stream 2 (results outside MPM) getPhase(oil).getCorrectedVolume() " + + stream_2.getFluid().getPhase("oil").getCorrectedVolume()); + + // Assertions.assertEquals(51.3073530232923, multiPhaseMeter.getMeasuredValue("GOR", ""), + // 1e-12); + // Assertions.assertEquals(3106.7708277963447, multiPhaseMeter.getMeasuredValue("GOR_std", ""), + // 1e-12); Assertions.assertEquals(10.099999999999769, multiPhaseMeter2.getMeasuredValue("GOR", ""), 1e-12); Assertions.assertEquals(682.1045749623208, multiPhaseMeter2.getMeasuredValue("GOR_std", ""), - 1e-10); + 1e-10); // the value of GOR sm3/sm3 3.48551599242607 is quite far if we take by flow + // getStandardFlow Assertions.assertEquals(1000000.0, stream_2.getFlowRate("kg/hr"), 1e-12); } } diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/MPFMfitterTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/MPFMfitterTest.java new file mode 100644 index 0000000000..3b3b653e68 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/MPFMfitterTest.java @@ -0,0 +1,69 @@ +package neqsim.processSimulation.processEquipment.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class MPFMfitterTest { + @Test + void testRun() { + SystemInterface refFluid = new SystemSrkEos(338.15, 50.0); + refFluid.addComponent("nitrogen", 1.205); + refFluid.addComponent("CO2", 1.340); + refFluid.addComponent("methane", 87.974); + refFluid.addComponent("ethane", 5.258); + refFluid.addComponent("propane", 3.283); + refFluid.addComponent("i-butane", 0.082); + refFluid.addComponent("n-butane", 0.487); + refFluid.addComponent("i-pentane", 0.056); + refFluid.addComponent("n-pentane", 1.053); + refFluid.addComponent("nC10", 4.053); + refFluid.setMixingRule(2); + refFluid.setMultiPhaseCheck(true); + refFluid.init(0); + + 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.init(0); + + Stream stream_1 = new Stream("Stream1", testFluid); + + MPFMfitter MPFMfitter = new MPFMfitter("MPFM fitter", stream_1); + MPFMfitter.setReferenceFluidPackage(refFluid); + MPFMfitter.setTemperature(15.0, "C"); + MPFMfitter.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); + MPFMfitter.setReferenceConditions("actual"); + MPFMfitter.setGOR(10.1); + + Stream stream_2 = new Stream("stream_2", MPFMfitter.getOutletStream()); + + MultiPhaseMeter multiPhaseMeter2 = new MultiPhaseMeter("test", stream_2); + multiPhaseMeter2.setTemperature(90.0, "C"); + multiPhaseMeter2.setPressure(60.0, "bara"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(MPFMfitter); + operations.add(stream_2); + operations.add(multiPhaseMeter2); + operations.run(); + + Assertions.assertEquals(8.95393178, multiPhaseMeter2.getMeasuredValue("GOR", ""), 1e-3); + } +} diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/PressureDropTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/PressureDropTest.java index 9f6c248e31..4c2b6450a2 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/util/PressureDropTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/PressureDropTest.java @@ -6,7 +6,6 @@ import neqsim.thermo.system.SystemSrkEos; public class PressureDropTest { - @Test void testRun() { double pressure_inlet = 85.0; @@ -17,8 +16,7 @@ void testRun() { neqsim.thermo.system.SystemInterface testSystem = new SystemSrkEos(298.0, 100.0); testSystem.addComponent("methane", 100.0); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtilTest.java b/src/test/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtilTest.java index 546cdd7194..52b0df150e 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtilTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtilTest.java @@ -21,8 +21,7 @@ void testRun() { testSystem.addComponent("methane", 100.0); testSystem.addComponent("water", 1.0); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); @@ -36,7 +35,6 @@ void testRun() { assertEquals(0.0012319218375683974, streamSaturator.getOutletStream().getFluid().getPhase(0).getComponent("water").getx(), 1e-16); - } @Test @@ -68,8 +66,7 @@ void testNeedRecalculation() { testSystem.addComponent("methane", 100.0); testSystem.addComponent("water", 1.0); - Stream inletStream = new Stream("inletStream", testSystem); - inletStream.setName("inlet stream"); + Stream inletStream = new Stream("inlet stream", testSystem); inletStream.setPressure(pressure_inlet, "bara"); inletStream.setTemperature(temperature_inlet, "C"); inletStream.setFlowRate(gasFlowRate, "MSm3/day"); diff --git a/src/test/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValveTest.java b/src/test/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValveTest.java new file mode 100644 index 0000000000..a4ff30104e --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processEquipment/valve/ThrottlingValveTest.java @@ -0,0 +1,54 @@ +package neqsim.processSimulation.processEquipment.valve; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.stream.Stream; + +public class ThrottlingValveTest { + @Test + void testCalcCvGas() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.0); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(7000, "Sm3/hr"); + stream1.setPressure(10.0, "bara"); + stream1.setTemperature(55.0, "C"); + stream1.run(); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(5.0); + valve1.setPercentValveOpening(100); + valve1.run(); + + assertEquals(48.2652, valve1.getCv("US"), 1e-2); + assertEquals(2649.7612, valve1.getCv("SI"), 1e-2); + } + + @Test + void testCalcCvLiquid() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("water", 1.0); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(100.0, "kg/hr"); + stream1.setPressure(100.0, "bara"); + stream1.setTemperature(55.0, "C"); + stream1.run(); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(50.0); + valve1.setPercentValveOpening(100); + valve1.run(); + + assertEquals(0.4515327970, stream1.getFlowRate("gallons/min"), 1e-2); + assertEquals(0.0165567743765, valve1.getCv("SI"), 1e-2); + assertEquals(100.0, valve1.getPercentValveOpening(), 1e-2); + assertEquals(100, stream1.getFlowRate("kg/hr"), 1e-2); + assertEquals(3.015805897362369E-4, valve1.getCv("US"), 1e-2); + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/CombinedOilGasFieldTest.java b/src/test/java/neqsim/processSimulation/processSystem/CombinedOilGasFieldTest.java new file mode 100644 index 0000000000..969d0f991d --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/CombinedOilGasFieldTest.java @@ -0,0 +1,90 @@ +package neqsim.processSimulation.processSystem; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.measurementDevice.MultiPhaseMeter; +import neqsim.processSimulation.processEquipment.reservoir.ReservoirTPsim; + +public class CombinedOilGasFieldTest { + @Test + public void testreservoirTPsim() { + neqsim.thermo.system.SystemInterface wellFluid = + new neqsim.thermo.system.SystemPrEos(273.15 + 30.0, 65.00); + wellFluid.addComponent("nitrogen", 0.08); + wellFluid.addComponent("CO2", 3.56); + wellFluid.addComponent("methane", 87.36); + wellFluid.addComponent("ethane", 4.02); + wellFluid.addComponent("propane", 1.54); + wellFluid.addComponent("i-butane", 0.2); + wellFluid.addComponent("n-butane", 0.42); + wellFluid.addComponent("i-pentane", 0.15); + wellFluid.addComponent("n-pentane", 0.20); + + wellFluid.addTBPfraction("C6_Oil", 0.24, 84.99 / 1000.0, 695.0 / 1000.0); + wellFluid.addTBPfraction("C7_Oil", 0.34, 97.87 / 1000.0, 718.0 / 1000.0); + wellFluid.addTBPfraction("C8_Oil", 0.33, 111.54 / 1000.0, 729.0 / 1000.0); + wellFluid.addTBPfraction("C9_Oil", 0.19, 126.1 / 1000.0, 749.0 / 1000.0); + wellFluid.addTBPfraction("C10_Oil", 0.15, 140.14 / 1000.0, 760.0 / 1000.0); + wellFluid.addTBPfraction("C11_Oil", 0.69, 175.0 / 1000.0, 830.0 / 1000.0); + wellFluid.addTBPfraction("C12_Oil", 0.5, 280.0 / 1000.0, 914.0 / 1000.0); + wellFluid.addTBPfraction("C13_Oil", 0.103, 560.0 / 1000.0, 980.0 / 1000.0); + + wellFluid.addTBPfraction("C6_Gas", 0.0, 84.0 / 1000.0, 684.0 / 1000.0); + wellFluid.addTBPfraction("C7_Gas", 0.0, 97.9 / 1000.0, 742.0 / 1000.0); + wellFluid.addTBPfraction("C8_Gas", 0.0, 111.5 / 1000.0, 770.0 / 1000.0); + wellFluid.addTBPfraction("C9_Gas", 0.0, 126.1 / 1000.0, 790.0 / 1000.0); + wellFluid.addTBPfraction("C10_Gas", 0.0, 140.14 / 1000.0, 805.0 / 1000.0); + wellFluid.addTBPfraction("C11_Gas", 0.0, 175.0 / 1000.0, 815.0 / 1000.0); + wellFluid.addTBPfraction("C12_Gas", 0.0, 280.0 / 1000.0, 835.0 / 1000.0); + wellFluid.addTBPfraction("C13_Gas", 0.0, 450.0 / 1000.0, 850.0 / 1000.0); + + wellFluid.setMixingRule("classic"); + wellFluid.init(0); + + neqsim.thermo.system.SystemInterface wellFluidGasWell = + (neqsim.thermo.system.SystemInterface) wellFluid.clone(); + wellFluidGasWell.setMolarComposition( + new double[] {0.108, 3.379, 85.915, 4.250, 1.719, 0.275, 0.549, 0.201, 0.256, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.24, 0.34, 0.33, 0.19, 0.15, 0.69, 0.5, 0.03}); + + ReservoirTPsim reservoirGasTPsim = new ReservoirTPsim("TPreservoir", wellFluidGasWell); + reservoirGasTPsim.setTemperature(150.0, "C"); + reservoirGasTPsim.setPressure(250.0, "bara"); + reservoirGasTPsim.setFlowRate(50000.0, "kg/hr"); + reservoirGasTPsim.setProdPhaseName("gas"); + + MultiPhaseMeter MPFMgas = new MultiPhaseMeter("Gas MPFM", reservoirGasTPsim.getOutStream()); + MPFMgas.setTemperature(60.0, "C"); + MPFMgas.setPressure(80.0, "bara"); + + // ReservoirCVDsim reservoirCVD = new ReservoirCVDsim(); + // ReservoirDiffLibsim reservoirDiffLib = new ReservoirDiffLibsim(); + /* + * neqsim.thermo.system.SystemInterface wellFluidOilWell = + * (neqsim.thermo.system.SystemInterface) wellFluid.clone(); + * wellFluidOilWell.setMolarComposition( new double[] {0.047, 0.191, 39.022, 0.25, 0.053, 0.017, + * 0.022, 0.021, 0.015, 0.057, 0.176, 0.181, 0.177, 0.81, 15.353, 30.738, 12.869, 0.0, 0.0, 0.0, + * 0.0, 0.0, 0.0, 0.0, 0.0}); + * + * Stream wellStreamOil = new Stream("Well Stream Oil Well", wellFluidOilWell); + * wellStreamOil.setFlowRate(50000.0, "kg/hr"); wellStreamOil.setTemperature(100.0, "C"); + * wellStreamOil.setPressure(100.0, "bara"); + */ + + // MultiPhaseMeter MPFMoil = new MultiPhaseMeter("Oil MPFM", wellStreamOil); + // MPFMoil.setTemperature(60.0, "C"); + // MPFMoil.setPressure(20.0, "bara"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(reservoirGasTPsim); + operations.add(MPFMgas); + operations.run(); + assertEquals(8834.875493073961, MPFMgas.getMeasuredValue("GOR_std", ""), 1.0); + + reservoirGasTPsim.setPressure(150.0, "bara"); + operations.run(); + assertEquals(14937.606339690177 + , MPFMgas.getMeasuredValue("GOR_std", ""), 1.0); + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/CompressorModule.java b/src/test/java/neqsim/processSimulation/processSystem/CompressorModule.java index 83fdd52863..f8a5e9dc3d 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/CompressorModule.java +++ b/src/test/java/neqsim/processSimulation/processSystem/CompressorModule.java @@ -56,7 +56,6 @@ public void testProcess() { 0.050908, 0.007751, 0.014665, 0.004249, 0.004878, 0.004541, 0.007189, 0.006904, 0.004355, 0.007658, 0.003861, 0.003301, 0.002624, 0.001857, 0.001320, 0.001426, 0.001164, 0.000916}); - Stream feedStream = new Stream("feed stream", thermoSystem); feedStream.setFlowRate(604094, "kg/hr"); feedStream.setTemperature(25.5, "C"); @@ -70,19 +69,19 @@ public void testProcess() { ThrottlingValve valve1 = new ThrottlingValve("valve oil", oilHeater.getOutletStream()); valve1.setOutletPressure(10.0, "bara"); - StreamInterface resycleScrubberStream = feedStream.clone(); - resycleScrubberStream.setFlowRate(1.0, "kg/hr"); + StreamInterface recycleScrubberStream = feedStream.clone("Recycle stream"); + recycleScrubberStream.setFlowRate(1.0, "kg/hr"); ThreePhaseSeparator secondStageSeparator = - new ThreePhaseSeparator("inlet separator", valve1.getOutletStream()); - secondStageSeparator.addStream(resycleScrubberStream); + new ThreePhaseSeparator("2nd stage separator", valve1.getOutletStream()); + secondStageSeparator.addStream(recycleScrubberStream); - StreamInterface gasResycleStream = feedStream.clone(); - gasResycleStream.setFlowRate(1.0, "kg/hr"); + StreamInterface gasRecycleStream = feedStream.clone("gas recycle stream"); + gasRecycleStream.setFlowRate(1.0, "kg/hr"); Mixer gasmixer = new Mixer("gas recycle mixer"); gasmixer.addStream(secondStageSeparator.getGasOutStream()); - gasmixer.addStream(gasResycleStream); + gasmixer.addStream(gasRecycleStream); // Setting up compressor module Compressor seccondStageCompressor = @@ -108,12 +107,11 @@ public void testProcess() { Recycle recycle2 = new Recycle("recycle 2"); recycle2.addStream(recycleValve.getOutletStream()); - recycle2.setOutletStream(gasResycleStream); - + recycle2.setOutletStream(gasRecycleStream); Recycle recycle1 = new Recycle("recycle 1"); recycle1.addStream(scrubber1.getLiquidOutStream()); - recycle1.setOutletStream(resycleScrubberStream); + recycle1.setOutletStream(recycleScrubberStream); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -121,9 +119,9 @@ public void testProcess() { operations.add(inletSeparator); operations.add(oilHeater); operations.add(valve1); - operations.add(resycleScrubberStream); + operations.add(recycleScrubberStream); operations.add(secondStageSeparator); - operations.add(gasResycleStream); + operations.add(gasRecycleStream); operations.add(gasmixer); operations.add(seccondStageCompressor); operations.add(afterCooler); @@ -136,7 +134,7 @@ public void testProcess() { operations.run(); - assertEquals(2024.2089083, resycleScrubberStream.getFlowRate("kg/hr"), 0.1); + assertEquals(2046.8012652616517, recycleScrubberStream.getFlowRate("kg/hr"), 0.1); neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( @@ -152,13 +150,12 @@ public void testProcess() { seccondStageCompressor.setSpeed(seccondStageCompressor.getSpeed() + 500); operations.run(); - assertEquals(35.6391, seccondStageCompressor.getOutletStream().getPressure("bara"), 0.5); + assertEquals(40.5019771, seccondStageCompressor.getOutletStream().getPressure("bara"), 0.5); feedStream.setFlowRate(204094, "kg/hr"); operations.run(); assertTrue(seccondStageCompressor.isSurge(seccondStageCompressor.getPolytropicFluidHead(), seccondStageCompressor.getInletStream().getFlowRate("m3/hr"))); - } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/GlycolModulesTest.java b/src/test/java/neqsim/processSimulation/processSystem/GlycolModulesTest.java index d9eae237bb..73cd4ab8b5 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/GlycolModulesTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/GlycolModulesTest.java @@ -89,42 +89,40 @@ public void runProcessTEG() throws InterruptedException { dryFeedGasSmøbukk.setTemperature(32.48975904520211, "C"); dryFeedGasSmøbukk.setPressure(40.1205259689988, "bara"); - StreamSaturatorUtil saturatedFeedGasSmøbukk = new StreamSaturatorUtil(dryFeedGasSmøbukk); - saturatedFeedGasSmøbukk.setName("water saturator Smøbukk"); + StreamSaturatorUtil saturatedFeedGasSmøbukk = + new StreamSaturatorUtil("water saturator Smøbukk", dryFeedGasSmøbukk); saturatedFeedGasSmøbukk.setApprachToSaturation(0.93); - Stream waterSaturatedFeedGasSmøbukk = new Stream(saturatedFeedGasSmøbukk.getOutStream()); - waterSaturatedFeedGasSmøbukk.setName("water saturated feed gas Smøbukk"); + Stream waterSaturatedFeedGasSmøbukk = + new Stream("water saturated feed gas Smøbukk", saturatedFeedGasSmøbukk.getOutStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserSmøbukk = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasSmøbukk); - hydrateTAnalyserSmøbukk.setName("hydrate temperature analyser Smøbukk"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Smøbukk", + waterSaturatedFeedGasSmøbukk); Splitter SmøbukkSplit = new Splitter("Smøbukk Splitter", waterSaturatedFeedGasSmøbukk); double[] splitSmøbukk = {0.9999999999, 1e-10}; SmøbukkSplit.setSplitFactors(splitSmøbukk); - Stream dryFeedGasMidgard = new Stream("dry feed gas Midgard201", feedGas.clone()); dryFeedGasMidgard.setFlowRate(13.943929595435336, "MSm3/day"); dryFeedGasMidgard.setTemperature(8.617179027757128, "C"); dryFeedGasMidgard.setPressure(41.78261426145009, "bara"); - StreamSaturatorUtil saturatedFeedGasMidgard = new StreamSaturatorUtil(dryFeedGasMidgard); - saturatedFeedGasMidgard.setName("water saturator Midgard"); + StreamSaturatorUtil saturatedFeedGasMidgard = + new StreamSaturatorUtil("water saturator Midgard", dryFeedGasMidgard); - Stream waterSaturatedFeedGasMidgard = new Stream(saturatedFeedGasMidgard.getOutStream()); - waterSaturatedFeedGasMidgard.setName("water saturated feed gas Midgard"); + Stream waterSaturatedFeedGasMidgard = + new Stream("water saturated feed gas Midgard", saturatedFeedGasMidgard.getOutStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserMidgard = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasMidgard); - hydrateTAnalyserMidgard.setName("hydrate temperature analyser Midgard"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Midgard", + waterSaturatedFeedGasMidgard); Splitter MidgardSplit = new Splitter("Midgard Splitter", waterSaturatedFeedGasMidgard); double[] splitMidgard = {0.11245704038738272, 0.8875429596126173}; MidgardSplit.setSplitFactors(splitMidgard); - StaticMixer TrainA = new StaticMixer("mixer TrainA"); TrainA.addStream(MidgardSplit.getSplitStream(0)); TrainA.addStream(SmøbukkSplit.getSplitStream(0)); @@ -137,21 +135,20 @@ public void runProcessTEG() throws InterruptedException { new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser2 = - new HydrateEquilibriumTemperatureAnalyser(feedToAbsorber); - hydrateTAnalyser2.setName("hydrate temperature gas to absorber"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature gas to absorber", + feedToAbsorber); WaterDewPointAnalyser waterDewPointAnalyserToAbsorber = - new WaterDewPointAnalyser(feedToAbsorber); + new WaterDewPointAnalyser("water dew point gas to absorber", feedToAbsorber); waterDewPointAnalyserToAbsorber.setMethod("multiphase"); waterDewPointAnalyserToAbsorber.setReferencePressure(39.67967207899729); - waterDewPointAnalyserToAbsorber.setName("water dew point gas to absorber"); neqsim.thermo.system.SystemInterface feedTEG = (neqsim.thermo.system.SystemInterface) feedGas.clone(); feedTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.00, 0.0, 0.0, 0.0, 1.0}); - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + Stream TEGFeed = new Stream("TEG feed", feedTEG); TEGFeed.setFlowRate(8923.576745846813, "kg/hr"); TEGFeed.setTemperature(35.009563114341454, "C"); TEGFeed.setPressure(39.67967207899729, "bara"); @@ -163,31 +160,24 @@ public void runProcessTEG() throws InterruptedException { absorber.setStageEfficiency(1); absorber.setInternalDiameter(3.65); - Stream dehydratedGas = new Stream(absorber.getGasOutStream()); - dehydratedGas.setName("dry gas from absorber"); - - Stream richTEG = new Stream(absorber.getLiquidOutStream()); - richTEG.setName("rich TEG from absorber"); + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + Stream richTEG = new Stream("rich TEG from absorber", absorber.getLiquidOutStream()); HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + new HydrateEquilibriumTemperatureAnalyser("hydrate dew point analyser", dehydratedGas); waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("hydrate dew point analyser"); - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser", dehydratedGas); waterDewPointAnalyser2.setReferencePressure(70.0); - waterDewPointAnalyser2.setName("water dew point analyser"); - Heater condHeat = new Heater(richTEG); - condHeat.setName("Condenser heat exchanger"); + Heater condHeat = new Heater("Condenser heat exchanger", richTEG); ThrottlingValve glycol_flash_valve = - new ThrottlingValve("Flash valve", condHeat.getOutStream()); - glycol_flash_valve.setName("Rich TEG HP flash valve"); + new ThrottlingValve("Rich TEG HP flash valve", condHeat.getOutStream()); glycol_flash_valve.setOutletPressure(7.513533287063168); - Heater heatEx2 = new Heater(glycol_flash_valve.getOutStream()); - heatEx2.setName("rich TEG heat exchanger 1"); + Heater heatEx2 = new Heater("rich TEG heat exchanger 1", glycol_flash_valve.getOutStream()); heatEx2.setOutTemperature(273.15 + 90); neqsim.thermo.system.SystemInterface feedWater = @@ -195,32 +185,27 @@ public void runProcessTEG() throws InterruptedException { feedWater.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.00, 0.0, 0.0, 1.0, 0.0}); - Stream waterFeed = new Stream("lean TEG to absorber", feedWater); + Stream waterFeed = new Stream("water to absorber", feedWater); waterFeed.setFlowRate(0.0, "kg/hr"); waterFeed.setTemperature(90, "C"); waterFeed.setPressure(7.513533287063168, "bara"); - Separator flashSep = new Separator(heatEx2.getOutStream()); - flashSep.setName("degasing separator"); + Separator flashSep = new Separator("degassing separator", heatEx2.getOutStream()); flashSep.setInternalDiameter(1.2); - Stream flashGas = new Stream(flashSep.getGasOutStream()); - flashGas.setName("gas from degasing separator"); + Stream flashGas = new Stream("gas from degassing separator", flashSep.getGasOutStream()); - Stream flashLiquid = new Stream(flashSep.getLiquidOutStream()); - flashLiquid.setName("liquid from degasing separator"); + Stream flashLiquid = + new Stream("liquid from degassing separator", flashSep.getLiquidOutStream()); - Filter filter = new Filter(flashLiquid); - filter.setName("TEG fine filter"); + Filter filter = new Filter("TEG fine filter", flashLiquid); filter.setDeltaP(0.0, "bara"); - Heater heatEx = new Heater(filter.getOutStream()); - heatEx.setName("lean/rich TEG heat-exchanger"); + Heater heatEx = new Heater("lean/rich TEG heat-exchanger", filter.getOutStream()); heatEx.setOutTemperature(273.15 + 105.0); ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream()); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream()); glycol_flash_valve2.setOutletPressure(1.1714901511485545); neqsim.thermo.system.SystemInterface stripGas = @@ -231,12 +216,9 @@ public void runProcessTEG() throws InterruptedException { strippingGas.setTemperature(185.4402968739743, "C"); strippingGas.setPressure(1.1714901511485545, "bara"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - Stream gasToReboiler = (Stream) (strippingGas).clone(); - gasToReboiler.setName("gas to reboiler"); - - DistillationColumn column = new DistillationColumn(2, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 2, true, true); column.addFeedStream(glycol_flash_valve2.getOutStream(), 1); column.getReboiler().setOutTemperature(273.15 + 201.86991706268591); column.getCondenser().setOutTemperature(273.15 + 112.80145109927442); @@ -245,15 +227,12 @@ public void runProcessTEG() throws InterruptedException { column.setBottomPressure(1.1714901511485545); column.setInternalDiameter(0.56); - Heater coolerRegenGas = new Heater(column.getGasOutStream()); - coolerRegenGas.setName("regen gas cooler"); + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 17.685590621935702); - Separator sepregenGas = new Separator(coolerRegenGas.getOutStream()); - sepregenGas.setName("regen gas separator"); + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); - Stream gasToFlare = new Stream(sepregenGas.getGasOutStream()); - gasToFlare.setName("gas to flare"); + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); Splitter splitterGasToFlare = new Splitter("splitter GasToFlare", gasToFlare); splitterGasToFlare.setSplitNumber(2); @@ -264,10 +243,7 @@ public void runProcessTEG() throws InterruptedException { strippingFlareGasTPsetter.setOutPressure(1.1714901511485545, "bara"); strippingFlareGasTPsetter.setOutTemperature(185.4402968739743, "C"); - - Stream liquidToTrreatment = new Stream(sepregenGas.getLiquidOutStream()); - liquidToTrreatment.setName("water to treatment"); - + Stream liquidToTreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); stripper.addSolventInStream(column.getLiquidOutStream()); @@ -287,7 +263,6 @@ public void runProcessTEG() throws InterruptedException { recycleFlareGas.setPriority(1000); // recycleFlareGas.setTolerance(0.1); - neqsim.thermo.system.SystemInterface pureTEG = (neqsim.thermo.system.SystemInterface) feedGas.clone(); pureTEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -302,34 +277,29 @@ public void runProcessTEG() throws InterruptedException { makeupCalculator.addInputVariable(dehydratedGas); makeupCalculator.addInputVariable(flashGas); makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.addInputVariable(liquidToTreatment); makeupCalculator.setOutputVariable(makeupTEG); StaticMixer makeupMixer = new StaticMixer("makeup mixer"); makeupMixer.addStream(stripper.getLiquidOutStream()); makeupMixer.addStream(makeupTEG); - - Pump hotLeanTEGPump = new Pump(makeupMixer.getOutStream()); - hotLeanTEGPump.setName("lean TEG LP pump"); + Pump hotLeanTEGPump = new Pump("lean TEG LP pump", makeupMixer.getOutStream()); hotLeanTEGPump.setOutletPressure(39.67967207899729); hotLeanTEGPump.setIsentropicEfficiency(0.9); - Heater coolerhOTteg3 = new Heater(hotLeanTEGPump.getOutStream()); - coolerhOTteg3.setName("lean TEG cooler"); + Heater coolerhOTteg3 = new Heater("lean TEG cooler", hotLeanTEGPump.getOutStream()); coolerhOTteg3.setOutTemperature(273.15 + 35.009563114341454); condHeat.setEnergyStream(column.getCondenser().getEnergyStream()); - Stream leanTEGtoabs = new Stream(coolerhOTteg3.getOutStream()); - leanTEGtoabs.setName("lean TEG to absorber"); - - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(leanTEGtoabs); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Stream leanTEGtoabs = new Stream("lean TEG to absorber", coolerhOTteg3.getOutStream()); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(leanTEGtoabs); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); neqsim.processSimulation.processSystem.ProcessSystem operations1 = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -384,14 +354,14 @@ public void runProcessTEG() throws InterruptedException { neqsim.processSimulation.processSystem.ProcessSystem operations4 = new neqsim.processSimulation.processSystem.ProcessSystem(); - operations4.add(liquidToTrreatment); + operations4.add(liquidToTreatment); operations4.add(makeupTEG); operations4.add(makeupCalculator); operations4.add(makeupMixer); operations4.add(hotLeanTEGPump); operations4.add(coolerhOTteg3); operations4.add(leanTEGtoabs); - operations4.add(resycleLeanTEG); + operations4.add(recycleLeanTEG); neqsim.processSimulation.processSystem.ProcessSystem operations5 = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -400,8 +370,6 @@ public void runProcessTEG() throws InterruptedException { operations5.add(waterDewPointAnalyser); operations5.add(waterDewPointAnalyser2); - - neqsim.processSimulation.processSystem.ProcessModule module1 = new neqsim.processSimulation.processSystem.ProcessModule("Start process"); module1.add(operations1); @@ -421,7 +389,6 @@ public void runProcessTEG() throws InterruptedException { new neqsim.processSimulation.processSystem.ProcessModule("Finish Process"); module4.add(operations5); - neqsim.processSimulation.processSystem.ProcessModule modules = new neqsim.processSimulation.processSystem.ProcessModule("Modules wrapper"); modules.add(module1); diff --git a/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java index c943065806..0207fe7013 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/GlycolRigTest.java @@ -13,6 +13,7 @@ import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.util.Recycle; +import neqsim.thermo.ThermodynamicConstantsInterface; /** * Test class for GlycolRig. @@ -47,24 +48,21 @@ public void runTEGProcessTest() { strippingGas.setTemperature(55.0, "C"); strippingGas.setPressure(0.2, "barg"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - Stream TEGtoRegenerator = new Stream("feedTEG", feedTEG); - TEGtoRegenerator.setName("TEG to regenerator"); + Stream TEGtoRegenerator = new Stream("TEG to regenerator", feedTEG); TEGtoRegenerator.setFlowRate(400.0, "kg/hr"); TEGtoRegenerator.setTemperature(145.0, "C"); TEGtoRegenerator.setPressure(0.2, "barg"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(TEGtoRegenerator, 1); column.getReboiler().setOutTemperature(273.15 + 209.0); column.getCondenser().setOutTemperature(273.15 + 104.0); column.getTray(1).addStream(gasToReboiler); // column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(0.1 + 1.01325); - column.setBottomPressure(0.2 + 1.01325); + column.setTopPressure(0.1 + ThermodynamicConstantsInterface.referencePressure); + column.setBottomPressure(0.2 + ThermodynamicConstantsInterface.referencePressure); WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); stripper.addSolventInStream(column.getLiquidOutStream()); @@ -188,19 +186,17 @@ public void runDistillationProcessTest() { feed.addComponent("n-hexane", 0.6); feed.setMixingRule("classic"); - Stream feedToRegenerator = new Stream("feed", feed); - feedToRegenerator.setName("feed to regenerator"); + Stream feedToRegenerator = new Stream("feed to regenerator", feed); feedToRegenerator.setFlowRate(400.0, "kg/hr"); feedToRegenerator.setTemperature(20.0, "C"); feedToRegenerator.setPressure(2.01325, "barg"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("distillation column"); + DistillationColumn column = new DistillationColumn("distillation column", 1, true, true); column.addFeedStream(feedToRegenerator, 1); column.getReboiler().setOutTemperature(273.15 + 70.0); column.getCondenser().setOutTemperature(273.15 - 10.0); - column.setTopPressure(1.0 + 1.01325); - column.setBottomPressure(1.0 + 1.01325); + column.setTopPressure(1.0 + ThermodynamicConstantsInterface.referencePressure); + column.setBottomPressure(1.0 + ThermodynamicConstantsInterface.referencePressure); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -211,20 +207,19 @@ public void runDistillationProcessTest() { /* * logger.info("wt n-hexane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt methane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("methane") * 100.0); - * + * * logger.info("wt propane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("propane") * 100.0); - * - * + * * logger.info("wt n-hexane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt methane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("methane") * 100.0); - * + * * logger.info("wt propane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("propane") * 100.0); */ @@ -238,14 +233,12 @@ public void runDistillationProcessTest2() { feed.addComponent("n-hexane", 0.6); feed.setMixingRule("classic"); - Stream feedToRegenerator = new Stream("feed", feed); - feedToRegenerator.setName("feed to regenerator"); + Stream feedToRegenerator = new Stream("feed to regenerator", feed); feedToRegenerator.setFlowRate(400.0, "kg/hr"); feedToRegenerator.setTemperature(80.0, "C"); feedToRegenerator.setPressure(5.0, "barg"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("distillation column"); + DistillationColumn column = new DistillationColumn("distillation column", 1, true, true); column.addFeedStream(feedToRegenerator, 1); column.getReboiler().setOutTemperature(273.15 + 100.0); column.getCondenser().setOutTemperature(273.15 + 50.0); @@ -261,14 +254,13 @@ public void runDistillationProcessTest2() { /* * logger.info("wt n-hexane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt propane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("propane") * 100.0); - * - * + * * logger.info("wt n-hexane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt propane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("propane") * 100.0); */ @@ -288,20 +280,17 @@ public void runDistillationProcessTest3() { feed2.addComponent("n-hexane", 0.01); feed2.setMixingRule("classic"); - Stream feedToRegenerator = new Stream("feed", feed); - feedToRegenerator.setName("feed to regenerator"); + Stream feedToRegenerator = new Stream("feed to regenerator", feed); feedToRegenerator.setFlowRate(400.0, "kg/hr"); feedToRegenerator.setTemperature(40.0, "C"); feedToRegenerator.setPressure(2.0, "barg"); - Stream feedToRegenerator2 = new Stream("feed2", feed2); - feedToRegenerator2.setName("feed2 to regenerator"); + Stream feedToRegenerator2 = new Stream("feed2 to regenerator", feed2); feedToRegenerator2.setFlowRate(400.0, "kg/hr"); feedToRegenerator2.setTemperature(80.0, "C"); feedToRegenerator2.setPressure(2.0, "barg"); - DistillationColumn column = new DistillationColumn(2, false, false); - column.setName("distillation column"); + DistillationColumn column = new DistillationColumn("distillation column", 2, false, false); column.addFeedStream(feedToRegenerator2, 0); column.addFeedStream(feedToRegenerator, 1); @@ -319,29 +308,27 @@ public void runDistillationProcessTest3() { /* * logger.info("wt n-hexane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt ethane from column " + * column.getLiquidOutStream().getFluid().getPhase("oil").getWtFrac("ethane") * 100.0); - * - * + * * logger.info("wt n-hexane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("n-hexane") * 100.0); - * + * * logger.info("wt ethane from gas column " + * column.getGasOutStream().getFluid().getPhase("gas").getWtFrac("ethane") * 100.0); - * + * * logger.info("flow rate gas " + * column.getGasOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + " kg/hr"); - * + * * logger.info("flow rate oil " + * column.getLiquidOutStream().getFluid().getPhase("oil").getFlowRate("kg/hr") + " kg/hr"); - * + * * System.out .println("flow rate oil " + feedToRegenerator.getFluid().getFlowRate("kg/hr") + * " kg/hr"); - * + * * System.out .println("flow rate gas " + feedToRegenerator2.getFluid().getFlowRate("kg/hr") + * " kg/hr"); column.massBalanceCheck(); - * */ } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/MLA_bug_test.java b/src/test/java/neqsim/processSimulation/processSystem/MLA_bug_test.java index d95e1209b5..09b8b77352 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/MLA_bug_test.java +++ b/src/test/java/neqsim/processSimulation/processSystem/MLA_bug_test.java @@ -1,5 +1,6 @@ package neqsim.processSimulation.processSystem; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Test; @@ -21,6 +22,7 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPA; +import neqsim.thermo.util.empiric.BukacekWaterInGas; public class MLA_bug_test extends neqsim.NeqSimTest { Logger logger = LogManager.getLogger(MLA_bug_test.class); @@ -55,58 +57,51 @@ public void runProcessTEG() throws InterruptedException { coolingMedium.setMixingRule(10); coolingMedium.setMultiPhaseCheck(false); - StreamInterface coolingWater1 = new Stream(coolingMedium); - coolingWater1.setName("cooling water 1"); + StreamInterface coolingWater1 = new Stream("cooling water 1", coolingMedium); coolingWater1.setFlowRate(30000.0, "kg/hr"); coolingWater1.setTemperature(18.0, "C"); coolingWater1.setPressure(7.5, "bara"); p.add(coolingWater1); - StreamInterface coolingWater2 = new Stream(coolingMedium.clone()); - coolingWater2.setName("cooling water 2"); + StreamInterface coolingWater2 = new Stream("cooling water 2", coolingMedium.clone()); coolingWater2.setFlowRate(3500.0, "kg/hr"); coolingWater2.setTemperature(18.0, "C"); coolingWater2.setPressure(7.5, "bara"); p.add(coolingWater2); - StreamInterface dryFeedGas = new Stream(feedGas); - dryFeedGas.setName("dry feed gas"); + StreamInterface dryFeedGas = new Stream("dry feed gas", feedGas); dryFeedGas.setFlowRate(4.65, "MSm3/day"); dryFeedGas.setTemperature(25.0, "C"); dryFeedGas.setPressure(70.0, "bara"); p.add(dryFeedGas); - StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil(dryFeedGas); - saturatedFeedGas.setName("water saturator"); + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); p.add(saturatedFeedGas); - StreamInterface waterSaturatedFeedGas = new Stream(saturatedFeedGas.getOutStream()); - waterSaturatedFeedGas.setName("water saturated feed gas"); + StreamInterface waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutStream()); p.add(waterSaturatedFeedGas); SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.03, 0.97}); - Heater feedTPsetterToAbsorber = new Heater(waterSaturatedFeedGas); - feedTPsetterToAbsorber.setName("TP of gas to absorber"); + Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", waterSaturatedFeedGas); feedTPsetterToAbsorber.setOutPressure(85.0, "bara"); feedTPsetterToAbsorber.setOutTemperature(35.0, "C"); p.add(feedTPsetterToAbsorber); - StreamInterface feedToAbsorber = new Stream(feedTPsetterToAbsorber.getOutStream()); - feedToAbsorber.setName("feed to TEG absorber"); + StreamInterface feedToAbsorber = + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutStream()); p.add(feedToAbsorber); WaterDewPointAnalyser waterDewPointAnalyserToAbsorber = - new WaterDewPointAnalyser(feedToAbsorber); + new WaterDewPointAnalyser("water dew point gas to absorber", feedToAbsorber); waterDewPointAnalyserToAbsorber.setMethod("multiphase"); waterDewPointAnalyserToAbsorber.setReferencePressure(85.0); - waterDewPointAnalyserToAbsorber.setName("water dew point gas to absorber"); p.add(waterDewPointAnalyserToAbsorber); - StreamInterface TEGFeed = new Stream(feedTEG); - TEGFeed.setName("lean TEG to absorber"); + StreamInterface TEGFeed = new Stream("TEG feed", feedTEG); TEGFeed.setFlowRate(5500.0, "kg/hr"); TEGFeed.setTemperature(48.5, "C"); TEGFeed.setPressure(85.0, "bara"); @@ -127,106 +122,96 @@ public void runProcessTEG() throws InterruptedException { absorberSetWater.setWaterInDryGas(30e-6); p.add(absorberSetWater); - StreamInterface dehydratedGasSetWater = new Stream(absorberSetWater.getGasOutStream()); - dehydratedGasSetWater.setName("dry gas from absorber set water"); + StreamInterface dehydratedGasSetWater = + new Stream("dry gas from absorber set water", absorberSetWater.getGasOutStream()); p.add(dehydratedGasSetWater); - Heater coolerDehydGas = new Heater(dehydratedGasSetWater); - coolerDehydGas.setName("coolerDehydGas"); + Heater coolerDehydGas = new Heater("coolerDehydGas", dehydratedGasSetWater); coolerDehydGas.setOutTemperature(273.15 + 10.0); p.add(coolerDehydGas); - Separator sepDehydratedGasSetWater = new Separator(coolerDehydGas.getOutStream()); - sepDehydratedGasSetWater.setName("dehyd gas separator"); + Separator sepDehydratedGasSetWater = + new Separator("dehyd gas separator", coolerDehydGas.getOutStream()); p.add(sepDehydratedGasSetWater); - Heater pipelineSetTP = new Heater(sepDehydratedGasSetWater.getGasOutStream()); - pipelineSetTP.setName("pipelineSetTP"); + Heater pipelineSetTP = new Heater("pipelineSetTP", sepDehydratedGasSetWater.getGasOutStream()); pipelineSetTP.setOutPressure(168.0, "bara"); pipelineSetTP.setOutTemperature(4.0, "C"); p.add(pipelineSetTP); - StreamInterface pipelineSetTPStream = new Stream(pipelineSetTP.getOutStream()); - pipelineSetTPStream.setName("pipelineSetTP stream"); + StreamInterface pipelineSetTPStream = + new Stream("pipelineSetTP stream", pipelineSetTP.getOutStream()); p.add(pipelineSetTPStream); - WaterDewPointAnalyser waterDewPointAnalyser3 = new WaterDewPointAnalyser(dehydratedGasSetWater); + WaterDewPointAnalyser waterDewPointAnalyser3 = + new WaterDewPointAnalyser("water dew point analyser3", dehydratedGasSetWater); waterDewPointAnalyser3.setReferencePressure(70.0); - waterDewPointAnalyser3.setName("water dew point analyser3"); p.add(waterDewPointAnalyser3); - StreamInterface dehydratedGas = new Stream(absorber.getGasOutStream()); - dehydratedGas.setName("dry gas from absorber"); + StreamInterface dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); p.add(dehydratedGas); - StreamInterface richTEG = new Stream(absorber.getLiquidOutStream()); - richTEG.setName("rich TEG from absorber"); + StreamInterface richTEG = new Stream("rich TEG from absorber", absorber.getLiquidOutStream()); p.add(richTEG); - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser", dehydratedGas); waterDewPointAnalyser2.setReferencePressure(70.0); - waterDewPointAnalyser2.setName("water dew point analyser"); p.add(waterDewPointAnalyser2); - ThrottlingValve glycol_flash_valve = new ThrottlingValve(richTEG); - glycol_flash_valve.setName("Rich TEG HP flash valve"); + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); glycol_flash_valve.setOutletPressure(4.8); p.add(glycol_flash_valve); - Heater richGLycolHeaterCondenser = new Heater(glycol_flash_valve.getOutStream()); - richGLycolHeaterCondenser.setName("rich TEG preheater"); + Heater richGLycolHeaterCondenser = + new Heater("rich TEG preheater", glycol_flash_valve.getOutStream()); p.add(richGLycolHeaterCondenser); - HeatExchanger heatEx2 = new HeatExchanger(richGLycolHeaterCondenser.getOutStream()); - heatEx2.setName("rich TEG heat exchanger 1"); + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", richGLycolHeaterCondenser.getOutStream()); heatEx2.setGuessOutTemperature(273.15 + 62.0); heatEx2.setUAvalue(2224.0); p.add(heatEx2); - Separator flashSep = new Separator(heatEx2.getOutStream(0)); - flashSep.setName("degasing separator"); + Separator flashSep = new Separator("degassing separator", heatEx2.getOutStream(0)); flashSep.setInternalDiameter(1.2); p.add(flashSep); - StreamInterface flashGas = new Stream(flashSep.getGasOutStream()); - flashGas.setName("gas from degasing separator"); + StreamInterface flashGas = + new Stream("gas from degassing separator", flashSep.getGasOutStream()); p.add(flashGas); - StreamInterface flashLiquid = new Stream(flashSep.getLiquidOutStream()); - flashLiquid.setName("liquid from degasing separator"); + StreamInterface flashLiquid = + new Stream("liquid from degassing separator", flashSep.getLiquidOutStream()); p.add(flashLiquid); - Filter fineFilter = new Filter(flashLiquid); - fineFilter.setName("TEG fine filter"); + Filter fineFilter = new Filter("TEG fine filter", flashLiquid); fineFilter.setDeltaP(0.0, "bara"); p.add(fineFilter); - HeatExchanger heatEx = new HeatExchanger(fineFilter.getOutStream()); - heatEx.setName("lean/rich TEG heat-exchanger"); + HeatExchanger heatEx = + new HeatExchanger("lean/rich TEG heat-exchanger", fineFilter.getOutStream()); heatEx.setGuessOutTemperature(273.15 + 130.0); heatEx.setUAvalue(8316.0); p.add(heatEx); - ThrottlingValve glycol_flash_valve2 = new ThrottlingValve(heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(1.2); p.add(glycol_flash_valve2); SystemInterface stripGas = feedGas.clone(); - StreamInterface strippingGas = new Stream(stripGas); - strippingGas.setName("stripGas"); + StreamInterface strippingGas = new Stream("stripGas", stripGas); strippingGas.setFlowRate(180.0, "Sm3/hr"); strippingGas.setTemperature(78.3, "C"); strippingGas.setPressure(1.2, "bara"); p.add(strippingGas); - StreamInterface gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + StreamInterface gasToReboiler = strippingGas.clone("gas to reboiler"); p.add(gasToReboiler); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutStream(), 1); column.getReboiler().setOutTemperature(273.15 + 197.5); column.getCondenser().setOutTemperature(273.15 + 80.0); @@ -236,29 +221,26 @@ public void runProcessTEG() throws InterruptedException { column.setInternalDiameter(0.56); p.add(column); - Heater coolerRegenGas = new Heater(column.getGasOutStream()); - coolerRegenGas.setName("regen gas cooler"); + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 47.0); p.add(coolerRegenGas); - HeatExchanger overheadCondHX = new HeatExchanger(column.getGasOutStream()); - overheadCondHX.setName("overhead condenser heat-exchanger"); + HeatExchanger overheadCondHX = + new HeatExchanger("overhead condenser heat-exchanger", column.getGasOutStream()); overheadCondHX.setGuessOutTemperature(273.15 + 50.0); overheadCondHX.setUAvalue(3247.0); overheadCondHX.setFeedStream(1, coolingWater1); p.add(overheadCondHX); - Separator sepregenGas = new Separator(coolerRegenGas.getOutStream()); - sepregenGas.setName("regen gas separator"); + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutStream()); p.add(sepregenGas); - StreamInterface gasToFlare = new Stream(sepregenGas.getGasOutStream()); - gasToFlare.setName("gas to flare"); + StreamInterface gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); p.add(gasToFlare); - StreamInterface liquidToTrreatment = new Stream(sepregenGas.getLiquidOutStream()); - liquidToTrreatment.setName("water to treatment"); - p.add(liquidToTrreatment); + StreamInterface liquidToTreatment = + new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + p.add(liquidToTreatment); WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); stripper.addSolventInStream(column.getLiquidOutStream()); @@ -274,47 +256,42 @@ public void runProcessTEG() throws InterruptedException { heatEx.setFeedStream(1, stripper.getLiquidOutStream()); - Heater bufferTank = new Heater(heatEx.getOutStream(1)); - bufferTank.setName("TEG buffer tank"); + Heater bufferTank = new Heater("TEG buffer tank", heatEx.getOutStream(1)); bufferTank.setOutTemperature(273.15 + 90.5); p.add(bufferTank); - Pump hotLeanTEGPump = new Pump(bufferTank.getOutStream()); - hotLeanTEGPump.setName("lean TEG LP pump"); + Pump hotLeanTEGPump = new Pump("lean TEG LP pump", bufferTank.getOutStream()); hotLeanTEGPump.setOutletPressure(3.0); hotLeanTEGPump.setIsentropicEfficiency(0.75); p.add(hotLeanTEGPump); heatEx2.setFeedStream(1, hotLeanTEGPump.getOutStream()); - Heater coolerhOTteg3 = new Heater(heatEx2.getOutStream(1)); - coolerhOTteg3.setName("lean TEG cooler"); + Heater coolerhOTteg3 = new Heater("lean TEG cooler", heatEx2.getOutStream(1)); coolerhOTteg3.setOutTemperature(273.15 + 48.5); p.add(coolerhOTteg3); - HeatExchanger coolerhOTteg3HX = new HeatExchanger(heatEx2.getOutStream(1)); - coolerhOTteg3HX.setName("lean TEG heat-exchanger 3"); + HeatExchanger coolerhOTteg3HX = + new HeatExchanger("lean TEG heat-exchanger 3", heatEx2.getOutStream(1)); coolerhOTteg3HX.setGuessOutTemperature(273.15 + 40.0); coolerhOTteg3HX.setUAvalue(7819.0); coolerhOTteg3HX.setFeedStream(1, coolingWater2); p.add(coolerhOTteg3HX); - Pump hotLeanTEGPump2 = new Pump(coolerhOTteg3.getOutStream()); - hotLeanTEGPump2.setName("lean TEG HP pump"); + Pump hotLeanTEGPump2 = new Pump("lean TEG HP pump", coolerhOTteg3.getOutStream()); hotLeanTEGPump2.setOutletPressure(85.0); hotLeanTEGPump2.setIsentropicEfficiency(0.75); p.add(hotLeanTEGPump2); - StreamInterface leanTEGtoabs = new Stream(hotLeanTEGPump2.getOutStream()); - leanTEGtoabs.setName("lean TEG to absorber"); + StreamInterface leanTEGtoabs = + new Stream("lean TEG to absorber", hotLeanTEGPump2.getOutStream()); p.add(leanTEGtoabs); SystemInterface pureTEG = feedGas.clone(); pureTEG.setMolarComposition( new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); - Stream makeupTEG = new Stream(pureTEG); - makeupTEG.setName("makeup TEG"); + Stream makeupTEG = new Stream("makeup TEG", pureTEG); makeupTEG.setFlowRate(1e-6, "kg/hr"); makeupTEG.setTemperature(48.5, "C"); makeupTEG.setPressure(85.0, "bara"); @@ -324,7 +301,7 @@ public void runProcessTEG() throws InterruptedException { makeupCalculator.addInputVariable(dehydratedGas); makeupCalculator.addInputVariable(flashGas); makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.addInputVariable(liquidToTreatment); makeupCalculator.setOutputVariable(makeupTEG); p.add(makeupCalculator); @@ -333,21 +310,30 @@ public void runProcessTEG() throws InterruptedException { makeupMixer.addStream(makeupTEG); p.add(makeupMixer); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); - p.add(resycleLeanTEG); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); + p.add(recycleLeanTEG); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); - Thread runThr = p.runAsThread(); try { runThr.join(100000); } catch (Exception ex) { logger.error("Something failed"); } + // System.out.println("water in gas " + dehydratedGas.getFluid().getComponent("water").getx()); + + assertEquals(-19.1886678, + p.getMeasurementDevice("water dew point analyser3").getMeasuredValue("C"), 1e-2); + } + + @Test + public void testBukacekWaterInGas() { + assertEquals(-36.485388110, + BukacekWaterInGas.waterDewPointTemperature(8.2504356945e-6, 70.0) - 273.15, 1e-2); } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java index 4c11b6c944..46090e4c28 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java @@ -2,18 +2,23 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.compressor.Compressor; +import neqsim.processSimulation.processEquipment.compressor.SurgeCurve; +import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; import neqsim.processSimulation.processEquipment.heatExchanger.Heater; +import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.pump.Pump; import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.splitter.Splitter; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processEquipment.util.Calculator; import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; public class OilGasProcessTest extends neqsim.NeqSimTest { - @Test public void runProcess() throws InterruptedException { SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); @@ -70,8 +75,7 @@ public void runProcess() throws InterruptedException { ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream()); valve2.setOutletPressure(2.7); - StreamInterface recircstream1 = valve2.getOutletStream().clone(); - recircstream1.setName("oilRecirc1"); + StreamInterface recircstream1 = valve2.getOutletStream().clone("oilRecirc1"); recircstream1.setFlowRate(1e-6, "kg/hr"); neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage = @@ -80,8 +84,6 @@ public void runProcess() throws InterruptedException { seprator3rdStage.addStream(valve2.getOutletStream()); seprator3rdStage.addStream(recircstream1); - - ThrottlingValve pipeloss1st = new ThrottlingValve("pipeloss1st", seprator3rdStage.getGasOutStream()); pipeloss1st.setOutletPressure(2.7 - 0.03); @@ -120,13 +122,236 @@ public void runProcess() throws InterruptedException { operations.run(); - assertEquals(17195.25050, seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), 0.001); + assertEquals(17105.52983567356, seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), 1.1); assertEquals(seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), coolerLP.getOutletStream().getFlowRate("kg/hr"), 1e-4); - // System.out.println("recycle flow " + recycle1.getOutletStream().getFlowRate("kg/hr")); + // System.out.println("recycle flow " + + // recycle1.getOutletStream().getFlowRate("kg/hr")); // valveLP1.getOutletStream().getFluid().prettyPrint(); + } + + @Test + public void runAntiSurgeProcess() throws InterruptedException { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.addComponent("nitrogen", 1.0); + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.setMixingRule("classic"); + + Stream gas_from_separator = new Stream("gas from separator", thermoSystem); + gas_from_separator.setPressure(55.0, "bara"); + gas_from_separator.setTemperature(30.0, "C"); + gas_from_separator.setFlowRate(7.0, "MSm3/day"); + gas_from_separator.run(); + + Stream recyclegasstream = gas_from_separator.clone("recycle gas stream"); + recyclegasstream.setFlowRate(1e-10, "MSm3/day"); + recyclegasstream.run(); + + Mixer gasmixer = new Mixer("gas mixer"); + gasmixer.addStream(gas_from_separator); + gasmixer.addStream(recyclegasstream); + gasmixer.run(); + + Compressor gascompressor = new Compressor("gas compressor"); + gascompressor.setInletStream(gasmixer.getOutletStream()); + gascompressor.setOutletPressure(90.0, "bara"); + gascompressor.run(); + + double fluidh = gascompressor.getPolytropicFluidHead(); + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + gascompressor); + gascompressor.setCompressorChart(compchartgenerator.generateCompressorChart("mid range")); + + Cooler gascooler = new Cooler("gas cooler"); + gascooler.setInletStream(gascompressor.getOutletStream()); + gascooler.setOutTemperature(30.0, "C"); + gascooler.run(); + + Separator gassep = new Separator("gas separator"); + gassep.setInletStream(gascooler.getOutletStream()); + gassep.run(); + Splitter gassplitter = new Splitter("gas splitter"); + gassplitter.setInletStream(gassep.getGasOutStream()); + gassplitter.setFlowRates(new double[] {7.0, 1.2}, "MSm3/day"); + gassplitter.run(); + + ThrottlingValve antisurgevalve = new ThrottlingValve("gas valve"); + antisurgevalve.setInletStream(gassplitter.getSplitStream(1)); + antisurgevalve.setOutletPressure(55.0, "bara"); + antisurgevalve.run(); + + Recycle recycl = new Recycle("rec"); + recycl.addStream(antisurgevalve.getOutletStream()); + recycl.setOutletStream(recyclegasstream); + recycl.setFlowAccuracy(1e-12); + recycl.run(); + + Calculator antisurgeCalculator = new Calculator("anti surge calculator"); + antisurgeCalculator.addInputVariable(gascompressor); + antisurgeCalculator.setOutputVariable(gassplitter); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(gas_from_separator); + operations.add(recyclegasstream); + operations.add(gasmixer); + operations.add(gascompressor); + operations.add(gascooler); + operations.add(gassep); + operations.add(gassplitter); + operations.add(antisurgevalve); + operations.add(recycl); + operations.add(antisurgeCalculator); + operations.run(); + + // gascompressor.setOutletPressure(90.0); + // gascompressor.getCompressorChart().setUseCompressorChart(false); + + operations.run(); + assertEquals(6.9999999, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(1e-6, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4009.59769517, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(90.91657683, gascompressor.getOutletPressure(), 1e-4); + + gas_from_separator.setFlowRate(2.0, "MSm3/day"); + operations.run(); + assertEquals(1.5704782278734, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-4); + assertEquals(1.99999997741, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4402.40767965, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(144.6783957, gascompressor.getOutletPressure(), 1e-4); + + gas_from_separator.setFlowRate(8.0, "MSm3/day"); + operations.run(); + assertEquals(1.0000000000014376E-6, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), + 1e-4); + assertEquals(8.000000000000004, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(3914.332053456, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(82.7494476493, gascompressor.getOutletPressure(), 1e-4); + + gas_from_separator.setFlowRate(0.1, "MSm3/day"); + gascompressor.setSpeed(2000); + operations.run(); + assertEquals(0.66417291176, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-4); + assertEquals(0.09999851484397385, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4037.5356388, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(96.609347, gascompressor.getOutletPressure(), 1e-4); + } + + @Test + public void runAntiSurgeProcess2() throws InterruptedException { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.addComponent("nitrogen", 1.0); + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.setMixingRule("classic"); + + Stream gas_from_separator = new Stream("feed stream", thermoSystem); + gas_from_separator.setPressure(55.0, "bara"); + gas_from_separator.setTemperature(30.0, "C"); + gas_from_separator.setFlowRate(7.0, "MSm3/day"); + + Stream recyclegasstream = gas_from_separator.clone("Recycle gas"); + recyclegasstream.setFlowRate(1e-10, "MSm3/day"); + + Mixer gasmixer = new Mixer("gas mixer"); + gasmixer.addStream(gas_from_separator); + gasmixer.addStream(recyclegasstream); + + Compressor gascompressor = new Compressor("gas compressor"); + gascompressor.setInletStream(gasmixer.getOutletStream()); + gascompressor.setOutletPressure(90.0, "bara"); + + Cooler gascooler = new Cooler("gas cooler"); + gascooler.setInletStream(gascompressor.getOutletStream()); + gascooler.setOutTemperature(30.0, "C"); + + Separator gassep = new Separator("gas separator"); + gassep.setInletStream(gascooler.getOutletStream()); + + Splitter gassplitter = new Splitter("gas splitter"); + gassplitter.setInletStream(gassep.getGasOutStream()); + gassplitter.setFlowRates(new double[] {7.0, 1.2}, "MSm3/day"); + + ThrottlingValve antisurgevalve = new ThrottlingValve("gas valve"); + antisurgevalve.setInletStream(gassplitter.getSplitStream(1)); + antisurgevalve.setOutletPressure(55.0, "bara"); + + Recycle recycl = new Recycle("rec"); + recycl.addStream(antisurgevalve.getOutletStream()); + recycl.setOutletStream(recyclegasstream); + recycl.setFlowAccuracy(1e-15); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(gas_from_separator); + operations.add(recyclegasstream); + operations.add(gasmixer); + operations.add(gascompressor); + operations.add(gascooler); + operations.add(gassep); + operations.add(gassplitter); + operations.add(antisurgevalve); + operations.add(recycl); + operations.run(); + + double fluidh = gascompressor.getPolytropicFluidHead(); + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + gascompressor); + gascompressor.setCompressorChart(compchartgenerator.generateCompressorChart("mid range")); + + gascompressor.setOutletPressure(90.0); + gascompressor.getCompressorChart().setUseCompressorChart(false); + + Calculator antisurgeCalculator = new Calculator("anti surge calculator"); + antisurgeCalculator.addInputVariable(gascompressor); + antisurgeCalculator.setOutputVariable(gassplitter); + + operations.add(antisurgeCalculator); + + operations.run(); + assertEquals(6.9999999, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(1e-6, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4646.77601821, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(90.0, gascompressor.getOutletPressure(), 1e-4); + + gas_from_separator.setFlowRate(2.0, "MSm3/day"); + operations.run(); + assertEquals(1.58988554, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-2); + assertEquals(1.99847869184, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4632.1489149, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(90.0, gascompressor.getOutletPressure(), 1e-4); + + gas_from_separator.setFlowRate(8.0, "MSm3/day"); + operations.run(); + assertEquals(1.0000000000014376E-6, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), + 1e-4); + assertEquals(8.000000000000004, gassplitter.getSplitStream(0).getFlowRate("MSm3/day"), 1e-4); + assertEquals(4646.77601880, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-4); + assertEquals(90.0, gascompressor.getOutletPressure(), 1e-4); + + double[] flows = new double[] {7044, 7560, 7760}; + double[] head = new double[] {74, 80, 90}; + SurgeCurve surg = new SurgeCurve(flows, head); + gascompressor.getCompressorChart().setSurgeCurve(surg); + operations.run(); + assertEquals(6753.1900, gascompressor.getCompressorChart().getSurgeCurve() + .getSurgeFlow(gascompressor.getPolytropicFluidHead()), 1e-2); + assertEquals(5998.55269, gascompressor.getInletStream().getFlowRate("m3/hr"), 1e-4); + assertEquals(0.9071841061, gassplitter.getSplitStream(1).getFlowRate("MSm3/day"), 1e-4); } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/OilProcessTest.java b/src/test/java/neqsim/processSimulation/processSystem/OilProcessTest.java new file mode 100644 index 0000000000..3e776d665f --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/OilProcessTest.java @@ -0,0 +1,21 @@ +package neqsim.processSimulation.processSystem; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.BeforeEach; + +/** + * Test class for GlycolRig. + */ +public class OilProcessTest extends neqsim.NeqSimTest { + static Logger logger = LogManager.getLogger(OilProcessTest.class); + + ProcessSystem p; + String _name = "TestProcess"; + + @BeforeEach + public void setUp() { + p = new ProcessSystem(); + p.setName(_name); + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java index 32d6053ad2..aa2b129570 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java @@ -7,11 +7,17 @@ import neqsim.processSimulation.SimulationInterface; import neqsim.processSimulation.controllerDevice.ControllerDeviceBaseClass; import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; +import neqsim.processSimulation.measurementDevice.CompressorMonitor; import neqsim.processSimulation.measurementDevice.LevelTransmitter; import neqsim.processSimulation.measurementDevice.PressureTransmitter; import neqsim.processSimulation.measurementDevice.VolumeFlowTransmitter; +import neqsim.processSimulation.processEquipment.compressor.Compressor; +import neqsim.processSimulation.processEquipment.heatExchanger.Cooler; import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.splitter.Splitter; import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.util.Recycle; +import neqsim.processSimulation.processEquipment.util.SetPoint; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.thermo.system.SystemInterface; @@ -31,12 +37,10 @@ public void testGetName() { } @Test - void testGetTime() { - } + void testGetTime() {} @Test - void testGetTimeStep() { - } + void testGetTimeStep() {} private SystemInterface getTestSystem() { neqsim.thermo.system.SystemInterface testSystem = @@ -49,7 +53,7 @@ private SystemInterface getTestSystem() { return testSystem; } - // @Test + @Test public void testDynamicCalculation() { neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); @@ -59,10 +63,14 @@ public void testDynamicCalculation() { ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); valve1.setOutletPressure(5.0); - valve1.setPercentValveOpening(50); + valve1.setPercentValveOpening(40); Separator separator1 = new Separator("sep 1"); separator1.addStream(valve1.getOutletStream()); + separator1.setInternalDiameter(1.0); + separator1.setSeparatorLength(2.5); + separator1.setLiquidLevel(0.5); + separator1.setCalculateSteadyState(true); ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); valve2.setOutletPressure(1.0); @@ -71,6 +79,7 @@ public void testDynamicCalculation() { ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); valve3.setOutletPressure(1.0); valve3.setPercentValveOpening(50); + valve3.setMinimumValveOpening(1.0); VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream1); flowTransmitter.setUnit("kg/hr"); @@ -80,8 +89,8 @@ public void testDynamicCalculation() { ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); flowController.setTransmitter(flowTransmitter); flowController.setReverseActing(true); - flowController.setControllerSetPoint(63.5); - flowController.setControllerParameters(0.1, 0.10, 0.0); + flowController.setControllerSetPoint(73.5); + flowController.setControllerParameters(0.2, 100.0, 0.0); p.add(stream1); p.add(valve1); @@ -90,20 +99,22 @@ public void testDynamicCalculation() { p.add(valve3); p.add(flowTransmitter); valve1.setController(flowController); + valve1.setCalculateSteadyState(false); p.run(); // transient behaviour - p.setTimeStep(1.0); - for (int i = 0; i < 5; i++) { - // logger.info("volume flow " + flowTransmitter.getMeasuredValue() - // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " - // + separator_1.getGasOutStream().getPressure()); + p.setTimeStep(20.0); + for (int i = 0; i < 200; i++) { + // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + " valve opening " + // + valve1.getPercentValveOpening() + " pressure " + // + separator1.getGasOutStream().getPressure()); p.runTransient(); for (SimulationInterface sim : p.getUnitOperations()) { assertEquals(sim.getCalculationIdentifier(), p.getCalculationIdentifier()); } } + assertEquals(73.5, flowTransmitter.getMeasuredValue(), 1.0); } @Test @@ -111,49 +122,65 @@ public void testDynamicCalculation2() { neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); testSystem2.addComponent("methane", 1.1); - testSystem2.addComponent("ethane", 0.10001); testSystem2.addComponent("n-heptane", 1.001); testSystem2.setMixingRule(2); - Stream purgeStream = new Stream("Purge Stream", testSystem2); - ThrottlingValve purgeValve = new ThrottlingValve("purgeValve", purgeStream); - purgeValve.setOutletPressure(7.0); - purgeValve.setPercentValveOpening(50.0); + neqsim.thermo.system.SystemInterface testSystem3 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem3.addComponent("methane", 1.1); + testSystem3.addComponent("n-heptane", 0.001); + testSystem3.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(1090.0, "kg/hr"); + stream1.setPressure(10.0, "bara"); + stream1.setTemperature(25.0, "C"); + + Stream streamPurge = new Stream("StreamPurge", testSystem3); + streamPurge.setFlowRate(50.0, "kg/hr"); + streamPurge.setPressure(10.0, "bara"); + streamPurge.setTemperature(25.0, "C"); - neqsim.thermo.system.SystemInterface testSystem = getTestSystem(); - Stream stream1 = new Stream("Stream1", testSystem); - stream1.setCalculateSteadyState(false); ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); valve1.setOutletPressure(7.0); valve1.setPercentValveOpening(50); + valve1.setCalculateSteadyState(false); + + ThrottlingValve valvePurge = new ThrottlingValve("valve_purge", streamPurge); + valvePurge.setOutletPressure(7.0); + valvePurge.setPercentValveOpening(50); + valvePurge.setCalculateSteadyState(false); Separator separator1 = new Separator("separator_1"); separator1.addStream(valve1.getOutletStream()); - separator1.addStream(purgeValve.getOutletStream()); - separator1.setCalculateSteadyState(true); + separator1.addStream(valvePurge.getOutletStream()); + separator1.setCalculateSteadyState(false); + separator1.setSeparatorLength(3.0); + separator1.setInternalDiameter(0.8); + separator1.setLiquidLevel(0.5); ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator1.getLiquidOutStream()); - valve2.setOutletPressure(5.0); + valve2.setOutletPressure(1.0); valve2.setPercentValveOpening(50); - valve2.setCalculateSteadyState(true); - // valve_2.setCv(10.0); + valve2.setCalculateSteadyState(false); + valve2.setMinimumValveOpening(1.0); ThrottlingValve valve3 = new ThrottlingValve("valve_3", separator1.getGasOutStream()); - valve3.setOutletPressure(5.0); - valve3.setPercentValveOpening(50); - valve3.setCalculateSteadyState(true); - // valve_3.setCv(10.0); + valve3.setOutletPressure(1.0); + valve3.setPercentValveOpening(10); + valve3.setCalculateSteadyState(false); + valve3.setMinimumValveOpening(1.0); - LevelTransmitter separatorLevelTransmitter = new LevelTransmitter(separator1); - separatorLevelTransmitter.setName("separatorLevelTransmitter1"); - separatorLevelTransmitter.setMaximumValue(1.0); - separatorLevelTransmitter.setMinimumValue(0.0); + LevelTransmitter separatorLevelTransmitter = + new LevelTransmitter("separatorLevelTransmitter1", separator1); + separatorLevelTransmitter.setMaximumValue(0.8); + separatorLevelTransmitter.setMinimumValue(0.2); ControllerDeviceInterface separatorLevelController = new ControllerDeviceBaseClass(); - separatorLevelController.setReverseActing(true); + separatorLevelController.setReverseActing(false); separatorLevelController.setTransmitter(separatorLevelTransmitter); - separatorLevelController.setControllerSetPoint(0.3); - separatorLevelController.setControllerParameters(1, 1000.0, 0.0); + separatorLevelController.setControllerSetPoint(0.45); + separatorLevelController.setControllerParameters(2.0, 500.0, 0.0); PressureTransmitter separatorPressureTransmitter = new PressureTransmitter(separator1.getGasOutStream()); @@ -165,13 +192,12 @@ public void testDynamicCalculation2() { separatorPressureController.setTransmitter(separatorPressureTransmitter); separatorPressureController.setReverseActing(false); separatorPressureController.setControllerSetPoint(7.0); - separatorPressureController.setControllerParameters(0.5, 10.0, 0.0); + separatorPressureController.setControllerParameters(1, 100, 0.0); p.add(stream1); + p.add(streamPurge); p.add(valve1); - - p.add(purgeStream); - p.add(purgeValve); + p.add(valvePurge); p.add(separator1); p.add(valve2); p.add(valve3); @@ -189,26 +215,561 @@ public void testDynamicCalculation2() { } // p.displayResult(); - p.setTimeStep(0.01); - for (int i = 0; i < 500; i++) { - // logger.info("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ - // separator_1.getGasOutStream().getFlowRate("kg/hr") + " sepr height - // "+separatorLevelTransmitter.getMeasuredValue()); + p.setTimeStep(10.0); + for (int i = 0; i < 250; i++) { + // System.out.println("pressure " + separator1.getGasOutStream().getPressure() + " flow " + // + separator1.getGasOutStream().getFlowRate("kg/hr") + " sepr height " + // + separatorLevelTransmitter.getMeasuredValue() + "valve2 opening " + // + valve2.getPercentValveOpening() + "valve3 opening " + valve3.getPercentValveOpening()); p.runTransient(); for (SimulationInterface sim : p.getUnitOperations()) { assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); } } + assertEquals(0.45, separatorLevelTransmitter.getMeasuredValue(), 0.01); + } + + @Test + public void testDynamicCompressor() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.1); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(501.0, "kg/hr"); + stream1.setPressure(100.0, "bara"); + stream1.setTemperature(55.0, "C"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(50.0); + valve1.setPercentValveOpening(50); + valve1.setCalculateSteadyState(false); + + Separator separator1 = new Separator("separator_1"); + separator1.addStream(valve1.getOutletStream()); + separator1.setCalculateSteadyState(false); + separator1.setSeparatorLength(3.0); + separator1.setInternalDiameter(0.8); + separator1.setLiquidLevel(0.0); + + Compressor compressor1 = new Compressor("comp1", separator1.getGasOutStream()); + compressor1.setCalculateSteadyState(false); + compressor1.setOutletPressure(100.0); + + Separator separator2 = new Separator("separator_2"); + separator2.addStream(compressor1.getOutletStream()); + separator2.setCalculateSteadyState(false); + separator2.setSeparatorLength(3.0); + separator2.setInternalDiameter(0.8); + separator2.setLiquidLevel(0.0); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator2.getGasOutStream()); + valve2.setOutletPressure(50.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(false); - valve1.setPercentValveOpening(60); + p.add(stream1); + p.add(valve1); + p.add(separator1); + p.add(compressor1); + p.add(separator2); + p.add(valve2); + + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01); + + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + compressor1); + compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal")); + compressor1.getCompressorChart().setUseCompressorChart(true); + // compressor1.setCalculateSteadyState(true); + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + + assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01); + assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01); + // System.out.println("speed " + compressor1.getSpeed()); + p.setTimeStep(10.0); + p.runTransient(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + compressor1.setSpeed(compressor1.getSpeed() + 500); + for (int i = 0; i < 2000; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + p.runTransient(); + } + + compressor1.setSpeed(compressor1.getSpeed() - 500); + for (int i = 0; i < 2000; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + p.runTransient(); + } + } + + @Test + public void testDynamicCompressor22() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.1); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(501.0, "kg/hr"); + stream1.setPressure(100.0, "bara"); + stream1.setTemperature(55.0, "C"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(50.0); + valve1.setPercentValveOpening(50); + valve1.setCalculateSteadyState(false); + + Compressor compressor1 = new Compressor("comp", valve1.getOutletStream()); + compressor1.setCalculateSteadyState(false); + compressor1.setOutletPressure(100.0); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", compressor1.getOutletStream()); + valve2.setOutletPressure(50.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(false); + + p.add(stream1); + p.add(valve1); + p.add(compressor1); + p.add(valve2); + + p.run(); + /* + * System.out.println(" steady staate no compressor curves....."); System.out.println(" speed " + * + compressor1.getSpeed() + "feed flow " + stream1.getFlowRate("kg/hr") + + * " compressor flow rate " + compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01); + + // System.out.println("steady state with compressor curves....."); + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + compressor1); + compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal")); + compressor1.getCompressorChart().setUseCompressorChart(true); + // compressor1.setCalculateSteadyState(true); + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + + // System.out.println("dynamic first step state with compressor curves....."); + p.setTimeStep(1.0); + p.runTransient(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + + // System.out.println("dynamic seccond step state with compressor curves....."); + p.runTransient(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + } + + @Test + public void testDynamicCompressorSpeedControl() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.1); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(501.0, "kg/hr"); + stream1.setPressure(100.0, "bara"); + stream1.setTemperature(55.0, "C"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(50.0); + valve1.setPercentValveOpening(50); + valve1.setCalculateSteadyState(false); + + Separator separator1 = new Separator("separator_1"); + separator1.addStream(valve1.getOutletStream()); + separator1.setCalculateSteadyState(false); + separator1.setSeparatorLength(3.0); + separator1.setInternalDiameter(0.8); + separator1.setLiquidLevel(0.0); + + Compressor compressor1 = new Compressor("comp1", separator1.getGasOutStream()); + compressor1.setCalculateSteadyState(false); + compressor1.setOutletPressure(100.0); + + Separator separator2 = new Separator("separator_2"); + separator2.addStream(compressor1.getOutletStream()); + separator2.setCalculateSteadyState(false); + separator2.setSeparatorLength(3.0); + separator2.setInternalDiameter(0.8); + separator2.setLiquidLevel(0.0); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", separator2.getGasOutStream()); + valve2.setOutletPressure(50.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(false); + + PressureTransmitter separatorPressureTransmitter = + new PressureTransmitter(separator2.getGasOutStream()); + + ControllerDeviceInterface speedController = new ControllerDeviceBaseClass(); + speedController.setReverseActing(true); + speedController.setTransmitter(separatorPressureTransmitter); + speedController.setControllerSetPoint(100.0); + speedController.setControllerParameters(0.1, 500.0, 0.0); + + p.add(stream1); + p.add(valve1); + p.add(separator1); + p.add(compressor1); + p.add(separator2); + p.add(separatorPressureTransmitter); + p.add(valve2); + compressor1.setController(speedController); + + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01); + + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + compressor1); + compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal")); + compressor1.getCompressorChart().setUseCompressorChart(true); + // compressor1.setCalculateSteadyState(true); + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + + assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01); + assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01); + // System.out.println("speed " + compressor1.getSpeed()); + p.setTimeStep(10.0); + p.runTransient(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + // compressor1.setSpeed(compressor1.getSpeed() + 500); + for (int i = 0; i < 200; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + p.runTransient(); + } + speedController.setControllerSetPoint(120.0); + for (int i = 0; i < 500; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure()); + */ + p.runTransient(); + } + } + + @Test + public void testAntiSurgeControl() { + neqsim.thermo.system.SystemInterface testSystem2 = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem2.addComponent("methane", 1.1); + testSystem2.addComponent("ethane", 0.1); + testSystem2.setMixingRule(2); + + Stream stream1 = new Stream("Stream1", testSystem2); + stream1.setFlowRate(500.0, "kg/hr"); + stream1.setPressure(100.0, "bara"); + stream1.setTemperature(55.0, "C"); + + ThrottlingValve valve1 = new ThrottlingValve("valve_1", stream1); + valve1.setOutletPressure(50.0); + valve1.setPercentValveOpening(20); + valve1.setCalculateSteadyState(false); + + Stream resycstream = stream1.clone("recycle stream"); + resycstream.setFlowRate(0.01, "kg/hr"); + + Separator separator1 = new Separator("separator_1"); + separator1.addStream(valve1.getOutletStream()); + separator1.addStream(resycstream); + separator1.setCalculateSteadyState(false); + separator1.setSeparatorLength(3.0); + separator1.setInternalDiameter(0.8); + separator1.setLiquidLevel(0.0); + + Compressor compressor1 = new Compressor("comp", separator1.getGasOutStream()); + compressor1.setCalculateSteadyState(false); + compressor1.setOutletPressure(100.0); + CompressorMonitor surgemonitor = new CompressorMonitor(compressor1); + surgemonitor.setMaximumValue(5.0); + surgemonitor.setMinimumValue(-5.0); + + Cooler aftercooler = new Cooler("after cooler", compressor1.getOutletStream()); + aftercooler.setOutTemperature(30.0, "C"); + aftercooler.setCalculateSteadyState(false); + + Separator separator2 = new Separator("separator_2"); + separator2.addStream(aftercooler.getOutletStream()); + separator2.setCalculateSteadyState(false); + separator2.setSeparatorLength(3.0); + separator2.setInternalDiameter(0.5); + separator2.setLiquidLevel(0.0); + + Stream gasfromsep2 = new Stream("gas from sep", separator2.getGasOutStream()); + + Splitter splitter = new Splitter("splitter1", gasfromsep2); + splitter.setSplitFactors(new double[] {0.99, 0.01}); + splitter.setCalculateSteadyState(false); + + ThrottlingValve recycleValve = + new ThrottlingValve("anti surge valve", splitter.getSplitStream(1)); + recycleValve.setPressure(50.0); + recycleValve.setCalculateSteadyState(false); + recycleValve.setMinimumValveOpening(1.0); + recycleValve.setPercentValveOpening(10); + + SetPoint pressureset = + new SetPoint("HP pump set", recycleValve, "pressure", separator1.getGasOutStream()); + + Recycle recycle = new Recycle("recycle 1"); + recycle.addStream(recycleValve.getOutletStream()); + recycle.setOutletStream(resycstream); + recycle.setFlowAccuracy(1e-4); + + ThrottlingValve valve2 = new ThrottlingValve("valve_2", splitter.getSplitStream(0)); + valve2.setOutletPressure(50.0); + valve2.setPercentValveOpening(50); + valve2.setCalculateSteadyState(false); + valve2.setMinimumValveOpening(1.0); + + ControllerDeviceInterface surgeController = new ControllerDeviceBaseClass(); + surgeController.setReverseActing(true); + surgeController.setTransmitter(surgemonitor); + surgeController.setControllerSetPoint(0.0); + surgeController.setControllerParameters(1.0, 200.0, 10.0); + surgeController.setActive(true); + + p.add(stream1); + p.add(resycstream); + p.add(valve1); + p.add(separator1); + p.add(compressor1); + p.add(surgemonitor); + p.add(aftercooler); + p.add(separator2); + p.add(gasfromsep2); + p.add(splitter); + p.add(recycleValve); + p.add(pressureset); + p.add(recycle); + p.add(valve2); + recycleValve.setController(surgeController); + + p.run(); + assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01); + recycleValve.setCv(valve2.getCv()); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure() + " distancetosurge "); + */ + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + compressor1); + compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal")); + compressor1.getCompressorChart().setUseCompressorChart(true); + p.run(); + /* + * System.out.println(" speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + + * " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure() + " distancetosurge " + + * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " + + * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " + + * recycleValve.getPercentValveOpening() + " compressorouttemperature " + + * compressor1.getOutStream().getTemperature("C") + " power " + compressor1.getPower("kW")); + */ + + // System.out.println("speed " + compressor1.getSpeed()); + p.setTimeStep(1.0); + + recycleValve.setPercentValveOpening(1.0); + valve2.setPercentValveOpening(100.0); + + for (int i = 0; i < 100; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure() + " distancetosurge " + + * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " + + * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " + + * recycleValve.getPercentValveOpening() + " compressorouttemperature " + + * compressor1.getOutStream().getTemperature("C") + " surgeflow " + + * compressor1.getCompressorChart().getSurgeCurve() + * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " + + * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW")); + */ + p.runTransient(); + } + + valve1.setPercentValveOpening(1.0); + valve2.setPercentValveOpening(1.0); + + for (int i = 0; i < 100; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure() + " distancetosurge " + + * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " + + * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " + + * recycleValve.getPercentValveOpening() + " compressorouttemperature " + + * compressor1.getOutStream().getTemperature("C") + " surgeflow " + + * compressor1.getCompressorChart().getSurgeCurve() + * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " + + * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW")); + */ + p.runTransient(); + } + + valve1.setPercentValveOpening(50.0); + valve2.setPercentValveOpening(50.0); + + for (int i = 0; i < 100; i++) { + /* + * System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + * stream1.getFlowRate("kg/hr") + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + * valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + * (compressor1.getOutletStream().getPressure() - compressor1.getInletStream().getPressure()) + * + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + * compressor1.getOutletStream().getPressure() + " distancetosurge " + + * surgemonitor.getMeasuredValue("distance to surge") + " antisurgeflow " + + * recycleValve.getOutletStream().getFlowRate("kg/hr") + " antisurgevalveopening " + + * recycleValve.getPercentValveOpening() + " compressorouttemperature " + + * compressor1.getOutStream().getTemperature("C") + " surgeflow " + + * compressor1.getCompressorChart().getSurgeCurve() + * .getSurgeFlow(compressor1.getPolytropicFluidHead()) + " compressor flow rate " + + * compressor1.getInletStream().getFlowRate("m3/hr") + " fluid head " + + * compressor1.getPolytropicFluidHead() + " power " + compressor1.getPower("kW")); + */ - for (int i = 0; i < 10; i++) { - // logger.info("pressure "+separator_1.getGasOutStream().getPressure()+ " flow "+ - // separator_1.getGasOutStream().getFlowRate("kg/hr")); p.runTransient(); - for (SimulationInterface sim : p.getUnitOperations()) { - assertEquals(p.getCalculationIdentifier(), sim.getCalculationIdentifier()); - } } } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemSerializationTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemSerializationTest.java index c3a94b3794..28b45f8dd5 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemSerializationTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemSerializationTest.java @@ -22,7 +22,6 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; public class ProcessSystemSerializationTest extends neqsim.NeqSimTest { - @Test public void runTEGProcessTest2() { neqsim.thermo.system.SystemInterface feedGas = @@ -56,8 +55,8 @@ public void runTEGProcessTest2() { new Stream("water saturated feed gas Smorbukk", saturatedFeedGasSmorbukk.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserSmorbukk = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasSmorbukk); - hydrateTAnalyserSmorbukk.setName("hydrate temperature analyser Smorbukk"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Smorbukk", + waterSaturatedFeedGasSmorbukk); Splitter SmorbukkSplit = new Splitter("Smorbukk Splitter", waterSaturatedFeedGasSmorbukk); double[] splitSmorbukk = {1.0 - 1e-10, 1e-10}; @@ -75,8 +74,8 @@ public void runTEGProcessTest2() { new Stream("water saturated feed gas Midgard", saturatedFeedGasMidgard.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserMidgard = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasMidgard); - hydrateTAnalyserMidgard.setName("hydrate temperature analyser Midgard"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Midgard", + waterSaturatedFeedGasMidgard); Splitter MidgardSplit = new Splitter("Midgard Splitter", waterSaturatedFeedGasMidgard); double[] splitMidgard = {1e-10, 1 - 1e-10}; @@ -94,21 +93,20 @@ public void runTEGProcessTest2() { new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser2 = - new HydrateEquilibriumTemperatureAnalyser(feedToAbsorber); - hydrateTAnalyser2.setName("hydrate temperature gas to absorber"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature gas to absorber", + feedToAbsorber); WaterDewPointAnalyser waterDewPointAnalyserToAbsorber = - new WaterDewPointAnalyser(feedToAbsorber); + new WaterDewPointAnalyser("water dew point gas to absorber", feedToAbsorber); waterDewPointAnalyserToAbsorber.setMethod("multiphase"); waterDewPointAnalyserToAbsorber.setReferencePressure(40.0); - waterDewPointAnalyserToAbsorber.setName("water dew point gas to absorber"); neqsim.thermo.system.SystemInterface feedTEG = (neqsim.thermo.system.SystemInterface) feedGas.clone(); feedTEG.setMolarComposition( new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.99}); - Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + Stream TEGFeed = new Stream("TEG feed", feedTEG); TEGFeed.setFlowRate(8000.0, "kg/hr"); TEGFeed.setTemperature(40.0, "C"); TEGFeed.setPressure(40.0, "bara"); @@ -125,13 +123,12 @@ public void runTEGProcessTest2() { Stream richTEG = new Stream("rich TEG from absorber", absorber.getLiquidOutStream()); HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + new HydrateEquilibriumTemperatureAnalyser("hydrate dew point analyser", dehydratedGas); waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("hydrate dew point analyser"); - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser", dehydratedGas); waterDewPointAnalyser2.setReferencePressure(70.0); - waterDewPointAnalyser2.setName("water dew point analyser"); Heater condHeat = new Heater("Condenser heat exchanger", richTEG); @@ -150,7 +147,7 @@ public void runTEGProcessTest2() { new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}); double addedWaterRate = 0.0; - Stream waterFeed = new Stream("lean TEG to absorber", feedWater); + Stream waterFeed = new Stream("water to absorber", feedWater); waterFeed.setFlowRate(addedWaterRate, "kg/hr"); waterFeed.setTemperature(90.0, "C"); waterFeed.setPressure(7.0, "bara"); @@ -182,8 +179,7 @@ public void runTEGProcessTest2() { // column ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(feedPressureGLycol); neqsim.thermo.system.SystemInterface stripGas = @@ -196,11 +192,9 @@ public void runTEGProcessTest2() { strippingGas.setTemperature(180.0, "C"); strippingGas.setPressure(feedPressureStripGas, "bara"); - Stream gasToReboiler = (Stream) strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); column.getReboiler().setOutTemperature(273.15 + 202.0); column.getCondenser().setOutTemperature(273.15 + 89.0); @@ -261,11 +255,11 @@ public void runTEGProcessTest2() { Stream leanTEGtoabs = new Stream("lean TEG to absorber", coolerhOTteg3.getOutletStream()); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(leanTEGtoabs); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(leanTEGtoabs); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -326,7 +320,7 @@ public void runTEGProcessTest2() { operations.add(makeupMixer); operations.add(coolerhOTteg3); operations.add(leanTEGtoabs); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); // Check that process can run operations.run(); diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java index ab51c88ca8..5d7fca7651 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemTest.java @@ -19,6 +19,7 @@ import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.splitter.Splitter; import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.tank.Tank; import neqsim.processSimulation.processEquipment.util.Calculator; import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; @@ -116,17 +117,30 @@ public void testRemoveUnit() { } @Test - @SuppressWarnings("deprecation") - public void testAddUnitsWithNoName() { - Separator sep = new Separator(); + public void testAddUnitsWithDuplicateName() { + String name = "TestSeparator"; + Separator sep = new Separator(name); p.add(sep); - sep = new Separator(); - p.add(sep); - Assertions.assertEquals(2, p.size()); - p.removeUnit("Separator2"); - Assertions.assertEquals(1, p.size()); - p.removeUnit("Separator"); + + RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> { + p.add(new Separator(name)); + }); + Assertions.assertEquals( + "neqsim.util.exception.InvalidInputException: ProcessSystem:add - Input operation - Process equipment of type Separator named " + + name + " already included in ProcessSystem", + thrown.getMessage()); + p.removeUnit(name); Assertions.assertEquals(0, p.size()); + p.add(new Tank(name)); + Assertions.assertEquals(1, p.size()); + + RuntimeException thrown2 = Assertions.assertThrows(RuntimeException.class, () -> { + p.add(new Separator(name)); + }); + Assertions.assertEquals( + "neqsim.util.exception.InvalidInputException: ProcessSystem:add - Input operation - Process equipment of type Tank named " + + name + " already included in ProcessSystem", + thrown2.getMessage()); } @Test @@ -135,11 +149,13 @@ public void testGetUnitNumber() { p.add(sep); Separator sep2 = new Separator("Separator2"); p.add(sep2); + Assertions.assertEquals(2, p.size()); Assertions.assertEquals(0, p.getUnitNumber("Separator")); Assertions.assertEquals(1, p.getUnitNumber("Separator2")); p.removeUnit("Separator"); + Assertions.assertEquals(1, p.size()); p.add(sep); Assertions.assertEquals(0, p.getUnitNumber("Separator2")); @@ -170,9 +186,6 @@ void testCopy() { Assertions.assertEquals(p, sys2); } - @Test - void testDisplayResult() {} - @Test void testGetAllUnitNames() {} @@ -287,8 +300,8 @@ public void runTEGProcessTest2() { new Stream("water saturated feed gas Smorbukk", saturatedFeedGasSmorbukk.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserSmorbukk = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasSmorbukk); - hydrateTAnalyserSmorbukk.setName("hydrate temperature analyser Smorbukk"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Smorbukk", + waterSaturatedFeedGasSmorbukk); Splitter SmorbukkSplit = new Splitter("Smorbukk Splitter", waterSaturatedFeedGasSmorbukk); double[] splitSmorbukk = {1.0 - 1e-10, 1e-10}; @@ -306,8 +319,8 @@ public void runTEGProcessTest2() { new Stream("water saturated feed gas Midgard", saturatedFeedGasMidgard.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserMidgard = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGasMidgard); - hydrateTAnalyserMidgard.setName("hydrate temperature analyser Midgard"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Midgard", + waterSaturatedFeedGasMidgard); Splitter MidgardSplit = new Splitter("Midgard Splitter", waterSaturatedFeedGasMidgard); double[] splitMidgard = {1e-10, 1 - 1e-10}; @@ -325,14 +338,13 @@ public void runTEGProcessTest2() { new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser2 = - new HydrateEquilibriumTemperatureAnalyser(feedToAbsorber); - hydrateTAnalyser2.setName("hydrate temperature gas to absorber"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature gas to absorber", + feedToAbsorber); WaterDewPointAnalyser waterDewPointAnalyserToAbsorber = - new WaterDewPointAnalyser(feedToAbsorber); + new WaterDewPointAnalyser("water dew point gas to absorber", feedToAbsorber); waterDewPointAnalyserToAbsorber.setMethod("multiphase"); waterDewPointAnalyserToAbsorber.setReferencePressure(40.0); - waterDewPointAnalyserToAbsorber.setName("water dew point gas to absorber"); neqsim.thermo.system.SystemInterface feedTEG = (neqsim.thermo.system.SystemInterface) feedGas.clone(); @@ -356,13 +368,12 @@ public void runTEGProcessTest2() { Stream richTEG = new Stream("rich TEG from absorber", absorber.getLiquidOutStream()); HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + new HydrateEquilibriumTemperatureAnalyser("hydrate dew point analyser", dehydratedGas); waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("hydrate dew point analyser"); - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser", dehydratedGas); waterDewPointAnalyser2.setReferencePressure(70.0); - waterDewPointAnalyser2.setName("water dew point analyser"); Heater condHeat = new Heater("Condenser heat exchanger", richTEG); @@ -413,8 +424,7 @@ public void runTEGProcessTest2() { // column ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(feedPressureGLycol); neqsim.thermo.system.SystemInterface stripGas = @@ -427,11 +437,9 @@ public void runTEGProcessTest2() { strippingGas.setTemperature(180.0, "C"); strippingGas.setPressure(feedPressureStripGas, "bara"); - Stream gasToReboiler = (Stream) strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); column.getReboiler().setOutTemperature(273.15 + 202.0); column.getCondenser().setOutTemperature(273.15 + 89.0); @@ -495,11 +503,11 @@ public void runTEGProcessTest2() { Stream leanTEGtoabs = new Stream("resyc lean TEG to absorber", coolerhOTteg3.getOutletStream()); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(leanTEGtoabs); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(leanTEGtoabs); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -560,7 +568,7 @@ public void runTEGProcessTest2() { operations.add(makeupMixer); operations.add(coolerhOTteg3); operations.add(leanTEGtoabs); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); operations.run(); /* * System.out.println("flowo " + hotLeanTEGPump.getOutletStream().getFlowRate("kg/hr")); @@ -575,4 +583,355 @@ public void runTEGProcessTest2() { assertEquals(1.5322819175995646E-5, dehydratedGas.getFluid().getComponent("water").getx(), 1e-6); } + + @Test + public void testRun_step() { + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 0.245); + feedGas.addComponent("CO2", 3.4); + feedGas.addComponent("methane", 85.7); + feedGas.addComponent("ethane", 5.981); + feedGas.addComponent("propane", 0.2743); + feedGas.addComponent("i-butane", 0.037); + feedGas.addComponent("n-butane", 0.077); + feedGas.addComponent("i-pentane", 0.0142); + feedGas.addComponent("n-pentane", 0.0166); + feedGas.addComponent("n-hexane", 0.006); + feedGas.addComponent("benzene", 0.001); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("TEG", 0); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(false); + feedGas.init(0); + + Stream dryFeedGasSmorbukk = new Stream("dry feed gas Smorbukk", feedGas); + dryFeedGasSmorbukk.setFlowRate(10.0, "MSm3/day"); + dryFeedGasSmorbukk.setTemperature(25.0, "C"); + dryFeedGasSmorbukk.setPressure(40.0, "bara"); + + StreamSaturatorUtil saturatedFeedGasSmorbukk = + new StreamSaturatorUtil("water saturator Smorbukk", dryFeedGasSmorbukk); + + Stream waterSaturatedFeedGasSmorbukk = + new Stream("water saturated feed gas Smorbukk", saturatedFeedGasSmorbukk.getOutletStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserSmorbukk = + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Smorbukk", + waterSaturatedFeedGasSmorbukk); + + Splitter SmorbukkSplit = new Splitter("Smorbukk Splitter", waterSaturatedFeedGasSmorbukk); + double[] splitSmorbukk = {1.0 - 1e-10, 1e-10}; + SmorbukkSplit.setSplitFactors(splitSmorbukk); + + Stream dryFeedGasMidgard = new Stream("dry feed gas Midgard201", feedGas.clone()); + dryFeedGasMidgard.setFlowRate(10, "MSm3/day"); + dryFeedGasMidgard.setTemperature(5, "C"); + dryFeedGasMidgard.setPressure(40.0, "bara"); + + StreamSaturatorUtil saturatedFeedGasMidgard = + new StreamSaturatorUtil("water saturator Midgard", dryFeedGasMidgard); + + Stream waterSaturatedFeedGasMidgard = + new Stream("water saturated feed gas Midgard", saturatedFeedGasMidgard.getOutletStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyserMidgard = + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser Midgard", + waterSaturatedFeedGasMidgard); + + Splitter MidgardSplit = new Splitter("Midgard Splitter", waterSaturatedFeedGasMidgard); + double[] splitMidgard = {1e-10, 1 - 1e-10}; + MidgardSplit.setSplitFactors(splitMidgard); + + StaticMixer TrainB = new StaticMixer("mixer TrainB"); + TrainB.addStream(SmorbukkSplit.getSplitStream(1)); + TrainB.addStream(MidgardSplit.getSplitStream(1)); + + Heater feedTPsetterToAbsorber = new Heater("TP of gas to absorber", TrainB.getOutletStream()); + feedTPsetterToAbsorber.setOutPressure(40.0, "bara"); + feedTPsetterToAbsorber.setOutTemperature(37.0, "C"); + + Stream feedToAbsorber = + new Stream("feed to TEG absorber", feedTPsetterToAbsorber.getOutletStream()); + + HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser2 = + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature gas to absorber", + feedToAbsorber); + + WaterDewPointAnalyser waterDewPointAnalyserToAbsorber = + new WaterDewPointAnalyser("water dew point gas to absorber", feedToAbsorber); + waterDewPointAnalyserToAbsorber.setMethod("multiphase"); + waterDewPointAnalyserToAbsorber.setReferencePressure(40.0); + + neqsim.thermo.system.SystemInterface feedTEG = + (neqsim.thermo.system.SystemInterface) feedGas.clone(); + feedTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.01, 0.99}); + + Stream TEGFeed = new Stream("lean TEG to absorber", feedTEG); + TEGFeed.setFlowRate(8000.0, "kg/hr"); + TEGFeed.setTemperature(40.0, "C"); + TEGFeed.setPressure(40.0, "bara"); + + SimpleTEGAbsorber absorber = new SimpleTEGAbsorber("TEG absorber"); + absorber.addGasInStream(feedToAbsorber); + absorber.addSolventInStream(TEGFeed); + absorber.setNumberOfStages(4); + absorber.setStageEfficiency(0.8); + absorber.setInternalDiameter(2.240); + + Stream dehydratedGas = new Stream("dry gas from absorber", absorber.getGasOutStream()); + + Stream richTEG = new Stream("rich TEG from absorber", absorber.getLiquidOutStream()); + + HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = + new HydrateEquilibriumTemperatureAnalyser("hydrate dew point analyser", dehydratedGas); + waterDewPointAnalyser.setReferencePressure(70.0); + + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser", dehydratedGas); + waterDewPointAnalyser2.setReferencePressure(70.0); + + Heater condHeat = new Heater("Condenser heat exchanger", richTEG); + + ThrottlingValve glycol_flash_valve = + new ThrottlingValve("Rich TEG HP flash valve", condHeat.getOutletStream()); + glycol_flash_valve.setOutletPressure(7.0); + + HeatExchanger heatEx2 = + new HeatExchanger("rich TEG heat exchanger 1", glycol_flash_valve.getOutletStream()); + heatEx2.setGuessOutTemperature(273.15 + 90.0); + heatEx2.setUAvalue(1450.0); + + neqsim.thermo.system.SystemInterface feedWater = + (neqsim.thermo.system.SystemInterface) feedGas.clone(); + feedWater.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}); + + double addedWaterRate = 0.0; + Stream waterFeed = new Stream("extra water", feedWater); + waterFeed.setFlowRate(addedWaterRate, "kg/hr"); + waterFeed.setTemperature(90.0, "C"); + waterFeed.setPressure(7.0, "bara"); + + Separator flashSep = new Separator("degassing separator", heatEx2.getOutStream(0)); + if (addedWaterRate > 0) { + flashSep.addStream(waterFeed); + } + flashSep.setInternalDiameter(1.2); + + Stream flashGas = new Stream("gas from degassing separator", flashSep.getGasOutStream()); + + Stream flashLiquid = + new Stream("liquid from degassing separator", flashSep.getLiquidOutStream()); + + Filter filter = new Filter("TEG fine filter", flashLiquid); + filter.setDeltaP(0.0, "bara"); + + HeatExchanger heatEx = + new HeatExchanger("lean/rich TEG heat-exchanger", filter.getOutletStream()); + heatEx.setGuessOutTemperature(273.15 + 140.0); + heatEx.setUAvalue(9140.0); + + double reboilerPressure = 1.4; + double condenserPressure = 1.2; + double feedPressureGLycol = (reboilerPressure + condenserPressure) / 2.0; // enters middle of + // column + double feedPressureStripGas = (reboilerPressure + condenserPressure) / 2.0; // enters middle of + // column + + ThrottlingValve glycol_flash_valve2 = + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); + glycol_flash_valve2.setOutletPressure(feedPressureGLycol); + + neqsim.thermo.system.SystemInterface stripGas = + (neqsim.thermo.system.SystemInterface) feedGas.clone(); + stripGas.setMolarComposition( + new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); + + Stream strippingGas = new Stream("stripGas", stripGas); + strippingGas.setFlowRate(250.0 * 0.8, "kg/hr"); + strippingGas.setTemperature(180.0, "C"); + strippingGas.setPressure(feedPressureStripGas, "bara"); + + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); + + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); + column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); + column.getReboiler().setOutTemperature(273.15 + 202.0); + column.getCondenser().setOutTemperature(273.15 + 89.0); + column.getTray(1).addStream(gasToReboiler); + column.setTopPressure(condenserPressure); + column.setBottomPressure(reboilerPressure); + column.setInternalDiameter(0.56); + + Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + 15.0); + + Separator sepregenGas = new Separator("regen gas separator", coolerRegenGas.getOutletStream()); + + Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); + + Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + + WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); + stripper.addSolventInStream(column.getLiquidOutStream()); + stripper.addGasInStream(strippingGas); + stripper.setNumberOfStages(3); + stripper.setStageEfficiency(0.8); + + Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); + recycleGasFromStripper.addStream(stripper.getGasOutStream()); + recycleGasFromStripper.setOutletStream(gasToReboiler); + + neqsim.thermo.system.SystemInterface pureTEG = + (neqsim.thermo.system.SystemInterface) feedGas.clone(); + pureTEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + heatEx.setFeedStream(1, stripper.getLiquidOutStream()); + + heatEx2.setFeedStream(1, heatEx.getOutStream(1)); + + Pump hotLeanTEGPump = new Pump("lean TEG LP pump", heatEx2.getOutStream(1)); + hotLeanTEGPump.setOutletPressure(40.0); + hotLeanTEGPump.setIsentropicEfficiency(0.9); + + Stream makeupTEG = new Stream("makeup TEG", pureTEG); + makeupTEG.setFlowRate(1e-6, "kg/hr"); + makeupTEG.setTemperature(100.0, "C"); + makeupTEG.setPressure(40.0, "bara"); + + Calculator makeupCalculator = new Calculator("TEG makeup calculator"); + makeupCalculator.addInputVariable(dehydratedGas); + makeupCalculator.addInputVariable(flashGas); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.setOutputVariable(makeupTEG); + + StaticMixer makeupMixer = new StaticMixer("makeup mixer"); + makeupMixer.addStream(hotLeanTEGPump.getOutletStream()); + makeupMixer.addStream(makeupTEG); + + Heater coolerhOTteg3 = new Heater("lean TEG cooler", makeupMixer.getOutletStream()); + coolerhOTteg3.setOutTemperature(273.15 + 40.0); + + condHeat.setEnergyStream(column.getCondenser().getEnergyStream()); + + Stream leanTEGtoabs = new Stream("resyc lean TEG to absorber", coolerhOTteg3.getOutletStream()); + + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(leanTEGtoabs); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGasSmorbukk); + operations.add(saturatedFeedGasSmorbukk); + operations.add(waterSaturatedFeedGasSmorbukk); + operations.add(hydrateTAnalyserSmorbukk); + operations.add(SmorbukkSplit); + + operations.add(dryFeedGasMidgard); + operations.add(saturatedFeedGasMidgard); + operations.add(waterSaturatedFeedGasMidgard); + operations.add(hydrateTAnalyserMidgard); + + operations.add(MidgardSplit); + + operations.add(TrainB); + + operations.add(feedTPsetterToAbsorber); + operations.add(feedToAbsorber); + operations.add(hydrateTAnalyser2); + operations.add(waterDewPointAnalyserToAbsorber); + operations.add(TEGFeed); + operations.add(absorber); + operations.add(dehydratedGas); + operations.add(richTEG); + operations.add(waterDewPointAnalyser); + operations.add(waterDewPointAnalyser2); + + operations.add(condHeat); + + operations.add(glycol_flash_valve); + operations.add(heatEx2); + operations.add(waterFeed); + operations.add(flashSep); + operations.add(flashGas); + operations.add(flashLiquid); + + operations.add(filter); + operations.add(heatEx); + operations.add(glycol_flash_valve2); + operations.add(strippingGas); + + operations.add(gasToReboiler); + operations.add(column); + + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(liquidToTrreatment); + + operations.add(stripper); + operations.add(recycleGasFromStripper); + + operations.add(hotLeanTEGPump); + operations.add(makeupTEG); + operations.add(makeupCalculator); + operations.add(makeupMixer); + operations.add(coolerhOTteg3); + operations.add(leanTEGtoabs); + operations.add(recycleLeanTEG); + operations.run(); + dryFeedGasMidgard.setFlowRate(11.1, "MSm3/day"); + operations.run_step(); + dryFeedGasMidgard.setFlowRate(12.3, "MSm3/day"); + operations.run_step(); + dryFeedGasMidgard.setFlowRate(13.5, "MSm3/day"); + ProcessSystem ops2 = operations.copy(); + operations.setRunInSteps(true); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + ProcessSystem ops3 = operations.copy(); + operations.run(); + operations.run(); + dryFeedGasMidgard.setFlowRate(10.0, "MSm3/day"); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + operations.run(); + assertEquals(1.5322819175995646E-5, dehydratedGas.getFluid().getComponent("water").getx(), + 1e-6); + + operations.run(); + operations.run(); + operations.run(); + operations.run(); + assertEquals(1.5322819175995646E-5, dehydratedGas.getFluid().getComponent("water").getx(), + 1e-6); + + // run as time step as thread + Thread thread = operations.runAsThread(); + Thread thread2 = ops2.runAsThread(); + Thread thread3 = ops3.runAsThread(); + try { + thread.join(); + thread2.join(); + thread3.join(); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/ReferenceProcessTest.java b/src/test/java/neqsim/processSimulation/processSystem/ReferenceProcessTest.java new file mode 100644 index 0000000000..8660fc057b --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/ReferenceProcessTest.java @@ -0,0 +1,117 @@ +package neqsim.processSimulation.processSystem; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class ReferenceProcessTest extends neqsim.NeqSimTest { + + @Test + public void testProcess() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.addComponent("nitrogen", 51.0); + thermoSystem.addComponent("CO2", 51.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 51.0); + thermoSystem.addComponent("propane", 51.0); + thermoSystem.addComponent("i-butane", 51.0); + thermoSystem.addComponent("n-butane", 51.0); + thermoSystem.addComponent("iC5", 51.0); + thermoSystem.addComponent("nC5", 1.0); + + thermoSystem.addTBPfraction("C6", 1.0, 86.0 / 1000.0, 0.66); + thermoSystem.addTBPfraction("C7", 1.0, 91.0 / 1000.0, 0.74); + thermoSystem.addTBPfraction("C8", 1.0, 103.0 / 1000.0, 0.77); + thermoSystem.addTBPfraction("C9", 1.0, 117.0 / 1000.0, 0.79); + thermoSystem.addPlusFraction("C10_C12", 1.0, 145.0 / 1000.0, 0.80); + thermoSystem.addPlusFraction("C13_C14", 1.0, 181.0 / 1000.0, 0.8279); + thermoSystem.addPlusFraction("C15_C16", 1.0, 212.0 / 1000.0, 0.837); + thermoSystem.addPlusFraction("C17_C19", 1.0, 248.0 / 1000.0, 0.849); + thermoSystem.addPlusFraction("C20_C22", 1.0, 289.0 / 1000.0, 0.863); + thermoSystem.addPlusFraction("C23_C25", 1.0, 330.0 / 1000.0, 0.875); + thermoSystem.addPlusFraction("C26_C30", 1.0, 387.0 / 1000.0, 0.88); + thermoSystem.addPlusFraction("C31_C38", 1.0, 471.0 / 1000.0, 0.90); + thermoSystem.addPlusFraction("C38_C80", 1.0, 662.0 / 1000.0, 0.92); + thermoSystem.setMixingRule("classic"); + // thermoSystem.setMultiPhaseCheck(true); + + thermoSystem.setMolarComposition(new double[] {0.005269, 0.039189, 0.700553, 0.091154, 0.050908, + 0.007751, 0.014665, 0.004249, 0.004878, 0.004541, 0.007189, 0.006904, 0.004355, 0.007658, + 0.003861, 0.003301, 0.002624, 0.001857, 0.001320, 0.001426, 0.001164, 0.000916}); + + neqsim.processSimulation.processEquipment.stream.Stream wellStream = + new neqsim.processSimulation.processEquipment.stream.Stream("well stream", thermoSystem); + wellStream.setTemperature(70.0, "C"); + wellStream.setPressure(90.0, "bara"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator firstStageSeparator = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "1st stage separator", wellStream); + + neqsim.processSimulation.processEquipment.heatExchanger.Heater oilHeaterSecondStage = + new neqsim.processSimulation.processEquipment.heatExchanger.Heater( + "oil heater second stage", firstStageSeparator.getOilOutStream()); + oilHeaterSecondStage.setOutPressure(30.0); + oilHeaterSecondStage.setOutTemperature(68.0, "C"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator secondStageSeparator = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "2nd stage separator", oilHeaterSecondStage.getOutStream()); + + neqsim.processSimulation.processEquipment.heatExchanger.Heater oilHeaterThirdStage = + new neqsim.processSimulation.processEquipment.heatExchanger.Heater("oil heater third stage", + secondStageSeparator.getOilOutStream()); + oilHeaterThirdStage.setOutPressure(2.8); + oilHeaterThirdStage.setOutTemperature(70.0, "C"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator thirdStageSeparator = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "3rd stage separator", oilHeaterThirdStage.getOutStream()); + + neqsim.processSimulation.processEquipment.heatExchanger.Heater oilHeaterStandardStage = + new neqsim.processSimulation.processEquipment.heatExchanger.Heater( + "oil heater standard stage", thirdStageSeparator.getOilOutStream()); + oilHeaterStandardStage.setOutPressure(1.01325); + oilHeaterStandardStage.setOutTemperature(15.0, "C"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator standardStageSeparator = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "standard stage separator", oilHeaterStandardStage.getOutStream()); + + neqsim.processSimulation.processEquipment.mixer.Mixer gasMixer = + new neqsim.processSimulation.processEquipment.mixer.Mixer("gas mixer"); + gasMixer.addStream(firstStageSeparator.getGasOutStream()); + gasMixer.addStream(secondStageSeparator.getGasOutStream()); + gasMixer.addStream(thirdStageSeparator.getGasOutStream()); + gasMixer.addStream(standardStageSeparator.getGasOutStream()); + gasMixer.setOutTemperature(288.15); + + neqsim.processSimulation.processEquipment.stream.Stream exportoil = + new neqsim.processSimulation.processEquipment.stream.Stream("export oil", + standardStageSeparator.getOilOutStream()); + neqsim.processSimulation.processEquipment.stream.Stream exportgas = + new neqsim.processSimulation.processEquipment.stream.Stream("export gas", + gasMixer.getOutStream()); + + neqsim.processSimulation.processSystem.ProcessSystem oilprocess = + new neqsim.processSimulation.processSystem.ProcessSystem(); + oilprocess.add(wellStream); + oilprocess.add(firstStageSeparator); + oilprocess.add(oilHeaterSecondStage); + oilprocess.add(secondStageSeparator); + oilprocess.add(oilHeaterThirdStage); + oilprocess.add(thirdStageSeparator); + oilprocess.add(oilHeaterStandardStage); + oilprocess.add(standardStageSeparator); + oilprocess.add(gasMixer); + oilprocess.add(exportoil); + oilprocess.add(exportgas); + + oilprocess.run(); + + assertEquals(15.0, gasMixer.getOutStream().getTemperature("C"), 0.01); + assertEquals(2278.2594247, exportgas.getFlowRate("Sm3/hr") / exportoil.getFlowRate("idSm3/hr"), + 0.01); + } +} diff --git a/src/test/java/neqsim/processSimulation/processSystem/waterDegasserTest.java b/src/test/java/neqsim/processSimulation/processSystem/waterDegasserTest.java index 1cf8e7374b..8aaaec7062 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/waterDegasserTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/waterDegasserTest.java @@ -175,7 +175,7 @@ public void runProcess2() throws InterruptedException { * heater_TP_setter_main_stream.setOutTemperature(77.92657470703125, "C"); * heater_TP_setter_main_stream.run(); * System.out.println(heater_TP_setter_main_stream.getOutStream().getFlowRate( "kg/hr")); - * + * * neqsim.thermo.system.SystemSrkCPAstatoil fluid_test_separator = new * neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); * fluid_test_separator.addComponent("water", 0.15); @@ -215,32 +215,31 @@ public void runProcess2() throws InterruptedException { * 036010742188/1000,608 .036010742188/(1000*0.642772477456171)); * fluid_test_separator.setMixingRule(10); fluid_test_separator.setMultiPhaseCheck(true); * fluid_test_separator.init(0); - * + * * neqsim.processSimulation.processEquipment.stream.Stream inlet_stream_test_sep = new * neqsim.processSimulation.processEquipment.stream.Stream( * "TEST_SEPARATOR_INLET,fluid_test_separator", fluid_test_separator); * inlet_stream_test_sep.setTemperature(39.92721557617188, "C"); * inlet_stream_test_sep.setPressure(1.4343990154266357, "bara"); * inlet_stream_test_sep.setFlowRate(472.5621656362427, "kg/hr"); inlet_stream_test_sep.run(); - * + * * neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator test_separator = new - * neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( - * inlet_stream_test_sep); test_separator.setName("TEST_SEPARATOR"); test_separator.run(); - * + * neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator("TEST_SEPARATOR", + * inlet_stream_test_sep); test_separator.run(); + * * neqsim.processSimulation.processEquipment.heatExchanger.Heater heater_TP_setter_test_stream = * new neqsim.processSimulation.processEquipment.heatExchanger.Heater( * "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); * heater_TP_setter_test_stream.setOutPressure(6.22176469039917, "bara"); * heater_TP_setter_test_stream.setOutTemperature(77.92657470703125, "C"); * heater_TP_setter_test_stream.run(); - * + * * neqsim.processSimulation.processEquipment.mixer.StaticMixer mixing_degasser = new - * neqsim.processSimulation.processEquipment.mixer.StaticMixer(); - * mixing_degasser.setName("MIXING_BEFORE_THE_DEGASSER"); + * neqsim.processSimulation.processEquipment.mixer.StaticMixer(MIXING_BEFORE_THE_DEGASSER); * mixing_degasser.addStream(heater_TP_setter_main_stream.getOutStream()); * mixing_degasser.addStream(heater_TP_setter_test_stream.getOutStream()); * mixing_degasser.run(); - * + * * System.out.println(mixing_degasser.getOutStream().getFlowRate("kg/hr")); // Should be arount * 33946.08070091751 */ diff --git a/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java b/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java index 135589a1df..7ca17be9fd 100644 --- a/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java +++ b/src/test/java/neqsim/processSimulation/util/example/LNGtankfilling.java @@ -6,6 +6,7 @@ import neqsim.processSimulation.processEquipment.tank.Tank; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; import neqsim.processSimulation.processEquipment.valve.ValveInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *LNGtankfilling class.
@@ -60,7 +61,7 @@ public static void main(String args[]) { Stream stream_1 = new Stream("Methane Stream", testSystem); ValveInterface valve = new ThrottlingValve("valve", stream_1); - valve.setOutletPressure(1.01325 + 0.110); + valve.setOutletPressure(ThermodynamicConstantsInterface.referencePressure + 0.110); Tank tank = new neqsim.processSimulation.processEquipment.tank.Tank("tank"); tank.addStream(valve.getOutletStream()); @@ -84,7 +85,7 @@ public static void main(String args[]) { // ControllerDeviceInterface pressureController = new ControllerDeviceBaseClass(); // pressureController.setTransmitter(tankPressureTransmitter); // pressureController.setReverseActing(false); - // pressureController.setControllerSetPoint(1.01325+0.110); + // pressureController.setControllerSetPoint(ThermodynamicConstantsInterface.referencePressure+0.110); // pressureController.setControllerParameters(2.0,400,0); neqsim.processSimulation.processSystem.ProcessSystem operations = diff --git a/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java b/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java index c5a9bc5020..1ed26d758e 100644 --- a/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java +++ b/src/test/java/neqsim/processSimulation/util/example/MEGinjection.java @@ -18,125 +18,124 @@ * @since 2.2.3 */ public class MEGinjection { - /** - *- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - // Create the input fluid to the TEG process and saturate it with water at - // scrubber conditions - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 1.03); - feedGas.addComponent("CO2", 1.42); - feedGas.addComponent("methane", 83.88); - feedGas.addComponent("ethane", 8.07); - feedGas.addComponent("propane", 3.54); - feedGas.addComponent("i-butane", 0.54); - feedGas.addComponent("n-butane", 0.84); - feedGas.addComponent("i-pentane", 0.21); - feedGas.addComponent("n-pentane", 0.19); - feedGas.addComponent("n-hexane", 0.28); - feedGas.addComponent("n-heptane", 1.28); - feedGas.addComponent("n-octane", 1.28); - feedGas.addComponent("n-nonane", 2.28); - feedGas.addComponent("water", 2.0); - feedGas.addComponent("MEG", 0.0); - feedGas.createDatabase(true); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(true); - - Stream feedGasStream = new Stream("feed fluid", feedGas); - feedGasStream.run(); - feedGasStream.setFlowRate(11.23, "MSm3/day"); - feedGasStream.setTemperature(50.0, "C"); - feedGasStream.setPressure(55.00, "bara"); - - neqsim.thermo.system.SystemInterface feedMEG = feedGas.clone(); - feedMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.1, 0.9}); - - Stream MEGFeed = new Stream("lean MEG feed stream", feedMEG); - MEGFeed.setFlowRate(1000.0, "kg/hr"); - MEGFeed.setTemperature(50.0, "C"); - MEGFeed.setPressure(55.0, "bara"); - - StaticMixer feedGasMEGmixer = new StaticMixer("MEG-gas mixer"); - feedGasMEGmixer.addStream(feedGasStream); - feedGasMEGmixer.addStream(MEGFeed); - - Heater pipeline = new Heater("gas-MEG pipeline", feedGasMEGmixer.getOutletStream()); - pipeline.setOutTemperature(273.15 + 35.5); - pipeline.setOutPressure(80.2); - - Stream mixerStream = (Stream) pipeline.getOutletStream(); - mixerStream.setName("feed gas and MEG"); - - Adjuster adjuster = new Adjuster("MEG adjuster"); - adjuster.setAdjustedVariable(MEGFeed, "mass flow"); - adjuster.setTargetVariable(mixerStream, "mass fraction", 0.6, "-", "aqueous", "MEG"); - - neqsim.processSimulation.processSystem.ProcessSystem MEGwelloperations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - MEGwelloperations.add(feedGasStream); - MEGwelloperations.add(MEGFeed); - MEGwelloperations.add(feedGasMEGmixer); - MEGwelloperations.add(pipeline); - MEGwelloperations.add(mixerStream); - MEGwelloperations.add(adjuster); - - MEGwelloperations.run(); - // operations.run(); - - MEGwelloperations.save("c:/temp/MEGinjection.neqsim"); - - Stream feedStream = new Stream("feed to onhore", - (Stream) MEGwelloperations.getUnit("feed gas and MEG")); - - ThrottlingValve onshoreChockeValve = new ThrottlingValve("onshore choke valve", feedStream); - onshoreChockeValve.setOutletPressure(70.3); - - ThreePhaseSeparator slugCatcher = - new ThreePhaseSeparator("slug catcher", onshoreChockeValve.getOutletStream()); - - neqsim.thermo.system.SystemInterface feedMEGOnshore = feedGas.clone(); - feedMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.1, 0.9}); - - Stream MEGFeedOnshore = new Stream("lean MEG feed stream", feedMEGOnshore); - MEGFeedOnshore.setFlowRate(1000.0, "kg/hr"); - MEGFeedOnshore.setTemperature(35.0, "C"); - MEGFeedOnshore.setPressure(80.0, "bara"); - - neqsim.processSimulation.processEquipment.splitter.Splitter MEGsplitter = - new Splitter("MEG splitter", MEGFeedOnshore); - MEGsplitter.setSplitFactors(new double[] {0.1, 0.1, 0.8}); - - StaticMixer MEGmixer1 = new StaticMixer("MEG mixer 1"); - MEGmixer1.addStream(slugCatcher.getGasOutStream()); - MEGmixer1.addStream(MEGsplitter.getSplitStream(0)); - - ThrottlingValve DPvalve1 = new ThrottlingValve("DP valve 1", MEGmixer1.getOutletStream()); - DPvalve1.setOutletPressure(70.0); - - neqsim.processSimulation.processSystem.ProcessSystem onshoreOperations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - onshoreOperations.add(feedStream); - onshoreOperations.add(onshoreChockeValve); - onshoreOperations.add(slugCatcher); - onshoreOperations.add(MEGFeedOnshore); - onshoreOperations.add(MEGsplitter); - onshoreOperations.add(MEGmixer1); - onshoreOperations.add(DPvalve1); - - onshoreOperations.run(); - - onshoreOperations.save("c:/temp/MEGonshore.neqsim"); - - // feedGasMEGmixer.getThermoSystem().display(); - DPvalve1.getThermoSystem().display(); - } + /** + *+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + // Create the input fluid to the TEG process and saturate it with water at + // scrubber conditions + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 1.03); + feedGas.addComponent("CO2", 1.42); + feedGas.addComponent("methane", 83.88); + feedGas.addComponent("ethane", 8.07); + feedGas.addComponent("propane", 3.54); + feedGas.addComponent("i-butane", 0.54); + feedGas.addComponent("n-butane", 0.84); + feedGas.addComponent("i-pentane", 0.21); + feedGas.addComponent("n-pentane", 0.19); + feedGas.addComponent("n-hexane", 0.28); + feedGas.addComponent("n-heptane", 1.28); + feedGas.addComponent("n-octane", 1.28); + feedGas.addComponent("n-nonane", 2.28); + feedGas.addComponent("water", 2.0); + feedGas.addComponent("MEG", 0.0); + feedGas.createDatabase(true); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(true); + + Stream feedGasStream = new Stream("feed fluid", feedGas); + feedGasStream.run(); + feedGasStream.setFlowRate(11.23, "MSm3/day"); + feedGasStream.setTemperature(50.0, "C"); + feedGasStream.setPressure(55.00, "bara"); + + neqsim.thermo.system.SystemInterface feedMEG = feedGas.clone(); + feedMEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.9}); + + Stream MEGFeed = new Stream("lean MEG feed stream", feedMEG); + MEGFeed.setFlowRate(1000.0, "kg/hr"); + MEGFeed.setTemperature(50.0, "C"); + MEGFeed.setPressure(55.0, "bara"); + + StaticMixer feedGasMEGmixer = new StaticMixer("MEG-gas mixer"); + feedGasMEGmixer.addStream(feedGasStream); + feedGasMEGmixer.addStream(MEGFeed); + + Heater pipeline = new Heater("gas-MEG pipeline", feedGasMEGmixer.getOutletStream()); + pipeline.setOutTemperature(273.15 + 35.5); + pipeline.setOutPressure(80.2); + + Stream mixerStream = new Stream("feed gas and MEG", pipeline.getOutletStream()); + + Adjuster adjuster = new Adjuster("MEG adjuster"); + adjuster.setAdjustedVariable(MEGFeed, "mass flow"); + adjuster.setTargetVariable(mixerStream, "mass fraction", 0.6, "-", "aqueous", "MEG"); + + neqsim.processSimulation.processSystem.ProcessSystem MEGwelloperations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + MEGwelloperations.add(feedGasStream); + MEGwelloperations.add(MEGFeed); + MEGwelloperations.add(feedGasMEGmixer); + MEGwelloperations.add(pipeline); + MEGwelloperations.add(mixerStream); + MEGwelloperations.add(adjuster); + + MEGwelloperations.run(); + // operations.run(); + + MEGwelloperations.save("c:/temp/MEGinjection.neqsim"); + + Stream feedStream = + new Stream("feed to onhore", (Stream) MEGwelloperations.getUnit("feed gas and MEG")); + + ThrottlingValve onshoreChockeValve = new ThrottlingValve("onshore choke valve", feedStream); + onshoreChockeValve.setOutletPressure(70.3); + + ThreePhaseSeparator slugCatcher = + new ThreePhaseSeparator("slug catcher", onshoreChockeValve.getOutletStream()); + + neqsim.thermo.system.SystemInterface feedMEGOnshore = feedGas.clone(); + feedMEG.setMolarComposition( + new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.9}); + + Stream MEGFeedOnshore = new Stream("lean MEG feed stream", feedMEGOnshore); + MEGFeedOnshore.setFlowRate(1000.0, "kg/hr"); + MEGFeedOnshore.setTemperature(35.0, "C"); + MEGFeedOnshore.setPressure(80.0, "bara"); + + neqsim.processSimulation.processEquipment.splitter.Splitter MEGsplitter = + new Splitter("MEG splitter", MEGFeedOnshore); + MEGsplitter.setSplitFactors(new double[] {0.1, 0.1, 0.8}); + + StaticMixer MEGmixer1 = new StaticMixer("MEG mixer 1"); + MEGmixer1.addStream(slugCatcher.getGasOutStream()); + MEGmixer1.addStream(MEGsplitter.getSplitStream(0)); + + ThrottlingValve DPvalve1 = new ThrottlingValve("DP valve 1", MEGmixer1.getOutletStream()); + DPvalve1.setOutletPressure(70.0); + + neqsim.processSimulation.processSystem.ProcessSystem onshoreOperations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + onshoreOperations.add(feedStream); + onshoreOperations.add(onshoreChockeValve); + onshoreOperations.add(slugCatcher); + onshoreOperations.add(MEGFeedOnshore); + onshoreOperations.add(MEGsplitter); + onshoreOperations.add(MEGmixer1); + onshoreOperations.add(DPvalve1); + + onshoreOperations.run(); + + onshoreOperations.save("c:/temp/MEGonshore.neqsim"); + + // feedGasMEGmixer.getThermoSystem().display(); + DPvalve1.getThermoSystem().display(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java b/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java index 36c23238c6..eac9492228 100644 --- a/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java +++ b/src/test/java/neqsim/processSimulation/util/example/MasstransferMeOH.java @@ -5,6 +5,7 @@ import neqsim.processSimulation.processEquipment.separator.GasScrubber; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *@@ -88,9 +89,10 @@ public static void main(String[] args) { // operations.run(); // ((DistillationColumn)operations.getUnit("TEG regeneration // column")).setNumberOfTrays(2); - System.out.println("water in wet gas [kg/MSm3] " - + ((Stream) operations.getUnit("water saturated feed gas")).getFluid().getPhase(0) - .getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + System.out.println( + "water in wet gas [kg/MSm3] " + ((Stream) operations.getUnit("water saturated feed gas")) + .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 + * ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15)); // mainMixer.getFluid().display(); // scrubber.getGasOutStream().displayResult(); System.out.println("hydt " + gasFromScrubber.getHydrateEquilibriumTemperature()); diff --git a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java index 755a59453f..e4b46fe6a8 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java +++ b/src/test/java/neqsim/processSimulation/util/example/OffshoreProcess3.java @@ -11,6 +11,7 @@ import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.util.SetPoint; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemSrkEos; /** @@ -82,7 +83,7 @@ public static void main(String[] args) { ThrottlingValve waterDPvalve = new ThrottlingValve("Water HP to LP valve", inletSeparator.getWaterOutStream()); - waterDPvalve.setOutletPressure(1.01325); + waterDPvalve.setOutletPressure(ThermodynamicConstantsInterface.referencePressure); Separator waterStabSep = new Separator("water degassing separator", waterDPvalve.getOutletStream()); @@ -105,8 +106,7 @@ public static void main(String[] args) { ThreePhaseSeparator lpseparator = new ThreePhaseSeparator("3rd stage separator", valvempValve.getOutletStream()); - Stream stableOilStream = (Stream) lpseparator.getOilOutStream(); - stableOilStream.setName("stable oil"); + Stream stableOilStream = new Stream("stable oil", lpseparator.getOilOutStream()); Compressor lpcompressor = new Compressor("1st stage recompressor", lpseparator.getGasOutStream()); @@ -127,11 +127,10 @@ public static void main(String[] args) { * Stream coolingWater = new Stream("cooling water", coolingWaterSYstm); * coolingWater.setFlowRate(500900.2, "kg/hr"); coolingWater.setTemperature(10.0, "C"); * coolingWater.setPressure(10.0, "bara"); - * - * HeatExchanger heatEx = new HeatExchanger(lpcompressor.getOutStream()); - * heatEx.setName("LP heat Exchanger"); heatEx.setGuessOutTemperature(273.15+40.0); - * heatEx.setUAvalue(45000.0); heatEx.setFeedStream(1, coolingWater); - * + * + * HeatExchanger heatEx = new HeatExchanger("LP heat Exchanger",lpcompressor.getOutStream()); + * heatEx.setGuessOutTemperature(273.15+40.0); heatEx.setUAvalue(45000.0); + * heatEx.setFeedStream(1, coolingWater); */ Cooler lpHeatExchanger = @@ -280,28 +279,27 @@ public static void main(String[] args) { /* * // System.out.println("second stage comp power " + ((Compressor) // * operations.getUnit("2nd stage recompressor")).getPower()/1.0e3 + " kW"); - * + * * // System.out.println("first stage comp power " + ((Compressor) * operations.getUnit("1st stage recompressor")).getPower()/1.0e3 + " kW"); - * + * * System.out.println("gas from inlet separator " + ((Separator) * operations.getUnit("1st stage separator")) * .getGasOutStream().getFluid().getFlowRate("MSm3/day")); - * + * * System.out .println("pressure of export oil " + ((Stream) * operations.getUnit("stable oil")).getPressure("bara")); - * + * * System.out.println( "temperature of export oil " + ((Stream) * operations.getUnit("stable oil")).getTemperature("C")); - * + * * System.out.println("TVP of export oil (30.0 C) " + ((Stream) * operations.getUnit("stable oil")).TVP(30.0, "C")); - * + * * // System.out.println("entropy production " + // operations.getEntropyProduction("J/K") + * " J/K"); // System.out.println("mass balance separator " + ((Separator) * operations.getUnit("scrubber of mix gas HP")).getMassBalance("kg/sec") + " kg/sec"); - * - * + * * // liqFromlpscrubber.displayResult(); // richGas.phaseEnvelope(); // richGas.displayResult(); * operations.save("c:/temp/offshorePro.neqsim"); * inletSeparator.getLiquidOutStream().getFluid().display(); diff --git a/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java b/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java index 89b4c0b187..2272d3a2b6 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java +++ b/src/test/java/neqsim/processSimulation/util/example/OnshoreMEGprocess.java @@ -28,282 +28,270 @@ * @since 2.2.3 */ public class OnshoreMEGprocess { - /** - *
- * main. - *
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String[] args) { - neqsim.thermo.system.SystemInterface feedGas = - new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); - feedGas.addComponent("nitrogen", 0.4); - feedGas.addComponent("CO2", 0.00042); - feedGas.addComponent("methane", 99.0); - feedGas.addComponent("ethane", 0.07); - feedGas.addComponent("propane", 0.054); - feedGas.addComponent("i-butane", 0.0054); - feedGas.addComponent("n-butane", 0.0084); - feedGas.addComponent("water", 0.0); - feedGas.addComponent("MEG", 0); - feedGas.createDatabase(true); - feedGas.setMixingRule(10); - feedGas.setMultiPhaseCheck(true); - - Stream dryFeedGas = new Stream("feed gas", feedGas); - dryFeedGas.setFlowRate(10.5, "MSm3/day"); - dryFeedGas.setTemperature(6.0, "C"); - dryFeedGas.setPressure(53.0, "bara"); - - StreamSaturatorUtil saturatedFeedGas = - new StreamSaturatorUtil("water saturator", dryFeedGas); - - Stream waterSaturatedFeedGas = - new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); - - Compressor inletCompressor = - new Compressor("Compressor 1 - first stage", waterSaturatedFeedGas); - inletCompressor.setOutletPressure(70.0, "bara"); - - Cooler interstageGasCooler = - new Cooler("Compressor 1 - interstage cooler", inletCompressor.getOutletStream()); - interstageGasCooler.setOutTemperature(40.0, "C"); - - Compressor inletCompressor2ndstage = - new Compressor("Compressor 1 - second stage", interstageGasCooler.getOutletStream()); - inletCompressor2ndstage.setOutletPressure(105.0, "bara"); - - neqsim.thermo.system.SystemInterface feedMEG = feedGas.clone(); - feedMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.6}); - - Stream MEGFeed = new Stream("lean MEG to header", feedMEG); - MEGFeed.setFlowRate(1000.0, "kg/hr"); - MEGFeed.setTemperature(20.0, "C"); - MEGFeed.setPressure(105.0, "bara"); + /** + *+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String[] args) { + neqsim.thermo.system.SystemInterface feedGas = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + feedGas.addComponent("nitrogen", 0.4); + feedGas.addComponent("CO2", 0.00042); + feedGas.addComponent("methane", 99.0); + feedGas.addComponent("ethane", 0.07); + feedGas.addComponent("propane", 0.054); + feedGas.addComponent("i-butane", 0.0054); + feedGas.addComponent("n-butane", 0.0084); + feedGas.addComponent("water", 0.0); + feedGas.addComponent("MEG", 0); + feedGas.createDatabase(true); + feedGas.setMixingRule(10); + feedGas.setMultiPhaseCheck(true); - Splitter MEGsplitter1 = new Splitter("lean MEG header", MEGFeed); - MEGsplitter1.setSplitFactors(new double[] {0.01, 0.94, 0.05}); + Stream dryFeedGas = new Stream("feed gas", feedGas); + dryFeedGas.setFlowRate(10.5, "MSm3/day"); + dryFeedGas.setTemperature(6.0, "C"); + dryFeedGas.setPressure(53.0, "bara"); + + StreamSaturatorUtil saturatedFeedGas = new StreamSaturatorUtil("water saturator", dryFeedGas); - StaticMixer MEGmixer1 = new StaticMixer("MEG mixer 1"); - MEGmixer1.addStream(inletCompressor2ndstage.getOutletStream()); - MEGmixer1.addStream(MEGsplitter1.getSplitStream(0)); + Stream waterSaturatedFeedGas = + new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); - Cooler inletGasCooler = new Cooler("dehydration cooler", MEGmixer1.getOutletStream()); - inletGasCooler.setOutTemperature(10.0, "C"); + Compressor inletCompressor = + new Compressor("Compressor 1 - first stage", waterSaturatedFeedGas); + inletCompressor.setOutletPressure(70.0, "bara"); - StaticMixer MEGmixer2 = new StaticMixer("MEG mixer 2"); - MEGmixer2.addStream(inletGasCooler.getOutletStream()); - MEGmixer2.addStream(MEGsplitter1.getSplitStream(1)); + Cooler interstageGasCooler = + new Cooler("Compressor 1 - interstage cooler", inletCompressor.getOutletStream()); + interstageGasCooler.setOutTemperature(40.0, "C"); - HeatExchanger heatEx = - new HeatExchanger("gas-gas heat exchanger", MEGmixer2.getOutletStream()); - heatEx.setGuessOutTemperature(273.15 - 10.0); - heatEx.setUAvalue(30000.0); - - StaticMixer MEGmixer3 = new StaticMixer("MEG mixer 3"); - MEGmixer3.addStream(heatEx.getOutStream(0)); - MEGmixer3.addStream(MEGsplitter1.getSplitStream(2)); - - ThrottlingValve presRedValveLT = - new ThrottlingValve("JT valve", MEGmixer3.getOutletStream()); - presRedValveLT.setOutletPressure(92.0); + Compressor inletCompressor2ndstage = + new Compressor("Compressor 1 - second stage", interstageGasCooler.getOutletStream()); + inletCompressor2ndstage.setOutletPressure(105.0, "bara"); - ThreePhaseSeparator mpseparator = - new ThreePhaseSeparator("low temperature scrubber", presRedValveLT.getOutletStream()); - - Stream coldGasFromSep = new Stream("gas from cold scrubber", mpseparator.getGasOutStream()); - - heatEx.setFeedStream(1, coldGasFromSep); - - Stream heatedGasFromLPSep = - new Stream("heated gas from cold scrubber", heatEx.getOutStream(1)); + neqsim.thermo.system.SystemInterface feedMEG = feedGas.clone(); + feedMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.6}); - Stream richMEGstream = new Stream("rich cold MEG stream", mpseparator.getWaterOutStream()); - - Heater richMEGstreamHeater = new Heater("rich MEG pre-heater", richMEGstream); - richMEGstreamHeater.setOutTemperature(15.0, "C"); - - Heater richMEGstreamHeater2 = - new Heater("column condenser HX", richMEGstreamHeater.getOutletStream()); - // richMEGstreamHeater2.setOutTemperature(22.0, "C"); - - ThrottlingValve presRedValve3 = - new ThrottlingValve("valve to flash drum", richMEGstreamHeater2.getOutletStream()); - presRedValve3.setOutletPressure(3.9); - - Separator flashDrumSep = - new Separator("rich MEG flash drum", presRedValve3.getOutletStream()); - - Stream flashGasStream = new Stream("gas from flash drum", flashDrumSep.getGasOutStream()); - - Stream flashLiquidStream = - new Stream("rich TEG from flash drum", flashDrumSep.getLiquidOutStream()); - - HeatExchanger columnPreHeater = - new HeatExchanger("MEG/MEG heat exchanger", flashLiquidStream); - columnPreHeater.setGuessOutTemperature(273.15 + 120.0); - columnPreHeater.setUAvalue(500.0); - - ThrottlingValve presRedValve4 = - new ThrottlingValve("valve to regenerator", columnPreHeater.getOutStream(0)); - presRedValve4.setOutletPressure(1.23); - - DistillationColumn column = new DistillationColumn(2, true, true); - column.setName("MEG regeneration column"); - column.addFeedStream(presRedValve4.getOutletStream(), 0); - column.getReboiler().setOutTemperature(273.15 + 135.0); - column.getCondenser().setOutTemperature(273.15 + 105.0); - column.setTopPressure(1.0); - column.setBottomPressure(1.23); - - Cooler coolerRegenGas = - new Cooler("regeneration overhead gas cooler", column.getGasOutStream()); - coolerRegenGas.setOutTemperature(273.15 + 20.0); - - Separator sepregenGas = - new Separator("overhead condenser scrubber", coolerRegenGas.getOutletStream()); - - Stream gasToFlare = - new Stream("gas to flare from regenerator", sepregenGas.getGasOutStream()); - - Stream waterToSea = - new Stream("condensed water from regenerator", sepregenGas.getLiquidOutStream()); - - Cooler bufferTank = new Cooler("MEG buffer tank", column.getLiquidOutStream()); - bufferTank.setOutTemperature(273.15 + 130.0); - - Pump hotLeanMEGPump = new Pump("hot lean MEG pump", bufferTank.getOutletStream()); - hotLeanMEGPump.setOutletPressure(105.0); - hotLeanMEGPump.setIsentropicEfficiency(0.75); - - Stream streamHotPump = - new Stream("stream from hot lean MEG pump", hotLeanMEGPump.getOutletStream()); - - columnPreHeater.setFeedStream(1, streamHotPump); - - Cooler coolerHotMEG2 = new Cooler("lean MEG cooler", columnPreHeater.getOutStream(1)); - coolerHotMEG2.setOutTemperature(273.15 + 20.0); - - Stream leanMEGtoMixer = - new Stream("lean MEG to makeup mixer", coolerHotMEG2.getOutletStream()); - - neqsim.thermo.system.SystemInterface pureMEG = feedGas.clone(); - pureMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); - - Stream makeupMEG = new Stream("makeup MEG", pureMEG); - makeupMEG.setFlowRate(1e-6, "kg/hr"); - makeupMEG.setTemperature(20.0, "C"); - makeupMEG.setPressure(105.0, "bara"); - - Calculator makeupCalculator = new Calculator("MEG makeup calculator"); - makeupCalculator.addInputVariable(coldGasFromSep); - makeupCalculator.addInputVariable(waterToSea); - makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(flashGasStream); - makeupCalculator.setOutputVariable(makeupMEG); - - StaticMixer makeupMixer = new StaticMixer("MEG makeup mixer"); - makeupMixer.addStream(leanMEGtoMixer); - makeupMixer.addStream(makeupMEG); - - Stream streamToResycle = new Stream("streamToResycle", makeupMixer.getOutletStream()); - - Recycle resycleLeanMEG = new Recycle("lean MEG resycle"); - resycleLeanMEG.addStream(streamToResycle); - resycleLeanMEG.setOutletStream(MEGFeed); - // resycleLeanMEG.setPriority(200); - resycleLeanMEG.setDownstreamProperty("flow rate"); - - richMEGstreamHeater2.setEnergyStream(column.getCondenser().getEnergyStream()); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(dryFeedGas); - operations.add(saturatedFeedGas); - operations.add(waterSaturatedFeedGas); - operations.add(inletCompressor); - operations.add(interstageGasCooler); - operations.add(inletCompressor2ndstage); - operations.add(MEGFeed); - operations.add(MEGsplitter1); - operations.add(MEGmixer1); - operations.add(inletGasCooler); - operations.add(MEGmixer2); - operations.add(heatEx); - operations.add(MEGmixer3); - operations.add(presRedValveLT); - operations.add(mpseparator); - operations.add(coldGasFromSep); - operations.add(heatedGasFromLPSep); - operations.add(richMEGstream); - operations.add(richMEGstreamHeater); - operations.add(richMEGstreamHeater2); - operations.add(presRedValve3); - operations.add(flashDrumSep); - operations.add(flashGasStream); - operations.add(flashLiquidStream); - operations.add(columnPreHeater); - operations.add(presRedValve4); - operations.add(column); - operations.add(coolerRegenGas); - operations.add(sepregenGas); - operations.add(gasToFlare); - operations.add(waterToSea); - operations.add(bufferTank); - operations.add(hotLeanMEGPump); - operations.add(streamHotPump); - operations.add(columnPreHeater); - operations.add(coolerHotMEG2); - operations.add(leanMEGtoMixer); - operations.add(makeupCalculator); - operations.add(makeupMEG); - operations.add(makeupMixer); - operations.add(streamToResycle); - operations.add(resycleLeanMEG); - - // operations = ProcessSystem.open("c:/temp/onshoreMEGprocess.neqsim"); - operations.run(); - System.out.println("MEG flow rate " + resycleLeanMEG.getFluid().getFlowRate("kg/hr")); - - // presRedValve4.displayResult(); - // System.out.println( - // "temperature after cross cooler " +heatEx.getOutStream(0).getTemperature("C")); - - System.out.println("Heat ex 2 duty " + richMEGstreamHeater2.getDuty() / 1.0e3 + " kW"); - System.out.println("Heat ex 2 duty2 " + richMEGstreamHeater2.getDuty() / 1.0e3 + " kW"); - - System.out.println("MEG flow rate " + richMEGstream.getFluid().getFlowRate("kg/hr")); - System.out.println("MEG feed to column rate " - + presRedValve4.getOutletStream().getFluid().getFlowRate("kg/hr")); - - System.out.println("MEG flow rate " + resycleLeanMEG.getFluid().getFlowRate("kg/hr")); - System.out.println( - "Reboiler duty [kW] " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); - System.out.println( - "Condenser duty [kW] " + ((Condenser) column.getCondenser()).getDuty() / 1.0e3); - System.out.println( - "wt% lean MEG " + MEGFeed.getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); - // System.out.println("heat ex out temperature " + - // heatEx.getOutStream(0).getTemperature("C")); - System.out.println("cold gas temperature " + coldGasFromSep.getTemperature("C")); - System.out.println("column glycol pre heater temperature " - + columnPreHeater.getOutStream(0).getTemperature("C")); - System.out.println("column glycol pre heater temperature " - + columnPreHeater.getOutStream(1).getTemperature("C")); - - // presRedValve4.getOutStream().displayResult(); - gasToFlare.displayResult(); - waterToSea.displayResult(); - System.out.println("lean MEG wt% " - + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("MEG") - * 100.0); - System.out.println("hydrate temperature 1 " - + (inletGasCooler.getOutletStream().getHydrateEquilibriumTemperature() - 273.15) - + " wt% MEG " - + inletGasCooler.getOutletStream().getFluid().getPhase("aqueous").getWtFrac("MEG") - * 100.0); - - operations.save("c:/temp/MEGdehydrationProcess.neqsim"); - } + Stream MEGFeed = new Stream("lean MEG to header", feedMEG); + MEGFeed.setFlowRate(1000.0, "kg/hr"); + MEGFeed.setTemperature(20.0, "C"); + MEGFeed.setPressure(105.0, "bara"); + + Splitter MEGsplitter1 = new Splitter("lean MEG header", MEGFeed); + MEGsplitter1.setSplitFactors(new double[] {0.01, 0.94, 0.05}); + + StaticMixer MEGmixer1 = new StaticMixer("MEG mixer 1"); + MEGmixer1.addStream(inletCompressor2ndstage.getOutletStream()); + MEGmixer1.addStream(MEGsplitter1.getSplitStream(0)); + + Cooler inletGasCooler = new Cooler("dehydration cooler", MEGmixer1.getOutletStream()); + inletGasCooler.setOutTemperature(10.0, "C"); + + StaticMixer MEGmixer2 = new StaticMixer("MEG mixer 2"); + MEGmixer2.addStream(inletGasCooler.getOutletStream()); + MEGmixer2.addStream(MEGsplitter1.getSplitStream(1)); + + HeatExchanger heatEx = new HeatExchanger("gas-gas heat exchanger", MEGmixer2.getOutletStream()); + heatEx.setGuessOutTemperature(273.15 - 10.0); + heatEx.setUAvalue(30000.0); + + StaticMixer MEGmixer3 = new StaticMixer("MEG mixer 3"); + MEGmixer3.addStream(heatEx.getOutStream(0)); + MEGmixer3.addStream(MEGsplitter1.getSplitStream(2)); + + ThrottlingValve presRedValveLT = new ThrottlingValve("JT valve", MEGmixer3.getOutletStream()); + presRedValveLT.setOutletPressure(92.0); + + ThreePhaseSeparator mpseparator = + new ThreePhaseSeparator("low temperature scrubber", presRedValveLT.getOutletStream()); + + Stream coldGasFromSep = new Stream("gas from cold scrubber", mpseparator.getGasOutStream()); + + heatEx.setFeedStream(1, coldGasFromSep); + + Stream heatedGasFromLPSep = new Stream("heated gas from cold scrubber", heatEx.getOutStream(1)); + + Stream richMEGstream = new Stream("rich cold MEG stream", mpseparator.getWaterOutStream()); + + Heater richMEGstreamHeater = new Heater("rich MEG pre-heater", richMEGstream); + richMEGstreamHeater.setOutTemperature(15.0, "C"); + + Heater richMEGstreamHeater2 = + new Heater("column condenser HX", richMEGstreamHeater.getOutletStream()); + // richMEGstreamHeater2.setOutTemperature(22.0, "C"); + + ThrottlingValve presRedValve3 = + new ThrottlingValve("valve to flash drum", richMEGstreamHeater2.getOutletStream()); + presRedValve3.setOutletPressure(3.9); + + Separator flashDrumSep = new Separator("rich MEG flash drum", presRedValve3.getOutletStream()); + + Stream flashGasStream = new Stream("gas from flash drum", flashDrumSep.getGasOutStream()); + + Stream flashLiquidStream = + new Stream("rich TEG from flash drum", flashDrumSep.getLiquidOutStream()); + + HeatExchanger columnPreHeater = new HeatExchanger("MEG/MEG heat exchanger", flashLiquidStream); + columnPreHeater.setGuessOutTemperature(273.15 + 120.0); + columnPreHeater.setUAvalue(500.0); + + ThrottlingValve presRedValve4 = + new ThrottlingValve("valve to regenerator", columnPreHeater.getOutStream(0)); + presRedValve4.setOutletPressure(1.23); + + DistillationColumn column = new DistillationColumn("MEG regeneration column", 2, true, true); + column.addFeedStream(presRedValve4.getOutletStream(), 0); + column.getReboiler().setOutTemperature(273.15 + 135.0); + column.getCondenser().setOutTemperature(273.15 + 105.0); + column.setTopPressure(1.0); + column.setBottomPressure(1.23); + + Cooler coolerRegenGas = + new Cooler("regeneration overhead gas cooler", column.getGasOutStream()); + coolerRegenGas.setOutTemperature(273.15 + 20.0); + + Separator sepregenGas = + new Separator("overhead condenser scrubber", coolerRegenGas.getOutletStream()); + + Stream gasToFlare = new Stream("gas to flare from regenerator", sepregenGas.getGasOutStream()); + + Stream waterToSea = + new Stream("condensed water from regenerator", sepregenGas.getLiquidOutStream()); + + Cooler bufferTank = new Cooler("MEG buffer tank", column.getLiquidOutStream()); + bufferTank.setOutTemperature(273.15 + 130.0); + + Pump hotLeanMEGPump = new Pump("hot lean MEG pump", bufferTank.getOutletStream()); + hotLeanMEGPump.setOutletPressure(105.0); + hotLeanMEGPump.setIsentropicEfficiency(0.75); + + Stream streamHotPump = + new Stream("stream from hot lean MEG pump", hotLeanMEGPump.getOutletStream()); + + columnPreHeater.setFeedStream(1, streamHotPump); + + Cooler coolerHotMEG2 = new Cooler("lean MEG cooler", columnPreHeater.getOutStream(1)); + coolerHotMEG2.setOutTemperature(273.15 + 20.0); + + Stream leanMEGtoMixer = new Stream("lean MEG to makeup mixer", coolerHotMEG2.getOutletStream()); + + neqsim.thermo.system.SystemInterface pureMEG = feedGas.clone(); + pureMEG.setMolarComposition(new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}); + + Stream makeupMEG = new Stream("makeup MEG", pureMEG); + makeupMEG.setFlowRate(1e-6, "kg/hr"); + makeupMEG.setTemperature(20.0, "C"); + makeupMEG.setPressure(105.0, "bara"); + + Calculator makeupCalculator = new Calculator("MEG makeup calculator"); + makeupCalculator.addInputVariable(coldGasFromSep); + makeupCalculator.addInputVariable(waterToSea); + makeupCalculator.addInputVariable(gasToFlare); + makeupCalculator.addInputVariable(flashGasStream); + makeupCalculator.setOutputVariable(makeupMEG); + + StaticMixer makeupMixer = new StaticMixer("MEG makeup mixer"); + makeupMixer.addStream(leanMEGtoMixer); + makeupMixer.addStream(makeupMEG); + + Stream streamToRecycle = new Stream("streamToRecycle", makeupMixer.getOutletStream()); + + Recycle recycleLeanMEG = new Recycle("lean MEG recycle"); + recycleLeanMEG.addStream(streamToRecycle); + recycleLeanMEG.setOutletStream(MEGFeed); + // recycleLeanMEG.setPriority(200); + recycleLeanMEG.setDownstreamProperty("flow rate"); + + richMEGstreamHeater2.setEnergyStream(column.getCondenser().getEnergyStream()); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(dryFeedGas); + operations.add(saturatedFeedGas); + operations.add(waterSaturatedFeedGas); + operations.add(inletCompressor); + operations.add(interstageGasCooler); + operations.add(inletCompressor2ndstage); + operations.add(MEGFeed); + operations.add(MEGsplitter1); + operations.add(MEGmixer1); + operations.add(inletGasCooler); + operations.add(MEGmixer2); + operations.add(heatEx); + operations.add(MEGmixer3); + operations.add(presRedValveLT); + operations.add(mpseparator); + operations.add(coldGasFromSep); + operations.add(heatedGasFromLPSep); + operations.add(richMEGstream); + operations.add(richMEGstreamHeater); + operations.add(richMEGstreamHeater2); + operations.add(presRedValve3); + operations.add(flashDrumSep); + operations.add(flashGasStream); + operations.add(flashLiquidStream); + operations.add(columnPreHeater); + operations.add(presRedValve4); + operations.add(column); + operations.add(coolerRegenGas); + operations.add(sepregenGas); + operations.add(gasToFlare); + operations.add(waterToSea); + operations.add(bufferTank); + operations.add(hotLeanMEGPump); + operations.add(streamHotPump); + operations.add(columnPreHeater); + operations.add(coolerHotMEG2); + operations.add(leanMEGtoMixer); + operations.add(makeupCalculator); + operations.add(makeupMEG); + operations.add(makeupMixer); + operations.add(streamToRecycle); + operations.add(recycleLeanMEG); + + // operations = ProcessSystem.open("c:/temp/onshoreMEGprocess.neqsim"); + operations.run(); + System.out.println("MEG flow rate " + recycleLeanMEG.getFluid().getFlowRate("kg/hr")); + + // presRedValve4.displayResult(); + // System.out.println( + // "temperature after cross cooler " +heatEx.getOutStream(0).getTemperature("C")); + + System.out.println("Heat ex 2 duty " + richMEGstreamHeater2.getDuty() / 1.0e3 + " kW"); + System.out.println("Heat ex 2 duty2 " + richMEGstreamHeater2.getDuty() / 1.0e3 + " kW"); + + System.out.println("MEG flow rate " + richMEGstream.getFluid().getFlowRate("kg/hr")); + System.out.println("MEG feed to column rate " + + presRedValve4.getOutletStream().getFluid().getFlowRate("kg/hr")); + + System.out.println("MEG flow rate " + recycleLeanMEG.getFluid().getFlowRate("kg/hr")); + System.out.println("Reboiler duty [kW] " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); + System.out + .println("Condenser duty [kW] " + ((Condenser) column.getCondenser()).getDuty() / 1.0e3); + System.out.println( + "wt% lean MEG " + MEGFeed.getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); + // System.out.println("heat ex out temperature " + + // heatEx.getOutStream(0).getTemperature("C")); + System.out.println("cold gas temperature " + coldGasFromSep.getTemperature("C")); + System.out.println("column glycol pre heater temperature " + + columnPreHeater.getOutStream(0).getTemperature("C")); + System.out.println("column glycol pre heater temperature " + + columnPreHeater.getOutStream(1).getTemperature("C")); + + // presRedValve4.getOutStream().displayResult(); + gasToFlare.displayResult(); + waterToSea.displayResult(); + System.out.println("lean MEG wt% " + + column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); + System.out.println("hydrate temperature 1 " + + (inletGasCooler.getOutletStream().getHydrateEquilibriumTemperature() - 273.15) + + " wt% MEG " + + inletGasCooler.getOutletStream().getFluid().getPhase("aqueous").getWtFrac("MEG") * 100.0); + + operations.save("c:/temp/MEGdehydrationProcess.neqsim"); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java index 08af4bb433..d3a50ceee8 100644 --- a/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java +++ b/src/test/java/neqsim/processSimulation/util/example/OnshoreProcess1.java @@ -300,10 +300,10 @@ public static void main(String[] args) { MeasurementDeviceInterface reservoirTemperaturTransmitter = new TemperatureTransmitter(stream_1); MeasurementDeviceInterface reservoirPressureTransmitter = new PressureTransmitter(stream_1); - WaterContentAnalyser waterAnalyser = new WaterContentAnalyser(separator.getGasOutStream()); - waterAnalyser.setName("Snohvit Total Water Analyser"); - MolarMassAnalyser molarMassAnalyser = new MolarMassAnalyser(separator.getGasOutStream()); - molarMassAnalyser.setName("Snohvit molar mass analyser"); + WaterContentAnalyser waterAnalyser = + new WaterContentAnalyser("Snohvit Total Water Analyser", separator.getGasOutStream()); + MolarMassAnalyser molarMassAnalyser = + new MolarMassAnalyser("Snohvit molar mass analyser", separator.getGasOutStream()); StreamInterface stream_2 = separator.getGasOutStream(); stream_2.setName("Gas From Snohvit Reservoir"); @@ -322,10 +322,10 @@ public static void main(String[] args) { // Albatross reservoir stream Stream stream_3 = new Stream("Stream2", testSystem2); Separator separator2 = new Separator("Separator 2", stream_3); - WaterContentAnalyser waterAnalyser2 = new WaterContentAnalyser(separator2.getGasOutStream()); - waterAnalyser2.setName("Albatross Total Water Analyser"); - MolarMassAnalyser molarMassAnalyser2 = new MolarMassAnalyser(separator2.getGasOutStream()); - molarMassAnalyser2.setName("Albatross molar mass analyser"); + WaterContentAnalyser waterAnalyser2 = + new WaterContentAnalyser("Albatross Total Water Analyser", separator2.getGasOutStream()); + MolarMassAnalyser molarMassAnalyser2 = + new MolarMassAnalyser("Albatross molar mass analyser", separator2.getGasOutStream()); StreamInterface stream_4 = separator2.getGasOutStream(); stream_4.setName("Gas From Albatross Reservoir"); @@ -338,8 +338,8 @@ public static void main(String[] args) { mixer1.addStream(valve1.getOutletStream()); mixer1.addStream(valve2.getOutletStream()); - WaterContentAnalyser waterAnalyser3 = new WaterContentAnalyser(mixer1.getOutletStream()); - waterAnalyser3.setName("Total Water Analyser"); + WaterContentAnalyser waterAnalyser3 = + new WaterContentAnalyser("Total Water Analyser", mixer1.getOutletStream()); // Pipeline SimpleTPoutPipeline pipeLine1 = @@ -358,43 +358,38 @@ public static void main(String[] args) { ThreePhaseSeparator slugCatcher = new ThreePhaseSeparator("slugCatcher", pipeLine1.getOutletStream()); - VolumeFlowTransmitter volumeTransmitter2 = - new VolumeFlowTransmitter(slugCatcher.getOilOutStream()); + VolumeFlowTransmitter volumeTransmitter2 = new VolumeFlowTransmitter( + "Condensate Volume Flow From Slug Catcher", slugCatcher.getOilOutStream()); volumeTransmitter2.setMeasuredPhaseNumber(0); - volumeTransmitter2.setName("Condensate Volume Flow From Slug Catcher"); - VolumeFlowTransmitter volumeTransmitter1 = - new VolumeFlowTransmitter(slugCatcher.getWaterOutStream()); + VolumeFlowTransmitter volumeTransmitter1 = new VolumeFlowTransmitter( + "MEG Volume FLow From Slug Catcher", slugCatcher.getWaterOutStream()); volumeTransmitter1.setMeasuredPhaseNumber(0); - volumeTransmitter1.setName("MEG Volume FLow From Slug Catcher"); - VolumeFlowTransmitter volumeTransmitter3 = - new VolumeFlowTransmitter(slugCatcher.getGasOutStream()); + VolumeFlowTransmitter volumeTransmitter3 = new VolumeFlowTransmitter( + "Gas Volume FLow From Slug Catcher", slugCatcher.getGasOutStream()); volumeTransmitter3.setMeasuredPhaseNumber(0); - volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); - // Stream stream_5 = new Stream(slugCatcher.getWaterOutStream()); - // stream_5.setName("MEG stream from slugcatcher"); + // Stream stream_5 = new Stream("MEG stream from + // slugcatcher",slugCatcher.getWaterOutStream()); Heater condensateheater1 = new Heater("Condensate heater1", slugCatcher.getOilOutStream()); condensateheater1.setdT(23.4); - // Heater gasHeater = new Heater(slugCatcher.getGasOutStream()); - // gasHeater.setName("Gas heater after slugcatcher"); + // Heater gasHeater = new Heater("Gas heater after slugcatcher", + // slugCatcher.getGasOutStream()); // gasHeater.setdT(30.0); ThreePhaseSeparator condensateSeparator = new ThreePhaseSeparator("condensateSeparator", condensateheater1.getOutletStream()); - // Heater MEGheater1 = new Heater(stream_5); - // MEGheater1.setName("MEG heater1"); + // Heater MEGheater1 = new Heater("MEG heater1",stream_5); // MEGheater1.setdT(23.4); // SnohvitCO2RemovalModule co2Module = new SnohvitCO2RemovalModule(); // co2Module.addInputStream("streamToAbsorber", gasHeater.getOutStream()); - // Heater MEGheater2 = new Heater(MEGheater1.getOutStream()); - // MEGheater2.setName("MEG heater2"); + // Heater MEGheater2 = new Heater("MEG heater2", MEGheater1.getOutStream()); // MEGheater2.setdT(20.0); // ThrottlingValve valve3 = new ThrottlingValve("MEG flash valve 1", @@ -405,11 +400,9 @@ public static void main(String[] args) { // separator", valve3.getOutStream()); // VolumeFlowTransmitter volumeTransmitter5= new - // VolumeFlowTransmitter(separator3.getGasOutStream()); - // volumeTransmitter5.setName("MEG Valve 1 Gas Volume FLow"); + // VolumeFlowTransmitter("MEG Valve 1 Gas Volume FLow",separator3.getGasOutStream()); - // Heater MEGheater3 = new Heater(separator3.getWaterOutStream()); - // MEGheater3.setName("MEG heater3"); + // Heater MEGheater3 = new Heater("MEG heater3", separator3.getWaterOutStream()); // MEGheater3.setdT(-35.0); // ThrottlingValve valve4 = new ThrottlingValve("MEG flash valve 2", @@ -431,13 +424,10 @@ public static void main(String[] args) { // GasHeater.setdT(-35.0); // CO2-removal - // Stream streamToCO2removal = new Stream(slugCatcher.getGasOutStream()); - // streamToCO2removal.setName("Gas to CO2 removal"); + // Stream streamToCO2removal = new Stream("Gas to CO2 removal",slugCatcher.getGasOutStream()); // VolumeFlowTransmitter volumeTransmitter_StreamToCO2removal = new - // VolumeFlowTransmitter(streamToCO2removal); + // VolumeFlowTransmitter("Stream to CO2 removal Volume FLow",streamToCO2removal); // volumeTransmitter_StreamToCO2removal.setUnit("Nm^3/day"); - // volumeTransmitter_StreamToCO2removal.setName("Stream to CO2 removal - // Volume FLow"); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java index 9e4ec16f5a..d997624a82 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcess2.java @@ -115,8 +115,8 @@ public static void main(String[] args) { Stream liquidRegenReflux = new Stream("liquidRegenReflux", sepRegen.getLiquidOutStream()); - Recycle resycle2 = new Recycle("reflux resycle"); - resycle2.addStream(liquidRegenReflux); + Recycle recycle2 = new Recycle("reflux recycle"); + recycle2.addStream(liquidRegenReflux); Heater coolerRegenGas = new Heater("coolerRegenGas", sepRegen.getGasOutStream()); coolerRegenGas.setOutTemperature(273.15 + 35.5); @@ -144,8 +144,8 @@ public static void main(String[] args) { stripper.setNumberOfStages(10); stripper.setStageEfficiency(0.5); - Recycle resycle3 = new Recycle("gas stripper resycle"); - resycle3.addStream(stripper.getGasOutStream()); + Recycle recycle3 = new Recycle("gas stripper recycle"); + recycle3.addStream(stripper.getGasOutStream()); Pump hotLeanTEGPump = new Pump("hot lean TEG pump", stripper.getSolventOutStream()); hotLeanTEGPump.setOutletPressure(20.0); @@ -184,8 +184,8 @@ public static void main(String[] args) { makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); @@ -210,7 +210,7 @@ public static void main(String[] args) { operations.add(sepregenGasCooler); operations.add(sepRegen); operations.add(liquidRegenReflux); - operations.add(resycle2); + operations.add(recycle2); operations.add(coolerRegenGas); operations.add(sepregenGas); @@ -220,7 +220,7 @@ public static void main(String[] args) { operations.add(strippingGas); operations.add(stripper); - operations.add(resycle3); + operations.add(recycle3); operations.add(hotLeanTEGPump); operations.add(coolerhOTteg); operations.add(coolerhOTteg2); @@ -230,16 +230,16 @@ public static void main(String[] args) { operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); operations.run(); richGLycolHeater2.getOutletStream().getFluid().display(); System.out.println("Energy reboiler " + heaterToReboiler.getDuty()); mixerTOreboiler.addStream(liquidRegenReflux); - mixerTOreboiler.addStream(resycle3.getOutletStream()); + mixerTOreboiler.addStream(recycle3.getOutletStream()); operations.run(); - absorber.replaceSolventInStream(resycleLeanTEG.getOutletStream()); + absorber.replaceSolventInStream(recycleLeanTEG.getOutletStream()); operations.run(); // richGLycolHeater2.getOutStream().getFluid().display(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java index 956aa73bfc..53526e0d5b 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation.java @@ -15,6 +15,7 @@ import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *@@ -106,8 +107,7 @@ public static void main(String[] args) { heatEx.setUAvalue(600.0); ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(1.23); neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); @@ -119,11 +119,9 @@ public static void main(String[] args) { strippingGas.setTemperature(80.0, "C"); strippingGas.setPressure(1.23, "bara"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 206.6); column.getCondenser().setOutTemperature(273.15 + 100.0); @@ -190,11 +188,11 @@ public static void main(String[] args) { makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); // richGLycolHeater.isSetEnergyStream(); @@ -233,7 +231,7 @@ public static void main(String[] args) { operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); operations.run(); // operations.run(); @@ -245,9 +243,10 @@ public static void main(String[] args) { // operations.run(); // ((DistillationColumn)operations.getUnit("TEG regeneration // column")).setNumberOfTrays(2); - System.out.println("water in wet gas " - + ((Stream) operations.getUnit("water saturated feed gas")).getFluid().getPhase(0) - .getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + System.out + .println("water in wet gas " + ((Stream) operations.getUnit("water saturated feed gas")) + .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 + * ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15)); System.out.println("water in dry gas " + ((Stream) operations.getUnit("dry gas from absorber")) .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " @@ -258,12 +257,14 @@ public static void main(String[] args) { double waterInWetGasppm = waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * ThermodynamicConstantsInterface.atm + / (ThermodynamicConstantsInterface.R * 288.15); double TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 + * ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15); double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); System.out.println("flow rate from reboiler " diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java index c3e354b64f..4b6d2e72cd 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillation3.java @@ -15,6 +15,7 @@ import neqsim.processSimulation.processEquipment.util.Recycle; import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *
@@ -113,11 +114,9 @@ public static void main(String[] args) { strippingGas.setTemperature(80.0, "C"); strippingGas.setPressure(1.23, "bara"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(richGLycolHeater2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 206.6); column.getCondenser().setOutTemperature(273.15 + 101.0); @@ -186,11 +185,11 @@ public static void main(String[] args) { makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); richGLycolHeater.isSetEnergyStream(); @@ -230,7 +229,7 @@ public static void main(String[] args) { operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); operations.run(); // operations.run(); @@ -242,9 +241,10 @@ public static void main(String[] args) { // operations.run(); // ((DistillationColumn)operations.getUnit("TEG regeneration // column")).setNumberOfTrays(2); - System.out.println("water in wet gas " - + ((Stream) operations.getUnit("water saturated feed gas")).getFluid().getPhase(0) - .getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + System.out + .println("water in wet gas " + ((Stream) operations.getUnit("water saturated feed gas")) + .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 + * ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15)); System.out.println("water in dry gas " + ((Stream) operations.getUnit("dry gas from absorber")) .getFluid().getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " @@ -255,12 +255,14 @@ public static void main(String[] args) { double waterInWetGasppm = waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * ThermodynamicConstantsInterface.atm + / (ThermodynamicConstantsInterface.R * 288.15); double TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; - double waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); + double waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 + * ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15); double richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / 1.0e3); System.out.println("flow rate from reboiler " diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java index f784ccf383..848f9f978f 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationAaHa.java @@ -17,6 +17,7 @@ import neqsim.processSimulation.processEquipment.util.SetPoint; import neqsim.processSimulation.processEquipment.util.StreamSaturatorUtil; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *
@@ -67,8 +68,8 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser", + waterSaturatedFeedGas); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( @@ -96,13 +97,12 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); /* - * WaterDewPointAnalyser waterDewPointAnalyser = new WaterDewPointAnalyser(dehydratedGas); - * waterDewPointAnalyser.setName("water dew point analyser"); + * WaterDewPointAnalyser waterDewPointAnalyser = new + * WaterDewPointAnalyser("water dew point analyser", dehydratedGas); */ HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); + new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas); waterDewPointAnalyser.setReferencePressure(70.0); - waterDewPointAnalyser.setName("water dew point analyser"); ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); glycol_flash_valve.setOutletPressure(5.5); @@ -134,8 +134,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() heatEx.setUAvalue(390.0); ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(1.23); neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); @@ -147,16 +146,14 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() strippingGas.setTemperature(80.0, "C"); strippingGas.setPressure(1.02, "bara"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + 201.0); column.getCondenser().setOutTemperature(273.15 + 92.0); column.getReboiler().addStream(gasToReboiler); - column.setTopPressure(1.01325); + column.setTopPressure(ThermodynamicConstantsInterface.referencePressure); column.setBottomPressure(1.02); Heater coolerRegenGas = new Heater("regen gas cooler", column.getGasOutStream()); @@ -174,8 +171,8 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() stripper.setNumberOfStages(4); stripper.setStageEfficiency(0.5); /* - * DistillationColumn stripper = new DistillationColumn(3, false, false); - * stripper.setName("TEG stripper"); stripper.addFeedStream(column.getLiquidOutStream(), 2); + * DistillationColumn stripper = new DistillationColumn("TEG stripper",3, false, false); + * stripper.addFeedStream(column.getLiquidOutStream(), 2); * stripper.getTray(0).addStream(strippingGas); */ Recycle recycleGasFromStripper = new Recycle("stripping gas recirc"); @@ -225,11 +222,11 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); // richGLycolHeater.isSetEnergyStream(); @@ -276,7 +273,7 @@ public static neqsim.processSimulation.processSystem.ProcessSystem getProcess() operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); return operations; } @@ -305,7 +302,8 @@ public static void main(String[] args) { /* * System.out.println("water in wet gas " + ((Stream) * operations.getUnit("water saturated feed gas")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 + * *ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15)); * System.out.println("water in dry gas " + ((Stream) * operations.getUnit("dry gas from absorber")).getFluid() * .getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " @@ -314,18 +312,20 @@ public static void main(String[] args) { * System.out.println("wt lean TEG " + ((WaterStripperColumn) * operations.getUnit("TEG stripper")) * .getSolventOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG") * 100.0); - * + * * double waterInWetGasppm = * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = + * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 *ThermodynamicConstantsInterface.atm / + * (ThermodynamicConstantsInterface.R * 288.15); double TEGfeedwt = + * TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = + * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 *ThermodynamicConstantsInterface.atm + * / (ThermodynamicConstantsInterface.R * 288.15); double richTEG2 = + * richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0). - * getComponent("water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); - * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / + * getComponent("water").getz()*1.0e6*0.01802*101325.0/(ThermodynamicConstantsInterface.R*288.15 + * ); System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); * System.out.println("flow rate from stripping column " + @@ -333,22 +333,22 @@ public static void main(String[] args) { * System.out.println("flow rate from pump2 " + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); - * + * * TEGFeed.getFluid().display(); absorber.run(); - * + * * System.out.println("pump power " + hotLeanTEGPump.getDuty()); * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); * System.out.println("wt lean TEG after reboiler " + * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); * System.out.println("temperature from pump " + * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); - * + * * System.out.println("flow rate from reboiler " + ((Reboiler) * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); * System.out.println("flow rate from pump2 " + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); - * + * * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); * System.out.println( "richGLycolHeaterCondenser duty " + @@ -356,17 +356,16 @@ public static void main(String[] args) { * System.out.println("richGLycolHeaterCondenser temperature out " + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); * richGLycolHeaterCondenser.run(); - * + * * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); - * + * * System.out.println("Temperature rich TEG out of reflux condenser " + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); * System.out.println("glycol out temperature " + * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(0).getTemperature("C")); * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(1).getTemperature("C")); - * - * + * * System.out.println("out water rate LP valve" + * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent( * "water").getNumberOfmoles()); System.out.println("glycol out water rate reboil " + @@ -376,29 +375,26 @@ public static void main(String[] args) { * getNumberOfmoles()); System.out.println("recycle out water rate " * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). * getNumberOfmoles()); - * + * * System.out.println("water dew point of dry gas " + * waterDewPointAnalyser.getMeasuredValue("C")); - * - * + * * System.out.println("hydrocarbons in lean TEG " + (1.0- * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("TEG")- * stripper.getLiquidOutStream().getFluid().getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); * System.out.println("hydrocarbons in rich TEG " + (1.0- * flashLiquid.getFluid().getPhase(0).getWtFrac("TEG")-flashLiquid.getFluid(). * getPhase(0).getWtFrac("water"))*1e6 + " mg/kg"); - * + * * //double dewT = ((WaterDewPointAnalyser)operations. * getMeasurementDevice("water dew point analyser")).getMeasuredValue("C"); * //waterDewPointAnalyser.setOnlineValue(measured, unit) * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); - * - * - * + * * //Heat echanger test - * + * * //Sabe and Open copy of model - * + * * ProcessSystem locoperations = operations.copy(); * //((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). * getInStream(0).setTemperature(298.15, "C"); @@ -413,8 +409,7 @@ public static void main(String[] args) { * eff = ((HeatExchanger)locoperations.getUnit("rich TEG heat exchanger 2")). * getThermalEffectiveness(); System.out.println("eff " + eff); //store fouling factor in * dataframe - * - * + * * dehydratedGas.getFluid().display(); */ diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java index 03d9f8b788..c3e76e4fbf 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationGFA.java @@ -195,8 +195,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser", + waterSaturatedFeedGas); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( @@ -224,15 +224,13 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); - WaterDewPointAnalyser waterDewPointAnalyser2 = new WaterDewPointAnalyser(dehydratedGas); - waterDewPointAnalyser2.setName("water dew point analyser2"); + WaterDewPointAnalyser waterDewPointAnalyser2 = + new WaterDewPointAnalyser("water dew point analyser2", dehydratedGas); HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); - waterDewPointAnalyser.setName("water dew point analyser"); + new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas); - ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG); - glycol_flash_valve.setName("Rich TEG HP flash valve"); + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); glycol_flash_valve.setOutletPressure(flashDrumPressure); Heater richGLycolHeaterCondenser = @@ -257,8 +255,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(reboilerPressure); neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); @@ -268,11 +265,9 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { strippingGas.setTemperature(strippingGasFeedTemperature, "C"); strippingGas.setPressure(reboilerPressure, "bara"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(3, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 3, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 1); column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); column.getCondenser().setOutTemperature(273.15 + condenserTemperature); @@ -287,7 +282,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Stream gasToFlare = new Stream("gas to flare", sepregenGas.getGasOutStream()); - Stream liquidToTrreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); + Stream liquidToTreatment = new Stream("water to treatment", sepregenGas.getLiquidOutStream()); WaterStripperColumn stripper = new WaterStripperColumn("TEG stripper"); stripper.addSolventInStream(column.getLiquidOutStream()); @@ -335,18 +330,18 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { makeupCalculator.addInputVariable(dehydratedGas); makeupCalculator.addInputVariable(flashGas); makeupCalculator.addInputVariable(gasToFlare); - makeupCalculator.addInputVariable(liquidToTrreatment); + makeupCalculator.addInputVariable(liquidToTreatment); makeupCalculator.setOutputVariable(makeupTEG); StaticMixer makeupMixer = new StaticMixer("makeup mixer"); makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); // richGLycolHeater.isSetEnergyStream(); @@ -379,7 +374,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { operations.add(coolerRegenGas); operations.add(sepregenGas); operations.add(gasToFlare); - operations.add(liquidToTrreatment); + operations.add(liquidToTreatment); operations.add(strippingGas); operations.add(stripper); operations.add(recycleGasFromStripper); @@ -392,7 +387,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); return operations; } @@ -453,7 +448,8 @@ public static void main(String[] args) { /* * System.out.println("water in wet gas " + ((Stream) * operations.getUnit("water saturated feed gas")).getFluid() - * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 * 101325.0 / (8.314 * 288.15)); + * .getPhase(0).getComponent("water").getz() * 1.0e6 * 0.01802 + * *ThermodynamicConstantsInterface.atm / (ThermodynamicConstantsInterface.R * 288.15)); * System.out.println("water in dry gas " + ((Stream) * operations.getUnit("dry gas from absorber")).getFluid() * .getPhase(0).getComponent("water").getz() * 1.0e6); System.out.println("reboiler duty (KW) " @@ -480,14 +476,16 @@ public static void main(String[] args) { /* * double waterInWetGasppm = * waterSaturatedFeedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * TEGfeedwt = TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = + * waterInWetGaskgMSm3 = waterInWetGasppm * 0.01802 *ThermodynamicConstantsInterface.atm / + * (ThermodynamicConstantsInterface.R * 288.15); double TEGfeedwt = + * TEGFeed.getFluid().getPhase("aqueous").getWtFrac("TEG"); double TEGfeedflw = * TEGFeed.getFlowRate("kg/hr"); double waterInDehydratedGasppm = * dehydratedGas.getFluid().getPhase(0).getComponent("water").getz() * 1.0e6; double - * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 * 101325.0 / (8.314 * 288.15); double - * richTEG2 = richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = + * waterInDryGaskgMSm3 = waterInDehydratedGasppm * 0.01802 *ThermodynamicConstantsInterface.atm + * / (ThermodynamicConstantsInterface.R * 288.15); double richTEG2 = + * richTEG.getFluid().getPhase("aqueous").getWtFrac("TEG"); double temp = * ((Stream)operations.getUnit("feed to TEG absorber")).getFluid().getPhase(0).getComponent( - * "water").getz()*1.0e6*0.01802*101325.0/(8.314*288.15); + * "water").getz()*1.0e6*0.01802*101325.0/(ThermodynamicConstantsInterface.R*288.15); * System.out.println("reboiler duty (KW) " + ((Reboiler) column.getReboiler()).getDuty() / * 1.0e3); System.out.println("flow rate from reboiler " + ((Reboiler) * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); @@ -496,22 +494,22 @@ public static void main(String[] args) { * System.out.println("flow rate from pump2 " + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); * System.out.println("makeup TEG " + makeupTEG.getFluid().getFlowRate("kg/hr")); - * + * * TEGFeed.getFluid().display(); absorber.run(); - * + * * System.out.println("pump power " + hotLeanTEGPump.getDuty()); * System.out.println("pump2 power " + hotLeanTEGPump2.getDuty()); * System.out.println("wt lean TEG after reboiler " + * column.getLiquidOutStream().getFluid().getPhase("aqueous").getWtFrac("TEG")); * System.out.println("temperature from pump " + * (hotLeanTEGPump2.getOutStream().getTemperature() - 273.15)); - * + * * System.out.println("flow rate from reboiler " + ((Reboiler) * column.getReboiler()).getLiquidOutStream().getFlowRate("kg/hr")); * System.out.println("flow rate from pump2 " + * hotLeanTEGPump2.getOutStream().getFluid().getFlowRate("kg/hr")); * System.out.println("flow rate to flare " + gasToFlare.getFluid().getFlowRate("kg/hr")); - * + * * System.out.println("condenser duty " + ((Condenser) ((DistillationColumn) * operations.getUnit("TEG regeneration column")).getCondenser()) .getDuty() / 1.0e3); * System.out.println( "richGLycolHeaterCondenser duty " + @@ -519,17 +517,16 @@ public static void main(String[] args) { * System.out.println("richGLycolHeaterCondenser temperature out " + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); * richGLycolHeaterCondenser.run(); - * + * * hotLeanTEGPump.getOutStream().displayResult(); flashLiquid.displayResult(); - * + * * System.out.println("Temperature rich TEG out of reflux condenser " + * richGLycolHeaterCondenser.getOutStream().getTemperature("C")); heatEx.displayResult(); * System.out.println("glycol out temperature " + * glycol_flash_valve2.getOutStream().getFluid().getTemperature("C")); * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(0).getTemperature("C")); * System.out.println("glycol out temperature2 " +heatEx2.getOutStream(1).getTemperature("C")); - * - * + * * System.out.println("out water rate LP valve" + * glycol_flash_valve2.getOutStream().getFluid().getPhase(0).getComponent("water"). * getNumberOfmoles()); System.out.println("glycol out water rate reboil " + ((Reboiler) @@ -539,19 +536,17 @@ public static void main(String[] args) { * getNumberOfmoles()); System.out.println("recycle out water rate " * +recycleGasFromStripper.getOutletStream().getFluid().getComponent("water"). * getNumberOfmoles()); - * + * * System.out.println("water dew point of dry gas " + * waterDewPointAnalyser.getMeasuredValue("C")); - * + * * //double dewT = * ((WaterDewPointAnalyser)operations.getMeasurementDevice("water dew point analyser")). * getMeasuredValue("C"); //waterDewPointAnalyser.setOnlineValue(measured, unit) * //waterDewPointAnalyser.setOnlineSignal(isOnlineSignal, plantName, transmitterame); - * - * - * + * * //Heat exchanger test - * + * * //Sabe and Open copy of model */ // ProcessSystem locoperations = operations.copy(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java index a65e432416..fff5b760cf 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java +++ b/src/test/java/neqsim/processSimulation/util/example/TEGdehydrationProcessDistillationJS.java @@ -200,8 +200,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { new Stream("water saturated feed gas", saturatedFeedGas.getOutletStream()); HydrateEquilibriumTemperatureAnalyser hydrateTAnalyser = - new HydrateEquilibriumTemperatureAnalyser(waterSaturatedFeedGas); - hydrateTAnalyser.setName("hydrate temperature analyser"); + new HydrateEquilibriumTemperatureAnalyser("hydrate temperature analyser", + waterSaturatedFeedGas); neqsim.thermo.system.SystemInterface feedTEG = feedGas.clone(); feedTEG.setMolarComposition( @@ -230,10 +230,8 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { Stream richTEG = new Stream("rich TEG from absorber", absorber.getSolventOutStream()); HydrateEquilibriumTemperatureAnalyser waterDewPointAnalyser = - new HydrateEquilibriumTemperatureAnalyser(dehydratedGas); - waterDewPointAnalyser.setName("water dew point analyser"); - ThrottlingValve glycol_flash_valve = new ThrottlingValve("Flash valve", richTEG); - glycol_flash_valve.setName("Rich TEG HP flash valve"); + new HydrateEquilibriumTemperatureAnalyser("water dew point analyser", dehydratedGas); + ThrottlingValve glycol_flash_valve = new ThrottlingValve("Rich TEG HP flash valve", richTEG); glycol_flash_valve.setOutletPressure(flashDrumPressure); Heater richGLycolHeaterCondenser = @@ -263,8 +261,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { heatEx.setUAvalue(UAvalueRichTEGHeatExchanger_2); ThrottlingValve glycol_flash_valve2 = - new ThrottlingValve("LP flash valve", heatEx.getOutStream(0)); - glycol_flash_valve2.setName("Rich TEG LP flash valve"); + new ThrottlingValve("Rich TEG LP flash valve", heatEx.getOutStream(0)); glycol_flash_valve2.setOutletPressure(reboilerPressure); neqsim.thermo.system.SystemInterface stripGas = feedGas.clone(); @@ -274,11 +271,9 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { strippingGas.setTemperature(strippingGasFeedTemperature, "C"); strippingGas.setPressure(reboilerPressure, "bara"); - Stream gasToReboiler = strippingGas.clone(); - gasToReboiler.setName("gas to reboiler"); + Stream gasToReboiler = strippingGas.clone("gas to reboiler"); - DistillationColumn column = new DistillationColumn(1, true, true); - column.setName("TEG regeneration column"); + DistillationColumn column = new DistillationColumn("TEG regeneration column", 1, true, true); column.addFeedStream(glycol_flash_valve2.getOutletStream(), 0); column.getReboiler().setOutTemperature(273.15 + reboilerTemperature); column.getCondenser().setOutTemperature(273.15 + condenserTemperature); @@ -348,11 +343,11 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { makeupMixer.addStream(leanTEGtoabs); makeupMixer.addStream(makeupTEG); - Recycle resycleLeanTEG = new Recycle("lean TEG resycle"); - resycleLeanTEG.addStream(makeupMixer.getOutletStream()); - resycleLeanTEG.setOutletStream(TEGFeed); - resycleLeanTEG.setPriority(200); - resycleLeanTEG.setDownstreamProperty("flow rate"); + Recycle recycleLeanTEG = new Recycle("lean TEG recycle"); + recycleLeanTEG.addStream(makeupMixer.getOutletStream()); + recycleLeanTEG.setOutletStream(TEGFeed); + recycleLeanTEG.setPriority(200); + recycleLeanTEG.setDownstreamProperty("flow rate"); richGLycolHeaterCondenser.setEnergyStream(column.getCondenser().getEnergyStream()); // richGLycolHeater.isSetEnergyStream(); @@ -399,7 +394,7 @@ public neqsim.processSimulation.processSystem.ProcessSystem getProcess() { operations.add(makeupCalculator); operations.add(makeupTEG); operations.add(makeupMixer); - operations.add(resycleLeanTEG); + operations.add(recycleLeanTEG); return operations; } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java index 689464d53c..03c70288b3 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestNeqsim.java @@ -89,14 +89,14 @@ public static void main(String[] args) { + stream1.getThermoSystem().getWtFraction(1) * DensityOil + stream1.getThermoSystem().getWtFraction(2) * Densityliquid; // operations.run(); - System.out.println("work " + compressor1.getTotalWork() + " density " + Density1 + " Cp " - + Cpone + " SPEED OF SOUND " + stream1.getThermoSystem().getPhase(0).getSoundSpeed()); + // System.out.println("work " + compressor1.getTotalWork() + " density " + Density1 + " Cp " + // + Cpone + " SPEED OF SOUND " + stream1.getThermoSystem().getPhase(0).getSoundSpeed()); compressor1.solveEfficiency(390.15); compressor1.getOutletStream().displayResult(); - System.out.println("Hvap " + stream1.getThermoSystem().getHeatOfVaporization() + " POLI " - + compressor1.getPolytropicEfficiency() + " dentity " - + stream1.getThermoSystem().getDensity() + " cp " + stream1.getThermoSystem().getCp()); + // System.out.println("Hvap " + stream1.getThermoSystem().getHeatOfVaporization() + " POLI " + // + compressor1.getPolytropicEfficiency() + " dentity " + // + stream1.getThermoSystem().getDensity() + " cp " + stream1.getThermoSystem().getCp()); stream1.getThermoSystem().display(); double massFlowGas = stream1.getThermoSystem().getPhase(0).getBeta() @@ -118,12 +118,12 @@ public static void main(String[] args) { /* * temperature[i] = compressor1.getOutStream().getTemperature(); work [i] = * compressor1.getTotalWork(); - * + * * Cp_Vapour [i] = compressor1.getOutStream().getThermoSystem().getPhase(0).getCp(); Cp_liquid * [i] = compressor1.getOutStream().getThermoSystem().getPhase(1).getCp(); Cp [i] = * compressor1.getOutStream().getThermoSystem().getPhase(0).getBeta() * Cp_Vapour [i] + * compressor1.getOutStream().getThermoSystem().getPhase(1).getBeta()* Cp_liquid [i]; - * + * * Density_Vapour [i] = compressor1.getOutStream().getThermoSystem().getPhase(0).getDensity(); * Density_liquid [i] = compressor1.getOutStream().getThermoSystem().getPhase(1).getDensity(); * Density [i] = compressor1.getOutStream().getThermoSystem().getWtFraction(0) * Density_Vapour @@ -140,21 +140,14 @@ public static void main(String[] args) { } // catch(Exception ex){ /* - * System.out.println( "P_out" ); for (int i=0;i<10;i++ ) { System.out.println(20 + 5*i); - * - * } - * + * System.out.println( "P_out" ); for (int i=0;i<10;i++ ) { System.out.println(20 + 5*i); } + * * System.out.println( "Temperature" ); for (int i=0;i<10;i++ ) { System.out.println( - * temperature[i] ); - * - * } - * - * System.out.println( "Work" ); for (int i=0;i<10;i++ ) { System.out.println( work [i] ); - * - * } System.out.println( "Cp" ); for (int i=0;i<10;i++ ) { System.out.println( Cp [i] ); - * - * } - * + * temperature[i] ); } + * + * System.out.println( "Work" ); for (int i=0;i<10;i++ ) { System.out.println( work [i] ); } + * System.out.println( "Cp" ); for (int i=0;i<10;i++ ) { System.out.println( Cp [i] ); } + * * System.out.println( "Density" ); for (int i=0;i<10;i++ ) { System.out.println( Density [i] ); */ } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestProcess4.java b/src/test/java/neqsim/processSimulation/util/example/TestProcess4.java index 3e5cd35b15..12a572ff97 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestProcess4.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestProcess4.java @@ -37,7 +37,7 @@ public static void main(String args[]) { Separator separator = new Separator("Separator 1", stream_1); // ThrottlingValve valve_1 = new ThrottlingValve(separator.getGasOutStream()); - // valve_1.setOutletPressure(75.0 + 1.01325); + // valve_1.setOutletPressure(75.0 + ThermodynamicConstantsInterface.referencePressure); // valve_1.setIsoThermal(true); // Heater heater = new Heater(valve_1.getOutStream()); diff --git a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java index da9fc4eddc..b714133beb 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestSlugcatcher.java @@ -54,15 +54,13 @@ public static void main(String args[]) { new ThreePhaseSeparator("Separator 1", valve1.getOutletStream()); Stream stream_2 = new Stream("stream_2", separator2.getGasOutStream()); - VolumeFlowTransmitter volumeTransmitter3 = - new VolumeFlowTransmitter(separator2.getGasOutStream()); + VolumeFlowTransmitter volumeTransmitter3 = new VolumeFlowTransmitter( + "Gas Volume FLow From Slug Catcher", separator2.getGasOutStream()); volumeTransmitter3.setMeasuredPhaseNumber(0); - volumeTransmitter3.setName("Gas Volume FLow From Slug Catcher"); - VolumeFlowTransmitter volumeTransmitter4 = - new VolumeFlowTransmitter(separator2.getWaterOutStream()); + VolumeFlowTransmitter volumeTransmitter4 = new VolumeFlowTransmitter( + "Water Volume FLow From Slug Catcher", separator2.getWaterOutStream()); volumeTransmitter4.setMeasuredPhaseNumber(0); - volumeTransmitter4.setName("Water Volume FLow From Slug Catcher"); neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); diff --git a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java index d6ef3fd9e7..c047e2ec8d 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow.java @@ -122,11 +122,11 @@ public static void main(String args[]) { * // transient behaviour operations.setTimeStep(1.1); for(int i=0;i<50;i++){ * operations.runTransient(); System.out.println("liquid level " + separator_1.getLiquidLevel()+ * " PRESSURE " + separator_1.getGasOutStream().getPressure()); } - * + * * operations.setTimeStep(30.0); for(int i=0;i<2000;i++){ operations.runTransient(); * System.out.println("liquid level " + separator_1.getLiquidLevel()+ " PRESSURE " + * separator_1.getGasOutStream().getPressure()); } operations.displayResult(); - * + * * operations.displayResult(); */ } diff --git a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java index 2e00c72ce3..cda2238d57 100644 --- a/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java +++ b/src/test/java/neqsim/processSimulation/util/example/TestTransientFlow2.java @@ -8,83 +8,87 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; /** - *
TestTransientFlow2 class.
+ *+ * TestTransientFlow2 class. + *
* * @author ESOL * @version $Id: $Id * @since 2.2.3 */ public class TestTransientFlow2 { - /** - *main.
- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); - testSystem.addComponent("methane", 0.900); - testSystem.addComponent("ethane", 0.100); - testSystem.addComponent("n-heptane", 1.00); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); + /** + *+ * main. + *
+ * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00); + testSystem.addComponent("methane", 0.900); + testSystem.addComponent("ethane", 0.100); + testSystem.addComponent("n-heptane", 1.00); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); - Stream stream_1 = new Stream("Stream1", testSystem); - ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); - valve_1.setOutletPressure(5.0); - valve_1.setPercentValveOpening(50); + Stream stream_1 = new Stream("Stream1", testSystem); + ThrottlingValve valve_1 = new ThrottlingValve("valve_1", stream_1); + valve_1.setOutletPressure(5.0); + valve_1.setPercentValveOpening(50); - Separator separator_1 = new Separator("separator_1"); - separator_1.addStream(valve_1.getOutletStream()); + Separator separator_1 = new Separator("separator_1"); + separator_1.addStream(valve_1.getOutletStream()); - ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); - valve_2.setOutletPressure(1.0); - valve_2.setPercentValveOpening(50); - // valve_2.setCv(10.0); + ThrottlingValve valve_2 = new ThrottlingValve("valve_2", separator_1.getLiquidOutStream()); + valve_2.setOutletPressure(1.0); + valve_2.setPercentValveOpening(50); + // valve_2.setCv(10.0); - ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); - valve_3.setOutletPressure(1.0); - valve_3.setPercentValveOpening(50); + ThrottlingValve valve_3 = new ThrottlingValve("valve_3", separator_1.getGasOutStream()); + valve_3.setOutletPressure(1.0); + valve_3.setPercentValveOpening(50); - VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream_1); - flowTransmitter.setUnit("m^3/hr"); - flowTransmitter.setMaximumValue(10.0); - flowTransmitter.setMinimumValue(1.0); + VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(stream_1); + flowTransmitter.setUnit("m^3/hr"); + flowTransmitter.setMaximumValue(10.0); + flowTransmitter.setMinimumValue(1.0); - ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); - flowController.setTransmitter(flowTransmitter); - flowController.setReverseActing(true); - flowController.setControllerSetPoint(1.0); - flowController.setControllerParameters(0.7, 300.0, 0.0); + ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); + flowController.setTransmitter(flowTransmitter); + flowController.setReverseActing(true); + flowController.setControllerSetPoint(1.0); + flowController.setControllerParameters(0.7, 300.0, 0.0); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(valve_1); - operations.add(separator_1); - operations.add(valve_2); - operations.add(valve_3); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(valve_1); + operations.add(separator_1); + operations.add(valve_2); + operations.add(valve_3); - operations.add(flowTransmitter); - valve_1.setController(flowController); + operations.add(flowTransmitter); + valve_1.setController(flowController); - operations.run(); - operations.displayResult(); - valve_2.setPercentValveOpening(0.1); - valve_3.setPercentValveOpening(0.1); - // transient behaviour - operations.setTimeStep(5.0); - for (int i = 0; i < 460; i++) { - System.out.println("volume flow " + flowTransmitter.getMeasuredValue() - + " valve opening " + valve_1.getPercentValveOpening() + " pressure " - + separator_1.getGasOutStream().getPressure()); - operations.runTransient(); - } + operations.run(); + operations.displayResult(); + valve_2.setPercentValveOpening(0.1); + valve_3.setPercentValveOpening(0.1); + // transient behaviour + operations.setTimeStep(5.0); + for (int i = 0; i < 460; i++) { + // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + // + " valve opening " + valve_1.getPercentValveOpening() + " pressure " + // + separator_1.getGasOutStream().getPressure()); + operations.runTransient(); + } - operations.displayResult(); - System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + " valve opening " - + valve_1.getPercentValveOpening()); + operations.displayResult(); + // System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + " valve opening " + // + valve_1.getPercentValveOpening()); - // operations.displayResult(); - } + // operations.displayResult(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/destillation1.java b/src/test/java/neqsim/processSimulation/util/example/destillation1.java index ae1770fa08..43a7080f71 100644 --- a/src/test/java/neqsim/processSimulation/util/example/destillation1.java +++ b/src/test/java/neqsim/processSimulation/util/example/destillation1.java @@ -7,64 +7,66 @@ import neqsim.thermodynamicOperations.ThermodynamicOperations; /** - *destillation1 class.
+ *+ * destillation1 class. + *
* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class destillation1 { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 63.0), 16.00); - // testSystem.addComponent("methane", 1.00); - testSystem.addComponent("ethane", 0.002); - // testSystem.addComponent("CO2", 10.00); - testSystem.addComponent("propane", 0.605900); - testSystem.addComponent("i-butane", 0.1473); - testSystem.addComponent("n-butane", 0.2414); - testSystem.addComponent("i-pentane", 0.00322); - testSystem.addComponent("n-pentane", 0.0002); - testSystem.addComponent("methanol", 0.00005); - // testSystem.addComponent("n-heptane", 100.0); - testSystem.createDatabase(true); - testSystem.setMixingRule(2); - ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - testOps.TPflash(); - testSystem.display(); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkEos((273.15 + 63.0), 16.00); + // testSystem.addComponent("methane", 1.00); + testSystem.addComponent("ethane", 0.002); + // testSystem.addComponent("CO2", 10.00); + testSystem.addComponent("propane", 0.605900); + testSystem.addComponent("i-butane", 0.1473); + testSystem.addComponent("n-butane", 0.2414); + testSystem.addComponent("i-pentane", 0.00322); + testSystem.addComponent("n-pentane", 0.0002); + testSystem.addComponent("methanol", 0.00005); + // testSystem.addComponent("n-heptane", 100.0); + testSystem.createDatabase(true); + testSystem.setMixingRule(2); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.display(); - Stream stream_1 = new Stream("Stream1", testSystem); + Stream stream_1 = new Stream("Stream1", testSystem); - DistillationColumn column = new DistillationColumn(9, true, true); - column.addFeedStream(stream_1, 4); - ((Reboiler) column.getReboiler()).setRefluxRatio(3.7); - ((Condenser) column.getCondenser()).setRefluxRatio(10.7); - // column.setReboilerTemperature(360); - // column.setReboilerTemperature(300); - /* - * Heater heater = new Heater((Stream) column.getGasOutStream()); heater.setdT(-15.0); - * - * DistillationColumn column2 = new DistillationColumn(4, true, true); - * column2.addFeedStream(heater.getOutStream(), 2); ((Reboiler) - * column2.getReboiler()).setRefluxRatio(0.01); ((Condenser) - * column2.getCondenser()).setRefluxRatio(0.01); - */ + DistillationColumn column = new DistillationColumn("distColumn", 9, true, true); + column.addFeedStream(stream_1, 4); + ((Reboiler) column.getReboiler()).setRefluxRatio(3.7); + ((Condenser) column.getCondenser()).setRefluxRatio(10.7); + // column.setReboilerTemperature(360); + // column.setReboilerTemperature(300); + /* + * Heater heater = new Heater((Stream) column.getGasOutStream()); heater.setdT(-15.0); + * + * DistillationColumn column2 = new DistillationColumn(4, true, true); + * column2.addFeedStream(heater.getOutStream(), 2); ((Reboiler) + * column2.getReboiler()).setRefluxRatio(0.01); ((Condenser) + * column2.getCondenser()).setRefluxRatio(0.01); + */ - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(column); - // operations.add(heater); - // operations.add(column2); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(column); + // operations.add(heater); + // operations.add(column2); - operations.run(); - // column.getReboiler().displayResult(); - // column.getCondenser().displayResult(); - // operations.displayResult(); - } + operations.run(); + // column.getReboiler().displayResult(); + // column.getCondenser().displayResult(); + // operations.displayResult(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/destillation2.java b/src/test/java/neqsim/processSimulation/util/example/destillation2.java index e388b5029b..f07879acf3 100644 --- a/src/test/java/neqsim/processSimulation/util/example/destillation2.java +++ b/src/test/java/neqsim/processSimulation/util/example/destillation2.java @@ -13,47 +13,47 @@ * @since 2.2.3 */ public class destillation2 { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 30.0), 50.00); - testSystem.addComponent("methane", 1.00); - testSystem.addComponent("water", 100e-6); - testSystem.addComponent("TEG", 0.0); - - testSystem.setMixingRule(10); - testSystem.setMultiPhaseCheck(true); - testSystem.init(0); - - Stream feedGas = new Stream("feedGas", testSystem); - feedGas.setFlowRate(5.0, "MSm3/day"); - feedGas.setTemperature(30.0, "C"); - feedGas.setPressure(50.0, "bara"); - - neqsim.thermo.system.SystemInterface TEGliq2 = testSystem.clone(); - TEGliq2.setMolarComposition(new double[] {0.0, 0.001, 1.0}); - - Stream TEGliq = new Stream("TEG liq", TEGliq2); - TEGliq.setFlowRate(5000.0, "kg/hr"); - TEGliq.setTemperature(30.0, "C"); - TEGliq.setPressure(50.0, "bara"); - - DistillationColumn column = new DistillationColumn(3, false, false); - column.addFeedStream(feedGas, 0); - column.getTray(2).addStream(TEGliq); - - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(feedGas); - operations.add(TEGliq); - operations.add(column); - operations.run(); - - column.getGasOutStream().displayResult(); - column.getLiquidOutStream().displayResult(); - } + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemSrkCPAstatoil((273.15 + 30.0), 50.00); + testSystem.addComponent("methane", 1.00); + testSystem.addComponent("water", 100e-6); + testSystem.addComponent("TEG", 0.0); + + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + testSystem.init(0); + + Stream feedGas = new Stream("feedGas", testSystem); + feedGas.setFlowRate(5.0, "MSm3/day"); + feedGas.setTemperature(30.0, "C"); + feedGas.setPressure(50.0, "bara"); + + neqsim.thermo.system.SystemInterface TEGliq2 = testSystem.clone(); + TEGliq2.setMolarComposition(new double[] {0.0, 0.001, 1.0}); + + Stream TEGliq = new Stream("TEG liq", TEGliq2); + TEGliq.setFlowRate(5000.0, "kg/hr"); + TEGliq.setTemperature(30.0, "C"); + TEGliq.setPressure(50.0, "bara"); + + DistillationColumn column = new DistillationColumn("distColumn", 3, false, false); + column.addFeedStream(feedGas, 0); + column.getTray(2).addStream(TEGliq); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(feedGas); + operations.add(TEGliq); + operations.add(column); + operations.run(); + + column.getGasOutStream().displayResult(); + column.getLiquidOutStream().displayResult(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java b/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java index 9dd350c644..ae1d10817f 100644 --- a/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java +++ b/src/test/java/neqsim/processSimulation/util/example/oxygenRemovalWater.java @@ -5,6 +5,7 @@ import neqsim.processSimulation.processEquipment.separator.Separator; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *oxygenRemovalWater class.
@@ -25,10 +26,10 @@ public static void main(String[] args) { neqsim.thermo.system.SystemInterface fluid1 = fluidCreator.create("air").autoSelectModel(); fluid1.setMultiPhaseCheck(true); neqsim.thermo.system.SystemInterface fluid2 = fluidCreator.create("water"); - fluid1.setPressure(1.01325); + fluid1.setPressure(ThermodynamicConstantsInterface.referencePressure); fluid1.setTemperature(273.15 + 10); fluid1.setTotalFlowRate(1.0, "kg/hr"); - fluid2.setPressure(1.01325); + fluid2.setPressure(ThermodynamicConstantsInterface.referencePressure); fluid2.setTemperature(273.15 + 10); fluid2.setTotalFlowRate(3500.0, "kg/hr"); diff --git a/src/test/java/neqsim/processSimulation/util/example/shtokman.java b/src/test/java/neqsim/processSimulation/util/example/shtokman.java index 746751e2d9..4a6e1e0ad1 100644 --- a/src/test/java/neqsim/processSimulation/util/example/shtokman.java +++ b/src/test/java/neqsim/processSimulation/util/example/shtokman.java @@ -63,7 +63,7 @@ public static void main(String args[]) { // ThermodynamicOperations ops = new ThermodynamicOperations(stream_2.getThermoSystem()); /* * try { // ops.TPflash(); - * + * * ops.waterPrecipitationTemperature(); stream_2.getThermoSystem().display(); * stream_2.getThermoSystem().init(0); ops.hydrateFormationTemperature(2); * stream_2.getThermoSystem().display(); // stream_2.getThermoSystem().display(); // @@ -73,7 +73,7 @@ public static void main(String args[]) { * getThermoSystem().getPhase(1).getComponent("MEG").getMolarMass(); double wtwater = * stream_2.getThermoSystem().getPhase(1).getComponent("water").getx()*stream_2. * getThermoSystem().getPhase(1).getComponent("water").getMolarMass(); - * + * * System.out.println("wt% MEG " + wtMEG/(wtMEG+wtwater)*100); // operations.displayResult(); */ } diff --git a/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java b/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java index b17acb4281..426e1d77db 100644 --- a/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java +++ b/src/test/java/neqsim/processSimulation/util/example/threePhaseSeparation.java @@ -6,98 +6,98 @@ import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; /** - *threePhaseSeparation class.
+ *+ * threePhaseSeparation class. + *
* * @author asmund * @version $Id: $Id * @since 2.2.3 */ public class threePhaseSeparation { - /** - * This method is just meant to test the thermo package. - * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - neqsim.thermo.system.SystemInterface system1 = - new neqsim.thermo.system.SystemSrkCPAs((273.15 + 15.0), 80.00); - system1.addComponent("CO2", 0.309); - system1.addComponent("nitrogen", 1.854); - system1.addComponent("methane", 94.90446); - system1.addComponent("ethane", 1.623); - system1.addComponent("propane", 0.535); - system1.addComponent("i-butane", 0.111293); - system1.addComponent("n-butane", 0.1547122); - system1.addComponent("iC5", 0.05894036); - system1.addComponent("n-pentane", 0.04441738); - system1.addComponent("benzene", 0.001207753); - system1.addComponent("toluene", 0.002350627); - system1.addComponent("m-Xylene", 0.00359331); - system1.addTBPfraction("C6", 0.04242109, 85.11 / 1000.0, 0.724); - system1.addTBPfraction("C7", 0.05719361, 98.4 / 1000.0, 0.751); - system1.addTBPfraction("C8", 0.03807916, 111.74 / 1000.0, 0.779); - system1.addTBPfraction("C9", 0.0203721, 125.19 / 1000.0, 0.793); - system1.addTBPfraction("C10", 0.01497714, 137.83 / 1000.0, 0.798); - system1.addTBPfraction("C11", 0.00929271, 149.0 / 1000.0, 0.803); - system1.addTBPfraction("C12", 0.00619347, 163.0 / 1000.0, 0.809); - system1.addTBPfraction("C13", 0.004102369, 176.0 / 1000.0, 0.815); - system1.addTBPfraction("C14", 0.002625117, 191.0 / 1000.0, 0.824); - system1.addTBPfraction("C15", 0.00168187, 207.0 / 1000.0, 0.829); - system1.addTBPfraction("C16", 0.001092967, 221.0 / 1000.0, 0.843); - system1.addTBPfraction("C17", 0.0006937096, 237.0 / 1000.0, 0.848); - system1.addTBPfraction("C18", 0.0004341923, 249.0 / 1000.0, 0.852); - system1.addTBPfraction("C19", 0.000329387, 261.0 / 1000.0, 0.855); - system1.addTBPfraction("CN1", 0.0008534124, 304.7 / 1000.0, 0.865); - system1.addTBPfraction("CN2", 5.340066E-005, 432.55 / 1000.0, 0.88); - system1.addComponent("TEG", 1.0e-10); - system1.addComponent("MEG", .3); - system1.addComponent("water", 1.0); + /** + * This method is just meant to test the thermo package. + * + * @param args an array of {@link java.lang.String} objects + */ + public static void main(String args[]) { + neqsim.thermo.system.SystemInterface system1 = + new neqsim.thermo.system.SystemSrkCPAs((273.15 + 15.0), 80.00); + system1.addComponent("CO2", 0.309); + system1.addComponent("nitrogen", 1.854); + system1.addComponent("methane", 94.90446); + system1.addComponent("ethane", 1.623); + system1.addComponent("propane", 0.535); + system1.addComponent("i-butane", 0.111293); + system1.addComponent("n-butane", 0.1547122); + system1.addComponent("iC5", 0.05894036); + system1.addComponent("n-pentane", 0.04441738); + system1.addComponent("benzene", 0.001207753); + system1.addComponent("toluene", 0.002350627); + system1.addComponent("m-Xylene", 0.00359331); + system1.addTBPfraction("C6", 0.04242109, 85.11 / 1000.0, 0.724); + system1.addTBPfraction("C7", 0.05719361, 98.4 / 1000.0, 0.751); + system1.addTBPfraction("C8", 0.03807916, 111.74 / 1000.0, 0.779); + system1.addTBPfraction("C9", 0.0203721, 125.19 / 1000.0, 0.793); + system1.addTBPfraction("C10", 0.01497714, 137.83 / 1000.0, 0.798); + system1.addTBPfraction("C11", 0.00929271, 149.0 / 1000.0, 0.803); + system1.addTBPfraction("C12", 0.00619347, 163.0 / 1000.0, 0.809); + system1.addTBPfraction("C13", 0.004102369, 176.0 / 1000.0, 0.815); + system1.addTBPfraction("C14", 0.002625117, 191.0 / 1000.0, 0.824); + system1.addTBPfraction("C15", 0.00168187, 207.0 / 1000.0, 0.829); + system1.addTBPfraction("C16", 0.001092967, 221.0 / 1000.0, 0.843); + system1.addTBPfraction("C17", 0.0006937096, 237.0 / 1000.0, 0.848); + system1.addTBPfraction("C18", 0.0004341923, 249.0 / 1000.0, 0.852); + system1.addTBPfraction("C19", 0.000329387, 261.0 / 1000.0, 0.855); + system1.addTBPfraction("CN1", 0.0008534124, 304.7 / 1000.0, 0.865); + system1.addTBPfraction("CN2", 5.340066E-005, 432.55 / 1000.0, 0.88); + system1.addComponent("TEG", 1.0e-10); + system1.addComponent("MEG", .3); + system1.addComponent("water", 1.0); - system1.createDatabase(true); - system1.setMixingRule(9); - system1.setMultiPhaseCheck(true); - Stream stream_1 = new Stream("Stream1", system1); + system1.createDatabase(true); + system1.setMixingRule(9); + system1.setMultiPhaseCheck(true); + Stream stream_1 = new Stream("Stream1", system1); - ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator", stream_1); + ThreePhaseSeparator separator = new ThreePhaseSeparator("Separator", stream_1); - Stream stream_2 = new Stream("gas from scrubber", separator.getGasOutStream()); - // Stream stream_3 = new Stream(separator.getOilOutStream()); - // stream_3.setName("oil from scrubber"); - // Stream stream_4 = new Stream(separator.getWaterOutStream()); - // stream_4.setName("water from scrubber"); + Stream stream_2 = new Stream("gas from scrubber", separator.getGasOutStream()); + // Stream stream_3 = new Stream("oil from scrubber", separator.getOilOutStream()); + // Stream stream_4 = new Stream("water from scrubber", separator.getWaterOutStream()); - MoleFractionControllerUtil waterRemoval = new MoleFractionControllerUtil(stream_2); - // waterRemoval.setMoleFraction("water", 15.0e-6); - waterRemoval.setComponentRate("TEG", 55.0, "litre/MSm^3"); - // werRemoval.setRelativeMoleFractionReduction("water", -0.99); - // waterRemoval.getOutStream(); + MoleFractionControllerUtil waterRemoval = new MoleFractionControllerUtil(stream_2); + // waterRemoval.setMoleFraction("water", 15.0e-6); + waterRemoval.setComponentRate("TEG", 55.0, "litre/MSm^3"); + // werRemoval.setRelativeMoleFractionReduction("water", -0.99); + // waterRemoval.getOutStream(); - MoleFractionControllerUtil TEGsaturator = - new MoleFractionControllerUtil(waterRemoval.getOutletStream()); - TEGsaturator.setMoleFraction("water", 5.0e-6); - // TEGsaturator.getOutStream(); + MoleFractionControllerUtil TEGsaturator = + new MoleFractionControllerUtil(waterRemoval.getOutletStream()); + TEGsaturator.setMoleFraction("water", 5.0e-6); + // TEGsaturator.getOutStream(); - ThrottlingValve LP_valve = new ThrottlingValve("LPventil", TEGsaturator.getOutletStream()); - LP_valve.setOutletPressure(5.0); + ThrottlingValve LP_valve = new ThrottlingValve("LPventil", TEGsaturator.getOutletStream()); + LP_valve.setOutletPressure(5.0); - // ThreePhaseSeparator separator2 = new ThreePhaseSeparator("Separator LP", - // LP_valve.getOutStream()); + // ThreePhaseSeparator separator2 = new ThreePhaseSeparator("Separator LP", + // LP_valve.getOutStream()); - neqsim.processSimulation.processSystem.ProcessSystem operations = - new neqsim.processSimulation.processSystem.ProcessSystem(); - operations.add(stream_1); - operations.add(separator); - // operations.add(stream_2); - // operations.add(stream_3); - // operations.add(stream_4); - // operations.add(waterRemoval); - // operations.add(TEGsaturator); - // operations.add(LP_valve); - // operations.add(separator2); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(stream_1); + operations.add(separator); + // operations.add(stream_2); + // operations.add(stream_3); + // operations.add(stream_4); + // operations.add(waterRemoval); + // operations.add(TEGsaturator); + // operations.add(LP_valve); + // operations.add(separator2); - operations.run(); - operations.displayResult(); - // stream_1.displayResult(); - // waterRemoval.displayResult(); - } + operations.run(); + operations.displayResult(); + // stream_1.displayResult(); + // waterRemoval.displayResult(); + } } diff --git a/src/test/java/neqsim/processSimulation/util/monitor/SeparatorResponseTest.java b/src/test/java/neqsim/processSimulation/util/monitor/SeparatorResponseTest.java new file mode 100644 index 0000000000..c1d8c1c808 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/util/monitor/SeparatorResponseTest.java @@ -0,0 +1,63 @@ +package neqsim.processSimulation.util.monitor; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import neqsim.processSimulation.processEquipment.heatExchanger.HeatExchanger; +import neqsim.processSimulation.processEquipment.pump.Pump; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemSrkEos; + +public class SeparatorResponseTest { + @Test + void testWrite() { + SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("n-heptane", 100.0); + testSystem.addComponent("water", 100.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + + ProcessSystem processOps = new ProcessSystem(); + + Stream inletStream = new Stream("feed stream", testSystem); + inletStream.setPressure(10.0, "bara"); + inletStream.setTemperature(20.0, "C"); + inletStream.setFlowRate(290.0, "kg/hr"); + + Separator separator = new Separator("two phase separator", inletStream); + separator.setInternalDiameter(0.05); + + ThreePhaseSeparator separator3phase = + new ThreePhaseSeparator("three phase separator", inletStream); + separator3phase.setInternalDiameter(0.05); + + HeatExchanger hx1 = new HeatExchanger("E-100", separator3phase.getGasOutStream()); + hx1.setGuessOutTemperature(273.15 + 35.0); + hx1.setUAvalue(444000.2); + hx1.setFeedStream(1, separator3phase.getOilOutStream()); + + Pump pump1 = new Pump("pump", separator3phase.getOilOutStream()); + pump1.setOutletPressure(100.0); + + processOps.add(inletStream); + processOps.add(separator); + processOps.add(separator3phase); + // processOps.add(hx1); + processOps.add(pump1); + processOps.run(); + + String sepjson = separator.toJson(); + String sep3json = separator3phase.toJson(); + String hxjson = hx1.toJson(); + String pumpjson = pump1.toJson(); + JsonObject jsonObject = JsonParser.parseString(sep3json).getAsJsonObject(); + Double reldens = jsonObject.getAsJsonObject("feed").getAsJsonObject("properties") + .getAsJsonObject("oil").getAsJsonObject("relative density").get("value").getAsDouble(); + assertEquals(0.688292615281, reldens, 0.01); + } +} diff --git a/src/test/java/neqsim/processSimulation/util/report/FluidCompinentReportTest.java b/src/test/java/neqsim/processSimulation/util/report/FluidCompinentReportTest.java new file mode 100644 index 0000000000..6e62020a1d --- /dev/null +++ b/src/test/java/neqsim/processSimulation/util/report/FluidCompinentReportTest.java @@ -0,0 +1,21 @@ +package neqsim.processSimulation.util.report; + +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; + +public class FluidCompinentReportTest { + @Test + void testWrite() { + SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("n-heptane", 100.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + + String report = testSystem.toCompJson(); + // System.out.println(report); + neqsim.util.unit.Units.activateFieldUnits(); + report = testSystem.toCompJson(); + // System.out.println(report); + } +} diff --git a/src/test/java/neqsim/processSimulation/util/report/FluidReportTest.java b/src/test/java/neqsim/processSimulation/util/report/FluidReportTest.java new file mode 100644 index 0000000000..9e62b209aa --- /dev/null +++ b/src/test/java/neqsim/processSimulation/util/report/FluidReportTest.java @@ -0,0 +1,24 @@ +package neqsim.processSimulation.util.report; + +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class FluidReportTest { + @Test + void testWrite() { + SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("n-heptane", 100.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); + ops.TPflash(); + + String report = testSystem.toJson(); + // System.out.println(report); + neqsim.util.unit.Units.activateFieldUnits(); + report = testSystem.toJson(); + // System.out.println(report); + } +} diff --git a/src/test/java/neqsim/processSimulation/util/report/ReportTest.java b/src/test/java/neqsim/processSimulation/util/report/ReportTest.java new file mode 100644 index 0000000000..ce3ee81ea1 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/util/report/ReportTest.java @@ -0,0 +1,58 @@ +package neqsim.processSimulation.util.report; + +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.compressor.Compressor; +import neqsim.processSimulation.processEquipment.mixer.Mixer; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.processSimulation.processSystem.ProcessSystem; +import neqsim.thermo.system.SystemSrkEos; + +public class ReportTest { + @Test + void testWrite() { + SystemSrkEos testSystem = new SystemSrkEos(298.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("n-heptane", 100.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + + ProcessSystem processOps = new ProcessSystem(); + + Stream inletStream = new Stream("feed stream", testSystem); + inletStream.setPressure(10.0, "bara"); + inletStream.setTemperature(20.0, "C"); + inletStream.setFlowRate(100.0, "kg/hr"); + + Separator separator = new Separator("two phase separator", inletStream); + + Compressor compressor = new Compressor("gas compressor", separator.getGasOutStream()); + compressor.setOutletPressure(20.0, "bara"); + + ThrottlingValve valve = new ThrottlingValve("valve 1", separator.getLiquidOutStream()); + valve.setOutletPressure(1.0, "bara"); + + Mixer mixer1 = new Mixer("mixer 1"); + mixer1.addStream(valve.getOutletStream()); + + processOps.add(inletStream); + processOps.add(separator); + processOps.add(compressor); + processOps.add(valve); + processOps.add(mixer1); + processOps.run(); + + Report report = new Report(processOps); + String obj = report.generateJsonReport(); + neqsim.util.unit.Units.activateFieldUnits(); + String obj2 = report.generateJsonReport(); + // System.out.println(obj2); + neqsim.util.unit.Units.activateSIUnits(); + // reporting from process Object + String processreportasjson = processOps.getReport_json(); + // System.out.println(processreportasjson); + // report stream + String streamreportasjson = inletStream.getReport_json(); + } +} diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO15403Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO15403Test.java index 9de99813a8..900771490f 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO15403Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO15403Test.java @@ -2,13 +2,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; public class Standard_ISO15403Test { - private static SystemInterface testSystem = null; private static Standard_ISO15403 ISO15403 = null; @@ -55,4 +55,14 @@ void testGetValue() { void testIsOnSpec() { assertEquals(true, ISO15403.isOnSpec()); } + + @Test + @Disabled + void testDisplay() { + Standard_ISO15403 s = new Standard_ISO15403(null); + s.display("test"); + + s = new Standard_ISO15403(testSystem); + s.display("test"); + } } diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java index b0d1c82b10..3f8b77a9c2 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6578Test.java @@ -1,11 +1,28 @@ package neqsim.standards.gasQuality; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; public class Standard_ISO6578Test extends neqsim.NeqSimTest { + SystemInterface testSystem; + + @BeforeEach + void setUp() { + testSystem = new SystemSrkEos(273.15 - 160.0, 1.0); + testSystem.addComponent("nitrogen", 0.006538); + testSystem.addComponent("methane", 0.91863); + testSystem.addComponent("ethane", 0.058382); + testSystem.addComponent("propane", 0.011993); + // testSystem.addComponent("i-butane", 0.00); + testSystem.addComponent("n-butane", 0.003255); + testSystem.addComponent("i-pentane", 0.000657); + testSystem.addComponent("n-pentane", 0.000545); + } + @Test void testCalculate() { SystemInterface testSystem = new SystemSrkEos(273.15 - 160.0, 1.0); @@ -34,4 +51,14 @@ void testCalculate() { Assertions.assertEquals(0.30930700620842033, standard.getCorrFactor1()); // testSystem.display(); } + + @Test + @Disabled + void testDisplay() { + Standard_ISO6578 s = new Standard_ISO6578(null); + s.display("test"); + + s = new Standard_ISO6578(testSystem); + s.display("test"); + } } diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java index 645ce07b22..076cb9ae3a 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976Test.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -10,7 +11,6 @@ /** * @author ESOL - * */ class Standard_ISO6976Test extends neqsim.NeqSimTest { static SystemInterface testSystem = null; @@ -111,16 +111,13 @@ void testCalculate2() { * testSystem.addComponent("22-dim-C3", 0.001015); testSystem.addComponent("n-hexane", * 0.002865); testSystem.addComponent("nitrogen", 0.01023); testSystem.addComponent("CO2", * 0.015236); - * */ /* - * * testSystem.addComponent("methane", 0.9247); testSystem.addComponent("ethane", 0.035); * testSystem.addComponent("propane", 0.0098); testSystem.addComponent("n-butane", 0.0022); * testSystem.addComponent("i-butane", 0.0034); testSystem.addComponent("n-pentane", 0.0006); * testSystem.addComponent("nitrogen", 0.0175); testSystem.addComponent("CO2", 0.0068); - * */ // testSystem.addComponent("water", 0.016837); @@ -129,7 +126,7 @@ void testCalculate2() { * testSystem.addComponent("n-hexane", 0.0); testSystem.addComponent("n-heptane", 0.0); * testSystem.addComponent("n-octane", 0.0); testSystem.addComponent("n-nonane", 0.0); * testSystem.addComponent("nC10", 0.0); - * + * * testSystem.addComponent("CO2", 0.68); testSystem.addComponent("H2S", 0.0); * testSystem.addComponent("water", 0.0); testSystem.addComponent("oxygen", 0.0); * testSystem.addComponent("carbonmonoxide", 0.0); testSystem.addComponent("nitrogen", 1.75); @@ -160,10 +157,17 @@ void testCalculate2() { * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem); * standardUK.calculate(); logger.info("ICF " + * standardUK.getValue("IncompleteCombustionFactor", "")); - * + * * logger.info("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15 - 150.0)); * logger.info("Hres " + testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - * 150.0)); */ } + + @Test + @Disabled + void testDisplay() { + Standard_ISO6976 s = new Standard_ISO6976(testSystem); + s.display("test"); + } } diff --git a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976_2016_Test.java b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976_2016_Test.java index f59d84c730..645ff2638e 100644 --- a/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976_2016_Test.java +++ b/src/test/java/neqsim/standards/gasQuality/Standard_ISO6976_2016_Test.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -10,7 +11,6 @@ /** * @author ESOL - * */ class Standard_ISO6976_2016_Test extends neqsim.NeqSimTest { static SystemInterface testSystem = null; @@ -125,10 +125,17 @@ void testCalculate2() { * StandardInterface standardUK = new UKspecifications_ICF_SI(testSystem); * standardUK.calculate(); logger.info("ICF " + * standardUK.getValue("IncompleteCombustionFactor", "")); - * + * * logger.info("HID " + testSystem.getPhase(0).getComponent("methane").getHID(273.15 - 150.0)); * logger.info("Hres " + testSystem.getPhase(0).getComponent("methane").getHresTP(273.15 - * 150.0)); */ } + + @Test + @Disabled + void testDisplay() { + Standard_ISO6976_2016 s = new Standard_ISO6976_2016(testSystem); + s.display("test"); + } } diff --git a/src/test/java/neqsim/standards/oilQuality/Standard_ASTM_D6377Test.java b/src/test/java/neqsim/standards/oilQuality/Standard_ASTM_D6377Test.java new file mode 100644 index 0000000000..413c620b9b --- /dev/null +++ b/src/test/java/neqsim/standards/oilQuality/Standard_ASTM_D6377Test.java @@ -0,0 +1,52 @@ +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.06538); + testSystem.addComponent("n-pentane", 0.1545); + testSystem.addComponent("nC10", 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(1.10455465, standard.getValue("RVP", "bara"), 1e-3); + Assertions.assertEquals(1.666298367, standard.getValue("TVP", "bara"), 1e-3); + } + + @Test + void testCalculate2() { + SystemInterface testSystem = new SystemSrkEos(273.15 + 2.0, 1.0); + testSystem.addComponent("methane", 0.026538); + testSystem.addComponent("ethane", 0.16538); + testSystem.addComponent("propane", 0.26538); + testSystem.addComponent("n-pentane", 0.545); + testSystem.addComponent("nC10", 0.545); + testSystem.addTBPfraction("C11", 0.545, 145.0 / 1000.0, 0.82); + testSystem.setMixingRule(2); + testSystem.init(0); + testSystem.setPressure(100.0); + Standard_ASTM_D6377 standard = new Standard_ASTM_D6377(testSystem); + standard.setMethodRVP("VPCR4"); + standard.setReferenceTemperature(37.8, "C"); + standard.calculate(); + Assertions.assertEquals(3.6145219653041623, standard.getValue("RVP", "bara"), 1e-3); + Assertions.assertEquals(7.867696779327479, standard.getValue("TVP", "bara"), 1e-3); + + standard.setMethodRVP("RVP_ASTM_D6377"); + standard.setReferenceTemperature(37.8, "C"); + standard.calculate(); + Assertions.assertEquals(3.014511319063671, standard.getValue("RVP", "bara"), 1e-3); + Assertions.assertEquals(7.867696779327479 + , standard.getValue("TVP", "bara"), 1e-3); + } +} diff --git a/src/test/java/neqsim/standards/salesContract/BaseContractTest.java b/src/test/java/neqsim/standards/salesContract/BaseContractTest.java index fe21eca0e6..5b4cec7959 100644 --- a/src/test/java/neqsim/standards/salesContract/BaseContractTest.java +++ b/src/test/java/neqsim/standards/salesContract/BaseContractTest.java @@ -2,13 +2,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemGERGwaterEos; import neqsim.thermo.system.SystemInterface; /** * @author ESOL - * */ class BaseContractTest extends neqsim.NeqSimTest { static SystemInterface testSystem = null; @@ -50,4 +50,13 @@ void testUKGSMR19962() { assertEquals(2.18817727816606, Double.parseDouble(standard.getResultTable()[1][1]), 1e-6); // standard.prettyPrint(); } + + @Test + @Disabled + void testDisplay() { + standard.display(); + + BaseContract bc = new BaseContract(); + bc.display(); + } } diff --git a/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java b/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java new file mode 100644 index 0000000000..c8dcae9156 --- /dev/null +++ b/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java @@ -0,0 +1,20 @@ +package neqsim.statistics.dataanalysis.datasmoothing; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class DataSmootherTest { + @Test + void testgetSmoothedNumbers() { + double[] numbers = {10, 11, 12, 13, 14, 15, 15.5, 15, 19, 14, 14, 13, 12, 12, 11, 10, 9, 8}; + DataSmoother test = new DataSmoother(numbers, 3, 3, 0, 4); + Assertions.assertArrayEquals(numbers, test.getSmoothedNumbers()); + + double[] expected = {10.000000, 11.000000, 12.000000, 12.567099567099579, 13.567099567099582, + 14.556277056277072, 15.305194805194823, 15.389610389610409, 16.66233766233768, + 17.149350649350666, 13.350649350649375, 13.627705627705646, 12.432900432900452, + 11.89177489177491, 11.541125541125552, 10.000000, 9.000000, 8.000000}; + test.runSmoothing(); + Assertions.assertArrayEquals(expected, test.getSmoothedNumbers()); + } +} diff --git a/src/test/java/neqsim/thermo/atomElement/ElementTest.java b/src/test/java/neqsim/thermo/atomElement/ElementTest.java index 206fd1440d..6bc2782ea9 100644 --- a/src/test/java/neqsim/thermo/atomElement/ElementTest.java +++ b/src/test/java/neqsim/thermo/atomElement/ElementTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test; public class ElementTest { - @Test public void testExistingElement() { ArrayList+ * testMolarVolume. + *
+ */ + @Test + @DisplayName("test molarVolume calculation as well as unit conerters") + public void testMolarVolume() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemPrEos(298.0, 1.0); + testSystem.addComponent("nitrogen", 0.01); + testSystem.addComponent("CO2", 0.01); + testSystem.addComponent("methane", 0.68); + testSystem.addComponent("ethane", 0.1); + testSystem.setMixingRule("classic"); + testModel = new neqsim.thermo.ThermodynamicModelTest(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(testSystem.getMolarVolume("m3/mol"), + testSystem.getMolarMass("kg/mol") / testSystem.getDensity("kg/m3")); + } + /** ** testTPflash2. @@ -149,12 +172,16 @@ public void checkKappa() { testSystem.addComponent("methane", 0.68); testSystem.addComponent("ethane", 0.1); testSystem.setMixingRule("classic"); + testSystem.useVolumeCorrection(true); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testOps.TPflash(); testSystem.initProperties(); testSystem.getKappa(); testSystem.getPhase("gas").getKappa(); assertEquals(testSystem.getKappa(), testSystem.getPhase("gas").getKappa(), 1e-5); + assertEquals(0.817374332, testSystem.getZ(), 1e-6); + assertEquals(0.833031816, testSystem.getZvolcorr(), 1e-6); + assertEquals(0.833031816, testSystem.getPhase("gas").getZvolcorr(), 1e-6); } /** diff --git a/src/test/java/neqsim/thermo/system/SystemSrkSchwartzentruberEosTest.java b/src/test/java/neqsim/thermo/system/SystemSrkSchwartzentruberEosTest.java index 1b6fe239c8..2e943e39af 100644 --- a/src/test/java/neqsim/thermo/system/SystemSrkSchwartzentruberEosTest.java +++ b/src/test/java/neqsim/thermo/system/SystemSrkSchwartzentruberEosTest.java @@ -1,6 +1,7 @@ package neqsim.thermo.system; import org.junit.jupiter.api.BeforeAll; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *
@@ -19,7 +20,8 @@ public class SystemSrkSchwartzentruberEosTest extends ModelBaseTest { */ @BeforeAll public static void setUp() { - thermoSystem = new SystemSrkSchwartzentruberEos(298.15, 1.01325); + thermoSystem = new SystemSrkSchwartzentruberEos(298.15, + ThermodynamicConstantsInterface.referencePressure); thermoSystem.addComponent("methanol", 1.0); thermoSystem.addComponent("water", 1.0); thermoSystem.createDatabase(true); diff --git a/src/test/java/neqsim/thermo/system/SystemThermoTest.java b/src/test/java/neqsim/thermo/system/SystemThermoTest.java index d8dc0e93d4..2d6e940e35 100644 --- a/src/test/java/neqsim/thermo/system/SystemThermoTest.java +++ b/src/test/java/neqsim/thermo/system/SystemThermoTest.java @@ -2,8 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; class SystemThermoTest extends neqsim.NeqSimTest { @@ -26,6 +28,24 @@ public static void setUp() { testSystem.initProperties(); } + /** + *
+ * setUp. + *
+ */ + @Test + public void testCp() { + neqsim.thermo.system.SystemPrEos testSystem = + new neqsim.thermo.system.SystemPrEos(273.15 + 40.0, 1.0); + testSystem.addComponent("methane", 10.01); + testSystem.addTBPfraction("C20", 10.68, 0.3, 0.85); + testSystem.setMixingRule("classic"); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + assertEquals(2.00406932521, testSystem.getPhase(1).getCp("kJ/kgK"), 1e-6); + } + /** ** test setPressure @@ -85,9 +105,17 @@ public void testSetPressure() { fluid.addComponent("nitrogen", 1.0); fluid.setPressure(0.0, "barg"); - assertEquals(1.01325, fluid.getPressure("bara"), 1e-4); + assertEquals(ThermodynamicConstantsInterface.referencePressure, fluid.getPressure("bara"), + 1e-4); assertEquals(0.0, fluid.getPressure("barg"), 1e-4); + } + @Test + @Disabled + void testDisplay() { + testSystem.display(); + SystemEos s = new SystemPrEos(); + s.display(); } } diff --git a/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java index 87122f1eb6..14c83345c3 100644 --- a/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java +++ b/src/test/java/neqsim/thermo/system/SystemUMRCPAEoStest.java @@ -93,24 +93,24 @@ public void testCompressibility() { testOps.TPflash(); testSystem.init(3); testSystem.init(3); - System.out.println("molar volume gas+oil is " + testSystem.getMolarVolume()); - System.out.println("molar volume gas is " + testSystem.getPhase(0).getMolarVolume()); - System.out.println("fugacity of gas phase " + testSystem.getPhase(0).getFugacity(0)); - System.out.println("residual enthalpy of gas phase is " + testSystem.getPhase(0).getHresTP()); - System.out.println( - "isochoric heat capacity of gas phase is " + testSystem.getPhase(0).getCv("J/mol")); - System.out - .println("isobaric heat capacity of gas phase is " + testSystem.getPhase(0).getCp("J/mol")); - System.out - .println("internal energy of gas phase is " + testSystem.getPhase(0).getInternalEnergy()); - System.out.println("molar volume liquid is " + testSystem.getPhase(1).getMolarVolume()); - System.out.println("fugacity of gas phase " + testSystem.getPhase(1).getFugacity(0)); - System.out.println("enthalpy of gas phase is " + testSystem.getPhase(1).getEnthalpy("J/mol")); - System.out.println( - "isochoric heat capacity of gas phase is " + testSystem.getPhase(1).getCv("J/mol")); - // ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - // testOps.TPflash(); - + /* + * System.out.println("molar volume gas+oil is " + testSystem.getMolarVolume()); + * System.out.println("molar volume gas is " + testSystem.getPhase(0).getMolarVolume()); + * System.out.println("fugacity of gas phase " + testSystem.getPhase(0).getFugacity(0)); + * System.out.println("residual enthalpy of gas phase is " + + * testSystem.getPhase(0).getHresTP()); System.out.println( + * "isochoric heat capacity of gas phase is " + testSystem.getPhase(0).getCv("J/mol")); + * System.out .println("isobaric heat capacity of gas phase is " + + * testSystem.getPhase(0).getCp("J/mol")); System.out + * .println("internal energy of gas phase is " + testSystem.getPhase(0).getInternalEnergy()); + * System.out.println("molar volume liquid is " + testSystem.getPhase(1).getMolarVolume()); + * System.out.println("fugacity of gas phase " + testSystem.getPhase(1).getFugacity(0)); + * System.out.println("enthalpy of gas phase is " + + * testSystem.getPhase(1).getEnthalpy("J/mol")); System.out.println( + * "isochoric heat capacity of gas phase is " + testSystem.getPhase(1).getCv("J/mol")); // + * ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); // + * testOps.TPflash(); + */ // testSystem.initProperties(); // assertEquals(0.9711401538454589, testSystem.getPhase(0).getZ(), 0.001); } @@ -204,7 +204,7 @@ public void checkFugacityCoefficientsDn2() { *
* checkPhaseEnvelope. *
- * + * * @throws Exception */ // @Test @@ -222,8 +222,8 @@ public void checkPhaseEnvelope() throws Exception { ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); try { testOps.calcPTphaseEnvelope(); - System.out.println("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " - + testOps.get("cricondenbar")[1]); + // System.out.println("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " + // + testOps.get("cricondenbar")[1]); } catch (Exception ex) { assertTrue(false); throw new Exception(ex); diff --git a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java index 38393fb617..14af4075e1 100644 --- a/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java +++ b/src/test/java/neqsim/thermo/system/SystemUMRPRUMCEosNewTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import neqsim.PVTsimulation.simulation.SaturationPressure; import neqsim.thermodynamicOperations.ThermodynamicOperations; class SystemUMRPRUMCEosNewTest extends neqsim.NeqSimTest { @@ -188,7 +189,7 @@ public void checkFugacityCoefficientsDn2() { ** checkPhaseEnvelope. *
- * + * * @throws Exception */ @Test @@ -214,4 +215,60 @@ public void checkPhaseEnvelope() throws Exception { } assertEquals(testOps.get("cricondenbar")[1], 130.686140727503, 0.02); } + + /** + *+ * checkPhaseEnvelope2. + *
+ * + * @throws Exception + */ + @Test + @DisplayName("calculate phase envelope using UMR") + public void checkPhaseEnvelope2() throws Exception { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 10.0); + testSystem.addComponent("N2", 0.00675317857); + testSystem.addComponent("CO2", .02833662296); + testSystem.addComponent("methane", 0.8363194562); + testSystem.addComponent("ethane", 0.06934307324); + testSystem.addComponent("propane", 0.03645246567); + testSystem.addComponent("i-butane", 0.0052133558); + testSystem.addComponent("n-butane", 0.01013260919); + testSystem.addComponent("i-pentane", 0.00227310164); + testSystem.addComponent("n-pentane", 0.00224658464); + testSystem.addComponent("2-m-C5", 0.00049491); + testSystem.addComponent("3-m-C5", 0.00025783); + testSystem.addComponent("n-hexane", 0.00065099); + testSystem.addComponent("c-hexane", .00061676); + testSystem.addComponent("n-heptane", 0.00038552); + testSystem.addComponent("benzene", 0.00016852); + testSystem.addComponent("n-octane", 0.00007629); + testSystem.addComponent("c-C7", 0.0002401); + testSystem.addComponent("toluene", 0.0000993); + testSystem.addComponent("n-nonane", 0.00001943); + testSystem.addComponent("c-C8", 0.00001848); + testSystem.addComponent("m-Xylene", 0.00002216); + testSystem.addComponent("nC10", 0.00000905); + testSystem.addComponent("nC11", 0.000000001); + testSystem.addComponent("nC12", 0.000000001); + + testSystem.setMixingRule("HV", "UNIFAC_UMRPRU"); + testSystem.init(0); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.calcPTphaseEnvelope(); + logger.info("Cricondenbar " + (testOps.get("cricondenbar")[0] - 273.15) + " " + + testOps.get("cricondenbar")[1]); + } catch (Exception ex) { + assertTrue(false); + throw new Exception(ex); + } + assertEquals((testOps.get("cricondenbar")[0] - 273.15), -11.09948347, 0.02); + assertEquals(testOps.get("cricondenbar")[1], 104.75329137038476, 0.02); + + testSystem.setTemperature(-11.09948347, "C"); + SaturationPressure satPresSim = new SaturationPressure(testSystem); + satPresSim.run(); + assertEquals(satPresSim.getThermoSystem().getPressure(), 104.7532, 0.001); + } } diff --git a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java index 71231c48c8..cc8db77078 100644 --- a/src/test/java/neqsim/thermo/util/example/ActivityCalc.java +++ b/src/test/java/neqsim/thermo/util/example/ActivityCalc.java @@ -6,6 +6,7 @@ package neqsim.thermo.util.example; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -28,7 +29,8 @@ public class ActivityCalc { * @param args an array of {@link java.lang.String} objects */ public static void main(String args[]) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 42, 1.01325); + SystemInterface testSystem = + new SystemSrkCPAstatoil(273.15 + 42, ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); diff --git a/src/test/java/neqsim/thermo/util/example/AmineFlash.java b/src/test/java/neqsim/thermo/util/example/AmineFlash.java index 5a438a0988..8bf2c09e33 100644 --- a/src/test/java/neqsim/thermo/util/example/AmineFlash.java +++ b/src/test/java/neqsim/thermo/util/example/AmineFlash.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -26,8 +27,10 @@ public class AmineFlash { * @param args an array of {@link java.lang.String} objects */ public static void main(String args[]) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(273.15 + 50, 1.01325); - // SystemInterface testSystem = new SystemElectrolyteCPA(273.15+40, 1.01325); + SystemInterface testSystem = new SystemFurstElectrolyteEos(273.15 + 50, + ThermodynamicConstantsInterface.referencePressure); + // SystemInterface testSystem = new SystemElectrolyteCPA(273.15+40, + // ThermodynamicConstantsInterface.referencePressure); double molMDEA = 0.1; double loading = 0.4; double density = 1088; diff --git a/src/test/java/neqsim/thermo/util/example/BubbleFlashCPA.java b/src/test/java/neqsim/thermo/util/example/BubbleFlashCPA.java index d0f6c99655..33f06f01ef 100644 --- a/src/test/java/neqsim/thermo/util/example/BubbleFlashCPA.java +++ b/src/test/java/neqsim/thermo/util/example/BubbleFlashCPA.java @@ -47,13 +47,13 @@ public static void main(String args[]) { testSystem.addComponent("TEG", 100.0); /* * testSystem.addComponent("methane", 69.243); - * + * * testSystem.addComponent("CO2", 4.113); testSystem.addComponent("ethane", 8.732); * testSystem.addComponent("propane", 4.27); testSystem.addComponent("n-pentane", 1.641); * testSystem.addComponent("i-pentane", 0.877); - * + * * testSystem.addComponent("benzene", 1.27); - * + * * testSystem.addTBPfraction("C6", 1.49985, 86.178 / 1000.0, 0.664); * testSystem.addTBPfraction("C7", 1.359864, 96.0 / 1000.0, 0.738); * testSystem.addTBPfraction("C8", 0.939906, 107.0 / 1000.0, 0.765); diff --git a/src/test/java/neqsim/thermo/util/example/DewPointCurve.java b/src/test/java/neqsim/thermo/util/example/DewPointCurve.java index d131330c59..81d6eb1416 100644 --- a/src/test/java/neqsim/thermo/util/example/DewPointCurve.java +++ b/src/test/java/neqsim/thermo/util/example/DewPointCurve.java @@ -92,7 +92,6 @@ public static void main(String args[]) { * testSystem.getPhase(1).getActivityCoefficientSymetric(i)); } * System.out.println("activity coeff " + testSystem.getPhase(1).getComponent(1).getName() + " " * + testSystem.getPhase(1).getActivityCoefficient(1, 0)); - * */ } } diff --git a/src/test/java/neqsim/thermo/util/example/FreezingPoint.java b/src/test/java/neqsim/thermo/util/example/FreezingPoint.java index ebe9114958..059458db1b 100644 --- a/src/test/java/neqsim/thermo/util/example/FreezingPoint.java +++ b/src/test/java/neqsim/thermo/util/example/FreezingPoint.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -27,10 +28,12 @@ public class FreezingPoint { */ public static void main(String[] args) { // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(260.15,19.00); - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 - 1, 1.01325); + SystemInterface testSystem = + new SystemSrkCPAstatoil(273.15 - 1, ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.15 + 100, 1.01325); + SystemInterface testSystem2 = + new SystemSrkCPAstatoil(273.15 + 100, ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); testSystem.addComponent("methane", 0.00882); diff --git a/src/test/java/neqsim/thermo/util/example/H2Sdistribution.java b/src/test/java/neqsim/thermo/util/example/H2Sdistribution.java index 40f68e1c39..6dc20ca7c4 100644 --- a/src/test/java/neqsim/thermo/util/example/H2Sdistribution.java +++ b/src/test/java/neqsim/thermo/util/example/H2Sdistribution.java @@ -51,6 +51,6 @@ public static void main(String args[]) { } catch (Exception ex) { } testSystem.display(); - System.out.println("pH " + testSystem.getPhase("aqueous").getpH()); + // System.out.println("pH " + testSystem.getPhase("aqueous").getpH()); } } diff --git a/src/test/java/neqsim/thermo/util/example/HydrateFlash.java b/src/test/java/neqsim/thermo/util/example/HydrateFlash.java index 9d8317d9b0..a7c4d5639b 100644 --- a/src/test/java/neqsim/thermo/util/example/HydrateFlash.java +++ b/src/test/java/neqsim/thermo/util/example/HydrateFlash.java @@ -150,8 +150,9 @@ public static void main(String args[]) { // testSystem.display(); // System.out.println("kg vann/MSm^3 gas " + // (testSystem.getPhase(0).getComponent("water").getx() * - // testSystem.getPhase(0).getComponent("water").getMolarMass() * 101325.0 / - // 8.314 / 288.15) * 1.0e6); + // testSystem.getPhase(0).getComponent("water").getMolarMass() + // *ThermodynamicConstantsInterface.atm / + // ThermodynamicConstantsInterface.R / 288.15) * 1.0e6); // System.out.println("activity coef water " + // testSystem.getPhase(1).getActivityCoefficientSymetric(1)); // int n = testSystem.getNumberOfPhases()-1; @@ -166,10 +167,8 @@ public static void main(String args[]) { * * testSystem2.setMixingRule(7); testSystem2.init(0); testSystem2.init(1); * ThermodynamicOperations testOps2 = new ThermodynamicOperations(testSystem2); try { - * testOps2.waterDewPointTemperatureFlash(); - * - * } catch (Exception ex) { logger.error(ex.getMessage()) } testSystem2.display(); - * + * testOps2.waterDewPointTemperatureFlash(); } catch (Exception ex) { + * logger.error(ex.getMessage()) } testSystem2.display(); */ } } diff --git a/src/test/java/neqsim/thermo/util/example/LNGFlash.java b/src/test/java/neqsim/thermo/util/example/LNGFlash.java index 9c6afda1b4..ea57a444f5 100644 --- a/src/test/java/neqsim/thermo/util/example/LNGFlash.java +++ b/src/test/java/neqsim/thermo/util/example/LNGFlash.java @@ -66,8 +66,6 @@ public static void main(String args[]) { * ThermodynamicOperations(testSystem); try { testOps.TPflash(); // testSystem.display(); // * testOps.freezingPointTemperatureFlash(); // testOps.calcWAT(); testSystem.display(); } catch * (Exception ex) { logger.error(ex.getMessage(),e); } } - * - * */ } } diff --git a/src/test/java/neqsim/thermo/util/example/ModelTest.java b/src/test/java/neqsim/thermo/util/example/ModelTest.java index 2ffce3ac5a..e905e668e2 100644 --- a/src/test/java/neqsim/thermo/util/example/ModelTest.java +++ b/src/test/java/neqsim/thermo/util/example/ModelTest.java @@ -33,7 +33,8 @@ public static void main(String args[]) { // SystemInterface testSystem = new SystemFurstElectrolyteEos(273.14 + 12, // 61.0); // SystemInterface testSystem = new SystemUMRPRUMCEos(300.0, 10.0); - // SystemInterface testSystem = new SystemSrkEos(298.15, 1.01325); + // SystemInterface testSystem = new SystemSrkEos(298.15, + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); //testSystem.addComponent("methane", 100); diff --git a/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient.java b/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient.java index 8e24ecee71..22e5599766 100644 --- a/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient.java +++ b/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient.java @@ -1,5 +1,6 @@ package neqsim.thermo.util.example; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemElectrolyteCPAstatoil; import neqsim.thermo.system.SystemInterface; @@ -22,11 +23,13 @@ public class OsmoticCoefficient { */ @SuppressWarnings("unused") public static void main(String args[]) { - SystemInterface testSystem = new SystemElectrolyteCPAstatoil(298.0, 1.01325); - // SystemInterface testSystem = new SystemElectrolyteCPA(298.15,1.01325201325); - // SystemInterface testSystem = new SystemSrkCPAs(298.15,1.01325); + SystemInterface testSystem = + new SystemElectrolyteCPAstatoil(298.0, ThermodynamicConstantsInterface.referencePressure); + // SystemInterface testSystem = new SystemElectrolyteCPA(298.15,1.01325201325); // SystemInterface testSystem = new - // SystemSrkSchwartzentruberEos(298.15,1.01325); + // SystemSrkCPAs(298.15,ThermodynamicConstantsInterface.referencePressure); + // SystemInterface testSystem = new + // SystemSrkSchwartzentruberEos(298.15,ThermodynamicConstantsInterface.referencePressure); // creates a 0.1 molar solution 0.0018 testSystem.addComponent("methane", 10.0); diff --git a/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient_1.java b/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient_1.java index 4937271d3c..c5362907ed 100644 --- a/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient_1.java +++ b/src/test/java/neqsim/thermo/util/example/OsmoticCoefficient_1.java @@ -1,5 +1,6 @@ package neqsim.thermo.util.example; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemFurstElectrolyteEos; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -23,11 +24,14 @@ public class OsmoticCoefficient_1 { */ @SuppressWarnings("unused") public static void main(String args[]) { - SystemInterface testSystem = new SystemFurstElectrolyteEos(298.15, 1.01325); - // SystemInterface testSystem = new SystemElectrolyteCPA(298.15,1.01325); - // SystemInterface testSystem = new SystemSrkCPAs(298.15,1.01325); + SystemInterface testSystem = + new SystemFurstElectrolyteEos(298.15, ThermodynamicConstantsInterface.referencePressure); // SystemInterface testSystem = new - // SystemSrkSchwartzentruberEos(298.15,1.01325); + // SystemElectrolyteCPA(298.15,ThermodynamicConstantsInterface.referencePressure); + // SystemInterface testSystem = new + // SystemSrkCPAs(298.15,ThermodynamicConstantsInterface.referencePressure); + // SystemInterface testSystem = new + // SystemSrkSchwartzentruberEos(298.15,ThermodynamicConstantsInterface.referencePressure); // creates a 0.1 molar solution 0.0018 testSystem.addComponent("CO2", 0.1); diff --git a/src/test/java/neqsim/thermo/util/example/PS_PH_flash.java b/src/test/java/neqsim/thermo/util/example/PS_PH_flash.java index 0e1c685257..c31fd705d7 100644 --- a/src/test/java/neqsim/thermo/util/example/PS_PH_flash.java +++ b/src/test/java/neqsim/thermo/util/example/PS_PH_flash.java @@ -74,11 +74,10 @@ public static void main(String args[]) { double entropy = testSystem.getEntropy(); /* * testSystem.setTemperature(273.15 + 0.0); testSystem.setPressure(100.0); try { - * testOps.TPflash(); // testOps.bubblePointTemperatureFlash(); } catch (Exception ex) { - * - * } testSystem.init(2); testSystem.setPressure(100.0); // System.out.println("entropy spec" + + * testOps.TPflash(); // testOps.bubblePointTemperatureFlash(); } catch (Exception ex) { } + * testSystem.init(2); testSystem.setPressure(100.0); // System.out.println("entropy spec" + * entropy); - * + * * // testSystem.setPressure(20.894745); */ testSystem.setPressure(10.0); diff --git a/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java b/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java index b724bdb320..fb958e0187 100644 --- a/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java +++ b/src/test/java/neqsim/thermo/util/example/PhaseEnvelope.java @@ -109,10 +109,10 @@ public static void main(String args[]) { * testOps.setRunAsThread(true); testOps.waterDewPointLine(10, 200); boolean isFinished = * testOps.waitAndCheckForFinishedCalculation(50000); double[][] waterData = * testOps.getData(); - * + * * testOps.hydrateEquilibriumLine(10, 200); isFinished = * testOps.waitAndCheckForFinishedCalculation(50000); double[][] hydData = testOps.getData(); - * + * * testSystem.addComponent("water", * -testSystem.getPhase(0).getComponent("water").getNumberOfmoles()); */ diff --git a/src/test/java/neqsim/thermo/util/example/ReactiveTPflash.java b/src/test/java/neqsim/thermo/util/example/ReactiveTPflash.java index 1ce0df6d96..2fc07cb1e8 100644 --- a/src/test/java/neqsim/thermo/util/example/ReactiveTPflash.java +++ b/src/test/java/neqsim/thermo/util/example/ReactiveTPflash.java @@ -67,7 +67,7 @@ public static void main(String args[]) { } catch (Exception ex) { } testSystem.display(); - System.out.println("pH " + testSystem.getPhase(1).getpH()); + // System.out.println("pH " + testSystem.getPhase(1).getpH()); logger.info("pH " + testSystem.getPhase(1).getpH()); logger.info( "activity coefficiet water " + testSystem.getPhase("aqueous").getActivityCoefficient(2)); diff --git a/src/test/java/neqsim/thermo/util/example/ReadFluidData2.java b/src/test/java/neqsim/thermo/util/example/ReadFluidData2.java index 6d9024070d..64cfb4d9dc 100644 --- a/src/test/java/neqsim/thermo/util/example/ReadFluidData2.java +++ b/src/test/java/neqsim/thermo/util/example/ReadFluidData2.java @@ -53,7 +53,7 @@ public static void main(String args[]) { * // // ""); // testSystem.addComponent("water", 1.0); testSystem.setMixingRule(2); // * testSystem.setMultiPhaseCheck(true); //testSystem.setMultiPhaseCheck(false); * ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); - * + * * try { testOps.TPflash(); testSystem.display(); testOps.PSflash(-123.108602625942); * testSystem.display(); testSystem.setPressure(100.0); testOps.PSflash(-119.003271056256); * testSystem.display(); System.out.println("entropy " + testSystem.getEntropy()); diff --git a/src/test/java/neqsim/thermo/util/example/SulfureDeposition.java b/src/test/java/neqsim/thermo/util/example/SulfureDeposition.java index b1c1fd4a8b..37c889e1f5 100644 --- a/src/test/java/neqsim/thermo/util/example/SulfureDeposition.java +++ b/src/test/java/neqsim/thermo/util/example/SulfureDeposition.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -137,7 +138,7 @@ public static void main(String args[]) { logger.info("mol S8/mol gas (ppb) " + testSystem.getPhase(0).getComponent("S8").getx() * 1e9); logger.info("mg S8/Sm^3 gas " + testSystem.getPhase(0).getComponent("S8").getx() * testSystem.getPhase(0).getComponent("S8").getMolarMass() * 1e6 - * (101325 / (8.315 * 288.15))); + * (101325 / (ThermodynamicConstantsInterface.R * 288.15))); logger.info("wt% S8 in gas " + testSystem.getPhase(0).getComponent("S8").getx() * testSystem.getPhase(0).getComponent("S8").getMolarMass() diff --git a/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java b/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java index bf1b40f010..f51bdfa325 100644 --- a/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java +++ b/src/test/java/neqsim/thermo/util/example/TPMultiFlash.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -98,7 +99,7 @@ public static void main(String[] args) { phase = 1; } - testSystem.setPhaseType(0, phase); + testSystem.setPhaseType(0, PhaseType.byValue(phase)); testSystem.init(2, 0); testSystem.initPhysicalProperties(); } diff --git a/src/test/java/neqsim/thermo/util/example/TPflash.java b/src/test/java/neqsim/thermo/util/example/TPflash.java index 93a5159a9a..ae044a6929 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflash.java +++ b/src/test/java/neqsim/thermo/util/example/TPflash.java @@ -48,7 +48,7 @@ public static void main(String[] args) { * testSystem.addTBPfraction("C10", 1.0, 225.5046 / 1000.0, 841.1014 / 1000.0); * testSystem.setMolarComposition(new double[] { 0.829, 0, 0.0007, 0.002, 0.0707, 0.0072, * 0.0051, 0.0019, 0.0062, 0.0048, 0.006, 0.0074, 0.0109, 0.0109, 0.0062, 0.031 }); - * + * * testSystem.setHeavyTBPfractionAsPlusFraction(); * testSystem.getCharacterization().characterisePlusFraction(); */ diff --git a/src/test/java/neqsim/thermo/util/example/TPflash2.java b/src/test/java/neqsim/thermo/util/example/TPflash2.java index 47835671e0..3adcb4eb01 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflash2.java +++ b/src/test/java/neqsim/thermo/util/example/TPflash2.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkCPAstatoil; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -26,14 +27,16 @@ public class TPflash2 { * @param args an array of {@link java.lang.String} objects */ public static void main(String[] args) { - SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325); + SystemInterface testSystem = + new SystemSrkCPAstatoil(273.15 + 80.0, ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("nitrogen", 8.71604938); // testSystem.addComponent("oxygen", 22.71604938); testSystem.addComponent("water", 110.234567901); testSystem.createDatabase(true); testSystem.setMixingRule(10); // testSystem.setMultiPhaseCheck(true); - SystemInterface testSystem2 = new SystemSrkCPAstatoil(273.15 + 80.0, 1.01325); + SystemInterface testSystem2 = + new SystemSrkCPAstatoil(273.15 + 80.0, ThermodynamicConstantsInterface.referencePressure); testSystem2.addComponent("nitrogen", 8.71604938); // testSystem.addComponent("oxygen", 22.71604938); testSystem2.addComponent("MEG", 110.234567901); diff --git a/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java b/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java index 1909d11e56..ed8f2e83a3 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashDehyd.java @@ -75,30 +75,30 @@ public static void main(String[] args) { // testSystem.init(1); /* * testSystem.init(2); - * + * * // testSystem.init(1); // testSystem.init(2); // testSystem.init(3); // * System.out.println("heat cap " + (testSystem.getPhase(1).getCp())); // * testOps.calcPTphaseEnvelope(); testSystem.display(); // testSystem.getPhase(0).getCp(); } * catch (Exception ex) { System.out.println(ex.toString()); } - * + * * /* System.out.println("gas density " + (testSystem.getPhase(0).getDensity())); * System.out.println("gas density " + (1.0 / (testSystem.getPhase(0).getDensity() / * testSystem.getPhase(0).getMolarMass()))); - * + * * System.out.println("liq density " + (testSystem.getPhase(1).getDensity())); * System.out.println("liq density " + (1.0 / (testSystem.getPhase(1).getDensity() / * testSystem.getPhase(1).getMolarMass()))); - * + * * testSystem.initPhysicalProperties(); testSystem.init(1); - * - * System.out.println("start....."); testSystem.removeMoles(); + * + * System.out.println("start....."); testSystem.setEmptyFluid(); * testSystem.setMolarComposition(new double[]{1.0, 1e-20, 1e-20}); testSystem.init(0, 0); * testSystem.init(1); testSystem.display(); - * + * * System.out.println("end....."); testSystem.setMolarComposition(new double[]{0.000001, * 0.00001, 1e-20}); // testSystem.init(1); testSystem.init(0, 0); testSystem.init(1); // * testSystem.display(); - * + * * /* testSystem.initPhysicalProperties(); double rho1 = * testSystem.getPhase(0).getPhysicalProperties().getDensity(); System.out.println("drhodP " + * testSystem.getPhase(0).getdrhodP()); System.out.println("drhodT " + @@ -106,10 +106,10 @@ public static void main(String[] args) { * testSystem.setPressure(testSystem.getPressure() + 0.001); testSystem.init(1); // * testSystem.display(); // testSystem.initPhysicalProperties(); double rho2 = * testSystem.getPhase(0).getPhysicalProperties().getDensity(); - * + * * //System.out.println("drhodPnum " + (rho2 - rho1) / 0.01); System.out.println("drhodTnum " + * (rho2 - rho1) / 0.001); - * + * * testSystem.saveFluid(2327); testSystem.saveFluid(2301); // testSystem.setNumberOfPhases(1); * // testSystem.setTemperature(299.0); // testSystem.init(1); // * testSystem.getPhase(0).getEntropy(); // System.out.println("enthalpy " + @@ -119,8 +119,7 @@ public static void main(String[] args) { * testSystem.getPhase(0).getCp()); System.out.println("enthalpy " + * testSystem.getPhase(0).getEnthalpy()); System.out.println("entropy " + * testSystem.getPhase(0).getEntropy()); - * - * + * * testSystem.init(2); System.out.println("Cp " + testSystem.getPhase(0).getCp()); * System.out.println("enthalpy " + testSystem.getPhase(0).getEnthalpy()); * System.out.println("entropy " + testSystem.getPhase(0).getEntropy()); testSystem.init(3); @@ -132,7 +131,7 @@ public static void main(String[] args) { * ThermodynamicOperations(testSystem); try { // testOps.freezingPointTemperatureFlash(); * testOps.TPflash(); // testOps.calcPTphaseEnvelope(); // testOps.display(); // * testSystem.display(); } catch (Exception ex) { System.out.println(ex.toString()); } - * + * * /* double h1 = testSystem.getPhase(0).getEntropy(); System.out.println("H " + * testSystem.getPhase(0).getEntropy()); System.out.println("H dP " + * testSystem.getPhase(0).getEntropydT()); testSystem.setTemperature(testSystem.getTemperature() @@ -147,7 +146,7 @@ public static void main(String[] args) { * (testSystem.getPhase(1).getComponent("methane").getx() / * testSystem.getPhase(0).getComponent("methane").getx()); * System.out.println("selectivity CO2/methane " + seletivity); - * + * * double seletivity2 = testSystem.getPhase(1).getComponent("CO2").getx() / * testSystem.getPhase(0).getComponent("CO2").getx() / * (testSystem.getPhase(1).getComponent("ethane").getx() / @@ -162,23 +161,23 @@ public static void main(String[] args) { * testSystem.getPhase(2).getWtFraction(testSystem) + * testSystem.getPhase(1).getWtFraction(testSystem) + * testSystem.getPhase(0).getWtFraction(testSystem)); - * + * * double a = testSystem.getPhase(0).getBeta() * testSystem.getPhase(0).getMolarMass() / * testSystem.getMolarMass(); double seletivity = * testSystem.getPhase(1).getComponent("CO2").getx() / * testSystem.getPhase(0).getComponent("CO2").getx() / * (testSystem.getPhase(1).getComponent("methane").getx() / * testSystem.getPhase(0).getComponent("methane").getx()); - * - * - * double solubility = testSystem.getPhase(1).getComponent("CO2").getx() * 8.314 * 298.15 / - * 101325.0 / (testSystem.getPhase(1).getMolarMass()) * 1000; - * + * + * double solubility = testSystem.getPhase(1).getComponent("CO2").getx() * + * ThermodynamicConstantsInterface.R * 298.15 /ThermodynamicConstantsInterface.atm / + * (testSystem.getPhase(1).getMolarMass()) * 1000; + * * System.out.println("selectivity " + seletivity); System.out.println("CO2 solubility " + * solubility); System.out.println("Z " + testSystem.getPhase(0).getZ()); // * testSystem.getPhase(0).getComponentWithIndex(1); // testSystem.saveObject(300); // * System.out.println("ethanol activity " + testSystem.getPhase(0).getActivityCoefficient(0)); - * + * * //testSystem. // System.out.println("water activity " + * testSystem.getPhase(1).getActivityCoefficient(1)); // System.out.println("TEG activity " + * testSystem.getPhase(1).getActivityCoefficient(0)); // testSystem.display(); diff --git a/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java b/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java index 722bf67073..4696a02b50 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashMembrane.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseType; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -30,7 +31,8 @@ public static void main(String args[]) { // SystemInterface testSystem2 = // util.serialization.SerializationManager.open("c:/test.fluid"); // testSystem2.display(); - SystemInterface testSystem = new SystemSrkEos(298, 1.01325); + SystemInterface testSystem = + new SystemSrkEos(298, ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); diff --git a/src/test/java/neqsim/thermo/util/example/TPflashMethanolWaterPropane.java b/src/test/java/neqsim/thermo/util/example/TPflashMethanolWaterPropane.java index fd83bee68d..04da438fc9 100644 --- a/src/test/java/neqsim/thermo/util/example/TPflashMethanolWaterPropane.java +++ b/src/test/java/neqsim/thermo/util/example/TPflashMethanolWaterPropane.java @@ -32,7 +32,7 @@ public static void main(String args[]) { /* * testSystem.addComponent("methane", 150.0e-2); testSystem.addComponent("propane", 150.0e-3); * testSystem.addComponent("methanol", 0.5); testSystem.addComponent("water", 0.5); - * + * * testSystem.createDatabase(true); testSystem.setMixingRule(10); * testSystem.setMultiPhaseCheck(true); */ diff --git a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java index b3adc4d207..654c1104f8 100644 --- a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java +++ b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate.java @@ -112,7 +112,7 @@ public static void main(String args[]) { /* * System.out.println("molar mass " * +testSystem.getPhase(0).getComponent("PC4_PC").getMolarMass() ); - * + * * testSystem.setMolarCompositionOfPlusFluid(new double[]{0.02, 0.005, 0.4, 0.01, 0.01, 0.02, * 0.02, 0.01 ,0.01, 0.01, 0.01 ,0.01, 0.01, 0.2 }); try { testOps.TPflash(); // * testOps.hydrateFormationTemperature(); // testOps.dewPointTemperatureFlash(); } catch diff --git a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java index f0d7e8d780..3b15f51a6e 100644 --- a/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java +++ b/src/test/java/neqsim/thermo/util/example/TestCharacterizationCondensate1.java @@ -51,18 +51,18 @@ public static void main(String args[]) { */ testSystem.addTBPfraction("C7", 5, 100.0 / 1000.0, 0.72); testSystem.addPlusFraction("C8", 50, 230.0 / 1000.0, 0.84); - //testSystem.addPlusFraction("C8", 34, 200.0 / 1000.0, 0.82); + // testSystem.addPlusFraction("C8", 34, 200.0 / 1000.0, 0.82); testSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12); testSystem.getCharacterization().characterisePlusFraction(); /* * testSystem.getInterphaseProperties().setInterfacialTensionModel(0); */ - System.out.println("number of components " + testSystem.getNumberOfComponents()); + // System.out.println("number of components " + testSystem.getNumberOfComponents()); testSystem.useVolumeCorrection(true); testSystem.createDatabase(true); testSystem.setMixingRule(2); testSystem.setMultiPhaseCheck(true); - System.out.println("number of components " + testSystem.getNumberOfComponents()); + // System.out.println("number of components " + testSystem.getNumberOfComponents()); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); try { diff --git a/src/test/java/neqsim/thermo/util/example/TestFluidIssues.java b/src/test/java/neqsim/thermo/util/example/TestFluidIssues.java index 7c5971e928..9bf29fe417 100644 --- a/src/test/java/neqsim/thermo/util/example/TestFluidIssues.java +++ b/src/test/java/neqsim/thermo/util/example/TestFluidIssues.java @@ -26,7 +26,7 @@ public static void main(String args[]) { // SystemInterface testSystem = new SystemSrkEos(303.15, 10.01325); SystemInterface testSystem = new SystemSrkCPAstatoil(303.15, 15.0); // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(298.15, - // 1.01325); + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testSystem.addComponent("methane", 100.0); // testSystem.addComponent("water", 100.0); diff --git a/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java b/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java index 6aa5f0bc31..8b052a110d 100644 --- a/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java +++ b/src/test/java/neqsim/thermo/util/example/TestUMRPRU.java @@ -100,8 +100,8 @@ public static void main(String args[]) { double numCp = (ent1 - ent2) / 0.002; - System.out.println("Cp " + cp + " numCp " + numCp); - System.out.println("entropy " + testSystem.getPhase(1).getEntropy()); + //System.out.println("Cp " + cp + " numCp " + numCp); + //System.out.println("entropy " + testSystem.getPhase(1).getEntropy()); // thermo.ThermodynamicModelTest testModel = new // thermo.ThermodynamicModelTest(testSystem); diff --git a/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java b/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java index 9d7638f6e0..9ed4964bd2 100644 --- a/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java +++ b/src/test/java/neqsim/thermo/util/example/TestUniSimsFlash.java @@ -42,7 +42,7 @@ public static void main(String[] args) { testSystem.display(); double[] composition = new double[] {0.1, 0.0, 1.1, 1.0, 1.0}; - // testSystem.removeMoles(); + // testSystem.setEmptyFluid(); testSystem.setMolarComposition(composition); testSystem.init(0); // testSystem.setMultiPhaseCheck(true); @@ -53,7 +53,7 @@ public static void main(String[] args) { testSystem.display(); /* - * composition = new double[]{0.1, 0.0, 1.1, 1.0, 1.0}; testSystem.removeMoles(); + * composition = new double[]{0.1, 0.0, 1.1, 1.0, 1.0}; testSystem.setEmptyFluid(); * testSystem.setMolarComposition(composition); for (int i = 0; i < 1; i++) { testOps.TPflash(); * } testSystem.display(); */ diff --git a/src/test/java/neqsim/thermo/util/example/TestVHflash.java b/src/test/java/neqsim/thermo/util/example/TestVHflash.java index f6ab07021e..9ad56b3f51 100644 --- a/src/test/java/neqsim/thermo/util/example/TestVHflash.java +++ b/src/test/java/neqsim/thermo/util/example/TestVHflash.java @@ -2,6 +2,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -26,13 +27,15 @@ public class TestVHflash { * @param args an array of {@link java.lang.String} objects */ public static void main(String args[]) { - double pressureInTank = 1.01325; // Pa + double pressureInTank = ThermodynamicConstantsInterface.referencePressure; // Pa double temperatureInTank = 293.15; - double totalMolesInTank = 136000 * pressureInTank * 1.0e5 / 8.314 / temperatureInTank; + double totalMolesInTank = + 136000 * pressureInTank * 1.0e5 / ThermodynamicConstantsInterface.R / temperatureInTank; double molefractionNitrogenInTank = 0.95; double molesInjectedLNG = 200000.0; - double molesInjecedVacumBreakerGas = 18 * pressureInTank * 1.0e5 / 8.314 / temperatureInTank; + double molesInjecedVacumBreakerGas = + 18 * pressureInTank * 1.0e5 / ThermodynamicConstantsInterface.R / temperatureInTank; SystemInterface testSystem = new SystemSrkEos(temperatureInTank, pressureInTank); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); diff --git a/src/test/java/neqsim/thermo/util/readwrite/A-1.E300 b/src/test/java/neqsim/thermo/util/readwrite/A-1.E300 new file mode 100644 index 0000000000..f7f1e1c43b --- /dev/null +++ b/src/test/java/neqsim/thermo/util/readwrite/A-1.E300 @@ -0,0 +1,434 @@ +-- Dummy EOS for FluidMagic Test case +-- +-- Copyright (C) 2022 Equinor + +-- Units +METRIC +-- Number of components: +NCOMPS +22 / +-- Equation of state +EOS +PR / +PRCORR + +-- Reservoir temperature (C) +RTEMP + 90.00 / + +-- Standard Conditions (C and bara) +STCOND + 15.00000 1.01325 / + +-- Component names +CNAMES +N2 +CO2 +C1 +C2 +C3 +iC4 +C4 +iC5 +C5 +C6 +C7 +C8 +C9 +C10-C12 +C13-C14 +C15-C17 +C18-C21 +C22-C28 +C29-C36 +C37-C45 +C46-C58 +C59-C80 / +-- Tc (K) +TCRIT + 126.200 + 304.200 + 190.600 + 305.400 + 369.800 + 408.100 + 425.200 + 460.400 + 469.600 + 507.400 + 548.083 + 568.470 + 592.686 + 631.845 + 680.299 + 727.035 + 774.284 + 851.846 + 943.373 + 1038.592 + 1152.236 + 1317.304 / +-- Pc (Bar) +PCRIT + 33.9439 + 73.7646 + 46.0015 + 48.8387 + 42.4552 + 36.4770 + 37.9969 + 33.8426 + 33.7412 + 29.6882 + 29.4519 + 27.6423 + 25.5535 + 22.7296 + 20.0143 + 18.1224 + 16.7108 + 15.1759 + 14.0297 + 13.2891 + 12.7370 + 12.2645 +/ +-- Omega +ACF + 0.04000 + 0.22500 + 0.00800 + 0.09800 + 0.15200 + 0.17600 + 0.19300 + 0.22700 + 0.25100 + 0.29600 + 0.33744 + 0.37547 + 0.42325 + 0.50535 + 0.61393 + 0.72473 + 0.83712 + 1.00708 + 1.15740 + 1.21951 + 1.12382 + 0.62590 / +-- OmegaA +OMEGAA + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 / +-- OmegaB +OMEGAB + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 / +-- Molecular weights +MW + 28.0135 + 44.0098 + 16.0429 + 30.0698 + 44.0968 + 58.1237 + 58.1237 + 72.1507 + 72.1506 + 86.1776 + 96.0000 + 107.0000 + 121.0000 + 145.7094 + 181.9678 + 220.6919 + 264.4041 + 342.9118 + 447.3217 + 565.3735 + 714.4236 + 942.2227 / +-- Boiling points (K) +TBOIL + 77.400 + 194.650 + 111.600 + 184.600 + 231.100 + 261.400 + 272.700 + 301.000 + 309.200 + 341.900 + 365.100 + 389.900 + 415.400 + 459.042 + 509.712 + 555.777 + 599.945 + 669.261 + 738.465 + 799.356 + 865.446 + 950.674 / +-- Critical volumes (m3/kg-mole) +VCRIT + 0.08980 + 0.09400 + 0.09900 + 0.14800 + 0.20300 + 0.26300 + 0.25500 + 0.30600 + 0.30400 + 0.37000 + 0.47555 + 0.48784 + 0.52918 + 0.62175 + 0.75937 + 0.92679 + 1.12076 + 1.49307 + 2.00337 + 2.60288 + 3.39260 + 4.64881 / +-- Critical Z-factors +ZCRIT + 0.29049 + 0.27414 + 0.28737 + 0.28465 + 0.28029 + 0.28272 + 0.27406 + 0.27052 + 0.26270 + 0.26037 + 0.30733 + 0.28530 + 0.27440 + 0.26900 + 0.26869 + 0.27784 + 0.29091 + 0.31991 + 0.35833 + 0.40055 + 0.45103 + 0.52054 / +-- Volume translation/co-volume +SSHIFT + -0.175888 + -0.049181 + -0.194020 + -0.143142 + -0.112702 + -0.099214 + -0.089659 + -0.070455 + -0.056872 + 0.012573 + 0.074067 + 0.085121 + 0.081268 + 0.069060 + 0.048755 + 0.018239 + -0.017443 + -0.077518 + -0.156174 + -0.235730 + -0.320950 + -0.420868 / +-- Parachors (dyn/cm) +PARACHOR + 41.000 + 78.000 + 77.300 + 108.900 + 151.900 + 181.500 + 191.700 + 225.000 + 233.900 + 271.000 + 283.940 + 309.680 + 342.440 + 402.209 + 485.824 + 577.490 + 679.641 + 866.931 + 1111.372 + 1387.629 + 1739.859 + 2282.641 / +-- Overall dummy oil composition +ZI + 0.003912 + 0.003010 + 0.403275 + 0.076341 + 0.079752 + 0.011938 + 0.040929 + 0.013944 + 0.021568 + 0.027988 + 0.042936 + 0.043237 + 0.030898 + 0.043939 + 0.045143 + 0.022571 + 0.025180 + 0.021188 + 0.014111 + 0.012845 + 0.008955 + 0.006340 / +-- Binary interaction coefficients for PR +BIC + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +BICS + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +-- LBC coefficients +LBCCOEF + 0.1023000 0.0233640 0.0585330 -0.0407580 0.0093324 / + +-- Volume translation/co-volume at surface conditions +SSHIFTS + -0.175888 + -0.061524 + -0.194020 + -0.143142 + -0.112702 + -0.099214 + -0.089659 + -0.070455 + -0.056872 + 0.012573 + 0.073289 + 0.087351 + 0.090562 + 0.088354 + 0.076389 + 0.053077 + 0.022966 + -0.030899 + -0.104022 + -0.179642 + -0.262040 + -0.361298 / diff --git a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java index 6fa3b5feb7..d51d42d922 100644 --- a/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java +++ b/src/test/java/neqsim/thermo/util/readwrite/EclipseFluidReadWriteTest.java @@ -8,12 +8,13 @@ /** * @author ESOL - * */ class EclipseFluidReadWriteTest extends neqsim.NeqSimTest { static neqsim.thermo.system.SystemInterface testSystem = null; File file = new File("src/test/java/neqsim/thermo/util/readwrite"); + String fileFluid1 = file.getAbsolutePath() + "/fluid1.e300"; + String fileA1 = file.getAbsolutePath() + "/A-1.E300"; String fileA13 = file.getAbsolutePath() + "/A-13.E300"; String fileA17 = file.getAbsolutePath() + "/A-17.E300"; String fileA19 = file.getAbsolutePath() + "/A-19.E300"; @@ -22,13 +23,12 @@ class EclipseFluidReadWriteTest extends neqsim.NeqSimTest { * @throws java.lang.Exception */ @BeforeAll - static void setUpBeforeClass() throws Exception { - } + static void setUpBeforeClass() throws Exception {} /** * Test method for * {@link neqsim.thermo.util.readwrite.EclipseFluidReadWrite#read(java.lang.String)}. - * + * * @throws IOException */ @Test @@ -54,6 +54,20 @@ void testReadAndAddFluids() throws IOException { testOps.TPflash(); } + @Test + void testReadAndAddFluids2() throws IOException { + EclipseFluidReadWrite.pseudoName = "_A1"; + testSystem = EclipseFluidReadWrite.read(fileA1); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.setPressure(100.0, "bara"); + testSystem.setTemperature(25.0, "C"); + testOps.TPflash(); + + // neqsim.thermo.util.readwrite.TablePrinter.printTable((((PhaseEos + // )testSystem.getPhase(0)).getMixingRule().getBinaryInteractionParameters())); + } + @Test void testSetComposition() throws IOException { EclipseFluidReadWrite.pseudoName = "_A19"; @@ -72,4 +86,21 @@ void testSetComposition() throws IOException { ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testOps.TPflash(); } + + @Test + void testReadFluid1() throws IOException { + testSystem = EclipseFluidReadWrite.read(fileFluid1); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testSystem.setPressure(50.0, "bara"); + testSystem.setTemperature(50.0, "C"); + testOps.TPflash(); + + // neqsim.thermo.util.readwrite.TablePrinter.printTable( + // (((PhaseEos) testSystem.getPhase(0)).getMixingRule().getBinaryInteractionParameters())); + + // for (int i = 0; i < testSystem.getNumberOfComponents(); i++) { + // System.out.println(testSystem.getComponent(i).getName() + " TC " + // + (testSystem.getComponent(i).getVolumeCorrectionConst())); + // } + } } diff --git a/src/test/java/neqsim/thermo/util/readwrite/fluid1.e300 b/src/test/java/neqsim/thermo/util/readwrite/fluid1.e300 new file mode 100644 index 0000000000..476a1374c8 --- /dev/null +++ b/src/test/java/neqsim/thermo/util/readwrite/fluid1.e300 @@ -0,0 +1,424 @@ +-- Generated +METRIC +-- Number of components: +NCOMPS +22 / +-- Equation of state +EOS +PR / +PRCORR +-- Reservoir temperature (C) +RTEMP + 112.30 / +-- Standard Conditions (C and bara) +STCOND + 15.00000 1.01325 / +-- Component names +CNAMES +N2 +CO2 +C1 +C2 +C3 +iC4 +C4 +iC5 +C5 +C6 +C7 +C8 +C9 +C10-C12 +C13-C14 +C15-C16 +C17-C19 +C20-C22 +C23-C25 +C26-C28 +C29-C33 +C34-C80 / +-- Tc (K) +TCRIT + 126.200 + 304.200 + 190.600 + 305.400 + 369.800 + 408.100 + 425.200 + 460.400 + 469.600 + 507.400 + 527.669 + 553.949 + 579.636 + 622.942 + 666.834 + 706.246 + 747.081 + 786.847 + 821.763 + 855.619 + 894.027 + 1061.556 / +-- Pc (Bar) +PCRIT + 33.9439 + 73.7646 + 46.0015 + 48.8387 + 42.4552 + 36.4770 + 37.9969 + 33.8426 + 33.7412 + 29.6882 + 30.7250 + 27.8786 + 25.1398 + 21.6669 + 19.1244 + 17.4631 + 16.1506 + 15.1782 + 14.5255 + 14.0013 + 13.5329 + 12.5974 / +-- Omega +ACF + 0.04000 + 0.22500 + 0.00800 + 0.09800 + 0.15200 + 0.17600 + 0.19300 + 0.22700 + 0.25100 + 0.29600 + 0.32171 + 0.36663 + 0.41648 + 0.50584 + 0.60076 + 0.69007 + 0.78285 + 0.87002 + 0.94131 + 1.00419 + 1.06491 + 1.04501 / +-- OmegaA +OMEGAA + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 + 0.45724 / +-- OmegaB +OMEGAB + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 + 0.07780 / +-- Molecular weights +MW + 28.0135 + 44.0098 + 16.0429 + 30.0698 + 44.0968 + 58.1237 + 58.1237 + 72.1506 + 72.1506 + 85.1000 + 91.3000 + 104.7000 + 119.8000 + 147.7631 + 180.7557 + 213.2724 + 249.8889 + 288.2513 + 323.6568 + 359.5848 + 401.4829 + 565.6066 / +-- Boiling points (K) +TBOIL + 77.400 + 194.650 + 111.600 + 184.600 + 231.100 + 261.400 + 272.700 + 301.000 + 309.200 + 341.900 + 365.100 + 389.900 + 415.400 + 462.297 + 508.144 + 547.043 + 585.667 + 623.616 + 658.686 + 691.204 + 725.969 + 817.977 / +-- Critical volumes (m3/kg-mole) +VCRIT + 0.08980 + 0.09400 + 0.09900 + 0.14800 + 0.20300 + 0.26300 + 0.25500 + 0.30600 + 0.30400 + 0.37000 + 0.45436 + 0.48019 + 0.53302 + 0.63683 + 0.75711 + 0.88963 + 1.05005 + 1.22386 + 1.38886 + 1.56097 + 1.76832 + 2.86516 / +-- Critical Z-factors +ZCRIT + 0.29049 + 0.27414 + 0.28737 + 0.28465 + 0.28029 + 0.28272 + 0.27406 + 0.27052 + 0.26270 + 0.26037 + 0.31819 + 0.29064 + 0.27804 + 0.26639 + 0.26114 + 0.26456 + 0.27301 + 0.28393 + 0.29525 + 0.30721 + 0.32192 + 0.40892 / +-- Volume translation/co-volume +SSHIFT + -0.175888 + -0.045511 + -0.194020 + -0.143142 + -0.112702 + -0.099214 + -0.089659 + -0.070455 + -0.056872 + 0.012573 + 0.073720 + 0.085173 + 0.083037 + 0.082231 + 0.077598 + 0.064618 + 0.043364 + 0.018779 + -0.003316 + -0.027041 + -0.053010 + -0.100845 / +-- Parachors (dyn/cm) +PARACHOR + 41.000 + 78.000 + 77.300 + 108.900 + 151.900 + 181.500 + 191.700 + 225.000 + 233.900 + 271.000 + 272.942 + 304.298 + 339.632 + 407.069 + 482.957 + 559.054 + 645.090 + 734.682 + 817.404 + 901.299 + 1000.122 + 1473.547 / +-- Overall composition +ZI + 0.003570 + 0.010280 + 0.571653 + 0.045892 + 0.027131 + 0.005420 + 0.013881 + 0.005730 + 0.008050 + 0.011760 + 0.022521 + 0.025721 + 0.018431 + 0.045402 + 0.029981 + 0.025641 + 0.033021 + 0.026731 + 0.021591 + 0.016941 + 0.018971 + 0.011680 / +-- Binary interaction coefficients for PR +BIC + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +BICS + -0.0170 + 0.0311 0.1200 + 0.0515 0.1200 0.0000 + 0.0852 0.1200 0.0000 0.0000 + 0.1033 0.1200 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 + 0.0922 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.1000 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1200 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0800 0.1000 0.0447 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 + 0.0000 +/ +-- Viscosity correlation +PEDERSEN +-- Volume translation/co-volume at surface conditions +SSHIFTS + -0.175888 + -0.061524 + -0.194020 + -0.143142 + -0.112702 + -0.099214 + -0.089659 + -0.070455 + -0.056872 + 0.012573 + 0.056615 + 0.079972 + 0.090897 + 0.104318 + 0.108036 + 0.101240 + 0.085802 + 0.065887 + 0.046875 + 0.026036 + 0.002593 + -0.045217 / diff --git a/src/test/java/neqsim/thermodynamicOperations/ThermodynamicOperationsTest.java b/src/test/java/neqsim/thermodynamicOperations/ThermodynamicOperationsTest.java index 5ee1abe953..e39bb89528 100644 --- a/src/test/java/neqsim/thermodynamicOperations/ThermodynamicOperationsTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/ThermodynamicOperationsTest.java @@ -16,6 +16,7 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import neqsim.api.ioc.CalculationResult; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemProperties; import neqsim.thermo.system.SystemSrkEos; @@ -52,6 +53,80 @@ void testFlash() { } } + @Test + void testFluidDefined() { + double[] fractions = new double[] {98.0, 2.0}; + ListPhaseEnvelope class. Created on 27. september 2001, 10:21 Updated on May 2019 by Nefeli
- * + * * @author esol - * + * * @version $Id: $Id - * + * * @since 2.2.3 */ public class PhaseEnvelope { diff --git a/src/test/java/neqsim/util/database/AspenIP21DatabaseTest.java b/src/test/java/neqsim/util/database/AspenIP21DatabaseTest.java index c988d96630..ac1a4faa39 100644 --- a/src/test/java/neqsim/util/database/AspenIP21DatabaseTest.java +++ b/src/test/java/neqsim/util/database/AspenIP21DatabaseTest.java @@ -17,8 +17,8 @@ void testMain() { AspenIP21Database database = new AspenIP21Database(); try (ResultSet dataSet = database.getResultSet("Karsto", "....'")) { while (dataSet.next()) { - System.out.println("dataset " + dataSet.getString(4)); - System.out.println("dataset value " + dataSet.getDouble("...")); + // System.out.println("dataset " + dataSet.getString(4)); + // System.out.println("dataset value " + dataSet.getDouble("...")); } failed = false; } catch (Exception ex) { diff --git a/src/test/java/neqsim/util/database/NeqSimContractDataBaseTest.java b/src/test/java/neqsim/util/database/NeqSimContractDataBaseTest.java index 19c98804ca..041ae78ba1 100644 --- a/src/test/java/neqsim/util/database/NeqSimContractDataBaseTest.java +++ b/src/test/java/neqsim/util/database/NeqSimContractDataBaseTest.java @@ -4,12 +4,8 @@ public class NeqSimContractDataBaseTest { @Test - void testInitH2DatabaseFromCSVfiles() { - - } + void testInitH2DatabaseFromCSVfiles() {} @Test - void testUpdateTable() { - - } + void testUpdateTable() {} } diff --git a/src/test/java/neqsim/util/database/NeqSimDataBaseTest.java b/src/test/java/neqsim/util/database/NeqSimDataBaseTest.java index 03ce354d8c..3539f341f4 100644 --- a/src/test/java/neqsim/util/database/NeqSimDataBaseTest.java +++ b/src/test/java/neqsim/util/database/NeqSimDataBaseTest.java @@ -17,6 +17,16 @@ void testHasComponent() { "Could not load component methane"); } + @Test + void testReplaceTable() { + neqsim.util.database.NeqSimDataBase.replaceTable("COMP", "src/main/resources/data/COMP.csv"); + RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, + () -> neqsim.util.database.NeqSimDataBase.replaceTable("COMP", "file_does_not_exist.csv")); + Assertions.assertEquals( + "neqsim.util.exception.InvalidInputException: NeqSimDataBase:replaceTable - Input path - Resource file_does_not_exist.csv not found", + thrown.getMessage()); + } + @Test void testUpdateTable() { neqsim.util.database.NeqSimDataBase.updateTable("COMP"); @@ -40,7 +50,6 @@ void testMain() { failed = false; } catch (Exception ex) { System.out.println(ex.getMessage()); - System.out.println("DB test failed "); } // Assertions.assertTrue(testHasMethane, "Methane component found in database"); Assertions.assertEquals(16.04, molmass, 0.1); diff --git a/src/test/java/neqsim/util/database/NeqSimFluidDataBaseTest.java b/src/test/java/neqsim/util/database/NeqSimFluidDataBaseTest.java index c40fafc0fe..6d02c8c845 100644 --- a/src/test/java/neqsim/util/database/NeqSimFluidDataBaseTest.java +++ b/src/test/java/neqsim/util/database/NeqSimFluidDataBaseTest.java @@ -18,7 +18,7 @@ void testMain() { try (ResultSet dataSet = database.getResultSet("FluidDatabase", "SELECT * FROM comp where name='water'")) { dataSet.next(); - System.out.println("dataset " + dataSet.getString("molarmass")); + // System.out.println("dataset " + dataSet.getString("molarmass")); failed = false; } catch (Exception ex) { System.out.println("failed"); diff --git a/src/test/java/neqsim/util/generator/PropertyGeneratorTest.java b/src/test/java/neqsim/util/generator/PropertyGeneratorTest.java new file mode 100644 index 0000000000..94a1cd0f81 --- /dev/null +++ b/src/test/java/neqsim/util/generator/PropertyGeneratorTest.java @@ -0,0 +1,33 @@ +package neqsim.util.generator; + +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class PropertyGeneratorTest { + @Test + void testCalculate() { + SystemInterface fluid = new SystemSrkEos(273.15 + 45.0, 22.0); + fluid.addComponent("water", 0.1); + fluid.addComponent("nitrogen", 0.02); + fluid.addComponent("CO2", 0.03); + fluid.addComponent("H2S", 0.01); + fluid.addComponent("methane", 0.80); + fluid.addComponent("ethane", 0.04); + fluid.addComponent("propane", 0.03); + fluid.addComponent("i-butane", 0.02); + fluid.addComponent("n-butane", 0.01); + fluid.addComponent("i-pentane", 0.01); + fluid.addComponent("n-pentane", 0.01); + fluid.addComponent("n-hexane", 0.01); + fluid.addComponent("nC10", 0.1); + fluid.setMixingRule(2); + fluid.useVolumeCorrection(true); + fluid.setMultiPhaseCheck(true); + + double[] temps = new double[] {280.0, 290.0}; + double[] pres = new double[] {10.0, 20.0}; + PropertyGenerator generator = new PropertyGenerator(fluid, temps, pres); + generator.calculate(); + } +} diff --git a/src/test/java/neqsim/util/unit/PressureUnitTest.java b/src/test/java/neqsim/util/unit/PressureUnitTest.java new file mode 100644 index 0000000000..91b38dfef2 --- /dev/null +++ b/src/test/java/neqsim/util/unit/PressureUnitTest.java @@ -0,0 +1,50 @@ +package neqsim.util.unit; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +class PressureUnitTest extends neqsim.NeqSimTest { + /** + *+ * testSetPressure + *
+ */ + @Test + public void testSetPressure() { + neqsim.thermo.system.SystemPrEos fluid = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + fluid.addComponent("nitrogen", 1.0); + fluid.addComponent("water", 1.0); + fluid.setPressure(0.0, "barg"); + + ThermodynamicOperations testOps = new ThermodynamicOperations(fluid); + testOps.TPflash(); + fluid.initProperties(); + + assertEquals(ThermodynamicConstantsInterface.referencePressure, fluid.getPressure("bara"), + 1e-4); + assertEquals(0.0, fluid.getPressure("barg"), 1e-4); + assertEquals(1.01325, fluid.getPressure("bara"), 1e-4); + assertEquals(101325.0, fluid.getPressure("Pa"), 1e-4); + assertEquals(101.3250, fluid.getPressure("kPa"), 1e-4); + assertEquals(1.0, fluid.getPressure("atm"), 1e-4); + assertEquals(14.6959488, fluid.getPressure("psi"), 1e-4); + assertEquals(14.6959488, fluid.getPressure("psia"), 1e-4); + assertEquals(-0.0040512245077, fluid.getPressure("psig"), 1e-4); + + fluid.setPressure(11.0, "bara"); + testOps.TPflash(); + + assertEquals(11.0, fluid.getPressure(), 1e-4); + assertEquals(11.0 - 1.01325, fluid.getPressure("barg"), 1e-4); + assertEquals(11.0, fluid.getPressure("bara"), 1e-4); + assertEquals(11.0e5, fluid.getPressure("Pa"), 1e-4); + assertEquals(11e2, fluid.getPressure("kPa"), 1e-4); + assertEquals(10.856155933, fluid.getPressure("atm"), 1e-4); + assertEquals(159.54151180, fluid.getPressure("psi"), 1e-4); + assertEquals(159.54151180, fluid.getPressure("psia"), 1e-4); + assertEquals(144.841511503000, fluid.getPressure("psig"), 1e-4); + } +} + diff --git a/src/test/java/neqsim/util/unit/TemperatureUnitTest.java b/src/test/java/neqsim/util/unit/TemperatureUnitTest.java new file mode 100644 index 0000000000..c8f1b9497a --- /dev/null +++ b/src/test/java/neqsim/util/unit/TemperatureUnitTest.java @@ -0,0 +1,53 @@ +package neqsim.util.unit; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +class TemperatureUnitTest extends neqsim.NeqSimTest { + /** + *+ * testSetPressure + *
+ */ + @Test + public void testSetTemperature() { + neqsim.thermo.system.SystemPrEos fluid = new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + fluid.addComponent("nitrogen", 10.0); + fluid.addComponent("nC10", 10.0); + fluid.setPressure(0.0, "barg"); + + ThermodynamicOperations testOps = new ThermodynamicOperations(fluid); + testOps.TPflash(); + fluid.initProperties(); + + assertEquals(ThermodynamicConstantsInterface.referencePressure, fluid.getPressure("bara"), + 1e-4); + assertEquals(24.850000000000, fluid.getTemperature("C"), 1e-4); + assertEquals(76.7300000, fluid.getTemperature("F"), 1e-4); + assertEquals(536.4, fluid.getTemperature("R"), 1e-4); + + fluid.setTemperature(11.0, "F"); + testOps.TPflash(); + + assertEquals(470.67, fluid.getTemperature("R"), 1e-4); + assertEquals(-11.6666666666, fluid.getTemperature("C"), 1e-4); + assertEquals(261.483333333, fluid.getTemperature("K"), 1e-4); + + fluid.setTemperature(527.67, "R"); + testOps.TPflash(); + + assertEquals(68.0, fluid.getTemperature("F"), 1e-4); + assertEquals(20.0, fluid.getTemperature("C"), 1e-4); + assertEquals(293.15, fluid.getTemperature("K"), 1e-4); + + fluid.setTemperature(25.25, "C"); + testOps.TPflash(); + + assertEquals(77.4499999999, fluid.getTemperature("F"), 1e-4); + assertEquals(537.12, fluid.getTemperature("R"), 1e-4); + assertEquals(298.4, fluid.getTemperature("K"), 1e-4); + } +} + diff --git a/src/test/java/neqsim/util/unit/UnitsTest.java b/src/test/java/neqsim/util/unit/UnitsTest.java new file mode 100644 index 0000000000..0d321c4c2a --- /dev/null +++ b/src/test/java/neqsim/util/unit/UnitsTest.java @@ -0,0 +1,29 @@ +package neqsim.util.unit; + +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class UnitsTest { + @Test + void testActivateUnits() { + neqsim.thermo.system.SystemInterface testSystem = + new neqsim.thermo.system.SystemPrEos(298.0, 10.0); + testSystem.addComponent("nitrogen", 0.01); + testSystem.addComponent("CO2", 0.01); + testSystem.addComponent("methane", 0.68); + testSystem.addComponent("ethane", 0.1); + testSystem.setMixingRule("classic"); + neqsim.thermo.ThermodynamicModelTest testModel = + new neqsim.thermo.ThermodynamicModelTest(testSystem); + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + neqsim.util.unit.Units.activateDefaultUnits(); + testSystem.createTable("results"); + neqsim.util.unit.Units.activateFieldUnits(); + testSystem.createTable("results"); + neqsim.util.unit.Units.activateSIUnits(); + testSystem.createTable("results"); + neqsim.util.unit.Units.activateMetricUnits(); + testSystem.createTable("results"); + } +}