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]]" /> - + @@ -232,7 +229,7 @@ - + @@ -248,8 +245,8 @@ - - + + diff --git a/docs/wiki/neqsimlogocircleflatsmall.png b/docs/wiki/neqsimlogocircleflatsmall.png new file mode 100644 index 0000000000..a7bfa57b26 Binary files /dev/null and b/docs/wiki/neqsimlogocircleflatsmall.png differ diff --git a/eclipse-java-google-style.xml b/eclipse-java-google-style.xml index 2c502f8e60..844fcd7c33 100644 --- a/eclipse-java-google-style.xml +++ b/eclipse-java-google-style.xml @@ -239,7 +239,7 @@ - + diff --git a/neqsim_formatter.xml b/neqsim_formatter.xml index 7f2936f512..10320d639d 100644 --- a/neqsim_formatter.xml +++ b/neqsim_formatter.xml @@ -20,7 +20,7 @@ - + @@ -79,7 +79,7 @@ - + diff --git a/pom.xml b/pom.xml index c5a7c0911e..678b873f40 100644 --- a/pom.xml +++ b/pom.xml @@ -4,18 +4,37 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - com.equinor + com.equinor.neqsim neqsim + NeqSim + NeqSim is a library for calculation of fluid behavior, phase equilibrium and process simulation. + https://github.com/equinor/neqsim jar ${revision}${sha1}${changelist} - 2.5.5 + 2.5.35 UTF-8 UTF-8 - - + + + checkstyle_neqsim.xml + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + Even Solbraa + esolbraa@gmail.com + Equinor + https://github.com/equinor + + @@ -29,27 +48,27 @@ com.h2database h2 - 2.2.220 - - - com.thoughtworks.xstream - xstream - 1.4.20 + 2.3.232 org.apache.logging.log4j log4j-api - 2.20.0 + 2.24.0 org.apache.logging.log4j log4j-core - 2.20.0 + 2.24.0 + + + com.thoughtworks.xstream + xstream + 1.4.20 org.junit.jupiter junit-jupiter - 5.9.3 + 5.11.1 test @@ -71,7 +90,7 @@ org.ejml ejml-all - 0.43 + 0.43.1 gov.nist.math @@ -86,7 +105,7 @@ org.jfree jfreechart - 1.5.4 + 1.5.5 com.googlecode.matrix-toolkits-java @@ -96,22 +115,90 @@ org.ojalgo ojalgo - 53.0.0 + 53.3.0 provided com.google.code.gson gson - 2.9.0 - test + 2.11.0 + + + release + + + + org.sonatype.central + central-publishing-maven-plugin + 0.6.0 + true + + central + true + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.0 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.10.0 + + + attach-javadoc + + jar + + + + + none + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.6 + + + sign-artifacts + verify + + sign + + + + + + --pinentry-mode + loopback + + + + + + + org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 + 3.5.0 enforce-maven @@ -121,7 +208,7 @@ - 3.3.9 + 3.8.8 @@ -131,7 +218,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 @@ -143,7 +230,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.3.0 + 1.6.0 true @@ -167,7 +254,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.0 + 3.6.0 package @@ -180,7 +267,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 11 ${project.build.sourceEncoding} @@ -195,7 +282,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.10.0 private true @@ -211,16 +298,16 @@ maven-surefire-plugin - 3.0.0-M7 + 3.5.0 maven-failsafe-plugin - 3.0.0-M7 + 3.5.0 org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.12 neqsim/physicalProperties/util/parameterFitting/**/* @@ -253,7 +340,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -263,6 +350,14 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.5.0 + + true + + diff --git a/pomJava21.xml b/pomJava21.xml new file mode 100644 index 0000000000..16e0b26e3b --- /dev/null +++ b/pomJava21.xml @@ -0,0 +1,292 @@ + + + + 4.0.0 + com.equinor.neqsim + neqsim + NeqSim + NeqSim is a library for calculation of fluid behavior, phase equilibrium and process simulation. + https://github.com/equinor/neqsim + jar + ${revision}${sha1}${changelist} + + + 2.5.35 + UTF-8 + UTF-8 + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + Even Solbraa + esolbraa@gmail.com + Equinor + https://github.com/equinor + + + + + + central + https://repo1.maven.org/maven2/ + + + + + + + com.h2database + h2 + 2.3.232 + + + com.thoughtworks.xstream + xstream + 1.4.20 + + + org.apache.logging.log4j + log4j-api + 2.24.0 + + + org.apache.logging.log4j + log4j-core + 2.24.0 + + + org.junit.jupiter + junit-jupiter + 5.11.1 + test + + + colt + colt + 1.2.0 + provided + + + commons-lang + commons-lang + 2.6 + + + org.apache.commons + commons-math3 + 3.6.1 + + + org.ejml + ejml-all + 0.43.1 + + + gov.nist.math + jama + 1.0.3 + + + org.jfree + jcommon + 1.0.24 + + + org.jfree + jfreechart + 1.5.4 + + + com.googlecode.matrix-toolkits-java + mtj + 1.0.4 + + + org.ojalgo + ojalgo + 53.1.1 + provided + + + com.google.code.gson + gson + 2.10.1 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce-maven + + enforce + + + + + 3.8.8 + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + neqsim.thermo.util.benchmark.TPflash_benchmark + + + + + + org.codehaus.mojo + flatten-maven-plugin + 1.6.0 + + true + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.10.0 + + private + true + + + + attach-javadocs + + jar + + + + + + maven-surefire-plugin + 3.5.0 + + + maven-failsafe-plugin + 3.5.0 + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + neqsim/physicalProperties/util/parameterFitting/**/* + neqsim/statistics/util/parameterFitting/**/* + neqsim/PVTsimulation/util/parameterfitting/**/* + + + + + + prepare-agent + + + + report + prepare-package + + report + + + + generate-report-after-test + test + + report + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + + + + github + GitHub Equinor Apache Maven Packages + https://maven.pkg.github.com/Equinor/neqsim + + + diff --git a/pomJava8.xml b/pomJava8.xml index c9a93826c6..5d908014c4 100644 --- a/pomJava8.xml +++ b/pomJava8.xml @@ -6,16 +6,34 @@ 4.0.0 com.equinor.neqsim neqsim + NeqSim + NeqSim is a library for calculation of fluid behavior, phase equilibrium and process simulation. + https://github.com/equinor/neqsim jar ${revision}${sha1}${changelist}-Java8 - + - 2.5.5 + 2.5.35 UTF-8 UTF-8 + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + Even Solbraa + esolbraa@gmail.com + Equinor + https://github.com/equinor + + @@ -25,15 +43,21 @@ + + + com.h2database + h2 + 2.2.224 + org.apache.logging.log4j log4j-api - 2.20.0 + 2.23.0 org.apache.logging.log4j log4j-core - 2.20.0 + 2.23.0 com.thoughtworks.xstream @@ -43,7 +67,7 @@ org.junit.jupiter junit-jupiter - 5.9.3 + 5.11.1 test @@ -62,12 +86,6 @@ commons-math3 3.6.1 - - - com.h2database - h2 - 2.1.214 - org.ejml ejml-all @@ -86,7 +104,7 @@ org.jfree jfreechart - 1.5.3 + 1.5.4 com.googlecode.matrix-toolkits-java @@ -102,8 +120,7 @@ com.google.code.gson gson - 2.9.0 - test + 2.10.1 @@ -111,7 +128,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.1.0 + 3.5.0 enforce-maven @@ -121,7 +138,7 @@ - 3.3.9 + 3.8.8 @@ -131,7 +148,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 @@ -143,7 +160,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.3.0 + 1.6.0 true @@ -167,7 +184,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.0 + 3.6.0 package @@ -180,8 +197,9 @@ org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 + 1.8 1.8 @@ -189,7 +207,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.6.3 private true @@ -197,16 +215,16 @@ maven-surefire-plugin - 3.0.0-M7 + 3.5.0 maven-failsafe-plugin - 3.0.0-M7 + 3.5.0 org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.12 neqsim/physicalProperties/util/parameterFitting/**/* diff --git a/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java b/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java index 8b31b22c30..d501d3c3ad 100644 --- a/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java +++ b/src/main/java/neqsim/MathLib/generalMath/TDMAsolve.java @@ -15,7 +15,6 @@ * @version $Id: $Id */ public final class TDMAsolve { - /** * Dummy constructor, not for use. Class is to be considered static. */ @@ -26,11 +25,11 @@ private TDMAsolve() {} * solve. *

* - * @param a an array of {@link double} objects - * @param b an array of {@link double} objects - * @param c an array of {@link double} objects - * @param r 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 + * @param c an array of type double + * @param r an array of type double + * @return an array of type double */ public static double[] solve(double[] a, double[] b, double[] c, double[] r) { int length = a.length; diff --git a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java index 3cf5aa60e5..9f5c2d63fb 100644 --- a/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java +++ b/src/main/java/neqsim/MathLib/nonLinearSolver/NumericalDerivative.java @@ -8,6 +8,7 @@ import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.phase.PhaseInterface; +import neqsim.thermo.phase.PhaseType; /** *

@@ -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 field experimentalData. *

* - * @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. *

* * @param temperature the temperature to set @@ -129,6 +130,13 @@ public void setTemperature(double temperature) { this.temperature = temperature; } + /** {@inheritDoc} */ + @Override + public void setTemperature(double temperature, String temperatureUnit) { + this.temperature = temperature; + this.temperatureUnit = temperatureUnit; + } + /** *

* Getter for the field pressures. @@ -169,7 +177,9 @@ public double getZsaturation() { } /** - *

Getter for the field saturationTemperature.

+ *

+ * Getter for the field saturationTemperature. + *

* * @return the saturationTemperature */ diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java index 1d8a3df4fa..80744fb9db 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantMassExpansion.java @@ -7,6 +7,7 @@ import neqsim.statistics.parameterFitting.SampleSet; import neqsim.statistics.parameterFitting.SampleValue; import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardt; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -86,6 +87,13 @@ public void calcSaturationConditions() { saturationPressure = getThermoSystem().getPressure(); Zsaturation = getThermoSystem().getZ(); saturationConditionFound = true; + + getThermoSystem().initPhysicalProperties(); + saturationVolume = getThermoSystem().getPhase(0).getMass() + / getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + saturationPressure = getThermoSystem().getPressure(); + Zsaturation = getThermoSystem().getZ(); + saturationConditionFound = true; } /** {@inheritDoc} */ @@ -115,7 +123,9 @@ public void runCalc() { viscosity = new double[pressures.length]; viscosityOil = new double[pressures.length]; gasExpensionFactor = new double[pressures.length]; - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } if (!saturationConditionFound) { calcSaturationConditions(); try { @@ -151,9 +161,10 @@ public void runCalc() { density[i] = getThermoSystem().getPhase(0).getDensity("kg/m3"); gasVolume[i] = getThermoSystem().getPhase(0).getNumberOfMolesInPhase() * getThermoSystem().getPhase(0).getMolarMass() / density[i]; // getThermoSystem().getPhase(0).getVolume(); - gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() - * getThermoSystem().getPhase(0).getPressure() / 1.01325 - / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); + gasStandardVolume[i] = + getThermoSystem().getPhase(0).getVolume() * getThermoSystem().getPhase(0).getPressure() + / ThermodynamicConstantsInterface.referencePressure + / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); Bg[i] = gasVolume[i] * 1e5 / gasStandardVolume[i]; Zgas[i] = getThermoSystem().getPhase(0).getZ(); if (getThermoSystem().getNumberOfPhases() == 1) { @@ -171,13 +182,13 @@ public void runCalc() { viscosity[i] = Double.NaN; isoThermalCompressibility[i] = Double.NaN; } - System.out.println("pressure " + getThermoSystem().getPressure() + " relative volume " - + relativeVolume[i] + " liquid rel vol " + liquidRelativeVolume[i] + " Zgas " + Zgas[i] - + " Yfactor " + getYfactor()[i] + " isoCompfactor " + getIsoThermalCompressibility()[i]); + // System.out.println("pressure " + getThermoSystem().getPressure() + " relative volume " + // + relativeVolume[i] + " liquid rel vol " + liquidRelativeVolume[i] + " Zgas " + Zgas[i] + // + " Yfactor " + getYfactor()[i] + " isoCompfactor " + getIsoThermalCompressibility()[i]); } - System.out.println("test finished"); - System.out.println("test finished"); + // System.out.println("test finished"); + // System.out.println("test finished"); } /** @@ -385,8 +396,8 @@ public double getSaturationIsoThermalCompressibility() { * 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.pressures = pressure; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java index f33511e385..fc13d215e3 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletion.java @@ -49,8 +49,8 @@ public ConstantVolumeDepletion(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; @@ -88,9 +88,10 @@ public void calcSaturationConditions() { * try { thermoOps.dewPointPressureFlash(); } catch (Exception ex) { * logger.error(ex.getMessage(), ex); } */ - saturationVolume = getThermoSystem().getVolume(); + getThermoSystem().initPhysicalProperties("density"); + saturationVolume = getThermoSystem().getCorrectedVolume(); saturationPressure = getThermoSystem().getPressure(); - Zsaturation = getThermoSystem().getZ(); + Zsaturation = getThermoSystem().getZvolcorr(); saturationConditionFound = true; } @@ -108,9 +109,13 @@ public void runCalc() { Zgas = new double[pressures.length]; Zmix = new double[pressures.length]; liquidRelativeVolume = new double[pressures.length]; + double oldVolCorr = 0.0; + double volumeCorrection = 0.0; cummulativeMolePercDepleted = new double[pressures.length]; double totalNumberOfMoles = getThermoSystem().getTotalNumberOfMoles(); - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } for (int i = 0; i < pressures.length; i++) { getThermoSystem().setPressure(pressures[i]); @@ -119,9 +124,10 @@ public void runCalc() { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } + getThermoSystem().initPhysicalProperties("density"); // getThermoSystem().display(); - totalVolume[i] = getThermoSystem().getVolume(); - System.out.println("volume " + totalVolume[i]); + totalVolume[i] = getThermoSystem().getCorrectedVolume(); + // System.out.println("volume " + totalVolume[i]); cummulativeMolePercDepleted[i] = 100.0 - getThermoSystem().getTotalNumberOfMoles() / totalNumberOfMoles * 100; if (getThermoSystem().getNumberOfPhases() > 1) { @@ -130,44 +136,60 @@ public void runCalc() { getThermoSystem().setPressure(pressures[i]); try { thermoOps.TPflash(); + getThermoSystem().initPhysicalProperties("density"); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } // if (totalVolume[i] > saturationVolume) { - liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); + liquidVolume[i] = getThermoSystem().getPhase(1).getCorrectedVolume(); liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; - Zgas[i] = getThermoSystem().getPhase(0).getZ(); - Zmix[i] = getThermoSystem().getZ(); - if (getThermoSystem().getNumberOfPhases() > 1) { - liquidRelativeVolume[i] = - getThermoSystem().getPhase("oil").getVolume() / saturationVolume * 100; - } - - double volumeCorrection = getThermoSystem().getVolume() - saturationVolume; - double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); + Zgas[i] = getThermoSystem().getPhase(0).getZvolcorr(); + Zmix[i] = getThermoSystem().getZvolcorr(); + liquidRelativeVolume[i] = + getThermoSystem().getPhase("oil").getCorrectedVolume() / saturationVolume * 100; + oldVolCorr = volumeCorrection; + volumeCorrection = getThermoSystem().getCorrectedVolume() - saturationVolume; + double test = + (volumeCorrection - oldVolCorr) / getThermoSystem().getPhase(0).getCorrectedVolume(); + double[] change = new double[getThermoSystem().getPhase(0).getNumberOfComponents()]; + // System.out.println(test); for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { try { - double change = + change[j] = (test * getThermoSystem().getPhase(0).getComponent(j).getx() < getThermoSystem() .getPhase(0).getComponent(j).getNumberOfMolesInPhase()) ? test * getThermoSystem().getPhase(0).getComponent(j).getx() - : test * getThermoSystem().getPhase(0).getComponent(j).getx(); - getThermoSystem().addComponent(j, -change); + : 0.0; } catch (Exception e) { logger.debug(e.getMessage()); } } + getThermoSystem().init(0); + for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { + try { + getThermoSystem().addComponent(j, -change[j]); + } catch (Exception e) { + logger.debug(e.getMessage()); + } + } + // getThermoSystem().init(0); + // getThermoSystem().init(1); } } for (int i = 0; i < pressures.length; i++) { relativeVolume[i] = totalVolume[i] / saturationVolume; - System.out.println("rel volume " + relativeVolume[i]); + // System.out.println("rel volume " + relativeVolume[i]); + } + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); } - System.out.println("test finished"); + // System.out.println("test finished"); } /** @@ -188,7 +210,7 @@ public void runTuning() { SystemInterface tempSystem = getThermoSystem(); // getThermoSystem().clone(); - tempSystem.setTemperature(temperature); + tempSystem.setTemperature(temperature, temperatureUnit); tempSystem.setPressure(pressures[i]); // thermoOps.TPflash(); // tempSystem.display(); @@ -275,7 +297,7 @@ public static void main(String[] args) { tempSystem.init(1); ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(tempSystem); - CVDsim.setTemperature(315.0); + CVDsim.setTemperature(315.0, "K"); CVDsim.setPressures(new double[] {400, 300.0, 200.0, 150.0, 100.0, 50.0}); CVDsim.runCalc(); CVDsim.setTemperaturesAndPressures(new double[] {313, 313, 313, 313}, diff --git a/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java b/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java index e47c60bb56..63d9dca18f 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/DensitySim.java @@ -49,8 +49,8 @@ public DensitySim(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; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java index a37f9e50da..ce6f986c68 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/DifferentialLiberation.java @@ -2,6 +2,8 @@ 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; @@ -76,7 +78,9 @@ public void calcSaturationConditions() { * try { thermoOps.dewPointPressureFlash(); } catch (Exception ex) { * logger.error(ex.getMessage(), ex); } */ - saturationVolume = getThermoSystem().getVolume(); + getThermoSystem().initPhysicalProperties(); + saturationVolume = getThermoSystem().getPhase(0).getMass() + / getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); saturationPressure = getThermoSystem().getPressure(); saturationConditionFound = true; } @@ -89,6 +93,7 @@ public void calcSaturationConditions() { public void runCalc() { saturationConditionFound = false; relativeVolume = new double[pressures.length]; + double[] mass = new double[pressures.length]; totalVolume = new double[pressures.length]; liquidVolumeRelativeToVsat = new double[pressures.length]; liquidVolume = new double[pressures.length]; @@ -102,7 +107,9 @@ public void runCalc() { oilDensity = new double[pressures.length]; double totalGasStandardVolume = 0; - getThermoSystem().setTemperature(temperature); + if (!Double.isNaN(temperature)) { + getThermoSystem().setTemperature(temperature, temperatureUnit); + } for (int i = 0; i < pressures.length; i++) { getThermoSystem().setPressure(pressures[i]); @@ -111,9 +118,12 @@ public void runCalc() { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - totalVolume[i] = getThermoSystem().getVolume(); - liquidVolume[i] = getThermoSystem().getVolume(); + getThermoSystem().initPhysicalProperties(); + oilDensity[i] = getThermoSystem().getDensity("kg/m3"); + mass[i] = getThermoSystem().getMass("kg"); + totalVolume[i] = mass[i] / oilDensity[i]; + liquidVolume[i] = totalVolume[i]; if (getThermoSystem().getNumberOfPhases() > 1) { if (!saturationConditionFound) { calcSaturationConditions(); @@ -124,80 +134,73 @@ public void runCalc() { logger.error(ex.getMessage(), ex); } } - gasStandardVolume[i] = getThermoSystem().getPhase(0).getVolume() - * getThermoSystem().getPhase(0).getPressure() / 1.01325 + gasStandardVolume[i] = getThermoSystem().getPhase(PhaseType.GAS).getMass() + / getThermoSystem().getPhase(PhaseType.GAS).getPhysicalProperties().getDensity() + * getThermoSystem().getPhase(0).getPressure() + / ThermodynamicConstantsInterface.referencePressure / getThermoSystem().getPhase(0).getZ() * 288.15 / getThermoSystem().getTemperature(); totalGasStandardVolume += getGasStandardVolume()[i]; // if (totalVolume[i] > saturationVolume) { Zgas[i] = getThermoSystem().getPhase(0).getZ(); relGasGravity[i] = getThermoSystem().getPhase(0).getMolarMass() / 0.028; - getThermoSystem().initPhysicalProperties(); - if (getThermoSystem().hasPhaseType("gas") && getThermoSystem().hasPhaseType("oil")) { - liquidVolume[i] = getThermoSystem().getPhase(1).getVolume(); + if (getThermoSystem().hasPhaseType(PhaseType.GAS) + && getThermoSystem().hasPhaseType(PhaseType.OIL)) { oilDensity[i] = getThermoSystem().getPhase(1).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(1).getMass() / oilDensity[i]; + getThermoSystem().getPhase(1).getMass(); } else if (getThermoSystem().hasPhaseType("oil")) { - liquidVolume[i] = getThermoSystem().getPhase(0).getVolume(); oilDensity[i] = getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(0).getMass() / oilDensity[i]; } else { - liquidVolume[i] = getThermoSystem().getPhase(0).getVolume(); oilDensity[i] = getThermoSystem().getPhase(0).getPhysicalProperties().getDensity(); + liquidVolume[i] = getThermoSystem().getPhase(0).getMass() / oilDensity[i]; } if (getThermoSystem().getNumberOfPhases() > 1) { - gasVolume[i] = getThermoSystem().getPhase(0).getVolume(); - } else { - gasVolume[i] = 0.0; + gasVolume[i] = getThermoSystem().getPhase(PhaseType.GAS).getMass() + / getThermoSystem().getPhase(PhaseType.GAS).getPhysicalProperties().getDensity(); } liquidVolumeRelativeToVsat[i] = liquidVolume[i] / saturationVolume; - double volumeCorrection = - getThermoSystem().getVolume() - getThermoSystem().getPhase(1).getVolume(); - double test = volumeCorrection / getThermoSystem().getPhase(0).getMolarVolume(); - - for (int j = 0; j < getThermoSystem().getPhase(0).getNumberOfComponents(); j++) { - try { - double change = - (test * getThermoSystem().getPhase(0).getComponent(j).getx() < getThermoSystem() - .getPhase(0).getComponent(j).getNumberOfMolesInPhase()) - ? test * getThermoSystem().getPhase(0).getComponent(j).getx() - : test * getThermoSystem().getPhase(0).getComponent(j).getx(); - getThermoSystem().addComponent(j, -change); - } catch (Exception e) { - logger.debug(e.getMessage()); - } - } + getThermoSystem().removePhase(0); } } - getThermoSystem().setPressure(1.01325); + getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().setTemperature(288.15); try { thermoOps.TPflash(); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - VoilStd = getThermoSystem().getPhase(1).getVolume(); - totalGasStandardVolume += getThermoSystem().getPhase(0).getVolume(); - // getThermoSystem().display(); + getThermoSystem().initPhysicalProperties(); + VoilStd = getThermoSystem().getPhase(PhaseType.OIL).getMass() + / getThermoSystem().getPhase(PhaseType.OIL).getPhysicalProperties().getDensity(); + if (getThermoSystem().hasPhaseType(PhaseType.GAS)) { + totalGasStandardVolume += getThermoSystem().getPhase(PhaseType.GAS).getCorrectedVolume(); + } + double total = 0; for (int i = 0; i < pressures.length; i++) { relativeVolume[i] = totalVolume[i] / saturationVolume; Bo[i] = liquidVolume[i] / VoilStd; total += getGasStandardVolume()[i]; + Rs[i] = (totalGasStandardVolume - total) / VoilStd; if (Zgas[i] > 1e-10) { Bg[i] = gasVolume[i] / getGasStandardVolume()[i]; - Rs[i] = (totalGasStandardVolume - total) / VoilStd; } /* - * System.out.println("Bo " + getBo()[i] + " Bg " + getBg()[i] + " Rs " + getRs()[i] + - * " oil density " + getOilDensity()[i] + " gas gracvity " + getRelGasGravity()[i] + " Zgas " - * + getZgas()[i] + " gasstdvol " + getGasStandardVolume()[i]); + * System.out.println("pressure " + pressures[i] + " Bo " + getBo()[i] + " Bg " + getBg()[i] + + * " Rs " + getRs()[i] + " oil density " + getOilDensity()[i] + " gas gracvity " + + * getRelGasGravity()[i] + " Zgas " + getZgas()[i] + " gasstdvol " + + * getGasStandardVolume()[i]); */ } } /** + * * *

- * 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. + *

+ * + * @param temperature the temperature to set + * @param temperatureUnit the unit of temperature as string + */ + public void setTemperature(double temperature, String temperatureUnit); } diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SlimTubeSim.java b/src/main/java/neqsim/PVTsimulation/simulation/SlimTubeSim.java index 5712abf4da..a8056b34d3 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SlimTubeSim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SlimTubeSim.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; @@ -38,7 +39,7 @@ public SlimTubeSim(SystemInterface tempSystem, SystemInterface injectionGas) { public void run() { slimTubeNodeSystem = new SystemInterface[numberOfSlimTubeNodes + 1]; - getThermoSystem().setPressure(1.01325); + getThermoSystem().setPressure(ThermodynamicConstantsInterface.referencePressure); getThermoSystem().setTemperature(288.15); thermoOps.TPflash(); @@ -162,13 +163,14 @@ public void run() { * slimTubeNodeSystem[numberOfSlimTubeNodes].getNumberOfMoles()); */ slimTubeNodeSystem[numberOfSlimTubeNodes].setTemperature(288.15); - slimTubeNodeSystem[numberOfSlimTubeNodes].setPressure(1.01325); + slimTubeNodeSystem[numberOfSlimTubeNodes] + .setPressure(ThermodynamicConstantsInterface.referencePressure); slimOps1.TPflash(); /* * double totalAccumulatedVolumeAtStadardConditions = * slimTubeNodeSystem[numberOfSlimTubeNodes].getPhase(0).getVolume(); - * + * * if (slimTubeNodeSystem[numberOfSlimTubeNodes].getNumberOfPhases() > 1) { * totalAccumulatedVolumeAtStadardConditions = * slimTubeNodeSystem[numberOfSlimTubeNodes].getPhase(1).getVolume(); } @@ -183,17 +185,18 @@ public void run() { } slimTubeNodeSystem[numberOfSlimTubeNodes].setTemperature(288.15); - slimTubeNodeSystem[numberOfSlimTubeNodes].setPressure(1.01325); + slimTubeNodeSystem[numberOfSlimTubeNodes] + .setPressure(ThermodynamicConstantsInterface.referencePressure); slimOps1.TPflash(); /* * double totalAccumulatedVolumeAtStadardConditions = * slimTubeNodeSystem[numberOfSlimTubeNodes].getPhase(0).getVolume(); - * + * * if (slimTubeNodeSystem[numberOfSlimTubeNodes].getNumberOfPhases() > 1) { * totalAccumulatedVolumeAtStadardConditions = * slimTubeNodeSystem[numberOfSlimTubeNodes].getPhase(1).getVolume(); } - * + * * System.out.println("accumulated VOlume " + totalAccumulatedVolumeAtStadardConditions + * " total reference volume " + totalReferenceNodeVolumeAtStadardConditions); * System.out.println("oil recovery ratio" + totalAccumulatedVolumeAtStadardConditions / diff --git a/src/main/java/neqsim/PVTsimulation/simulation/SwellingTest.java b/src/main/java/neqsim/PVTsimulation/simulation/SwellingTest.java index 24f701d1b7..0398db0f14 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/SwellingTest.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/SwellingTest.java @@ -48,7 +48,7 @@ public void setInjectionGas(SystemInterface injectionGas) { * setCummulativeMolePercentGasInjected. *

* - * @param gasInjected an array of {@link double} objects + * @param gasInjected an array of type double */ public void setCummulativeMolePercentGasInjected(double[] gasInjected) { this.gasInjected = gasInjected; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java b/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java index d3a54dd136..571191c83f 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ViscositySim.java @@ -49,8 +49,8 @@ public ViscositySim(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; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java b/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java index 8dfafd4584..b3d5b2ad1c 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/ViscosityWaxOilSim.java @@ -53,8 +53,8 @@ public ViscosityWaxOilSim(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; diff --git a/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java b/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java index fab7282e03..f4a6e4778a 100644 --- a/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java +++ b/src/main/java/neqsim/PVTsimulation/simulation/WaxFractionSim.java @@ -52,8 +52,8 @@ public WaxFractionSim(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; diff --git a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/DensityFunction.java b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/DensityFunction.java index 55163102dd..2fe6c85640 100644 --- a/src/main/java/neqsim/PVTsimulation/util/parameterfitting/DensityFunction.java +++ b/src/main/java/neqsim/PVTsimulation/util/parameterfitting/DensityFunction.java @@ -11,31 +11,31 @@ * @version $Id: $Id */ public class DensityFunction extends LevenbergMarquardtFunction { - double molarMass = 0.0; + double molarMass = 0.0; - /** - *

- * 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 0.5) step = 0.5; return step; } diff --git a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java index 30ccb7e132..e9270e1a93 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalEquilibriaum/LinearProgrammingChemicalEquilibrium.java @@ -51,19 +51,12 @@ public class LinearProgrammingChemicalEquilibrium ChemicalReactionOperations operations; - /** - *

- * 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;i1e-10); - * + * * double temp=1.0; for(int i=1;i * * @param system a {@link neqsim.thermo.system.SystemInterface} object - * @param bVector an array of {@link double} objects + * @param bVector an array of type double * @param inertMoles a double * @param phase a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[] generateInitialEstimates(SystemInterface system, double[] bVector, double inertMoles, int phase) { diff --git a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java index b5f30f691d..7b4616a892 100644 --- a/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java +++ b/src/main/java/neqsim/chemicalReactions/chemicalReaction/ChemicalReaction.java @@ -40,20 +40,6 @@ public class ChemicalReaction extends NamedBaseClass double lnK = 0; int numberOfReactants = 0; - /** - *

- * 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. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getStocCoefs() { return this.stocCoefs; @@ -277,8 +244,8 @@ public double calcK(neqsim.thermo.system.SystemInterface system, int phaseNumb) * * @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) { @@ -409,12 +376,12 @@ public boolean reactantsContains(String[] names) { test = false; } } - if (test == false) { + if (!test) { break; } } - if (test == false) { + if (!test) { for (int j = 0; j < productNames.length; j++) { for (int i = 0; i < names.length; i++) { if (names[i].equals(productNames[j])) { @@ -424,7 +391,7 @@ public boolean reactantsContains(String[] names) { test = false; } } - if (test == false) { + if (!test) { break; } } @@ -482,6 +449,24 @@ public double[] getK() { return this.K; } + /** + *

+ * 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 e = chemicalReactionList.iterator(); @@ -279,7 +272,7 @@ public double[][] createReactionMatrix(PhaseInterface phase, ComponentInterface[ * * @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[] updateReferencePotentials(PhaseInterface phase, ComponentInterface[] components) { for (int i = 0; i < chemicalReactionList.size(); i++) { @@ -294,7 +287,7 @@ public double[] updateReferencePotentials(PhaseInterface phase, ComponentInterfa * getReactionGMatrix. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getReactionGMatrix() { return reacGMatrix; @@ -305,7 +298,7 @@ public double[][] getReactionGMatrix() { * getReactionMatrix. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getReactionMatrix() { return reacMatrix; @@ -316,7 +309,7 @@ public double[][] getReactionMatrix() { * calcReferencePotentials. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] calcReferencePotentials() { Matrix reacMatr = new Matrix(reacGMatrix); @@ -383,7 +376,7 @@ public void calcReacMatrix(PhaseInterface phase) { * Getter for the field 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 e = operations.getReactionList().getChemicalReactionList().iterator(); phase.getPhysicalProperties().calcEffectiveDiffusionCoefficients(); diff --git a/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java b/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java index d53eb7920f..7aa6ca33fb 100644 --- a/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java +++ b/src/main/java/neqsim/dataPresentation/JFreeChart/graph2b.java @@ -51,7 +51,7 @@ public graph2b() { * Constructor for graph2b. *

* - * @param points an array of {@link double} objects + * @param points an array of type double */ public graph2b(double[][] points) { String[] seriesNames = new String[points.length]; @@ -97,7 +97,7 @@ public graph2b(double[][] points) { * Constructor for graph2b. *

* - * @param points an array of {@link double} objects + * @param points an array of type double * @param seriesNames an array of {@link java.lang.String} objects * @param tit a {@link java.lang.String} object * @param xaxis a {@link java.lang.String} object @@ -139,8 +139,8 @@ public graph2b(double[][] points, String[] seriesNames, String tit, String xaxis * Constructor for graph2b. *

* - * @param xpoints an array of {@link double} objects - * @param points an array of {@link double} objects + * @param xpoints an array of type double + * @param points an array of type double * @param seriesNames an array of {@link java.lang.String} objects * @param tit a {@link java.lang.String} object * @param xaxis a {@link java.lang.String} object diff --git a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java index dac34dedda..8ffd67aedd 100644 --- a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java +++ b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java @@ -24,6 +24,8 @@ * Note that the aim of this class is to create a self-contained data source for demo purposes - it * is NOT intended to show how you should go about writing your own data sources. *

+ * + * @author Even Solbraa */ public class SampleXYDataSource { double[][] points; @@ -31,19 +33,12 @@ public class SampleXYDataSource { int[] items = new int[10]; String[] seriesName; - /** - * Default constructor. - */ - public SampleXYDataSource() { - // items=0; - } - /** *

* 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 field values. *

* - * @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 - * getFileWriter. - *

- * - * @param i a int - * @return a {@link neqsim.fluidMechanics.util.fluidMechanicsDataHandeling.FileWriterInterface} - * object - */ - public FileWriterInterface getFileWriter(int 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 field times. *

* - * @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; /** Constant referenceSystem. */ - 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 field time. * * @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 NATURAL_GAS_COMPOSITION = new HashMap<>(); @@ -36,6 +44,11 @@ public CombustionEmissionsCalculator(String name, StreamInterface stream) { super(name, "kg/hr", stream); } + /** + *

+ * 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 composition, Map emissionsFactors) { double totalEmissions = 0.0; diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java b/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java new file mode 100644 index 0000000000..cc304c9a69 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/measurementDevice/CompressorMonitor.java @@ -0,0 +1,58 @@ +package neqsim.processSimulation.measurementDevice; + +import neqsim.processSimulation.processEquipment.compressor.Compressor; + +/** + *

+ * 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. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getMethod() { + return method; + } + + /** + *

+ * Setter for the field method. + *

+ * + * @param method a {@link java.lang.String} object + */ + public void setMethod(String method) { + this.method = method; + } + + /** + *

+ * Setter for the field segment. + *

+ * + * @param segment a {@link java.lang.Double} object + */ + public void setSegment(int segment) { + this.segment = segment; + this.segmentSet = true; + } + + /** + *

+ * setFRMSConstant. + *

+ * + * @param frms a double + */ + public void setFRMSConstant(double frms) { + this.FRMSConstant = frms; + } + + /** + *

+ * Setter for the support arrangement supportArrangement. + *

+ * + * @param arrangement a {@link java.lang.String} object + */ + public void setSupportArrangement(String arrangement) { + this.supportArrangement = arrangement; + } + + /** + *

+ * Setter for the support distance . + *

+ * + * @param distance a {@link java.lang.Double} object + */ + public void setSupportDistance(Double distance) { + this.supportDistance = distance; + } +} diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/HydrateEquilibriumTemperatureAnalyser.java b/src/main/java/neqsim/processSimulation/measurementDevice/HydrateEquilibriumTemperatureAnalyser.java index 9087e214ee..1544530f6f 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/HydrateEquilibriumTemperatureAnalyser.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/HydrateEquilibriumTemperatureAnalyser.java @@ -47,14 +47,13 @@ public HydrateEquilibriumTemperatureAnalyser(String name, StreamInterface stream /** {@inheritDoc} */ @Override public void displayResult() { - try { - // System.out.println("total water production [kg/dag]" + - // stream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles() * - // stream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass()*3600*24); - // System.out.println("water in phase 1 (ppm) " + - // stream.getThermoSystem().getPhase(0).getComponent("water").getx()*1e6); - } finally { - } + /* + * try { // System.out.println("total water production [kg/dag]" + // + * stream.getThermoSystem().getPhase(0).getComponent("water").getNumberOfmoles() * // + * stream.getThermoSystem().getPhase(0).getComponent("water").getMolarMass()*3600*24); // + * System.out.println("water in phase 1 (ppm) " + // + * stream.getThermoSystem().getPhase(0).getComponent("water").getx()*1e6); } finally { } + */ } /** {@inheritDoc} */ @@ -82,7 +81,7 @@ public double getMeasuredValue(String unit) { * Getter for the field 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. *

* - * @return a double + * @return Reference pressure in bara */ public double getReferencePressure() { return referencePressure; @@ -110,7 +109,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/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. - *

- * - * @return the alkalinity - * @deprecated Replaced by {@link getAlkalinity} - */ - @Deprecated - public double getAlkanility() { - return getAlkalinity(); - } - /** *

* 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. - *

- * - * @param alkalinity the alkalinity to set - * @deprecated Replaced by {@link setAlkalinity} - */ - @Deprecated - public void setAlkanility(double alkalinity) { - setAlkalinity(alkalinity); - } } diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/Pipe.java b/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/Pipe.java index 44d1dd3310..f6e2abdcd0 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/Pipe.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/Pipe.java @@ -157,9 +157,9 @@ public void setAngle(double angle) { * @return a double */ public double getAngle(String unit) { - if (unit == "Degree") { + if (unit.equals("Degree")) { return this.angle; - } else if (unit == "Radian") { + } else if (unit.equals("Radian")) { return this.angle * pi / 180; } return this.angle; @@ -175,5 +175,4 @@ public double getAngle(String unit) { public double getArea() { return pi * Math.pow(this.internalDiameter, 2) / 4; } - } diff --git a/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/SevereSlugAnalyser.java b/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/SevereSlugAnalyser.java index 2e4a89e358..986f0e48e0 100644 --- a/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/SevereSlugAnalyser.java +++ b/src/main/java/neqsim/processSimulation/measurementDevice/simpleFlowRegime/SevereSlugAnalyser.java @@ -6,6 +6,7 @@ import org.apache.logging.log4j.Logger; import neqsim.processSimulation.measurementDevice.MeasurementDeviceBaseClass; import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -368,7 +369,7 @@ public double getSimulationTime() { * @return a double */ public double gasConst(FluidSevereSlug fluid) { - return 8.314 / fluid.getMolecularWeight() * (273.15 + temperature); + return ThermodynamicConstantsInterface.R / fluid.getMolecularWeight() * (273.15 + temperature); } // Declare the variables for resuts after creating an object Severe slug with required number of @@ -457,7 +458,6 @@ public double stratifiedHoldUp(FluidSevereSlug fluid, Pipe pipe, SevereSlugAnaly logger.debug("Could not find solution for stratified flow holdup"); } else { holdUp = (gamma - 0.5 * Math.sin(2 * gamma)) / (pi); - } return holdUp; } @@ -627,13 +627,7 @@ public String checkFlowRegime(FluidSevereSlug fluid, Pipe pipe, SevereSlugAnalys return flowPattern; } - /** - *

- * 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 designStandard = new Hashtable(); public UnitCostEstimateBaseClass costEstimate = null; + double defaultLiquidDensity = 1000.0; + double defaultLiquidViscosity = 0.001012; /** *

@@ -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. + *

+ * + * @param defaultLiqDens a double + */ + public void setDefaultLiquidDensity(double defaultLiqDens) { + this.defaultLiquidDensity = defaultLiqDens; + } + + /** + *

+ * Getter for the field defaultLiquidDensity. + *

+ * + * @return a double + */ + public double getDefaultLiquidDensity() { + return defaultLiquidDensity; + } + + /** + *

+ * Setter for the field defaultLiquidViscosity. + *

+ * + * @param defaultLiqVisc a double + */ + public void setDefaultLiquidViscosity(double defaultLiqVisc) { + this.defaultLiquidViscosity = defaultLiqVisc; + } + + /** + *

+ * Getter for the field defaultLiquidViscosity. + *

+ * + * @return a double + */ + public double getDefaultLiquidViscosity() { + return defaultLiquidViscosity; + } + /** {@inheritDoc} */ @Override public int hashCode() { diff --git a/src/main/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesign.java b/src/main/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesign.java index 54d67fd3da..04820c240a 100644 --- a/src/main/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesign.java +++ b/src/main/java/neqsim/processSimulation/mechanicalDesign/SystemMechanicalDesign.java @@ -36,6 +36,13 @@ public SystemMechanicalDesign(ProcessSystem processSystem) { this.processSystem = processSystem; } + /** + *

+ * 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. *

- **/ - default void initMechanicalDesign() { - - } + */ + default void initMechanicalDesign() {} /** *

@@ -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. *

* * @return a double @@ -147,7 +144,7 @@ public default SystemInterface getFluid() { /** *

- * getPressure. + * Getter for the field pressure converted to specified unit. *

* * @param unit a {@link java.lang.String} object @@ -157,7 +154,7 @@ public default SystemInterface getFluid() { /** *

- * setPressure. + * Setter for the field pressure. *

* * @param pressure a double @@ -216,4 +213,23 @@ public default SystemInterface getFluid() { /** {@inheritDoc} */ @Override public int hashCode(); + + /** + *

+ * 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. *

* - * @return a int + * @return a double */ - public int getSpeed() { + public double getSpeed() { return speed; } @@ -996,7 +1016,7 @@ public int getSpeed() { * * @param speed a int */ - public void setSpeed(int speed) { + public void setSpeed(double speed) { this.speed = speed; } @@ -1254,6 +1274,29 @@ public void setPropertyProfile(CompressorPropertyProfile propertyProfile) { this.propertyProfile = propertyProfile; } + /** + *

+ * 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. + *

+ * + * @param compRatio a double + */ + public void setCompressionRatio(double compRatio) { + this.compressionRatio = compRatio; + useCompressionRatio = true; + } + + /** + *

+ * Getter for the field compressionRatio. + *

+ * + * @return a double + */ + public double getCompressionRatio() { + return compressionRatio; + } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new CompressorResponse(this)); + } + + public double getMaxOutletPressure() { + return maxOutletPressure; + } + + public void setMaxOutletPressure(double maxOutletPressure) { + this.maxOutletPressure = maxOutletPressure; + this.isSetMaxOutletPressure = true; + } + + public boolean isSetMaxOutletPressure() { + return isSetMaxOutletPressure; + } + + public void setIsSetMaxOutletPressure(boolean isSetMaxOutletPressure) { + this.isSetMaxOutletPressure = isSetMaxOutletPressure; + } + + public double getActualCompressionRatio() { + return actualCompressionRatio; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java index 9aea592a78..fd48aba400 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java @@ -162,13 +162,39 @@ public int getSpeed(double flow, double head) { return (int) Math.round(newspeed); } + /** {@inheritDoc} */ + @Override + public double getFlow(double head, double speed, double guessFlow) { + int iter = 1; + double error = 1.0; + double derrordspeed = 1.0; + double newflow = guessFlow; + double newhead = 0.0; + double oldflow = newflow * 1.1; + double oldhead = getPolytropicHead(oldflow, speed); + double olderror = oldhead - head; + do { + iter++; + newhead = + getPolytropicHead(newflow, speed) / (getPolytropicEfficiency(newflow, speed) / 100.0); + error = newhead - head; + derrordspeed = (error - olderror) / (newflow - oldflow); + newflow -= error / derrordspeed; + // System.out.println("newflow " + newflow); + } while (Math.abs(error) > 1e-6 && iter < 100); + + // change speed to minimize + // Math.abs(head - reducedHeadFitterFunc.value(flow / speed) * speed * speed); + return newflow; + } + /** *

* 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.

+ * + * @return a double + */ public double getMaxSpeedCurve() { return maxSpeedCurve; } + /** + *

Setter for the field maxSpeedCurve.

+ * + * @param maxSpeedCurve a double + */ public void setMaxSpeedCurve(double maxSpeedCurve) { this.maxSpeedCurve = maxSpeedCurve; } + /** + *

Getter for the field minSpeedCurve.

+ * + * @return a double + */ public double getMinSpeedCurve() { return minSpeedCurve; } + /** + *

Setter for the field minSpeedCurve.

+ * + * @param minSpeedCurve a double + */ public void setMinSpeedCurve(double minSpeedCurve) { this.minSpeedCurve = minSpeedCurve; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java index 04f0df49d9..f4c47b52bb 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartAlternativeMapLookup.java @@ -168,8 +168,8 @@ public double getPolytropicEfficiency(double flow, double speed) { * 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); @@ -428,7 +428,7 @@ public static void main(String[] args) { * double[] surgeflow = new double[] { 453.2, 550.0, 700.0, 800.0 }; double[] surgehead = new * double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; * comp1.getCompressorChart().getSurgeCurve().setCurve(chartConditions, surgeflow, surgehead); - * + * * double[] stoneWallflow = new double[] { 923.2, 950.0, 980.0, 1000.0 }; double[] stoneWallHead * = new double[] { 6000.0, 7000.0, 8000.0, 10000.0 }; * comp1.getCompressorChart().getStoneWallCurve().setCurve(chartConditions, stoneWallflow, @@ -541,4 +541,10 @@ public static int bisect_left(Double[] A, double x, int lo, int hi) { /** {@inheritDoc} */ @Override public void plot() {} + + /** {@inheritDoc} */ + @Override + public double getFlow(double head, double speed, double guessFlow) { + return 0.0; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java index 4a58c6fef4..d1b18144d3 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChartGenerator.java @@ -2,54 +2,71 @@ /** * Compressor chart generator. + * + * @author Even Solbraa */ public class CompressorChartGenerator { - Compressor compressor = null; + /** + *

+ * 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. + *

+ * + * @param isTotalCondenser a boolean + */ public void setTotalCondenser(boolean isTotalCondenser) { this.totalCondenser = isTotalCondenser; } @@ -72,13 +79,8 @@ public double getDuty() { return duty; } - /** - *

- * 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. - *

- * - * @return a boolean - */ + /** {@inheritDoc} */ + @Override public boolean solved() { return (err < 1e-4); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java index 721e369c67..91c30f713f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/distillation/SimpleTray.java @@ -3,7 +3,6 @@ import java.util.UUID; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import neqsim.processSimulation.processEquipment.mixer.Mixer; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java b/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java index 70bda3599f..66b91ee736 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/expander/Expander.java @@ -16,29 +16,6 @@ public class Expander extends Compressor implements ExpanderInterface { private static final long serialVersionUID = 1000; - /** - *

- * 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. + *

+ * + * @param guessOutTemperature a double + */ + public void setGuessOutTemperature(double guessOutTemperature, String unit) { + this.guessOutTemperature = guessOutTemperature; + this.guessOutTemperatureUnit = unit; } /** {@inheritDoc} */ @@ -551,7 +624,9 @@ public void setThermalEffectiveness(double thermalEffectiveness) { } /** - *

Getter for the field flowArrangement.

+ *

+ * Getter for the field flowArrangement. + *

* * @return String */ @@ -560,7 +635,9 @@ public String getFlowArrangement() { } /** - *

Setter for the field flowArrangement.

+ *

+ * Setter for the field flowArrangement. + *

* * @param flowArrangement name of flow arrangement */ @@ -617,4 +694,26 @@ public double getHotColdDutyBalance() { public void setHotColdDutyBalance(double hotColdDutyBalance) { this.hotColdDutyBalance = hotColdDutyBalance; } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().serializeSpecialFloatingPointValues().create() + .toJson(new HXResponse(this)); + } + + public void setUseDeltaT(boolean useDeltaT) { + this.useDeltaT = useDeltaT; + } + + private double deltaT = 1.0; + + public double getDeltaT() { + return deltaT; + } + + public void setDeltaT(double deltaT) { + useDeltaT = true; + this.deltaT = deltaT; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java index b2eb357720..de9f5abb4f 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/heatExchanger/Heater.java @@ -7,10 +7,11 @@ package neqsim.processSimulation.processEquipment.heatExchanger; import java.util.UUID; - +import com.google.gson.GsonBuilder; import neqsim.processSimulation.processEquipment.TwoPortEquipment; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.HeaterResponse; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -44,29 +45,6 @@ public class Heater extends TwoPortEquipment implements HeaterInterface { protected double lastDuty = 0.0; protected double lastPressureDrop = 0.0; - /** - *

- * 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 pressureProfile; @@ -127,32 +136,14 @@ public class PipeBeggsAndBrills extends Pipeline { private List mixtureViscosityProfile; private List mixtureDensityProfile; + private List liquidDensityProfile; + private List liquidHoldupProfile; private List mixtureReynoldsNumber; private List lengthProfile; private List elevationProfile; - - /** - *

- * Constructor for PipeBeggsAndBrills. - *

- */ - @Deprecated - public PipeBeggsAndBrills() {} - - /** - *

- * Constructor for PipeBeggsAndBrills. - *

- * - * @param inStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public PipeBeggsAndBrills(StreamInterface inStream) { - this("PipeBeggsAndBrills", inStream); - } + private List incrementsProfile; /** * Constructor for PipeBeggsAndBrills. @@ -178,12 +169,30 @@ public PipeBeggsAndBrills(String name, StreamInterface inStream) { * Setter for the field pipeSpecification. *

* - * @param nominalDiameter a double + * @param nominalDiameter a double in inch * @param pipeSec a {@link java.lang.String} object */ public void setPipeSpecification(double nominalDiameter, String pipeSec) { - pipeSpecification = pipeSec; - insideDiameter = nominalDiameter / 1000.0; + this.pipeSpecification = pipeSec; + this.nominalDiameter = nominalDiameter; + this.PipeSpecSet = true; + + neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = + database.getResultSet("SELECT * FROM pipedata where Size='" + nominalDiameter + "'"); + try { + if (dataSet.next()) { + this.pipeThickness = Double.parseDouble(dataSet.getString(pipeSpecification)) / 1000; + this.insideDiameter = + (Double.parseDouble(dataSet.getString("OD"))) / 1000 - 2 * this.pipeThickness; + } + } catch (NumberFormatException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } /** {@inheritDoc} */ @@ -203,7 +212,6 @@ public void setElevation(double elevation) { this.totalElevation = elevation; } - /** *

* 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. + *

+ * * @return angle in degrees */ public double getAngle() { return angle; } - /** - * @return total length of the pipe in m + *

+ * Getter for the field length. + *

+ * + * @return total length of the pipe in m */ public double getLength() { return cumulativeLength; } - /** - * @return total elevation of the pipe in m + /** + *

+ * Getter for the field elevation. + *

+ * + * @return total elevation of the pipe in m */ public double getElevation() { return cumulativeElevation; } - - /** *

* 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 PressureProfile. @@ -812,8 +906,6 @@ public List getPressureProfile() { return new ArrayList<>(pressureProfile); } - - /** *

* getSegmentPressure @@ -823,280 +915,370 @@ public List getPressureProfile() { * @return segment pressure as double */ public Double getSegmentPressure(int index) { - if (index >= 1 && index < pressureProfile.size() + 1) { - return pressureProfile.get(index - 1); + if (index >= 0 && index < pressureProfile.size()) { + return pressureProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - /** - * - * @return list of results - * + * Get Pressure + * + * @return ArrayList of pressure drop profile */ public List getPressureDropProfile() { return new ArrayList<>(pressureDropProfile); } - /** + *

+ * getSegmentPressureDrop. + *

+ * * @param index segment number * @return Double */ public Double getSegmentPressureDrop(int index) { - if (index >= 1 && index < pressureDropProfile.size() + 1) { - return pressureDropProfile.get(index - 1); + if (index >= 0 && index < pressureDropProfile.size()) { + return pressureDropProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - /** + *

+ * Getter for the field temperatureProfile. + *

+ * * @return list of temperatures */ public List getTemperatureProfile() { return new ArrayList<>(temperatureProfile); } - /** + *

+ * getSegmentTemperature. + *

+ * * @param index segment number * @return Double */ public Double getSegmentTemperature(int index) { - if (index >= 1 && index < temperatureProfile.size() + 1) { - return temperatureProfile.get(index - 1); + if (index >= 0 && index < temperatureProfile.size()) { + return temperatureProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - /** + *

+ * Getter for the field flowRegimeProfile. + *

+ * * @return list of flow regime names */ public List getFlowRegimeProfile() { return new ArrayList<>(flowRegimeProfile); } - /** + *

+ * getSegmentFlowRegime. + *

+ * * @param index segment number * @return String */ public String getSegmentFlowRegime(int index) { - if (index >= 1 && index < flowRegimeProfile.size() + 1) { - return flowRegimeProfile.get(index - 1); + if (index >= 0 && index < flowRegimeProfile.size()) { + return flowRegimeProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * Getter for the field liquidSuperficialVelocityProfile. + *

+ * * @return list of liquid superficial velocity profile */ public List getLiquidSuperficialVelocityProfile() { return new ArrayList<>(liquidSuperficialVelocityProfile); } - - /** + *

+ * Getter for the field gasSuperficialVelocityProfile. + *

+ * * @return list of gas superficial velocities */ public List getGasSuperficialVelocityProfile() { return new ArrayList<>(gasSuperficialVelocityProfile); } - /** + *

+ * Getter for the field mixtureSuperficialVelocityProfile. + *

+ * * @return list of mixture superficial velocity profile */ public List getMixtureSuperficialVelocityProfile() { return new ArrayList<>(mixtureSuperficialVelocityProfile); } - - /** + *

+ * Getter for the field mixtureViscosityProfile. + *

+ * * @return list of mixture viscosity */ public List getMixtureViscosityProfile() { return new ArrayList<>(mixtureViscosityProfile); } - - /** + *

+ * Getter for the field mixtureDensityProfile. + *

+ * * @return list of density profile */ public List getMixtureDensityProfile() { return new ArrayList<>(mixtureDensityProfile); } - + /** + *

+ * Getter for the field liquidDensityProfile. + *

+ * + * @return a {@link java.util.List} object + */ + public List getLiquidDensityProfile() { + return new ArrayList<>(liquidDensityProfile); + } /** + *

+ * Getter for the field liquidHoldupProfile. + *

+ * * @return list of hold-up */ public List getLiquidHoldupProfile() { return new ArrayList<>(liquidHoldupProfile); } - - /** + *

+ * Getter for the field mixtureReynoldsNumber. + *

+ * * @return list of reynold numbers */ public List getMixtureReynoldsNumber() { return new ArrayList<>(mixtureReynoldsNumber); } - - /** + *

+ * Getter for the field lengthProfile. + *

+ * * @return list of length profile */ public List getLengthProfile() { return new ArrayList<>(lengthProfile); } - + /** + *

+ * Getter for the field incrementsProfile. + *

+ * + * @return list of increments profile + */ + public List getIncrementsProfile() { + return new ArrayList<>(incrementsProfile); + } /** + *

+ * Getter for the field elevationProfile. + *

+ * * @return list of elevation profile */ public List getElevationProfile() { return new ArrayList<>(elevationProfile); } - - /** + *

+ * getSegmentLiquidSuperficialVelocity. + *

+ * * @param index segment number * @return Double */ public Double getSegmentLiquidSuperficialVelocity(int index) { - if (index >= 1 && index <= liquidSuperficialVelocityProfile.size()) { - return liquidSuperficialVelocityProfile.get(index - 1); + if (index >= 0 && index <= liquidSuperficialVelocityProfile.size()) { + return liquidSuperficialVelocityProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentGasSuperficialVelocity. + *

+ * * @param index segment number * @return Double */ public Double getSegmentGasSuperficialVelocity(int index) { - if (index >= 1 && index <= gasSuperficialVelocityProfile.size()) { - return gasSuperficialVelocityProfile.get(index - 1); + if (index >= 0 && index <= gasSuperficialVelocityProfile.size()) { + return gasSuperficialVelocityProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentMixtureSuperficialVelocity. + *

+ * * @param index segment number * @return Double */ public Double getSegmentMixtureSuperficialVelocity(int index) { - if (index >= 1 && index <= mixtureSuperficialVelocityProfile.size()) { - return mixtureSuperficialVelocityProfile.get(index - 1); + if (index >= 0 && index <= mixtureSuperficialVelocityProfile.size()) { + return mixtureSuperficialVelocityProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - /** + *

+ * getSegmentMixtureViscosity. + *

+ * * @param index segment number * @return Double */ public Double getSegmentMixtureViscosity(int index) { - if (index >= 1 && index <= mixtureViscosityProfile.size()) { - return mixtureViscosityProfile.get(index - 1); + if (index >= 0 && index <= mixtureViscosityProfile.size()) { + return mixtureViscosityProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentMixtureDensity. + *

+ * * @param index segment number * @return Double */ public Double getSegmentMixtureDensity(int index) { - if (index >= 1 && index <= mixtureDensityProfile.size()) { - return mixtureDensityProfile.get(index - 1); + if (index >= 0 && index <= mixtureDensityProfile.size()) { + return mixtureDensityProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } + /** + *

+ * getSegmentLiquidDensity. + *

+ * + * @param index segment number + * @return Double + */ + public Double getSegmentLiquidDensity(int index) { + if (index >= 0 && index <= liquidDensityProfile.size()) { + return liquidDensityProfile.get(index); + } else { + throw new IndexOutOfBoundsException("Index is out of bounds."); + } + } /** + *

+ * getSegmentLiquidHoldup. + *

+ * * @param index segment number * @return Double */ public Double getSegmentLiquidHoldup(int index) { - if (index >= 1 && index <= liquidHoldupProfile.size()) { - return liquidHoldupProfile.get(index - 1); + if (index >= 0 && index <= liquidHoldupProfile.size()) { + return liquidHoldupProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentMixtureReynoldsNumber. + *

+ * * @param index segment number * @return Double */ public Double getSegmentMixtureReynoldsNumber(int index) { - if (index >= 1 && index <= mixtureReynoldsNumber.size()) { - return mixtureReynoldsNumber.get(index - 1); + if (index >= 0 && index <= mixtureReynoldsNumber.size()) { + return mixtureReynoldsNumber.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentLength. + *

+ * * @param index segment number * @return Double */ public Double getSegmentLength(int index) { - if (index >= 1 && index <= lengthProfile.size()) { - return lengthProfile.get(index - 1); + if (index >= 0 && index <= lengthProfile.size()) { + return lengthProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - - /** + *

+ * getSegmentElevation. + *

+ * * @param index segment number * @return Double */ public Double getSegmentElevation(int index) { - if (index >= 1 && index <= elevationProfile.size()) { - return elevationProfile.get(index - 1); + if (index >= 0 && index <= elevationProfile.size()) { + return elevationProfile.get(index); } else { throw new IndexOutOfBoundsException("Index is out of bounds."); } } - } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java index ab499bcf08..5072ae3ee8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeLineInterface.java @@ -33,7 +33,7 @@ public interface PipeLineInterface extends SimulationInterface, TwoPortInterface * setHeightProfile. *

* - * @param heights an array of {@link double} objects + * @param heights an array of type double */ public void setHeightProfile(double[] heights); @@ -42,7 +42,7 @@ public interface PipeLineInterface extends SimulationInterface, TwoPortInterface * setLegPositions. *

* - * @param positions an array of {@link double} objects + * @param positions an array of type double */ public void setLegPositions(double[] positions); @@ -51,7 +51,7 @@ public interface PipeLineInterface extends SimulationInterface, TwoPortInterface * setPipeDiameters. *

* - * @param diameter an array of {@link double} objects + * @param diameter an array of type double */ public void setPipeDiameters(double[] diameter); @@ -60,7 +60,7 @@ public interface PipeLineInterface extends SimulationInterface, TwoPortInterface * setPipeWallRoughness. *

* - * @param rough an array of {@link double} objects + * @param rough an array of type double */ public void setPipeWallRoughness(double[] rough); @@ -69,7 +69,7 @@ public interface PipeLineInterface extends SimulationInterface, TwoPortInterface * setOuterTemperatures. *

* - * @param outerTemp an array of {@link double} objects + * @param outerTemp an array of type double */ public void setOuterTemperatures(double[] outerTemp); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java index 47152a99d4..7b63f0ec59 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/Pipeline.java @@ -48,29 +48,6 @@ public class Pipeline extends TwoPortEquipment implements PipeLineInterface { PipelineMechanicalDesign pipelineMechanicalDesign = null; - /** - *

- * 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. *

*/ + @Override public void setInletStream(StreamInterface inletStream) { this.inStream = inletStream; try { @@ -146,7 +128,7 @@ public void setInletStream(StreamInterface inletStream) { public void run(UUID id) { thermoSystem = inStream.getThermoSystem().clone(); airStream.setFlowRate(thermoSystem.getFlowRate("mole/sec") * airGasRatio, "mole/sec"); - airStream.setPressure(1.01325); + airStream.setPressure(ThermodynamicConstantsInterface.referencePressure); airStream.run(id); airCompressor.setInletStream(airStream); @@ -181,7 +163,7 @@ public void run(UUID id) { locHeater.displayResult(); Expander expander = new Expander("expander", locHeater.getOutletStream()); - expander.setOutletPressure(1.01325); + expander.setOutletPressure(ThermodynamicConstantsInterface.referencePressure); expander.run(id); Cooler cooler1 = new Cooler("cooler1", expander.getOutletStream()); @@ -196,12 +178,11 @@ public void run(UUID id) { } /** - * - * *

- * 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. + *

+ * + * @param pressure a double + * @param unit a {@link java.lang.String} object + */ + public void setOutletPressure(double pressure, String unit) { + setOutletPressure(pressure); + pressureUnit = unit; + } + /** *

* 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() { *

* * @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 PumpCurve(double speed, double[] flow, double[] head, double[] efficiency) { this.speed = speed; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirCVDsim.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirCVDsim.java new file mode 100644 index 0000000000..73a73c2284 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/ReservoirCVDsim.java @@ -0,0 +1,33 @@ +package neqsim.processSimulation.processEquipment.reservoir; + +import java.util.UUID; +import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; +import neqsim.thermo.system.SystemInterface; + +/** + *

+ * 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. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getOutStream() { + return outStream; + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param reservoirPressure a double + * @param pUnit a {@link java.lang.String} object + */ + public void setPressure(double reservoirPressure, String pUnit) { + this.pressure = reservoirPressure; + this.pUnit = pUnit; + } + + /** + *

+ * Setter for the field temperature. + *

+ * + * @param reservoirTemperature a double + * @param tUnit a {@link java.lang.String} object + */ + public void setTemperature(double reservoirTemperature, String tUnit) { + this.temperature = reservoirTemperature; + this.tUnit = tUnit; + } + + /** + *

+ * Getter for the field prodPhaseName. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getProdPhaseName() { + return prodPhaseName; + } + + /** + *

+ * Setter for the field prodPhaseName. + *

+ * + * @param prodPhaseName a {@link java.lang.String} object + */ + public void setProdPhaseName(String prodPhaseName) { + this.prodPhaseName = prodPhaseName; + } + + /** + *

+ * Setter for the field flowRate. + *

+ * + * @param flowRate a double + * @param flowUnit a {@link java.lang.String} object + */ + public void setFlowRate(double flowRate, String flowUnit) { + this.flowRate = flowRate; + this.flowUnit = flowUnit; + } +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java index 66048d4bb9..dc431023a7 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/SimpleReservoir.java @@ -12,8 +12,10 @@ import neqsim.processSimulation.processEquipment.pipeline.AdiabaticTwoPhasePipe; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; +import neqsim.util.unit.PressureUnit; /** *

@@ -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. *

* + * @param value a double + * @param unit a {@link java.lang.String} object + */ + public void setLowPressureLimit(double value, String unit) { + PressureUnit conver = new PressureUnit(value, unit); + lowPressureLimit = conver.getValue("bara"); + } + + /** + *

+ * Getter for the field lowPressureLimit. + *

+ * + * @param unit a {@link java.lang.String} object * @return a double */ - public double getTime() { - return time; + public double getLowPressureLimit(String unit) { + PressureUnit conver = new PressureUnit(lowPressureLimit, "bara"); + return conver.getValue(unit); } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/Well.java b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/Well.java index a1fadae858..8ed55e513a 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/reservoir/Well.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/reservoir/Well.java @@ -1,6 +1,7 @@ package neqsim.processSimulation.processEquipment.reservoir; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; import neqsim.util.NamedBaseClass; @@ -17,19 +18,9 @@ public class Well extends NamedBaseClass { private static final long serialVersionUID = 1000; private StreamInterface stream = null; - double x, y, z; - - /** - *

- * 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. + *

+ * + * @return a double + */ + public double getWellProductionIndex() { + return wellProductionIndex; + } + + /** + *

+ * Setter for the field wellProductionIndex. + *

+ * + * @param wellProductionIndex a double + */ + public void setWellProductionIndex(double wellProductionIndex) { + useWellProductionIndex = true; + this.wellProductionIndex = wellProductionIndex; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java index dccb4095b5..7350824107 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubber.java @@ -6,13 +6,8 @@ package neqsim.processSimulation.processEquipment.separator; -import java.util.ArrayList; -import java.util.UUID; import neqsim.processSimulation.mechanicalDesign.separator.GasScrubberMechanicalDesign; -import neqsim.processSimulation.processEquipment.separator.sectionType.SeparatorSection; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; -import neqsim.thermo.system.SystemInterface; /** *

@@ -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 scrubberSection = null; - StreamInterface inletStream; - StreamInterface gasOutStream; - StreamInterface liquidOutStream; - - /** - *

- * Constructor for GasScrubber. - *

- */ - @Deprecated - public GasScrubber() { - this("GasScrubber"); - } - - /** - *

- * Constructor for GasScrubber. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public GasScrubber(StreamInterface inletStream) { - this("GasScrubber", inletStream); - } - /** * Constructor for GasScrubber. * @@ -82,88 +43,9 @@ public GasScrubber(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); } - - /** - * {@inheritDoc} - * - *

- * Setter for the field inletStream. - *

- */ - public void setInletStream(StreamInterface inletStream) { - this.inletStream = inletStream; - - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasOutStream = new Stream("gasOutStream", gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidOutStream = new Stream("liquidOutStream", liquidSystem); - } - - /** - *

- * addScrubberSection. - *

- * - * @param type a {@link java.lang.String} object - */ - public void addScrubberSection(String type) { - scrubberSection.add(new SeparatorSection("section" + scrubberSection.size() + 1, type, this)); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquidOutStream() { - return liquidOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGasOutStream() { - return gasOutStream; - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getGas() { - return getGasOutStream(); - } - - /** {@inheritDoc} */ - @Override - public StreamInterface getLiquid() { - return getLiquidOutStream(); - } - - /** {@inheritDoc} */ - @Override - public void run(UUID id) { - thermoSystem = inletStream.getThermoSystem().clone(); - gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]); - gasSystem.setNumberOfPhases(1); - gasOutStream.setThermoSystem(gasSystem); - - thermoSystem = inletStream.getThermoSystem().clone(); - liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]); - liquidSystem.setNumberOfPhases(1); - liquidOutStream.setThermoSystem(liquidSystem); - setCalculationIdentifier(id); - } - - /** {@inheritDoc} */ - @Override - public void displayResult() {} } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java index efd0ff4b2e..b831d2681e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/GasScrubberSimple.java @@ -33,28 +33,6 @@ public class GasScrubberSimple extends Separator { StreamInterface gasOutStream; StreamInterface liquidOutStream; - /** - *

- * Constructor for GasScrubberSimple. - *

- */ - @Deprecated - public GasScrubberSimple() { - this("GasScrubberSimple"); - } - - /** - *

- * Constructor for GasScrubberSimple. - *

- * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.Stream} object - */ - @Deprecated - public GasScrubberSimple(StreamInterface inletStream) { - this("GasScrubberSimple", inletStream); - } - /** * Constructor for GasScrubberSimple. * @@ -78,13 +56,7 @@ public GasScrubberSimple(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); @@ -97,6 +69,7 @@ public GasScrubberMechanicalDesign getMechanicalDesign() { * Setter for the field inletStream. *

*/ + @Override public void setInletStream(StreamInterface inletStream) { this.inletStream = inletStream; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java index d28e29a291..8795337294 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Hydrocyclone.java @@ -24,29 +24,6 @@ public class Hydrocyclone extends Separator { double oilInAqueous = 100e-6; StreamInterface waterOutStream = new Stream("waterOutStream", waterSystem); - /** - *

- * 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 scrubberSection = null; - /** - *

- * 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 field inletStream. *

*/ + @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 separatorSection = new ArrayList(); SeparatorMechanicalDesign separatorMechanicalDesign; - /** - * Constructor for Separator. - */ - @Deprecated - public Separator() { - super("Separator"); - setCalculateSteadyState(false); - } - - /** - * Constructor for Separator. - * - * @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - @Deprecated - public Separator(StreamInterface inletStream) { - this("Separator", inletStream); - } - /** * Constructor for Separator. * @@ -97,6 +80,7 @@ public Separator(StreamInterface inletStream) { */ public Separator(String name) { super(name); + setCalculateSteadyState(false); } /** @@ -112,17 +96,13 @@ public Separator(String name, StreamInterface inletStream) { numberOfInputStreams++; } - /** - * {@inheritDoc} - * - * @return a {@link neqsim.processSimulation.mechanicalDesign.separator.SeparatorMechanicalDesign} - * object - */ + /** {@inheritDoc} */ @Override public SeparatorMechanicalDesign getMechanicalDesign() { return separatorMechanicalDesign; } + /** {@inheritDoc} */ @Override public void initMechanicalDesign() { separatorMechanicalDesign = new SeparatorMechanicalDesign(this); @@ -241,50 +221,56 @@ public void run(UUID id) { if (thermoSystem2.hasPhaseType("aqueous") || thermoSystem2.hasPhaseType("oil")) { liquidOutStream.run(id); } else { - liquidOutStream.getFluid().init(3); + try { + liquidOutStream.getFluid().init(3); + } catch (Exception e) { + logger.error(e.getMessage()); + } } - // liquidOutStream.setThermoSystemFromPhase(thermoSystem2, "aqueous"); - try { - thermoSystem = thermoSystem2.clone(); - thermoSystem.setTotalNumberOfMoles(1.0e-10); - thermoSystem.init(1); - // System.out.println("number of phases " + thermoSystem.getNumberOfPhases()); - double totalliquidVolume = 0.0; - for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { - double relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - if (j >= 1) { - relFact = liquidVolume / (thermoSystem2.getPhase(j).getVolume() * 1.0e-5); - - totalliquidVolume += liquidVolume / thermoSystem2.getPhase(j).getMolarVolume(); + if (getCalculateSteadyState()) { + thermoSystem = thermoSystem2; + } else { + try { + liquidVolume = + Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength * liquidLevel; + gasVolume = Math.PI * internalDiameter * internalDiameter / 4.0 * separatorLength + * (1.0 - liquidLevel); + thermoSystem = thermoSystem2.clone(); + thermoSystem.init(1); + thermoSystem.initPhysicalProperties("density"); + thermoSystem2.initPhysicalProperties("density"); + for (int j = 0; j < thermoSystem.getNumberOfPhases(); j++) { + double relFact = 1.0; + if (thermoSystem.getPhase(j).getPhaseTypeName().equals("gas")) { + relFact = gasVolume / (thermoSystem2.getPhase(j).getVolume("m3")); + } else { + relFact = liquidVolume / (thermoSystem2.getPhase(j).getVolume("m3")); + } + for (int i = 0; i < thermoSystem.getPhase(j).getNumberOfComponents(); i++) { + thermoSystem.addComponent(i, (relFact - 1.0) + * thermoSystem2.getPhase(j).getComponent(i).getNumberOfMolesInPhase(), j); + } } - 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); + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + thermoSystem.init(3); + thermoSystem.initPhysicalProperties("density"); + if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) { + liquidLevel = thermoSystem.getPhase(1).getVolume("m3") / (liquidVolume + gasVolume); + liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() + * getInternalDiameter() * getSeparatorLength(); + } else { + liquidLevel = 0.0; + liquidVolume = 0.0; } - } - if (thermoSystem.hasPhaseType("gas")) { - thermoSystem.setBeta(gasVolume / thermoSystem2.getPhase(0).getMolarVolume() - / (gasVolume / thermoSystem2.getPhase(0).getMolarVolume() + totalliquidVolume)); + gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() + * getInternalDiameter() * getSeparatorLength(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); } - thermoSystem.initBeta(); - thermoSystem.init(3); - // System.out.println("moles in separator " + thermoSystem.getNumberOfMoles()); - // double volume1 = thermoSystem.getVolume(); - // System.out.println("volume1 bef " + volume1); - // System.out.println("beta " + thermoSystem.getBeta()); - - liquidLevel = thermoSystem.getPhase(1).getVolume() * 1e-5 / (liquidVolume + gasVolume); - liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() - * getSeparatorLength(); - gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() - * getInternalDiameter() * getSeparatorLength(); - // System.out.println("moles out" + - // liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); } - thermoSystem = thermoSystem2; + setCalculationIdentifier(id); } @@ -306,50 +292,73 @@ public void runTransient(double dt, UUID id) { if (getCalculateSteadyState()) { run(id); increaseTime(dt); - return; - } - - inletStreamMixer.run(id); + setCalculationIdentifier(id); + } else { + inletStreamMixer.run(id); + thermoSystem.init(3); + thermoSystem.initPhysicalProperties("density"); + try { + gasOutStream.getThermoSystem().init(3); + liquidOutStream.getThermoSystem().init(3); + } catch (Exception e) { + logger.error(e.getMessage()); + } + boolean hasliq = false; + double deliq = 0.0; + if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) { + hasliq = true; + deliq = -liquidOutStream.getThermoSystem().getEnthalpy(); + } + double deltaEnergy = inletStreamMixer.getOutletStream().getThermoSystem().getEnthalpy() + - gasOutStream.getThermoSystem().getEnthalpy() + deliq; + double newEnergy = thermoSystem.getInternalEnergy() + dt * deltaEnergy; + thermoSystem.init(0); + for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) { + double dncomp = 0.0; + dncomp += + inletStreamMixer.getOutletStream().getThermoSystem().getComponent(i).getNumberOfmoles(); + double dniliq = 0.0; + if (hasliq) { + dniliq = -liquidOutStream.getThermoSystem().getComponent(i).getNumberOfmoles(); + } + dncomp += -gasOutStream.getThermoSystem().getComponent(i).getNumberOfmoles() + dniliq; - // System.out.println("moles out" + - // liquidOutStream.getThermoSystem().getTotalNumberOfMoles()); - // double inMoles = - // inletStreamMixer.getOutStream().getThermoSystem().getTotalNumberOfMoles(); - // double gasoutMoles = gasOutStream.getThermoSystem().getNumberOfMoles(); - // double liqoutMoles = liquidOutStream.getThermoSystem().getNumberOfMoles(); - thermoSystem.init(3); - gasOutStream.getThermoSystem().init(3); - liquidOutStream.getThermoSystem().init(3); - double volume1 = thermoSystem.getVolume(); - // System.out.println("volume1 " + volume1); - double deltaEnergy = inletStreamMixer.getOutletStream().getThermoSystem().getEnthalpy() - - gasOutStream.getThermoSystem().getEnthalpy() - - liquidOutStream.getThermoSystem().getEnthalpy(); - // System.out.println("enthalph delta " + deltaEnergy); - double newEnergy = thermoSystem.getInternalEnergy() + dt * deltaEnergy; - for (int i = 0; i < thermoSystem.getPhase(0).getNumberOfComponents(); i++) { - double dn = inletStreamMixer.getOutletStream().getThermoSystem().getPhase(0).getComponent(i) - .getNumberOfMolesInPhase() - + inletStreamMixer.getOutletStream().getThermoSystem().getPhase(1).getComponent(i) - .getNumberOfMolesInPhase() - - gasOutStream.getThermoSystem().getPhase(0).getComponent(i).getNumberOfMolesInPhase() - - liquidOutStream.getThermoSystem().getPhase(0).getComponent(i).getNumberOfMolesInPhase(); - // System.out.println("dn " + dn); - thermoSystem.addComponent(inletStreamMixer.getOutletStream().getThermoSystem().getPhase(0) - .getComponent(i).getComponentNumber(), dn * dt); - } - ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); - thermoOps.VUflash(volume1, newEnergy); + thermoSystem.addComponent(i, dncomp * dt); + } + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.VUflash(gasVolume + liquidVolume, newEnergy, "m3", "J"); + thermoSystem.initPhysicalProperties("density"); - setTempPres(thermoSystem.getTemperature(), thermoSystem.getPressure()); + if (thermoSystem.hasPhaseType("gas")) { + gasOutStream.getFluid() + .setMolarComposition(thermoSystem.getPhase("gas").getMolarComposition()); + } + if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) { + if (thermoSystem.getNumberOfPhases() > 1) { + liquidOutStream.getFluid() + .setMolarComposition(thermoSystem.getPhase(1).getMolarComposition()); + } + } + setTempPres(thermoSystem.getTemperature(), thermoSystem.getPressure()); - liquidLevel = thermoSystem.getPhase(1).getVolume() * 1e-5 / (liquidVolume + gasVolume); - // System.out.println("liquid level " + liquidLevel); - liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() - * getSeparatorLength(); - gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() - * getInternalDiameter() * getSeparatorLength(); - setCalculationIdentifier(id); + liquidLevel = 0.0; + if (thermoSystem.hasPhaseType("oil") || thermoSystem.hasPhaseType("aqueous")) { + double volumeLoc = 0.0; + if (thermoSystem.hasPhaseType("oil")) { + volumeLoc += thermoSystem.getPhase("oil").getVolume("m3"); + } + if (thermoSystem.hasPhaseType("aqueous")) { + volumeLoc += thermoSystem.getPhase("aqueous").getVolume("m3"); + } + liquidLevel = volumeLoc / (liquidVolume + gasVolume); + } + liquidVolume = getLiquidLevel() * 3.14 / 4.0 * getInternalDiameter() * getInternalDiameter() + * getSeparatorLength(); + gasVolume = (1.0 - getLiquidLevel()) * 3.14 / 4.0 * getInternalDiameter() + * getInternalDiameter() * getSeparatorLength(); + // System.out.println("gas volume " + gasVolume + " liq volime " + liquidVolume); + setCalculationIdentifier(id); + } } /** @@ -441,6 +450,12 @@ public void setGasCarryunderFraction(double gasCarryunderFraction) { this.gasCarryunderFraction = gasCarryunderFraction; } + /** {@inheritDoc} */ + @Override + public void setLiquidLevel(double liquidlev) { + liquidLevel = liquidlev; + } + /** *

* 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. + *

+ * + * @param liquidlev a double + */ + public void setLiquidLevel(double liquidlev); } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java index dc1d1abee6..0ef95e6551 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/ThreePhaseSeparator.java @@ -1,8 +1,10 @@ package neqsim.processSimulation.processEquipment.separator; import java.util.UUID; +import com.google.gson.GsonBuilder; import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.util.monitor.SeparatorResponse; import neqsim.thermodynamicOperations.ThermodynamicOperations; /** @@ -37,28 +39,7 @@ public class ThreePhaseSeparator extends Separator { double aqueousInOil = 0.00; String aqueousInOilSpec = "mole"; - /** - *

- * 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. + *

+ * + * @param i a int + * @return a double + */ + public double getSplitFactor(int i) { + return splitFactor[i]; + } + + /** + *

+ * 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) *

* - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - */ - @Deprecated - public Stream(SystemInterface thermoSystem) { - this("Stream", thermoSystem); - } - - /** - * Constructor for Stream. - * * @param name name of stream - */ - public Stream(String name) { - super(name); - } - - /** - * Constructor for Stream. - * - * @param name name of stream - * @param stream input stream + * @param stream Stream to use as internal Stream. */ public Stream(String name, StreamInterface stream) { this(name); this.setStream(stream); - thermoSystem = stream.getThermoSystem(); numberOfStreams++; streamNumber = numberOfStreams; } @@ -103,8 +82,12 @@ public Stream(String name, StreamInterface stream) { * Constructor for Stream. *

* - * @param name a {@link java.lang.String} object - * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object + *

+ * 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 field stream. *

* - * @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 getReport() { + HashMap gasprops = new HashMap(); + ArrayList phases = new ArrayList(); + + phases.add("Total"); + if (getFluid().hasPhaseType("gas")) { + phases.add("Gas"); + gasprops.put("temperature", + Double.toString(getTemperature(neqsim.util.unit.Units.getSymbol("temperature")))); + } + if (getFluid().hasPhaseType("oil")) { + phases.add("oil"); + } + if (getFluid().hasPhaseType("aqueous")) { + phases.add("aqueous"); + } + + ArrayList report = new ArrayList(); + report.add(phases.toArray(new String[0])); + report.add(new String[] {"temperature", + Double.toString(getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature")}); + report.add(new String[] {"pressure", + Double.toString(getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure")}); + report.add(new String[] {"mass flow", + Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))), + neqsim.util.unit.Units.getSymbol("mass flow")}); + report.add(new String[] {"molar flow", + Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))), + neqsim.util.unit.Units.getSymbol("molar flow")}); + report.add(new String[] {"volume flow", + Double.toString(getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))), + neqsim.util.unit.Units.getSymbol("volume flow")}); + return report; + } + + /** {@inheritDoc} */ + @Override + public String toJson() { + return new GsonBuilder().create().toJson(new StreamResponse(this)); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java index 29151b4d08..5ea1586d26 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/StreamInterface.java @@ -7,6 +7,7 @@ package neqsim.processSimulation.processEquipment.stream; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; +import neqsim.standards.gasQuality.Standard_ISO6976; import neqsim.thermo.system.SystemInterface; /** @@ -48,6 +49,7 @@ public interface StreamInterface extends ProcessEquipmentInterface { * getPressure. *

*/ + @Override public double getPressure(String unit); /** {@inheritDoc} */ @@ -128,6 +130,30 @@ public default double getFlowRate(String unit) { */ public double TVP(double temperature, String unit); + /** + *

+ * 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. *

* - * @param comps an array of {@link double} objects + * @param comps an array of type double * @param unit a {@link java.lang.String} object */ public void setComposition(double[] comps, String unit) { diff --git a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java index 24bc57ba8f..bbdcec9142 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/subsea/SimpleFlowLine.java @@ -22,20 +22,6 @@ public class SimpleFlowLine extends TwoPortEquipment { double outletTemperature = 313.15; AdiabaticTwoPhasePipe pipeline; - /** - *

- * 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. + *

+ * + * @param maxVal a double + */ + public void setMaxAdjustedValue(double maxVal) { + maxAdjustedValue = maxVal; + if (maxAdjustedValue < minAdjustedValue) { + minAdjustedValue = maxAdjustedValue; + } + } + + /** + *

+ * Setter for the field minAdjustedValue. + *

+ * + * @param minVal a double + */ + public void setMinAdjustedValue(double minVal) { + minAdjustedValue = minVal; + if (minAdjustedValue > maxAdjustedValue) { + maxAdjustedValue = minAdjustedValue; + } + } + + /** + *

+ * Getter for the field maxAdjustedValue. + *

+ * + * @return a double + */ + public double getMaxAdjustedValue() { + return maxAdjustedValue; + } + + /** + *

+ * Getter for the field minAdjustedValue. + *

+ * + * @return a double + */ + public double getMinAdjustedValue() { + return minAdjustedValue; + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java index 02566e80f3..c26ab6e4e8 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java @@ -7,7 +7,8 @@ import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; - +import neqsim.processSimulation.processEquipment.compressor.Compressor; +import neqsim.processSimulation.processEquipment.splitter.Splitter; /** *

@@ -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. + *

+ */ + @Override + public void setInletStream(StreamInterface inletStream) { + this.inStream = inletStream; + try { + this.outStream = inletStream.clone(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + } + + /** + *

+ * 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. + *

+ * + * @return a {@link neqsim.processSimulation.processSystem.ProcessSystem} object + */ + public ProcessSystem getReferenceProcess() { + return 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 field inletStream. *

*/ + @Override public void setInletStream(StreamInterface inletStream) { this.inStream = inletStream; try { @@ -87,13 +93,8 @@ public void setInletStream(StreamInterface inletStream) { } } - /** - *

- * Getter for the field pressure. - *

- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double getPressure() { return pressure; } @@ -164,7 +165,7 @@ public void run(UUID id) { } if (!getReferenceConditions().equals("actual")) { tempFluid.setTemperature(15.0, "C"); - tempFluid.setPressure(1.01325, "bara"); + tempFluid.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); } ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); try { @@ -210,6 +211,7 @@ public void run(UUID id) { } catch (Exception ex) { logger.error(ex.getMessage(), ex); } + tempFluid.initProperties(); outStream.setThermoSystem(tempFluid); if (!tempFluid.hasPhaseType("gas")) { GVF = 0.0; @@ -261,7 +263,9 @@ public void setGVF(double gvf) { } /** - *

Getter for the field referenceConditions.

+ *

+ * Getter for the field referenceConditions. + *

* * @return the referenceConditions */ @@ -270,7 +274,9 @@ public String getReferenceConditions() { } /** - *

Setter for the field referenceConditions.

+ *

+ * Setter for the field referenceConditions. + *

* * @param referenceConditions the referenceConditions to set */ @@ -279,7 +285,9 @@ public void setReferenceConditions(String referenceConditions) { } /** - *

isFitAsGVF.

+ *

+ * isFitAsGVF. + *

* * @return the fitAsGVF */ @@ -288,7 +296,9 @@ public boolean isFitAsGVF() { } /** - *

Setter for the field fitAsGVF.

+ *

+ * Setter for the field fitAsGVF. + *

* * @param fitAsGVF the fitAsGVF to set */ diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/MPFMfitter.java b/src/main/java/neqsim/processSimulation/processEquipment/util/MPFMfitter.java new file mode 100644 index 0000000000..2a59020587 --- /dev/null +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/MPFMfitter.java @@ -0,0 +1,332 @@ +package neqsim.processSimulation.processEquipment.util; + +import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import neqsim.processSimulation.processEquipment.TwoPortEquipment; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + *

+ * 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. + *

+ */ + @Override + public void setInletStream(StreamInterface inletStream) { + this.inStream = inletStream; + try { + this.outStream = inletStream.clone(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + } + + /** {@inheritDoc} */ + @Override + public double getPressure() { + return pressure; + } + + /** + *

+ * Setter for the field pressure. + *

+ * + * @param pressure a double + * @param unitP a {@link java.lang.String} object + */ + public void setPressure(double pressure, String unitP) { + this.pressure = pressure; + this.unitP = unitP; + } + + /** + *

+ * getTemperature. + *

+ * + * @return a double + */ + public double getTemperature() { + return temperature; + } + + /** + *

+ * Setter for the field temperature. + *

+ * + * @param temperature a double + * @param unitT a {@link java.lang.String} object + */ + public void setTemperature(double temperature, String unitT) { + this.temperature = temperature; + this.unitT = unitT; + } + + /** {@inheritDoc} */ + @Override + public void run(UUID id) { + SystemInterface tempFluid = inStream.getThermoSystem().clone(); + double flow = tempFluid.getFlowRate("kg/sec"); + + if (GOR < 1e-15) { + outStream.setThermoSystem(tempFluid); + return; + } + + if (flow < 1e-6) { + outStream.setThermoSystem(tempFluid); + return; + } + + if (GOR == 0 && tempFluid.hasPhaseType("gas")) { + tempFluid.removePhase(0); + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + outStream.setThermoSystem(tempFluid); + return; + } + if (!getReferenceConditions().equals("actual")) { + tempFluid.setTemperature(15.0, "C"); + tempFluid.setPressure(ThermodynamicConstantsInterface.referencePressure, "bara"); + } + ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + if (!tempFluid.hasPhaseType("gas") || !tempFluid.hasPhaseType("oil")) { + outStream = inStream.clone(); + return; + } + tempFluid.initPhysicalProperties("density"); + double currGOR = tempFluid.getPhase("gas").getCorrectedVolume() + / tempFluid.getPhase("oil").getCorrectedVolume(); + + if (fitAsGVF) { + GOR = tempFluid.getPhase("oil").getCorrectedVolume() * getGOR() + / (tempFluid.getPhase("oil").getCorrectedVolume() + - tempFluid.getPhase("oil").getCorrectedVolume() * getGOR()); + // GVF*Vo/(Vo-GVF*Vo) + // currGOR = tempFluid.getPhase("gas").getCorrectedVolume() + // / (tempFluid.getPhase("oil").getCorrectedVolume() + + // tempFluid.getPhase("gas").getCorrectedVolume()); + } + + double dev = getGOR() / currGOR; + // System.out.println("dev "+dev); + + double[] moleChange = new double[tempFluid.getNumberOfComponents()]; + for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { + moleChange[i] = + (dev - 1.0) * tempFluid.getPhase("gas").getComponent(i).getNumberOfMolesInPhase(); + } + tempFluid.init(0); + for (int i = 0; i < tempFluid.getNumberOfComponents(); i++) { + tempFluid.addComponent(i, moleChange[i]); + } + tempFluid.setPressure((inStream.getThermoSystem()).getPressure()); + tempFluid.setTemperature((inStream.getThermoSystem()).getTemperature()); + tempFluid.setTotalFlowRate(flow, "kg/sec"); + try { + thermoOps.TPflash(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + tempFluid.initProperties(); + outStream.setThermoSystem(tempFluid); + if (!tempFluid.hasPhaseType("gas")) { + GVF = 0.0; + } else if (tempFluid.hasPhaseType("gas") && tempFluid.hasPhaseType("oil")) { + GVF = tempFluid.getPhase("gas").getCorrectedVolume() + / (tempFluid.getPhase("oil").getCorrectedVolume() + + tempFluid.getPhase("gas").getCorrectedVolume()); + } else { + GVF = Double.NaN; + } + + outStream.setCalculationIdentifier(id); + setCalculationIdentifier(id); + } + + /** + *

+ * 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. + *

+ * + * @return the referenceConditions + */ + public String getReferenceConditions() { + return referenceConditions; + } + + /** + *

+ * Setter for the field referenceConditions. + *

+ * + * @param referenceConditions the referenceConditions to set + */ + public void setReferenceConditions(String referenceConditions) { + this.referenceConditions = referenceConditions; + } + + /** + *

+ * isFitAsGVF. + *

+ * + * @return the fitAsGVF + */ + public boolean isFitAsGVF() { + return fitAsGVF; + } + + /** + *

+ * Setter for the field fitAsGVF. + *

+ * + * @param fitAsGVF the fitAsGVF to set + */ + public void setFitAsGVF(boolean fitAsGVF) { + this.fitAsGVF = fitAsGVF; + } + + /** + *

+ * Getter for the field referenceFluidPackage. + *

+ * + * @return a {@link neqsim.thermo.system.SystemInterface} object + */ + public SystemInterface getReferenceFluidPackage() { + return referenceFluidPackage; + } + + /** + *

+ * Setter for the field referenceFluidPackage. + *

+ * + * @param referenceFluidPackage a {@link neqsim.thermo.system.SystemInterface} object + */ + public void setReferenceFluidPackage(SystemInterface referenceFluidPackage) { + this.referenceFluidPackage = referenceFluidPackage; + } +} diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java index 6d93ba46ce..901c261eeb 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/MoleFractionControllerUtil.java @@ -46,6 +46,7 @@ public MoleFractionControllerUtil(StreamInterface inletStream) { * Setter for the field 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.

+ * + * @param pressureDrop a double + * @param unit a {@link java.lang.String} object + */ public void setPressureDrop(double pressureDrop, String unit) { if (unit.equals("bara")) { this.pressureDrop = pressureDrop; @@ -73,5 +79,4 @@ public void run(UUID id) { outStream.setFluid(thermoSystem); } - } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 38a007c079..892978632e 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -6,7 +6,6 @@ import org.apache.logging.log4j.Logger; import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.MixerInterface; -import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -144,14 +143,14 @@ public void addStream(StreamInterface newStream) { streams.add(newStream); if (numberOfInputStreams == 0) { - mixedStream = 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); } mixedStream.setEmptyThermoSystem(streams.get(0).getThermoSystem()); numberOfInputStreams++; - lastIterationStream = mixedStream.clone(); + lastIterationStream = mixedStream.clone(this.getName() + " last iteration stream"); } /** @@ -252,11 +251,8 @@ public double calcMixStreamEnthalpy() { return enthalpy; } - /** - * {@inheritDoc} - * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ + /** {@inheritDoc} */ + @Override @Deprecated public StreamInterface getOutStream() { return mixedStream; @@ -294,9 +290,7 @@ public void setDownstreamProperties() { public void run(UUID id) { iterations++; /* - * if(firstTime || iterations>maxIterations) { firstTime=false; return; - * - * } + * if(firstTime || iterations>maxIterations) { firstTime=false; return; } */ double enthalpy = 0.0; @@ -336,7 +330,7 @@ public void run(UUID id) { setErrorFlow(massBalanceCheck2()); logger.debug("comp recycle error: " + getError()); logger.debug("flow recycle error: " + getErrorFlow()); - lastIterationStream = (Stream) mixedStream.clone(); + lastIterationStream = mixedStream.clone(); outletStream.setThermoSystem(mixedStream.getThermoSystem()); outletStream.setCalculationIdentifier(id); logger.info( @@ -544,13 +538,8 @@ public ArrayList getDownstreamProperty() { return downstreamProperty; } - /** - *

- * Getter for the field outletStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ + /** {@inheritDoc} */ + @Override public StreamInterface getOutletStream() { return outletStream; } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java index 1333e42f65..6213a8d209 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/SetPoint.java @@ -71,7 +71,7 @@ public SetPoint(String name, ProcessEquipmentInterface targetEquipment, String t this.targetEquipment = targetEquipment; this.targetVariable = targetVariable; this.sourceEquipment = sourceEquipment; - run(); + // run(); } /** diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java index 117c11b2c7..d7f15d32c7 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/StreamSaturatorUtil.java @@ -24,19 +24,6 @@ public class StreamSaturatorUtil extends TwoPortEquipment { protected double oldInletFlowRate = 0.0; - /** - *

- * 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 field inletStream. *

*/ + @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. + *

+ * + * @param gasValve a boolean + */ + public void setGasValve(boolean gasValve) { + this.gasValve = 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 getAddedUnitOperations() { * * @return the list of operations index */ - public List getOperationsIndex() { return operationsIndex; } @@ -101,7 +95,6 @@ public List getOperationsIndex() { * * @return the list of added process modules */ - public List getAddedModules() { return addedModules; } @@ -112,16 +105,11 @@ public List getAddedModules() { * * @return the list of module index */ - public List getModulesIndex() { return modulesIndex; } - /** - * Run the current process module. - * - * @param id the UUID of the process module - */ + /** {@inheritDoc} */ @Override public void run(UUID id) { logger.info("Running module " + getName()); @@ -156,7 +144,7 @@ public void checkModulesRecycles() { for (ProcessSystem operation : addedUnitOperations) { for (ProcessEquipmentInterface unitOperation : operation.getUnitOperations()) { if (unitOperation instanceof Recycle) { - recycleModules.add((Recycle) unitOperation); + recycleModules.add(unitOperation); } } } @@ -176,11 +164,7 @@ public boolean recyclesSolved() { return true; } - /** - * Returns whether or not the module has been solved. - * - * @return true if the module has been solved, false otherwise - */ + /** {@inheritDoc} */ @Override public boolean solved() { @@ -224,6 +208,30 @@ public Object getUnit(String name) { return null; // no unit found with the given name } + /** + * Returns the unit with the given name from the list of added unit operations and list of added + * modules. + * + * @param name the name of the unit to retrieve + * @return the unit with the given name, or {@code null} if no such unit is found + */ + public Object getMeasurementDevice(String name) { + for (ProcessSystem processSystem : addedUnitOperations) { + Object unit = processSystem.getMeasurementDevice(name); + if (unit != null) { + return unit; + } + } + + for (ProcessModule processModule : addedModules) { + Object unit = processModule.getMeasurementDevice(name); + if (unit != null) { + return unit; + } + } + return null; // no unit found with the given name + } + /** *

* 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 getReport() { + return null; + } + + /** + * {@inheritDoc} + * + * @return a String + */ + public String getReport_json() { + return new Report(this).generateJsonReport(); + } + + /** {@inheritDoc} */ + @Override + public void run_step(UUID id) { + run(id); + } } diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java index d88a67e5a4..7768f7d79d 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessModuleBaseClass.java @@ -11,6 +11,7 @@ import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface; import neqsim.processSimulation.mechanicalDesign.MechanicalDesign; import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface; +import neqsim.processSimulation.util.report.Report; import neqsim.thermo.system.SystemInterface; /** @@ -220,13 +221,8 @@ public String getConditionAnalysisMessage() { return null; } - /** - *

- * 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 unitOperations = @@ -63,33 +64,46 @@ public ProcessSystem(String name) { /** *

- * 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 units = this.getUnitOperations(); for (ProcessEquipmentInterface unit : units) { if (unit == operation) { + logger.info("Equipment " + operation.getName() + " is already included in ProcessSystem"); return; } } if (getAllUnitNames().contains(operation.getName())) { - String currClass = operation.getClass().getSimpleName(); - int num = 1; - for (ProcessEquipmentInterface unit : units) { - if (unit.getClass().getSimpleName().equals(currClass)) { - num++; - } - } - operation.setName(currClass + Integer.toString(num)); + ProcessEquipmentInterface existing = + (ProcessEquipmentInterface) this.getUnit(operation.getName()); + throw new RuntimeException(new neqsim.util.exception.InvalidInputException("ProcessSystem", + "add", "operation", "- Process equipment of type " + existing.getClass().getSimpleName() + + " named " + operation.getName() + " already included in ProcessSystem")); + } - getUnitOperations().add(operation); + getUnitOperations().add(position, operation); if (operation instanceof ModuleInterface) { ((ModuleInterface) operation).initializeModule(); } @@ -97,7 +111,7 @@ public void add(ProcessEquipmentInterface operation) { /** *

- * 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. - *

- * - * @return a double - */ + /** {@inheritDoc} */ + @Override public double getTime() { return time; } @@ -690,24 +727,16 @@ public void setTimeStep(double timeStep) { this.timeStep = timeStep; } - /** - *

- * Getter for the field name. - *

- * - * @return the name - */ + /** {@inheritDoc} */ + @Override public String getName() { return name; } /** * {@inheritDoc} - * - *

- * Setter for the field name. - *

*/ + @Override public void setName(String name) { this.name = name; } @@ -910,15 +939,24 @@ public boolean equals(Object obj) { && Objects.equals(unitOperations, other.unitOperations); } + /** + * {@inheritDoc} + * + * @return a String + */ + public String getReport_json() { + return new Report(this).generateJsonReport(); + } + /* * @XmlRootElement private class Report extends Object{ public Double name; public * ArrayList unitOperationsReports = new ArrayList(); - * + * * Report(){ name= getName(); - * + * * for (int i = 0; i < unitOperations.size(); i++) { * unitOperationsReports.add(unitOperations.getReport()); } } } - * + * * public Report getReport(){ return this.new Report(); } */ } diff --git a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java index 7fedfd4322..e186601305 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java +++ b/src/main/java/neqsim/processSimulation/processSystem/processModules/AdsorptionDehydrationlModule.java @@ -9,6 +9,7 @@ import neqsim.processSimulation.processEquipment.stream.Stream; import neqsim.processSimulation.processEquipment.stream.StreamInterface; import neqsim.processSimulation.processSystem.ProcessModuleBaseClass; +import neqsim.thermo.ThermodynamicConstantsInterface; /** *

@@ -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 compProp; - - public Map> definedComponent; - public Map> oilComponent; - - /** - *

- * 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> properties = + new 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 newdata = new HashMap(); + + for (int i = 0; i < inputFluid.getNumberOfComponents(); i++) { + String name = inputFluid.getPhase(0).getComponent(i).getComponentName(); + ComponentInterface component = inputFluid.getPhase(0).getComponent(i); + PhaseInterface phase = inputFluid.getPhase(0); + newdata = new HashMap(); + newdata.put("Acentric Factor", + new Value(Double.toString(component.getAcentricFactor()), "-")); + newdata.put("Mole Fraction", new Value(Double.toString(component.getz()), "-")); + newdata.put("Weigth Fraction", new Value(Double.toString(phase.getWtFrac(i)), "-")); + newdata.put("Critical Temperature", + new Value( + Double.toString(component.getTC(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature"))); + newdata.put("Critical Pressure", + new Value(Double.toString(component.getPC(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("Normal Liquid Density", + new Value( + Double.toString( + component.getNormalLiquidDensity(neqsim.util.unit.Units.getSymbol("density"))), + neqsim.util.unit.Units.getSymbol("density"))); + + properties.put(name, newdata); + } + } + + /** + * @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/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> properties = + new HashMap>(); + public HashMap> composition = + new HashMap>(); + public HashMap> conditions = + new 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 newdata = new HashMap(); + newdata.put("temperature", + new Value( + Double.toString( + inputFluid.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature"))); + newdata.put("pressure", + new Value( + Double.toString(inputFluid.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("molar flow", + new Value( + Double.toString(inputFluid.getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))), + neqsim.util.unit.Units.getSymbol("molar flow"))); + newdata.put("mass flow", + new Value( + Double.toString(inputFluid.getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))), + neqsim.util.unit.Units.getSymbol("mass flow"))); + newdata.put("fluid model", new Value(inputFluid.getModelName(), "")); + newdata.put("enthalpy", + new Value( + Double.toString(inputFluid.getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + conditions.put("overall", newdata); + + for (int i = 0; i < inputFluid.getNumberOfPhases(); i++) { + String name = inputFluid.getPhase(i).getPhaseTypeName(); + newdata = new HashMap(); + newdata.put("temperature", + new Value( + Double.toString(inputFluid.getPhase(name) + .getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature"))); + newdata.put("pressure", new Value( + Double.toString( + inputFluid.getPhase(name).getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("molar flow", + new Value( + Double.toString(inputFluid.getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))), + neqsim.util.unit.Units.getSymbol("molar flow"))); + newdata.put("mass flow", new Value( + Double.toString( + inputFluid.getPhase(name).getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))), + neqsim.util.unit.Units.getSymbol("mass flow"))); + newdata.put("fluid model", new Value(inputFluid.getModelName(), "")); + newdata.put("enthalpy", new Value( + Double.toString( + inputFluid.getPhase(name).getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + conditions.put(name, newdata); + } + + name = inputFluid.getFluidName(); + newdata = new HashMap(); + for (int i = 0; i < inputFluid.getNumberOfComponents(); i++) { + newdata.put(inputFluid.getComponent(i).getComponentName(), + new Value(Double.toString(inputFluid.getComponent(i).getz()), "mole fraction")); + } + composition.put("overall", newdata); + for (int j = 0; j < inputFluid.getNumberOfPhases(); j++) { + newdata = new HashMap(); + HashMap newdata2 = new HashMap(); + for (int i = 0; i < inputFluid.getNumberOfComponents(); i++) { + newdata2.put(inputFluid.getPhase(j).getComponent(i).getComponentName(), new Value( + Double.toString(inputFluid.getPhase(j).getComponent(i).getx()), "mole fraction")); + newdata.put(inputFluid.getPhase(j).getComponent(i).getComponentName(), + new Value(Double.toString(inputFluid.getPhase(j).getWtFrac(i)), "weight fraction")); + } + composition.put(inputFluid.getPhase(j).getPhaseTypeName(), newdata2); + composition.put(inputFluid.getPhase(j).getPhaseTypeName() + "_wt", newdata); + } + + newdata = new HashMap(); + + newdata.put("density", + new Value( + Double.toString(inputFluid.getDensity(neqsim.util.unit.Units.getSymbol("density"))), + neqsim.util.unit.Units.getSymbol("density"))); + + newdata.put("molar mass", + new Value( + Double + .toString(inputFluid.getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))), + neqsim.util.unit.Units.getSymbol("Molar Mass"))); + + newdata.put("flow rate", + new Value( + Double + .toString(inputFluid.getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))), + neqsim.util.unit.Units.getSymbol("volume flow"))); + properties.put("overall", newdata); + for (int i = 0; i < inputFluid.getNumberOfPhases(); i++) { + newdata = new HashMap(); + String name = inputFluid.getPhase(i).getPhaseTypeName(); + newdata.put("density", new Value( + Double.toString( + inputFluid.getPhase(name).getDensity(neqsim.util.unit.Units.getSymbol("density"))), + neqsim.util.unit.Units.getSymbol("density"))); + newdata.put("molar mass", + new Value( + Double.toString(inputFluid.getPhase(name) + .getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))), + neqsim.util.unit.Units.getSymbol("Molar Mass"))); + + newdata.put("flow rate", + new Value( + Double.toString(inputFluid.getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))), + neqsim.util.unit.Units.getSymbol("volume flow"))); + properties.put(name, newdata); + } + } + + /** + * @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/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> properties = + new HashMap>(); + public HashMap> conditions = + new HashMap>(); + public HashMap> composition = + new HashMap>(); + + /** + *

+ * Constructor for StreamResponse. + *

+ * + * @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public StreamResponse(StreamInterface inputStream) { + name = inputStream.getName(); + + HashMap newdata = new HashMap(); + newdata.put("temperature", + new Value( + Double.toString( + inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature"))); + newdata.put("pressure", + new Value( + Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("molar flow", + new Value( + Double + .toString(inputStream.getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))), + neqsim.util.unit.Units.getSymbol("molar flow"))); + newdata.put("mass flow", + new Value( + Double.toString(inputStream.getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))), + neqsim.util.unit.Units.getSymbol("mass flow"))); + newdata.put("fluid model", new Value(inputStream.getFluid().getModelName(), "")); + newdata.put("enthalpy", + new Value( + Double.toString( + inputStream.getFluid().getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + conditions.put("overall", newdata); + + for (int i = 0; i < inputStream.getFluid().getNumberOfPhases(); i++) { + String name = inputStream.getFluid().getPhase(i).getPhaseTypeName(); + newdata = new HashMap(); + newdata.put("temperature", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))), + neqsim.util.unit.Units.getSymbol("temperature"))); + newdata.put("pressure", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getPressure(neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("molar flow", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("molar flow"))), + neqsim.util.unit.Units.getSymbol("molar flow"))); + newdata.put("mass flow", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("mass flow"))), + neqsim.util.unit.Units.getSymbol("mass flow"))); + newdata.put("fluid model", new Value(inputStream.getFluid().getModelName(), "")); + newdata.put("enthalpy", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + conditions.put(name, newdata); } - /** - *

Constructor 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 HashMap(); + for (int i = 0; i < inputStream.getFluid().getNumberOfComponents(); i++) { + newdata.put(inputStream.getFluid().getComponent(i).getComponentName(), new Value( + Double.toString(inputStream.getFluid().getComponent(i).getz()), "mole fraction")); + } + composition.put("overall", newdata); + for (int j = 0; j < inputStream.getFluid().getNumberOfPhases(); j++) { + newdata = new HashMap(); + HashMap newdata2 = new HashMap(); + for (int i = 0; i < inputStream.getFluid().getNumberOfComponents(); i++) { + newdata2.put(inputStream.getFluid().getPhase(j).getComponent(i).getComponentName(), + new Value(Double.toString(inputStream.getFluid().getPhase(j).getComponent(i).getx()), + "mole fraction")); + newdata.put(inputStream.getFluid().getPhase(j).getComponent(i).getComponentName(), + new Value(Double.toString(inputStream.getFluid().getPhase(j).getWtFrac(i)), + "weight fraction")); + } + composition.put(inputStream.getFluid().getPhase(j).getPhaseTypeName(), newdata2); + composition.put(inputStream.getFluid().getPhase(j).getPhaseTypeName() + "_wt", newdata); + } + + newdata = new HashMap(); + + newdata.put("density", + new Value( + Double.toString( + inputStream.getFluid().getDensity(neqsim.util.unit.Units.getSymbol("density"))), + neqsim.util.unit.Units.getSymbol("density"))); + + newdata.put("molar mass", new Value( + Double.toString( + inputStream.getFluid().getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))), + neqsim.util.unit.Units.getSymbol("Molar Mass"))); + + newdata.put("flow rate", new Value( + Double.toString( + inputStream.getFluid().getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))), + neqsim.util.unit.Units.getSymbol("volume flow"))); + + newdata.put("heat capacity (Cp)", new Value( + Double.toString( + inputStream.getFluid().getCp(neqsim.util.unit.Units.getSymbol("Heat Capacity (Cp)"))), + neqsim.util.unit.Units.getSymbol("Heat Capacity (Cp)"))); + + newdata.put("heat capacity (Cv)", new Value( + Double.toString( + inputStream.getFluid().getCv(neqsim.util.unit.Units.getSymbol("Heat Capacity (Cv)"))), + neqsim.util.unit.Units.getSymbol("Heat Capacity (Cv)"))); + + newdata.put("enthalpy", + new Value( + Double.toString( + inputStream.getFluid().getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + + newdata.put("entropy", + new Value( + Double.toString( + inputStream.getFluid().getEntropy(neqsim.util.unit.Units.getSymbol("entropy"))), + neqsim.util.unit.Units.getSymbol("entropy"))); + + properties.put("overall", newdata); + for (int i = 0; i < inputStream.getFluid().getNumberOfPhases(); i++) { + newdata = new HashMap(); + String name = inputStream.getFluid().getPhase(i).getPhaseTypeName(); + newdata.put("density", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getDensity(neqsim.util.unit.Units.getSymbol("density"))), + neqsim.util.unit.Units.getSymbol("density"))); + newdata.put("molar mass", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getMolarMass(neqsim.util.unit.Units.getSymbol("Molar Mass"))), + neqsim.util.unit.Units.getSymbol("Molar Mass"))); + + newdata.put("flow rate", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("volume flow"))), + neqsim.util.unit.Units.getSymbol("volume flow"))); + + newdata.put("heat capacity (Cp)", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getCp(neqsim.util.unit.Units.getSymbol("Heat Capacity (Cp)"))), + neqsim.util.unit.Units.getSymbol("Heat Capacity (Cp)"))); + + newdata.put("heat capacity (Cv)", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getCv(neqsim.util.unit.Units.getSymbol("Heat Capacity (Cv)"))), + neqsim.util.unit.Units.getSymbol("Heat Capacity (Cv)"))); + + newdata.put("enthalpy", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getEnthalpy(neqsim.util.unit.Units.getSymbol("enthalpy"))), + neqsim.util.unit.Units.getSymbol("enthalpy"))); + + newdata.put("entropy", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getEntropy(neqsim.util.unit.Units.getSymbol("entropy"))), + neqsim.util.unit.Units.getSymbol("entropy"))); + + if (name.equals("oil")) { + try { + newdata.put("TVP", + new Value( + Double.toString( + inputStream.getTVP(37.8, "C", neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + } catch (Exception e) { + logger.error(e.getMessage()); } - if (inputStream.getFluid().hasPhaseType("oil")) { - massflowOil = inputStream.getFluid().getPhase("oil").getFlowRate("kg/hr"); - } else { - massflowOil = 0.0; + try { + newdata.put("RVP", + new Value( + Double.toString( + inputStream.getRVP(37.8, "C", neqsim.util.unit.Units.getSymbol("pressure"))), + neqsim.util.unit.Units.getSymbol("pressure"))); + newdata.put("relative density", new Value( + Double.toString(inputStream.getFluid().getPhase(name).getDensity("kg/m3") / 1000.0), + "-")); + } catch (Exception e) { + logger.error(e.getMessage()); } + } else if (name.equals("gas")) { + Standard_ISO6976 standard = inputStream.getISO6976("volume", 15.0, 15.0); + standard.calculate(); + newdata.put("GCV", new Value( + Double.toString(standard.getValue("SuperiorCalorificValue") / 1e3), "MJ/Sm3 @15C,15C")); + newdata.put("WI", new Value(Double.toString(standard.getValue("SuperiorWobbeIndex") / 1e3), + "MJ/Sm3 @15C,15C")); + newdata.put("standard flow rate", + new Value( + Double.toString(inputStream.getFluid().getPhase(name) + .getFlowRate(neqsim.util.unit.Units.getSymbol("standard volume flow"))), + neqsim.util.unit.Units.getSymbol("standard volume flow"))); + newdata.put("relative density", + new Value(Double.toString(standard.getValue("RelativeDensity")), "[-]")); + } + properties.put(name, newdata); } + } - /** - *

print.

- */ - 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 data = new 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 json_reports = new HashMap<>(); + + if (process != null) { + for (ProcessEquipmentInterface unit : process.getUnitOperations()) { + json_reports.put(unit.getName(), unit.toJson()); + } + } + if (processEquipment != null) { + json_reports.put(processEquipment.getName(), processEquipment.toJson()); + } + if (fluid != null) { + json_reports.put(fluid.getFluidName(), fluid.toJson()); + } + + // Create a JsonObject to hold the parsed nested JSON objects + JsonObject finalJsonObject = new JsonObject(); + + // Iterate through the entries of the json_reports map + for (Map.Entry entry : json_reports.entrySet()) { + // Parse each value as a separate JSON object using the static parseString method + try { + JsonObject nestedJsonObject = JsonParser.parseString(entry.getValue()).getAsJsonObject(); + // Update the final JsonObject with the parsed JSON object + finalJsonObject.add(entry.getKey(), nestedJsonObject); + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + // Convert the final JsonObject to a JSON string with pretty printing + Gson prettyGson = new GsonBuilder().serializeSpecialFloatingPointValues().setPrettyPrinting().create(); + return prettyGson.toJson(finalJsonObject); + } +} diff --git a/src/main/java/neqsim/standards/Standard.java b/src/main/java/neqsim/standards/Standard.java index 4a27d526e0..5f9daff797 100644 --- a/src/main/java/neqsim/standards/Standard.java +++ b/src/main/java/neqsim/standards/Standard.java @@ -41,7 +41,7 @@ public abstract class Standard extends NamedBaseClass implements StandardInterfa /** * Constructor for Standard. * - * @param name name of standard + * @param name name of standard * @param description description */ public Standard(String name, String description) { @@ -52,8 +52,8 @@ public Standard(String name, String description) { /** * Constructor for Standard. * - * @param name name of standard - * @param thermoSyst input fluid + * @param name name of standard + * @param thermoSyst input fluid * @param description description of standard */ public Standard(String name, String description, SystemInterface thermoSyst) { @@ -111,14 +111,19 @@ public void setStandardDescription(String standardDescription) { /** {@inheritDoc} */ @Override public String[][] createTable(String name) { + if (thermoSystem == null) { + String[][] table = new String[0][6]; + return table; + } thermoSystem.setNumberOfPhases(1); - thermoSystem.createTable(name); DecimalFormat nf = new DecimalFormat(); nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; + + int rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + String[][] table = new String[rows][6]; // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; // getPhases()[0].getType(); //""; @@ -156,7 +161,7 @@ public void display(String name) { Container dialogContentPane = dialog.getContentPane(); dialogContentPane.setLayout(new BorderLayout()); - String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; + String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" }; String[][] table = createTable(name); JTable Jtab = new JTable(table, names); JScrollPane scrollpane = new JScrollPane(Jtab); @@ -199,11 +204,15 @@ public void setReferenceState(String referenceState) { this.referenceState = referenceState; } - public void setReferencePressure(double referencePressure) { - this.referencePressure = referencePressure; + /** {@inheritDoc} */ + @Override + public double getReferencePressure() { + return referencePressure; } - public double getReferencePressure(){ - return referencePressure; + /** {@inheritDoc} */ + @Override + public void setReferencePressure(double referencePressure) { + this.referencePressure = referencePressure; } } diff --git a/src/main/java/neqsim/standards/StandardInterface.java b/src/main/java/neqsim/standards/StandardInterface.java index 7140224cc2..e86d3b2d00 100644 --- a/src/main/java/neqsim/standards/StandardInterface.java +++ b/src/main/java/neqsim/standards/StandardInterface.java @@ -27,7 +27,7 @@ public interface StandardInterface { * @param returnUnit a {@link java.lang.String} object * @return a double */ - double getValue(java.lang.String returnParameter, java.lang.String returnUnit); + double getValue(String returnParameter, String returnUnit); /** *

@@ -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. + *

+ * + * @return Reference pressure in bara + */ + public double getReferencePressure(); + + /** + *

+ * Setter for the field referencePressure. + *

+ * + * @param referencePressure Reference pressure to set in in bara + */ public void setReferencePressure(double referencePressure); } diff --git a/src/main/java/neqsim/standards/gasQuality/BestPracticeHydrocarbonDewPoint.java b/src/main/java/neqsim/standards/gasQuality/BestPracticeHydrocarbonDewPoint.java index aedfd2f3e9..2ad4cb5bf7 100644 --- a/src/main/java/neqsim/standards/gasQuality/BestPracticeHydrocarbonDewPoint.java +++ b/src/main/java/neqsim/standards/gasQuality/BestPracticeHydrocarbonDewPoint.java @@ -68,7 +68,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { if (returnParameter.equals("hydrocarbondewpointTemperature")) { return dewPointTemperature; } else { diff --git a/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java b/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java index 754091cfde..cefb88e063 100644 --- a/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java +++ b/src/main/java/neqsim/standards/gasQuality/Draft_GERG2004.java @@ -65,7 +65,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { return 0.0; } @@ -111,7 +111,16 @@ public String[][] createTable(String name) { DecimalFormat nf = new DecimalFormat(); nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; + + int rows = 0; + if (thermoSystem == null) { + String[][] table = new String[0][6]; + return table; + } + + rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + String[][] table = new String[rows][6]; + // String[] names = {"", "Phase 1", "Phase 2", "Phase 3", "Unit"}; table[0][0] = ""; // getPhases()[0].getType(); //""; diff --git a/src/main/java/neqsim/standards/gasQuality/Draft_ISO18453.java b/src/main/java/neqsim/standards/gasQuality/Draft_ISO18453.java index 7798b6aa7a..1a839c7eb1 100644 --- a/src/main/java/neqsim/standards/gasQuality/Draft_ISO18453.java +++ b/src/main/java/neqsim/standards/gasQuality/Draft_ISO18453.java @@ -71,7 +71,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { if (returnParameter.equals("dewPointTemperature")) { return dewPointTemperature; } else { diff --git a/src/main/java/neqsim/standards/gasQuality/GasChromotograpyhBase.java b/src/main/java/neqsim/standards/gasQuality/GasChromotograpyhBase.java index 44fe5fc107..41dacfc0fb 100644 --- a/src/main/java/neqsim/standards/gasQuality/GasChromotograpyhBase.java +++ b/src/main/java/neqsim/standards/gasQuality/GasChromotograpyhBase.java @@ -20,13 +20,11 @@ public class GasChromotograpyhBase extends neqsim.standards.Standard { *

* * @param thermoSystem a {@link neqsim.thermo.system.SystemInterface} object - * */ public GasChromotograpyhBase(SystemInterface thermoSystem) { super("gas chromotography", "Gas composition", thermoSystem); } - /** {@inheritDoc} */ @Override public void calculate() { @@ -36,7 +34,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String componentName, java.lang.String returnUnit) { + public double getValue(String componentName, String returnUnit) { unit = returnUnit; if (returnUnit.equals("mol%")) { return 100 * thermoSystem.getPhase(0).getComponent(componentName).getz(); diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO15403.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO15403.java index 46ca70d220..61c35f2981 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO15403.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO15403.java @@ -2,6 +2,13 @@ import neqsim.thermo.system.SystemInterface; +/** + *

+ * 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 componentsNotDefinedByStandard = new ArrayList(); double volRefT = 0; - double volRefP = 1.01325; + double volRefP = ThermodynamicConstantsInterface.referencePressure; + // ThermodynamicConstantsInterface.R double R = 8.314510; double molRefm3 = 0.0; // combustion conditions double energyRefT = 25; - double energyRefP = 1.01325; + double energyRefP = ThermodynamicConstantsInterface.referencePressure; String referenceType = "volume"; // mass volume molar String energyUnit = "KJ/Nm3"; double energy = 1.0; @@ -246,7 +248,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { checkReferenceCondition(); if (returnParameter.equals("GCV")) { @@ -371,7 +373,7 @@ public double getValue(String returnParameter, java.lang.String returnUnit) { *

*/ public void checkReferenceCondition() { - Double[] validvalues = {0.0, 15.0, 15.55, 20.0}; + Double[] validvalues = {0.0, 15.0, 15.55, 20.0, 25.0}; if (!java.util.Arrays.stream(validvalues).anyMatch(Double.valueOf(energyRefT)::equals)) { energyRefT = 25.0; @@ -415,7 +417,16 @@ public String[][] createTable(String name) { DecimalFormat nf = new DecimalFormat(); nf.setMaximumFractionDigits(5); nf.applyPattern("#.#####E0"); - String[][] table = new String[thermoSystem.getPhases()[0].getNumberOfComponents() + 30][6]; + + int rows = 0; + if (thermoSystem == null) { + String[][] table = new String[0][6]; + return table; + } + + rows = thermoSystem.getPhases()[0].getNumberOfComponents() + 30; + String[][] table = new String[rows][6]; + // String[] names = { "", "Phase 1", "Phase 2", "Phase 3", "Unit" }; table[0][0] = ""; // getPhases()[0].getType(); //""; diff --git a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java index cc08ce87aa..4936811e84 100644 --- a/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java +++ b/src/main/java/neqsim/standards/gasQuality/Standard_ISO6976_2016.java @@ -18,6 +18,7 @@ public class Standard_ISO6976_2016 extends Standard_ISO6976 { // metering conditions + // ThermodynamicConstantsInterface.R double R = 8.3144621; double Zmix0 = 1.0; @@ -240,7 +241,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { checkReferenceCondition(); if (returnParameter.equals("GCV")) { returnParameter = "SuperiorCalorificValue"; diff --git a/src/main/java/neqsim/standards/gasQuality/SulfurSpecificationMethod.java b/src/main/java/neqsim/standards/gasQuality/SulfurSpecificationMethod.java index 868ffe1b09..24afd0c825 100644 --- a/src/main/java/neqsim/standards/gasQuality/SulfurSpecificationMethod.java +++ b/src/main/java/neqsim/standards/gasQuality/SulfurSpecificationMethod.java @@ -34,7 +34,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { thermoSystem.init(0); if (returnParameter.equals("H2S")) { if (thermoSystem.getPhase(0).hasComponent("H2S")) { diff --git a/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java b/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java index 466d7b5c97..29eea41c05 100644 --- a/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java +++ b/src/main/java/neqsim/standards/gasQuality/UKspecifications_ICF_SI.java @@ -45,7 +45,7 @@ public void calculate() { /** {@inheritDoc} */ @Override - public double getValue(String returnParameter, java.lang.String returnUnit) { + public double getValue(String returnParameter, String returnUnit) { if (returnParameter.equals("PropaneNumber")) { return propaneNumber; } diff --git a/src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.java b/src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.java index 7d152a880f..2e5aa98443 100644 --- a/src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.java +++ b/src/main/java/neqsim/standards/oilQuality/Standard_ASTM_D6377.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; @@ -20,6 +21,55 @@ public class Standard_ASTM_D6377 extends neqsim.standards.Standard { String unit = "bara"; double RVP = 1.0; + double TVP = 1.0; + double referenceTemperature = 37.8; + String referenceTemperatureUnit = "C"; + String methodRVP = "VPCR4"; // RVP_ASTM_D6377 // RVP_ASTM_D323_73_79 // + // RVP_ASTM_D323_82 // VPCR4_no_water // VPCR4 + + private double VPCR4_no_water = 0.0; + private double VPCR4 = 0.0; + private double RVP_ASTM_D6377 = 0.0; + private double RVP_ASTM_D323_73_79 = 0.0; + private double RVP_ASTM_D323_82 = 0.0; + + /** + * Gets the method used for measuring Reid Vapor Pressure (RVP). + * + *

+ * The method can be one of the following: + *

+ *
    + *
  • RVP_ASTM_D6377
  • + *
  • RVP_ASTM_D323_73_79
  • + *
  • RVP_ASTM_D323_82
  • + *
  • VPCR4
  • + *
+ * + * @return the method used for RVP measurement. + */ + public String getMethodRVP() { + return methodRVP; + } + + /** + * Sets the method used for measuring Reid Vapor Pressure (RVP). + * + *

+ * The method should be one of the following: + *

+ *
    + *
  • RVP_ASTM_D6377
  • + *
  • RVP_ASTM_D323_73_79
  • + *
  • RVP_ASTM_D323_82
  • + *
  • VPCR4
  • + *
+ * + * @param methodRVP the method to set for RVP measurement. + */ + public void setMethodRVP(String methodRVP) { + this.methodRVP = methodRVP; + } /** *

@@ -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. *

* - * @return a double + * @return Reference pressure in bara */ public double getReferencePressure() { return referencePressure; @@ -213,7 +205,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/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 field smoothedNumbers. *

* - * @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 field sampleObjectList. *

* - * @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 ArrayList getSampleObjectList() { return sampleObjectList; diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java index e05491b68f..6c6b69cacc 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java @@ -7,12 +7,13 @@ package neqsim.statistics.experimentalSampleCreation.sampleCreator.wettedWallColumnSampleCreator; import Jama.Matrix; -import neqsim.statistics.dataAnalysis.dataSmoothing.DataSmoothor; +import neqsim.statistics.dataanalysis.datasmoothing.DataSmoother; import neqsim.statistics.experimentalEquipmentData.ExperimentalEquipmentData; import neqsim.statistics.experimentalEquipmentData.wettedWallColumnData.WettedWallColumnData; import neqsim.statistics.experimentalSampleCreation.readDataFromFile.wettedWallColumnReader.WettedWallColumnDataObject; import neqsim.statistics.experimentalSampleCreation.readDataFromFile.wettedWallColumnReader.WettedWallDataReader; import neqsim.statistics.experimentalSampleCreation.sampleCreator.SampleCreator; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; @@ -26,7 +27,6 @@ */ public class WettedWallColumnSampleCreator extends SampleCreator { WettedWallDataReader reader; - DataSmoothor smoothor; double[] time; double[] pressure; double[] inletLiquidTemperature; @@ -115,33 +115,33 @@ public void smoothData() { Matrix data = new Matrix(pressure, 1); data.print(10, 2); - smoothor = new DataSmoothor(pressure, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedPressure = smoothor.getSmoothedNumbers(); + DataSmoother smoother = new DataSmoother(pressure, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedPressure = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletLiquidTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletLiquidTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletLiquidTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletLiquidTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(outletLiquidTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedOutletLiquidTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(outletLiquidTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedOutletLiquidTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(columnWallTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedColumnWallTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(columnWallTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedColumnWallTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletTotalGasFlowRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletTotalGasFlowRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletTotalGasFlowRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletTotalGasFlowRate = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(co2SupplyRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedCo2SupplyRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(co2SupplyRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedCo2SupplyRate = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletLiquidFlowRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletLiquidFlowRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletLiquidFlowRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletLiquidFlowRate = smoother.getSmoothedNumbers(); data = new Matrix(smoothedPressure, 1); data.print(10, 2); @@ -190,7 +190,8 @@ public void calcdPdt() { dNdt[i] = dPdt[i] * 1.0 / dPdn[i]; err += Math.abs((dNdtOld[i] - dNdt[i])); // System.out.println("dndt: " + dNdt[i]); - dnVdt[i] = dNdt[i] * 8.314 * 298.15 / 101325.0 * 1000 * 60; + dnVdt[i] = dNdt[i] * ThermodynamicConstantsInterface.R * 298.15 + / ThermodynamicConstantsInterface.atm * 1000 * 60; System.out.println("dVdt: " + dnVdt[i]); } System.out.println("err: " + err); diff --git a/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java b/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java index 7baa7cc9b1..a936162a8e 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java +++ b/src/main/java/neqsim/statistics/parameterFitting/FunctionInterface.java @@ -22,7 +22,7 @@ public interface FunctionInterface extends Cloneable { * calcValue. *

* - * @param dependentValues an array of {@link double} objects + * @param dependentValues an array of type double * @return a double */ public double calcValue(double[] dependentValues); @@ -69,7 +69,7 @@ public interface FunctionInterface extends Cloneable { * getFittingParams. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getFittingParams(); @@ -87,7 +87,7 @@ public interface FunctionInterface extends Cloneable { * setInitialGuess. *

* - * @param guess an array of {@link double} objects + * @param guess an array of type double */ public void setInitialGuess(double[] guess); @@ -123,7 +123,7 @@ public interface FunctionInterface extends Cloneable { * getBounds. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getBounds(); @@ -152,7 +152,7 @@ public interface FunctionInterface extends Cloneable { * setBounds. *

* - * @param bounds an array of {@link double} objects + * @param bounds an array of type double */ public void setBounds(double[][] bounds); } diff --git a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java index 105f564e38..3707faf178 100644 --- a/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java +++ b/src/main/java/neqsim/statistics/parameterFitting/SampleValue.java @@ -48,7 +48,7 @@ public SampleValue() {} * * @param sampleValue a double * @param standardDeviation a double - * @param dependentValues an array of {@link double} objects + * @param dependentValues an array of type double */ public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues) { this.dependentValues = new double[dependentValues.length]; @@ -64,8 +64,8 @@ public SampleValue(double sampleValue, double standardDeviation, double[] depend * * @param sampleValue a double * @param standardDeviation a double - * @param dependentValues an array of {@link double} objects - * @param standardDeviations an array of {@link double} objects + * @param dependentValues an array of type double + * @param standardDeviations an array of type double */ public SampleValue(double sampleValue, double standardDeviation, double[] dependentValues, double[] standardDeviations) { @@ -165,7 +165,7 @@ public double getSampleValue() { * Getter for the field dependentValues. *

* - * @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 property maxError. + * + * @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 list = new ArrayList(); for (int i = 0; i < system.getPhase(0).getNumberOfComponents(); i++) { double boilpoint = system.getPhase(0).getComponent(i).getNormalBoilingPoint(); - if (boilpoint >= 69.0) { + if (boilpoint >= 273.15 + 69.0) { list.add(system.getPhase(0).getComponent(i).getName()); } } diff --git a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java index ee80b8d32d..f8cdebd8c9 100644 --- a/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java +++ b/src/main/java/neqsim/thermo/characterization/PlusFractionModel.java @@ -227,9 +227,8 @@ public void characterizePlusFraction(TBPModelInterface TBPModel) { z[i] = Math.exp(getCoef(0) + getCoef(1) * i); M[i] = PVTsimMolarMass[i - 6] / 1000.0; dens[i] = getCoef(2) + getCoef(3) * Math.log(i); - - // System.out.println("z,m,dens " + z[i] + " " + M[i] + " " + dens[i]); } + // System.out.println("z,m,dens " + z[i] + " " + M[i] + " " + dens[i]); } @Override @@ -287,6 +286,11 @@ public void setCoefs(double[] coefs) { public void setCoefs(double coef, int i) { this.coefs[i] = coef; } + + @Override + public void setLastPlusFractionNumber(int fract) { + lastPlusFractionNumber = fract + 1; + } } private class PedersenHeavyOilPlusModel extends PedersenPlusModel { @@ -299,6 +303,170 @@ public PedersenHeavyOilPlusModel() { } } + class WhitsonGammaModel extends PedersenPlusModel { + + public double[] zValues; + public double[] molarMasses; + public double[] densities; + public double eta = 90; // minimum molecular weight in C7+ + public String model = "Whitson"; + public double alfa = 1.0; + public double betta = Double.NaN; + + public WhitsonGammaModel() { + name = "Whitson Gamma"; + } + + public void setCalculationModel(String model) { + this.model = model; + } + + public void characterizePlusFractionWhitsonGamma() {} + + public double gamma(double X) { + double[] dataB = {-0.577191652, 0.988205891, -0.897056937, 0.918206857, -0.756704078, + 0.482199394, -0.193527818, 0.035868343}; + double const_ = 1.0; + double XX = X; + if (X < 1.0) { + XX = X + 1.0; + } + while (XX >= 2.0) { + XX -= 1.0; + } + const_ = XX * const_; + XX -= 1.0; + double Y = 1.0; + for (int i = 1; i <= 8; i++) { + Y += dataB[i - 1] * XX * i; + } + double GAMMA = const_ * Y; + if (X < 1.0) { + GAMMA /= X; + } + return GAMMA; + } + + public double[] P0P1(double MWB) { + double P0 = 0.0; + double P1 = 0.0; + if (MWB == eta) { + return new double[] {P0, P1}; + } + double Y = (MWB - eta) / betta; + double Q = Math.exp(-Y) * Math.pow(Y, alfa) / gamma(alfa); + double TERM = 1.0 / alfa; + double S = TERM; + for (int j = 1; j <= 10000; j++) { + TERM *= Y / (alfa + j); + S += TERM; + if (Math.abs(TERM) <= 1e-8) { + P0 = Q * S; + P1 = Q * (S - 1.0 / alfa); + break; + } + } + return new double[] {P0, P1}; + } + + public void densityUOP() { + // Calculates density of the C+ function with Watson or Universal Oil Products + // characterization factor + // Experience has shown, that the method is not very accurate for C20+ + double Kw = 4.5579 * Math.pow(MPlus * 1000, 0.15178) * Math.pow(densPlus, -1.18241); + for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) { + densities[i - 1] = 6.0108 * Math.pow(molarMasses[i - 1], 0.17947) * Math.pow(Kw, -1.18241); + } + } + + @Override + public void characterizePlusFraction(TBPModelInterface TBPModel) { + system.init(0); + double MWBU = Double.NaN; + double MWBL = Double.NaN; + double sumZ = 0.0; + + betta = (MPlus * 1000 - eta) / alfa; + // Implement the Gamma distribution for the plus fraction + zValues = new double[lastPlusFractionNumber]; + molarMasses = new double[lastPlusFractionNumber]; + densities = new double[lastPlusFractionNumber]; + + if (model.equals("Whitson")) { + for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) { + if (i == 1) { + MWBU = eta; + } + MWBL = MWBU; + MWBU = MWBL + 14; + if (i == lastPlusFractionNumber) { + MWBU = 10000.0; + } + double[] P0LP1L = P0P1(MWBL); + double P0L = P0LP1L[0]; + double P1L = P0LP1L[1]; + + double[] P0UP1U = P0P1(MWBU); + double P0U = P0UP1U[0]; + double P1U = P0UP1U[1]; + + double Z = P0U - P0L; + if (Z < 1E-15) { + Z = 1E-15; + } + zValues[i] = Z * zPlus; + double MWAV = eta + alfa * betta * (P1U - P1L) / (P0U - P0L); + molarMasses[i] = MWAV / 1000; + sumZ = sumZ + zValues[i]; + } + densityUOP(); + } + + // Normalize z values to ensure sumZ equals zPlus + for (int i = firstPlusFractionNumber; i < lastPlusFractionNumber; i++) { + zValues[i] *= zPlus / sumZ; + } + } + + public void setGammaParameters(double shape, double minMW) { + this.alfa = shape; + this.eta = minMW; + } + + public double[] getGammaParameters() { + return new double[] {this.alfa, this.eta}; + } + + @Override + public double[] getCoefs() { + return new double[] {alfa, eta}; + } + + @Override + public double getCoef(int i) { + if (i == 0) + return alfa; + if (i == 1) + return eta; + return 0; + } + + @Override + public double[] getZ() { + return zValues; + } + + @Override + public double[] getM() { + return molarMasses; + } + + @Override + public double[] getDens() { + return densities; + } + } + /** *

* 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 field matiascopemanParamsPR. *

* - * @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 field dGfHydrate. *

* - * @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. *

* - * @param dHfHydrate a double - * @param i a int + * @return an array of type double */ - public void setDHfHydrate(double dHfHydrate, int i) { - this.dHfHydrate[i] = dHfHydrate; + public double[] getDHfHydrate() { + return dHfHydrate; } /** *

- * Getter for the field dHfHydrate. + * Setter for the field dHfHydrate. *

* - * @return an array of {@link double} objects + * @param dHfHydrate a double + * @param i a int */ - public double[] getDHfHydrate() { - return dHfHydrate; + public void setDHfHydrate(double dHfHydrate, int i) { + this.dHfHydrate[i] = dHfHydrate; } /** @@ -534,7 +534,7 @@ public double[] getDHfHydrate() { * Setter for the field 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. *

* * @return a {@link java.lang.String} object @@ -1528,7 +1581,7 @@ public default double getLogFugacityCoefficient() { * getSchwartzentruberParams. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getSchwartzentruberParams(); @@ -1547,7 +1600,7 @@ public default double getLogFugacityCoefficient() { * getTwuCoonParams. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getTwuCoonParams(); @@ -1671,7 +1724,7 @@ public default double getLogFugacityCoefficient() { * getMatiascopemanParams. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getMatiascopemanParams(); @@ -1690,7 +1743,7 @@ public default double getLogFugacityCoefficient() { * setMatiascopemanParams. *

* - * @param matiascopemanParams an array of {@link double} objects + * @param matiascopemanParams an array of type double */ public void setMatiascopemanParams(double[] matiascopemanParams); @@ -1861,7 +1914,7 @@ public default double getLogFugacityCoefficient() { * Setter for field 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); ArrayList temp = new ArrayList(); @@ -275,6 +299,14 @@ public double getTemperature() { return temperature; } + /** {@inheritDoc} */ + @Override + public double getTemperature(String unit) { + neqsim.util.unit.TemperatureUnit tempConversion = + new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); + return tempConversion.getValue(unit); + } + /** {@inheritDoc} */ @Override public double getPressure() { @@ -335,7 +367,8 @@ public double getMixGibbsEnergy() { for (int i = 0; i < numberOfComponents; i++) { gmix += getComponent(i).getx() * Math.log(getComponent(i).getx()); } - return getExcessGibbsEnergy() + R * temperature * gmix * numberOfMolesInPhase; + // todo: is this correct? + return R * temperature * numberOfMolesInPhase * getExcessGibbsEnergy() * gmix; } /** {@inheritDoc} */ @@ -370,6 +403,13 @@ public double getZ() { return Z; } + /** {@inheritDoc} */ + @Override + public double getZvolcorr() { + return getPressure("Pa") * getMolarMass() / neqsim.thermo.ThermodynamicConstantsInterface.R + / temperature / getDensity("kg/m3"); + } + /** {@inheritDoc} */ @Override public void setPressure(double pres) { @@ -395,13 +435,7 @@ public neqsim.physicalProperties.physicalPropertySystem.PhysicalPropertiesInterf /** {@inheritDoc} */ @Override - public void init() { - init(numberOfMolesInPhase / beta, numberOfComponents, initType, getType(), beta); - } - - /** {@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 (totalNumberOfMoles <= 0) { throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "init", @@ -410,14 +444,14 @@ public void init(double totalNumberOfMoles, int numberOfComponents, int type, Ph this.beta = beta; numberOfMolesInPhase = beta * totalNumberOfMoles; - if (this.pt != phase) { - setType(phase); + if (this.pt != pt) { + setType(pt); // setPhysicalProperties(physicalPropertyType); } - this.setInitType(type); + this.setInitType(initType); this.numberOfComponents = numberOfComponents; for (int i = 0; i < numberOfComponents; i++) { - componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, type); + componentArray[i].init(temperature, pressure, totalNumberOfMoles, beta, initType); } } @@ -480,13 +514,13 @@ public void initPhysicalProperties(String type) { /** {@inheritDoc} */ @Override public double geta(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'geta'"); } /** {@inheritDoc} */ @Override public double calcA(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcA'"); } /** @@ -503,67 +537,67 @@ public double calcA(PhaseInterface phase, double temperature, double pressure, i */ public double calcA(int comp, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcA'"); } /** {@inheritDoc} */ @Override public double calcAi(int comp, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcAi'"); } /** {@inheritDoc} */ @Override public double calcAiT(int comp, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcAiT'"); } /** {@inheritDoc} */ @Override public double calcAT(int comp, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcAT'"); } /** {@inheritDoc} */ @Override public double calcAij(int compNumb, int j, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'calcAij'"); } /** {@inheritDoc} */ @Override public double getb(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'getb'"); } /** {@inheritDoc} */ @Override public double calcB(PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcB'"); } /** {@inheritDoc} */ @Override public double getg() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'getg'"); } /** {@inheritDoc} */ @Override public double calcBij(int compNumb, int j, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'calcBij'"); } /** {@inheritDoc} */ @Override public double calcBi(int comp, PhaseInterface phase, double temperature, double pressure, int numbcomp) { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'calcBi'"); } /** {@inheritDoc} */ @@ -580,6 +614,29 @@ public double getMolarVolume() { return molarVolume; } + /** {@inheritDoc} */ + @Override + public double getMolarVolume(String unit) { + double conversionFactor = 1.0; + switch (unit) { + case "m3/mol": + conversionFactor = 1.0; + break; + case "cm3/mol": + conversionFactor = 1e6; + break; + case "litre/mol": + conversionFactor = 1000.0; + break; + case "ft3/lbmole": + conversionFactor = 16018.463373960138; + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + return getMolarMass() / getDensity("kg/m3") * conversionFactor; + } + /** {@inheritDoc} */ @Override public int getNumberOfComponents() { @@ -589,13 +646,13 @@ public int getNumberOfComponents() { /** {@inheritDoc} */ @Override public double getA() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'calcAij'"); } /** {@inheritDoc} */ @Override public double getB() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getB'"); } /** @@ -606,19 +663,19 @@ public double getB() { * @return a double */ public double getBi() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getBi'"); } /** {@inheritDoc} */ @Override public double getAT() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getAT'"); } /** {@inheritDoc} */ @Override public double getATT() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getATT'"); } /** @@ -629,7 +686,7 @@ public double getATT() { * @return a double */ public double getAiT() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getAiT'"); } /** {@inheritDoc} */ @@ -659,7 +716,7 @@ public void setComponentArray(ComponentInterface[] components) { /** {@inheritDoc} */ @Override public double calcR() { - double R = 8.314 / getMolarMass(); + double R = ThermodynamicConstantsInterface.R / getMolarMass(); return R; } @@ -667,193 +724,193 @@ public double calcR() { /** {@inheritDoc} */ @Override public double Fn() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'Fn'"); } /** {@inheritDoc} */ @Override public double FT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FT'"); } /** {@inheritDoc} */ @Override public double FV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FV'"); } /** {@inheritDoc} */ @Override public double FD() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FD'"); } /** {@inheritDoc} */ @Override public double FB() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FB'"); } /** {@inheritDoc} */ @Override public double gb() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'gb'"); } /** {@inheritDoc} */ @Override public double fb() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'fb'"); } /** {@inheritDoc} */ @Override public double gV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'gV'"); } /** {@inheritDoc} */ @Override public double fv() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'fv'"); } /** {@inheritDoc} */ @Override public double FnV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FnV'"); } /** {@inheritDoc} */ @Override public double FnB() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FnB'"); } /** {@inheritDoc} */ @Override public double FTT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FTT'"); } /** {@inheritDoc} */ @Override public double FBT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FBT'"); } /** {@inheritDoc} */ @Override public double FDT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FDT'"); } /** {@inheritDoc} */ @Override public double FBV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FBV'"); } /** {@inheritDoc} */ @Override public double FBB() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FBB'"); } /** {@inheritDoc} */ @Override public double FDV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FDV'"); } /** {@inheritDoc} */ @Override public double FBD() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FBD'"); } /** {@inheritDoc} */ @Override public double FTV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FTV'"); } /** {@inheritDoc} */ @Override public double FVV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'FVV'"); } /** {@inheritDoc} */ @Override public double gVV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'gVV'"); } /** {@inheritDoc} */ @Override public double gBV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'gBV'"); } /** {@inheritDoc} */ @Override public double gBB() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'gBB'"); } /** {@inheritDoc} */ @Override public double fVV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'fVV'"); } /** {@inheritDoc} */ @Override public double fBV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'fBV'"); } /** {@inheritDoc} */ @Override public double fBB() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'fBB'"); } /** {@inheritDoc} */ @Override public double dFdT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'dFdT'"); } /** {@inheritDoc} */ @Override public double dFdV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'dFdV'"); } /** {@inheritDoc} */ @Override public double dFdTdV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'dFdTdV'"); } /** {@inheritDoc} */ @Override public double dFdVdV() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'dFdVdV'"); } /** {@inheritDoc} */ @Override public double dFdTdT() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'dFdTdT'"); } /** {@inheritDoc} */ @Override public double getCpres() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'getCpres'"); } /** @@ -864,14 +921,13 @@ public double getCpres() { * @return a double */ public double getCvres() { - return 1; + throw new UnsupportedOperationException("Unimplemented method 'getCvres'"); } /** {@inheritDoc} */ @Override public double getHresTP() { - logger.error("error Hres"); - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getHresTP'"); } /** @@ -882,15 +938,13 @@ public double getHresTP() { * @return a double */ public double getHresdP() { - logger.error(" getHresdP error Hres - not implemented?"); - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getHresdP'"); } /** {@inheritDoc} */ @Override public double getGresTP() { - logger.error("error Gres"); - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getGresTP'"); } /** @@ -901,14 +955,13 @@ public double getGresTP() { * @return a double */ public double getSresTV() { - logger.error("error Hres"); - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getSresTV'"); } /** {@inheritDoc} */ @Override public double getSresTP() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getSresTP'"); } /** {@inheritDoc} */ @@ -962,8 +1015,11 @@ public double getCp(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; - default: + case "btu/lbmole-F": + conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0 * 0.2388; break; + default: + throw new RuntimeException("unit not supported " + unit); } return refCp * conversionFactor; } @@ -992,8 +1048,11 @@ public double getCv(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; - default: + case "btu/lbmole-F": + conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0 * 0.2388; break; + default: + throw new RuntimeException("unit not supported " + unit); } return refCv * conversionFactor; } @@ -1025,6 +1084,7 @@ public double getEnthalpy(String unit) { case "J": conversionFactor = 1.0; break; + case "kJ/kmol": case "J/mol": conversionFactor = 1.0 / getNumberOfMolesInPhase(); break; @@ -1034,8 +1094,14 @@ public double getEnthalpy(String unit) { case "kJ/kg": conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; - default: + case "Btu/lbmol": + conversionFactor = 1.0 / getNumberOfMolesInPhase() * 0.429923; break; + case "Btu": + conversionFactor = 0.00094781712; + break; + default: + throw new RuntimeException("unit not supported " + unit); } return refEnthalpy * conversionFactor; } @@ -1120,8 +1186,11 @@ public double getEntropy(String unit) { case "kJ/kgK": conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0; break; - default: + case "btu/lb-F": + conversionFactor = 1.0 / getNumberOfMolesInPhase() / getMolarMass() / 1000.0 * 0.2388; break; + default: + throw new RuntimeException("unit not supported " + unit); } return refEntropy * conversionFactor; } @@ -1150,6 +1219,7 @@ public double getViscosity(String unit) { double refViscosity = getViscosity(); // viscosity in kg/msec double conversionFactor = 1.0; switch (unit) { + case "Pas": case "kg/msec": conversionFactor = 1.0; break; @@ -1157,7 +1227,7 @@ public double getViscosity(String unit) { conversionFactor = 1.0e3; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refViscosity * conversionFactor; } @@ -1175,39 +1245,17 @@ public double getThermalConductivity(String unit) { 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; - default: - throw new RuntimeException(); - } - return refConductivity * conversionFactor; - } - - /** {@inheritDoc} */ - @Override - @Deprecated - public double getConductivity() { - return getPhysicalProperties().getConductivity(); - } - - /** {@inheritDoc} */ - @Override - @Deprecated - public double getConductivity(String unit) { - double refConductivity = getConductivity(); // conductivity in W/m*K - double conversionFactor = 1.0; - switch (unit) { - case "W/mK": - conversionFactor = 1.0; - break; - case "W/cmK": - conversionFactor = 0.01; + case "Btu/hr-ft-F": + conversionFactor = 0.5781759824; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refConductivity * conversionFactor; } @@ -1226,7 +1274,7 @@ public void initRefPhases(boolean onlyPure) { *

* * @param onlyPure a boolean - * @param name a {@link String} object + * @param name a {@link java.lang.String} object */ public void initRefPhases(boolean onlyPure, String name) { refPhase = new PhaseInterface[numberOfComponents]; @@ -1329,7 +1377,7 @@ public double getLogInfiniteDiluteFugacity(int k, int p) { /** {@inheritDoc} */ @Override public double getLogInfiniteDiluteFugacity(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, @@ -1539,6 +1587,27 @@ public final double getMolarMass() { return tempVar; } + /** {@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 double getJouleThomsonCoefficient(String unit) { @@ -1551,8 +1620,14 @@ public double getJouleThomsonCoefficient(String unit) { case "C/bar": conversionFactor = 1.0; break; - default: + case "K/Pa": + conversionFactor = 1.0e-5; + break; + case "F/psi": + conversionFactor = 1.8 * 1.0 / 14.503773773; break; + default: + throw new RuntimeException("unit not supported " + unit); } return JTcoef * conversionFactor; } @@ -1560,7 +1635,7 @@ public double getJouleThomsonCoefficient(String unit) { /** {@inheritDoc} */ @Override public double getJouleThomsonCoefficient() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getJouleThomsonCoefficient'"); } /** {@inheritDoc} */ @@ -1585,8 +1660,7 @@ public double getDensity(String unit) { conversionFactor = 0.0624279606; break; default: - throw new RuntimeException( - "Could not create conversion factor because molar mass is NULL or 0"); + throw new RuntimeException("unit not supported " + unit); } return refDensity * conversionFactor; } @@ -1600,25 +1674,25 @@ public final double getPhaseFraction() { /** {@inheritDoc} */ @Override public double getdPdrho() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getdPdrho'"); } /** {@inheritDoc} */ @Override public double getdrhodP() { - return 0.0; + throw new UnsupportedOperationException("Unimplemented method 'getdrhodP'"); } /** {@inheritDoc} */ @Override public double getdrhodT() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getdrhodT'"); } /** {@inheritDoc} */ @Override public double getdrhodN() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getdrhodN'"); } /** {@inheritDoc} */ @@ -1692,13 +1766,13 @@ public final double getDiElectricConstant() { /** {@inheritDoc} */ @Override public double getdPdTVn() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getdPdTVn'"); } /** {@inheritDoc} */ @Override public double getdPdVTn() { - return 0; + throw new UnsupportedOperationException("Unimplemented method 'getdPdVTn'"); } /** {@inheritDoc} */ @@ -1763,10 +1837,37 @@ public ComponentInterface getComponent(String name) { /** {@inheritDoc} */ @Override - public boolean hasComponent(String name) { + public String[] getComponentNames() { + ArrayList components = new ArrayList(); + + for (int j = 0; j < componentArray.length; j++) { + if (componentArray[j] != null) { + components.add(componentArray[j].getComponentName()); + } + } + + String[] componentList = new String[components.size()]; + for (int j = 0; j < numberOfComponents; j++) { + componentList[j] = components.get(j); + } + return componentList; + } + + /** {@inheritDoc} */ + @Override + public boolean hasComponent(String name, boolean normalized) { for (int i = 0; i < numberOfComponents; i++) { - if (componentArray[i].getName().equals(name)) { - return true; + if (componentArray != null) { + if (normalized) { + if (componentArray[i].getComponentName() + .equals(ComponentInterface.getComponentNameFromAlias(name))) { + return true; + } + } else { + if (componentArray[i].getName().equals(name)) { + return true; + } + } } } return false; @@ -1858,13 +1959,13 @@ public double getFugacity(String compName) { * groupTBPfractions. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] groupTBPfractions() { double[] TPBfrac = new double[20]; for (int i = 0; i < getNumberOfComponents(); i++) { - double boilpoint = getComponent(i).getNormalBoilingPoint(); + double boilpoint = getComponent(i).getNormalBoilingPoint("C"); if (boilpoint >= 331.0) { TPBfrac[19] += getComponent(i).getx(); @@ -1990,7 +2091,7 @@ public double getVolume(String unit) { conversionFactor = 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return conversionFactor * getVolume() / 1.0e5; } @@ -2043,8 +2144,28 @@ public double getMass() { /** {@inheritDoc} */ @Override - public double getSoundSpeed() { - return 0.0; + public abstract double getSoundSpeed(); + + /** {@inheritDoc} */ + @Override + public double getSoundSpeed(String unit) { + double refVel = getSoundSpeed(); + double conversionFactor = 1.0; + switch (unit) { + case "m/s": + case "m/sec": + conversionFactor = 1.0; + break; + case "km/hr": + conversionFactor = 3.6; + break; + case "ft/sec": + conversionFactor = 3.280839895; + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + return refVel * conversionFactor; } /** {@inheritDoc} */ @@ -2140,16 +2261,26 @@ public double getFlowRate(String flowunit) { return numberOfMolesInPhase * 3600.0; } else if (flowunit.equals("Sm3/sec")) { return numberOfMolesInPhase * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; } else if (flowunit.equals("Sm3/hr")) { return numberOfMolesInPhase * 3600.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; } else if (flowunit.equals("Sm3/day")) { return numberOfMolesInPhase * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; } else if (flowunit.equals("MSm3/day")) { return numberOfMolesInPhase * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0 / 1.0e6; + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm / 1.0e6; + } else if (flowunit.equals("lbmole/hr")) { + return numberOfMolesInPhase * 3600.0 / 1000.0 * 2.205; + } else if (flowunit.equals("lb/hr")) { + return numberOfMolesInPhase * getMolarMass() * 60.0 * 2.20462262; + } else if (flowunit.equals("barrel/day")) { + return numberOfMolesInPhase * getMolarMass() * 60.0 * 2.20462262 * 0.068; } else { throw new RuntimeException("failed.. unit: " + flowunit + " not supported"); } @@ -2160,7 +2291,7 @@ public double getFlowRate(String flowunit) { * Getter for the field thermoPropertyModelName. *

* - * @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. + *

+ * + * @param i a int + * @param j a int + * @return a double + */ + public double getAij(int i, int j) { + return aij[i][j]; + } + /** *

* Setter for the field aij. *

* - * @param alpha an array of {@link double} objects + * @param alpha an array of type double */ public void setAij(double[][] alpha) { for (int i = 0; i < alpha.length; i++) { @@ -114,14 +134,26 @@ public void setAij(double[][] alpha) { * Setter for the field 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. - *

- * - * @param i a int - * @param j a int - * @return a double - */ - public double getAij(int i, int j) { - return aij[i][j]; - } - /** *

* 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. *

* * @param component Component number to change @@ -784,9 +740,9 @@ public default void addMoles(int component, double dn) { * Change the number of moles of component of phase, i.e., 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. + *

+ * + * @return a boolean */ - public void setEmptyFluid(); + public boolean doMultiPhaseCheck(); /** *

- * 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. *

* - * @param componentNames an array of {@link java.lang.String} objects + * @return Beta value */ - public void setComponentNames(String[] componentNames); + public double getBeta(); /** *

- * calc_x_y_nonorm. + * Getter for property beta for a specific phase. *

+ * + * @param phase Number of phase to get beta for. + * @return Beta value for */ - public void calc_x_y_nonorm(); + public double getBeta(int 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. *

* - * @return True if system contains a solid phase + * @return Gets the maximum allowed number of phases to use. */ - public default boolean hasSolidPhase() { - return hasPhaseType(PhaseType.SOLID); // || hasPhaseType(PhaseType.SOLIDCOMPLEX); - } + public int getMaxNumberOfPhases(); /** *

- * 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. *

* - * @param index Component number to add - * @param moles number of moles (per second) of the component to be added to the fluid + * @return a double + * @deprecated Replaced by {@link getTotalNumberOfMoles} */ - public void addComponent(int index, double moles); + @Deprecated + public default double getNumberOfMoles() { + return getTotalNumberOfMoles(); + } /** *

- * 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. *

* - * @param name Name of the component to remove. See NeqSim database for component in the database. + * @return Number of phases used */ - public void removeComponent(String name); + public int getNumberOfPhases(); /** *

- * Getter for property beta. - * - * Gets value for heaviest phase. + * getOilFractionIDs. *

* - * @return Beta value + * @return an array of {@link int} objects */ - public double getBeta(); + public int[] getOilFractionIDs(); /** *

- * Getter for property beta for a specific phase. + * getOilFractionLiquidDensityAt25C. *

* - * @param phase Number of phase to get beta for. - * @return Beta value for + * @return an array of type double */ - public double getBeta(int phase); + public double[] getOilFractionLiquidDensityAt25C(); /** *

- * Setter for property beta. NB! Sets beta = b for first phase and 1-b for second - * phase, not for multiphase systems. + * getOilFractionMolecularMass. *

* - * @param b Beta value to set. + * @return an array of type double */ - public void setBeta(double b); + public double[] getOilFractionMolecularMass(); /** *

- * Setter for property beta for a given phase. + * getOilFractionNormalBoilingPoints. *

* - * @param phase Phase number to set beta for. - * @param b Beta value to set. + * @return an array of type double */ - public void setBeta(int phase, double b); + public double[] getOilFractionNormalBoilingPoints(); /** *

- * Save System object to file. + * Getter for property PC. *

* - * @param name File path to save to. + * @return Critical pressure */ - public void save(String name); + public double getPC(); + + /** + * Get phase number i from SystemInterface object. + * + * @param i Phase number + * @return a {@link neqsim.thermo.phase.PhaseInterface} object + */ + public PhaseInterface getPhase(int i); /** *

- * 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. *

* - * @param index a int - * @param phaseIndex a int + * @param standardName a {@link java.lang.String} object + * @return a {@link neqsim.standards.StandardInterface} object */ - public void setPhaseIndex(int index, int phaseIndex); + public neqsim.standards.StandardInterface getStandard(String standardName); /** *

- * Set phaseArray[phaseIndex] = phase. NB! Transfers the pressure and temperature - * from the currently existing phase object at index numb + * Getter for property TC. *

* - * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @param index Phase index to insert object at + * @return Critical temperature */ - public void setPhase(PhaseInterface phase, int index); + public double getTC(); /** - * method to read pure component and interaction parameters from the NeqSim database and create - * temporary tables with parameters for active fluid. + * method to return temperature. * - * @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) + * @return temperature in unit Kelvin */ - public void createDatabase(boolean reset); + public double getTemperature(); /** *

- * 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. - *

+ * Getter for property 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. *

- * - * @return Critical temperature */ - public double getTC(); + public void reset_x_y(); /** *

- * Getter for property TC. + * resetCharacterisation. *

- * - * @param TC Critical temperature to set */ - public void setTC(double TC); + public void resetCharacterisation(); /** *

- * Getter for property PC. + * resetDatabase. *

- * - * @return Critical pressure */ - public double getPC(); + public void resetDatabase(); /** *

- * Getter for property PC. + * resetPhysicalProperties. *

- * - * @param PC Critical pressure to set */ - public void setPC(double PC); + public void 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. *

* - * @return Number of phases used + * @param id a int */ - public int getNumberOfPhases(); + public void saveFluid(int id); /** *

- * Setter for property numberOfPhases. + * saveFluid. *

* - * @param number Number of phases to use. + * @param id a int + * @param text a {@link java.lang.String} object */ - public void setNumberOfPhases(int number); + public void saveFluid(int id, String text); /** *

- * Getter for property maxNumberOfPhases. + * saveObject. *

* - * @return Gets the maximum allowed number of phases to use. + * @param ID a int + * @param text a {@link java.lang.String} object */ - public int getMaxNumberOfPhases(); + public void saveObject(int ID, String text); /** *

- * Setter for property maxNumberOfPhases. + * saveObjectToFile. *

* - * @param maxNumberOfPhases The maximum allowed number of phases to use. + * @param filePath a {@link java.lang.String} object + * @param fluidName a {@link java.lang.String} object */ - public void setMaxNumberOfPhases(int maxNumberOfPhases); + public void saveObjectToFile(String filePath, String fluidName); /** *

- * 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. - *

+ * Set phase type of all phases. * - * @return Component names in system. + * @param pt PhaseType to set phases as. */ - public String[] getComponentNames(); + public void setAllPhaseType(PhaseType pt); /** *

- * 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. *

* - * @param i Component index - * @return a {@link neqsim.thermo.component.ComponentInterface} object + * @param b Beta value to set. */ - public default ComponentInterface getComponent(int i) { - return getPhase(0).getComponent(i); - } + public void setBeta(double b); /** *

- * clone. + * Setter for property beta for a given phase. *

* - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param phase Phase number to set beta for. + * @param b Beta value to set. */ - public SystemInterface clone(); + public void setBeta(int phase, double b); /** *

- * 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. *

* - * @return a {@link java.lang.String} object + * @param maxNumberOfPhases The maximum allowed number of phases to use. */ - public String getFluidName(); + public void setMaxNumberOfPhases(int 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. *

+ * + * @param number Number of phases to use. */ - public void saveToDataBase(); + public void setNumberOfPhases(int number); /** *

- * 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. *

* - * @return an array of {@link java.lang.String} objects + * @param PC Critical pressure to set */ - public String[][] getResultTable(); + public void setPC(double PC); /** *

- * autoSelectModel. + * Set phaseArray[phaseIndex] = phase. NB! Transfers the pressure and temperature + * from the currently existing phase object at index numb *

* - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object + * @param index Phase index to insert object at */ - public SystemInterface autoSelectModel(); + public void setPhase(PhaseInterface phase, int index); /** *

- * autoSelectMixingRule. + * Indexed setter for property phaseIndex. + * this.phaseIndex[index] = phaseIndex; *

+ * + * @param index a int + * @param phaseIndex a int */ - public void autoSelectMixingRule(); + public void setPhaseIndex(int index, int phaseIndex); /** - * Order phases by density. + * Change the phase type of a given phase. + * + * @param phaseToChange the phase number of the phase to set phase type + * @param pt PhaseType to set */ - public void orderByDensity(); + public void setPhaseType(int phaseToChange, PhaseType pt); /** - *

- * 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 property totalNumberOfMoles. + * 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. - *

+ * method to set the pressure of a fluid (same pressure for all phases). * - * @return a double - * @deprecated Replaced by {@link getTotalNumberOfMoles} + * @param newPressure in specified unit + * @param unit unit can be bar, bara, barg or atm */ - @Deprecated - public default double getNumberOfMoles() { - return getTotalNumberOfMoles(); - } + public void setPressure(double newPressure, String unit); /** *

- * Setter for property totalNumberOfMoles. + * Setter for property solidPhaseCheck. *

* - * @param totalNumberOfMoles Total molar flow rate of fluid in unit mol/sec + * @param test a boolean */ - public void setTotalNumberOfMoles(double totalNumberOfMoles); + public void setSolidPhaseCheck(boolean test); /** *

- * 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. *

* - * @return a {@link neqsim.thermo.system.SystemInterface} object + * @param TC Critical temperature to set */ - public SystemInterface getEmptySystemClone(); + public void setTC(double 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. *

* - * @param implementedPressureDeriativesofFugacity a boolean + * @param totalNumberOfMoles Total molar flow rate of fluid in unit mol/sec */ - public void setImplementedPressureDeriativesofFugacity( - boolean implementedPressureDeriativesofFugacity); + public void setTotalNumberOfMoles(double 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 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 HashMap getProperties() { public Double[] getValues() { return this.values; } - - /** - * Get names of properties. - * - * @return Array of names of properties - */ - public static String[] getPropertyNames() { - SystemProperties p = new SystemProperties(new SystemSrkEos()); - return p.names; - } } diff --git a/src/main/java/neqsim/thermo/system/SystemPsrkEos.java b/src/main/java/neqsim/thermo/system/SystemPsrkEos.java index 4933619c61..9716498992 100644 --- a/src/main/java/neqsim/thermo/system/SystemPsrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemPsrkEos.java @@ -40,8 +40,7 @@ public SystemPsrkEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemPsrkEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 4; modelName = "Predictive-SRK-EOS"; } @@ -56,10 +55,6 @@ public SystemPsrkEos 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/SystemRKEos.java b/src/main/java/neqsim/thermo/system/SystemRKEos.java index 17cc579a9b..148b755387 100644 --- a/src/main/java/neqsim/thermo/system/SystemRKEos.java +++ b/src/main/java/neqsim/thermo/system/SystemRKEos.java @@ -43,8 +43,7 @@ public SystemRKEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemRKEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 5; modelName = "RK-EOS"; diff --git a/src/main/java/neqsim/thermo/system/SystemSrkCPA.java b/src/main/java/neqsim/thermo/system/SystemSrkCPA.java index 92928067ed..acf5c117cf 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkCPA.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkCPA.java @@ -41,11 +41,12 @@ public SystemSrkCPA(double T, double P) { * * @param T The temperature in unit Kelvin * @param P The pressure in unit bara (absolute pressure) - * @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 SystemSrkCPA(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); + + // Recreates phases created in super constructor SystemSrkEos for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkCPA(); phaseArray[i].setTemperature(T); @@ -69,6 +70,16 @@ public SystemSrkCPA(double T, double P, boolean checkForSolids) { } } + /** {@inheritDoc} */ + @Override + public void addComponent(String componentName, double moles) { + // if (componentName.equals("Ca++") || componentName.equals("Na+") || + // componentName.equals("Cl-")) { + // componentName = "NaCl"; + // } + super.addComponent(componentName, moles); + } + /** {@inheritDoc} */ @Override public SystemSrkCPA clone() { @@ -79,10 +90,6 @@ public SystemSrkCPA clone() { logger.error("Cloning failed.", ex); } - // for(int i = 0; i < numberOfPhases; i++) { - // clonedSystem.phaseArray[i] = (PhaseInterface) phaseArray[i].clone(); - // } - return clonedSystem; } @@ -96,14 +103,4 @@ public void commonInitialization() { setImplementedPressureDeriativesofFugacity(true); setImplementedTemperatureDeriativesofFugacity(true); } - - /** {@inheritDoc} */ - @Override - public void addComponent(String componentName, double moles) { - // if (componentName.equals("Ca++") || componentName.equals("Na+") || - // componentName.equals("Cl-")) { - // componentName = "NaCl"; - // } - super.addComponent(componentName, moles); - } } diff --git a/src/main/java/neqsim/thermo/system/SystemSrkCPAs.java b/src/main/java/neqsim/thermo/system/SystemSrkCPAs.java index f13d7816df..6f86bc584d 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkCPAs.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkCPAs.java @@ -44,10 +44,10 @@ public SystemSrkCPAs(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkCPAs(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "CPAs-SRK-EOS"; + // Recreates phases created in super constructor SystemSrkCPA for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkCPAsOld(); phaseArray[i].setTemperature(T); @@ -80,10 +80,6 @@ public SystemSrkCPAs 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/SystemSrkCPAstatoil.java b/src/main/java/neqsim/thermo/system/SystemSrkCPAstatoil.java index 310fb1f4e2..61b653fcb8 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkCPAstatoil.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkCPAstatoil.java @@ -38,10 +38,11 @@ public SystemSrkCPAstatoil(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkCPAstatoil(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "CPAs-SRK-EOS-statoil"; attractiveTermNumber = 15; + + // Recreates phases created in super constructor SystemSrkCPAs for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkCPAs(); phaseArray[i].setTemperature(T); @@ -74,10 +75,6 @@ public SystemSrkCPAstatoil 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/SystemSrkEos.java b/src/main/java/neqsim/thermo/system/SystemSrkEos.java index 3f9e9e0aca..aed2de75d6 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkEos.java @@ -38,8 +38,7 @@ public SystemSrkEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "SRK-EOS"; getCharacterization().setTBPModel("PedersenSRK"); attractiveTermNumber = 0; @@ -76,10 +75,6 @@ public SystemSrkEos 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/SystemSrkMathiasCopeman.java b/src/main/java/neqsim/thermo/system/SystemSrkMathiasCopeman.java index 6b631ec4e3..a2ee47539b 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkMathiasCopeman.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkMathiasCopeman.java @@ -40,8 +40,7 @@ public SystemSrkMathiasCopeman(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkMathiasCopeman(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 4; modelName = "Mathias-Copeman-SRK-EOS"; } @@ -56,10 +55,6 @@ public SystemSrkMathiasCopeman 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/SystemSrkPenelouxEos.java b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java index cb2cbd9c1e..701f961890 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkPenelouxEos.java @@ -38,12 +38,12 @@ public SystemSrkPenelouxEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkPenelouxEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "SRK-Peneloux-EOS"; getCharacterization().setTBPModel("PedersenSRK"); attractiveTermNumber = 0; + // Recreates phases created in super constructor SystemSrkEos for (int i = 0; i < numberOfPhases; i++) { phaseArray[i] = new PhaseSrkPenelouxEos(); phaseArray[i].setTemperature(T); @@ -76,10 +76,6 @@ public SystemSrkPenelouxEos 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/SystemSrkSchwartzentruberEos.java b/src/main/java/neqsim/thermo/system/SystemSrkSchwartzentruberEos.java index 92d7b58394..8372590e29 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkSchwartzentruberEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkSchwartzentruberEos.java @@ -40,8 +40,7 @@ public SystemSrkSchwartzentruberEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkSchwartzentruberEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "ScRK-EOS"; attractiveTermNumber = 2; } @@ -56,10 +55,6 @@ public SystemSrkSchwartzentruberEos 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/SystemSrkTwuCoonEos.java b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonEos.java index 44a70c39d7..12d851c3a5 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonEos.java @@ -40,8 +40,7 @@ public SystemSrkTwuCoonEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkTwuCoonEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "TwuCoonRK-EOS"; attractiveTermNumber = 11; } @@ -56,10 +55,6 @@ public SystemSrkTwuCoonEos 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/SystemSrkTwuCoonParamEos.java b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonParamEos.java index e7310fc8c9..8b3cfd4aa2 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonParamEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonParamEos.java @@ -40,8 +40,7 @@ public SystemSrkTwuCoonParamEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkTwuCoonParamEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "TwuCoonRKparam-EOS"; attractiveTermNumber = 12; } @@ -56,10 +55,6 @@ public SystemSrkTwuCoonParamEos 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/SystemSrkTwuCoonStatoilEos.java b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonStatoilEos.java index f0c2d5479b..92c7283735 100644 --- a/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonStatoilEos.java +++ b/src/main/java/neqsim/thermo/system/SystemSrkTwuCoonStatoilEos.java @@ -41,8 +41,7 @@ public SystemSrkTwuCoonStatoilEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemSrkTwuCoonStatoilEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); modelName = "TwuCoonStatoil-EOS"; attractiveTermNumber = 18; } @@ -57,10 +56,6 @@ public SystemSrkTwuCoonStatoilEos 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/SystemTSTEos.java b/src/main/java/neqsim/thermo/system/SystemTSTEos.java index b10a86714a..2def778082 100644 --- a/src/main/java/neqsim/thermo/system/SystemTSTEos.java +++ b/src/main/java/neqsim/thermo/system/SystemTSTEos.java @@ -46,8 +46,7 @@ public SystemTSTEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemTSTEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 14; modelName = "TST-EOS"; @@ -83,11 +82,6 @@ public SystemTSTEos 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/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index 58fa393a12..3ad573a1f2 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -1,24 +1,15 @@ package neqsim.thermo.system; -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Toolkit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.sql.ResultSet; -import java.text.FieldPosition; import java.util.ArrayList; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.gson.GsonBuilder; import neqsim.chemicalReactions.ChemicalReactionOperations; import neqsim.physicalProperties.interfaceProperties.InterfaceProperties; import neqsim.physicalProperties.interfaceProperties.InterphasePropertiesInterface; @@ -36,109 +27,115 @@ import neqsim.thermo.phase.PhaseSolidComplex; import neqsim.thermo.phase.PhaseType; import neqsim.thermo.phase.PhaseWax; -import neqsim.thermo.phase.StateOfMatter; import neqsim.util.database.NeqSimDataBase; import neqsim.util.exception.InvalidInputException; +import neqsim.util.unit.Units; /** * This is the base class of the System classes. + * + * @author Even Solbraa */ -abstract class SystemThermo implements SystemInterface { - private static final long serialVersionUID = 1000; +public abstract class SystemThermo implements SystemInterface { + /** Logger object for class. */ static Logger logger = LogManager.getLogger(SystemThermo.class); - // Class variables private static final int MAX_PHASES = 6; - // Object metadata - protected String fluidInfo = "No Information Available"; - protected String fluidName = "DefaultName"; - protected String modelName = "Default"; - - // Initialization - boolean isInitialized = false; - protected boolean numericDerivatives = false; - protected int initType = 3; - - private boolean implementedTemperatureDeriativesofFugacity = true; - private boolean implementedPressureDeriativesofFugacity = true; - private boolean implementedCompositionDeriativesofFugacity = true; - protected double criticalTemperature = 0; - protected String[][] resultTable = null; - - protected boolean allowPhaseShift = true; - - private boolean useTVasIndependentVariables = false; - protected double criticalPressure = 0; - private double totalNumberOfMoles = 0; + /** Serialization version UID. */ + private static final long serialVersionUID = 1000; - // TODO: componentNameTag is not working yet, a kind of alias-postfix for Components from this - // system that will be passed on to other systems. used to find originator of specific components - // or - public String componentNameTag = ""; - protected neqsim.thermo.characterization.WaxCharacterise waxCharacterisation = null; protected int a; + protected boolean allowPhaseShift = true; + protected int attractiveTermNumber = 0; - private ArrayList componentNames = new ArrayList(); - // todo: replace numberOfComponents with length of componentNames. - protected int numberOfComponents = 0; - - // protected ArrayList resultArray1 = new ArrayList(); - protected String[] CapeOpenProperties11 = {"molecularWeight", "speedOfSound", - "jouleThomsonCoefficient", "internalEnergy", "internalEnergy.Dtemperature", "gibbsEnergy", - "helmholtzEnergy", "fugacityCoefficient", "logFugacityCoefficient", + // Fraction of moles_in_phase / moles_in_system. + protected double[] beta = new double[MAX_PHASES]; + protected String[] CapeOpenProperties10 = {"molecularWeight", "speedOfSound", + "jouleThomsonCoefficient", "energy", "energy.Dtemperature", "gibbsFreeEnergy", + "helmholtzFreeEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", "logFugacityCoefficient.Dmoles", "enthalpy", "enthalpy.Dmoles", "enthalpy.Dtemperature", "enthalpy.Dpressure", "entropy", "entropy.Dtemperature", "entropy.Dpressure", - "entropy.Dmoles", "heatCapacityCp", "heatCapacityCv", "density", "density.Dtemperature", + "entropy.Dmoles", "heatCapacity", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", "compressibilityFactor"}; - protected String[] CapeOpenProperties10 = {"molecularWeight", "speedOfSound", - "jouleThomsonCoefficient", "energy", "energy.Dtemperature", "gibbsFreeEnergy", - "helmholtzFreeEnergy", "fugacityCoefficient", "logFugacityCoefficient", + // protected ArrayList resultArray1 = new ArrayList(); + protected String[] CapeOpenProperties11 = {"molecularWeight", "speedOfSound", + "jouleThomsonCoefficient", "internalEnergy", "internalEnergy.Dtemperature", "gibbsEnergy", + "helmholtzEnergy", "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", "logFugacityCoefficient.Dpressure", "logFugacityCoefficient.Dmoles", "enthalpy", "enthalpy.Dmoles", "enthalpy.Dtemperature", "enthalpy.Dpressure", "entropy", "entropy.Dtemperature", "entropy.Dpressure", - "entropy.Dmoles", "heatCapacity", "heatCapacityCv", "density", "density.Dtemperature", + "entropy.Dmoles", "heatCapacityCp", "heatCapacityCv", "density", "density.Dtemperature", "density.Dpressure", "density.Dmoles", "volume", "volume.Dpressure", "volume.Dtemperature", "molecularWeight.Dtemperature", "molecularWeight.Dpressure", "molecularWeight.Dmoles", "compressibilityFactor"}; - protected int attractiveTermNumber = 0; - /** Number of phases in use/existing. */ - protected int numberOfPhases = 2; + public neqsim.thermo.characterization.Characterise characterization = null; + protected boolean checkStability = true; + protected ChemicalReactionOperations chemicalReactionOperations = null; + protected boolean chemicalSystem = false; + private ArrayList componentNames = new ArrayList(); + + // TODO: componentNameTag is not working yet, a kind of alias-postfix for + // Components from this + // system that will be passed on to other systems. used to find originator of + // specific components + // or + public String componentNameTag = ""; + + protected double criticalPressure = 0; + protected double criticalTemperature = 0; + // Object metadata + protected String fluidInfo = "No Information Available"; + + protected String fluidName = "DefaultName"; + private boolean forcePhaseTypes = false; + protected boolean hydrateCheck = false; + + private boolean implementedCompositionDeriativesofFugacity = true; + private boolean implementedPressureDeriativesofFugacity = true; + + private boolean implementedTemperatureDeriativesofFugacity = true; + protected int initType = 3; + protected InterphasePropertiesInterface interfaceProp = null; + + // Initialization + boolean isInitialized = false; /** Maximum allowed number of phases . */ public int maxNumberOfPhases = 2; - /** - * Array of indexes to phaseArray keeping track of the creation order of the phases where 0 is the - * first created phase and the lowest number is the phase created last. - */ - protected int[] phaseIndex; + private int mixingRule = 1; + protected String modelName = "Default"; + protected boolean multiPhaseCheck = false; + private boolean multiphaseWaxCheck = false; + + // todo: replace numberOfComponents with length of componentNames. + protected int numberOfComponents = 0; + /** Number of phases in use/existing. */ + protected int numberOfPhases = 2; + protected boolean numericDerivatives = false; + /** * Array containing all phases of System. NB! Phases are reorered according to density, use * phaseIndex to keep track of the creation order. */ protected PhaseInterface[] phaseArray = new PhaseInterface[MAX_PHASES]; + /** + * Array of indexes to phaseArray keeping track of the creation order of the phases where 0 is the + * first created phase and the lowest number is the phase created last. + */ + protected int[] phaseIndex; // PhaseType of phases belonging to system. protected PhaseType[] phaseType = new PhaseType[MAX_PHASES]; - // Fraction of moles_in_phase / moles_in_system. - protected double[] beta = new double[MAX_PHASES]; - - protected ChemicalReactionOperations chemicalReactionOperations = null; - private int mixingRule = 1; - protected boolean chemicalSystem = false; + protected String[][] resultTable = null; protected boolean solidPhaseCheck = false; - protected boolean multiPhaseCheck = false; - protected boolean hydrateCheck = false; - - protected boolean checkStability = true; - public neqsim.thermo.characterization.Characterise characterization = null; protected neqsim.standards.StandardInterface standard = null; - protected InterphasePropertiesInterface interfaceProp = null; - private boolean multiphaseWaxCheck = false; - private boolean forcePhaseTypes = false; + private double totalNumberOfMoles = 0; + private boolean useTVasIndependentVariables = false; + protected neqsim.thermo.characterization.WaxCharacterise waxCharacterisation = null; /** *

@@ -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. - *

- */ - public void addSolidPhase() { - if (!multiPhaseCheck) { - setMultiPhaseCheck(true); - } - phaseArray[3] = new PhasePureComponentSolid(); - phaseArray[3].setTemperature(phaseArray[0].getTemperature()); - phaseArray[3].setPressure(phaseArray[0].getPressure()); - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - phaseArray[3].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); - phaseArray[3].getComponent(i).setIsPlusFraction(true); - } else { - phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); + int index = 0; + + boolean addForFirstTime = true; + for (int p = 0; p < componentNames.size(); p++) { + if (componentNames.get(p).equals(componentName)) { + addForFirstTime = false; + index = p; + break; } } - ((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]); - if (getMaxNumberOfPhases() < 4) { - setMaxNumberOfPhases(4); + if (addForFirstTime) { + if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { + throw new RuntimeException( + new neqsim.util.exception.InvalidInputException(this, "addComponent", "componentName", + "with value " + componentName + " not found in database.")); + } + if (moles < 0.0) { + String msg = "is negative input for component: " + componentName; + throw new RuntimeException( + new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg)); + } + // System.out.println("adding " + componentName); + componentNames.add(componentName); + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + getPhase(i).addComponent(componentName, moles, moles, numberOfComponents); + getPhase(i).setAttractiveTerm(attractiveTermNumber); + } + numberOfComponents++; + } else { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null + && (tmpPhase.getComponent(componentName).getNumberOfMolesInPhase() + moles) < 0.0) { + init(0); + break; + } + } + + // System.out.println("adding chem reac " + componentName); + for (PhaseInterface tmpPhase : phaseArray) { + // TODO: adding moles to all phases, not just the active ones. + if (tmpPhase != null) { + tmpPhase.addMolesChemReac(index, moles, moles); + } + } } + setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); } /** {@inheritDoc} */ @Override - public void addSolidComplexPhase(String type) { - if (!multiPhaseCheck) { - setMultiPhaseCheck(true); - } - addHydratePhase(); - if (type.equalsIgnoreCase("wax")) { - phaseArray[5] = new PhaseWax(); + public void addComponent(String componentName, double moles, double TC, double PC, double acs) { + componentName = ComponentInterface.getComponentNameFromAlias(componentName); + + String comNam = componentName; + if (getPhase(0).hasComponent(componentName)) { + addComponent(componentName, moles); } else { - phaseArray[5] = new PhaseSolidComplex(); + addComponent("default", moles); + comNam = "default"; + // componentNames.set(componentNames.indexOf("default"), componentName); } - - phaseArray[5].setTemperature(phaseArray[0].getTemperature()); - phaseArray[5].setPressure(phaseArray[0].getPressure()); - phaseArray[5].setType(PhaseType.WAX); - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - phaseArray[5].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - phaseArray[5].getComponent(i).setIsPlusFraction(true); - } else { - phaseArray[5].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - } + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + getPhase(i).getComponent(comNam).setComponentName(componentName); + getPhase(i).getComponent(componentName).setTC(TC); + getPhase(i).getComponent(componentName).setPC(PC); + getPhase(i).getComponent(componentName).setAcentricFactor(acs); + } + if (comNam.equals("default")) { + componentNames.remove("default"); + componentNames.add(componentName); } - ((PhaseSolid) phaseArray[5]).setSolidRefFluidPhase(phaseArray[0]); - setNumberOfPhases(6); } - /** - *

- * addHydratePhase. - *

- */ - public void addHydratePhase() { - if (!multiPhaseCheck) { - setMultiPhaseCheck(true); + /** {@inheritDoc} */ + @Override + public void addComponent(String componentName, double moles, int phaseNumber) { + componentName = ComponentInterface.getComponentNameFromAlias(componentName); + + if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { + throw new RuntimeException("No component with name: " + componentName + " in database"); } - if (!hasSolidPhase()) { - phaseArray[3] = new PhasePureComponentSolid(); - phaseArray[3].setTemperature(phaseArray[0].getTemperature()); - phaseArray[3].setPressure(phaseArray[0].getPressure()); - phaseArray[3].setType(PhaseType.SOLID); - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - phaseArray[3].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); - phaseArray[3].getComponent(i).setIsTBPfraction(true); - } else { - phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - } + for (int p = 0; p < componentNames.size(); p++) { + if (componentNames.get(p).equals(componentName)) { + addComponent(p, moles, phaseNumber); + return; } - ((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]); } - phaseArray[4] = new PhaseHydrate(getModelName()); - phaseArray[4].setTemperature(phaseArray[0].getTemperature()); - phaseArray[4].setPressure(phaseArray[0].getPressure()); - phaseArray[4].setType(PhaseType.HYDRATE); - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - phaseArray[4].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - phaseArray[4].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); - phaseArray[4].getComponent(i).setIsTBPfraction(true); - } else { - phaseArray[4].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - } + // Add new component + if (moles < 0.0) { + String msg = "Negative input number of moles."; + neqsim.util.exception.InvalidInputException ex = + new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg); + throw new RuntimeException(ex); } - ((PhaseHydrate) phaseArray[4]).setSolidRefFluidPhase(phaseArray[0]); - setNumberOfPhases(5); - } + componentNames.add(componentName); + double k = 1.0; + setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); - /** - *

- * addHydratePhase2. - *

- */ - public void addHydratePhase2() { - if (!multiPhaseCheck) { - setMultiPhaseCheck(true); - } - phaseArray[3] = new PhaseHydrate(); - phaseArray[3].setTemperature(phaseArray[0].getTemperature()); - phaseArray[3].setPressure(phaseArray[0].getPressure()); - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); - phaseArray[3].getComponent("default") - .setComponentName(getPhase(0).getComponent(i).getName()); + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + if (phaseNumber == i) { + k = 1.0; } else { - phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getNumberOfmoles(), i); + k = 1.0e-30; } + getPhase(i).addComponent(componentName, moles, moles * k, numberOfComponents); + getPhase(i).setAttractiveTerm(attractiveTermNumber); } - setNumberOfPhases(4); + numberOfComponents++; } /** {@inheritDoc} */ @Override - public void setAllComponentsInPhase(int phase) { - for (int k = 0; k < numberOfPhases; k++) { - for (int i = 0; i < numberOfComponents; i++) { - if (phase != k) { - // System.out.println("moles of comp: " + i + " " + - // phaseArray[k].getComponents()[i].getNumberOfMolesInPhase()); - phaseArray[phase].addMoles(i, - (phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() * (1.0 - 0.01))); - phaseArray[k].addMoles(i, - -(phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() * (1.0 - 0.01))); - phaseArray[k].getComponents()[i] - .setx(phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() - / phaseArray[k].getNumberOfMolesInPhase()); - // System.out.println("moles of comp after: " + i + " " + - // phaseArray[k].getComponents()[i].getNumberOfMolesInPhase()); - } - } + public void addComponent(String componentName, double value, String unitName) { + componentName = ComponentInterface.getComponentNameFromAlias(componentName); + + if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { + throw new RuntimeException("No component with name: " + componentName + " in database"); } - initBeta(); - init(1); + + double molarmass = 0.0; + double stddens = 0.0; + double boilp = 0.0; + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { + dataSet.next(); + molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; + stddens = Double.parseDouble(dataSet.getString("stddens")); + boilp = Double.parseDouble(dataSet.getString("normboil")); + } catch (Exception ex) { + // todo: mole amount may be not set. should not be caught? + logger.error("failed ", ex); + } + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); + double SIval = unit.getSIvalue(); + // System.out.println("number of moles " + SIval); + this.addComponent(componentName, SIval); } /** {@inheritDoc} */ @Override - public void removePhase(int specPhase) { - setTotalNumberOfMoles(getTotalNumberOfMoles() - getPhase(specPhase).getNumberOfMolesInPhase()); - - for (int j = 0; j < numberOfPhases; j++) { - for (int i = 0; i < numberOfComponents; i++) { - getPhase(j).getComponents()[i] - .setNumberOfmoles(getPhase(j).getComponents()[i].getNumberOfmoles() - - getPhase(specPhase).getComponents()[i].getNumberOfMolesInPhase()); - } - } + public void addComponent(String componentName, double value, String name, int phase) { + componentName = ComponentInterface.getComponentNameFromAlias(componentName); - ArrayList phaseList = new ArrayList(0); - for (int i = 0; i < numberOfPhases; i++) { - if (specPhase != i) { - phaseList.add(phaseArray[phaseIndex[i]]); - } + if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { + throw new RuntimeException("No component with name: " + componentName + " in database"); } - // phaseArray = new PhaseInterface[numberOfPhases - 1]; - for (int i = 0; i < numberOfPhases - 1; i++) { - // phaseArray[i] = (PhaseInterface) phaseList.get(i); - if (i >= specPhase) { - phaseIndex[i] = phaseIndex[i + 1]; - phaseType[i] = phaseType[i + 1]; - } + double molarmass = 0.0; + double stddens = 0.0; + double boilp = 0.0; + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); + java.sql.ResultSet dataSet = + database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { + dataSet.next(); + molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; + stddens = Double.parseDouble(dataSet.getString("stddens")); + boilp = Double.parseDouble(dataSet.getString("normboil")); + } catch (Exception ex) { + logger.error("failed ", ex); + throw new RuntimeException(ex); } - numberOfPhases--; + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); + double SIval = unit.getSIvalue(); + // System.out.println("number of moles " + SIval); + this.addComponent(componentName, SIval, phase); } /** {@inheritDoc} */ @Override - public void removePhaseKeepTotalComposition(int specPhase) { - ArrayList phaseList = new ArrayList(0); - for (int i = 0; i < numberOfPhases; i++) { - if (specPhase != i) { - phaseList.add(phaseArray[phaseIndex[i]]); + 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(); } - } - // phaseArray = new PhaseInterface[numberOfPhases - 1]; - for (int i = 0; i < numberOfPhases - 1; i++) { - // phaseArray[i] = (PhaseInterface) phaseList.get(i); - if (i >= specPhase) { - phaseIndex[i] = phaseIndex[i + 1]; - phaseType[i] = phaseType[i + 1]; + 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)); + } } } - numberOfPhases--; + if (addedNewComponent) { + createDatabase(true); + setMixingRule(getMixingRule()); + init(0); + } + return this; } /** {@inheritDoc} */ @Override - public void replacePhase(int repPhase, PhaseInterface newPhase) { - for (int i = 0; i < 2; i++) { - phaseArray[i] = newPhase.clone(); + 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); } - setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); + return this; } /** {@inheritDoc} */ @Override - public SystemThermo clone() { - SystemThermo clonedSystem = null; - try { - clonedSystem = (SystemThermo) super.clone(); - // clonedSystem.chemicalReactionOperations = (ChemicalReactionOperations) - // chemicalReactionOperations.clone(); - } catch (Exception ex) { - logger.error("Cloning failed.", ex); + public void addGasToLiquid(double fraction) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + double change = getPhase(0).getComponent(i).getNumberOfMolesInPhase() * fraction; + addComponent(i, -change, 0); + addComponent(i, change, 1); } + } - clonedSystem.beta = beta.clone(); - clonedSystem.attractiveTermNumber = attractiveTermNumber; - clonedSystem.phaseType = phaseType.clone(); - clonedSystem.phaseIndex = phaseIndex.clone(); + /** + *

+ * addHydratePhase. + *

+ */ + public void addHydratePhase() { + if (!multiPhaseCheck) { + setMultiPhaseCheck(true); + } - clonedSystem.componentNames = new ArrayList(componentNames); - if (interfaceProp != null) { - // clonedSystem.interfaceProp = (InterphasePropertiesInterface) - // interfaceProp.clone(); + if (!hasSolidPhase()) { + phaseArray[3] = new PhasePureComponentSolid(); + phaseArray[3].setTemperature(phaseArray[0].getTemperature()); + phaseArray[3].setPressure(phaseArray[0].getPressure()); + phaseArray[3].setType(PhaseType.SOLID); + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + phaseArray[3].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); + phaseArray[3].getComponent(i).setIsTBPfraction(true); + } else { + phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + } + } + ((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]); } - clonedSystem.characterization = characterization.clone(); - if (clonedSystem.waxCharacterisation != null) { - clonedSystem.waxCharacterisation = waxCharacterisation.clone(); + + phaseArray[4] = new PhaseHydrate(getModelName()); + phaseArray[4].setTemperature(phaseArray[0].getTemperature()); + phaseArray[4].setPressure(phaseArray[0].getPressure()); + phaseArray[4].setType(PhaseType.HYDRATE); + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + phaseArray[4].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + phaseArray[4].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); + phaseArray[4].getComponent(i).setIsTBPfraction(true); + } else { + phaseArray[4].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + } } + ((PhaseHydrate) phaseArray[4]).setSolidRefFluidPhase(phaseArray[0]); - System.arraycopy(this.beta, 0, clonedSystem.beta, 0, beta.length); - System.arraycopy(this.phaseType, 0, clonedSystem.phaseType, 0, phaseType.length); - System.arraycopy(this.phaseIndex, 0, clonedSystem.phaseIndex, 0, phaseIndex.length); + setNumberOfPhases(5); + } - clonedSystem.phaseArray = phaseArray.clone(); - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - clonedSystem.phaseArray[i] = phaseArray[i].clone(); + /** + *

+ * addHydratePhase2. + *

+ */ + public void addHydratePhase2() { + if (!multiPhaseCheck) { + setMultiPhaseCheck(true); } - return clonedSystem; + phaseArray[3] = new PhaseHydrate(); + phaseArray[3].setTemperature(phaseArray[0].getTemperature()); + phaseArray[3].setPressure(phaseArray[0].getPressure()); + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + phaseArray[3].getComponent("default") + .setComponentName(getPhase(0).getComponent(i).getName()); + } else { + phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + } + } + setNumberOfPhases(4); } /** {@inheritDoc} */ @Override - public SystemInterface getEmptySystemClone() { - int phaseNumber = 0; - - SystemInterface newSystem = this.clone(); - - for (int j = 0; j < getMaxNumberOfPhases(); j++) { - phaseNumber = j; - for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { - newSystem.getPhase(j).getComponents()[i].setNumberOfmoles( - getPhase(phaseNumber).getComponents()[i].getNumberOfMolesInPhase() / 1.0e30); - newSystem.getPhase(j).getComponents()[i].setNumberOfMolesInPhase( - getPhase(phaseNumber).getComponents()[i].getNumberOfMolesInPhase() / 1.0e30); - } + public void addLiquidToGas(double fraction) { + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + double change = getPhase(1).getComponent(i).getNumberOfMolesInPhase() * fraction; + addComponent(i, change, 0); + addComponent(i, -change, 1); } - - newSystem.setTotalNumberOfMoles(getPhase(phaseNumber).getNumberOfMolesInPhase() / 1.0e30); - - newSystem.init(0); - // newSystem.init(1); - return newSystem; } /** {@inheritDoc} */ @Override - public SystemInterface phaseToSystem(PhaseInterface newPhase) { - // TODO: other phaseToSystem functions returns clones. - for (int i = 0; i < newPhase.getNumberOfComponents(); i++) { - newPhase.getComponents()[i] - .setNumberOfmoles(newPhase.getComponents()[i].getNumberOfMolesInPhase()); - } - - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - phaseArray[i] = newPhase.clone(); - } - - setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); - this.init(0); - setNumberOfPhases(1); - setPhaseType(0, newPhase.getType()); - initBeta(); - init_x_y(); - this.init(1); - return this; + public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity, boolean lastIsPlusFraction) { + addOilFractions(charNames, charFlowrate, molarMass, relativedensity, lastIsPlusFraction, true, + 12); } /** {@inheritDoc} */ @Override - public SystemInterface phaseToSystem(String phaseName) { - try { - for (int j = 0; j < getMaxNumberOfPhases(); j++) { - if (this.getPhase(j).getPhaseTypeName().equals(phaseName)) { - return phaseToSystem(j); - } + public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, + double[] relativedensity, boolean lastIsPlusFraction, boolean lumpComponents, + int numberOfPseudoComponents) { + if (charNames.length != charFlowrate.length) { + logger.error("component names and mole fractions need to be same length..."); + } + + for (int i = 0; i < charNames.length - 1; i++) { + addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } + int i = charNames.length - 1; + if (lastIsPlusFraction) { + addPlusFraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } else { + addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); + } + createDatabase(true); + if (lastIsPlusFraction) { + getCharacterization().getLumpingModel().setNumberOfPseudoComponents(numberOfPseudoComponents); + if (lumpComponents) { + getCharacterization().setLumpingModel("PVTlumpingModel"); + } else { + getCharacterization().setLumpingModel("no lumping"); } - } catch (Exception ex) { - logger.error("error....." + fluidName + " has no phase .... " + phaseName - + " ..... returning phase number 0"); + getCharacterization().characterisePlusFraction(); } - return phaseToSystem(0); + setMixingRule(getMixingRule()); + setMultiPhaseCheck(true); + init(0); } /** {@inheritDoc} */ @Override - public SystemInterface phaseToSystem(int phaseNumber) { - SystemInterface newSystem = this.clone(); + 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++; + } - for (int j = 0; j < getMaxNumberOfPhases(); j++) { - for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { - newSystem.getPhase(j).getComponent(i) - .setNumberOfmoles(getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase()); - newSystem.getPhase(j).getComponent(i).setNumberOfMolesInPhase( - getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase()); - } + /** {@inheritDoc} */ + @Override + public void addPhaseFractionToPhase(double fraction, String specification, String fromPhaseName, + String toPhaseName) { + if (!(hasPhaseType(fromPhaseName) && hasPhaseType(toPhaseName) || fraction < 1e-30)) { + return; } - - newSystem.setTotalNumberOfMoles(getPhase(phaseNumber).getNumberOfMolesInPhase()); - - newSystem.init(0); - newSystem.setNumberOfPhases(1); - newSystem.setPhaseType(0, getPhase(phaseNumber).getType()); // phaseType[phaseNumber]); - newSystem.init(1); - return newSystem; + int phaseNumbFrom = getPhaseNumberOfPhase(fromPhaseName); + int phaseNumbTo = getPhaseNumberOfPhase(toPhaseName); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + double change = getPhase(phaseNumbFrom).getComponent(i).getNumberOfMolesInPhase() * fraction; + addComponent(i, change, phaseNumbTo); + addComponent(i, -change, phaseNumbFrom); + } + init_x_y(); } /** {@inheritDoc} */ @Override - public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2) { - SystemInterface newSystem = this.clone(); - - for (int j = 0; j < getMaxNumberOfPhases(); j++) { - for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { - newSystem.getPhases()[j].getComponents()[i] - .setNumberOfmoles(getPhase(phaseNumber1).getComponents()[i].getNumberOfMolesInPhase() - + getPhase(phaseNumber2).getComponents()[i].getNumberOfMolesInPhase()); - newSystem.getPhases()[j].getComponents()[i].setNumberOfMolesInPhase( - getPhase(phaseNumber1).getComponents()[i].getNumberOfMolesInPhase() - + getPhase(phaseNumber2).getComponents()[i].getNumberOfMolesInPhase()); - } + public void addPhaseFractionToPhase(double fraction, String specification, String specifiedStream, + String fromPhaseName, String toPhaseName) { + double moleFraction = fraction; + if (!hasPhaseType(fromPhaseName) || !hasPhaseType(toPhaseName) || fraction < 1e-30) { + return; } + int phaseNumbFrom = getPhaseNumberOfPhase(fromPhaseName); + int phaseNumbTo = getPhaseNumberOfPhase(toPhaseName); - newSystem.setTotalNumberOfMoles(getPhase(phaseNumber1).getNumberOfMolesInPhase() - + getPhase(phaseNumber2).getNumberOfMolesInPhase()); + if (specifiedStream.equals("feed")) { + moleFraction = fraction; + } else if (specifiedStream.equals("product")) { + // double specFractionFrom = getPhaseFraction(specification, fromPhaseName); + double specFractionTo = getPhaseFraction(specification, toPhaseName); - newSystem.init(0); + double moleFractionFrom = getMoleFraction(phaseNumbFrom); + double moleFractionTo = getMoleFraction(phaseNumbTo); - newSystem.setNumberOfPhases(1); - // newSystem.setPhaseType(0, - // getPhase(phaseNumber1).getType()); //phaseType[phaseNumber]); - newSystem.init(1); - return newSystem; - } + if (specification.equals("volume") || specification.equals("mass")) { + double test = fraction * specFractionTo / (fraction * specFractionTo + specFractionTo); + moleFraction = test * moleFractionTo / specFractionTo; + } else if (specification.equals("mole")) { + double test = fraction * moleFractionTo / (fraction * moleFractionTo + moleFractionTo); + moleFraction = test; + } - /** {@inheritDoc} */ - @Override - public void setTotalFlowRate(double flowRate, String flowunit) { - init(0); - try { - init(1); - } catch (Exception e) { - logger.error(e.getMessage()); - } - double density = 0.0; - if (flowunit.equals("Am3/hr") || flowunit.equals("Am3/min") || flowunit.equals("Am3/sec")) { - initPhysicalProperties("density"); + moleFraction = moleFraction * moleFractionTo / moleFractionFrom; + if (moleFraction > moleFractionFrom) { + logger.debug("error in addPhaseFractionToPhase()...to low fraction in from phase"); + moleFraction = moleFractionFrom; + } } - density = getPhase(0).getDensity("kg/m3"); - if (flowunit.equals("idSm3/hr")) { - density = getIdealLiquidDensity("kg/m3"); - } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); - double SIval = unit.getSIvalue(); - double totalNumberOfMolesLocal = totalNumberOfMoles; - for (int i = 0; i < numberOfComponents; i++) { - if (flowRate < 1e-100) { - setEmptyFluid(); - } else if (totalNumberOfMolesLocal > 1e-100) { - // (SIval / totalNumberOfMolesLocal - 1) * ... - double change = - SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles() - - getPhase(0).getComponent(i).getNumberOfmoles(); - if (Math.abs(change) > 1e-12) { - addComponent(i, change); - } - } else { - addComponent(i, SIval); - } + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + double change = 0.0; + change = getPhase(phaseNumbFrom).getComponent(i).getNumberOfMolesInPhase() * moleFraction; + addComponent(i, change, phaseNumbTo); + addComponent(i, -change, phaseNumbFrom); } + init_x_y(); } /** {@inheritDoc} */ @Override - public double getFlowRate(String flowunit) { - if (flowunit.equals("kg/sec")) { - return totalNumberOfMoles * getMolarMass(); - } else if (flowunit.equals("kg/min")) { - return totalNumberOfMoles * getMolarMass() * 60.0; - } else if (flowunit.equals("kg/hr")) { - return totalNumberOfMoles * getMolarMass() * 3600.0; - } else if (flowunit.equals("kg/day")) { - return totalNumberOfMoles * getMolarMass() * 3600.0 * 24.0; - } else if (flowunit.equals("m3/sec")) { - initPhysicalProperties("density"); - return totalNumberOfMoles * getMolarMass() / getDensity("kg/m3"); - // return getVolume() / 1.0e5; - } else if (flowunit.equals("m3/min")) { - initPhysicalProperties("density"); - return totalNumberOfMoles * getMolarMass() * 60.0 / getDensity("kg/m3"); - // return getVolume() / 1.0e5 * 60.0; - } else if (flowunit.equals("m3/hr")) { - // return getVolume() / 1.0e5 * 3600.0; - initPhysicalProperties("density"); - return totalNumberOfMoles * getMolarMass() * 3600.0 / getDensity("kg/m3"); - } else if (flowunit.equals("idSm3/hr")) { - return totalNumberOfMoles * getMolarMass() * 3600.0 / getIdealLiquidDensity("kg/m3"); - } else if (flowunit.equals("Sm3/sec")) { - return totalNumberOfMoles * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; - } else if (flowunit.equals("Sm3/hr")) { - return totalNumberOfMoles * 3600.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; - } else if (flowunit.equals("Sm3/day")) { - return totalNumberOfMoles * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0; - } else if (flowunit.equals("MSm3/day")) { - return totalNumberOfMoles * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0 / 1.0e6; - } else if (flowunit.equals("MSm3/hr")) { - return totalNumberOfMoles * 3600.0 * ThermodynamicConstantsInterface.R - * ThermodynamicConstantsInterface.standardStateTemperature / 101325.0 / 1.0e6; - } else if (flowunit.equals("mole/sec")) { - return totalNumberOfMoles; - } else if (flowunit.equals("mole/min")) { - return totalNumberOfMoles * 60.0; - } else if (flowunit.equals("mole/hr")) { - return totalNumberOfMoles * 3600.0; - } else { - throw new RuntimeException("failed.. unit: " + flowunit + " not supported"); + public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, + double density) { + addTBPfraction(componentName, numberOfMoles, molarMass, density); + componentName = (componentName + "_" + "PC"); // getFluidName()); + for (int i = 0; i < numberOfPhases; i++) { + // System.out.println("comp " + componentName); + getPhase(i).getComponent(componentName).setIsPlusFraction(true); + getPhase(i).getComponent(componentName).setCriticalViscosity( + 7.94830 * Math.sqrt(1e3 * getPhase(i).getComponent(componentName).getMolarMass()) + * Math.pow(getPhase(i).getComponent(componentName).getPC(), 2.0 / 3.0) + / Math.pow(getPhase(i).getComponent(componentName).getTC(), 1.0 / 6.0) * 1e-7); } } @@ -787,13 +774,76 @@ public void addSalt(String componentName, double value) { /** {@inheritDoc} */ @Override - public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, - double density) { - if (density < 0.0) { - throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, - "addTBPfraction", "density", "is negative.")); + public void addSolidComplexPhase(String type) { + if (!multiPhaseCheck) { + setMultiPhaseCheck(true); } - if (molarMass < 0.0) { + addHydratePhase(); + if (type.equalsIgnoreCase("wax")) { + phaseArray[5] = new PhaseWax(); + } else { + phaseArray[5] = new PhaseSolidComplex(); + } + + phaseArray[5].setTemperature(phaseArray[0].getTemperature()); + phaseArray[5].setPressure(phaseArray[0].getPressure()); + phaseArray[5].setType(PhaseType.WAX); + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + phaseArray[5].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + phaseArray[5].getComponent(i).setIsPlusFraction(true); + } else { + phaseArray[5].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + } + } + ((PhaseSolid) phaseArray[5]).setSolidRefFluidPhase(phaseArray[0]); + setNumberOfPhases(6); + } + + /** + *

+ * addSolidPhase. + *

+ */ + public void addSolidPhase() { + if (!multiPhaseCheck) { + setMultiPhaseCheck(true); + } + phaseArray[3] = new PhasePureComponentSolid(); + phaseArray[3].setTemperature(phaseArray[0].getTemperature()); + phaseArray[3].setPressure(phaseArray[0].getPressure()); + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + phaseArray[3].addComponent("default", getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + phaseArray[3].getComponent(i).setComponentName(getPhase(0).getComponent(i).getName()); + phaseArray[3].getComponent(i).setIsPlusFraction(true); + } else { + phaseArray[3].addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getNumberOfmoles(), i); + } + } + ((PhaseSolid) phaseArray[3]).setSolidRefFluidPhase(phaseArray[0]); + + if (getMaxNumberOfPhases() < 4) { + setMaxNumberOfPhases(4); + } + } + + /** {@inheritDoc} */ + @Override + public void addTBPfraction(String componentName, double numberOfMoles, double molarMass, + double density) { + if (density < 0.0) { + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "addTBPfraction", "density", "is negative.")); + } + if (molarMass < 0.0) { throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "addTBPfraction", "molarMass", "is negative.")); } @@ -811,7 +861,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo try { refSystem = this.getClass().getDeclaredConstructor().newInstance(); refSystem.setTemperature(273.15 + 15.0); - refSystem.setPressure(1.01325); + refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); refSystem.addComponent("default", 1.0, 273.15, 50.0, 0.1); refSystem.init(0); refSystem.setNumberOfPhases(1); @@ -819,14 +869,16 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo molarMass = 1000 * molarMass; TC = characterization.getTBPModel().calcTC(molarMass, density); PC = characterization.getTBPModel().calcPC(molarMass, density); - m = characterization.getTBPModel().calcm(molarMass, density); + if (characterization.getTBPModel().isCalcm()) { + m = characterization.getTBPModel().calcm(molarMass, density); + } acs = characterization.getTBPModel().calcAcentricFactor(molarMass, density); // TBPfractionCoefs[2][0]+TBPfractionCoefs[2][1]*molarMass+TBPfractionCoefs[2][2]*density+TBPfractionCoefs[2][3]*Math.pow(molarMass,2.0); TB = characterization.getTBPModel().calcTB(molarMass, density); // Math.pow((molarMass/5.805e-5*Math.pow(density,0.9371)), 1.0/2.3776); // acs = TBPfractionModel.calcAcentricFactor(molarMass, density); // System.out.println("acentric " + acs); - // 3.0/7.0*Math.log10(PC/1.01325)/(TC/TB-1.0)-1.0; + // 3.0/7.0*Math.log10(PC/ThermodynamicConstantsInterface.referencePressure)/(TC/TB-1.0)-1.0; molarMass /= 1000.0; for (int i = 0; i < refSystem.getNumberOfPhases(); i++) { @@ -844,7 +896,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo } refSystem.setTemperature(273.15 + 15.0); - refSystem.setPressure(1.01325); + refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); refSystem.init(1); // refSystem.display(); racketZ = characterization.getTBPModel().calcRacketZ(refSystem, molarMass * 1000.0, density); @@ -862,7 +914,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo // refSystem.getPhase(1).getComponent(0).setRacketZ(racketZ); // // refSystem.setTemperature(273.15+80.0); - // // refSystem.setPressure(1.01325); + // // refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); // // refSystem.init(1); // //refSystem.initPhysicalProperties(); // // APIdens - refSystem.getPhase(1).getPhysicalProperties().getDensity(); @@ -871,8 +923,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo logger.error(ex.getMessage(), ex); } - double critVol = characterization.getTBPModel().calcCriticalVolume(molarMass * 1000, density); // 0.2918-0.0928* - // acs)*8.314*TC/PC*10.0; + double critVol = characterization.getTBPModel().calcCriticalVolume(molarMass * 1000, density); + // 0.2918-0.0928*acs)*ThermodynamicConstantsInterface.R*TC/PC*10.0; addComponent(componentName, numberOfMoles, TC, PC, acs); double Kwatson = Math.pow(TB * 1.8, 1.0 / 3.0) / density; // System.out.println("watson " + Kwatson); @@ -892,7 +944,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo getPhase(i).getComponent(componentName).setMolarMass(molarMass); getPhase(i).getComponent(componentName).setComponentType("TBPfraction"); getPhase(i).getComponent(componentName).setNormalLiquidDensity(density); - getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB - 273.15); + getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB); getPhase(i).getComponent(componentName) .setAcentricFactor(refSystem.getPhase(0).getComponent(0).getAcentricFactor()); getPhase(i).getComponent(componentName).setCriticalVolume(critVol); @@ -901,7 +953,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo getPhase(i).getComponent(componentName).setIsTBPfraction(true); getPhase(i).getComponent(componentName).setParachorParameter( characterization.getTBPModel().calcParachorParameter(molarMass, density)); // 59.3+2.34*molarMass*1000.0); - // //0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); + // 0.5003*thermo.ThermodynamicConstantsInterface.R*TC/PC*(0.25969-racketZ)); getPhase(i).getComponent(componentName).setCriticalViscosity( characterization.getTBPModel().calcCriticalViscosity(molarMass * 1000.0, density)); // 7.94830*Math.sqrt(1e3*molarMass)*Math.pow(PC,2.0/3.0)/Math.pow(TC, // 1.0/6.0)*1e-7); @@ -953,7 +1005,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo try { refSystem = this.getClass().getDeclaredConstructor().newInstance(); refSystem.setTemperature(273.15 + 15.0); - refSystem.setPressure(1.01325); + refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); refSystem.addComponent("default", 1.0, 273.15, 50.0, 0.1); refSystem.init(0); refSystem.setNumberOfPhases(1); @@ -964,7 +1016,8 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo // characterization.getTBPModel().calcPC(molarMass, density); PC = criticalPressure; m = characterization.getTBPModel().calcm(molarMass, density); - // acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, density); + // acentracentrcharacterization.getTBPModel().calcAcentricFactor(molarMass, + // density); acs = acentricFactor; TB = characterization.getTBPModel().calcTB(molarMass, density); molarMass /= 1000.0; @@ -984,7 +1037,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo } refSystem.setTemperature(273.15 + 15.0); - refSystem.setPressure(1.01325); + refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); refSystem.init(1); // refSystem.display(); racketZ = characterization.getTBPModel().calcRacketZ(refSystem, molarMass * 1000.0, density); @@ -1002,7 +1055,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo // refSystem.getPhase(1).getComponent(0).setRacketZ(racketZ); // // refSystem.setTemperature(273.15+80.0); - // // refSystem.setPressure(1.01325); + // // refSystem.setPressure(ThermodynamicConstantsInterface.referencePressure); // // refSystem.init(1); // // refSystem.initPhysicalProperties(); // // APIdens - refSystem.getPhase(1).getPhysicalProperties().getDensity(); @@ -1012,12 +1065,13 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo } double critVol = characterization.getTBPModel().calcCriticalVolume(molarMass * 1000, density); // 0.2918-0.0928* - // acs)*8.314*TC/PC*10.0; + // acs)*ThermodynamicConstantsInterface.R*TC/PC*10.0; addComponent(componentName, numberOfMoles, TC, PC, acs); double Kwatson = Math.pow(TB * 1.8, 1.0 / 3.0) / density; // System.out.println("watson " + Kwatson); double CF = Math.pow((12.8 - Kwatson) * (10.0 - Kwatson) / (10.0 * acs), 2.0); - // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, density); + // characterization.getTBPModel().calcAcentricFactorKeslerLee(molarMass*1000.0, + // density); double acsKeslerLee = acs; double cpa = (-0.33886 + 0.02827 * Kwatson - 0.26105 * CF + 0.59332 * acsKeslerLee * CF) * 4.18682 * molarMass * 1e3; @@ -1032,7 +1086,7 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo getPhase(i).getComponent(componentName).setMolarMass(molarMass); getPhase(i).getComponent(componentName).setComponentType("TBPfraction"); getPhase(i).getComponent(componentName).setNormalLiquidDensity(density); - getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB - 273.15); + getPhase(i).getComponent(componentName).setNormalBoilingPoint(TB); getPhase(i).getComponent(componentName) .setAcentricFactor(refSystem.getPhase(0).getComponent(0).getAcentricFactor()); getPhase(i).getComponent(componentName).setCriticalVolume(critVol); @@ -1068,280 +1122,158 @@ public void addTBPfraction(String componentName, double numberOfMoles, double mo /** {@inheritDoc} */ @Override - public void addPlusFraction(String componentName, double numberOfMoles, double molarMass, - double density) { - addTBPfraction(componentName, numberOfMoles, molarMass, density); - componentName = (componentName + "_" + "PC"); // getFluidName()); - for (int i = 0; i < numberOfPhases; i++) { - // System.out.println("comp " + componentName); - getPhase(i).getComponent(componentName).setIsPlusFraction(true); - getPhase(i).getComponent(componentName).setCriticalViscosity( - 7.94830 * Math.sqrt(1e3 * getPhase(i).getComponent(componentName).getMolarMass()) - * Math.pow(getPhase(i).getComponent(componentName).getPC(), 2.0 / 3.0) - / Math.pow(getPhase(i).getComponent(componentName).getTC(), 1.0 / 6.0) * 1e-7); + public void addToComponentNames(String postfix) { + for (int j = 0; j < componentNames.size(); j++) { + componentNames.set(j, componentNames.get(j) + postfix); + } + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + for (int j = 0; j < componentNames.size(); j++) { + getPhase(i).getComponent(j) + .setComponentName(getPhase(i).getComponent(j).getComponentName() + postfix); + } } } /** {@inheritDoc} */ @Override - 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()); - } + public boolean allowPhaseShift() { + return allowPhaseShift; } /** {@inheritDoc} */ @Override - public void addComponent(String name) { - addComponent(name, 0.0); + public void allowPhaseShift(boolean allowPhaseShift) { + this.allowPhaseShift = allowPhaseShift; } /** {@inheritDoc} */ @Override - public void addComponent(String componentName, double moles) { - componentName = ComponentInterface.getComponentNameFromAlias(componentName); - - int index = 0; - - boolean addForFirstTime = true; - for (int p = 0; p < componentNames.size(); p++) { - if (componentNames.get(p).equals(componentName)) { - addForFirstTime = false; - index = p; - break; - } + public void autoSelectMixingRule() { + logger.info("setting mixing rule"); + if (modelName.equals("CPAs-SRK-EOS") || modelName.equals("CPA-SRK-EOS") + || modelName.equals("Electrolyte-CPA-EOS-statoil") + || modelName.equals("CPAs-SRK-EOS-statoil") || modelName.equals("Electrolyte-CPA-EOS")) { + this.setMixingRule(10); + // System.out.println("mix rule 10"); + } else if ((modelName.equals("ScRK-EOS-HV") || modelName.equals("SRK-EOS") + || modelName.equals("ScRK-EOS")) && this.getPhase(0).hasComponent("water")) { + this.setMixingRule(4); + } else if (modelName.equals("PR-EOS")) { + this.setMixingRule(2); + } else if (modelName.equals("Electrolyte-ScRK-EOS")) { + this.setMixingRule(4); + } else if (modelName.equals("UMR-PRU-EoS") || modelName.equals("UMR-PRU-MC-EoS")) { + this.setMixingRule("HV", "UNIFAC_UMRPRU"); + } else if (modelName.equals("GERG-water-EOS")) { + this.setMixingRule(8); + } else if (modelName.equals("GERG-2008-EOS")) { + this.setMixingRule(2); + } else if (modelName.equals("PC-SAFT")) { + this.setMixingRule(8); + } else { + this.setMixingRule(2); } + } - if (addForFirstTime) { - if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { - throw new RuntimeException( - new neqsim.util.exception.InvalidInputException(this, "addComponent", "componentName", - "with value " + componentName + " not found in database.")); - } - if (moles < 0.0) { - String msg = "is negative input for component: " + componentName; - throw new RuntimeException( - new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg)); - } - // System.out.println("adding " + componentName); - componentNames.add(componentName); - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - getPhase(i).addComponent(componentName, moles, moles, numberOfComponents); - getPhase(i).setAttractiveTerm(attractiveTermNumber); + /** {@inheritDoc} */ + @Override + public SystemInterface autoSelectModel() { + if (this.getPhase(0).hasComponent("MDEA") && this.getPhase(0).hasComponent("water") + && this.getPhase(0).hasComponent("CO2")) { + return setModel("Electrolyte-ScRK-EOS"); + } else if (this.getPhase(0).hasComponent("water") || this.getPhase(0).hasComponent("methanol") + || this.getPhase(0).hasComponent("MEG") || this.getPhase(0).hasComponent("TEG") + || this.getPhase(0).hasComponent("ethanol") || this.getPhase(0).hasComponent("DEG")) { + if (this.getPhase(0).hasComponent("Na+") || this.getPhase(0).hasComponent("K+") + || this.getPhase(0).hasComponent("Br-") || this.getPhase(0).hasComponent("Mg++") + || this.getPhase(0).hasComponent("Cl-") || this.getPhase(0).hasComponent("Ca++") + || this.getPhase(0).hasComponent("Fe++") || this.getPhase(0).hasComponent("SO4--")) { + logger.info("model elect"); + return setModel("Electrolyte-CPA-EOS-statoil"); + } else { + return setModel("CPAs-SRK-EOS-statoil"); } - numberOfComponents++; + } else if (this.getPhase(0).hasComponent("water")) { + return setModel("ScRK-EOS"); + } else if (this.getPhase(0).hasComponent("mercury")) { + return setModel("SRK-TwuCoon-Statoil-EOS"); } else { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null - && (tmpPhase.getComponent(componentName).getNumberOfMolesInPhase() + moles) < 0.0) { - init(0); - break; - } - } + logger.info("no model"); + return setModel("SRK-EOS"); + } + } - // System.out.println("adding chem reac " + componentName); - for (PhaseInterface tmpPhase : phaseArray) { - // TODO: adding moles to all phases, not just the active ones. - if (tmpPhase != null) { - tmpPhase.addMolesChemReac(index, moles, moles); + /** {@inheritDoc} */ + @Override + public final void calc_x_y() { + for (int j = 0; j < numberOfPhases; j++) { + for (int i = 0; i < numberOfComponents; i++) { + if (j == 0) { + getPhase(j).getComponent(i) + .setx(getPhase(0).getComponent(i).getK() * getPhase(j).getComponents()[i].getz() + / (1 - beta[phaseIndex[0]] + + beta[phaseIndex[0]] * getPhase(0).getComponent(i).getK())); + } else if (j == 1) { + getPhase(j).getComponent(i).setx(getPhase(0).getComponent(i).getz() / (1.0 + - beta[phaseIndex[0]] + beta[phaseIndex[0]] * getPhase(0).getComponent(i).getK())); } + // phaseArray[j].getComponents()[i].setx(phaseArray[0].getComponents()[i].getx() + // / phaseArray[0].getComponents()[i].getK()); + // System.out.println("comp: " + j + i + " " + c[j][i].getx()); } + getPhase(j).normalize(); } - setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); } /** {@inheritDoc} */ @Override - public void addComponent(String componentName, double value, String unitName) { - componentName = ComponentInterface.getComponentNameFromAlias(componentName); - - if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { - throw new RuntimeException("No component with name: " + componentName + " in database"); - } - - double molarmass = 0.0; - double stddens = 0.0; - double boilp = 0.0; - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { - dataSet.next(); - molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; - stddens = Double.parseDouble(dataSet.getString("stddens")); - boilp = Double.parseDouble(dataSet.getString("normboil")); - } catch (Exception ex) { - logger.error("failed ", ex); - } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(value, unitName, molarmass, stddens, boilp); - double SIval = unit.getSIvalue(); - // System.out.println("number of moles " + SIval); - this.addComponent(componentName, SIval); - } - - /** {@inheritDoc} */ - @Override - public void addComponent(String componentName, double moles, double TC, double PC, double acs) { - componentName = ComponentInterface.getComponentNameFromAlias(componentName); - - String comNam = componentName; - if (getPhase(0).hasComponent(componentName)) { - addComponent(componentName, moles); - } else { - addComponent("default", moles); - comNam = "default"; - // componentNames.set(componentNames.indexOf("default"), componentName); - } - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - getPhase(i).getComponent(comNam).setComponentName(componentName); - getPhase(i).getComponent(componentName).setTC(TC); - getPhase(i).getComponent(componentName).setPC(PC); - getPhase(i).getComponent(componentName).setAcentricFactor(acs); - } - if (comNam.equals("default")) { - componentNames.remove("default"); - componentNames.add(componentName); - } - } - - /** {@inheritDoc} */ - @Override - public void addComponent(String componentName, double moles, int phaseNumber) { - componentName = ComponentInterface.getComponentNameFromAlias(componentName); - - if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { - throw new RuntimeException("No component with name: " + componentName + " in database"); - } - - for (int p = 0; p < componentNames.size(); p++) { - if (componentNames.get(p).equals(componentName)) { - addComponent(p, moles, phaseNumber); - return; - } - } - - // Add new component - if (moles < 0.0) { - String msg = "Negative input number of moles."; - neqsim.util.exception.InvalidInputException ex = - new neqsim.util.exception.InvalidInputException(this, "addComponent", "moles", msg); - throw new RuntimeException(ex); - } - - componentNames.add(componentName); - double k = 1.0; - setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); - - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - if (phaseNumber == i) { - k = 1.0; - } else { - k = 1.0e-30; + public final void calc_x_y_nonorm() { + for (int j = 0; j < numberOfPhases; j++) { + for (int i = 0; i < numberOfComponents; i++) { + if (j == 0) { + getPhase(j).getComponents()[i].setx(getPhase(j).getComponents()[i].getK() + * getPhase(j).getComponents()[i].getz() / (1 - beta[phaseIndex[0]] + + beta[phaseIndex[0]] * getPhase(0).getComponents()[i].getK())); + } + if (j == 1) { + getPhase(j).getComponents()[i].setx(getPhase(0).getComponents()[i].getz() / (1.0 + - beta[phaseIndex[0]] + beta[phaseIndex[0]] * getPhase(0).getComponents()[i].getK())); + } + // phaseArray[j].getComponents()[i].setx(phaseArray[0].getComponents()[i].getx() + // / phaseArray[0].getComponents()[i].getK()); + // System.out.println("comp: " + j + i + " " + c[j][i].getx()); } - getPhase(i).addComponent(componentName, moles, moles * k, numberOfComponents); - getPhase(i).setAttractiveTerm(attractiveTermNumber); + // getPhase(j).normalize(); } - numberOfComponents++; } /** {@inheritDoc} */ @Override - public void addComponent(String componentName, double value, String name, int phase) { - componentName = ComponentInterface.getComponentNameFromAlias(componentName); - - if (!neqsim.util.database.NeqSimDataBase.hasComponent(componentName)) { - throw new RuntimeException("No component with name: " + componentName + " in database"); - } - - double molarmass = 0.0; - double stddens = 0.0; - double boilp = 0.0; - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase(); - java.sql.ResultSet dataSet = - database.getResultSet(("SELECT * FROM comp WHERE name='" + componentName + "'"))) { - dataSet.next(); - molarmass = Double.parseDouble(dataSet.getString("molarmass")) / 1000.0; - stddens = Double.parseDouble(dataSet.getString("stddens")); - boilp = Double.parseDouble(dataSet.getString("normboil")); - } catch (Exception ex) { - logger.error("failed ", ex); - throw new RuntimeException(ex); + public double calcHenrysConstant(String component) { + if (numberOfPhases != 2) { + logger.error("Can't calculate Henrys constant - two phases must be present."); + return 0; + } else { + int compNumb = getPhase(getPhaseIndex(0)).getComponent(component).getComponentNumber(); + double hc = getPhase(getPhaseIndex(0)).getFugacity(compNumb) + / getPhase(getPhaseIndex(1)).getComponent(component).getx(); + return hc; } - neqsim.util.unit.Unit unit = - new neqsim.util.unit.RateUnit(value, name, molarmass, stddens, boilp); - double SIval = unit.getSIvalue(); - // System.out.println("number of moles " + SIval); - this.addComponent(componentName, SIval, phase); } /** {@inheritDoc} */ @Override - public void addComponent(int index, double moles) { - if (index >= getPhase(0).getNumberOfComponents()) { - logger.error("componentIndex higher than number of components in system"); - return; - } - - for (PhaseInterface tmpPhase : phaseArray) { - // TODO: adding moles to all phases, not just the active ones. - if (tmpPhase != null) { - tmpPhase.addMolesChemReac(index, moles, moles); - } - } - setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); + public void calcInterfaceProperties() { + interfaceProp.init(); } /** {@inheritDoc} */ @Override - 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; - } - 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); + public void calcKIJ(boolean ok) { + neqsim.thermo.mixingRule.EosMixingRules.calcEOSInteractionParameters = ok; + for (int i = 0; i < numberOfPhases; i++) { + ((PhaseEosInterface) getPhase(i)).getMixingRule().setCalcEOSInteractionParameters(ok); } - - setTotalNumberOfMoles(getTotalNumberOfMoles() + moles); } /** {@inheritDoc} */ @@ -1360,1387 +1292,981 @@ public void changeComponentName(String name, String newName) { /** {@inheritDoc} */ @Override - public void removeComponent(String name) { - name = ComponentInterface.getComponentNameFromAlias(name); - - setTotalNumberOfMoles( - getTotalNumberOfMoles() - phaseArray[0].getComponent(name).getNumberOfmoles()); - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - getPhase(i).removeComponent(name, getTotalNumberOfMoles(), - phaseArray[phaseIndex[i]].getComponent(name).getNumberOfMolesInPhase(), - phaseArray[phaseIndex[i]].getComponent(name).getComponentNumber()); - } - - componentNames.remove(name); - // System.out.println("removing " + componentNames.toString()); - numberOfComponents--; + public boolean checkStability() { + return checkStability; } /** {@inheritDoc} */ @Override - public String[] getComponentNames() { - ArrayList components = new ArrayList(); - - for (int j = 0; j < numberOfComponents; j++) { - components.add(phaseArray[0].getComponents()[j].getName()); - } - String[] componentList = new String[components.size()]; - for (int j = 0; j < numberOfComponents; j++) { - componentList[j] = components.get(j); - } - return componentList; + public void checkStability(boolean val) { + checkStability = val; } /** {@inheritDoc} */ @Override - public void setComponentNames(String[] componentNames) { - for (int i = 0; i < componentNames.length; i++) { - this.componentNames.set(i, componentNames[i]); - } + public void chemicalReactionInit() { + chemicalReactionOperations = new ChemicalReactionOperations(this); + chemicalSystem = chemicalReactionOperations.hasReactions(); } /** {@inheritDoc} */ @Override - public void renameComponent(String oldName, String newName) { - componentNames.set(getPhase(0).getComponent(oldName).getComponentNumber(), newName); - for (int i = 0; i < maxNumberOfPhases; i++) { - getPhase(i).getComponent(oldName).setComponentName(newName); + 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); } } /** {@inheritDoc} */ @Override - public void addToComponentNames(String postfix) { - for (int j = 0; j < componentNames.size(); j++) { - componentNames.set(j, componentNames.get(j) + postfix); + public SystemThermo clone() { + SystemThermo clonedSystem = null; + try { + clonedSystem = (SystemThermo) super.clone(); + // clonedSystem.chemicalReactionOperations = (ChemicalReactionOperations) + // chemicalReactionOperations.clone(); + } catch (Exception ex) { + logger.error("Cloning failed.", ex); + } + + clonedSystem.beta = beta.clone(); + clonedSystem.attractiveTermNumber = attractiveTermNumber; + clonedSystem.phaseType = phaseType.clone(); + clonedSystem.phaseIndex = phaseIndex.clone(); + + clonedSystem.componentNames = new ArrayList(componentNames); + if (interfaceProp != null) { + // clonedSystem.interfaceProp = (InterphasePropertiesInterface) + // interfaceProp.clone(); + } + clonedSystem.characterization = characterization.clone(); + if (clonedSystem.waxCharacterisation != null) { + clonedSystem.waxCharacterisation = waxCharacterisation.clone(); } + + System.arraycopy(this.beta, 0, clonedSystem.beta, 0, beta.length); + System.arraycopy(this.phaseType, 0, clonedSystem.phaseType, 0, phaseType.length); + System.arraycopy(this.phaseIndex, 0, clonedSystem.phaseIndex, 0, phaseIndex.length); + + clonedSystem.phaseArray = phaseArray.clone(); for (int i = 0; i < getMaxNumberOfPhases(); i++) { - for (int j = 0; j < componentNames.size(); j++) { - getPhase(i).getComponent(j) - .setComponentName(getPhase(i).getComponent(j).getComponentName() + postfix); - } + clonedSystem.phaseArray[i] = phaseArray[i].clone(); } - } - /** {@inheritDoc} */ - @Override - public String getComponentNameTag() { - return componentNameTag; + return clonedSystem; } /** {@inheritDoc} */ @Override - public void setComponentNameTag(String nameTag) { - componentNameTag = nameTag; - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - renameComponent(componentNames.get(i), componentNames.get(i) + nameTag); + public void createDatabase(boolean reset) { + if (reset) { + resetDatabase(); } - } - /** {@inheritDoc} */ - @Override - public void setComponentNameTagOnNormalComponents(String nameTag) { - componentNameTag = nameTag; - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - if (!getPhase(0).getComponent(i).isIsTBPfraction() - && !getPhase(0).getComponent(i).isIsPlusFraction()) { - renameComponent(componentNames.get(i), componentNames.get(i) + nameTag); + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { + String names = new String(); + + for (int k = 0; k < getPhase(0).getNumberOfComponents() - 1; k++) { + names += "'" + this.getComponentNames()[k] + "', "; } - } - } + names += "'" + this.getComponentNames()[getPhase(0).getNumberOfComponents() - 1] + "'"; - /** {@inheritDoc} */ - @Override - public void setEmptyFluid() { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) { - tmpPhase.setEmptyFluid(); + if (NeqSimDataBase.createTemporaryTables()) { + database.execute("insert into comptemp SELECT * FROM comp WHERE name IN (" + names + ")"); + database.execute("insert into intertemp SELECT DISTINCT * FROM inter WHERE comp1 IN (" + + names + ") AND comp2 IN (" + names + ")"); + database.execute("delete FROM intertemp WHERE comp1=comp2"); + } + // System.out.println("ok " + names); + + for (int phase = 0; phase < maxNumberOfPhases; phase++) { + getPhase(phase).setMixingRuleDefined(false); + } + + for (int i = 0; i < numberOfComponents; i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction() + || getPhase(0).getComponent(i).isIsPlusFraction()) { + getPhase(0).getComponent(i).insertComponentIntoDatabase(""); + } } + } catch (Exception ex) { + logger.error("error in SystemThermo Class...createDatabase() method", ex); } - totalNumberOfMoles = 0.0; } /** {@inheritDoc} */ @Override - public final double calcBeta() throws neqsim.util.exception.IsNaNException, - neqsim.util.exception.TooManyIterationsException { - ComponentInterface[] compArray = getPhase(0).getComponents(); + public String[][] createTable(String name) { + initProperties(); + java.text.DecimalFormat nf = new java.text.DecimalFormat(); - int i; - double tolerance = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - double deriv = 0.0; - double gbeta = 0.0; - double betal = 0; - double nybeta = 0; + java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + nf.setDecimalFormatSymbols(symbols); - double midler = 0; - double minBeta = tolerance; - double maxBeta = 1.0 - tolerance; - double g0 = -1.0; - double g1 = 1.0; - nybeta = this.beta[0]; - betal = 1.0 - nybeta; + nf.setMaximumFractionDigits(5); + nf.applyPattern("#.#####E0"); - for (i = 0; i < numberOfComponents; 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; + // 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(); //""; + + for (int i = 0; i < getPhases()[0].getNumberOfComponents() + 30; i++) { + for (int j = 0; j < 7; j++) { + table[i][j] = ""; } - 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]; + table[0][1] = "total"; + for (int i = 0; i < numberOfPhases; i++) { + table[0][i + 2] = getPhase(i).getType().toString(); } - if (g1 > 0) { - this.beta[1] = tolerance; - this.beta[0] = 1.0 - tolerance; - return this.beta[0]; + + StringBuffer buf = new StringBuffer(); + java.text.FieldPosition test = new java.text.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(); } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 4][1] = + nf.format(getMolarMass(Units.getSymbol("Molar Mass")), buf, test).toString(); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 9][1] = + nf.format(getEnthalpy(Units.getSymbol("enthalpy")), buf, test).toString(); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 10][1] = + nf.format(getEntropy(Units.getSymbol("entropy")), buf, test).toString(); - nybeta = (minBeta + maxBeta) / 2.0; - // System.out.println("guessed beta: " + nybeta + " maxbeta: " +maxBeta + " - // minbeta: " +minBeta ); - betal = 1.0 - nybeta; + 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]"; + } - // ' *l = 1.0-nybeta; - double gtest = 0.0; - for (i = 0; i < numberOfComponents; i++) { - gtest += compArray[i].getz() * (compArray[i].getK() - 1.0) - / (1.0 - nybeta + nybeta * compArray[i].getK()); // beta - // = - // nybeta - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 2][0] = "Density"; + table[getPhases()[0].getNumberOfComponents() + 2][i + 2] = + nf.format(getPhase(i).getDensity(Units.activeUnits.get("density").symbol), buf, test) + .toString(); + table[getPhases()[0].getNumberOfComponents() + 2][6] = + Units.activeUnits.get("density").symbol; - if (gtest >= 0) { - minBeta = nybeta; - } else { - maxBeta = nybeta; - } + // Double.longValue(system.getPhase(i).getBeta()); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 3][0] = "Phase Fraction"; + table[getPhases()[0].getNumberOfComponents() + 3][i + 2] = + nf.format(getPhase(i).getBeta(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 3][6] = "[mole fraction]"; - if (gtest < 0) { - double minold = minBeta; - minBeta = 1.0 - maxBeta; - maxBeta = 1.0 - minold; - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 4][0] = "Molar Mass"; + table[getPhases()[0].getNumberOfComponents() + 4][i + 2] = + nf.format(getPhase(i).getMolarMass(Units.activeUnits.get("Molar Mass").symbol), buf, test) + .toString(); + table[getPhases()[0].getNumberOfComponents() + 4][6] = + Units.activeUnits.get("Molar Mass").symbol; - int iterations = 0; - int maxIterations = 300; - // System.out.println("gtest: " + gtest); - double step = 1.0; - do { - iterations++; - if (gtest >= 0) { - // oldbeta = nybeta; - deriv = 0.0; - gbeta = 0.0; - - for (i = 0; i < numberOfComponents; 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); - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 5][0] = "Z factor"; + table[getPhases()[0].getNumberOfComponents() + 5][i + 2] = + nf.format(getPhase(i).getZvolcorr(), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 5][6] = "[-]"; - if (gbeta >= 0) { - minBeta = nybeta; - } else { - maxBeta = nybeta; - } - nybeta -= (gbeta / deriv); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 6][0] = "Heat Capacity (Cp)"; + table[getPhases()[0].getNumberOfComponents() + 6][i + 2] = + nf.format((getPhase(i).getCp(Units.activeUnits.get("Heat Capacity (Cp)").symbol)), buf, + test).toString(); + table[getPhases()[0].getNumberOfComponents() + 6][6] = + Units.activeUnits.get("Heat Capacity (Cp)").symbol; - // System.out.println("beta: " + maxBeta); - if (nybeta > maxBeta) { - nybeta = maxBeta; - } - if (nybeta < minBeta) { - nybeta = minBeta; - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 7][0] = "Heat Capacity (Cv)"; + table[getPhases()[0].getNumberOfComponents() + 7][i + 2] = + nf.format((getPhase(i).getCv(Units.activeUnits.get("Heat Capacity (Cv)").symbol)), buf, + test).toString(); + table[getPhases()[0].getNumberOfComponents() + 7][6] = + Units.activeUnits.get("Heat Capacity (Cv)").symbol; - /* - * if ((nybeta > maxBeta) || (nybeta < minBeta)) { // nybeta = 0.5 * (maxBeta + minBeta); - * gbeta = 1.0; } - */ - } else { - // oldbeta = betal; - deriv = 0.0; - gbeta = 0.0; - - for (i = 0; i < numberOfComponents; 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()); - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 8][0] = "Speed of Sound"; + table[getPhases()[0].getNumberOfComponents() + 8][i + 2] = + nf.format((getPhase(i).getSoundSpeed(Units.getSymbol("speed of sound"))), buf, test) + .toString(); + table[getPhases()[0].getNumberOfComponents() + 8][6] = Units.getSymbol("speed of sound"); - if (gbeta < 0) { - minBeta = betal; - } else { - maxBeta = betal; - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 9][0] = "Enthalpy"; + table[getPhases()[0].getNumberOfComponents() + 9][i + 2] = + nf.format((getPhase(i).getEnthalpy(Units.getSymbol("enthalpy"))), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 9][6] = Units.getSymbol("enthalpy"); - betal -= (gbeta / deriv); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 10][0] = "Entropy"; + table[getPhases()[0].getNumberOfComponents() + 10][i + 2] = + nf.format((getPhase(i).getEntropy(Units.getSymbol("entropy"))), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 10][6] = Units.getSymbol("entropy"); - if (betal > maxBeta) { - betal = maxBeta; - } - if (betal < minBeta) { - betal = minBeta; - } + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 11][0] = "JT coefficient"; + table[getPhases()[0].getNumberOfComponents() + 11][i + 2] = + nf.format((getPhase(i).getJouleThomsonCoefficient(Units.getSymbol("JT coefficient"))), + buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 11][6] = Units.getSymbol("JT coefficient"); + + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 13][0] = "Viscosity"; + table[getPhases()[0].getNumberOfComponents() + 13][i + 2] = + nf.format((getPhase(i).getViscosity(Units.getSymbol("viscosity"))), buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 13][6] = Units.getSymbol("viscosity"); - /* - * if ((betal > maxBeta) || (betal < minBeta)) { gbeta = 1.0; { betal = 0.5 * (maxBeta + - * minBeta); } } - */ - nybeta = 1.0 - betal; + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 14][0] = "Thermal Conductivity"; + table[getPhases()[0].getNumberOfComponents() + 14][i + 2] = + nf.format(getPhase(i).getThermalConductivity(Units.getSymbol("thermal conductivity")), + buf, test).toString(); + table[getPhases()[0].getNumberOfComponents() + 14][6] = + Units.getSymbol("thermal conductivity"); + + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 15][0] = "Surface Tension"; + 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); } - step = gbeta / deriv; - // System.out.println("step : " + step); - } while (Math.abs(step) >= 1.0e-10 && iterations < maxIterations); // && - // (Math.abs(nybeta)-Math.abs(maxBeta))>0.1); - - // System.out.println("beta: " + nybeta + " iterations: " + iterations); - 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 + table[getPhases()[0].getNumberOfComponents() + 15][6] = "[N/m]"; - this.beta[0] = nybeta; - this.beta[1] = 1.0 - nybeta; + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 19][0] = "Pressure"; + table[getPhases()[0].getNumberOfComponents() + 19][i + 2] = + Double.toString(getPhase(i).getPressure(Units.getSymbol("pressure"))); + table[getPhases()[0].getNumberOfComponents() + 19][6] = Units.getSymbol("pressure"); - 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"); + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 20][0] = "Temperature"; + table[getPhases()[0].getNumberOfComponents() + 20][i + 2] = + Double.toString(getPhase(i).getTemperature(Units.getSymbol("temperature"))); + table[getPhases()[0].getNumberOfComponents() + 20][6] = Units.getSymbol("temperature"); + Double.toString(getPhase(i).getTemperature()); + + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 22][0] = "Model"; + table[getPhases()[0].getNumberOfComponents() + 22][i + 2] = getModelName(); + table[getPhases()[0].getNumberOfComponents() + 22][6] = "-"; + + 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); + } + table[getPhases()[0].getNumberOfComponents() + 23][6] = "-"; + + buf = new StringBuffer(); + table[getPhases()[0].getNumberOfComponents() + 25][0] = "Stream"; + table[getPhases()[0].getNumberOfComponents() + 25][i + 2] = name; + table[getPhases()[0].getNumberOfComponents() + 25][6] = "-"; } - return this.beta[0]; + + resultTable = table; + return table; } /** {@inheritDoc} */ @Override - public final void initBeta() { - for (int i = 0; i < numberOfPhases; i++) { - this.beta[phaseIndex[i]] = getPhase(i).getNumberOfMolesInPhase() / getTotalNumberOfMoles(); - } - if (this.getSumBeta() < 1.0 - ThermodynamicModelSettings.phaseFractionMinimumLimit - || this.getSumBeta() > 1.0 + ThermodynamicModelSettings.phaseFractionMinimumLimit) { - logger.warn("SystemThermo:initBeta - Sum of beta does not equal 1.0"); + public void deleteFluidPhase(int phase) { + for (int i = phase; i < numberOfPhases; i++) { + phaseIndex[i] = phaseIndex[i + 1]; } + numberOfPhases--; } /** {@inheritDoc} */ @Override - public double getJouleThomsonCoefficient(String unit) { - double JTcoef = getJouleThomsonCoefficient(); - double conversionFactor = 1.0; - switch (unit) { - case "K/bar": - conversionFactor = 1.0; - break; - case "C/bar": - conversionFactor = 1.0; - break; - default: - break; + public void display(String name) { + if (this.getNumberOfComponents() == 0) { + return; } - return JTcoef * conversionFactor; + javax.swing.JFrame dialog = new javax.swing.JFrame("System-Report"); + java.awt.Dimension screenDimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + java.awt.Container dialogContentPane = dialog.getContentPane(); + dialogContentPane.setLayout(new java.awt.BorderLayout()); + + String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit"}; + String[][] table = createTable(name); + javax.swing.JTable Jtab = new javax.swing.JTable(table, names); + javax.swing.JScrollPane scrollpane = new javax.swing.JScrollPane(Jtab); + dialogContentPane.add(scrollpane); + + // setting the size of the frame and text size + dialog.setSize(screenDimension.width / 2, screenDimension.height / 2); // pack(); + Jtab.setRowHeight(dialog.getHeight() / table.length); + Jtab.setFont(new java.awt.Font("Serif", java.awt.Font.PLAIN, + dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10)); + + // dialog.pack(); + dialog.setVisible(true); } /** {@inheritDoc} */ @Override - public double getJouleThomsonCoefficient() { - double JTcoef = 0; - for (int i = 0; i < numberOfPhases; i++) { - JTcoef += getBeta(i) * getPhase(i).getJouleThomsonCoefficient(); - } - return JTcoef; + public boolean doMultiPhaseCheck() { + return multiPhaseCheck; } /** {@inheritDoc} */ @Override - public double getSoundSpeed(String unit) { - double refVel = getSoundSpeed(); - double conversionFactor = 1.0; - switch (unit) { - case "m/s": - conversionFactor = 1.0; - break; - case "km/hr": - conversionFactor = 3.6; - break; - default: - break; - } - return refVel * conversionFactor; + public final boolean doSolidPhaseCheck() { + return solidPhaseCheck; + } + + /** + *

+ * getAntoineVaporPressure. + *

+ * + * @param temp a double + * @return a double + */ + public double getAntoineVaporPressure(double temp) { + return phaseArray[0].getAntoineVaporPressure(temp); } /** {@inheritDoc} */ @Override - public double getSoundSpeed() { - double soundspeed = 0; - for (int i = 0; i < numberOfPhases; i++) { - soundspeed += getBeta(i) * getPhase(i).getSoundSpeed(); - } - return soundspeed; + public final double getBeta() { + return beta[0]; } /** {@inheritDoc} */ @Override - public final void initTotalNumberOfMoles(double change) { - setTotalNumberOfMoles(getTotalNumberOfMoles() + change); - // System.out.println("total moles: " + totalNumberOfMoles); - for (int j = 0; j < numberOfPhases; j++) { - for (int i = 0; i < numberOfComponents; i++) { - getPhase(j).getComponents()[i] - .setNumberOfmoles(phaseArray[phaseIndex[0]].getComponents()[i].getNumberOfmoles()); - } - } + public final double getBeta(int phase) { + return beta[phaseIndex[phase]]; } /** {@inheritDoc} */ @Override - public final void init_x_y() { - // double x, z; - for (int j = 0; j < numberOfPhases; j++) { - // x = 0; - // z = 0; - for (int i = 0; i < numberOfComponents; i++) { - getPhase(j).getComponents()[i] - .setz(getPhase(j).getComponents()[i].getNumberOfmoles() / getTotalNumberOfMoles()); - getPhase(j).getComponents()[i].setx(getPhase(j).getComponents()[i].getNumberOfMolesInPhase() - / getPhase(j).getNumberOfMolesInPhase()); - } - getPhase(j).normalize(); - } + public String[] getCapeOpenProperties10() { + return CapeOpenProperties10; } /** {@inheritDoc} */ @Override - public final void calc_x_y() { - for (int j = 0; j < numberOfPhases; j++) { - for (int i = 0; i < numberOfComponents; i++) { - if (j == 0) { - getPhase(j).getComponent(i) - .setx(getPhase(0).getComponent(i).getK() * getPhase(j).getComponents()[i].getz() - / (1 - beta[phaseIndex[0]] - + beta[phaseIndex[0]] * getPhase(0).getComponent(i).getK())); - } else if (j == 1) { - getPhase(j).getComponent(i).setx(getPhase(0).getComponent(i).getz() / (1.0 - - beta[phaseIndex[0]] + beta[phaseIndex[0]] * getPhase(0).getComponent(i).getK())); - } - // phaseArray[j].getComponents()[i].setx(phaseArray[0].getComponents()[i].getx() - // / phaseArray[0].getComponents()[i].getK()); - // System.out.println("comp: " + j + i + " " + c[j][i].getx()); - } - getPhase(j).normalize(); - } + public String[] getCapeOpenProperties11() { + return CapeOpenProperties11; } /** {@inheritDoc} */ @Override - public final void calc_x_y_nonorm() { - for (int j = 0; j < numberOfPhases; j++) { - for (int i = 0; i < numberOfComponents; i++) { - if (j == 0) { - getPhase(j).getComponents()[i].setx(getPhase(j).getComponents()[i].getK() - * getPhase(j).getComponents()[i].getz() / (1 - beta[phaseIndex[0]] - + beta[phaseIndex[0]] * getPhase(0).getComponents()[i].getK())); - } - if (j == 1) { - getPhase(j).getComponents()[i].setx(getPhase(0).getComponents()[i].getz() / (1.0 - - beta[phaseIndex[0]] + beta[phaseIndex[0]] * getPhase(0).getComponents()[i].getK())); - } - // phaseArray[j].getComponents()[i].setx(phaseArray[0].getComponents()[i].getx() - // / phaseArray[0].getComponents()[i].getK()); - // System.out.println("comp: " + j + i + " " + c[j][i].getx()); - } - // getPhase(j).normalize(); + public String[] getCASNumbers() { + String[] names = new String[numberOfComponents]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + names[compNumb] = getPhase(0).getComponent(compNumb).getCASnumber(); } + return names; } /** {@inheritDoc} */ @Override - public void reset_x_y() { - for (int j = 0; j < numberOfPhases; j++) { - for (int i = 0; i < numberOfComponents; i++) { - getPhase(j).getComponents()[i].setx(phaseArray[phaseIndex[0]].getComponents()[i].getz()); - } - } + public neqsim.thermo.characterization.Characterise getCharacterization() { + return characterization; } /** {@inheritDoc} */ @Override - public void reset() { - for (int i = 0; i < numberOfComponents; i++) { - // TODO: numeric issue, nearly zero - addComponent(getPhase(0).getComponent(i).getComponentName(), - -getPhase(0).getComponent(i).getNumberOfmoles()); - } + public ChemicalReactionOperations getChemicalReactionOperations() { + return chemicalReactionOperations; } /** {@inheritDoc} */ @Override - public void init(int type) { - if (!isInitialized) { - initBeta(); - init_x_y(); - } - if (this.numericDerivatives) { - initNumeric(type); - } else { - initAnalytic(type); + public String[] getCompFormulaes() { + String[] formula = new String[numberOfComponents]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + formula[compNumb] = getPhase(0).getComponent(compNumb).getFormulae(); } + return formula; } /** {@inheritDoc} */ @Override - public void init(int type, int phase) { - if (this.numericDerivatives) { - initNumeric(type, phase); - } else { - initAnalytic(type, phase); + public String[] getCompIDs() { + String[] ids = new String[numberOfComponents]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + ids[compNumb] = Integer.toString(getPhase(0).getComponent(compNumb).getIndex()); } + return ids; } - /** - *

- * initAnalytic. - *

- * - * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P derivatives, 3 to - * calculate all derivatives and 4 to calculate all derivatives numerically - */ - public void initAnalytic(int type) { - - if (type == 0) { - reInitPhaseInformation(); - - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - if (isPhase(i)) { - getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, type, - phaseType[phaseIndex[i]], beta[phaseIndex[i]]); - } - } - setNumberOfPhases(2); - } else if (type == 1) { - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 1, phaseType[phaseIndex[i]], - beta[phaseIndex[i]]); - } - } - - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - for (int j = 0; j < numberOfComponents; j++) { - getPhase(i).getComponents()[j].fugcoef(getPhase(i)); - } - } - } - } else if (type == 2) { // calculate T and P derivatives - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 2, phaseType[phaseIndex[i]], - beta[phaseIndex[i]]); - } - } - - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - for (int j = 0; j < numberOfComponents; j++) { - getPhase(i).getComponents()[j].fugcoef(getPhase(i)); - getPhase(i).getComponents()[j].logfugcoefdT(getPhase(i)); - getPhase(i).getComponents()[j].logfugcoefdP(getPhase(i)); - } - } - } - } else if (type == 3) { // calculate all derivatives - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 3, phaseType[phaseIndex[i]], - beta[phaseIndex[i]]); - } - } + /** {@inheritDoc} */ + @Override + public String[] getCompNames() { + String[] names = new String[numberOfComponents]; - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - for (int j = 0; j < numberOfComponents; j++) { - getPhase(i).getComponents()[j].fugcoef(getPhase(i)); - getPhase(i).getComponents()[j].logfugcoefdT(getPhase(i)); - getPhase(i).getComponents()[j].logfugcoefdP(getPhase(i)); - getPhase(i).getComponents()[j].logfugcoefdN(getPhase(i)); - } - } - } - } else if (type == 4) { // calculate all derivatives numerically - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, 3, phaseType[phaseIndex[i]], - beta[phaseIndex[i]]); - } - } - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - for (int j = 0; j < numberOfComponents; j++) { - getPhase(i).getComponents()[j].fugcoef(getPhase(i)); - getPhase(i).getComponents()[j].fugcoefDiffTempNumeric(getPhase(i), numberOfComponents, - getPhase(i).getTemperature(), getPhase(i).getPressure()); - getPhase(i).getComponents()[j].fugcoefDiffPresNumeric(getPhase(i), numberOfComponents, - getPhase(i).getTemperature(), getPhase(i).getPressure()); - } - } - } + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + names[compNumb] = getPhase(0).getComponent(compNumb).getComponentName(); } + return names; + } - for (int i = 1; i < numberOfPhases; i++) { - if (isPhase(i)) { - if (getPhase(i).getType() == PhaseType.GAS) { - getPhase(i).setType(PhaseType.OIL); - } - } - } - this.isInitialized = true; + /** {@inheritDoc} */ + @Override + public String getComponentNameTag() { + return componentNameTag; } /** + * {@inheritDoc} + * *

- * initAnalytic. + * need to call initPhysicalProperties() before this method is called *

- * - * @param type a int - * @param phase a int */ - public void initAnalytic(int type, int phase) { - if (type == 0) { - beta[0] = 1.0; - phaseIndex[phase] = phase; + @Override + public double getCorrectedVolume() { + double volume = 0; + for (int i = 0; i < numberOfPhases; i++) { + volume += getPhase(i).getMolarMass() / getPhase(i).getPhysicalProperties().getDensity() + * getPhase(i).getNumberOfMolesInPhase(); } + return volume; + } - if (isPhase(phase)) { - if (type == 0) { - getPhase(phase).init(getTotalNumberOfMoles(), numberOfComponents, 0, - phaseType[phaseIndex[phase]], beta[phaseIndex[phase]]); - } else if (type == 1) { - getPhase(phase).init(getTotalNumberOfMoles(), numberOfComponents, 1, - phaseType[phaseIndex[phase]], beta[phaseIndex[phase]]); - - for (int j = 0; j < numberOfComponents; j++) { - getPhase(phase).getComponents()[j].fugcoef(getPhase(phase)); - } - } else if (type == 2) { - getPhase(phase).init(getTotalNumberOfMoles(), numberOfComponents, 2, - phaseType[phaseIndex[phase]], beta[phaseIndex[phase]]); - - for (int j = 0; j < numberOfComponents; j++) { - getPhase(phase).getComponents()[j].fugcoef(getPhase(phase)); - getPhase(phase).getComponents()[j].logfugcoefdT(getPhase(phase)); - getPhase(phase).getComponents()[j].logfugcoefdP(getPhase(phase)); - } - } else if (type == 3) { - getPhase(phase).init(getTotalNumberOfMoles(), numberOfComponents, 3, - phaseType[phaseIndex[phase]], beta[phaseIndex[phase]]); - - for (int j = 0; j < numberOfComponents; j++) { - getPhase(phase).getComponents()[j].fugcoef(getPhase(phase)); - getPhase(phase).getComponents()[j].logfugcoefdT(getPhase(phase)); - getPhase(phase).getComponents()[j].logfugcoefdP(getPhase(phase)); - getPhase(phase).getComponents()[j].logfugcoefdN(getPhase(phase)); - } - } - } - - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null && tmpPhase.getType() == PhaseType.GAS) { - tmpPhase.setType(PhaseType.OIL); - } - } - this.isInitialized = true; - } - - /** - *

- * initNumeric. - *

- * - * @param type a int - */ - public void initNumeric(int type) { - initNumeric(type, 1); - } - - /** - *

- * initNumeric. - *

- * - * @param type a int - * @param phasen a int - */ - public void initNumeric(int type, int phasen) { - if (type < 2) { - initAnalytic(type); - } else if (type >= 2) { - double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; - - double dt = getTemperature() / 1.0e6; - setTemperature(getTemperature() + dt); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - setTemperature(getTemperature() - 2 * dt); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - getPhase(0).getComponent(i).setdfugdt((gasfug[0][i] - gasfug[1][i]) / (2 * dt)); - getPhase(1).getComponent(i).setdfugdt((liqfug[0][i] - liqfug[1][i]) / (2 * dt)); - } - - setTemperature(getTemperature() + dt); - - double dp = getPressure() / 1.0e6; - setPressure(getPressure() + dp); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - setPressure(getPressure() - 2 * dp); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - getPhase(0).getComponent(i).setdfugdp((gasfug[0][i] - gasfug[1][i]) / (2 * dp)); - getPhase(1).getComponent(i).setdfugdp((liqfug[0][i] - liqfug[1][i]) / (2 * dp)); - } - - setPressure(getPressure() + dp); - init(1); - - if (type == 3) { - for (int phase = 0; phase < 2; phase++) { - for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { - double dn = getPhases()[phase].getComponents()[k].getNumberOfMolesInPhase() / 1.0e6; - - addComponent(k, dn, phase); - // initBeta(); - init_x_y(); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - liqfug[0][i] = - Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); - } - - addComponent(k, -2.0 * dn, phase); - // initBeta(); - init_x_y(); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - // gasfug[1][i] = - // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = - Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); - } - addComponent(k, dn, phase); - init_x_y(); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - getPhase(phase).getComponent(k).setdfugdn(i, - (liqfug[0][i] - liqfug[1][i]) / (2 * dn)); - getPhase(phase).getComponent(k).setdfugdx(i, (liqfug[0][i] - liqfug[1][i]) / (2 * dn) - * getPhase(phase).getNumberOfMolesInPhase()); - } - // initBeta(); - } - } - } - } - this.isInitialized = true; - } + /** {@inheritDoc} */ + @Override + public double getCorrectedVolumeFraction(int phaseNumber) { + return getPhase(phaseNumber).getCorrectedVolume() / getCorrectedVolume(); + } /** {@inheritDoc} */ @Override - public void initNumeric() { - double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] gasnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][] liqnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; - double[][][] gasnumericDfugdn = new double[2][getPhases()[0] - .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; - double[][][] liqnumericDfugdn = new double[2][getPhases()[0] - .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; - - double dt = getTemperature() / 1e5; - setTemperature(getTemperature() + dt); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - setTemperature(getTemperature() - 2 * dt); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - gasnumericDfugdt[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dt); - liqnumericDfugdt[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dt); - phaseArray[0].getComponents()[i].setdfugdt(gasnumericDfugdt[0][i]); - phaseArray[1].getComponents()[i].setdfugdt(liqnumericDfugdt[0][i]); - } - - setTemperature(getTemperature() + dt); - - double dp = getPressure() / 1e5; - setPressure(getPressure() + dp); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - } - - setPressure(getPressure() - 2 * dp); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); - gasnumericDfugdp[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dp); - liqnumericDfugdp[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dp); - phaseArray[0].getComponents()[i].setdfugdp(gasnumericDfugdp[0][i]); - phaseArray[1].getComponents()[i].setdfugdp(liqnumericDfugdp[0][i]); - } - - setPressure(getPressure() + dp); - init(1); - - for (int phase = 0; phase < 2; phase++) { - for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { - double dn = getPhases()[phase].getComponents()[k].getNumberOfMolesInPhase() / 1.0e6; - if (dn < 1e-12) { - dn = 1e-12; - } - - addComponent(k, dn, phase); - // initBeta(); - init_x_y(); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - liqfug[0][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); - } - - addComponent(k, -2.0 * dn, phase); - // initBeta(); - init_x_y(); - init(1); - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - // gasfug[1][i] = - // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); - liqfug[1][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); - } - - for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { - if (phase == 0) { - gasnumericDfugdn[0][k][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dn); - phaseArray[0].getComponents()[i].setdfugdn(k, gasnumericDfugdn[0][k][i]); - phaseArray[0].getComponents()[i].setdfugdx(k, - gasnumericDfugdn[0][k][i] * phaseArray[0].getNumberOfMolesInPhase()); - } - - if (phase == 1) { - liqnumericDfugdn[0][k][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dn); - phaseArray[1].getComponents()[i].setdfugdn(k, liqnumericDfugdn[0][k][i]); - phaseArray[1].getComponents()[i].setdfugdx(k, - liqnumericDfugdn[0][k][i] * phaseArray[1].getNumberOfMolesInPhase()); - } - } - - addComponent(k, dn, phase); - // initBeta(); - init_x_y(); - init(1); - } + public double getCp() { + double cP = 0.0; + for (int i = 0; i < numberOfPhases; i++) { + cP += getPhase(i).getCp(); } + return cP; } /** {@inheritDoc} */ @Override - public void initProperties() { - initThermoProperties(); - initPhysicalProperties(); - } - - /** {@inheritDoc} */ - @Override - public void initPhysicalProperties() { - for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).initPhysicalProperties(); + public double getCp(String unit) { + double refCp = getCp(); // Cp in J/K + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + break; + case "btu/lbmole-F": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0 * 0.2388; + break; + default: + throw new RuntimeException("unit not supported " + unit); } - calcInterfaceProperties(); + return refCp * conversionFactor; } /** {@inheritDoc} */ @Override - public void initPhysicalProperties(String propertyName) { + public double getCv() { + double cv = 0.0; for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).initPhysicalProperties(propertyName); + cv += getPhase(i).getCv(); } + return cv; } /** {@inheritDoc} */ @Override - public void resetPhysicalProperties() { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) { - tmpPhase.resetPhysicalProperties(); - } + public double getCv(String unit) { + double refCv = getCv(); // enthalpy in J + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / getTotalNumberOfMoles(); + break; + case "J/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + break; + case "btu/lbmole-F": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0 * 0.2388; + break; + default: + throw new RuntimeException("unit not supported " + unit); } + return refCv * conversionFactor; } /** {@inheritDoc} */ @Override - public void initRefPhases() { + public double getDensity() { + double density = 0; for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).initRefPhases(false); + density += + 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); } + return density; } /** {@inheritDoc} */ @Override - public void setPhysicalPropertyModel(int type) { - for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).setPhysicalProperties(type); + public double getDensity(String unit) { + double density = 0; + for (int i = 0; i < getNumberOfPhases(); i++) { + density += + getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); } - } - - /** {@inheritDoc} */ - @Override - public void chemicalReactionInit() { - chemicalReactionOperations = new ChemicalReactionOperations(this); - chemicalSystem = chemicalReactionOperations.hasRections(); - } - - /** {@inheritDoc} */ - @Override - public ChemicalReactionOperations getChemicalReactionOperations() { - return chemicalReactionOperations; + double refDensity = density; // 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; } /** - * Verify if system has a phase of a specific type. + * getPdVtn. * - * @param pt PhaseType to look for. - * @return True if system contains a phase of requested type. + * @return dpdv */ - public boolean hasPhaseType(PhaseType pt) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i) == null) { - continue; - } - 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; - } - - /** {@inheritDoc} */ - @Override - public final PhaseInterface getGasPhase() { - for (int phase = 0; phase < numberOfPhases; phase++) { - if (phaseArray[phaseIndex[phase]].getType() == PhaseType.GAS) { - return phaseArray[phase]; - } - } - logger.info("No gas phase at current state."); - return null; - } - - /** {@inheritDoc} */ - @Override - public final PhaseInterface getLiquidPhase() { - for (int phase = 0; phase < numberOfPhases; phase++) { - if (phaseArray[phaseIndex[phase]].getType() == PhaseType.LIQUID) { - return phaseArray[phase]; - } - } - logger.info("No liquid phase at current state."); - return null; - } - - /** {@inheritDoc} */ - @Override - public boolean isPhase(int i) { - // TODO: what if i > numberofphases? - if (i > phaseArray.length) { - return false; - } - - // getPhase(i) without try/catch - return phaseArray[phaseIndex[i]] != null; - } - - /** {@inheritDoc} */ - @Override - public final PhaseInterface getPhase(int i) { - if (i < 0) { - throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "getPhase", - "i", i + " is not valid, must be in the range 0-" + this.getNumberOfPhases())); - } else if (i >= getNumberOfPhases() && phaseArray[phaseIndex[i]] == null) { - throw new RuntimeException(new neqsim.util.exception.InvalidInputException( - this.getClass() + ":getPhase - Can not return phase number " + i - + ". Current number of phases are " + getNumberOfPhases())); - } - return phaseArray[phaseIndex[i]]; - } - - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhase(PhaseType pt) { - if (!this.hasPhaseType(pt)) { - throw new RuntimeException("Phase with phase type " + pt + " not found."); - } - - int phaseNum = getPhaseNumberOfPhase(pt); - if (phaseNum >= 0) { - return getPhase(phaseNum); - } - - return null; - } - - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhase(String phaseTypeName) { - PhaseType pt = PhaseType.byDesc(phaseTypeName); - return getPhase(pt); - } - - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhaseOfType(String phaseTypeName) { - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { - return getPhase(i); - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public int getPhaseNumberOfPhase(PhaseType pt) { - // TODO: returning first if not found, not same as the others. - for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getType() == pt) { - return i; - } - } - return 0; - } - - /** {@inheritDoc} */ - @Override - public final int getPhaseIndex(int index) { - return phaseIndex[index]; - } - - /** {@inheritDoc} */ - @Override - public int getPhaseIndex(String phaseTypeName) { - // TODO: returning first if not found, not same as the others. + public double getdPdVtn() { + double dPdV = 0.0; for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { - return phaseIndex[i]; + if (isPhase(i)) { + dPdV += getPhase(i).getdPdVTn() * getPhase(i).getVolume() / getVolume(); } } - return phaseIndex[0]; + return dPdV; } /** {@inheritDoc} */ @Override - public int getPhaseIndex(PhaseInterface phase) { + public double getdVdPtn() { + double dVdP = 0.0; for (int i = 0; i < numberOfPhases; i++) { - if (getPhase(i) == phase) { - return phaseIndex[i]; + if (isPhase(i)) { + dVdP += 1.0 / getPhase(i).getdPdVTn(); } } - throw new RuntimeException( - new InvalidInputException(this, "getPhaseIndex", "phase", "is not found in phaseArray.")); + return dVdP; } /** {@inheritDoc} */ @Override - public final void setPhaseIndex(int index, int phaseIndex) { - this.phaseIndex[index] = phaseIndex; + public double getdVdTpn() { + double dVdT = 0.0; + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + dVdT += -getPhase(i).getdPdTVn() / getPhase(i).getdPdVTn(); + } + } + return dVdT; } /** {@inheritDoc} */ @Override - public final boolean isChemicalSystem() { - return chemicalSystem; - } + public SystemInterface getEmptySystemClone() { + int phaseNumber = 0; - /** {@inheritDoc} */ - @Override - public final void isChemicalSystem(boolean temp) { - chemicalSystem = temp; - } + SystemInterface newSystem = this.clone(); - /** - *

- * getAntoineVaporPressure. - *

- * - * @param temp a double - * @return a double - */ - public double getAntoineVaporPressure(double temp) { - return phaseArray[0].getAntoineVaporPressure(temp); - } + for (int j = 0; j < getMaxNumberOfPhases(); j++) { + phaseNumber = j; + for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { + newSystem.getPhase(j).getComponents()[i].setNumberOfmoles( + getPhase(phaseNumber).getComponents()[i].getNumberOfMolesInPhase() / 1.0e30); + newSystem.getPhase(j).getComponents()[i].setNumberOfMolesInPhase( + getPhase(phaseNumber).getComponents()[i].getNumberOfMolesInPhase() / 1.0e30); + } + } - /** {@inheritDoc} */ - @Override - public final double getTC() { - return criticalTemperature; - } + newSystem.setTotalNumberOfMoles(getPhase(phaseNumber).getNumberOfMolesInPhase() / 1.0e30); - /** {@inheritDoc} */ - @Override - public final double getPC() { - return criticalPressure; + newSystem.init(0); + // newSystem.init(1); + return newSystem; } /** {@inheritDoc} */ @Override - public final void setTC(double TC) { - criticalTemperature = TC; + public double getEnthalpy() { + double enthalpy = 0; + for (int i = 0; i < numberOfPhases; i++) { + enthalpy += getPhase(i).getEnthalpy(); + } + return enthalpy; } /** {@inheritDoc} */ @Override - public final void setPC(double PC) { - criticalPressure = PC; - } - - /** - *

- * setMixingRuleGEmodel. - *

- * - * @param name a {@link java.lang.String} object - */ - public void setMixingRuleGEmodel(String name) { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) { - tmpPhase.setMixingRuleGEModel(name); - } + public double getEnthalpy(String unit) { + double refEnthalpy = getEnthalpy(); // enthalpy in J + double conversionFactor = 1.0; + switch (unit) { + case "J": + conversionFactor = 1.0; + break; + case "Btu": + conversionFactor = 0.00094781712; + break; + case "kJ/kmol": + conversionFactor = 1.0 / getTotalNumberOfMoles() / 1000.0; + break; + case "J/mol": + conversionFactor = 1.0 / getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + break; + case "kJ/kg": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + break; + case "Btu/lbmol": + conversionFactor = 1.0 / getTotalNumberOfMoles() * 0.429923; + break; + default: + throw new RuntimeException("unit not supported " + unit); } + return refEnthalpy * conversionFactor; } /** {@inheritDoc} */ @Override - public final void setMixingRule(int type) { - mixingRule = type; - if (numberOfPhases < 4) { - resetPhysicalProperties(); // initPhysicalProperties(); - } - for (int i = 0; i < maxNumberOfPhases; i++) { - if (isPhase(i)) { - getPhase(i).setMixingRule(type); - getPhase(i).initPhysicalProperties(); - // getPhase(i).getPhysicalProperties().getMixingRule().initMixingRules(getPhase(i)); - } + public double getEntropy() { + double entropy = 0; + for (int i = 0; i < numberOfPhases; i++) { + entropy += getPhase(i).getEntropy(); } + return entropy; } /** {@inheritDoc} */ @Override - public void setMixingRule(String typename, String GEmodel) { - setMixingRuleGEmodel(GEmodel); - setMixingRule(typename); + public double getEntropy(String unit) { + double refEntropy = getEntropy(); // entropy in J/K + double conversionFactor = 1.0; + switch (unit) { + case "J/K": + conversionFactor = 1.0; + break; + case "J/molK": + conversionFactor = 1.0 / getTotalNumberOfMoles(); + break; + case "kJ/molK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / 1000.0; + break; + case "J/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + break; + case "kJ/kgK": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + break; + case "btu/lb-F": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0 * 0.2388; + break; + default: + throw new RuntimeException("unit not supported " + unit); + } + return refEntropy * conversionFactor; } /** {@inheritDoc} */ @Override - public void setMixingRule(String typename) { - int var = 0; - if (typename.equals("no")) { - var = 1; - } else if (typename.equals("classic")) { - var = 2; - } else if (typename.equals("HV")) { - var = 4; - } else if (typename.equals("WS")) { - var = 5; - } else if (typename.equals("CPA-Mix")) { - var = 7; - } else if (typename.equals("classic-T")) { - var = 8; - } else if (typename.equals("classic-T-cpa")) { - var = 9; - } else if (typename.equals("classic-Tx-cpa")) { - var = 10; - } else { - var = 1; - } - this.setMixingRule(var); + public double getExergy(double temperatureOfSurroundings) { + double getExergy = getEnthalpy() - temperatureOfSurroundings * getEntropy(); + return getExergy; } /** {@inheritDoc} */ @Override - public void setNumberOfPhases(int number) { - this.numberOfPhases = number; - if (numberOfPhases > getMaxNumberOfPhases()) { - setMaxNumberOfPhases(number); + public double getExergy(double temperatureOfSurroundings, String exergyUnit) { + double refExergy = getExergy(temperatureOfSurroundings); // exergy in J + double conversionFactor = 1.0; + switch (exergyUnit) { + case "J": + conversionFactor = 1.0; + break; + case "J/mol": + conversionFactor = 1.0 / getTotalNumberOfMoles(); + break; + case "J/kg": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + break; + case "kJ/kg": + conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + break; + default: + break; } + return refExergy * conversionFactor; } /** {@inheritDoc} */ @Override - public void useVolumeCorrection(boolean volcor) { - for (PhaseInterface tmpPhase : phaseArray) { - if (tmpPhase != null) { - tmpPhase.useVolumeCorrection(volcor); - } + public double getFlowRate(String flowunit) { + if (flowunit.equals("kg/sec")) { + return totalNumberOfMoles * getMolarMass(); + } else if (flowunit.equals("kg/min")) { + return totalNumberOfMoles * getMolarMass() * 60.0; + } else if (flowunit.equals("kg/hr")) { + return totalNumberOfMoles * getMolarMass() * 3600.0; + } else if (flowunit.equals("kg/day")) { + return totalNumberOfMoles * getMolarMass() * 3600.0 * 24.0; + } else if (flowunit.equals("m3/sec")) { + initPhysicalProperties("density"); + return totalNumberOfMoles * getMolarMass() / getDensity("kg/m3"); + // return getVolume() / 1.0e5; + } else if (flowunit.equals("m3/min")) { + initPhysicalProperties("density"); + return totalNumberOfMoles * getMolarMass() * 60.0 / getDensity("kg/m3"); + // return getVolume() / 1.0e5 * 60.0; + } else if (flowunit.equals("m3/hr")) { + // return getVolume() / 1.0e5 * 3600.0; + initPhysicalProperties("density"); + return totalNumberOfMoles * getMolarMass() * 3600.0 / getDensity("kg/m3"); + } else if (flowunit.equals("idSm3/hr")) { + return totalNumberOfMoles * getMolarMass() * 3600.0 / getIdealLiquidDensity("kg/m3"); + } else if (flowunit.equals("gallons/min")) { + initPhysicalProperties("density"); + return totalNumberOfMoles * getMolarMass() * 60.0 / getDensity("kg/m3") * 1000 / 3.78541178; + } else if (flowunit.equals("Sm3/sec")) { + return totalNumberOfMoles * ThermodynamicConstantsInterface.R + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; + } else if (flowunit.equals("Sm3/hr")) { + return totalNumberOfMoles * 3600.0 * ThermodynamicConstantsInterface.R + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; + } else if (flowunit.equals("Sm3/day")) { + return totalNumberOfMoles * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm; + } else if (flowunit.equals("MSm3/day")) { + return totalNumberOfMoles * 3600.0 * 24.0 * ThermodynamicConstantsInterface.R + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm / 1.0e6; + } else if (flowunit.equals("MSm3/hr")) { + return totalNumberOfMoles * 3600.0 * ThermodynamicConstantsInterface.R + * ThermodynamicConstantsInterface.standardStateTemperature + / ThermodynamicConstantsInterface.atm / 1.0e6; + } else if (flowunit.equals("mole/sec")) { + return totalNumberOfMoles; + } else if (flowunit.equals("mole/min")) { + return totalNumberOfMoles * 60.0; + } else if (flowunit.equals("mole/hr")) { + return totalNumberOfMoles * 3600.0; + } else if (flowunit.equals("lbmole/hr")) { + return totalNumberOfMoles * 3600.0 / 1000.0 * 2.205; + } else if (flowunit.equals("lb/hr")) { + return totalNumberOfMoles * getMolarMass() * 60.0 * 2.20462262; + } else if (flowunit.equals("barrel/day")) { + return totalNumberOfMoles * getMolarMass() * 60.0 * 2.20462262 * 0.068; + } else { + throw new RuntimeException("failed.. unit: " + flowunit + " not supported"); } } /** {@inheritDoc} */ @Override - public final PhaseInterface[] getPhases() { - return phaseArray; + public String getFluidInfo() { + return fluidInfo; } /** {@inheritDoc} */ @Override - public double getGibbsEnergy() { - double gibbsEnergy = 0; - for (int i = 0; i < numberOfPhases; i++) { - gibbsEnergy += getPhase(i).getGibbsEnergy(); - } - return gibbsEnergy; + public String getFluidName() { + return fluidName; } /** {@inheritDoc} */ @Override - public double getExergy(double temperatureOfSurroundings, String exergyUnit) { - double refExergy = getExergy(temperatureOfSurroundings); // exergy in J - double conversionFactor = 1.0; - switch (exergyUnit) { - case "J": - conversionFactor = 1.0; - break; - case "J/mol": - conversionFactor = 1.0 / getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); - break; - case "kJ/kg": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; - break; - default: - break; - } - return refExergy * conversionFactor; + public double getGamma() { + return getCp() / getCv(); } /** {@inheritDoc} */ @Override - public double getExergy(double temperatureOfSurroundings) { - double getExergy = getEnthalpy() - temperatureOfSurroundings * getEntropy(); - return getExergy; + public final PhaseInterface getGasPhase() { + for (int phase = 0; phase < numberOfPhases; phase++) { + if (phaseArray[phaseIndex[phase]].getType() == PhaseType.GAS) { + return phaseArray[phase]; + } + } + logger.info("No gas phase at current state."); + return null; } /** {@inheritDoc} */ @Override - public double getEnthalpy() { - double enthalpy = 0; + public double getGibbsEnergy() { + double gibbsEnergy = 0; for (int i = 0; i < numberOfPhases; i++) { - enthalpy += getPhase(i).getEnthalpy(); + gibbsEnergy += getPhase(i).getGibbsEnergy(); } - return enthalpy; + return gibbsEnergy; } /** {@inheritDoc} */ @Override - public double getEnthalpy(String unit) { - double refEnthalpy = getEnthalpy(); // enthalpy in J - double conversionFactor = 1.0; - switch (unit) { - case "J": - conversionFactor = 1.0; - break; - case "J/mol": - conversionFactor = 1.0 / getTotalNumberOfMoles(); - break; - case "J/kg": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); - break; - case "kJ/kg": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; - break; - default: - break; + public double getHeatOfVaporization() { + if (numberOfPhases < 2) { + return 0; + } else { + return getPhase(0).getEnthalpy() / getPhase(0).getNumberOfMolesInPhase() + - getPhase(1).getEnthalpy() / getPhase(1).getNumberOfMolesInPhase(); } - return refEnthalpy * conversionFactor; } /** {@inheritDoc} */ @Override - public double getViscosity() { - double visc = 0; + public double getHelmholtzEnergy() { + double helmholtzEnergy = 0; for (int i = 0; i < numberOfPhases; i++) { - visc += beta[phaseIndex[i]] * getPhase(i).getPhysicalProperties().getViscosity(); + helmholtzEnergy += getPhase(i).getHelmholtzEnergy(); } - return visc; + return helmholtzEnergy; } /** {@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; - default: - throw new RuntimeException(); - } - return refViscosity * conversionFactor; + public boolean getHydrateCheck() { + return hydrateCheck; } /** {@inheritDoc} */ @Override - public double getKinematicViscosity(String unit) { - double refViscosity = getViscosity("kg/msec") / getDensity("kg/m3"); // viscosity in kg/msec - double conversionFactor = 1.0; + public double getIdealLiquidDensity(String unit) { + double normalLiquidDensity = 0.0; + double molarMass = getMolarMass(); + for (int i = 0; i < getNumberOfComponents(); i++) { + normalLiquidDensity += getComponent(i).getNormalLiquidDensity() * getComponent(i).getz() + * getComponent(i).getMolarMass() / molarMass; + } switch (unit) { - case "m2/sec": - conversionFactor = 1.0; - break; + case "gr/cm3": + return normalLiquidDensity; + case "kg/m3": + return normalLiquidDensity * 1000.0; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } - return refViscosity * conversionFactor; - } - - /** {@inheritDoc} */ - @Override - public double getKinematicViscosity() { - return getViscosity() / getDensity(); } /** {@inheritDoc} */ - @Deprecated @Override - public double getConductivity() { - double cond = 0; - for (int i = 0; i < numberOfPhases; i++) { - cond += beta[phaseIndex[i]] * getPhase(i).getPhysicalProperties().getConductivity(); - } - return cond; + public int getInitType() { + return initType; } /** {@inheritDoc} */ - @Deprecated @Override - public double getConductivity(String unit) { - double refConductivity = getConductivity(); // conductivity in W/m*K - double conversionFactor = 1.0; - switch (unit) { - case "W/mK": - conversionFactor = 1.0; - break; - case "W/cmK": - conversionFactor = 0.01; - break; - default: - throw new RuntimeException(); - } - return refConductivity * conversionFactor; + public double getInterfacialTension(int phase1, int phase2) { + return interfaceProp.getSurfaceTension(phase1, phase2); } /** {@inheritDoc} */ @Override - public double getThermalConductivity() { - double cond = 0; - for (int i = 0; i < numberOfPhases; i++) { - cond += beta[phaseIndex[i]] * getPhase(i).getPhysicalProperties().getConductivity(); - } - return cond; + public double getInterfacialTension(int phase1, int phase2, String unit) { + return interfaceProp.getSurfaceTension(phase1, phase2, unit); } /** {@inheritDoc} */ @Override - public double getThermalConductivity(String unit) { - double refConductivity = getConductivity(); // conductivity in W/m*K - double conversionFactor = 1.0; - switch (unit) { - case "W/mK": - conversionFactor = 1.0; - break; - case "W/cmK": - conversionFactor = 0.01; - break; - default: - throw new RuntimeException(); + public double getInterfacialTension(String phase1, String phase2) { + if (hasPhaseType(phase1) && hasPhaseType(phase2)) { + return interfaceProp.getSurfaceTension(getPhaseNumberOfPhase(phase1), + getPhaseNumberOfPhase(phase2)); + } else { + return Double.NaN; } - return refConductivity * conversionFactor; } /** {@inheritDoc} */ @@ -2772,123 +2298,167 @@ public double getInternalEnergy(String unit) { conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } return refEnthalpy * conversionFactor; } /** {@inheritDoc} */ @Override - public double getHelmholtzEnergy() { - double helmholtzEnergy = 0; - for (int i = 0; i < numberOfPhases; i++) { - helmholtzEnergy += getPhase(i).getHelmholtzEnergy(); - } - return helmholtzEnergy; + public InterphasePropertiesInterface getInterphaseProperties() { + return interfaceProp; } /** {@inheritDoc} */ @Override - public double getEntropy() { - double entropy = 0; + public double getJouleThomsonCoefficient() { + double JTcoef = 0; for (int i = 0; i < numberOfPhases; i++) { - entropy += getPhase(i).getEntropy(); + JTcoef += getBeta(i) * getPhase(i).getJouleThomsonCoefficient(); } - return entropy; + return JTcoef; } /** {@inheritDoc} */ @Override - public double getEntropy(String unit) { - double refEntropy = getEntropy(); // entropy in J/K + public double getJouleThomsonCoefficient(String unit) { + double JTcoef = getJouleThomsonCoefficient(); double conversionFactor = 1.0; switch (unit) { - case "J/K": + case "K/bar": conversionFactor = 1.0; break; - case "J/molK": - conversionFactor = 1.0 / getTotalNumberOfMoles(); + case "C/bar": + conversionFactor = 1.0; break; - case "J/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + case "K/Pa": + conversionFactor = 1.0e-5; break; - case "kJ/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + case "F/psi": + conversionFactor = 1.8 * 1.0 / 14.503773773; break; default: + throw new RuntimeException("unit not supported " + unit); + } + return JTcoef * conversionFactor; + } + + /** {@inheritDoc} */ + @Override + public double getKappa() { + return -getCp() / getCv() * getVolume() / getPressure() * getdPdVtn(); + } + + /** {@inheritDoc} */ + @Override + public double getKinematicViscosity() { + return getViscosity() / getDensity(); + } + + /** {@inheritDoc} */ + @Override + public double getKinematicViscosity(String unit) { + double refViscosity = getViscosity("kg/msec") / getDensity("kg/m3"); // viscosity in kg/msec + double conversionFactor = 1.0; + switch (unit) { + case "m2/sec": + conversionFactor = 1.0; break; + default: + throw new RuntimeException("unit not supported " + unit); } - return refEntropy * conversionFactor; + return refViscosity * conversionFactor; } /** {@inheritDoc} */ @Override - public double getMolarVolume() { - double volume = 0; - for (int i = 0; i < numberOfPhases; i++) { - volume += beta[phaseIndex[i]] * getPhase(i).getMolarVolume(); + public final PhaseInterface getLiquidPhase() { + for (int phase = 0; phase < numberOfPhases; phase++) { + if (phaseArray[phaseIndex[phase]].getType() == PhaseType.LIQUID) { + return phaseArray[phase]; + } } - return volume; + logger.info("No liquid phase at current state."); + return null; } /** {@inheritDoc} */ @Override - public double getDensity() { - double density = 0; - for (int i = 0; i < numberOfPhases; i++) { - density += - 1.0e5 * (getPhase(i).getMolarMass() * beta[phaseIndex[i]] / getPhase(i).getMolarVolume()); + public double getLiquidVolume() { + double totFlow = 0; + + for (int kj = 0; kj < numberOfPhases; kj++) { + if (getPhase(kj).getType() != PhaseType.GAS) { + totFlow += getPhase(kj).getVolume(); + } } - return density; + return totFlow; } /** {@inheritDoc} */ @Override - public double getDensity(String unit) { - double density = 0; - for (int i = 0; i < getNumberOfPhases(); i++) { - density += - getPhase(i).getVolume() / getVolume() * getPhase(i).getPhysicalProperties().getDensity(); + public PhaseInterface getLowestGibbsEnergyPhase() { + if (getPhase(0).getGibbsEnergy() < getPhase(1).getGibbsEnergy()) { + return getPhase(0); + } else { + return getPhase(1); } - double refDensity = density; // density in kg/m3 + } + + /** {@inheritDoc} */ + @Override + public double getMass(String unit) { double conversionFactor = 1.0; switch (unit) { - case "kg/m3": + case "kg": conversionFactor = 1.0; break; - case "lb/ft3": - conversionFactor = 0.0624279606; + case "gr": + conversionFactor = 1000.0; break; - case "kg/Sm3": - return getMolarMass() * 101325.0 / ThermodynamicConstantsInterface.R - / ThermodynamicConstantsInterface.standardStateTemperature; - case "mol/m3": - conversionFactor = 1.0 / getMolarMass(); + case "tons": + conversionFactor = 1.0e-3; break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } - return refDensity * conversionFactor; + return conversionFactor * getTotalNumberOfMoles() * getMolarMass(); } /** {@inheritDoc} */ @Override - public double getZ() { - double Z = 0; - for (int i = 0; i < numberOfPhases; i++) { - Z += beta[phaseIndex[i]] * getPhase(i).getZ(); - } - return Z; + public int getMaxNumberOfPhases() { + return maxNumberOfPhases; } /** {@inheritDoc} */ @Override - public double getMoleFractionsSum() { - double sumz = 0.0; - for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { - sumz += phaseArray[0].getComponent(i).getz(); + public int getMixingRule() { + return mixingRule; + } + + /** {@inheritDoc} */ + @Override + public String getMixingRuleName() { + return ((PhaseEosInterface) getPhase(0)).getMixingRule().getMixingRuleName(); + } + + /** {@inheritDoc} */ + @Override + public String getModelName() { + return modelName; + } + + /** {@inheritDoc} */ + @Override + public double[] getMolarComposition() { + PhaseInterface phase = this.getPhase(0); + double[] comp = new double[phase.getNumberOfComponents()]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + comp[compNumb] = phase.getComponent(compNumb).getz(); } - return sumz; + return comp; } /** {@inheritDoc} */ @@ -2914,1377 +2484,1343 @@ public double getMolarMass(String unit) { case "gr/mol": conversionFactor = 1000.0; break; + case "lbm/lbmol": + conversionFactor = 1000.0; + break; default: - throw new RuntimeException(); + throw new RuntimeException("unit not supported " + unit); } return refMolarMass * conversionFactor; } /** {@inheritDoc} */ @Override - public void setTemperature(double newTemperature) { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - getPhases()[i].setTemperature(newTemperature); + public double[] getMolarRate() { + double[] comp = new double[getPhase(0).getNumberOfComponents()]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + comp[compNumb] = getPhase(0).getComponent(compNumb).getNumberOfmoles(); } + return comp; } /** {@inheritDoc} */ @Override - public final void setTemperature(double newTemperature, int phase) { - getPhase(phaseIndex[phase]).setTemperature(newTemperature); + public double getMolarVolume() { + double volume = 0; + for (int i = 0; i < numberOfPhases; i++) { + volume += beta[phaseIndex[i]] * getPhase(i).getMolarVolume(); + } + return volume; } /** {@inheritDoc} */ @Override - public void setTemperature(double newTemperature, String unit) { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - if (unit.equals("K")) { - getPhases()[i].setTemperature(newTemperature); - } else if (unit.equals("C")) { - getPhases()[i].setTemperature(newTemperature + 273.15); - } else { - throw new RuntimeException(); - } + public double getMolarVolume(String unit) { + double volume = 0; + for (int i = 0; i < numberOfPhases; i++) { + volume += beta[phaseIndex[i]] * getPhase(i).getMolarVolume(unit); } + return volume; } /** {@inheritDoc} */ @Override - public void setPhaseType(int phaseToChange, PhaseType pt) { - // System.out.println("new phase type: cha " + pt); - if (allowPhaseShift) { - phaseType[phaseIndex[phaseToChange]] = pt; + public double[] getMolecularWeights() { + double[] mm = new double[numberOfComponents]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + mm[compNumb] = getPhase(0).getComponent(compNumb).getMolarMass() * 1e3; } + return mm; } /** {@inheritDoc} */ @Override - public void setPhaseType(int phaseToChange, String phaseTypeName) { - // System.out.println("new phase type: cha " + newPhaseType); - int newPhaseType = 0; - if (phaseTypeName.equals("gas")) { - newPhaseType = 1; - } else if (StateOfMatter.isLiquid(PhaseType.byDesc(phaseTypeName))) { - newPhaseType = 0; - } else { - newPhaseType = 0; - } - - setPhaseType(phaseToChange, PhaseType.byValue(newPhaseType)); + public double getMoleFraction(int phaseNumber) { + return getPhase(phaseNumber).getBeta(); } /** {@inheritDoc} */ @Override - public void setPhaseType(String phases, int newPhaseType) { - // System.out.println("new phase type: cha " + newPhaseType); - if (phases.equals("all")) { - setAllPhaseType(PhaseType.byValue(newPhaseType)); + public double getMoleFractionsSum() { + double sumz = 0.0; + for (int i = 0; i < phaseArray[0].getNumberOfComponents(); i++) { + sumz += phaseArray[0].getComponent(i).getz(); } + return sumz; } /** {@inheritDoc} */ @Override - public void setAllPhaseType(PhaseType pt) { - if (allowPhaseShift) { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - setPhaseType(i, pt); - } + public double[] getNormalBoilingPointTemperatures() { + double[] bt = new double[numberOfComponents]; + + for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { + bt[compNumb] = getPhase(0).getComponent(compNumb).getNormalBoilingPoint(); } + return bt; } /** {@inheritDoc} */ @Override - public void invertPhaseTypes() { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - if (phaseType[i] == PhaseType.byValue(0)) { - phaseType[i] = PhaseType.byValue(1); - } else { - phaseType[i] = PhaseType.byValue(0); - } - } + public int getNumberOfComponents() { + return getComponentNames().length; } /** {@inheritDoc} */ @Override - public void setPhase(PhaseInterface phase, int index) { - double temp = phaseArray[index].getTemperature(); - double pres = phaseArray[index].getPressure(); - this.phaseArray[index] = phase; - this.phaseArray[index].setTemperature(temp); - this.phaseArray[index].setPressure(pres); + public int getNumberOfOilFractionComponents() { + int number = 0; + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction() + || getPhase(0).getComponent(i).isIsPlusFraction()) { + number++; + } + } + return number; } /** {@inheritDoc} */ @Override - public void reInitPhaseType() { - phaseType[0] = PhaseType.byValue(1); - phaseType[1] = PhaseType.byValue(0); - phaseType[2] = PhaseType.byValue(0); - phaseType[3] = PhaseType.byValue(0); - // TODO: why stop at 3 and not iterate through MAX_PHASES elements? - } - - /** - * Re-initialize phasetype, beta and phaseindex arrays, same initialization which is used in - * constructor. - */ - public void reInitPhaseInformation() { - reInitPhaseType(); - phaseType[4] = phaseType[3]; - phaseType[5] = phaseType[3]; - - for (int i = 0; i < MAX_PHASES; i++) { - beta[i] = 1.0; - } - - phaseIndex = new int[] {0, 1, 2, 3, 4, 5}; + public final int getNumberOfPhases() { + return numberOfPhases; } /** {@inheritDoc} */ @Override - public final boolean doSolidPhaseCheck() { - return solidPhaseCheck; + public int[] getOilFractionIDs() { + int numb = getNumberOfOilFractionComponents(); + int[] IDs = new int[numb]; + // int number = 0; + for (int i = 0; i < numb; i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction() + || getPhase(0).getComponent(i).isIsPlusFraction()) { + IDs[i] = getPhase(0).getComponent(i).getIndex(); + // number++; + } + } + return IDs; } /** {@inheritDoc} */ @Override - public final void setPressure(double newPressure) { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - phaseArray[i].setPressure(newPressure); + public double[] getOilFractionLiquidDensityAt25C() { + int numb = getNumberOfOilFractionComponents(); + int[] indexes = getOilFractionIDs(); + double[] temp = new double[numb]; + for (int i = 0; i < numb; i++) { + temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getNormalLiquidDensity(); } + return temp; } /** {@inheritDoc} */ @Override - public final void setPressure(double newPressure, String unit) { - neqsim.util.unit.PressureUnit presConversion = - new neqsim.util.unit.PressureUnit(newPressure, unit); - setPressure(presConversion.getValue("bara")); + public double[] getOilFractionMolecularMass() { + int numb = getNumberOfOilFractionComponents(); + int[] indexes = getOilFractionIDs(); + double[] temp = new double[numb]; + for (int i = 0; i < numb; i++) { + temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getMolarMass(); + } + return temp; } /** {@inheritDoc} */ @Override - public final double getTemperature() { - return phaseArray[0].getTemperature(); + public double[] getOilFractionNormalBoilingPoints() { + int numb = getNumberOfOilFractionComponents(); + int[] indexes = getOilFractionIDs(); + double[] temp = new double[numb]; + for (int i = 0; i < numb; i++) { + temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getNormalBoilingPoint(); + } + return temp; } /** {@inheritDoc} */ @Override - public final double getTemperature(String unit) { - neqsim.util.unit.TemperatureUnit tempConversion = - new neqsim.util.unit.TemperatureUnit(getTemperature(), "K"); - return tempConversion.getValue(unit); + public final double getPC() { + return criticalPressure; } /** {@inheritDoc} */ @Override - public double getTemperature(int phaseNumber) { - return getPhase(phaseIndex[phaseNumber]).getTemperature(); + public final PhaseInterface getPhase(int i) { + if (i < 0) { + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, "getPhase", + "i", i + " is not valid, must be in the range 0-" + this.getNumberOfPhases())); + } else if (i >= getNumberOfPhases() && phaseArray[phaseIndex[i]] == null) { + throw new RuntimeException(new neqsim.util.exception.InvalidInputException( + this.getClass() + ":getPhase - Can not return phase number " + i + + ". Current number of phases are " + getNumberOfPhases())); + } + return phaseArray[phaseIndex[i]]; } /** {@inheritDoc} */ @Override - public final double getPressure() { - return phaseArray[0].getPressure(); + public PhaseInterface getPhase(PhaseType pt) { + if (!this.hasPhaseType(pt)) { + throw new RuntimeException("Phase with phase type " + pt + " not found."); + } + + int phaseNum = getPhaseNumberOfPhase(pt); + if (phaseNum >= 0) { + return getPhase(phaseNum); + } + + return null; } /** {@inheritDoc} */ @Override - public final double getPressure(String unit) { - neqsim.util.unit.PressureUnit presConversion = - new neqsim.util.unit.PressureUnit(getPressure(), "bara"); - return presConversion.getValue(unit); + public PhaseInterface getPhase(String phaseTypeName) { + PhaseType pt = PhaseType.byDesc(phaseTypeName); + return getPhase(pt); } /** {@inheritDoc} */ @Override - public final double getPressure(int phaseNumber) { - return getPhase(phaseIndex[phaseNumber]).getPressure(); + public final double getPhaseFraction(String phaseTypeName, String unit) { + int phaseNumber = getPhaseNumberOfPhase(phaseTypeName); + switch (unit) { + case "mole": + return getBeta(phaseNumber); + case "volume": + return getVolumeFraction(phaseNumber); + case "mass": + initPhysicalProperties("density"); + return getVolumeFraction(phaseNumber) * getPhase(phaseNumber).getDensity("kg/m3") + / getDensity("kg/m3"); + default: + throw new RuntimeException("unit not supported " + unit); + } } /** {@inheritDoc} */ @Override - public final double getBeta() { - return beta[0]; + public final int getPhaseIndex(int index) { + return phaseIndex[index]; } /** {@inheritDoc} */ @Override - public final double getBeta(int phase) { - return beta[phaseIndex[phase]]; - } - - public final double getSumBeta() { - double sum = 0; - for (int k = 0; k < numberOfPhases; k++) { - sum += getBeta(k); + public int getPhaseIndex(PhaseInterface phase) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i) == phase) { + return phaseIndex[i]; + } } - return sum; + throw new RuntimeException( + new InvalidInputException(this, "getPhaseIndex", "phase", "is not found in phaseArray.")); } /** {@inheritDoc} */ @Override - public void setAttractiveTerm(int i) { - for (int k = 0; k < getMaxNumberOfPhases(); k++) { - phaseArray[k].setAttractiveTerm(i); + public int getPhaseIndex(String phaseTypeName) { + // TODO: returning first if not found, not same as the others. + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { + return phaseIndex[i]; + } } + return phaseIndex[0]; } /** {@inheritDoc} */ @Override - public final int getNumberOfPhases() { - return numberOfPhases; + public int getPhaseNumberOfPhase(PhaseType pt) { + // TODO: returning first if not found, not same as the others. + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getType() == pt) { + return i; + } + } + return 0; } /** {@inheritDoc} */ @Override - public final void setBeta(double b) { - if (b < 0) { - b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - } - if (b > 1) { - b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; + public PhaseInterface getPhaseOfType(String phaseTypeName) { + for (int i = 0; i < numberOfPhases; i++) { + if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { + return getPhase(i); + } } - beta[0] = b; - beta[1] = 1.0 - b; + return null; } /** {@inheritDoc} */ @Override - public final void setBeta(int phase, double b) { - if (b < 0) { - b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - } - if (b > 1) { - b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; - } - beta[phaseIndex[phase]] = b; + public final PhaseInterface[] getPhases() { + return phaseArray; } /** {@inheritDoc} */ @Override - public final double getVolume() { - double volume = 0.0; - for (int i = 0; i < numberOfPhases; i++) { - volume += getPhase(i).getMolarVolume() * getPhase(i).getNumberOfMolesInPhase(); - } - return volume; + public final double getPressure() { + return phaseArray[0].getPressure(); } /** {@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: - break; - } - return conversionFactor * getVolume() / 1.0e5; + public final double getPressure(int phaseNumber) { + return getPhase(phaseIndex[phaseNumber]).getPressure(); } /** {@inheritDoc} */ @Override - public double getMass(String unit) { - double conversionFactor = 1.0; - switch (unit) { - case "kg": - conversionFactor = 1.0; - break; - - case "gr": - conversionFactor = 1000.0; - break; - case "tons": - conversionFactor = 1.0e-3; - break; - default: - break; - } - return conversionFactor * getTotalNumberOfMoles() * getMolarMass(); + public final double getPressure(String unit) { + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(getPressure(), "bara"); + return presConversion.getValue(unit); } - /** - * {@inheritDoc} - * - *

- * need to call initPhysicalProperties() before this method is called - *

- */ + /** {@inheritDoc} */ @Override - public double getCorrectedVolume() { - double volume = 0; - for (int i = 0; i < numberOfPhases; i++) { - volume += getPhase(i).getMolarMass() / getPhase(i).getPhysicalProperties().getDensity() - * getPhase(i).getNumberOfMolesInPhase(); - } - return volume; - } - - /** - * getPdVtn. TODO: document - * - * @return dpdv - */ - public double getdPdVtn() { - double dPdV = 0.0; - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - dPdV += getPhase(i).getdPdVTn() * getPhase(i).getVolume() / getVolume(); - } - } - return dPdV; + public SystemProperties getProperties() { + return new SystemProperties(this); } /** {@inheritDoc} */ @Override - public double getdVdPtn() { - double dVdP = 0.0; - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - dVdP += 1.0 / getPhase(i).getdPdVTn(); - } + public double getProperty(String prop) { + if (prop.equals("numberOfPhases")) { + return numberOfPhases; + } else if (prop.equals("numberOfComponents")) { + return numberOfComponents; + } else if (prop.equals("enthalpy")) { + return getEnthalpy(); + } else if (prop.equals("entropy")) { + return getEntropy(); + } else if (prop.equals("temperature")) { + return getTemperature(); + } else if (prop.equals("pressure")) { + return getPressure(); + } else { + return 1.0; } - return dVdP; } /** {@inheritDoc} */ @Override - public double getdVdTpn() { - double dVdT = 0.0; - for (int i = 0; i < numberOfPhases; i++) { - if (isPhase(i)) { - dVdT += -getPhase(i).getdPdTVn() / getPhase(i).getdPdVTn(); - } + public double getProperty(String prop, int phase) { + initPhysicalProperties(); + if (prop.equals("temperature")) { + return getPhase(phase).getTemperature(); + } else if (prop.equals("pressure")) { + return getPhase(phase).getPressure(); + } else if (prop.equals("compressibility")) { + return getPhase(phase).getZ(); + } else if (prop.equals("density")) { + return getPhase(phase).getPhysicalProperties().getDensity(); + } else if (prop.equals("beta")) { + return getPhase(phase).getBeta(); + } else if (prop.equals("enthalpy")) { + return getPhase(phase).getEnthalpy(); + } else if (prop.equals("entropy")) { + return getPhase(phase).getEntropy(); + } else if (prop.equals("viscosity")) { + return getPhase(phase).getPhysicalProperties().getViscosity(); + } else if (prop.equals("conductivity")) { + return getPhase(phase).getPhysicalProperties().getConductivity(); + } else { + return 1.0; } - return dVdT; } /** {@inheritDoc} */ @Override - public double getCp() { - double cP = 0.0; - for (int i = 0; i < numberOfPhases; i++) { - cP += getPhase(i).getCp(); + public double getProperty(String prop, String compName, int phase) { + if (prop.equals("molefraction")) { + return getPhase(phase).getComponent(compName).getx(); + } else if (prop.equals("fugacitycoefficient")) { + return getPhase(phase).getComponent(compName).getFugacityCoefficient(); + } else if (prop.equals("logfugdT")) { + return getPhase(phase).getComponent(compName).getdfugdt(); + } else if (prop.equals("logfugdP")) { + return getPhase(phase).getComponent(compName).getdfugdp(); + } else { + return 1.0; } - return cP; } /** {@inheritDoc} */ @Override - public double getCp(String unit) { - double refCp = getCp(); // Cp in J/K - double conversionFactor = 1.0; - switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / getTotalNumberOfMoles(); - break; - case "J/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); - break; - case "kJ/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; - break; - default: - break; - } - return refCp * conversionFactor; + public String[][] getResultTable() { + return resultTable; } /** {@inheritDoc} */ @Override - public double getCv() { - double cv = 0.0; + public double getSoundSpeed() { + double soundspeed = 0; for (int i = 0; i < numberOfPhases; i++) { - cv += getPhase(i).getCv(); + soundspeed += getBeta(i) * getPhase(i).getSoundSpeed(); } - return cv; + return soundspeed; } /** {@inheritDoc} */ @Override - public double getCv(String unit) { - double refCv = getCv(); // enthalpy in J + public double getSoundSpeed(String unit) { + double refVel = getSoundSpeed(); double conversionFactor = 1.0; switch (unit) { - case "J/K": - conversionFactor = 1.0; - break; - case "J/molK": - conversionFactor = 1.0 / getTotalNumberOfMoles(); + case "m/s": + conversionFactor = 1.0; break; - case "J/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass(); + case "km/hr": + conversionFactor = 3.6; break; - case "kJ/kgK": - conversionFactor = 1.0 / getTotalNumberOfMoles() / getMolarMass() / 1000.0; + case "ft/sec": + conversionFactor = 3.280839895; break; default: - break; + throw new RuntimeException("unit not supported " + unit); } - return refCv * conversionFactor; + return refVel * conversionFactor; } /** {@inheritDoc} */ @Override - public double getKappa() { - return -getCp() / getCv() * getVolume() / getPressure() * getdPdVtn(); + public neqsim.standards.StandardInterface getStandard() { + return standard; } /** {@inheritDoc} */ @Override - public double getGamma() { - return getCp() / getCv(); + public neqsim.standards.StandardInterface getStandard(String standardName) { + this.setStandard(standardName); + return standard; } - /** {@inheritDoc} */ - @Override - public void calcInterfaceProperties() { - interfaceProp.init(); + /** + * Get sum of phase beta 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; + /** + *

+ * hasTBPFraction. + *

+ * + * @return a boolean + */ + public boolean hasTBPFraction() { + for (int i = 0; i < numberOfComponents; i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + return true; + } + } + return false; } /** {@inheritDoc} */ @Override - public void display() { - display(this.getFluidName()); + public void init(int type) { + if (!this.isInitialized) { + initBeta(); + init_x_y(); + } + if (this.numericDerivatives) { + initNumeric(type); + } else { + initAnalytic(type); + } + this.isInitialized = true; } /** {@inheritDoc} */ @Override - public void display(String name) { - JFrame dialog = new JFrame("System-Report"); - Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); - Container dialogContentPane = dialog.getContentPane(); - dialogContentPane.setLayout(new BorderLayout()); + public void init(int type, int phase) { + if (this.numericDerivatives) { + initNumeric(type, phase); + } else { + initAnalytic(type, phase); + } + } - String[] names = {"", "Feed", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Unit"}; - String[][] table = createTable(name); - JTable Jtab = new JTable(table, names); - JScrollPane scrollpane = new JScrollPane(Jtab); - dialogContentPane.add(scrollpane); + /** {@inheritDoc} */ + @Override + public final void init_x_y() { + // double x, z; + for (int j = 0; j < numberOfPhases; j++) { + // x = 0; + // z = 0; + for (int i = 0; i < numberOfComponents; i++) { + getPhase(j).getComponents()[i] + .setz(getPhase(j).getComponents()[i].getNumberOfmoles() / getTotalNumberOfMoles()); + getPhase(j).getComponents()[i].setx(getPhase(j).getComponents()[i].getNumberOfMolesInPhase() + / getPhase(j).getNumberOfMolesInPhase()); + } + getPhase(j).normalize(); + } + } - // setting the size of the frame and text size - dialog.setSize(screenDimension.width / 2, screenDimension.height / 2); // pack(); - Jtab.setRowHeight(dialog.getHeight() / table.length); - Jtab.setFont(new Font("Serif", Font.PLAIN, - dialog.getHeight() / table.length - dialog.getHeight() / table.length / 10)); + /** + *

+ * initAnalytic. + *

+ * + * @param type a int. 0 to initialize and 1 to reset, 2 to calculate T and P derivatives, 3 to + * calculate all derivatives and 4 to calculate all derivatives numerically + */ + public void initAnalytic(int type) { + if (type == 0) { + reInitPhaseInformation(); + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + if (isPhase(i)) { + getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, type, + phaseType[phaseIndex[i]], beta[phaseIndex[i]]); + } + } + setNumberOfPhases(2); + } - // dialog.pack(); - dialog.setVisible(true); + if (type > 0) { + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + // todo: possible bug here, some components check for initType >= 3 + getPhase(i).init(getTotalNumberOfMoles(), numberOfComponents, Math.min(3, type), + phaseType[phaseIndex[i]], beta[phaseIndex[i]]); + } + } + + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(i).getComponents()[j].fugcoef(getPhase(i)); + } + } + } + } + + if (type == 4) { // special case, calculate all derivatives numerically + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + for (int j = 0; j < numberOfComponents; j++) { + // TODO: only runs two calculations init == 3 runs three + getPhase(i).getComponents()[j].fugcoefDiffTempNumeric(getPhase(i), numberOfComponents, + getPhase(i).getTemperature(), getPhase(i).getPressure()); + getPhase(i).getComponents()[j].fugcoefDiffPresNumeric(getPhase(i), numberOfComponents, + getPhase(i).getTemperature(), getPhase(i).getPressure()); + } + } + } + } else { + if (type > 1) { // calculate T and P derivatives + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(i).getComponents()[j].logfugcoefdT(getPhase(i)); + getPhase(i).getComponents()[j].logfugcoefdP(getPhase(i)); + } + } + } + } + if (type == 3) { // calculate all derivatives + for (int i = 0; i < numberOfPhases; i++) { + if (isPhase(i)) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(i).getComponents()[j].logfugcoefdN(getPhase(i)); + } + } + } + } + } + + for (int i = 1; i < numberOfPhases; i++) { + if (isPhase(i)) { + if (getPhase(i).getType() == PhaseType.GAS) { + getPhase(i).setType(PhaseType.OIL); + } + } + } + this.isInitialized = true; } /** *

- * write. + * initAnalytic. *

* - * @return a {@link java.lang.String} object + * @param type a int + * @param phase a int */ - public String write() { - // create a String description of the system - return ""; - } + public void initAnalytic(int type, int phase) { + if (type == 0) { + beta[0] = 1.0; + phaseIndex[phase] = phase; + } - /** {@inheritDoc} */ - @Override - public void write(String name, String filename, boolean newfile) { - String[][] table = createTable(name); - neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = - new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); - if (newfile) { - file.newFile(filename); + if (isPhase(phase)) { + getPhase(phase).init(getTotalNumberOfMoles(), numberOfComponents, type, + phaseType[phaseIndex[phase]], beta[phaseIndex[phase]]); + if (type > 0) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(phase).getComponents()[j].fugcoef(getPhase(phase)); + } + } + if (type > 1) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(phase).getComponents()[j].logfugcoefdT(getPhase(phase)); + getPhase(phase).getComponents()[j].logfugcoefdP(getPhase(phase)); + } + } + if (type > 2) { + for (int j = 0; j < numberOfComponents; j++) { + getPhase(phase).getComponents()[j].logfugcoefdT(getPhase(phase)); + getPhase(phase).getComponents()[j].logfugcoefdP(getPhase(phase)); + getPhase(phase).getComponents()[j].logfugcoefdN(getPhase(phase)); + } + } } - file.setOutputFileName(filename); - file.setValues(table); - file.createFile(); + + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null && tmpPhase.getType() == PhaseType.GAS) { + tmpPhase.setType(PhaseType.OIL); + } + } + + this.isInitialized = true; } /** {@inheritDoc} */ @Override - public void resetDatabase() { - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - if (NeqSimDataBase.createTemporaryTables()) { - database.execute("delete FROM comptemp"); - database.execute("delete FROM intertemp"); - } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + public final void initBeta() { + for (int i = 0; i < numberOfPhases; i++) { + this.beta[phaseIndex[i]] = getPhase(i).getNumberOfMolesInPhase() / getTotalNumberOfMoles(); + } + if (this.getSumBeta() < 1.0 - ThermodynamicModelSettings.phaseFractionMinimumLimit + || this.getSumBeta() > 1.0 + ThermodynamicModelSettings.phaseFractionMinimumLimit) { + logger.warn("SystemThermo:initBeta - Sum of beta does not equal 1.0"); } } /** {@inheritDoc} */ @Override - public void createDatabase(boolean reset) { - if (reset) { - resetDatabase(); + public void initNumeric() { + double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] gasnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] liqnumericDfugdt = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] gasnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] liqnumericDfugdp = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][][] gasnumericDfugdn = new double[2][getPhases()[0] + .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; + double[][][] liqnumericDfugdn = new double[2][getPhases()[0] + .getNumberOfComponents()][getPhases()[0].getNumberOfComponents()]; + + double dt = getTemperature() / 1e5; + setTemperature(getTemperature() + dt); + init(1); + + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); } - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - String names = new String(); + setTemperature(getTemperature() - 2 * dt); + init(1); - for (int k = 0; k < getPhase(0).getNumberOfComponents() - 1; k++) { - names += "'" + this.getComponentNames()[k] + "', "; - } - names += "'" + this.getComponentNames()[getPhase(0).getNumberOfComponents() - 1] + "'"; + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + gasnumericDfugdt[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dt); + liqnumericDfugdt[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dt); + phaseArray[0].getComponents()[i].setdfugdt(gasnumericDfugdt[0][i]); + phaseArray[1].getComponents()[i].setdfugdt(liqnumericDfugdt[0][i]); + } - if (NeqSimDataBase.createTemporaryTables()) { - database.execute("insert into comptemp SELECT * FROM comp WHERE name IN (" + names + ")"); - database.execute("insert into intertemp SELECT DISTINCT * FROM inter WHERE comp1 IN (" - + names + ") AND comp2 IN (" + names + ")"); - database.execute("delete FROM intertemp WHERE comp1=comp2"); - } - // System.out.println("ok " + names); + setTemperature(getTemperature() + dt); - for (int phase = 0; phase < maxNumberOfPhases; phase++) { - getPhase(phase).setMixingRuleDefined(false); - } + double dp = getPressure() / 1e5; + setPressure(getPressure() + dp); + init(1); - for (int i = 0; i < numberOfComponents; i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction() - || getPhase(0).getComponent(i).isIsPlusFraction()) { - getPhase(0).getComponent(i).insertComponentIntoDatabase(""); - } - } - } catch (Exception ex) { - logger.error("error in SystemThermo Class...createDatabase() method", ex); + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); } - } - - /** {@inheritDoc} */ - @Override - public void setSolidPhaseCheck(boolean solidPhaseCheck) { - this.solidPhaseCheck = solidPhaseCheck; + setPressure(getPressure() - 2 * dp); + init(1); - final int oldphase = numberOfPhases; - if (solidPhaseCheck && !this.hasSolidPhase()) { - addSolidPhase(); + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + gasnumericDfugdp[0][i] = (gasfug[0][i] - gasfug[1][i]) / (2 * dp); + liqnumericDfugdp[0][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dp); + phaseArray[0].getComponents()[i].setdfugdp(gasnumericDfugdp[0][i]); + phaseArray[1].getComponents()[i].setdfugdp(liqnumericDfugdp[0][i]); } - // init(0); - for (int phase = 0; phase < numberOfPhases; phase++) { + setPressure(getPressure() + dp); + init(1); + + for (int phase = 0; phase < 2; phase++) { for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { - getPhase(phase).getComponent(k).setSolidCheck(solidPhaseCheck); - getPhase(3).getComponent(k).setSolidCheck(solidPhaseCheck); - } - } - setNumberOfPhases(oldphase); - } + double dn = getPhases()[phase].getComponents()[k].getNumberOfMolesInPhase() / 1.0e6; + if (dn < 1e-12) { + dn = 1e-12; + } - /** {@inheritDoc} */ - @Override - public void setSolidPhaseCheck(String solidComponent) { - init(0); - final int oldphase = numberOfPhases; - if (!solidPhaseCheck) { - addSolidPhase(); - } - this.solidPhaseCheck = true; - init(0); + addComponent(k, dn, phase); + // initBeta(); + init_x_y(); + init(1); - for (int phase = 0; phase < getMaxNumberOfPhases(); phase++) { - try { - getPhase(phase).getComponent(solidComponent).setSolidCheck(true); - getPhase(3).getComponent(solidComponent).setSolidCheck(true); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - } - setNumberOfPhases(oldphase); - } + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + liqfug[0][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + } - /** {@inheritDoc} */ - @Override - public void setHydrateCheck(boolean hydrateCheck) { - init(0); - if (hydrateCheck) { - addHydratePhase(); - } - this.hydrateCheck = hydrateCheck; - init(0); - } + addComponent(k, -2.0 * dn, phase); + // initBeta(); + init_x_y(); + init(1); - /** {@inheritDoc} */ - @Override - public boolean doMultiPhaseCheck() { - return multiPhaseCheck; - } + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + // gasfug[1][i] = + // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + } - /** {@inheritDoc} */ - @Override - public void setMultiPhaseCheck(boolean multiPhaseCheck) { - if (getMaxNumberOfPhases() < 3) { - if (multiPhaseCheck) { - setMaxNumberOfPhases(3); - if (phaseArray[1] != null) { - phaseArray[2] = phaseArray[1].clone(); - phaseArray[2].resetMixingRule(phaseArray[0].getMixingRuleNumber()); - phaseArray[2].resetPhysicalProperties(); - phaseArray[2].initPhysicalProperties(); + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + if (phase == 0) { + gasnumericDfugdn[0][k][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dn); + phaseArray[0].getComponents()[i].setdfugdn(k, gasnumericDfugdn[0][k][i]); + phaseArray[0].getComponents()[i].setdfugdx(k, + gasnumericDfugdn[0][k][i] * phaseArray[0].getNumberOfMolesInPhase()); + } + + if (phase == 1) { + liqnumericDfugdn[0][k][i] = (liqfug[0][i] - liqfug[1][i]) / (2 * dn); + phaseArray[1].getComponents()[i].setdfugdn(k, liqnumericDfugdn[0][k][i]); + phaseArray[1].getComponents()[i].setdfugdx(k, + liqnumericDfugdn[0][k][i] * phaseArray[1].getNumberOfMolesInPhase()); + } } - } else { - setMaxNumberOfPhases(2); + + addComponent(k, dn, phase); + // initBeta(); + init_x_y(); + init(1); } } - this.multiPhaseCheck = multiPhaseCheck; } - /** {@inheritDoc} */ - @Override - public int getInitType() { - return initType; + /** + *

+ * initNumeric. + *

+ * + * @param type a int + */ + public void initNumeric(int type) { + initNumeric(type, 1); } - /** {@inheritDoc} */ - @Override - public void setInitType(int initType) { - this.initType = initType; - } + /** + *

+ * initNumeric. + *

+ * + * @param type a int + * @param phasen a int + */ + public void initNumeric(int type, int phasen) { + if (type < 2) { + initAnalytic(type); + } else if (type >= 2) { + double[][] gasfug = new double[2][getPhases()[0].getNumberOfComponents()]; + double[][] liqfug = new double[2][getPhases()[0].getNumberOfComponents()]; + + double dt = getTemperature() / 1.0e6; + setTemperature(getTemperature() + dt); + init(1); + + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } + + setTemperature(getTemperature() - 2 * dt); + init(1); + + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } + + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + getPhase(0).getComponent(i).setdfugdt((gasfug[0][i] - gasfug[1][i]) / (2 * dt)); + getPhase(1).getComponent(i).setdfugdt((liqfug[0][i] - liqfug[1][i]) / (2 * dt)); + } + + setTemperature(getTemperature() + dt); + + double dp = getPressure() / 1.0e6; + setPressure(getPressure() + dp); + init(1); + + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[0][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[0][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } + + setPressure(getPressure() - 2 * dp); + init(1); - /** {@inheritDoc} */ - @Override - public boolean isNumericDerivatives() { - return numericDerivatives; - } + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + gasfug[1][i] = Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = Math.log(getPhases()[1].getComponents()[i].getFugacityCoefficient()); + } - /** {@inheritDoc} */ - @Override - public void setNumericDerivatives(boolean numericDerivatives) { - this.numericDerivatives = numericDerivatives; - } + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + getPhase(0).getComponent(i).setdfugdp((gasfug[0][i] - gasfug[1][i]) / (2 * dp)); + getPhase(1).getComponent(i).setdfugdp((liqfug[0][i] - liqfug[1][i]) / (2 * dp)); + } - /** {@inheritDoc} */ - @Override - public void checkStability(boolean val) { - checkStability = val; - } + setPressure(getPressure() + dp); + init(1); - /** {@inheritDoc} */ - @Override - public boolean checkStability() { - return checkStability; - } + if (type == 3) { + for (int phase = 0; phase < 2; phase++) { + for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { + double dn = getPhases()[phase].getComponents()[k].getNumberOfMolesInPhase() / 1.0e6; - /** {@inheritDoc} */ - @Override - public boolean doHydrateCheck() { - return hydrateCheck; - } + addComponent(k, dn, phase); + // initBeta(); + init_x_y(); + init(1); - /** {@inheritDoc} */ - @Override - public boolean getHydrateCheck() { - return hydrateCheck; - } + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + liqfug[0][i] = + Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + } - /** {@inheritDoc} */ - @Override - public void save(String name) { - try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name))) { - out.writeObject(this); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - } + addComponent(k, -2.0 * dn, phase); + // initBeta(); + init_x_y(); + init(1); - /** {@inheritDoc} */ - @Override - public SystemInterface readObject(int ID) { - ResultSet rs = null; - SystemThermo tempSystem = null; - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); - try { - java.sql.Connection con = database.openConnection(); - String sqlStr = "SELECT FLUID FROM fluid_blobdb WHERE ID=" + Integer.toString(ID); - java.sql.PreparedStatement ps = con.prepareStatement(sqlStr); - rs = ps.executeQuery(); + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + // gasfug[1][i] = + // Math.log(getPhases()[0].getComponents()[i].getFugacityCoefficient()); + liqfug[1][i] = + Math.log(getPhases()[phase].getComponents()[i].getFugacityCoefficient()); + } + addComponent(k, dn, phase); + init_x_y(); + init(1); - if (rs.next()) { - try (ObjectInputStream ins = - new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { - tempSystem = (SystemThermo) ins.readObject(); - } - } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (database.getStatement() != null) { - database.getStatement().close(); - } - if (database.getConnection() != null) { - database.getConnection().close(); + for (int i = 0; i < getPhases()[0].getNumberOfComponents(); i++) { + getPhase(phase).getComponent(k).setdfugdn(i, + (liqfug[0][i] - liqfug[1][i]) / (2 * dn)); + getPhase(phase).getComponent(k).setdfugdx(i, (liqfug[0][i] - liqfug[1][i]) / (2 * dn) + * getPhase(phase).getNumberOfMolesInPhase()); + } + // initBeta(); + } } - } catch (Exception ex) { - logger.error("err closing database IN MIX...", ex); } } - - return tempSystem; + this.isInitialized = true; } /** {@inheritDoc} */ @Override - public void saveFluid(int ID) { - saveObject(ID, ""); + public void initPhysicalProperties() { + for (int i = 0; i < numberOfPhases; i++) { + getPhase(i).initPhysicalProperties(); + } + calcInterfaceProperties(); } /** {@inheritDoc} */ @Override - public void saveFluid(int ID, String text) { - saveObject(ID, text); + public void initPhysicalProperties(String propertyName) { + for (int i = 0; i < numberOfPhases; i++) { + getPhase(i).initPhysicalProperties(propertyName); + } } /** {@inheritDoc} */ @Override - public void saveObject(int ID, String text) { - ByteArrayOutputStream fout = new ByteArrayOutputStream(); - try (ObjectOutputStream out = new ObjectOutputStream(fout)) { - out.writeObject(this); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - byte[] byteObject = fout.toByteArray(); - ByteArrayInputStream inpStream = new ByteArrayInputStream(byteObject); - - neqsim.util.database.NeqSimBlobDatabase database = - new neqsim.util.database.NeqSimBlobDatabase(); - - try { - java.sql.Connection con = database.openConnection(); - - java.sql.PreparedStatement ps = - con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); - ps.setInt(1, ID); - ps.setBlob(2, inpStream); - - ps.executeUpdate(); - /* - * if (!text.isEmpty()) { ps = con.prepareStatement( - * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); ps.setString(2, text); - * } - * - * ps.executeUpdate(); - * - */ - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } finally { - try { - if (database.getStatement() != null) { - database.getStatement().close(); - } - if (database.getConnection() != null) { - database.getConnection().close(); - } - } catch (Exception ex) { - logger.error("err closing database IN MIX...", ex); - } - } - // database.execute("INSERT INTO fluid_blobdb VALUES ('1'," + sqlString + ")"); + public void initProperties() { + initThermoProperties(); + initPhysicalProperties(); } /** {@inheritDoc} */ @Override - public void saveObjectToFile(String filePath, String fluidName) { - try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filePath, false))) { - out.writeObject(this); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + public void initRefPhases() { + for (int i = 0; i < numberOfPhases; i++) { + getPhase(i).initRefPhases(false); } } /** {@inheritDoc} */ @Override - public SystemInterface readObjectFromFile(String filePath, String fluidName) { - SystemThermo tempSystem = null; - try (ObjectInputStream objectinputstream = - new ObjectInputStream(new FileInputStream(filePath))) { - tempSystem = (SystemThermo) objectinputstream.readObject(); - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); + public final void initTotalNumberOfMoles(double change) { + setTotalNumberOfMoles(getTotalNumberOfMoles() + change); + // System.out.println("total moles: " + totalNumberOfMoles); + for (int j = 0; j < numberOfPhases; j++) { + for (int i = 0; i < numberOfComponents; i++) { + getPhase(j).getComponents()[i] + .setNumberOfmoles(phaseArray[phaseIndex[0]].getComponents()[i].getNumberOfmoles()); + } } - return tempSystem; } /** {@inheritDoc} */ @Override - public String getMixingRuleName() { - return ((PhaseEosInterface) getPhase(0)).getMixingRule().getMixingRuleName(); + public void setPhaseType(int phaseToChange, String phaseName) { + // System.out.println("new phase type: cha " + pt); + if (allowPhaseShift) { + phaseType[phaseIndex[phaseToChange]] = PhaseType.byName(phaseName); + } } /** {@inheritDoc} */ @Override - public String getFluidInfo() { - return fluidInfo; - } + public void invertPhaseTypes() { + // Following code was from public void setPhaseType(int phaseToChange, String + // phaseTypeName) { + /* + * int newPhaseType = 0; if (phaseTypeName.equals("gas")) { newPhaseType = 1; } else if + * (StateOfMatter.isLiquid(PhaseType.byDesc(phaseTypeName))) { newPhaseType = 0; } else { + * newPhaseType = 0; } + */ - /** {@inheritDoc} */ - @Override - public void setFluidInfo(String info) { - this.fluidInfo = info; + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + if (phaseType[i] == PhaseType.byValue(0)) { + phaseType[i] = PhaseType.byValue(1); + } else { + phaseType[i] = PhaseType.byValue(0); + } + } } /** {@inheritDoc} */ @Override - public String getFluidName() { - return fluidName; + public final boolean isChemicalSystem() { + return chemicalSystem; } /** {@inheritDoc} */ @Override - public void setFluidName(String fluidName) { - this.fluidName = fluidName; - } - - /** - *

- * setLastTBPasPlus. - *

- * - * @return a boolean - */ - public boolean setLastTBPasPlus() { - neqsim.thermo.characterization.PlusCharacterize temp = - new neqsim.thermo.characterization.PlusCharacterize(this); - if (temp.hasPlusFraction()) { - return false; - } else { - temp.setHeavyTBPtoPlus(); - } - return true; + public final void isChemicalSystem(boolean temp) { + chemicalSystem = temp; } /** {@inheritDoc} */ @Override - public neqsim.thermo.characterization.Characterise getCharacterization() { - return characterization; + public boolean isForcePhaseTypes() { + return forcePhaseTypes; } /** {@inheritDoc} */ @Override - public void calcKIJ(boolean ok) { - neqsim.thermo.mixingRule.EosMixingRules.calcEOSInteractionParameters = ok; - for (int i = 0; i < numberOfPhases; i++) { - ((PhaseEosInterface) getPhase(i)).getMixingRule().setCalcEOSInteractionParameters(ok); - } + public boolean isImplementedCompositionDeriativesofFugacity() { + return implementedCompositionDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public String getModelName() { - return modelName; + public void isImplementedCompositionDeriativesofFugacity(boolean isImpl) { + this.implementedCompositionDeriativesofFugacity = isImpl; } - /** - * Setter for property modelName. - * - * @param modelName New value of property modelName. - */ - public void setModelName(String modelName) { - this.modelName = modelName; + /** {@inheritDoc} */ + @Override + public boolean isImplementedPressureDeriativesofFugacity() { + return implementedPressureDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public boolean allowPhaseShift() { - return allowPhaseShift; + public boolean isImplementedTemperatureDeriativesofFugacity() { + return implementedTemperatureDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public void allowPhaseShift(boolean allowPhaseShift) { - this.allowPhaseShift = allowPhaseShift; + public boolean isMultiphaseWaxCheck() { + return multiphaseWaxCheck; } /** {@inheritDoc} */ @Override - public double getProperty(String prop, String compName, int phase) { - if (prop.equals("molefraction")) { - return getPhase(phase).getComponent(compName).getx(); - } else if (prop.equals("fugacitycoefficient")) { - return getPhase(phase).getComponent(compName).getFugacityCoefficient(); - } else if (prop.equals("logfugdT")) { - return getPhase(phase).getComponent(compName).getdfugdt(); - } else if (prop.equals("logfugdP")) { - return getPhase(phase).getComponent(compName).getdfugdp(); - } else { - return 1.0; - } + public boolean isNumericDerivatives() { + return numericDerivatives; } /** {@inheritDoc} */ @Override - public double getProperty(String prop, int phase) { - initPhysicalProperties(); - if (prop.equals("temperature")) { - return getPhase(phase).getTemperature(); - } else if (prop.equals("pressure")) { - return getPhase(phase).getPressure(); - } else if (prop.equals("compressibility")) { - return getPhase(phase).getZ(); - } else if (prop.equals("density")) { - return getPhase(phase).getPhysicalProperties().getDensity(); - } else if (prop.equals("beta")) { - return getPhase(phase).getBeta(); - } else if (prop.equals("enthalpy")) { - return getPhase(phase).getEnthalpy(); - } else if (prop.equals("entropy")) { - return getPhase(phase).getEntropy(); - } else if (prop.equals("viscosity")) { - return getPhase(phase).getPhysicalProperties().getViscosity(); - } else if (prop.equals("conductivity")) { - return getPhase(phase).getPhysicalProperties().getConductivity(); - } else { - return 1.0; + public boolean isPhase(int i) { + // TODO: what if i > numberofphases? + if (i > phaseArray.length) { + return false; } + + // getPhase(i) without try/catch + return phaseArray[phaseIndex[i]] != null; } /** {@inheritDoc} */ @Override - public double getProperty(String prop) { - if (prop.equals("numberOfPhases")) { - return numberOfPhases; - } else if (prop.equals("numberOfComponents")) { - return numberOfComponents; - } else if (prop.equals("enthalpy")) { - return getEnthalpy(); - } else if (prop.equals("entropy")) { - return getEntropy(); - } else if (prop.equals("temperature")) { - return getTemperature(); - } else if (prop.equals("pressure")) { - return getPressure(); - } else { - return 1.0; + public void normalizeBeta() { + double tot = 0.0; + for (int i = 0; i < numberOfPhases; i++) { + tot += beta[phaseIndex[i]]; + } + for (int i = 0; i < numberOfPhases; i++) { + beta[phaseIndex[i]] /= tot; } } /** {@inheritDoc} */ @Override - public void saveToDataBase() { - // java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM - // SYSTEMREPORT")); - // double molarmass = 0.0, stddens = 0.0, boilp = 0.0; - try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { - database.execute("delete FROM systemreport"); - int i = 0; - for (; i < numberOfComponents; i++) { - String sqlString = - "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " - + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; - - int j = 0; - for (; j < numberOfPhases; j++) { - sqlString += ", '" + Double.toString(getPhase(j).getComponent(i).getx()) + "'"; - } - - while (j < 3) { - j++; - sqlString += ", '0'"; - } - - logger.error(sqlString); - - database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); - } - - // beta - i++; - - String sqlString = "'" + Integer.toString(i + 1) + "', 'PhaseFraction', " + "'[-]', '1'"; - - int j = 0; - for (; j < numberOfPhases; j++) { - sqlString += ", '" + Double.toString(getPhase(j).getBeta()) + "'"; - } + public void orderByDensity() { + boolean change = false; + // int count = 0; - while (j < 3) { - j++; - sqlString += ", '0'"; + for (int i = 0; i < getNumberOfPhases(); i++) { + if (getPhase(i).getPhysicalProperties() == null) { + getPhase(i).initPhysicalProperties("density"); } + getPhase(i).getPhysicalProperties().setPhase(getPhase(i)); + } - logger.error(sqlString); - - database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); - - // molarmass - i++; - - sqlString = "'" + Integer.toString(i + 1) + "', 'MolarMass', " + "'kg/mol ', '" - + Double.toString(getMolarMass()) + "'"; + do { + change = false; + // count++; + for (int i = 1; i < getNumberOfPhases(); i++) { + if (i == 4) { + break; + } - j = 0; - for (; j < numberOfPhases; j++) { - sqlString += ", '" + Double.toString(getPhase(j).getMolarMass()) + "'"; - } - while (j < 3) { - j++; - sqlString += ", '0'"; + try { + if (change || getPhase(i).getPhysicalProperties() == null) { + getPhase(i).initPhysicalProperties("density"); + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + if (getPhase(i).getPhysicalProperties().calcDensity() < getPhase(i - 1) + .getPhysicalProperties().calcDensity()) { + int tempIndex1 = getPhaseIndex(i - 1); + int tempIndex2 = getPhaseIndex(i); + setPhaseIndex(i, tempIndex1); + setPhaseIndex(i - 1, tempIndex2); + change = true; + } } - - // System.out.println(sqlString); - database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); - - // dataSet.next(); - // dataSet.updateString("SPECIFICATION", "dette"); - // double test = dataSet.getDouble("Phase1"); - // System.out.println(test); - // dataSet.next(); - // dataSet.updateString(1,"tesst"); - } catch (Exception ex) { - logger.error("failed ", ex); - } - } - - /** {@inheritDoc} */ - @Override - public neqsim.standards.StandardInterface getStandard() { - return standard; + } while (change); } /** {@inheritDoc} */ @Override - public neqsim.standards.StandardInterface getStandard(String standardName) { - this.setStandard(standardName); - return standard; - } + public SystemInterface phaseToSystem(int phaseNumber) { + SystemInterface newSystem = this.clone(); - /** {@inheritDoc} */ - @Override - public void setStandard(String standardName) { - if (standardName.equals("ISO1992")) { - this.standard = new neqsim.standards.gasQuality.Standard_ISO6976(this); - } else if (standardName.equals("Draft_ISO18453")) { - this.standard = new neqsim.standards.gasQuality.Draft_ISO18453(this); - } else { - this.standard = new neqsim.standards.gasQuality.Standard_ISO6976(this); + for (int j = 0; j < getMaxNumberOfPhases(); j++) { + for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { + newSystem.getPhase(j).getComponent(i) + .setNumberOfmoles(getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase()); + newSystem.getPhase(j).getComponent(i).setNumberOfMolesInPhase( + getPhase(phaseNumber).getComponent(i).getNumberOfMolesInPhase()); + } } + + newSystem.setTotalNumberOfMoles(getPhase(phaseNumber).getNumberOfMolesInPhase()); + + newSystem.init(0); + newSystem.setNumberOfPhases(1); + newSystem.setPhaseType(0, getPhase(phaseNumber).getType()); // phaseType[phaseNumber]); + newSystem.init(1); + return newSystem; } /** {@inheritDoc} */ @Override - public boolean hasPlusFraction() { - for (int i = 0; i < numberOfComponents; i++) { - if (getPhase(0).getComponent(i).isIsPlusFraction()) { - return true; - } - } - return false; - } + public SystemInterface phaseToSystem(int phaseNumber1, int phaseNumber2) { + SystemInterface newSystem = this.clone(); - /** - *

- * hasTBPFraction. - *

- * - * @return a boolean - */ - public boolean hasTBPFraction() { - for (int i = 0; i < numberOfComponents; i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - return true; + for (int j = 0; j < getMaxNumberOfPhases(); j++) { + for (int i = 0; i < getPhase(j).getNumberOfComponents(); i++) { + newSystem.getPhases()[j].getComponents()[i] + .setNumberOfmoles(getPhase(phaseNumber1).getComponents()[i].getNumberOfMolesInPhase() + + getPhase(phaseNumber2).getComponents()[i].getNumberOfMolesInPhase()); + newSystem.getPhases()[j].getComponents()[i].setNumberOfMolesInPhase( + getPhase(phaseNumber1).getComponents()[i].getNumberOfMolesInPhase() + + getPhase(phaseNumber2).getComponents()[i].getNumberOfMolesInPhase()); } } - return false; + + newSystem.setTotalNumberOfMoles(getPhase(phaseNumber1).getNumberOfMolesInPhase() + + getPhase(phaseNumber2).getNumberOfMolesInPhase()); + + newSystem.init(0); + + newSystem.setNumberOfPhases(1); + // newSystem.setPhaseType(0, + // getPhase(phaseNumber1).getType()); //phaseType[phaseNumber]); + newSystem.init(1); + return newSystem; } /** {@inheritDoc} */ @Override - public void tuneModel(String model, double val, int phase) { - if (model.equals("viscosity")) { - getPhase(phase).getPhysicalProperties().getViscosityModel().tuneModel(val, - getPhase(phase).getTemperature(), getPhase(phase).getPressure()); - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - for (int j = 0; j < numberOfPhases; j++) { - getPhase(i).getComponent(j) - .setCriticalViscosity(getPhase(phase).getComponent(j).getCriticalViscosity()); - } - } + public SystemInterface phaseToSystem(PhaseInterface newPhase) { + // TODO: other phaseToSystem functions returns clones. + for (int i = 0; i < newPhase.getNumberOfComponents(); i++) { + newPhase.getComponents()[i] + .setNumberOfmoles(newPhase.getComponents()[i].getNumberOfMolesInPhase()); } - initPhysicalProperties(); + + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + phaseArray[i] = newPhase.clone(); + } + + setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); + this.init(0); + setNumberOfPhases(1); + setPhaseType(0, newPhase.getType()); + initBeta(); + init_x_y(); + this.init(1); + return this; } /** {@inheritDoc} */ @Override - public double getHeatOfVaporization() { - if (numberOfPhases < 2) { - return 0; - } else { - return getPhase(0).getEnthalpy() / getPhase(0).getNumberOfMolesInPhase() - - getPhase(1).getEnthalpy() / getPhase(1).getNumberOfMolesInPhase(); + public SystemInterface phaseToSystem(String phaseName) { + try { + for (int j = 0; j < getMaxNumberOfPhases(); j++) { + if (this.getPhase(j).getPhaseTypeName().equals(phaseName)) { + return phaseToSystem(j); + } + } + } catch (Exception ex) { + logger.error("error....." + fluidName + " has no phase .... " + phaseName + + " ..... returning phase number 0"); } + return phaseToSystem(0); } /** {@inheritDoc} */ @@ -4325,8 +3861,205 @@ public void readFluid(String fluidName) { /** {@inheritDoc} */ @Override - public String[][] getResultTable() { - return resultTable; + public SystemInterface readObject(int ID) { + java.sql.ResultSet rs = null; + SystemThermo tempSystem = null; + neqsim.util.database.NeqSimBlobDatabase database = + new neqsim.util.database.NeqSimBlobDatabase(); + try { + java.sql.Connection con = database.openConnection(); + String sqlStr = "SELECT FLUID FROM fluid_blobdb WHERE ID=" + Integer.toString(ID); + java.sql.PreparedStatement ps = con.prepareStatement(sqlStr); + rs = ps.executeQuery(); + + if (rs.next()) { + try (ObjectInputStream ins = + new ObjectInputStream(new ByteArrayInputStream(rs.getBytes("FLUID")))) { + tempSystem = (SystemThermo) ins.readObject(); + } + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } finally { + try { + if (database.getStatement() != null) { + database.getStatement().close(); + } + if (database.getConnection() != null) { + database.getConnection().close(); + } + } catch (Exception ex) { + logger.error("err closing database IN MIX...", ex); + } + } + + return tempSystem; + } + + /** {@inheritDoc} */ + @Override + public SystemInterface readObjectFromFile(String filePath, String fluidName) { + SystemThermo tempSystem = null; + try (ObjectInputStream objectinputstream = + new ObjectInputStream(new FileInputStream(filePath))) { + tempSystem = (SystemThermo) objectinputstream.readObject(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + return tempSystem; + } + + /** + * Re-initialize phasetype, beta and phaseindex arrays, same initialization which is used in + * constructor. + */ + public void reInitPhaseInformation() { + reInitPhaseType(); + phaseType[4] = phaseType[3]; + phaseType[5] = phaseType[3]; + + for (int i = 0; i < MAX_PHASES; i++) { + beta[i] = 1.0; + } + + phaseIndex = new int[] {0, 1, 2, 3, 4, 5}; + } + + /** {@inheritDoc} */ + @Override + public void reInitPhaseType() { + phaseType[0] = PhaseType.byValue(1); + phaseType[1] = PhaseType.byValue(0); + phaseType[2] = PhaseType.byValue(0); + phaseType[3] = PhaseType.byValue(0); + // TODO: why stop at 3 and not iterate through MAX_PHASES elements? + } + + /** {@inheritDoc} */ + @Override + public void removeComponent(String name) { + name = ComponentInterface.getComponentNameFromAlias(name); + + setTotalNumberOfMoles( + getTotalNumberOfMoles() - phaseArray[0].getComponent(name).getNumberOfmoles()); + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + getPhase(i).removeComponent(name, getTotalNumberOfMoles(), + getPhase(i).getComponent(name).getNumberOfMolesInPhase()); + } + + componentNames.remove(name); + numberOfComponents--; + } + + /** {@inheritDoc} */ + @Override + public void removePhase(int specPhase) { + setTotalNumberOfMoles(getTotalNumberOfMoles() - getPhase(specPhase).getNumberOfMolesInPhase()); + + for (int j = 0; j < numberOfPhases; j++) { + for (int i = 0; i < numberOfComponents; i++) { + getPhase(j).getComponents()[i] + .setNumberOfmoles(getPhase(j).getComponents()[i].getNumberOfmoles() + - getPhase(specPhase).getComponents()[i].getNumberOfMolesInPhase()); + } + } + + ArrayList phaseList = new ArrayList(0); + for (int i = 0; i < numberOfPhases; i++) { + if (specPhase != i) { + phaseList.add(phaseArray[phaseIndex[i]]); + } + } + + // phaseArray = new PhaseInterface[numberOfPhases - 1]; + for (int i = 0; i < numberOfPhases - 1; i++) { + // phaseArray[i] = (PhaseInterface) phaseList.get(i); + if (i >= specPhase) { + phaseIndex[i] = phaseIndex[i + 1]; + phaseType[i] = phaseType[i + 1]; + } + } + numberOfPhases--; + } + + /** {@inheritDoc} */ + @Override + public void removePhaseKeepTotalComposition(int specPhase) { + ArrayList phaseList = new ArrayList(0); + for (int i = 0; i < numberOfPhases; i++) { + if (specPhase != i) { + phaseList.add(phaseArray[phaseIndex[i]]); + } + } + + // phaseArray = new PhaseInterface[numberOfPhases - 1]; + for (int i = 0; i < numberOfPhases - 1; i++) { + // phaseArray[i] = (PhaseInterface) phaseList.get(i); + if (i >= specPhase) { + phaseIndex[i] = phaseIndex[i + 1]; + phaseType[i] = phaseType[i + 1]; + } + } + numberOfPhases--; + } + + /** {@inheritDoc} */ + @Override + public void renameComponent(String oldName, String newName) { + componentNames.set(getPhase(0).getComponent(oldName).getComponentNumber(), newName); + for (int i = 0; i < maxNumberOfPhases; i++) { + getPhase(i).getComponent(oldName).setComponentName(newName); + } + } + + /** {@inheritDoc} */ + @Override + public void replacePhase(int repPhase, PhaseInterface newPhase) { + for (int i = 0; i < 2; i++) { + phaseArray[i] = newPhase.clone(); + } + setTotalNumberOfMoles(newPhase.getNumberOfMolesInPhase()); + } + + /** {@inheritDoc} */ + @Override + public void reset() { + for (int i = 0; i < numberOfComponents; i++) { + // TODO: numeric issue, nearly zero + addComponent(getPhase(0).getComponent(i).getComponentName(), + -getPhase(0).getComponent(i).getNumberOfmoles()); + } + } + + /** {@inheritDoc} */ + @Override + public void reset_x_y() { + for (int j = 0; j < numberOfPhases; j++) { + for (int i = 0; i < numberOfComponents; i++) { + getPhase(j).getComponents()[i].setx(phaseArray[phaseIndex[0]].getComponents()[i].getz()); + } + } + } + + /** {@inheritDoc} */ + @Override + public void resetCharacterisation() { + int numberOfLumpedComps = characterization.getLumpingModel().getNumberOfLumpedComponents(); + characterization = new Characterise(this); + characterization.getLumpingModel().setNumberOfLumpedComponents(numberOfLumpedComps); + } + + /** {@inheritDoc} */ + @Override + public void resetDatabase() { + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { + if (NeqSimDataBase.createTemporaryTables()) { + database.execute("delete FROM comptemp"); + database.execute("delete FROM intertemp"); + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } } // public String[] getResultArray1(){ @@ -4343,354 +4076,338 @@ public String[][] getResultTable() { /** {@inheritDoc} */ @Override - public SystemInterface setModel(String model) { - SystemInterface tempModel = null; - try { - if (model.equals("SRK-EOS")) { - tempModel = new SystemSrkEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("GERG2004-EOS")) { - tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("PrEos") || model.equals("PR-EOS")) { - tempModel = new SystemPrEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("ScRK-EOS") || model.equals("ScRK-EOS-HV")) { - tempModel = new SystemSrkSchwartzentruberEos(getPhase(0).getTemperature(), - getPhase(0).getPressure()); - } else if (model.equals("Electrolyte-ScRK-EOS")) { - tempModel = - new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("GERG-water-EOS")) { - tempModel = new SystemGERGwaterEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("CPAs-SRK-EOS")) { - tempModel = new SystemSrkCPAs(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("CPAs-SRK-EOS-statoil")) { - tempModel = - new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("Electrolyte-CPA-EOS-statoil") - || model.equals("Electrolyte-CPA-EOS")) { - tempModel = new SystemElectrolyteCPAstatoil(getPhase(0).getTemperature(), - getPhase(0).getPressure()); - } else if (model.equals("UMR-PRU-EoS")) { - tempModel = new SystemUMRPRUMCEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("PC-SAFT")) { - tempModel = new SystemPCSAFT(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("GERG-2008-EoS")) { - tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("SRK-TwuCoon-Statoil-EOS") || model.equals("SRK-TwuCoon-EOS")) { - tempModel = - new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("SRK-TwuCoon-Param-EOS")) { - tempModel = - new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else if (model.equals("Duan-Sun")) { - tempModel = new SystemDuanSun(getPhase(0).getTemperature(), getPhase(0).getPressure()); - } else { - logger.error("model : " + model + " not defined....."); - } - // tempModel.getCharacterization().setTBPModel("RiaziDaubert"); - tempModel.useVolumeCorrection(true); - - logger.info("created class " + tempModel); - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - logger.info("adding " + getPhase(0).getComponent(i).getName() + " moles " - + getPhase(0).getComponent(i).getNumberOfmoles() + " isPlus " - + getPhase(0).getComponent(i).isIsPlusFraction() + " isTBP " - + getPhase(0).getComponent(i).isIsTBPfraction()); - if (getPhase(0).getComponent(i).isIsTBPfraction()) { - tempModel.addTBPfraction(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getMolarMass(), - getPhase(0).getComponent(i).getNormalLiquidDensity()); - } else if (getPhase(0).getComponent(i).isIsPlusFraction()) { - tempModel.addPlusFraction(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles(), - getPhase(0).getComponent(i).getMolarMass(), - getPhase(0).getComponent(i).getNormalLiquidDensity()); - } else { - tempModel.addComponent(getPhase(0).getComponent(i).getName(), - getPhase(0).getComponent(i).getNumberOfmoles()); - } + public void resetPhysicalProperties() { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.resetPhysicalProperties(); } + } + } - // if (tempModel.getCharacterization().characterize()) { - // tempModel.addPlusFraction(6, 100); - // } - if (NeqSimDataBase.createTemporaryTables()) { - logger.info("done ... create database ......"); - tempModel.createDatabase(true); - } - logger.info("done ... set mixing rule ......"); - tempModel.autoSelectMixingRule(); - if (model.equals("Electrolyte-ScRK-EOS")) { // || - // model.equals("Electrolyte-CPA-EOS-statoil" - logger.info("chemical reaction init......"); - tempModel.setMultiPhaseCheck(false); - tempModel.chemicalReactionInit(); - } else { - tempModel.setMultiPhaseCheck(true); - } + /** {@inheritDoc} */ + @Override + public void save(String name) { + try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name))) { + out.writeObject(this); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } - return tempModel; } /** {@inheritDoc} */ @Override - public SystemInterface autoSelectModel() { - if (this.getPhase(0).hasComponent("MDEA") && this.getPhase(0).hasComponent("water") - && this.getPhase(0).hasComponent("CO2")) { - return setModel("Electrolyte-ScRK-EOS"); - } else if (this.getPhase(0).hasComponent("water") || this.getPhase(0).hasComponent("methanol") - || this.getPhase(0).hasComponent("MEG") || this.getPhase(0).hasComponent("TEG") - || this.getPhase(0).hasComponent("ethanol") || this.getPhase(0).hasComponent("DEG")) { - if (this.getPhase(0).hasComponent("Na+") || this.getPhase(0).hasComponent("K+") - || this.getPhase(0).hasComponent("Br-") || this.getPhase(0).hasComponent("Mg++") - || this.getPhase(0).hasComponent("Cl-") || this.getPhase(0).hasComponent("Ca++") - || this.getPhase(0).hasComponent("Fe++") || this.getPhase(0).hasComponent("SO4--")) { - logger.info("model elect"); - return setModel("Electrolyte-CPA-EOS-statoil"); - } else { - return setModel("CPAs-SRK-EOS-statoil"); + public void saveFluid(int ID) { + saveObject(ID, ""); + } + + /** {@inheritDoc} */ + @Override + public void saveFluid(int ID, String text) { + saveObject(ID, text); + } + + /** {@inheritDoc} */ + @Override + public void saveObject(int ID, String text) { + ByteArrayOutputStream fout = new ByteArrayOutputStream(); + try (ObjectOutputStream out = new ObjectOutputStream(fout)) { + out.writeObject(this); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + byte[] byteObject = fout.toByteArray(); + ByteArrayInputStream inpStream = new ByteArrayInputStream(byteObject); + + neqsim.util.database.NeqSimBlobDatabase database = + new neqsim.util.database.NeqSimBlobDatabase(); + + try { + java.sql.Connection con = database.openConnection(); + + java.sql.PreparedStatement ps = + con.prepareStatement("REPLACE INTO fluid_blobdb (ID, FLUID) VALUES (?,?)"); + ps.setInt(1, ID); + ps.setBlob(2, inpStream); + + ps.executeUpdate(); + /* + * if (!text.isEmpty()) { ps = con.prepareStatement( + * "REPLACE INTO fluidinfo (ID, TEXT) VALUES (?,?)"); ps.setInt(1, ID); ps.setString(2, text); + * } + * + * ps.executeUpdate(); + */ + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } finally { + try { + if (database.getStatement() != null) { + database.getStatement().close(); + } + if (database.getConnection() != null) { + database.getConnection().close(); + } + } catch (Exception ex) { + logger.error("err closing database IN MIX...", ex); } - } else if (this.getPhase(0).hasComponent("water")) { - return setModel("ScRK-EOS"); - } else if (this.getPhase(0).hasComponent("mercury")) { - return setModel("SRK-TwuCoon-Statoil-EOS"); - } else { - logger.info("no model"); - return setModel("SRK-EOS"); } + // database.execute("INSERT INTO fluid_blobdb VALUES ('1'," + sqlString + ")"); } /** {@inheritDoc} */ @Override - public void autoSelectMixingRule() { - logger.info("setting mixing rule"); - if (modelName.equals("CPAs-SRK-EOS") || modelName.equals("CPA-SRK-EOS") - || modelName.equals("Electrolyte-CPA-EOS-statoil") - || modelName.equals("CPAs-SRK-EOS-statoil") || modelName.equals("Electrolyte-CPA-EOS")) { - this.setMixingRule(10); - // System.out.println("mix rule 10"); - } else if ((modelName.equals("ScRK-EOS-HV") || modelName.equals("SRK-EOS") - || modelName.equals("ScRK-EOS")) && this.getPhase(0).hasComponent("water")) { - this.setMixingRule(4); - } else if (modelName.equals("PR-EOS")) { - this.setMixingRule(2); - } else if (modelName.equals("Electrolyte-ScRK-EOS")) { - this.setMixingRule(4); - } else if (modelName.equals("UMR-PRU-EoS") || modelName.equals("UMR-PRU-MC-EoS")) { - this.setMixingRule("HV", "UNIFAC_UMRPRU"); - } else if (modelName.equals("GERG-water-EOS")) { - this.setMixingRule(8); - } else if (modelName.equals("GERG-2008-EOS")) { - this.setMixingRule(2); - } else if (modelName.equals("PC-SAFT")) { - this.setMixingRule(8); - } else { - this.setMixingRule(2); + public void saveObjectToFile(String filePath, String fluidName) { + try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filePath, false))) { + out.writeObject(this); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + } + + /** {@inheritDoc} */ + @Override + public void saveToDataBase() { + // java.sql.ResultSet dataSet = database.getResultSet(("SELECT * FROM + // SYSTEMREPORT")); + // double molarmass = 0.0, stddens = 0.0, boilp = 0.0; + try (neqsim.util.database.NeqSimDataBase database = new neqsim.util.database.NeqSimDataBase()) { + database.execute("delete FROM systemreport"); + int i = 0; + for (; i < numberOfComponents; i++) { + String sqlString = + "'" + Integer.toString(i + 1) + "', '" + getPhase(0).getComponent(i).getName() + "', " + + "'molfrac[-] ', '" + Double.toString(getPhase(0).getComponent(i).getz()) + "'"; + + int j = 0; + for (; j < numberOfPhases; j++) { + sqlString += ", '" + Double.toString(getPhase(j).getComponent(i).getx()) + "'"; + } + + while (j < 3) { + j++; + sqlString += ", '0'"; + } + + logger.error(sqlString); + + database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); + } + + // beta + i++; + + String sqlString = "'" + Integer.toString(i + 1) + "', 'PhaseFraction', " + "'[-]', '1'"; + + int j = 0; + for (; j < numberOfPhases; j++) { + sqlString += ", '" + Double.toString(getPhase(j).getBeta()) + "'"; + } + + while (j < 3) { + j++; + sqlString += ", '0'"; + } + + logger.error(sqlString); + + database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); + + // molarmass + i++; + + sqlString = "'" + Integer.toString(i + 1) + "', 'MolarMass', " + "'kg/mol ', '" + + Double.toString(getMolarMass()) + "'"; + + j = 0; + for (; j < numberOfPhases; j++) { + sqlString += ", '" + Double.toString(getPhase(j).getMolarMass()) + "'"; + } + while (j < 3) { + j++; + sqlString += ", '0'"; + } + + // System.out.println(sqlString); + database.execute("INSERT INTO systemreport VALUES (" + sqlString + ")"); + + // dataSet.next(); + // dataSet.updateString("SPECIFICATION", "dette"); + // double test = dataSet.getDouble("Phase1"); + // System.out.println(test); + // dataSet.next(); + // dataSet.updateString(1,"tesst"); + } catch (Exception ex) { + logger.error("failed ", ex); } } /** {@inheritDoc} */ @Override - public int getMixingRule() { - return mixingRule; + public void setAllComponentsInPhase(int phase) { + for (int k = 0; k < numberOfPhases; k++) { + for (int i = 0; i < numberOfComponents; i++) { + if (phase != k) { + // System.out.println("moles of comp: " + i + " " + + // phaseArray[k].getComponents()[i].getNumberOfMolesInPhase()); + phaseArray[phase].addMoles(i, + (phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() * (1.0 - 0.01))); + phaseArray[k].addMoles(i, + -(phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() * (1.0 - 0.01))); + phaseArray[k].getComponents()[i] + .setx(phaseArray[k].getComponents()[i].getNumberOfMolesInPhase() + / phaseArray[k].getNumberOfMolesInPhase()); + // System.out.println("moles of comp after: " + i + " " + + // phaseArray[k].getComponents()[i].getNumberOfMolesInPhase()); + } + } + } + initBeta(); + init(1); } /** {@inheritDoc} */ @Override - public void orderByDensity() { - boolean change = false; - // int count = 0; - - for (int i = 0; i < getNumberOfPhases(); i++) { - if (getPhase(i).getPhysicalProperties() == null) { - getPhase(i).initPhysicalProperties("density"); + public void setAllPhaseType(PhaseType pt) { + if (allowPhaseShift) { + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + setPhaseType(i, pt); } - getPhase(i).getPhysicalProperties().setPhase(getPhase(i)); } - - do { - change = false; - // count++; - for (int i = 1; i < getNumberOfPhases(); i++) { - if (i == 4) { - break; - } - - try { - if (change || getPhase(i).getPhysicalProperties() == null) { - getPhase(i).initPhysicalProperties("density"); - } - } catch (Exception ex) { - logger.error(ex.getMessage(), ex); - } - if (getPhase(i).getPhysicalProperties().calcDensity() < getPhase(i - 1) - .getPhysicalProperties().calcDensity()) { - int tempIndex1 = getPhaseIndex(i - 1); - int tempIndex2 = getPhaseIndex(i); - setPhaseIndex(i, tempIndex1); - setPhaseIndex(i - 1, tempIndex2); - change = true; - } - } - } while (change); } /** {@inheritDoc} */ @Override - public void addLiquidToGas(double fraction) { - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - double change = getPhase(1).getComponent(i).getNumberOfMolesInPhase() * fraction; - addComponent(i, change, 0); - addComponent(i, -change, 1); + public void setAttractiveTerm(int i) { + for (int k = 0; k < getMaxNumberOfPhases(); k++) { + phaseArray[k].setAttractiveTerm(i); } } /** {@inheritDoc} */ @Override - public void addPhaseFractionToPhase(double fraction, String specification, String fromPhaseName, - String toPhaseName) { - if (!(hasPhaseType(fromPhaseName) && hasPhaseType(toPhaseName) || fraction < 1e-30)) { - return; + public final void setBeta(double b) { + if (b < 0) { + b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; } - int phaseNumbFrom = getPhaseNumberOfPhase(fromPhaseName); - int phaseNumbTo = getPhaseNumberOfPhase(toPhaseName); - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - double change = getPhase(phaseNumbFrom).getComponent(i).getNumberOfMolesInPhase() * fraction; - addComponent(i, change, phaseNumbTo); - addComponent(i, -change, phaseNumbFrom); + if (b > 1) { + b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; } - init_x_y(); + beta[0] = b; + beta[1] = 1.0 - b; } /** {@inheritDoc} */ @Override - public void addPhaseFractionToPhase(double fraction, String specification, String specifiedStream, - String fromPhaseName, String toPhaseName) { - double moleFraction = fraction; - if (!hasPhaseType(fromPhaseName) || !hasPhaseType(toPhaseName) || fraction < 1e-30) { - return; + public final void setBeta(int phase, double b) { + if (b < 0) { + b = neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; } - int phaseNumbFrom = getPhaseNumberOfPhase(fromPhaseName); - int phaseNumbTo = getPhaseNumberOfPhase(toPhaseName); - - if (specifiedStream.equals("feed")) { - moleFraction = fraction; - } else if (specifiedStream.equals("product")) { - // double specFractionFrom = getPhaseFraction(specification, fromPhaseName); - double specFractionTo = getPhaseFraction(specification, toPhaseName); - - double moleFractionFrom = getMoleFraction(phaseNumbFrom); - double moleFractionTo = getMoleFraction(phaseNumbTo); - - if (specification.equals("volume") || specification.equals("mass")) { - double test = fraction * specFractionTo / (fraction * specFractionTo + specFractionTo); - moleFraction = test * moleFractionTo / specFractionTo; - } else if (specification.equals("mole")) { - double test = fraction * moleFractionTo / (fraction * moleFractionTo + moleFractionTo); - moleFraction = test; - } - - moleFraction = moleFraction * moleFractionTo / moleFractionFrom; - if (moleFraction > moleFractionFrom) { - logger.debug("error in addPhaseFractionToPhase()...to low fraction in from phase"); - moleFraction = moleFractionFrom; - } + if (b > 1) { + b = 1.0 - neqsim.thermo.ThermodynamicModelSettings.phaseFractionMinimumLimit; } + beta[phaseIndex[phase]] = b; + } - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - double change = 0.0; - change = getPhase(phaseNumbFrom).getComponent(i).getNumberOfMolesInPhase() * moleFraction; - addComponent(i, change, phaseNumbTo); - addComponent(i, -change, phaseNumbFrom); + /** {@inheritDoc} */ + @Override + public void setBmixType(int bmixType) { + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + ((PhaseEosInterface) getPhase(i)).getMixingRule().setBmixType(bmixType); } - init_x_y(); } /** {@inheritDoc} */ @Override - public void addGasToLiquid(double fraction) { - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - double change = getPhase(0).getComponent(i).getNumberOfMolesInPhase() * fraction; - addComponent(i, -change, 0); - addComponent(i, change, 1); + public void setComponentNames(String[] componentNames) { + for (int i = 0; i < componentNames.length; i++) { + this.componentNames.set(i, componentNames[i]); } } /** {@inheritDoc} */ @Override - public double getTotalNumberOfMoles() { - return this.totalNumberOfMoles; + public void setComponentNameTag(String nameTag) { + componentNameTag = nameTag; + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + renameComponent(componentNames.get(i), componentNames.get(i) + nameTag); + } } /** {@inheritDoc} */ @Override - public void setTotalNumberOfMoles(double totalNumberOfMoles) { - if (totalNumberOfMoles < 0) { - /* - * throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, - * "setTotalNumberOfMoles", "totalNumberOfMoles", "can not be less than 0.")); - */ - totalNumberOfMoles = 0; + public void setComponentNameTagOnNormalComponents(String nameTag) { + componentNameTag = nameTag; + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + if (!getPhase(0).getComponent(i).isIsTBPfraction() + && !getPhase(0).getComponent(i).isIsPlusFraction()) { + renameComponent(componentNames.get(i), componentNames.get(i) + nameTag); + } } - this.totalNumberOfMoles = totalNumberOfMoles; } /** {@inheritDoc} */ @Override - public double calcHenrysConstant(String component) { - if (numberOfPhases != 2) { - logger.error("Can't calculate Henrys constant - two phases must be present."); - return 0; - } else { - int compNumb = getPhase(getPhaseIndex(0)).getComponent(component).getComponentNumber(); - double hc = getPhase(getPhaseIndex(0)).getFugacity(compNumb) - / getPhase(getPhaseIndex(1)).getComponent(component).getx(); - return hc; + public void setEmptyFluid() { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.setEmptyFluid(); + } } + totalNumberOfMoles = 0.0; } - /** - *

- * useTVasIndependentVariables. - *

- * - * @return a boolean - */ - public boolean useTVasIndependentVariables() { - return useTVasIndependentVariables; + /** {@inheritDoc} */ + @Override + public void setFluidInfo(String info) { + this.fluidInfo = info; } /** {@inheritDoc} */ @Override - public void setUseTVasIndependentVariables(boolean useTVasIndependentVariables) { - for (int i = 0; i < numberOfPhases; i++) { - getPhase(i).setTotalVolume(getPhase(i).getVolume()); - getPhase(i).setConstantPhaseVolume(useTVasIndependentVariables); - getPhase(i).calcMolarVolume(!useTVasIndependentVariables); - } - this.useTVasIndependentVariables = useTVasIndependentVariables; + public void setFluidName(String fluidName) { + this.fluidName = fluidName; } /** {@inheritDoc} */ @Override - public void setBmixType(int bmixType) { - for (int i = 0; i < getMaxNumberOfPhases(); i++) { - ((PhaseEosInterface) getPhase(i)).getMixingRule().setBmixType(bmixType); - } + public void setForcePhaseTypes(boolean forcePhaseTypes) { + this.forcePhaseTypes = forcePhaseTypes; } /** {@inheritDoc} */ @Override - public boolean isImplementedCompositionDeriativesofFugacity() { - return implementedCompositionDeriativesofFugacity; + public boolean setHeavyTBPfractionAsPlusFraction() { + int compNumber = 0; + double molarMass = 0; + boolean foundTBP = false; + + for (int i = 0; i < numberOfComponents; i++) { + if (getPhase(0).getComponent(i).isIsTBPfraction() + || getPhase(0).getComponent(i).isIsPlusFraction()) { + if (getPhase(0).getComponent(i).getMolarMass() > molarMass) { + molarMass = getPhase(0).getComponent(i).getMolarMass(); + compNumber = i; + foundTBP = true; + } + } + } + if (foundTBP) { + for (int i = 0; i < maxNumberOfPhases; i++) { + getPhase(0).getComponent(compNumber).setIsPlusFraction(true); + } + } + return foundTBP; } /** {@inheritDoc} */ @Override - public void isImplementedCompositionDeriativesofFugacity(boolean isImpl) { - this.implementedCompositionDeriativesofFugacity = isImpl; + public void setHydrateCheck(boolean hydrateCheck) { + init(0); + if (hydrateCheck) { + addHydratePhase(); + } + this.hydrateCheck = hydrateCheck; + init(0); } /** {@inheritDoc} */ @@ -4709,54 +4426,210 @@ public void setImplementedPressureDeriativesofFugacity( /** {@inheritDoc} */ @Override - public boolean isImplementedPressureDeriativesofFugacity() { - return implementedPressureDeriativesofFugacity; + public void setImplementedTemperatureDeriativesofFugacity( + boolean implementedTemperatureDeriativesofFugacity) { + this.implementedTemperatureDeriativesofFugacity = implementedTemperatureDeriativesofFugacity; } /** {@inheritDoc} */ @Override - public boolean isImplementedTemperatureDeriativesofFugacity() { - return implementedTemperatureDeriativesofFugacity; + public void setInitType(int initType) { + this.initType = initType; + } + + /** + *

+ * setLastTBPasPlus. + *

+ * + * @return a boolean + */ + public boolean setLastTBPasPlus() { + neqsim.thermo.characterization.PlusCharacterize temp = + new neqsim.thermo.characterization.PlusCharacterize(this); + if (temp.hasPlusFraction()) { + return false; + } else { + temp.setHeavyTBPtoPlus(); + } + return true; } /** {@inheritDoc} */ @Override - public void setImplementedTemperatureDeriativesofFugacity( - boolean implementedTemperatureDeriativesofFugacity) { - this.implementedTemperatureDeriativesofFugacity = implementedTemperatureDeriativesofFugacity; + public void setMaxNumberOfPhases(int maxNumberOfPhases) { + this.maxNumberOfPhases = maxNumberOfPhases; } /** {@inheritDoc} */ @Override - public void deleteFluidPhase(int phase) { - for (int i = phase; i < numberOfPhases; i++) { - phaseIndex[i] = phaseIndex[i + 1]; + public final void setMixingRule(int type) { + mixingRule = type; + if (numberOfPhases < 4) { + resetPhysicalProperties(); + } + for (int i = 0; i < maxNumberOfPhases; i++) { + if (isPhase(i)) { + getPhase(i).setMixingRule(type); + getPhase(i).initPhysicalProperties(); + } } - numberOfPhases--; } /** {@inheritDoc} */ @Override - public int getMaxNumberOfPhases() { - return maxNumberOfPhases; + public void setMixingRule(String typename) { + int var = 0; + if (typename.equals("no")) { + var = 1; + } else if (typename.equals("classic")) { + var = 2; + } else if (typename.equals("HV")) { + var = 4; + } else if (typename.equals("WS")) { + var = 5; + } else if (typename.equals("CPA-Mix")) { + var = 7; + } else if (typename.equals("classic-T")) { + var = 8; + } else if (typename.equals("classic-T-cpa")) { + var = 9; + } else if (typename.equals("classic-Tx-cpa")) { + var = 10; + } else { + var = 1; + } + this.setMixingRule(var); } /** {@inheritDoc} */ @Override - public void setMaxNumberOfPhases(int maxNumberOfPhases) { - this.maxNumberOfPhases = maxNumberOfPhases; + public void setMixingRule(String typename, String GEmodel) { + setMixingRuleGEmodel(GEmodel); + setMixingRule(typename); + } + + /** + *

+ * setMixingRuleGEmodel. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setMixingRuleGEmodel(String name) { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.setMixingRuleGEModel(name); + } + } } /** {@inheritDoc} */ @Override - public void setMolarComposition(double[] molefractions) { - setMolarFractions(molefractions, ""); + public SystemInterface setModel(String model) { + SystemInterface tempModel = null; + try { + if (model.equals("SRK-EOS")) { + tempModel = new SystemSrkEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("GERG2004-EOS")) { + tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("PrEos") || model.equals("PR-EOS")) { + tempModel = new SystemPrEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("ScRK-EOS") || model.equals("ScRK-EOS-HV")) { + tempModel = new SystemSrkSchwartzentruberEos(getPhase(0).getTemperature(), + getPhase(0).getPressure()); + } else if (model.equals("Electrolyte-ScRK-EOS")) { + tempModel = + new SystemFurstElectrolyteEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("GERG-water-EOS")) { + tempModel = new SystemGERGwaterEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("CPAs-SRK-EOS")) { + tempModel = new SystemSrkCPAs(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("CPAs-SRK-EOS-statoil")) { + tempModel = + new SystemSrkCPAstatoil(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("Electrolyte-CPA-EOS-statoil") + || model.equals("Electrolyte-CPA-EOS")) { + tempModel = new SystemElectrolyteCPAstatoil(getPhase(0).getTemperature(), + getPhase(0).getPressure()); + } else if (model.equals("UMR-PRU-EoS")) { + tempModel = new SystemUMRPRUMCEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("PC-SAFT")) { + tempModel = new SystemPCSAFT(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("GERG-2008-EoS")) { + tempModel = new SystemGERG2004Eos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("SRK-TwuCoon-Statoil-EOS") || model.equals("SRK-TwuCoon-EOS")) { + tempModel = + new SystemSrkTwuCoonStatoilEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("SRK-TwuCoon-Param-EOS")) { + tempModel = + new SystemSrkTwuCoonParamEos(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else if (model.equals("Duan-Sun")) { + tempModel = new SystemDuanSun(getPhase(0).getTemperature(), getPhase(0).getPressure()); + } else { + logger.error("model : " + model + " not defined....."); + } + // tempModel.getCharacterization().setTBPModel("RiaziDaubert"); + tempModel.useVolumeCorrection(true); + + logger.info("created class " + tempModel); + for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { + logger.info("adding " + getPhase(0).getComponent(i).getName() + " moles " + + getPhase(0).getComponent(i).getNumberOfmoles() + " isPlus " + + getPhase(0).getComponent(i).isIsPlusFraction() + " isTBP " + + getPhase(0).getComponent(i).isIsTBPfraction()); + if (getPhase(0).getComponent(i).isIsTBPfraction()) { + tempModel.addTBPfraction(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getMolarMass(), + getPhase(0).getComponent(i).getNormalLiquidDensity()); + } else if (getPhase(0).getComponent(i).isIsPlusFraction()) { + tempModel.addPlusFraction(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles(), + getPhase(0).getComponent(i).getMolarMass(), + getPhase(0).getComponent(i).getNormalLiquidDensity()); + } else { + tempModel.addComponent(getPhase(0).getComponent(i).getName(), + getPhase(0).getComponent(i).getNumberOfmoles()); + } + } + + // if (tempModel.getCharacterization().characterize()) { + // tempModel.addPlusFraction(6, 100); + // } + if (NeqSimDataBase.createTemporaryTables()) { + logger.info("done ... create database ......"); + tempModel.createDatabase(true); + } + logger.info("done ... set mixing rule ......"); + tempModel.autoSelectMixingRule(); + if (model.equals("Electrolyte-ScRK-EOS")) { // || + // model.equals("Electrolyte-CPA-EOS-statoil" + logger.info("chemical reaction init......"); + tempModel.setMultiPhaseCheck(false); + tempModel.chemicalReactionInit(); + } else { + tempModel.setMultiPhaseCheck(true); + } + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + return tempModel; + } + + /** + * Setter for property modelName. + * + * @param modelName New value of property modelName. + */ + public void setModelName(String modelName) { + this.modelName = modelName; } /** {@inheritDoc} */ @Override - public void setMolarCompositionPlus(double[] molefractions) { - setMolarFractions(molefractions, "Plus"); + public void setMolarComposition(double[] molefractions) { + setMolarFractions(molefractions, ""); } /** {@inheritDoc} */ @@ -4765,6 +4638,12 @@ public void setMolarCompositionOfPlusFluid(double[] molefractions) { setMolarFractions(molefractions, "PlusFluid"); } + /** {@inheritDoc} */ + @Override + public void setMolarCompositionPlus(double[] molefractions) { + setMolarFractions(molefractions, "Plus"); + } + /** {@inheritDoc} */ @Override public void setMolarFlowRates(double[] moles) { @@ -4777,33 +4656,85 @@ public void setMolarFlowRates(double[] moles) { } } + /** + * Wrapper function for addComponent to set fluid type and specify mole fractions. + * + * @param molefractions Component mole fraction of each component. + * @param type Type of fluid. Supports "PlusFluid", "Plus" and default. + */ + private void setMolarFractions(double[] molefractions, String type) { + double totalFlow = getTotalNumberOfMoles(); + if (totalFlow < 1e-100) { + String msg = "must be larger than 0 (1e-100) when setting molar composition"; + throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + "setMolarComposition", "totalFlow", msg)); + } + double sum = 0; + for (double value : molefractions) { + sum += value; + } + setEmptyFluid(); + + switch (type) { + case "PlusFluid": + // TODO: really skip last component of molefraction? + for (int compNumb = 0; compNumb < molefractions.length - 1; compNumb++) { + addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); + } + for (int j = 0; j < getCharacterization().getLumpingModel().getNumberOfLumpedComponents() + - 1; j++) { + // addComponent(compNumb, totalFlow * molefractions[molefractions.length - 1] + // * getCharacterization().getLumpingModel().getFractionOfHeavyEnd(j) / sum); + } + break; + case "Plus": + // TODO: compNumb can be negative + for (int compNumb = 0; compNumb < this.numberOfComponents + - getCharacterization().getLumpingModel().getNumberOfLumpedComponents(); compNumb++) { + addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); + } + int ii = 0; + for (int compNumb = this.numberOfComponents - getCharacterization().getLumpingModel() + .getNumberOfLumpedComponents(); compNumb < this.numberOfComponents; compNumb++) { + addComponent(compNumb, + totalFlow * getCharacterization().getLumpingModel().getFractionOfHeavyEnd(ii++) + * molefractions[this.numberOfComponents + - getCharacterization().getLumpingModel().getNumberOfLumpedComponents()] + / sum); + } + break; + default: + // NB! It will allow setting composition for only the first items. + // for (int compNumb = 0; compNumb <= molefractions.length - 1; compNumb++) { + // NB! Can fail because len(molefractions) < this.numberOfComponents + for (int compNumb = 0; compNumb <= this.numberOfComponents - 1; compNumb++) { + addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); + } + break; + } + + for (int i = 0; i < getNumberOfPhases(); i++) { + init(0, i); + } + } + /** {@inheritDoc} */ @Override - public double[] getMolarRate() { - double[] comp = new double[getPhase(0).getNumberOfComponents()]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - comp[compNumb] = getPhase(0).getComponent(compNumb).getNumberOfmoles(); - } - return comp; - } - - /** {@inheritDoc} */ - @Override - public double[] getMolarComposition() { - PhaseInterface phase = this.getPhase(0); - double[] comp = new double[phase.getNumberOfComponents()]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - comp[compNumb] = phase.getComponent(compNumb).getz(); + public void setMultiPhaseCheck(boolean multiPhaseCheck) { + if (getMaxNumberOfPhases() < 3) { + if (multiPhaseCheck) { + setMaxNumberOfPhases(3); + if (phaseArray[1] != null) { + phaseArray[2] = phaseArray[1].clone(); + phaseArray[2].resetMixingRule(phaseArray[0].getMixingRuleNumber()); + phaseArray[2].resetPhysicalProperties(); + phaseArray[2].initPhysicalProperties(); + } + } else { + setMaxNumberOfPhases(2); + } } - return comp; - } - - /** {@inheritDoc} */ - @Override - public boolean isMultiphaseWaxCheck() { - return multiphaseWaxCheck; + this.multiPhaseCheck = multiPhaseCheck; } /** {@inheritDoc} */ @@ -4814,414 +4745,329 @@ public void setMultiphaseWaxCheck(boolean multiphaseWaxCheck) { /** {@inheritDoc} */ @Override - public String[] getCompIDs() { - String[] ids = new String[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - ids[compNumb] = Integer.toString(getPhase(0).getComponent(compNumb).getIndex()); - } - return ids; - } - - /** {@inheritDoc} */ - @Override - public String[] getCompFormulaes() { - String[] formula = new String[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - formula[compNumb] = getPhase(0).getComponent(compNumb).getFormulae(); - } - return formula; - } - - /** {@inheritDoc} */ - @Override - public String[] getCompNames() { - String[] names = new String[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - names[compNumb] = getPhase(0).getComponent(compNumb).getComponentName(); + public void setNumberOfPhases(int number) { + this.numberOfPhases = number; + if (numberOfPhases > getMaxNumberOfPhases()) { + setMaxNumberOfPhases(number); } - return names; } /** {@inheritDoc} */ @Override - public double[] getNormalBoilingPointTemperatures() { - double[] bt = new double[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - bt[compNumb] = getPhase(0).getComponent(compNumb).getNormalBoilingPoint() + 273.15; - } - return bt; + public void setNumericDerivatives(boolean numericDerivatives) { + this.numericDerivatives = numericDerivatives; } /** {@inheritDoc} */ @Override - public String[] getCapeOpenProperties11() { - return CapeOpenProperties11; + public final void setPC(double PC) { + criticalPressure = PC; } /** {@inheritDoc} */ @Override - public String[] getCapeOpenProperties10() { - return CapeOpenProperties10; + public void setPhase(PhaseInterface phase, int index) { + double temp = phaseArray[index].getTemperature(); + double pres = phaseArray[index].getPressure(); + this.phaseArray[index] = phase; + this.phaseArray[index].setTemperature(temp); + this.phaseArray[index].setPressure(pres); } /** {@inheritDoc} */ @Override - public double[] getMolecularWeights() { - double[] mm = new double[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - mm[compNumb] = getPhase(0).getComponent(compNumb).getMolarMass() * 1e3; - } - return mm; + public final void setPhaseIndex(int index, int phaseIndex) { + this.phaseIndex[index] = phaseIndex; } /** {@inheritDoc} */ @Override - public String[] getCASNumbers() { - String[] names = new String[numberOfComponents]; - - for (int compNumb = 0; compNumb < numberOfComponents; compNumb++) { - names[compNumb] = getPhase(0).getComponent(compNumb).getCASnumber(); + public void setPhaseType(int phaseToChange, PhaseType pt) { + // System.out.println("new phase type: cha " + pt); + if (allowPhaseShift) { + phaseType[phaseIndex[phaseToChange]] = pt; } - return names; } /** {@inheritDoc} */ @Override - public int getNumberOfOilFractionComponents() { - int number = 0; - for (int i = 0; i < getPhase(0).getNumberOfComponents(); i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction() - || getPhase(0).getComponent(i).isIsPlusFraction()) { - number++; - } + public void setPhysicalPropertyModel(int type) { + for (int i = 0; i < numberOfPhases; i++) { + getPhase(i).setPhysicalProperties(type); } - return number; } /** {@inheritDoc} */ @Override - public int[] getOilFractionIDs() { - int numb = getNumberOfOilFractionComponents(); - int[] IDs = new int[numb]; - // int number = 0; - for (int i = 0; i < numb; i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction() - || getPhase(0).getComponent(i).isIsPlusFraction()) { - IDs[i] = getPhase(0).getComponent(i).getIndex(); - // number++; - } + public final void setPressure(double newPressure) { + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + phaseArray[i].setPressure(newPressure); } - return IDs; } /** {@inheritDoc} */ @Override - public boolean setHeavyTBPfractionAsPlusFraction() { - int compNumber = 0; - double molarMass = 0; - boolean foundTBP = false; - - for (int i = 0; i < numberOfComponents; i++) { - if (getPhase(0).getComponent(i).isIsTBPfraction() - || getPhase(0).getComponent(i).isIsPlusFraction()) { - if (getPhase(0).getComponent(i).getMolarMass() > molarMass) { - molarMass = getPhase(0).getComponent(i).getMolarMass(); - compNumber = i; - foundTBP = true; - } - } - } - if (foundTBP) { - for (int i = 0; i < maxNumberOfPhases; i++) { - getPhase(0).getComponent(compNumber).setIsPlusFraction(true); - } - } - return foundTBP; + public final void setPressure(double newPressure, String unit) { + neqsim.util.unit.PressureUnit presConversion = + new neqsim.util.unit.PressureUnit(newPressure, unit); + setPressure(presConversion.getValue("bara")); } /** {@inheritDoc} */ @Override - public double[] getOilFractionNormalBoilingPoints() { - int numb = getNumberOfOilFractionComponents(); - int[] indexes = getOilFractionIDs(); - double[] temp = new double[numb]; - for (int i = 0; i < numb; i++) { - temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getNormalBoilingPoint(); - } - return temp; - } + public void setSolidPhaseCheck(boolean solidPhaseCheck) { + this.solidPhaseCheck = solidPhaseCheck; - /** {@inheritDoc} */ - @Override - public double[] getOilFractionLiquidDensityAt25C() { - int numb = getNumberOfOilFractionComponents(); - int[] indexes = getOilFractionIDs(); - double[] temp = new double[numb]; - for (int i = 0; i < numb; i++) { - temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getNormalLiquidDensity(); + final int oldphase = numberOfPhases; + if (solidPhaseCheck && !this.hasSolidPhase()) { + addSolidPhase(); } - return temp; - } + // init(0); - /** {@inheritDoc} */ - @Override - public double[] getOilFractionMolecularMass() { - int numb = getNumberOfOilFractionComponents(); - int[] indexes = getOilFractionIDs(); - double[] temp = new double[numb]; - for (int i = 0; i < numb; i++) { - temp[i] = getPhase(0).getComponentWithIndex(indexes[i]).getMolarMass(); + for (int phase = 0; phase < numberOfPhases; phase++) { + for (int k = 0; k < getPhases()[0].getNumberOfComponents(); k++) { + getPhase(phase).getComponent(k).setSolidCheck(solidPhaseCheck); + getPhase(3).getComponent(k).setSolidCheck(solidPhaseCheck); + } } - return temp; + setNumberOfPhases(oldphase); } /** {@inheritDoc} */ @Override - public PhaseInterface getLowestGibbsEnergyPhase() { - if (getPhase(0).getGibbsEnergy() < getPhase(1).getGibbsEnergy()) { - return getPhase(0); - } else { - return getPhase(1); + public void setSolidPhaseCheck(String solidComponent) { + init(0); + final int oldphase = numberOfPhases; + if (!solidPhaseCheck) { + addSolidPhase(); } - } - - /** {@inheritDoc} */ - @Override - public double getWtFraction(int phaseNumber) { - return getPhase(phaseNumber).getWtFraction(this); - } - - /** {@inheritDoc} */ - @Override - public double getVolumeFraction(int phaseNumber) { - return getPhase(phaseNumber).getVolume() / getVolume(); - } + this.solidPhaseCheck = true; + init(0); - /** {@inheritDoc} */ - @Override - public final double getPhaseFraction(String phaseTypeName, String unit) { - int phaseNumber = getPhaseNumberOfPhase(phaseTypeName); - switch (unit) { - case "mole": - return getBeta(phaseNumber); - case "volume": - return getVolumeFraction(phaseNumber); - case "mass": - initPhysicalProperties("density"); - return getVolumeFraction(phaseNumber) * getPhase(phaseNumber).getDensity("kg/m3") - / getDensity("kg/m3"); - default: - return getBeta(phaseNumber); + for (int phase = 0; phase < getMaxNumberOfPhases(); phase++) { + try { + getPhase(phase).getComponent(solidComponent).setSolidCheck(true); + getPhase(3).getComponent(solidComponent).setSolidCheck(true); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } } + setNumberOfPhases(oldphase); } /** {@inheritDoc} */ @Override - public double getCorrectedVolumeFraction(int phaseNumber) { - return getPhase(phaseNumber).getCorrectedVolume() / getCorrectedVolume(); + public void setStandard(String standardName) { + if (standardName.equals("ISO1992")) { + this.standard = new neqsim.standards.gasQuality.Standard_ISO6976(this); + } else if (standardName.equals("Draft_ISO18453")) { + this.standard = new neqsim.standards.gasQuality.Draft_ISO18453(this); + } else { + this.standard = new neqsim.standards.gasQuality.Standard_ISO6976(this); + } } /** {@inheritDoc} */ @Override - public double getMoleFraction(int phaseNumber) { - return getPhase(phaseNumber).getBeta(); + public final void setTC(double TC) { + criticalTemperature = TC; } /** {@inheritDoc} */ @Override - 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; + public void setTemperature(double newTemperature) { + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + getPhases()[i].setTemperature(newTemperature); + } } /** {@inheritDoc} */ @Override - public neqsim.thermo.characterization.WaxCharacterise getWaxCharacterisation() { - return waxCharacterisation; + public final void setTemperature(double newTemperature, int phase) { + getPhase(phaseIndex[phase]).setTemperature(newTemperature); } /** {@inheritDoc} */ @Override - public WaxModelInterface getWaxModel() { - if (waxCharacterisation == null) { - waxCharacterisation = new WaxCharacterise(this); + public void setTemperature(double newTemperature, String unit) { + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + if (unit.equals("K")) { + // Direct setting as Kelvin + getPhases()[i].setTemperature(newTemperature); + } else if (unit.equals("C")) { + // Convert Celsius to Kelvin + getPhases()[i].setTemperature(newTemperature + 273.15); + } else if (unit.equals("F")) { + // Convert Fahrenheit to Kelvin + getPhases()[i].setTemperature((newTemperature - 32) * 5.0 / 9.0 + 273.15); + } else if (unit.equals("R")) { + // Convert Rankine to Kelvin + getPhases()[i].setTemperature(newTemperature * 5.0 / 9.0); + } else { + // Exception for unsupported units + throw new RuntimeException("Unit not supported: " + unit); + } } - return waxCharacterisation.getModel(); } /** {@inheritDoc} */ @Override - public double getLiquidVolume() { - double totFlow = 0; + public void setTotalFlowRate(double flowRate, String flowunit) { + init(0); + try { + init(1); + } catch (Exception e) { + logger.error(e.getMessage()); + } + double density = 0.0; + if (flowunit.equals("Am3/hr") || flowunit.equals("Am3/min") || flowunit.equals("gallons/min") + || flowunit.equals("Am3/sec")) { + initPhysicalProperties("density"); + } - for (int kj = 0; kj < numberOfPhases; kj++) { - if (getPhase(kj).getType() != PhaseType.GAS) { - totFlow += getPhase(kj).getVolume(); + density = getPhase(0).getDensity("kg/m3"); + if (flowunit.equals("idSm3/hr")) { + density = getIdealLiquidDensity("kg/m3"); + } + neqsim.util.unit.Unit unit = + new neqsim.util.unit.RateUnit(flowRate, flowunit, getMolarMass(), density, 0); + double SIval = unit.getSIvalue(); + double totalNumberOfMolesLocal = totalNumberOfMoles; + for (int i = 0; i < numberOfComponents; i++) { + if (flowRate < 1e-100) { + setEmptyFluid(); + } else if (totalNumberOfMolesLocal > 1e-100) { + // (SIval / totalNumberOfMolesLocal - 1) * ... + double change = + SIval / totalNumberOfMolesLocal * getPhase(0).getComponent(i).getNumberOfmoles() + - getPhase(0).getComponent(i).getNumberOfmoles(); + if (Math.abs(change) > 1e-12) { + addComponent(i, change); + } + } else { + addComponent(i, SIval); } } - return totFlow; } /** {@inheritDoc} */ @Override - public boolean isForcePhaseTypes() { - return forcePhaseTypes; + public void setTotalNumberOfMoles(double totalNumberOfMoles) { + if (totalNumberOfMoles < 0) { + /* + * throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, + * "setTotalNumberOfMoles", "totalNumberOfMoles", "can not be less than 0.")); + */ + totalNumberOfMoles = 0; + } + this.totalNumberOfMoles = totalNumberOfMoles; } /** {@inheritDoc} */ @Override - public void setForcePhaseTypes(boolean forcePhaseTypes) { - this.forcePhaseTypes = forcePhaseTypes; + public void setUseTVasIndependentVariables(boolean useTVasIndependentVariables) { + for (int i = 0; i < numberOfPhases; i++) { + getPhase(i).setTotalVolume(getPhase(i).getVolume()); + getPhase(i).setConstantPhaseVolume(useTVasIndependentVariables); + getPhase(i).calcMolarVolume(!useTVasIndependentVariables); + } + this.useTVasIndependentVariables = useTVasIndependentVariables; } /** {@inheritDoc} */ @Override - public SystemProperties getProperties() { - return new SystemProperties(this); + public void tuneModel(String model, double val, int phase) { + if (model.equals("viscosity")) { + getPhase(phase).getPhysicalProperties().getViscosityModel().tuneModel(val, + getPhase(phase).getTemperature(), getPhase(phase).getPressure()); + for (int i = 0; i < getMaxNumberOfPhases(); i++) { + for (int j = 0; j < numberOfPhases; j++) { + getPhase(i).getComponent(j) + .setCriticalViscosity(getPhase(phase).getComponent(j).getCriticalViscosity()); + } + } + } + initPhysicalProperties(); } /** - * Wrapper function for addComponent to set fluid type and specify mole fractions. + *

+ * useTVasIndependentVariables. + *

* - * @param molefractions Component mole fraction of each component. - * @param type Type of fluid. Supports "PlusFluid", "Plus" and default. + * @return a boolean */ - private void setMolarFractions(double[] molefractions, String type) { - double totalFlow = getTotalNumberOfMoles(); - if (totalFlow < 1e-100) { - String msg = "must be larger than 0 (1e-100) when setting molar composition"; - throw new RuntimeException(new neqsim.util.exception.InvalidInputException(this, - "setMolarComposition", "totalFlow", msg)); - } - double sum = 0; - for (double value : molefractions) { - sum += value; - } - setEmptyFluid(); + public boolean useTVasIndependentVariables() { + return useTVasIndependentVariables; + } - switch (type) { - case "PlusFluid": - // TODO: really skip last component of molefraction? - for (int compNumb = 0; compNumb < molefractions.length - 1; compNumb++) { - addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); - } - for (int j = 0; j < getCharacterization().getLumpingModel().getNumberOfLumpedComponents() - - 1; j++) { - // addComponent(compNumb, totalFlow * molefractions[molefractions.length - 1] - // * getCharacterization().getLumpingModel().getFractionOfHeavyEnd(j) / sum); - } - break; - case "Plus": - // TODO: compNumb can be negative - for (int compNumb = 0; compNumb < this.numberOfComponents - - getCharacterization().getLumpingModel().getNumberOfLumpedComponents(); compNumb++) { - addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); - } - int ii = 0; - for (int compNumb = this.numberOfComponents - getCharacterization().getLumpingModel() - .getNumberOfLumpedComponents(); compNumb < this.numberOfComponents; compNumb++) { - addComponent(compNumb, - totalFlow * getCharacterization().getLumpingModel().getFractionOfHeavyEnd(ii++) - * molefractions[this.numberOfComponents - - getCharacterization().getLumpingModel().getNumberOfLumpedComponents()] - / sum); - } - break; - default: - // NB! It will allow setting composition for only the first items. - // for (int compNumb = 0; compNumb <= molefractions.length - 1; compNumb++) { - // NB! Can fail because len(molefractions) < this.numberOfComponents - for (int compNumb = 0; compNumb <= this.numberOfComponents - 1; compNumb++) { - addComponent(compNumb, totalFlow * molefractions[compNumb] / sum); - } - break; + /** {@inheritDoc} */ + @Override + public void useVolumeCorrection(boolean volcor) { + for (PhaseInterface tmpPhase : phaseArray) { + if (tmpPhase != null) { + tmpPhase.useVolumeCorrection(volcor); + } } + } - for (int i = 0; i < getNumberOfPhases(); i++) { - init(0, i); - } + /** + *

+ * write. + *

+ * + * @return a {@link java.lang.String} object + */ + public String write() { + // create a String description of the system + return ""; } /** {@inheritDoc} */ @Override - 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]); + public void write(String name, String filename, boolean newfile) { + String[][] table = createTable(name); + neqsim.dataPresentation.fileHandeling.createTextFile.TextFile file = + new neqsim.dataPresentation.fileHandeling.createTextFile.TextFile(); + if (newfile) { + file.newFile(filename); } + file.setOutputFileName(filename); + file.setValues(table); + file.createFile(); } /** {@inheritDoc} */ @Override - public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, - double[] relativedensity, boolean lastIsPlusFraction, boolean lumpComponents, - int numberOfPseudoComponents) { - if (charNames.length != charFlowrate.length) { - logger.error("component names and mole fractions need to be same length..."); + public double[] getKvector() { + double[] K = new double[this.getNumberOfComponents()]; + for (int i = 0; i < this.getNumberOfComponents(); i++) { + K[i] = this.getPhase(0).getComponent(i).getK(); } + return K; + } - for (int i = 0; i < charNames.length - 1; i++) { - addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } - int i = charNames.length - 1; - if (lastIsPlusFraction) { - addPlusFraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } else { - addTBPfraction(charNames[i], charFlowrate[i], molarMass[i], relativedensity[i]); - } - createDatabase(true); - if (lastIsPlusFraction) { - getCharacterization().getLumpingModel().setNumberOfPseudoComponents(numberOfPseudoComponents); - if (lumpComponents) { - getCharacterization().setLumpingModel("PVTlumpingModel"); - } else { - getCharacterization().setLumpingModel("no lumping"); - } - getCharacterization().characterisePlusFraction(); + /** {@inheritDoc} */ + @Override + public double[] getzvector() { + double[] z = new double[this.getNumberOfComponents()]; + for (int i = 0; i < this.getNumberOfComponents(); i++) { + z[i] = this.getPhase(0).getComponent(i).getz(); } - setMixingRule(getMixingRule()); - setMultiPhaseCheck(true); - init(0); + return z; } /** {@inheritDoc} */ @Override - public void addOilFractions(String[] charNames, double[] charFlowrate, double[] molarMass, - double[] relativedensity, boolean lastIsPlusFraction) { - addOilFractions(charNames, charFlowrate, molarMass, relativedensity, lastIsPlusFraction, true, - 12); + public String toJson() { + return new GsonBuilder().create() + .toJson(new neqsim.processSimulation.util.monitor.FluidResponse(this)); } /** {@inheritDoc} */ - public double getIdealLiquidDensity(String unit) { - double normalLiquidDensity = 0.0; - double molarMass = getMolarMass(); - for (int i = 0; i < getNumberOfComponents(); i++) { - normalLiquidDensity += getComponent(i).getNormalLiquidDensity() * getComponent(i).getz() - * getComponent(i).getMolarMass() / molarMass; - } - if (unit.equals("gr/cm3")) { - return normalLiquidDensity; - } else if (unit.equals("kg/m3")) { - return normalLiquidDensity * 1000.0; - } else { - logger.error("unit not supported: " + unit); - return normalLiquidDensity; - } + @Override + public String toCompJson() { + return new GsonBuilder().create() + .toJson(new neqsim.processSimulation.util.monitor.FluidComponentResponse(this)); } } diff --git a/src/main/java/neqsim/thermo/system/SystemUMRPRUEos.java b/src/main/java/neqsim/thermo/system/SystemUMRPRUEos.java index 6f336ae796..27d9a1973e 100644 --- a/src/main/java/neqsim/thermo/system/SystemUMRPRUEos.java +++ b/src/main/java/neqsim/thermo/system/SystemUMRPRUEos.java @@ -40,8 +40,7 @@ public SystemUMRPRUEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemUMRPRUEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); setBmixType(1); modelName = "UMR-PRU-EoS"; attractiveTermNumber = 1; diff --git a/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEos.java b/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEos.java index c8e67c3eaa..0a5f2bd4d2 100644 --- a/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEos.java +++ b/src/main/java/neqsim/thermo/system/SystemUMRPRUMCEos.java @@ -40,17 +40,9 @@ public SystemUMRPRUMCEos(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemUMRPRUMCEos(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; - setBmixType(1); + super(T, P, checkForSolids); modelName = "UMR-PRU-MC-EoS"; attractiveTermNumber = 13; - CapeOpenProperties11 = new String[] {"speedOfSound", "jouleThomsonCoefficient", - "internalEnergy", "internalEnergy.Dtemperature", "gibbsEnergy", "helmholtzEnergy", - "fugacityCoefficient", "logFugacityCoefficient", "logFugacityCoefficient.Dtemperature", - "logFugacityCoefficient.Dpressure", "logFugacityCoefficient.Dmoles", "enthalpy", - "enthalpy.Dtemperature", "entropy", "heatCapacityCp", "heatCapacityCv", "density", - "volume"}; } /** {@inheritDoc} */ diff --git a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java index 1f0bdb3ebe..e728b386b0 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFAC.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFAC.java @@ -45,8 +45,7 @@ public SystemUNIFAC(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemUNIFAC(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "UNIFAC-GE-model"; solidPhaseCheck = checkForSolids; @@ -79,10 +78,6 @@ public SystemUNIFAC 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/SystemUNIFACpsrk.java b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java index 8b0b244c18..c742b8cd66 100644 --- a/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java +++ b/src/main/java/neqsim/thermo/system/SystemUNIFACpsrk.java @@ -44,8 +44,7 @@ public SystemUNIFACpsrk(double T, double P) { * @param checkForSolids Set true to do solid phase check and calculations */ public SystemUNIFACpsrk(double T, double P, boolean checkForSolids) { - super(T, P); - this.solidPhaseCheck = checkForSolids;; + super(T, P, checkForSolids); attractiveTermNumber = 0; modelName = "UNIFAC-GE-model"; solidPhaseCheck = checkForSolids; @@ -78,10 +77,6 @@ public SystemUNIFACpsrk 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/util/GERG/DETAIL.java b/src/main/java/neqsim/thermo/util/GERG/DETAIL.java index fe951a20d8..9478f8cadb 100644 --- a/src/main/java/neqsim/thermo/util/GERG/DETAIL.java +++ b/src/main/java/neqsim/thermo/util/GERG/DETAIL.java @@ -13,1545 +13,1539 @@ * @version $Id: $Id */ public class DETAIL { - // The compositions in the x() array use the following order and must be sent as - // mole fractions: - // 0 - PLACEHOLDER - // 1 - Methane - // 2 - Nitrogen - // 3 - Carbon dioxide - // 4 - Ethane - // 5 - Propane - // 6 - Isobutane - // 7 - n-Butane - // 8 - Isopentane - // 9 - n-Pentane - // 10 - n-Hexane - // 11 - n-Heptane - // 12 - n-Octane - // 13 - n-Nonane - // 14 - n-Decane - // 15 - Hydrogen - // 16 - Oxygen - // 17 - Carbon monoxide - // 18 - Water - // 19 - Hydrogen sulfide - // 20 - Helium - // 21 - Argon - // - // For example, a mixture (in moles) of 94% methane, 5% CO2, and 1% helium would - // be (in mole fractions): - // x(1)=0.94, x(3)=0.05, x(20)=0.01 - - // Variables containing the common parameters in the DETAIL equations - double RDetail; - int NcDetail = 21, MaxFlds = 21, NTerms = 58; - double epsilon = 1e-15; - int[] fn = new int[NTerms + 1]; - int[] gn = new int[NTerms + 1]; - int[] qn = new int[NTerms + 1]; - double[] an = new double[NTerms + 1]; - double[] un = new double[NTerms + 1]; - int[] bn = new int[NTerms + 1]; - int[] kn = new int[NTerms + 1]; - - double[][][] Bsnij2 = new double[MaxFlds + 1][MaxFlds + 1][18 + 1]; - double[] Bs = new double[18 + 1]; - double[] Csn = new double[NTerms + 1]; - - double[] Fi = new double[MaxFlds + 1]; - double[] Gi = new double[MaxFlds + 1]; - double[] Qi = new double[MaxFlds + 1]; - - double[] Ki25 = new double[MaxFlds + 1]; - double[] Ei25 = new double[MaxFlds + 1]; - - double[][] Kij5 = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] Uij5 = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] Gij5 = new double[MaxFlds + 1][MaxFlds + 1]; - - double[] Tun = new double[NTerms + 1]; - double Told; - double[][] n0i = new double[MaxFlds + 1][7 + 1]; - double[][] th0i = new double[MaxFlds + 1][7 + 1]; - - double[] MMiDetail = new double[MaxFlds + 1]; - double[] xold = new double[MaxFlds + 1]; - double K3; - double dPdDsave; - - /** - *

- * sq. - *

- * - * @param x a double - * @return a double - */ - public double sq(double x) { - return x * x; + // The compositions in the x() array use the following order and must be sent as + // mole fractions: + // 0 - PLACEHOLDER + // 1 - Methane + // 2 - Nitrogen + // 3 - Carbon dioxide + // 4 - Ethane + // 5 - Propane + // 6 - Isobutane + // 7 - n-Butane + // 8 - Isopentane + // 9 - n-Pentane + // 10 - n-Hexane + // 11 - n-Heptane + // 12 - n-Octane + // 13 - n-Nonane + // 14 - n-Decane + // 15 - Hydrogen + // 16 - Oxygen + // 17 - Carbon monoxide + // 18 - Water + // 19 - Hydrogen sulfide + // 20 - Helium + // 21 - Argon + // + // For example, a mixture (in moles) of 94% methane, 5% CO2, and 1% helium would + // be (in mole fractions): + // x(1)=0.94, x(3)=0.05, x(20)=0.01 + + // Variables containing the common parameters in the DETAIL equations + double RDetail; + int NcDetail = 21, MaxFlds = 21, NTerms = 58; + double epsilon = 1e-15; + int[] fn = new int[NTerms + 1]; + int[] gn = new int[NTerms + 1]; + int[] qn = new int[NTerms + 1]; + double[] an = new double[NTerms + 1]; + double[] un = new double[NTerms + 1]; + int[] bn = new int[NTerms + 1]; + int[] kn = new int[NTerms + 1]; + + double[][][] Bsnij2 = new double[MaxFlds + 1][MaxFlds + 1][18 + 1]; + double[] Bs = new double[18 + 1]; + double[] Csn = new double[NTerms + 1]; + + double[] Fi = new double[MaxFlds + 1]; + double[] Gi = new double[MaxFlds + 1]; + double[] Qi = new double[MaxFlds + 1]; + + double[] Ki25 = new double[MaxFlds + 1]; + double[] Ei25 = new double[MaxFlds + 1]; + + double[][] Kij5 = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] Uij5 = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] Gij5 = new double[MaxFlds + 1][MaxFlds + 1]; + + double[] Tun = new double[NTerms + 1]; + double Told; + double[][] n0i = new double[MaxFlds + 1][7 + 1]; + double[][] th0i = new double[MaxFlds + 1][7 + 1]; + + double[] MMiDetail = new double[MaxFlds + 1]; + double[] xold = new double[MaxFlds + 1]; + double K3; + double dPdDsave; + + /** + *

+ * sq. + *

+ * + * @param x a double + * @return a double + */ + public double sq(double x) { + return x * x; + } + + /** + *

+ * MolarMassDetail. + *

+ * + * @param x an array of type double + * @param Mm a {@link org.netlib.util.doubleW} object + */ + public void MolarMassDetail(double[] x, doubleW Mm) { + // Calculate molar mass of the mixture with the compositions contained in the + // x() input array + + // Inputs: + // x() - Composition (mole fraction) + // Do not send mole percents or mass fractions in the x() array, otherwise the + // output will be incorrect. + // The sum of the compositions in the x() array must be equal to one. + // The order of the fluids in this array is given at the top of this code. + + // Outputs: + // Mm - Molar mass (g/mol) + + Mm.val = 0; + for (int i = 1; i <= NcDetail; ++i) { + Mm.val += x[i] * MMiDetail[i]; } - - /** - *

- * MolarMassDetail. - *

- * - * @param x an array of {@link double} objects - * @param Mm a {@link org.netlib.util.doubleW} object - */ - public void MolarMassDetail(double[] x, doubleW Mm) { - // Calculate molar mass of the mixture with the compositions contained in the - // x() input array - - // Inputs: - // x() - Composition (mole fraction) - // Do not send mole percents or mass fractions in the x() array, otherwise the - // output will be incorrect. - // The sum of the compositions in the x() array must be equal to one. - // The order of the fluids in this array is given at the top of this code. - - // Outputs: - // Mm - Molar mass (g/mol) - - Mm.val = 0; - for (int i = 1; i <= NcDetail; ++i) { - Mm.val += x[i] * MMiDetail[i]; - } + } + + /** + *

+ * PressureDetail. + *

+ * + * @param T a double + * @param D a double + * @param x an array of type double + * @param P a {@link org.netlib.util.doubleW} object + * @param Z a {@link org.netlib.util.doubleW} object + */ + public void PressureDetail(double T, double D, double[] x, doubleW P, doubleW Z) { + // Sub Pressure(T, D, x, P, Z) + + // Calculate pressure as a function of temperature and density. The derivative + // d(P)/d(D) is also calculated + // for use in the iterative DensityDetail subroutine (and is only returned as a + // common variable). + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + // Do not send mole percents or mass fractions in the x() array, otherwise the + // output will be incorrect. + // The sum of the compositions in the x() array must be equal to one. + + // Outputs: + // P - Pressure (kPa) + // Z - Compressibility factor + // dPdDsave - d(P)/d(D) [kPa/(mol/l)] (at constant temperature) + // - This variable is cached in the common variables for use in the iterative + // density solver, but not returned as an argument. + + doubleW[][] ar = new doubleW[3 + 1][3 + 1]; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + ar[i][j] = new doubleW(0.0d); + } } - - /** - *

- * PressureDetail. - *

- * - * @param T a double - * @param D a double - * @param x an array of {@link double} objects - * @param P a {@link org.netlib.util.doubleW} object - * @param Z a {@link org.netlib.util.doubleW} object - */ - public void PressureDetail(double T, double D, double[] x, doubleW P, doubleW Z) { - // Sub Pressure(T, D, x, P, Z) - - // Calculate pressure as a function of temperature and density. The derivative - // d(P)/d(D) is also calculated - // for use in the iterative DensityDetail subroutine (and is only returned as a - // common variable). - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - // Do not send mole percents or mass fractions in the x() array, otherwise the - // output will be incorrect. - // The sum of the compositions in the x() array must be equal to one. - - // Outputs: - // P - Pressure (kPa) - // Z - Compressibility factor - // dPdDsave - d(P)/d(D) [kPa/(mol/l)] (at constant temperature) - // - This variable is cached in the common variables for use in the iterative - // density solver, but not returned as an argument. - - doubleW[][] ar = new doubleW[3 + 1][3 + 1]; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - ar[i][j] = new doubleW(0.0d); - } - } - xTermsDetail(x); - AlpharDetail(0, 2, T, D, ar); - Z.val = 1 + ar[0][1].val / RDetail / T; // ar(0,1) is the first derivative of alpha(r) with - // respect to density - P.val = D * RDetail * T * Z.val; - dPdDsave = RDetail * T + 2 * ar[0][1].val + ar[0][2].val; // d(P)/d(D) for use in density - // iteration + xTermsDetail(x); + AlpharDetail(0, 2, T, D, ar); + Z.val = 1 + ar[0][1].val / RDetail / T; // ar(0,1) is the first derivative of alpha(r) with + // respect to density + P.val = D * RDetail * T * Z.val; + dPdDsave = RDetail * T + 2 * ar[0][1].val + ar[0][2].val; // d(P)/d(D) for use in density + // iteration + } + + /** + *

+ * DensityDetail. + *

+ * + * @param T a double + * @param P a double + * @param x an array of type double + * @param D a {@link org.netlib.util.doubleW} object + * @param ierr a {@link org.netlib.util.intW} object + * @param herr a {@link org.netlib.util.StringW} object + */ + public void DensityDetail(double T, double P, double[] x, doubleW D, intW ierr, StringW herr) { + // Sub DensityDetail(T, P, x, D, ierr, herr) + + // Calculate density as a function of temperature and pressure. This is an + // iterative routine that calls PressureDetail + // to find the correct state point. Generally only 6 iterations at most are + // required. + // If the iteration fails to converge, the ideal gas density and an error + // message are returned. + // No checks are made to determine the phase boundary, which would have + // guaranteed that the output is in the gas phase. + // It is up to the user to locate the phase boundary, and thus identify the + // phase of the T and P inputs. + // If the state point is 2-phase, the output density will represent a metastable + // state. + + // Inputs: + // T - Temperature (K) + // P - Pressure (kPa) + // x() - Composition (mole fraction) + + // Outputs: + // D - Density (mol/l) (make D negative and send as an input to use as an + // initial guess) + // ierr - Error number (0 indicates no error) + // herr - Error message if ierr is not equal to zero + + double plog, vlog, dpdlv, vdiff, tolr; + doubleW P2 = new doubleW(0.0d); + doubleW Z = new doubleW(0.0d); + ierr.val = 0; + herr.val = ""; + if (Math.abs(P) < epsilon) { + D.val = 0.0; + return; } - - /** - *

- * DensityDetail. - *

- * - * @param T a double - * @param P a double - * @param x an array of {@link double} objects - * @param D a {@link org.netlib.util.doubleW} object - * @param ierr a {@link org.netlib.util.intW} object - * @param herr a {@link org.netlib.util.StringW} object - */ - public void DensityDetail(double T, double P, double[] x, doubleW D, intW ierr, - StringW herr) { - // Sub DensityDetail(T, P, x, D, ierr, herr) - - // Calculate density as a function of temperature and pressure. This is an - // iterative routine that calls PressureDetail - // to find the correct state point. Generally only 6 iterations at most are - // required. - // If the iteration fails to converge, the ideal gas density and an error - // message are returned. - // No checks are made to determine the phase boundary, which would have - // guaranteed that the output is in the gas phase. - // It is up to the user to locate the phase boundary, and thus identify the - // phase of the T and P inputs. - // If the state point is 2-phase, the output density will represent a metastable - // state. - - // Inputs: - // T - Temperature (K) - // P - Pressure (kPa) - // x() - Composition (mole fraction) - - // Outputs: - // D - Density (mol/l) (make D negative and send as an input to use as an - // initial guess) - // ierr - Error number (0 indicates no error) - // herr - Error message if ierr is not equal to zero - - double plog, vlog, dpdlv, vdiff, tolr; - doubleW P2 = new doubleW(0.0d); - doubleW Z = new doubleW(0.0d); - ierr.val = 0; - herr.val = ""; - if (Math.abs(P) < epsilon) { - D.val = 0.0; - return; - } - tolr = 0.0000001; - if (D.val > -epsilon) { - D.val = P / RDetail / T; // Ideal gas estimate - } else { - D.val = Math.abs(D.val); // If D<0, then use as initial estimate - } - plog = Math.log(P); - vlog = -Math.log(D.val); - for (int it = 1; it <= 20; ++it) { - if (vlog < -7 || vlog > 100) { - ierr.val = 1; - herr.val = - "Calculation failed to converge in DETAIL method, ideal gas density returned."; - D.val = P / RDetail / T; - return; - } - D.val = Math.exp(-vlog); - PressureDetail(T, D.val, x, P2, Z); - if (dPdDsave < epsilon || P2.val < epsilon) { - vlog += 0.1; - } else { - // Find the next density with a first order Newton's type iterative scheme, with - // log(P) as the known variable and log(v) as the unknown property. - // See AGA 8 publication for further information. - dpdlv = -D.val * dPdDsave; // d(p)/d[log(v)] - vdiff = (Math.log(P2.val) - plog) * P2.val / dpdlv; - vlog = vlog - vdiff; - if (Math.abs(vdiff) < tolr) { - D.val = Math.exp(-vlog); - return; // Iteration converged - } - } - } + tolr = 0.0000001; + if (D.val > -epsilon) { + D.val = P / RDetail / T; // Ideal gas estimate + } else { + D.val = Math.abs(D.val); // If D<0, then use as initial estimate + } + plog = Math.log(P); + vlog = -Math.log(D.val); + for (int it = 1; it <= 20; ++it) { + if (vlog < -7 || vlog > 100) { ierr.val = 1; herr.val = "Calculation failed to converge in DETAIL method, ideal gas density returned."; D.val = P / RDetail / T; return; - } - - /** - *

- * PropertiesDetail. - *

- * - * @param T a double - * @param D a double - * @param x an array of {@link double} objects - * @param P a {@link org.netlib.util.doubleW} object - * @param Z a {@link org.netlib.util.doubleW} object - * @param dPdD a {@link org.netlib.util.doubleW} object - * @param d2PdD2 a {@link org.netlib.util.doubleW} object - * @param d2PdTD a {@link org.netlib.util.doubleW} object - * @param dPdT a {@link org.netlib.util.doubleW} object - * @param U a {@link org.netlib.util.doubleW} object - * @param H a {@link org.netlib.util.doubleW} object - * @param S a {@link org.netlib.util.doubleW} object - * @param Cv a {@link org.netlib.util.doubleW} object - * @param Cp a {@link org.netlib.util.doubleW} object - * @param W a {@link org.netlib.util.doubleW} object - * @param G a {@link org.netlib.util.doubleW} object - * @param JT a {@link org.netlib.util.doubleW} object - * @param Kappa a {@link org.netlib.util.doubleW} object - */ - public void PropertiesDetail(double T, double D, double[] x, doubleW P, doubleW Z, - doubleW dPdD, doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, - doubleW S, doubleW Cv, doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa) { - // Sub Properties(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, - // G, JT, Kappa) - - // Calculate thermodynamic properties as a function of temperature and density. - // Calls are made to the subroutines - // Molarmass, Alpha0Detail, and AlpharDetail. If the density is not known, call - // subroutine DensityDetail first - // with the known values of pressure and temperature. - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - - // Outputs: - // P - Pressure (kPa) - // Z - Compressibility factor - // dPdD - First derivative of pressure with respect to density at constant - // temperature [kPa/(mol/l)] - // d2PdD2 - Second derivative of pressure with respect to density at constant - // temperature [kPa/(mol/l)^2] - // d2PdTD - Second derivative of pressure with respect to temperature and - // density [kPa/(mol/l)/K] (currently not calculated) - // dPdT - First derivative of pressure with respect to temperature at constant - // density (kPa/K) - // U - Internal energy (J/mol) - // H - Enthalpy (J/mol) - // S - Entropy [J/(mol-K)] - // Cv - Isochoric heat capacity [J/(mol-K)] - // Cp - Isobaric heat capacity [J/(mol-K)] - // W - Speed of sound (m/s) - // G - Gibbs energy (J/mol) - // JT - Joule-Thomson coefficient (K/kPa) - // Kappa - Isentropic Exponent - doubleW A = new doubleW(0.0d); - doubleW[] a0 = new doubleW[2 + 1]; - for (int i = 0; i < 3; i++) { - a0[i] = new doubleW(0.0d); + } + D.val = Math.exp(-vlog); + PressureDetail(T, D.val, x, P2, Z); + if (dPdDsave < epsilon || P2.val < epsilon) { + vlog += 0.1; + } else { + // Find the next density with a first order Newton's type iterative scheme, with + // log(P) as the known variable and log(v) as the unknown property. + // See AGA 8 publication for further information. + dpdlv = -D.val * dPdDsave; // d(p)/d[log(v)] + vdiff = (Math.log(P2.val) - plog) * P2.val / dpdlv; + vlog = vlog - vdiff; + if (Math.abs(vdiff) < tolr) { + D.val = Math.exp(-vlog); + return; // Iteration converged } - doubleW[][] ar = new doubleW[3 + 1][3 + 1]; + } + } + ierr.val = 1; + herr.val = "Calculation failed to converge in DETAIL method, ideal gas density returned."; + D.val = P / RDetail / T; + } + + /** + *

+ * PropertiesDetail. + *

+ * + * @param T a double + * @param D a double + * @param x an array of type double + * @param P a {@link org.netlib.util.doubleW} object + * @param Z a {@link org.netlib.util.doubleW} object + * @param dPdD a {@link org.netlib.util.doubleW} object + * @param d2PdD2 a {@link org.netlib.util.doubleW} object + * @param d2PdTD a {@link org.netlib.util.doubleW} object + * @param dPdT a {@link org.netlib.util.doubleW} object + * @param U a {@link org.netlib.util.doubleW} object + * @param H a {@link org.netlib.util.doubleW} object + * @param S a {@link org.netlib.util.doubleW} object + * @param Cv a {@link org.netlib.util.doubleW} object + * @param Cp a {@link org.netlib.util.doubleW} object + * @param W a {@link org.netlib.util.doubleW} object + * @param G a {@link org.netlib.util.doubleW} object + * @param JT a {@link org.netlib.util.doubleW} object + * @param Kappa a {@link org.netlib.util.doubleW} object + */ + public void PropertiesDetail(double T, double D, double[] x, doubleW P, doubleW Z, doubleW dPdD, + doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, doubleW S, doubleW Cv, + doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa) { + // Sub Properties(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, + // G, JT, Kappa) + + // Calculate thermodynamic properties as a function of temperature and density. + // Calls are made to the subroutines + // Molarmass, Alpha0Detail, and AlpharDetail. If the density is not known, call + // subroutine DensityDetail first + // with the known values of pressure and temperature. + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + + // Outputs: + // P - Pressure (kPa) + // Z - Compressibility factor + // dPdD - First derivative of pressure with respect to density at constant + // temperature [kPa/(mol/l)] + // d2PdD2 - Second derivative of pressure with respect to density at constant + // temperature [kPa/(mol/l)^2] + // d2PdTD - Second derivative of pressure with respect to temperature and + // density [kPa/(mol/l)/K] (currently not calculated) + // dPdT - First derivative of pressure with respect to temperature at constant + // density (kPa/K) + // U - Internal energy (J/mol) + // H - Enthalpy (J/mol) + // S - Entropy [J/(mol-K)] + // Cv - Isochoric heat capacity [J/(mol-K)] + // Cp - Isobaric heat capacity [J/(mol-K)] + // W - Speed of sound (m/s) + // G - Gibbs energy (J/mol) + // JT - Joule-Thomson coefficient (K/kPa) + // Kappa - Isentropic Exponent + doubleW A = new doubleW(0.0d); + doubleW[] a0 = new doubleW[2 + 1]; + for (int i = 0; i < 3; i++) { + a0[i] = new doubleW(0.0d); + } + doubleW[][] ar = new doubleW[3 + 1][3 + 1]; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - ar[i][j] = new doubleW(0.0d); - } - } - doubleW Mm = new doubleW(0.0d); - MolarMassDetail(x, Mm); - xTermsDetail(x); - - // Calculate the ideal gas Helmholtz energy, and its first and second - // derivatives with respect to temperature. - Alpha0Detail(T, D, x, a0); - - // Calculate the real gas Helmholtz energy, and its derivatives with respect to - // temperature and/or density. - AlpharDetail(2, 3, T, D, ar); - - double R = RDetail; - double RT = R * T; - Z.val = 1 + ar[0][1].val / RT; - P.val = D * RT * Z.val; - dPdD.val = RT + 2 * ar[0][1].val + ar[0][2].val; - dPdT.val = D * R + D * ar[1][1].val; - A.val = a0[0].val + ar[0][0].val; - S.val = -a0[1].val - ar[1][0].val; - U.val = A.val + T * S.val; - Cv.val = -(a0[2].val + ar[2][0].val); - if (D > epsilon) { - H.val = U.val + P.val / D; - G.val = A.val + P.val / D; - Cp.val = Cv.val + T * sq(dPdT.val / D) / dPdD.val; - d2PdD2.val = (2 * ar[0][1].val + 4 * ar[0][2].val + ar[0][3].val) / D; - JT.val = (T / D * dPdT.val / dPdD.val - 1) / Cp.val / D; - } else { - H.val = U.val + RT; - G.val = A.val + RT; - Cp.val = Cv.val + R; - d2PdD2.val = 0; - JT.val = 1E+20; // =(dB/dT*T-B)/Cp for an ideal gas, but dB/dT is not calculated here - } - W.val = 1000 * Cp.val / Cv.val * dPdD.val / Mm.val; - if (W.val < 0) { - W.val = 0; - } - W.val = Math.sqrt(W.val); - Kappa.val = W.val * W.val * Mm.val / (RT * 1000 * Z.val); - d2PdTD.val = 0; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + ar[i][j] = new doubleW(0.0d); + } + } + doubleW Mm = new doubleW(0.0d); + MolarMassDetail(x, Mm); + xTermsDetail(x); + + // Calculate the ideal gas Helmholtz energy, and its first and second + // derivatives with respect to temperature. + Alpha0Detail(T, D, x, a0); + + // Calculate the real gas Helmholtz energy, and its derivatives with respect to + // temperature and/or density. + AlpharDetail(2, 3, T, D, ar); + + double R = RDetail; + double RT = R * T; + Z.val = 1 + ar[0][1].val / RT; + P.val = D * RT * Z.val; + dPdD.val = RT + 2 * ar[0][1].val + ar[0][2].val; + dPdT.val = D * R + D * ar[1][1].val; + A.val = a0[0].val + ar[0][0].val; + S.val = -a0[1].val - ar[1][0].val; + U.val = A.val + T * S.val; + Cv.val = -(a0[2].val + ar[2][0].val); + if (D > epsilon) { + H.val = U.val + P.val / D; + G.val = A.val + P.val / D; + Cp.val = Cv.val + T * sq(dPdT.val / D) / dPdD.val; + d2PdD2.val = (2 * ar[0][1].val + 4 * ar[0][2].val + ar[0][3].val) / D; + JT.val = (T / D * dPdT.val / dPdD.val - 1) / Cp.val / D; + } else { + H.val = U.val + RT; + G.val = A.val + RT; + Cp.val = Cv.val + R; + d2PdD2.val = 0; + JT.val = 1E+20; // =(dB/dT*T-B)/Cp for an ideal gas, but dB/dT is not calculated here + } + W.val = 1000 * Cp.val / Cv.val * dPdD.val / Mm.val; + if (W.val < 0) { + W.val = 0; + } + W.val = Math.sqrt(W.val); + Kappa.val = W.val * W.val * Mm.val / (RT * 1000 * Z.val); + d2PdTD.val = 0; + } + + /** + * // Calculate terms dependent only on composition + * + * @param x Composition (mole fraction) + */ + // The following routines are low-level routines that should not be called outside of this code. + void xTermsDetail(double[] x) { + double G, Q, F, U, Q2, xij, xi2; + int icheck; + + // Check to see if a component fraction has changed. If x is the same as the + // previous call, then exit. + icheck = 0; + for (int i = 1; i <= NcDetail; ++i) { + if (Math.abs(x[i] - xold[i]) > 0.0000001) { + icheck = 1; + } + xold[i] = x[i]; + } + if (icheck == 0) { + return; } - /** - * // Calculate terms dependent only on composition - * - * @param x Composition (mole fraction) - */ - // The following routines are low-level routines that should not be called outside of this code. - void xTermsDetail(double[] x) { - double G, Q, F, U, Q2, xij, xi2; - int icheck; - - // Check to see if a component fraction has changed. If x is the same as the - // previous call, then exit. - icheck = 0; - for (int i = 1; i <= NcDetail; ++i) { - if (Math.abs(x[i] - xold[i]) > 0.0000001) { - icheck = 1; - } - xold[i] = x[i]; - } - if (icheck == 0) { - return; - } + K3 = 0; + U = 0; + G = 0; + Q = 0; + F = 0; + for (int n = 1; n <= 18; ++n) { + Bs[n] = 0; + } - K3 = 0; - U = 0; - G = 0; - Q = 0; - F = 0; + // Calculate pure fluid contributions + for (int i = 1; i <= NcDetail; ++i) { + if (x[i] > 0) { + xi2 = sq(x[i]); + K3 += x[i] * Ki25[i]; // K, U, and G are the sums of a pure fluid contribution and a + U += x[i] * Ei25[i]; // binary pair contribution + G += x[i] * Gi[i]; + Q += x[i] * Qi[i]; // Q and F depend only on the pure fluid parts + F += xi2 * Fi[i]; for (int n = 1; n <= 18; ++n) { - Bs[n] = 0; - } - - // Calculate pure fluid contributions - for (int i = 1; i <= NcDetail; ++i) { - if (x[i] > 0) { - xi2 = sq(x[i]); - K3 += x[i] * Ki25[i]; // K, U, and G are the sums of a pure fluid contribution and a - U += x[i] * Ei25[i]; // binary pair contribution - G += x[i] * Gi[i]; - Q += x[i] * Qi[i]; // Q and F depend only on the pure fluid parts - F += xi2 * Fi[i]; - for (int n = 1; n <= 18; ++n) { - Bs[n] = Bs[n] + xi2 * Bsnij2[i][i][n]; // Pure fluid contributions to second - // virial coefficient - } - } - } - K3 = sq(K3); - U = sq(U); - - // Binary pair contributions - for (int i = 1; i <= NcDetail - 1; ++i) { - if (x[i] > 0) { - for (int j = i + 1; j <= NcDetail; ++j) { - if (x[j] > 0) { - xij = 2 * x[i] * x[j]; - K3 = K3 + xij * Kij5[i][j]; - U = U + xij * Uij5[i][j]; - G = G + xij * Gij5[i][j]; - for (int n = 1; n <= 18; ++n) { - Bs[n] = Bs[n] + xij * Bsnij2[i][j][n]; // Second virial coefficients of - // mixture - } - } - } - } - } - K3 = Math.pow(K3, 0.6); - U = Math.pow(U, 0.2); - - // Third virial and higher coefficients - Q2 = sq(Q); - for (int n = 13; n <= 58; ++n) { - Csn[n] = an[n] * Math.pow(U, un[n]); - if (gn[n] == 1) { - Csn[n] = Csn[n] * G; - } - if (qn[n] == 1) { - Csn[n] = Csn[n] * Q2; - } - if (fn[n] == 1) { - Csn[n] = Csn[n] * F; - } + Bs[n] = Bs[n] + xi2 * Bsnij2[i][i][n]; // Pure fluid contributions to second + // virial coefficient } + } } - - /** - * @param T ... - * @param D ... - * @param x ... - * @param a0 ... - */ - void Alpha0Detail(double T, double D, double[] x, doubleW[] a0) { - // Private Sub Alpha0Detail(T, D, x, a0) - - // Calculate the ideal gas Helmholtz energy and its derivatives with respect to - // T and D. - // This routine is not needed when only P (or Z) is calculated. - - // Inputs: - // T - Temperature (K) - // D - Density (mol/l) - // x() - Composition (mole fraction) - - // Outputs: - // a0(0) - Ideal gas Helmholtz energy (J/mol) - // a0(1) - partial (a0)/partial(T) [J/(mol-K)] - // a0(2) - T*partial^2(a0)/partial(T)^2 [J/(mol-K)] - - double LogT, LogD, LogHyp, th0T, LogxD; - double SumHyp0, SumHyp1, SumHyp2; - double em, ep, hcn, hsn; - - a0[0].val = 0; - a0[1].val = 0; - a0[2].val = 0; - - if (D > epsilon) { - LogD = Math.log(D); - } else { - LogD = Math.log(epsilon); - } - LogT = Math.log(T); - for (int i = 1; i <= NcDetail; ++i) { - if (x[i] > 0) { - LogxD = LogD + Math.log(x[i]); - SumHyp0 = 0; - SumHyp1 = 0; - SumHyp2 = 0; - for (int j = 4; j <= 7; ++j) { - if (th0i[i][j] > 0) { - th0T = th0i[i][j] / T; - ep = Math.exp(th0T); - em = 1 / ep; - hsn = (ep - em) / 2; - hcn = (ep + em) / 2; - if (j == 4 || j == 6) { - LogHyp = Math.log(Math.abs(hsn)); - SumHyp0 += n0i[i][j] * LogHyp; - SumHyp1 += n0i[i][j] * (LogHyp - th0T * hcn / hsn); - SumHyp2 += n0i[i][j] * sq(th0T / hsn); - } else { - LogHyp = Math.log(Math.abs(hcn)); - SumHyp0 += -n0i[i][j] * LogHyp; - SumHyp1 += -n0i[i][j] * (LogHyp - th0T * hsn / hcn); - SumHyp2 += +n0i[i][j] * sq(th0T / hcn); - } - } - } - a0[0].val += - x[i] * (LogxD + n0i[i][1] + n0i[i][2] / T - n0i[i][3] * LogT + SumHyp0); - a0[1].val += x[i] * (LogxD + n0i[i][1] - n0i[i][3] * (1 + LogT) + SumHyp1); - a0[2].val += -x[i] * (n0i[i][3] + SumHyp2); + K3 = sq(K3); + U = sq(U); + + // Binary pair contributions + for (int i = 1; i <= NcDetail - 1; ++i) { + if (x[i] > 0) { + for (int j = i + 1; j <= NcDetail; ++j) { + if (x[j] > 0) { + xij = 2 * x[i] * x[j]; + K3 = K3 + xij * Kij5[i][j]; + U = U + xij * Uij5[i][j]; + G = G + xij * Gij5[i][j]; + for (int n = 1; n <= 18; ++n) { + Bs[n] = Bs[n] + xij * Bsnij2[i][j][n]; // Second virial coefficients of + // mixture } + } } - a0[0].val = a0[0].val * RDetail * T; - a0[1].val = a0[1].val * RDetail; - a0[2].val = a0[2].val * RDetail; + } } - - /** - * @param itau .... - * @param idel ... - * @param T ... - * @param D ... - * @param ar ... - */ - void AlpharDetail(int itau, int idel, double T, double D, doubleW[][] ar) { - // Private Sub AlpharDetail(itau, idel, T, D, ar) - - // Calculate the derivatives of the residual Helmholtz energy (ar) with respect - // to T and D. - // itau and idel are inputs that contain the highest derivatives needed. - // Outputs are returned in the array ar. - // Subroutine xTerms must be called before this routine if x has changed - - // Inputs: - // itau - Set this to 1 to calculate "ar" derivatives with respect to T [i.e., - // ar(1,0), ar(1,1), and ar(2,0)], otherwise set it to 0. - // idel - Currently not used, but kept as an input for future use in specifing - // the highest density derivative needed. - // T - Temperature (K) - // D - Density (mol/l) - - // Outputs: - // ar(0,0) - Residual Helmholtz energy (J/mol) - // ar(0,1) - D*partial (ar)/partial(D) (J/mol) - // ar(0,2) - D^2*partial^2(ar)/partial(D)^2 (J/mol) - // ar(0,3) - D^3*partial^3(ar)/partial(D)^3 (J/mol) - // ar(1,0) - partial (ar)/partial(T) [J/(mol-K)] - // ar(1,1) - D*partial^2(ar)/partial(D)/partial(T) [J/(mol-K)] - // ar(2,0) - T*partial^2(ar)/partial(T)^2 [J/(mol-K)] - - double ckd, bkd, Dred; - double Sum, s0, s1, s2, s3, RT; - double[] Sum0 = new double[NTerms + 1]; - double[] SumB = new double[NTerms + 1]; - double[] Dknn = new double[9 + 1]; - double[] Expn = new double[4 + 1]; - - double[] CoefD1 = new double[NTerms + 1]; - double[] CoefD2 = new double[NTerms + 1]; - double[] CoefD3 = new double[NTerms + 1]; - - double[] CoefT1 = new double[NTerms + 1]; - double[] CoefT2 = new double[NTerms + 1]; - - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - ar[i][j].val = 0; - } - } - if (Math.abs(T - Told) > 0.0000001) { - for (int n = 1; n <= 58; ++n) { - Tun[n] = Math.pow(T, -un[n]); - } - } - Told = T; - - // Precalculation of common powers and exponents of density - Dred = K3 * D; - Dknn[0] = 1; - for (int n = 1; n <= 9; ++n) { - Dknn[n] = Dred * Dknn[n - 1]; - } - Expn[0] = 1; - for (int n = 1; n <= 4; ++n) { - Expn[n] = Math.exp(-Dknn[n]); - } - RT = RDetail * T; - - for (int n = 1; n <= 58; ++n) { - // Contributions to the Helmholtz energy and its derivatives with respect to - // temperature - CoefT1[n] = RDetail * (un[n] - 1); - CoefT2[n] = CoefT1[n] * un[n]; - // Contributions to the virial coefficients - SumB[n] = 0; - Sum0[n] = 0; - if (n <= 18) { - Sum = Bs[n] * D; - if (n >= 13) { - Sum += -Csn[n] * Dred; - } - SumB[n] = Sum * Tun[n]; - } - if (n >= 13) { - // Contributions to the residual part of the Helmholtz energy - Sum0[n] = Csn[n] * Dknn[bn[n]] * Tun[n] * Expn[kn[n]]; - // Contributions to the derivatives of the Helmholtz energy with respect to - // density - bkd = bn[n] - kn[n] * Dknn[kn[n]]; - ckd = kn[n] * kn[n] * Dknn[kn[n]]; - CoefD1[n] = bkd; - CoefD2[n] = bkd * (bkd - 1) - ckd; - CoefD3[n] = (bkd - 2) * CoefD2[n] + ckd * (1 - kn[n] - 2 * bkd); + K3 = Math.pow(K3, 0.6); + U = Math.pow(U, 0.2); + + // Third virial and higher coefficients + Q2 = sq(Q); + for (int n = 13; n <= 58; ++n) { + Csn[n] = an[n] * Math.pow(U, un[n]); + if (gn[n] == 1) { + Csn[n] = Csn[n] * G; + } + if (qn[n] == 1) { + Csn[n] = Csn[n] * Q2; + } + if (fn[n] == 1) { + Csn[n] = Csn[n] * F; + } + } + } + + /** + * @param T ... + * @param D ... + * @param x ... + * @param a0 ... + */ + void Alpha0Detail(double T, double D, double[] x, doubleW[] a0) { + // Private Sub Alpha0Detail(T, D, x, a0) + + // Calculate the ideal gas Helmholtz energy and its derivatives with respect to + // T and D. + // This routine is not needed when only P (or Z) is calculated. + + // Inputs: + // T - Temperature (K) + // D - Density (mol/l) + // x() - Composition (mole fraction) + + // Outputs: + // a0(0) - Ideal gas Helmholtz energy (J/mol) + // a0(1) - partial (a0)/partial(T) [J/(mol-K)] + // a0(2) - T*partial^2(a0)/partial(T)^2 [J/(mol-K)] + + double LogT, LogD, LogHyp, th0T, LogxD; + double SumHyp0, SumHyp1, SumHyp2; + double em, ep, hcn, hsn; + + a0[0].val = 0; + a0[1].val = 0; + a0[2].val = 0; + + if (D > epsilon) { + LogD = Math.log(D); + } else { + LogD = Math.log(epsilon); + } + LogT = Math.log(T); + for (int i = 1; i <= NcDetail; ++i) { + if (x[i] > 0) { + LogxD = LogD + Math.log(x[i]); + SumHyp0 = 0; + SumHyp1 = 0; + SumHyp2 = 0; + for (int j = 4; j <= 7; ++j) { + if (th0i[i][j] > 0) { + th0T = th0i[i][j] / T; + ep = Math.exp(th0T); + em = 1 / ep; + hsn = (ep - em) / 2; + hcn = (ep + em) / 2; + if (j == 4 || j == 6) { + LogHyp = Math.log(Math.abs(hsn)); + SumHyp0 += n0i[i][j] * LogHyp; + SumHyp1 += n0i[i][j] * (LogHyp - th0T * hcn / hsn); + SumHyp2 += n0i[i][j] * sq(th0T / hsn); } else { - CoefD1[n] = 0; - CoefD2[n] = 0; - CoefD3[n] = 0; + LogHyp = Math.log(Math.abs(hcn)); + SumHyp0 += -n0i[i][j] * LogHyp; + SumHyp1 += -n0i[i][j] * (LogHyp - th0T * hsn / hcn); + SumHyp2 += +n0i[i][j] * sq(th0T / hcn); } + } } + a0[0].val += x[i] * (LogxD + n0i[i][1] + n0i[i][2] / T - n0i[i][3] * LogT + SumHyp0); + a0[1].val += x[i] * (LogxD + n0i[i][1] - n0i[i][3] * (1 + LogT) + SumHyp1); + a0[2].val += -x[i] * (n0i[i][3] + SumHyp2); + } + } + a0[0].val = a0[0].val * RDetail * T; + a0[1].val = a0[1].val * RDetail; + a0[2].val = a0[2].val * RDetail; + } + + /** + * @param itau .... + * @param idel ... + * @param T ... + * @param D ... + * @param ar ... + */ + void AlpharDetail(int itau, int idel, double T, double D, doubleW[][] ar) { + // Private Sub AlpharDetail(itau, idel, T, D, ar) + + // Calculate the derivatives of the residual Helmholtz energy (ar) with respect + // to T and D. + // itau and idel are inputs that contain the highest derivatives needed. + // Outputs are returned in the array ar. + // Subroutine xTerms must be called before this routine if x has changed + + // Inputs: + // itau - Set this to 1 to calculate "ar" derivatives with respect to T [i.e., + // ar(1,0), ar(1,1), and ar(2,0)], otherwise set it to 0. + // idel - Currently not used, but kept as an input for future use in specifing + // the highest density derivative needed. + // T - Temperature (K) + // D - Density (mol/l) + + // Outputs: + // ar(0,0) - Residual Helmholtz energy (J/mol) + // ar(0,1) - D*partial (ar)/partial(D) (J/mol) + // ar(0,2) - D^2*partial^2(ar)/partial(D)^2 (J/mol) + // ar(0,3) - D^3*partial^3(ar)/partial(D)^3 (J/mol) + // ar(1,0) - partial (ar)/partial(T) [J/(mol-K)] + // ar(1,1) - D*partial^2(ar)/partial(D)/partial(T) [J/(mol-K)] + // ar(2,0) - T*partial^2(ar)/partial(T)^2 [J/(mol-K)] + + double ckd, bkd, Dred; + double Sum, s0, s1, s2, s3, RT; + double[] Sum0 = new double[NTerms + 1]; + double[] SumB = new double[NTerms + 1]; + double[] Dknn = new double[9 + 1]; + double[] Expn = new double[4 + 1]; + + double[] CoefD1 = new double[NTerms + 1]; + double[] CoefD2 = new double[NTerms + 1]; + double[] CoefD3 = new double[NTerms + 1]; + + double[] CoefT1 = new double[NTerms + 1]; + double[] CoefT2 = new double[NTerms + 1]; + + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + ar[i][j].val = 0; + } + } + if (Math.abs(T - Told) > 0.0000001) { + for (int n = 1; n <= 58; ++n) { + Tun[n] = Math.pow(T, -un[n]); + } + } + Told = T; - for (int n = 1; n <= 58; ++n) { - // Density derivatives - s0 = Sum0[n] + SumB[n]; - s1 = Sum0[n] * CoefD1[n] + SumB[n]; - s2 = Sum0[n] * CoefD2[n]; - s3 = Sum0[n] * CoefD3[n]; - ar[0][0].val = ar[0][0].val + RT * s0; - ar[0][1].val = ar[0][1].val + RT * s1; - ar[0][2].val = ar[0][2].val + RT * s2; - ar[0][3].val = ar[0][3].val + RT * s3; - // Temperature derivatives - if (itau > 0) { - ar[1][0].val = ar[1][0].val - CoefT1[n] * s0; - ar[1][1].val = ar[1][1].val - CoefT1[n] * s1; - ar[2][0].val = ar[2][0].val + CoefT2[n] * s0; - // The following are not used, but fully functional - // ar(1, 2) = ar(1, 2) - CoefT1(n) * s2; - // ar(1, 3) = ar(1, 3) - CoefT1(n) * s3; - // ar(2, 1) = ar(2, 1) + CoefT2(n) * s1; - // ar(2, 2) = ar(2, 2) + CoefT2(n) * s2; - // ar(2, 3) = ar(2, 3) + CoefT2(n) * s3; - } + // Precalculation of common powers and exponents of density + Dred = K3 * D; + Dknn[0] = 1; + for (int n = 1; n <= 9; ++n) { + Dknn[n] = Dred * Dknn[n - 1]; + } + Expn[0] = 1; + for (int n = 1; n <= 4; ++n) { + Expn[n] = Math.exp(-Dknn[n]); + } + RT = RDetail * T; + + for (int n = 1; n <= 58; ++n) { + // Contributions to the Helmholtz energy and its derivatives with respect to + // temperature + CoefT1[n] = RDetail * (un[n] - 1); + CoefT2[n] = CoefT1[n] * un[n]; + // Contributions to the virial coefficients + SumB[n] = 0; + Sum0[n] = 0; + if (n <= 18) { + Sum = Bs[n] * D; + if (n >= 13) { + Sum += -Csn[n] * Dred; } + SumB[n] = Sum * Tun[n]; + } + if (n >= 13) { + // Contributions to the residual part of the Helmholtz energy + Sum0[n] = Csn[n] * Dknn[bn[n]] * Tun[n] * Expn[kn[n]]; + // Contributions to the derivatives of the Helmholtz energy with respect to + // density + bkd = bn[n] - kn[n] * Dknn[kn[n]]; + ckd = kn[n] * kn[n] * Dknn[kn[n]]; + CoefD1[n] = bkd; + CoefD2[n] = bkd * (bkd - 1) - ckd; + CoefD3[n] = (bkd - 2) * CoefD2[n] + ckd * (1 - kn[n] - 2 * bkd); + } else { + CoefD1[n] = 0; + CoefD2[n] = 0; + CoefD3[n] = 0; + } } - // The following routine must be called once before any other routine. - /** - *

- * SetupDetail. - *

- */ - public void SetupDetail() { - // Initialize all the constants and parameters in the DETAIL model. - // Some values are modified for calculations that do not depend on T, D, and x - // in order to speed up the program. - - int[] sn = new int[NTerms + 1]; - int[] wn = new int[NTerms + 1]; - - double[] Ei = new double[MaxFlds + 1]; - double[] Ki = new double[MaxFlds + 1]; - double[] Si = new double[MaxFlds + 1]; - double[] Wi = new double[MaxFlds + 1]; - double Bsnij; - double[][] Kij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] Gij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] Eij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] Uij = new double[MaxFlds + 1][MaxFlds + 1]; - - double d0; - - RDetail = 8.31451; - - // Molar masses (g/mol) - MMiDetail[1] = 16.043; // Methane - MMiDetail[2] = 28.0135; // Nitrogen - MMiDetail[3] = 44.01; // Carbon dioxide - MMiDetail[4] = 30.07; // Ethane - MMiDetail[5] = 44.097; // Propane - MMiDetail[6] = 58.123; // Isobutane - MMiDetail[7] = 58.123; // n-Butane - MMiDetail[8] = 72.15; // Isopentane - MMiDetail[9] = 72.15; // n-Pentane - MMiDetail[10] = 86.177; // Hexane - MMiDetail[11] = 100.204; // Heptane - MMiDetail[12] = 114.231; // Octane - MMiDetail[13] = 128.258; // Nonane - MMiDetail[14] = 142.285; // Decane - MMiDetail[15] = 2.0159; // Hydrogen - MMiDetail[16] = 31.9988; // Oxygen - MMiDetail[17] = 28.01; // Carbon monoxide - MMiDetail[18] = 18.0153; // Water - MMiDetail[19] = 34.082; // Hydrogen sulfide - MMiDetail[20] = 4.0026; // Helium - MMiDetail[21] = 39.948; // Argon - - // Initialize constants - Told = 0; - for (int i = 1; i <= NTerms; ++i) { - an[i] = 0; - bn[i] = 0; - gn[i] = 0; - fn[i] = 0; - kn[i] = 0; - qn[i] = 0; - sn[i] = 0; - un[i] = 0; - wn[i] = 0; - } + for (int n = 1; n <= 58; ++n) { + // Density derivatives + s0 = Sum0[n] + SumB[n]; + s1 = Sum0[n] * CoefD1[n] + SumB[n]; + s2 = Sum0[n] * CoefD2[n]; + s3 = Sum0[n] * CoefD3[n]; + ar[0][0].val = ar[0][0].val + RT * s0; + ar[0][1].val = ar[0][1].val + RT * s1; + ar[0][2].val = ar[0][2].val + RT * s2; + ar[0][3].val = ar[0][3].val + RT * s3; + // Temperature derivatives + if (itau > 0) { + ar[1][0].val = ar[1][0].val - CoefT1[n] * s0; + ar[1][1].val = ar[1][1].val - CoefT1[n] * s1; + ar[2][0].val = ar[2][0].val + CoefT2[n] * s0; + // The following are not used, but fully functional + // ar(1, 2) = ar(1, 2) - CoefT1(n) * s2; + // ar(1, 3) = ar(1, 3) - CoefT1(n) * s3; + // ar(2, 1) = ar(2, 1) + CoefT2(n) * s1; + // ar(2, 2) = ar(2, 2) + CoefT2(n) * s2; + // ar(2, 3) = ar(2, 3) + CoefT2(n) * s3; + } + } + } + + // The following routine must be called once before any other routine. + /** + *

+ * SetupDetail. + *

+ */ + public void SetupDetail() { + // Initialize all the constants and parameters in the DETAIL model. + // Some values are modified for calculations that do not depend on T, D, and x + // in order to speed up the program. + + int[] sn = new int[NTerms + 1]; + int[] wn = new int[NTerms + 1]; + + double[] Ei = new double[MaxFlds + 1]; + double[] Ki = new double[MaxFlds + 1]; + double[] Si = new double[MaxFlds + 1]; + double[] Wi = new double[MaxFlds + 1]; + double Bsnij; + double[][] Kij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] Gij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] Eij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] Uij = new double[MaxFlds + 1][MaxFlds + 1]; + + double d0; + + RDetail = 8.31451; + + // Molar masses (g/mol) + MMiDetail[1] = 16.043; // Methane + MMiDetail[2] = 28.0135; // Nitrogen + MMiDetail[3] = 44.01; // Carbon dioxide + MMiDetail[4] = 30.07; // Ethane + MMiDetail[5] = 44.097; // Propane + MMiDetail[6] = 58.123; // Isobutane + MMiDetail[7] = 58.123; // n-Butane + MMiDetail[8] = 72.15; // Isopentane + MMiDetail[9] = 72.15; // n-Pentane + MMiDetail[10] = 86.177; // Hexane + MMiDetail[11] = 100.204; // Heptane + MMiDetail[12] = 114.231; // Octane + MMiDetail[13] = 128.258; // Nonane + MMiDetail[14] = 142.285; // Decane + MMiDetail[15] = 2.0159; // Hydrogen + MMiDetail[16] = 31.9988; // Oxygen + MMiDetail[17] = 28.01; // Carbon monoxide + MMiDetail[18] = 18.0153; // Water + MMiDetail[19] = 34.082; // Hydrogen sulfide + MMiDetail[20] = 4.0026; // Helium + MMiDetail[21] = 39.948; // Argon + + // Initialize constants + Told = 0; + for (int i = 1; i <= NTerms; ++i) { + an[i] = 0; + bn[i] = 0; + gn[i] = 0; + fn[i] = 0; + kn[i] = 0; + qn[i] = 0; + sn[i] = 0; + un[i] = 0; + wn[i] = 0; + } - for (int i = 1; i <= MaxFlds; ++i) { - Ei[i] = 0; - Fi[i] = 0; - Gi[i] = 0; - Ki[i] = 0; - Qi[i] = 0; - Si[i] = 0; - Wi[i] = 0; - xold[i] = 0; - for (int j = 1; j <= MaxFlds; ++j) { - Eij[i][j] = 1; - Gij[i][j] = 1; - Kij[i][j] = 1; - Uij[i][j] = 1; - } - } + for (int i = 1; i <= MaxFlds; ++i) { + Ei[i] = 0; + Fi[i] = 0; + Gi[i] = 0; + Ki[i] = 0; + Qi[i] = 0; + Si[i] = 0; + Wi[i] = 0; + xold[i] = 0; + for (int j = 1; j <= MaxFlds; ++j) { + Eij[i][j] = 1; + Gij[i][j] = 1; + Kij[i][j] = 1; + Uij[i][j] = 1; + } + } - // Coefficients of the equation of state - an[1] = 0.1538326; - an[2] = 1.341953; - an[3] = -2.998583; - an[4] = -0.04831228; - an[5] = 0.3757965; - an[6] = -1.589575; - an[7] = -0.05358847; - an[8] = 0.88659463; - an[9] = -0.71023704; - an[10] = -1.471722; - an[11] = 1.32185035; - an[12] = -0.78665925; - an[13] = 0.00000000229129; - an[14] = 0.1576724; - an[15] = -0.4363864; - an[16] = -0.04408159; - an[17] = -0.003433888; - an[18] = 0.03205905; - an[19] = 0.02487355; - an[20] = 0.07332279; - an[21] = -0.001600573; - an[22] = 0.6424706; - an[23] = -0.4162601; - an[24] = -0.06689957; - an[25] = 0.2791795; - an[26] = -0.6966051; - an[27] = -0.002860589; - an[28] = -0.008098836; - an[29] = 3.150547; - an[30] = 0.007224479; - an[31] = -0.7057529; - an[32] = 0.5349792; - an[33] = -0.07931491; - an[34] = -1.418465; - an[35] = -5.99905E-17; - an[36] = 0.1058402; - an[37] = 0.03431729; - an[38] = -0.007022847; - an[39] = 0.02495587; - an[40] = 0.04296818; - an[41] = 0.7465453; - an[42] = -0.2919613; - an[43] = 7.294616; - an[44] = -9.936757; - an[45] = -0.005399808; - an[46] = -0.2432567; - an[47] = 0.04987016; - an[48] = 0.003733797; - an[49] = 1.874951; - an[50] = 0.002168144; - an[51] = -0.6587164; - an[52] = 0.000205518; - an[53] = 0.009776195; - an[54] = -0.02048708; - an[55] = 0.01557322; - an[56] = 0.006862415; - an[57] = -0.001226752; - an[58] = 0.002850908; - - // Density exponents - bn[1] = 1; - bn[2] = 1; - bn[3] = 1; - bn[4] = 1; - bn[5] = 1; - bn[6] = 1; - bn[7] = 1; - bn[8] = 1; - bn[9] = 1; - bn[10] = 1; - bn[11] = 1; - bn[12] = 1; - bn[13] = 1; - bn[14] = 1; - bn[15] = 1; - bn[16] = 1; - bn[17] = 1; - bn[18] = 1; - bn[19] = 2; - bn[20] = 2; - bn[21] = 2; - bn[22] = 2; - bn[23] = 2; - bn[24] = 2; - bn[25] = 2; - bn[26] = 2; - bn[27] = 2; - bn[28] = 3; - bn[29] = 3; - bn[30] = 3; - bn[31] = 3; - bn[32] = 3; - bn[33] = 3; - bn[34] = 3; - bn[35] = 3; - bn[36] = 3; - bn[37] = 3; - bn[38] = 4; - bn[39] = 4; - bn[40] = 4; - bn[41] = 4; - bn[42] = 4; - bn[43] = 4; - bn[44] = 4; - bn[45] = 5; - bn[46] = 5; - bn[47] = 5; - bn[48] = 5; - bn[49] = 5; - bn[50] = 6; - bn[51] = 6; - bn[52] = 7; - bn[53] = 7; - bn[54] = 8; - bn[55] = 8; - bn[56] = 8; - bn[57] = 9; - bn[58] = 9; - - // Exponents on density in EXP[-cn*D^kn] part - // The cn part in this term is not included in this program since it is 1 when - // kn<>0][and 0 otherwise - kn[13] = 3; - kn[14] = 2; - kn[15] = 2; - kn[16] = 2; - kn[17] = 4; - kn[18] = 4; - kn[21] = 2; - kn[22] = 2; - kn[23] = 2; - kn[24] = 4; - kn[25] = 4; - kn[26] = 4; - kn[27] = 4; - kn[29] = 1; - kn[30] = 1; - kn[31] = 2; - kn[32] = 2; - kn[33] = 3; - kn[34] = 3; - kn[35] = 4; - kn[36] = 4; - kn[37] = 4; - kn[40] = 2; - kn[41] = 2; - kn[42] = 2; - kn[43] = 4; - kn[44] = 4; - kn[46] = 2; - kn[47] = 2; - kn[48] = 4; - kn[49] = 4; - kn[51] = 2; - kn[53] = 2; - kn[54] = 1; - kn[55] = 2; - kn[56] = 2; - kn[57] = 2; - kn[58] = 2; - - // Temperature exponents - un[1] = 0; - un[2] = 0.5; - un[3] = 1; - un[4] = 3.5; - un[5] = -0.5; - un[6] = 4.5; - un[7] = 0.5; - un[8] = 7.5; - un[9] = 9.5; - un[10] = 6; - un[11] = 12; - un[12] = 12.5; - un[13] = -6; - un[14] = 2; - un[15] = 3; - un[16] = 2; - un[17] = 2; - un[18] = 11; - un[19] = -0.5; - un[20] = 0.5; - un[21] = 0; - un[22] = 4; - un[23] = 6; - un[24] = 21; - un[25] = 23; - un[26] = 22; - un[27] = -1; - un[28] = -0.5; - un[29] = 7; - un[30] = -1; - un[31] = 6; - un[32] = 4; - un[33] = 1; - un[34] = 9; - un[35] = -13; - un[36] = 21; - un[37] = 8; - un[38] = -0.5; - un[39] = 0; - un[40] = 2; - un[41] = 7; - un[42] = 9; - un[43] = 22; - un[44] = 23; - un[45] = 1; - un[46] = 9; - un[47] = 3; - un[48] = 8; - un[49] = 23; - un[50] = 1.5; - un[51] = 5; - un[52] = -0.5; - un[53] = 4; - un[54] = 7; - un[55] = 3; - un[56] = 0; - un[57] = 1; - un[58] = 0; - - // Flags - fn[13] = 1; - fn[27] = 1; - fn[30] = 1; - fn[35] = 1; - gn[5] = 1; - gn[6] = 1; - gn[25] = 1; - gn[29] = 1; - gn[32] = 1; - gn[33] = 1; - gn[34] = 1; - gn[51] = 1; - gn[54] = 1; - gn[56] = 1; - qn[7] = 1; - qn[16] = 1; - qn[26] = 1; - qn[28] = 1; - qn[37] = 1; - qn[42] = 1; - qn[47] = 1; - qn[49] = 1; - qn[52] = 1; - qn[58] = 1; - sn[8] = 1; - sn[9] = 1; - wn[10] = 1; - wn[11] = 1; - wn[12] = 1; - - // Energy parameters - Ei[1] = 151.3183; - Ei[2] = 99.73778; - Ei[3] = 241.9606; - Ei[4] = 244.1667; - Ei[5] = 298.1183; - Ei[6] = 324.0689; - Ei[7] = 337.6389; - Ei[8] = 365.5999; - Ei[9] = 370.6823; - Ei[10] = 402.636293; - Ei[11] = 427.72263; - Ei[12] = 450.325022; - Ei[13] = 470.840891; - Ei[14] = 489.558373; - Ei[15] = 26.95794; - Ei[16] = 122.7667; - Ei[17] = 105.5348; - Ei[18] = 514.0156; - Ei[19] = 296.355; - Ei[20] = 2.610111; - Ei[21] = 119.6299; - - // Size parameters - Ki[1] = 0.4619255; - Ki[2] = 0.4479153; - Ki[3] = 0.4557489; - Ki[4] = 0.5279209; - Ki[5] = 0.583749; - Ki[6] = 0.6406937; - Ki[7] = 0.6341423; - Ki[8] = 0.6738577; - Ki[9] = 0.6798307; - Ki[10] = 0.7175118; - Ki[11] = 0.7525189; - Ki[12] = 0.784955; - Ki[13] = 0.8152731; - Ki[14] = 0.8437826; - Ki[15] = 0.3514916; - Ki[16] = 0.4186954; - Ki[17] = 0.4533894; - Ki[18] = 0.3825868; - Ki[19] = 0.4618263; - Ki[20] = 0.3589888; - Ki[21] = 0.4216551; - - // Orientation parameters - Gi[2] = 0.027815; - Gi[3] = 0.189065; - Gi[4] = 0.0793; - Gi[5] = 0.141239; - Gi[6] = 0.256692; - Gi[7] = 0.281835; - Gi[8] = 0.332267; - Gi[9] = 0.366911; - Gi[10] = 0.289731; - Gi[11] = 0.337542; - Gi[12] = 0.383381; - Gi[13] = 0.427354; - Gi[14] = 0.469659; - Gi[15] = 0.034369; - Gi[16] = 0.021; - Gi[17] = 0.038953; - Gi[18] = 0.3325; - Gi[19] = 0.0885; - - // Quadrupole parameters - Qi[3] = 0.69; - Qi[18] = 1.06775; - Qi[19] = 0.633276; - Fi[15] = 1; // High temperature parameter - Si[18] = 1.5822; // Dipole parameter - Si[19] = 0.39; // Dipole parameter - Wi[18] = 1; // Association parameter - - // Energy parameters - Eij[1][2] = 0.97164; - Eij[1][3] = 0.960644; - Eij[1][5] = 0.994635; - Eij[1][6] = 1.01953; - Eij[1][7] = 0.989844; - Eij[1][8] = 1.00235; - Eij[1][9] = 0.999268; - Eij[1][10] = 1.107274; - Eij[1][11] = 0.88088; - Eij[1][12] = 0.880973; - Eij[1][13] = 0.881067; - Eij[1][14] = 0.881161; - Eij[1][15] = 1.17052; - Eij[1][17] = 0.990126; - Eij[1][18] = 0.708218; - Eij[1][19] = 0.931484; - Eij[2][3] = 1.02274; - Eij[2][4] = 0.97012; - Eij[2][5] = 0.945939; - Eij[2][6] = 0.946914; - Eij[2][7] = 0.973384; - Eij[2][8] = 0.95934; - Eij[2][9] = 0.94552; - Eij[2][15] = 1.08632; - Eij[2][16] = 1.021; - Eij[2][17] = 1.00571; - Eij[2][18] = 0.746954; - Eij[2][19] = 0.902271; - Eij[3][4] = 0.925053; - Eij[3][5] = 0.960237; - Eij[3][6] = 0.906849; - Eij[3][7] = 0.897362; - Eij[3][8] = 0.726255; - Eij[3][9] = 0.859764; - Eij[3][10] = 0.855134; - Eij[3][11] = 0.831229; - Eij[3][12] = 0.80831; - Eij[3][13] = 0.786323; - Eij[3][14] = 0.765171; - Eij[3][15] = 1.28179; - Eij[3][17] = 1.5; - Eij[3][18] = 0.849408; - Eij[3][19] = 0.955052; - Eij[4][5] = 1.02256; - Eij[4][7] = 1.01306; - Eij[4][9] = 1.00532; - Eij[4][15] = 1.16446; - Eij[4][18] = 0.693168; - Eij[4][19] = 0.946871; - Eij[5][7] = 1.0049; - Eij[5][15] = 1.034787; - Eij[6][15] = 1.3; - Eij[7][15] = 1.3; - Eij[10][19] = 1.008692; - Eij[11][19] = 1.010126; - Eij[12][19] = 1.011501; - Eij[13][19] = 1.012821; - Eij[14][19] = 1.014089; - Eij[15][17] = 1.1; - - // Conformal energy parameters - Uij[1][2] = 0.886106; - Uij[1][3] = 0.963827; - Uij[1][5] = 0.990877; - Uij[1][7] = 0.992291; - Uij[1][9] = 1.00367; - Uij[1][10] = 1.302576; - Uij[1][11] = 1.191904; - Uij[1][12] = 1.205769; - Uij[1][13] = 1.219634; - Uij[1][14] = 1.233498; - Uij[1][15] = 1.15639; - Uij[1][19] = 0.736833; - Uij[2][3] = 0.835058; - Uij[2][4] = 0.816431; - Uij[2][5] = 0.915502; - Uij[2][7] = 0.993556; - Uij[2][15] = 0.408838; - Uij[2][19] = 0.993476; - Uij[3][4] = 0.96987; - Uij[3][10] = 1.066638; - Uij[3][11] = 1.077634; - Uij[3][12] = 1.088178; - Uij[3][13] = 1.098291; - Uij[3][14] = 1.108021; - Uij[3][17] = 0.9; - Uij[3][19] = 1.04529; - Uij[4][5] = 1.065173; - Uij[4][6] = 1.25; - Uij[4][7] = 1.25; - Uij[4][8] = 1.25; - Uij[4][9] = 1.25; - Uij[4][15] = 1.61666; - Uij[4][19] = 0.971926; - Uij[10][19] = 1.028973; - Uij[11][19] = 1.033754; - Uij[12][19] = 1.038338; - Uij[13][19] = 1.042735; - Uij[14][19] = 1.046966; - - // Size parameters - Kij[1][2] = 1.00363; - Kij[1][3] = 0.995933; - Kij[1][5] = 1.007619; - Kij[1][7] = 0.997596; - Kij[1][9] = 1.002529; - Kij[1][10] = 0.982962; - Kij[1][11] = 0.983565; - Kij[1][12] = 0.982707; - Kij[1][13] = 0.981849; - Kij[1][14] = 0.980991; - Kij[1][15] = 1.02326; - Kij[1][19] = 1.00008; - Kij[2][3] = 0.982361; - Kij[2][4] = 1.00796; - Kij[2][15] = 1.03227; - Kij[2][19] = 0.942596; - Kij[3][4] = 1.00851; - Kij[3][10] = 0.910183; - Kij[3][11] = 0.895362; - Kij[3][12] = 0.881152; - Kij[3][13] = 0.86752; - Kij[3][14] = 0.854406; - Kij[3][19] = 1.00779; - Kij[4][5] = 0.986893; - Kij[4][15] = 1.02034; - Kij[4][19] = 0.999969; - Kij[10][19] = 0.96813; - Kij[11][19] = 0.96287; - Kij[12][19] = 0.957828; - Kij[13][19] = 0.952441; - Kij[14][19] = 0.948338; - - // Orientation parameters - Gij[1][3] = 0.807653; - Gij[1][15] = 1.95731; - Gij[2][3] = 0.982746; - Gij[3][4] = 0.370296; - Gij[3][18] = 1.67309; - - // Ideal gas parameters - n0i[1][3] = 4.00088; - n0i[1][4] = 0.76315; - n0i[1][5] = 0.0046; - n0i[1][6] = 8.74432; - n0i[1][7] = -4.46921; - n0i[1][1] = 29.83843397; - n0i[1][2] = -15999.69151; - n0i[2][3] = 3.50031; - n0i[2][4] = 0.13732; - n0i[2][5] = -0.1466; - n0i[2][6] = 0.90066; - n0i[2][7] = 0; - n0i[2][1] = 17.56770785; - n0i[2][2] = -2801.729072; - n0i[3][3] = 3.50002; - n0i[3][4] = 2.04452; - n0i[3][5] = -1.06044; - n0i[3][6] = 2.03366; - n0i[3][7] = 0.01393; - n0i[3][1] = 20.65844696; - n0i[3][2] = -4902.171516; - n0i[4][3] = 4.00263; - n0i[4][4] = 4.33939; - n0i[4][5] = 1.23722; - n0i[4][6] = 13.1974; - n0i[4][7] = -6.01989; - n0i[4][1] = 36.73005938; - n0i[4][2] = -23639.65301; - n0i[5][3] = 4.02939; - n0i[5][4] = 6.60569; - n0i[5][5] = 3.197; - n0i[5][6] = 19.1921; - n0i[5][7] = -8.37267; - n0i[5][1] = 44.70909619; - n0i[5][2] = -31236.63551; - n0i[6][3] = 4.06714; - n0i[6][4] = 8.97575; - n0i[6][5] = 5.25156; - n0i[6][6] = 25.1423; - n0i[6][7] = 16.1388; - n0i[6][1] = 34.30180349; - n0i[6][2] = -38525.50276; - n0i[7][3] = 4.33944; - n0i[7][4] = 9.44893; - n0i[7][5] = 6.89406; - n0i[7][6] = 24.4618; - n0i[7][7] = 14.7824; - n0i[7][1] = 36.53237783; - n0i[7][2] = -38957.80933; - n0i[8][3] = 4; - n0i[8][4] = 11.7618; - n0i[8][5] = 20.1101; - n0i[8][6] = 33.1688; - n0i[8][7] = 0; - n0i[8][1] = 43.17218626; - n0i[8][2] = -51198.30946; - n0i[9][3] = 4; - n0i[9][4] = 8.95043; - n0i[9][5] = 21.836; - n0i[9][6] = 33.4032; - n0i[9][7] = 0; - n0i[9][1] = 42.67837089; - n0i[9][2] = -45215.83; - n0i[10][3] = 4; - n0i[10][4] = 11.6977; - n0i[10][5] = 26.8142; - n0i[10][6] = 38.6164; - n0i[10][7] = 0; - n0i[10][1] = 46.99717188; - n0i[10][2] = -52746.83318; - n0i[11][3] = 4; - n0i[11][4] = 13.7266; - n0i[11][5] = 30.4707; - n0i[11][6] = 43.5561; - n0i[11][7] = 0; - n0i[11][1] = 52.07631631; - n0i[11][2] = -57104.81056; - n0i[12][3] = 4; - n0i[12][4] = 15.6865; - n0i[12][5] = 33.8029; - n0i[12][6] = 48.1731; - n0i[12][7] = 0; - n0i[12][1] = 57.25830934; - n0i[12][2] = -60546.76385; - n0i[13][3] = 4; - n0i[13][4] = 18.0241; - n0i[13][5] = 38.1235; - n0i[13][6] = 53.3415; - n0i[13][7] = 0; - n0i[13][1] = 62.09646901; - n0i[13][2] = -66600.12837; - n0i[14][3] = 4; - n0i[14][4] = 21.0069; - n0i[14][5] = 43.4931; - n0i[14][6] = 58.3657; - n0i[14][7] = 0; - n0i[14][1] = 65.93909154; - n0i[14][2] = -74131.45483; - n0i[15][3] = 2.47906; - n0i[15][4] = 0.95806; - n0i[15][5] = 0.45444; - n0i[15][6] = 1.56039; - n0i[15][7] = -1.3756; - n0i[15][1] = 13.07520288; - n0i[15][2] = -5836.943696; - n0i[16][3] = 3.50146; - n0i[16][4] = 1.07558; - n0i[16][5] = 1.01334; - n0i[16][6] = 0; - n0i[16][7] = 0; - n0i[16][1] = 16.8017173; - n0i[16][2] = -2318.32269; - n0i[17][3] = 3.50055; - n0i[17][4] = 1.02865; - n0i[17][5] = 0.00493; - n0i[17][6] = 0; - n0i[17][7] = 0; - n0i[17][1] = 17.45786899; - n0i[17][2] = -2635.244116; - n0i[18][3] = 4.00392; - n0i[18][4] = 0.01059; - n0i[18][5] = 0.98763; - n0i[18][6] = 3.06904; - n0i[18][7] = 0; - n0i[18][1] = 21.57882705; - n0i[18][2] = -7766.733078; - n0i[19][3] = 4; - n0i[19][4] = 3.11942; - n0i[19][5] = 1.00243; - n0i[19][6] = 0; - n0i[19][7] = 0; - n0i[19][1] = 21.5830944; - n0i[19][2] = -6069.035869; - n0i[20][3] = 2.5; - n0i[20][4] = 0; - n0i[20][5] = 0; - n0i[20][6] = 0; - n0i[20][7] = 0; - n0i[20][1] = 10.04639507; - n0i[20][2] = -745.375; - n0i[21][3] = 2.5; - n0i[21][4] = 0; - n0i[21][5] = 0; - n0i[21][6] = 0; - n0i[21][7] = 0; - n0i[21][1] = 10.04639507; - n0i[21][2] = -745.375; - th0i[1][4] = 820.659; - th0i[1][5] = 178.41; - th0i[1][6] = 1062.82; - th0i[1][7] = 1090.53; - th0i[2][4] = 662.738; - th0i[2][5] = 680.562; - th0i[2][6] = 1740.06; - th0i[2][7] = 0; - th0i[3][4] = 919.306; - th0i[3][5] = 865.07; - th0i[3][6] = 483.553; - th0i[3][7] = 341.109; - th0i[4][4] = 559.314; - th0i[4][5] = 223.284; - th0i[4][6] = 1031.38; - th0i[4][7] = 1071.29; - th0i[5][4] = 479.856; - th0i[5][5] = 200.893; - th0i[5][6] = 955.312; - th0i[5][7] = 1027.29; - th0i[6][4] = 438.27; - th0i[6][5] = 198.018; - th0i[6][6] = 1905.02; - th0i[6][7] = 893.765; - th0i[7][4] = 468.27; - th0i[7][5] = 183.636; - th0i[7][6] = 1914.1; - th0i[7][7] = 903.185; - th0i[8][4] = 292.503; - th0i[8][5] = 910.237; - th0i[8][6] = 1919.37; - th0i[8][7] = 0; - th0i[9][4] = 178.67; - th0i[9][5] = 840.538; - th0i[9][6] = 1774.25; - th0i[9][7] = 0; - th0i[10][4] = 182.326; - th0i[10][5] = 859.207; - th0i[10][6] = 1826.59; - th0i[10][7] = 0; - th0i[11][4] = 169.789; - th0i[11][5] = 836.195; - th0i[11][6] = 1760.46; - th0i[11][7] = 0; - th0i[12][4] = 158.922; - th0i[12][5] = 815.064; - th0i[12][6] = 1693.07; - th0i[12][7] = 0; - th0i[13][4] = 156.854; - th0i[13][5] = 814.882; - th0i[13][6] = 1693.79; - th0i[13][7] = 0; - th0i[14][4] = 164.947; - th0i[14][5] = 836.264; - th0i[14][6] = 1750.24; - th0i[14][7] = 0; - th0i[15][4] = 228.734; - th0i[15][5] = 326.843; - th0i[15][6] = 1651.71; - th0i[15][7] = 1671.69; - th0i[16][4] = 2235.71; - th0i[16][5] = 1116.69; - th0i[16][6] = 0; - th0i[16][7] = 0; - th0i[17][4] = 1550.45; - th0i[17][5] = 704.525; - th0i[17][6] = 0; - th0i[17][7] = 0; - th0i[18][4] = 268.795; - th0i[18][5] = 1141.41; - th0i[18][6] = 2507.37; - th0i[18][7] = 0; - th0i[19][4] = 1833.63; - th0i[19][5] = 847.181; - th0i[19][6] = 0; - th0i[19][7] = 0; - th0i[20][4] = 0; - th0i[20][5] = 0; - th0i[20][6] = 0; - th0i[20][7] = 0; - th0i[21][4] = 0; - th0i[21][5] = 0; - th0i[21][6] = 0; - th0i[21][7] = 0; - - // Precalculations of constants - for (int i = 1; i <= MaxFlds; ++i) { - Ki25[i] = Math.pow(Ki[i], 2.5); - Ei25[i] = Math.pow(Ei[i], 2.5); - } - for (int i = 1; i <= MaxFlds; ++i) { - for (int j = i; j <= MaxFlds; ++j) { - for (int n = 1; n <= 18; ++n) { - Bsnij = 1; - if (gn[n] == 1) { - Bsnij = Gij[i][j] * (Gi[i] + Gi[j]) / 2; - } - if (qn[n] == 1) { - Bsnij = Bsnij * Qi[i] * Qi[j]; - } - if (fn[n] == 1) { - Bsnij = Bsnij * Fi[i] * Fi[j]; - } - if (sn[n] == 1) { - Bsnij = Bsnij * Si[i] * Si[j]; - } - if (wn[n] == 1) { - Bsnij = Bsnij * Wi[i] * Wi[j]; - } - Bsnij2[i][j][n] = an[n] * Math.pow(Eij[i][j] * Math.sqrt(Ei[i] * Ei[j]), un[n]) - * Math.pow(Ki[i] * Ki[j], 1.5) * Bsnij; - } - Kij5[i][j] = (Math.pow(Kij[i][j], 5) - 1) * Ki25[i] * Ki25[j]; - Uij5[i][j] = (Math.pow(Uij[i][j], 5) - 1) * Ei25[i] * Ei25[j]; - Gij5[i][j] = (Gij[i][j] - 1) * (Gi[i] + Gi[j]) / 2; - } - } - // Ideal gas terms - d0 = 101.325 / RDetail / 298.15; - for (int i = 1; i <= MaxFlds; ++i) { - n0i[i][3] = n0i[i][3] - 1; - n0i[i][1] = n0i[i][1] - Math.log(d0); + // Coefficients of the equation of state + an[1] = 0.1538326; + an[2] = 1.341953; + an[3] = -2.998583; + an[4] = -0.04831228; + an[5] = 0.3757965; + an[6] = -1.589575; + an[7] = -0.05358847; + an[8] = 0.88659463; + an[9] = -0.71023704; + an[10] = -1.471722; + an[11] = 1.32185035; + an[12] = -0.78665925; + an[13] = 0.00000000229129; + an[14] = 0.1576724; + an[15] = -0.4363864; + an[16] = -0.04408159; + an[17] = -0.003433888; + an[18] = 0.03205905; + an[19] = 0.02487355; + an[20] = 0.07332279; + an[21] = -0.001600573; + an[22] = 0.6424706; + an[23] = -0.4162601; + an[24] = -0.06689957; + an[25] = 0.2791795; + an[26] = -0.6966051; + an[27] = -0.002860589; + an[28] = -0.008098836; + an[29] = 3.150547; + an[30] = 0.007224479; + an[31] = -0.7057529; + an[32] = 0.5349792; + an[33] = -0.07931491; + an[34] = -1.418465; + an[35] = -5.99905E-17; + an[36] = 0.1058402; + an[37] = 0.03431729; + an[38] = -0.007022847; + an[39] = 0.02495587; + an[40] = 0.04296818; + an[41] = 0.7465453; + an[42] = -0.2919613; + an[43] = 7.294616; + an[44] = -9.936757; + an[45] = -0.005399808; + an[46] = -0.2432567; + an[47] = 0.04987016; + an[48] = 0.003733797; + an[49] = 1.874951; + an[50] = 0.002168144; + an[51] = -0.6587164; + an[52] = 0.000205518; + an[53] = 0.009776195; + an[54] = -0.02048708; + an[55] = 0.01557322; + an[56] = 0.006862415; + an[57] = -0.001226752; + an[58] = 0.002850908; + + // Density exponents + bn[1] = 1; + bn[2] = 1; + bn[3] = 1; + bn[4] = 1; + bn[5] = 1; + bn[6] = 1; + bn[7] = 1; + bn[8] = 1; + bn[9] = 1; + bn[10] = 1; + bn[11] = 1; + bn[12] = 1; + bn[13] = 1; + bn[14] = 1; + bn[15] = 1; + bn[16] = 1; + bn[17] = 1; + bn[18] = 1; + bn[19] = 2; + bn[20] = 2; + bn[21] = 2; + bn[22] = 2; + bn[23] = 2; + bn[24] = 2; + bn[25] = 2; + bn[26] = 2; + bn[27] = 2; + bn[28] = 3; + bn[29] = 3; + bn[30] = 3; + bn[31] = 3; + bn[32] = 3; + bn[33] = 3; + bn[34] = 3; + bn[35] = 3; + bn[36] = 3; + bn[37] = 3; + bn[38] = 4; + bn[39] = 4; + bn[40] = 4; + bn[41] = 4; + bn[42] = 4; + bn[43] = 4; + bn[44] = 4; + bn[45] = 5; + bn[46] = 5; + bn[47] = 5; + bn[48] = 5; + bn[49] = 5; + bn[50] = 6; + bn[51] = 6; + bn[52] = 7; + bn[53] = 7; + bn[54] = 8; + bn[55] = 8; + bn[56] = 8; + bn[57] = 9; + bn[58] = 9; + + // Exponents on density in EXP[-cn*D^kn] part + // The cn part in this term is not included in this program since it is 1 when + // kn<>0][and 0 otherwise + kn[13] = 3; + kn[14] = 2; + kn[15] = 2; + kn[16] = 2; + kn[17] = 4; + kn[18] = 4; + kn[21] = 2; + kn[22] = 2; + kn[23] = 2; + kn[24] = 4; + kn[25] = 4; + kn[26] = 4; + kn[27] = 4; + kn[29] = 1; + kn[30] = 1; + kn[31] = 2; + kn[32] = 2; + kn[33] = 3; + kn[34] = 3; + kn[35] = 4; + kn[36] = 4; + kn[37] = 4; + kn[40] = 2; + kn[41] = 2; + kn[42] = 2; + kn[43] = 4; + kn[44] = 4; + kn[46] = 2; + kn[47] = 2; + kn[48] = 4; + kn[49] = 4; + kn[51] = 2; + kn[53] = 2; + kn[54] = 1; + kn[55] = 2; + kn[56] = 2; + kn[57] = 2; + kn[58] = 2; + + // Temperature exponents + un[1] = 0; + un[2] = 0.5; + un[3] = 1; + un[4] = 3.5; + un[5] = -0.5; + un[6] = 4.5; + un[7] = 0.5; + un[8] = 7.5; + un[9] = 9.5; + un[10] = 6; + un[11] = 12; + un[12] = 12.5; + un[13] = -6; + un[14] = 2; + un[15] = 3; + un[16] = 2; + un[17] = 2; + un[18] = 11; + un[19] = -0.5; + un[20] = 0.5; + un[21] = 0; + un[22] = 4; + un[23] = 6; + un[24] = 21; + un[25] = 23; + un[26] = 22; + un[27] = -1; + un[28] = -0.5; + un[29] = 7; + un[30] = -1; + un[31] = 6; + un[32] = 4; + un[33] = 1; + un[34] = 9; + un[35] = -13; + un[36] = 21; + un[37] = 8; + un[38] = -0.5; + un[39] = 0; + un[40] = 2; + un[41] = 7; + un[42] = 9; + un[43] = 22; + un[44] = 23; + un[45] = 1; + un[46] = 9; + un[47] = 3; + un[48] = 8; + un[49] = 23; + un[50] = 1.5; + un[51] = 5; + un[52] = -0.5; + un[53] = 4; + un[54] = 7; + un[55] = 3; + un[56] = 0; + un[57] = 1; + un[58] = 0; + + // Flags + fn[13] = 1; + fn[27] = 1; + fn[30] = 1; + fn[35] = 1; + gn[5] = 1; + gn[6] = 1; + gn[25] = 1; + gn[29] = 1; + gn[32] = 1; + gn[33] = 1; + gn[34] = 1; + gn[51] = 1; + gn[54] = 1; + gn[56] = 1; + qn[7] = 1; + qn[16] = 1; + qn[26] = 1; + qn[28] = 1; + qn[37] = 1; + qn[42] = 1; + qn[47] = 1; + qn[49] = 1; + qn[52] = 1; + qn[58] = 1; + sn[8] = 1; + sn[9] = 1; + wn[10] = 1; + wn[11] = 1; + wn[12] = 1; + + // Energy parameters + Ei[1] = 151.3183; + Ei[2] = 99.73778; + Ei[3] = 241.9606; + Ei[4] = 244.1667; + Ei[5] = 298.1183; + Ei[6] = 324.0689; + Ei[7] = 337.6389; + Ei[8] = 365.5999; + Ei[9] = 370.6823; + Ei[10] = 402.636293; + Ei[11] = 427.72263; + Ei[12] = 450.325022; + Ei[13] = 470.840891; + Ei[14] = 489.558373; + Ei[15] = 26.95794; + Ei[16] = 122.7667; + Ei[17] = 105.5348; + Ei[18] = 514.0156; + Ei[19] = 296.355; + Ei[20] = 2.610111; + Ei[21] = 119.6299; + + // Size parameters + Ki[1] = 0.4619255; + Ki[2] = 0.4479153; + Ki[3] = 0.4557489; + Ki[4] = 0.5279209; + Ki[5] = 0.583749; + Ki[6] = 0.6406937; + Ki[7] = 0.6341423; + Ki[8] = 0.6738577; + Ki[9] = 0.6798307; + Ki[10] = 0.7175118; + Ki[11] = 0.7525189; + Ki[12] = 0.784955; + Ki[13] = 0.8152731; + Ki[14] = 0.8437826; + Ki[15] = 0.3514916; + Ki[16] = 0.4186954; + Ki[17] = 0.4533894; + Ki[18] = 0.3825868; + Ki[19] = 0.4618263; + Ki[20] = 0.3589888; + Ki[21] = 0.4216551; + + // Orientation parameters + Gi[2] = 0.027815; + Gi[3] = 0.189065; + Gi[4] = 0.0793; + Gi[5] = 0.141239; + Gi[6] = 0.256692; + Gi[7] = 0.281835; + Gi[8] = 0.332267; + Gi[9] = 0.366911; + Gi[10] = 0.289731; + Gi[11] = 0.337542; + Gi[12] = 0.383381; + Gi[13] = 0.427354; + Gi[14] = 0.469659; + Gi[15] = 0.034369; + Gi[16] = 0.021; + Gi[17] = 0.038953; + Gi[18] = 0.3325; + Gi[19] = 0.0885; + + // Quadrupole parameters + Qi[3] = 0.69; + Qi[18] = 1.06775; + Qi[19] = 0.633276; + Fi[15] = 1; // High temperature parameter + Si[18] = 1.5822; // Dipole parameter + Si[19] = 0.39; // Dipole parameter + Wi[18] = 1; // Association parameter + + // Energy parameters + Eij[1][2] = 0.97164; + Eij[1][3] = 0.960644; + Eij[1][5] = 0.994635; + Eij[1][6] = 1.01953; + Eij[1][7] = 0.989844; + Eij[1][8] = 1.00235; + Eij[1][9] = 0.999268; + Eij[1][10] = 1.107274; + Eij[1][11] = 0.88088; + Eij[1][12] = 0.880973; + Eij[1][13] = 0.881067; + Eij[1][14] = 0.881161; + Eij[1][15] = 1.17052; + Eij[1][17] = 0.990126; + Eij[1][18] = 0.708218; + Eij[1][19] = 0.931484; + Eij[2][3] = 1.02274; + Eij[2][4] = 0.97012; + Eij[2][5] = 0.945939; + Eij[2][6] = 0.946914; + Eij[2][7] = 0.973384; + Eij[2][8] = 0.95934; + Eij[2][9] = 0.94552; + Eij[2][15] = 1.08632; + Eij[2][16] = 1.021; + Eij[2][17] = 1.00571; + Eij[2][18] = 0.746954; + Eij[2][19] = 0.902271; + Eij[3][4] = 0.925053; + Eij[3][5] = 0.960237; + Eij[3][6] = 0.906849; + Eij[3][7] = 0.897362; + Eij[3][8] = 0.726255; + Eij[3][9] = 0.859764; + Eij[3][10] = 0.855134; + Eij[3][11] = 0.831229; + Eij[3][12] = 0.80831; + Eij[3][13] = 0.786323; + Eij[3][14] = 0.765171; + Eij[3][15] = 1.28179; + Eij[3][17] = 1.5; + Eij[3][18] = 0.849408; + Eij[3][19] = 0.955052; + Eij[4][5] = 1.02256; + Eij[4][7] = 1.01306; + Eij[4][9] = 1.00532; + Eij[4][15] = 1.16446; + Eij[4][18] = 0.693168; + Eij[4][19] = 0.946871; + Eij[5][7] = 1.0049; + Eij[5][15] = 1.034787; + Eij[6][15] = 1.3; + Eij[7][15] = 1.3; + Eij[10][19] = 1.008692; + Eij[11][19] = 1.010126; + Eij[12][19] = 1.011501; + Eij[13][19] = 1.012821; + Eij[14][19] = 1.014089; + Eij[15][17] = 1.1; + + // Conformal energy parameters + Uij[1][2] = 0.886106; + Uij[1][3] = 0.963827; + Uij[1][5] = 0.990877; + Uij[1][7] = 0.992291; + Uij[1][9] = 1.00367; + Uij[1][10] = 1.302576; + Uij[1][11] = 1.191904; + Uij[1][12] = 1.205769; + Uij[1][13] = 1.219634; + Uij[1][14] = 1.233498; + Uij[1][15] = 1.15639; + Uij[1][19] = 0.736833; + Uij[2][3] = 0.835058; + Uij[2][4] = 0.816431; + Uij[2][5] = 0.915502; + Uij[2][7] = 0.993556; + Uij[2][15] = 0.408838; + Uij[2][19] = 0.993476; + Uij[3][4] = 0.96987; + Uij[3][10] = 1.066638; + Uij[3][11] = 1.077634; + Uij[3][12] = 1.088178; + Uij[3][13] = 1.098291; + Uij[3][14] = 1.108021; + Uij[3][17] = 0.9; + Uij[3][19] = 1.04529; + Uij[4][5] = 1.065173; + Uij[4][6] = 1.25; + Uij[4][7] = 1.25; + Uij[4][8] = 1.25; + Uij[4][9] = 1.25; + Uij[4][15] = 1.61666; + Uij[4][19] = 0.971926; + Uij[10][19] = 1.028973; + Uij[11][19] = 1.033754; + Uij[12][19] = 1.038338; + Uij[13][19] = 1.042735; + Uij[14][19] = 1.046966; + + // Size parameters + Kij[1][2] = 1.00363; + Kij[1][3] = 0.995933; + Kij[1][5] = 1.007619; + Kij[1][7] = 0.997596; + Kij[1][9] = 1.002529; + Kij[1][10] = 0.982962; + Kij[1][11] = 0.983565; + Kij[1][12] = 0.982707; + Kij[1][13] = 0.981849; + Kij[1][14] = 0.980991; + Kij[1][15] = 1.02326; + Kij[1][19] = 1.00008; + Kij[2][3] = 0.982361; + Kij[2][4] = 1.00796; + Kij[2][15] = 1.03227; + Kij[2][19] = 0.942596; + Kij[3][4] = 1.00851; + Kij[3][10] = 0.910183; + Kij[3][11] = 0.895362; + Kij[3][12] = 0.881152; + Kij[3][13] = 0.86752; + Kij[3][14] = 0.854406; + Kij[3][19] = 1.00779; + Kij[4][5] = 0.986893; + Kij[4][15] = 1.02034; + Kij[4][19] = 0.999969; + Kij[10][19] = 0.96813; + Kij[11][19] = 0.96287; + Kij[12][19] = 0.957828; + Kij[13][19] = 0.952441; + Kij[14][19] = 0.948338; + + // Orientation parameters + Gij[1][3] = 0.807653; + Gij[1][15] = 1.95731; + Gij[2][3] = 0.982746; + Gij[3][4] = 0.370296; + Gij[3][18] = 1.67309; + + // Ideal gas parameters + n0i[1][3] = 4.00088; + n0i[1][4] = 0.76315; + n0i[1][5] = 0.0046; + n0i[1][6] = 8.74432; + n0i[1][7] = -4.46921; + n0i[1][1] = 29.83843397; + n0i[1][2] = -15999.69151; + n0i[2][3] = 3.50031; + n0i[2][4] = 0.13732; + n0i[2][5] = -0.1466; + n0i[2][6] = 0.90066; + n0i[2][7] = 0; + n0i[2][1] = 17.56770785; + n0i[2][2] = -2801.729072; + n0i[3][3] = 3.50002; + n0i[3][4] = 2.04452; + n0i[3][5] = -1.06044; + n0i[3][6] = 2.03366; + n0i[3][7] = 0.01393; + n0i[3][1] = 20.65844696; + n0i[3][2] = -4902.171516; + n0i[4][3] = 4.00263; + n0i[4][4] = 4.33939; + n0i[4][5] = 1.23722; + n0i[4][6] = 13.1974; + n0i[4][7] = -6.01989; + n0i[4][1] = 36.73005938; + n0i[4][2] = -23639.65301; + n0i[5][3] = 4.02939; + n0i[5][4] = 6.60569; + n0i[5][5] = 3.197; + n0i[5][6] = 19.1921; + n0i[5][7] = -8.37267; + n0i[5][1] = 44.70909619; + n0i[5][2] = -31236.63551; + n0i[6][3] = 4.06714; + n0i[6][4] = 8.97575; + n0i[6][5] = 5.25156; + n0i[6][6] = 25.1423; + n0i[6][7] = 16.1388; + n0i[6][1] = 34.30180349; + n0i[6][2] = -38525.50276; + n0i[7][3] = 4.33944; + n0i[7][4] = 9.44893; + n0i[7][5] = 6.89406; + n0i[7][6] = 24.4618; + n0i[7][7] = 14.7824; + n0i[7][1] = 36.53237783; + n0i[7][2] = -38957.80933; + n0i[8][3] = 4; + n0i[8][4] = 11.7618; + n0i[8][5] = 20.1101; + n0i[8][6] = 33.1688; + n0i[8][7] = 0; + n0i[8][1] = 43.17218626; + n0i[8][2] = -51198.30946; + n0i[9][3] = 4; + n0i[9][4] = 8.95043; + n0i[9][5] = 21.836; + n0i[9][6] = 33.4032; + n0i[9][7] = 0; + n0i[9][1] = 42.67837089; + n0i[9][2] = -45215.83; + n0i[10][3] = 4; + n0i[10][4] = 11.6977; + n0i[10][5] = 26.8142; + n0i[10][6] = 38.6164; + n0i[10][7] = 0; + n0i[10][1] = 46.99717188; + n0i[10][2] = -52746.83318; + n0i[11][3] = 4; + n0i[11][4] = 13.7266; + n0i[11][5] = 30.4707; + n0i[11][6] = 43.5561; + n0i[11][7] = 0; + n0i[11][1] = 52.07631631; + n0i[11][2] = -57104.81056; + n0i[12][3] = 4; + n0i[12][4] = 15.6865; + n0i[12][5] = 33.8029; + n0i[12][6] = 48.1731; + n0i[12][7] = 0; + n0i[12][1] = 57.25830934; + n0i[12][2] = -60546.76385; + n0i[13][3] = 4; + n0i[13][4] = 18.0241; + n0i[13][5] = 38.1235; + n0i[13][6] = 53.3415; + n0i[13][7] = 0; + n0i[13][1] = 62.09646901; + n0i[13][2] = -66600.12837; + n0i[14][3] = 4; + n0i[14][4] = 21.0069; + n0i[14][5] = 43.4931; + n0i[14][6] = 58.3657; + n0i[14][7] = 0; + n0i[14][1] = 65.93909154; + n0i[14][2] = -74131.45483; + n0i[15][3] = 2.47906; + n0i[15][4] = 0.95806; + n0i[15][5] = 0.45444; + n0i[15][6] = 1.56039; + n0i[15][7] = -1.3756; + n0i[15][1] = 13.07520288; + n0i[15][2] = -5836.943696; + n0i[16][3] = 3.50146; + n0i[16][4] = 1.07558; + n0i[16][5] = 1.01334; + n0i[16][6] = 0; + n0i[16][7] = 0; + n0i[16][1] = 16.8017173; + n0i[16][2] = -2318.32269; + n0i[17][3] = 3.50055; + n0i[17][4] = 1.02865; + n0i[17][5] = 0.00493; + n0i[17][6] = 0; + n0i[17][7] = 0; + n0i[17][1] = 17.45786899; + n0i[17][2] = -2635.244116; + n0i[18][3] = 4.00392; + n0i[18][4] = 0.01059; + n0i[18][5] = 0.98763; + n0i[18][6] = 3.06904; + n0i[18][7] = 0; + n0i[18][1] = 21.57882705; + n0i[18][2] = -7766.733078; + n0i[19][3] = 4; + n0i[19][4] = 3.11942; + n0i[19][5] = 1.00243; + n0i[19][6] = 0; + n0i[19][7] = 0; + n0i[19][1] = 21.5830944; + n0i[19][2] = -6069.035869; + n0i[20][3] = 2.5; + n0i[20][4] = 0; + n0i[20][5] = 0; + n0i[20][6] = 0; + n0i[20][7] = 0; + n0i[20][1] = 10.04639507; + n0i[20][2] = -745.375; + n0i[21][3] = 2.5; + n0i[21][4] = 0; + n0i[21][5] = 0; + n0i[21][6] = 0; + n0i[21][7] = 0; + n0i[21][1] = 10.04639507; + n0i[21][2] = -745.375; + th0i[1][4] = 820.659; + th0i[1][5] = 178.41; + th0i[1][6] = 1062.82; + th0i[1][7] = 1090.53; + th0i[2][4] = 662.738; + th0i[2][5] = 680.562; + th0i[2][6] = 1740.06; + th0i[2][7] = 0; + th0i[3][4] = 919.306; + th0i[3][5] = 865.07; + th0i[3][6] = 483.553; + th0i[3][7] = 341.109; + th0i[4][4] = 559.314; + th0i[4][5] = 223.284; + th0i[4][6] = 1031.38; + th0i[4][7] = 1071.29; + th0i[5][4] = 479.856; + th0i[5][5] = 200.893; + th0i[5][6] = 955.312; + th0i[5][7] = 1027.29; + th0i[6][4] = 438.27; + th0i[6][5] = 198.018; + th0i[6][6] = 1905.02; + th0i[6][7] = 893.765; + th0i[7][4] = 468.27; + th0i[7][5] = 183.636; + th0i[7][6] = 1914.1; + th0i[7][7] = 903.185; + th0i[8][4] = 292.503; + th0i[8][5] = 910.237; + th0i[8][6] = 1919.37; + th0i[8][7] = 0; + th0i[9][4] = 178.67; + th0i[9][5] = 840.538; + th0i[9][6] = 1774.25; + th0i[9][7] = 0; + th0i[10][4] = 182.326; + th0i[10][5] = 859.207; + th0i[10][6] = 1826.59; + th0i[10][7] = 0; + th0i[11][4] = 169.789; + th0i[11][5] = 836.195; + th0i[11][6] = 1760.46; + th0i[11][7] = 0; + th0i[12][4] = 158.922; + th0i[12][5] = 815.064; + th0i[12][6] = 1693.07; + th0i[12][7] = 0; + th0i[13][4] = 156.854; + th0i[13][5] = 814.882; + th0i[13][6] = 1693.79; + th0i[13][7] = 0; + th0i[14][4] = 164.947; + th0i[14][5] = 836.264; + th0i[14][6] = 1750.24; + th0i[14][7] = 0; + th0i[15][4] = 228.734; + th0i[15][5] = 326.843; + th0i[15][6] = 1651.71; + th0i[15][7] = 1671.69; + th0i[16][4] = 2235.71; + th0i[16][5] = 1116.69; + th0i[16][6] = 0; + th0i[16][7] = 0; + th0i[17][4] = 1550.45; + th0i[17][5] = 704.525; + th0i[17][6] = 0; + th0i[17][7] = 0; + th0i[18][4] = 268.795; + th0i[18][5] = 1141.41; + th0i[18][6] = 2507.37; + th0i[18][7] = 0; + th0i[19][4] = 1833.63; + th0i[19][5] = 847.181; + th0i[19][6] = 0; + th0i[19][7] = 0; + th0i[20][4] = 0; + th0i[20][5] = 0; + th0i[20][6] = 0; + th0i[20][7] = 0; + th0i[21][4] = 0; + th0i[21][5] = 0; + th0i[21][6] = 0; + th0i[21][7] = 0; + + // Precalculations of constants + for (int i = 1; i <= MaxFlds; ++i) { + Ki25[i] = Math.pow(Ki[i], 2.5); + Ei25[i] = Math.pow(Ei[i], 2.5); + } + for (int i = 1; i <= MaxFlds; ++i) { + for (int j = i; j <= MaxFlds; ++j) { + for (int n = 1; n <= 18; ++n) { + Bsnij = 1; + if (gn[n] == 1) { + Bsnij = Gij[i][j] * (Gi[i] + Gi[j]) / 2; + } + if (qn[n] == 1) { + Bsnij = Bsnij * Qi[i] * Qi[j]; + } + if (fn[n] == 1) { + Bsnij = Bsnij * Fi[i] * Fi[j]; + } + if (sn[n] == 1) { + Bsnij = Bsnij * Si[i] * Si[j]; + } + if (wn[n] == 1) { + Bsnij = Bsnij * Wi[i] * Wi[j]; + } + Bsnij2[i][j][n] = an[n] * Math.pow(Eij[i][j] * Math.sqrt(Ei[i] * Ei[j]), un[n]) + * Math.pow(Ki[i] * Ki[j], 1.5) * Bsnij; } - return; - - // Code to produce nearly exact values for n0[1] and n0[2] - // This is not called in the current code, but included below to show how the - // values were calculated. The return above can be removed to call this code. - // T0 = 298.15; - // d0 = 101.325 / RDetail / T0; - // for (int i=1; i <= MaxFlds; ++i){ - // n1 = 0; n2 = 0; - // if (th0i[i][4] > 0) {n2 = n2 - n0i[i][4] * th0i[i][4] / tanh(th0i[i][4] / - // T0); n1 = n1 - n0i[i][4] * log(sinh(th0i[i][4] / T0));} - // if (th0i[i][5] > 0) {n2 = n2 + n0i[i][5] * th0i[i][5] * tanh(th0i[i][5] / - // T0); n1 = n1 + n0i[i][5] * log(cosh(th0i[i][5] / T0));} - // if (th0i[i][6] > 0) {n2 = n2 - n0i[i][6] * th0i[i][6] / tanh(th0i[i][6] / - // T0); n1 = n1 - n0i[i][6] * log(sinh(th0i[i][6] / T0));} - // if (th0i[i][7] > 0) {n2 = n2 + n0i[i][7] * th0i[i][7] * tanh(th0i[i][7] / - // T0); n1 = n1 + n0i[i][7] * log(cosh(th0i[i][7] / T0));} - // n0i[i][2] = n2 - n0i[i][3] * T0; - // n0i[i][3] = n0i[i][3] - 1; - // n0i[i][1] = n1 - n2 / T0 + n0i[i][3] * (1 + log(T0)) - log(d0); - // } + Kij5[i][j] = (Math.pow(Kij[i][j], 5) - 1) * Ki25[i] * Ki25[j]; + Uij5[i][j] = (Math.pow(Uij[i][j], 5) - 1) * Ei25[i] * Ei25[j]; + Gij5[i][j] = (Gij[i][j] - 1) * (Gi[i] + Gi[j]) / 2; + } } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - @SuppressWarnings("unused") - public static void main(String[] args) { - DETAIL test = new DETAIL(); - test.SetupDetail(); - - double T = 400; - doubleW D = new doubleW(0.0); - doubleW P = new doubleW(50000.0d); - intW ierr = new intW(0); - doubleW Mm = new doubleW(0.0d); - doubleW Z = new doubleW(0.0d); - int iFlag = 0; - StringW herr = new StringW(""); - - double x[] = {0.0, 0.77824, 0.02, 0.06, 0.08, 0.03, 0.0015, 0.003, 0.0005, 0.00165, 0.00215, - 0.00088, 0.00024, 0.00015, 0.00009, 0.004, 0.005, 0.002, 0.0001, 0.0025, 0.007, - 0.001}; - - test.MolarMassDetail(x, Mm); - - System.out.println("mol mass " + Mm.val); - - test.DensityDetail(T, P.val, x, D, ierr, herr); - System.out.println("density " + D.val); - test.PressureDetail(T, D.val, x, P, Z); - System.out.println("pressure " + P.val); - System.out.println("Z " + Z.val); - - doubleW dPdD = new doubleW(0.0d), d2PdD2 = new doubleW(0.0d), d2PdTD = new doubleW(0.0d), - dPdT = new doubleW(0.0d), U = new doubleW(0.0d), H = new doubleW(0.0d), - S = new doubleW(0.0d), A = new doubleW(0.0d), P2 = new doubleW(0.0d); - doubleW Cv = new doubleW(0.0d), Cp = new doubleW(0.0d), W = new doubleW(0.0d), - G = new doubleW(0.0d), JT = new doubleW(0.0d), Kappa = new doubleW(0.0d), - PP = new doubleW(0.0d); - - test.PropertiesDetail(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, - G, JT, Kappa); - - System.out.println("JT " + JT.val); - System.out.println("Kappa " + Kappa.val); + // Ideal gas terms + d0 = 101.325 / RDetail / 298.15; + for (int i = 1; i <= MaxFlds; ++i) { + n0i[i][3] = n0i[i][3] - 1; + n0i[i][1] = n0i[i][1] - Math.log(d0); } + + // Code to produce nearly exact values for n0[1] and n0[2] + // This is not called in the current code, but included below to show how the + // values were calculated. The return above can be removed to call this code. + // T0 = 298.15; + // d0 = 101.325 / RDetail / T0; + // for (int i=1; i <= MaxFlds; ++i){ + // n1 = 0; n2 = 0; + // if (th0i[i][4] > 0) {n2 = n2 - n0i[i][4] * th0i[i][4] / tanh(th0i[i][4] / + // T0); n1 = n1 - n0i[i][4] * log(sinh(th0i[i][4] / T0));} + // if (th0i[i][5] > 0) {n2 = n2 + n0i[i][5] * th0i[i][5] * tanh(th0i[i][5] / + // T0); n1 = n1 + n0i[i][5] * log(cosh(th0i[i][5] / T0));} + // if (th0i[i][6] > 0) {n2 = n2 - n0i[i][6] * th0i[i][6] / tanh(th0i[i][6] / + // T0); n1 = n1 - n0i[i][6] * log(sinh(th0i[i][6] / T0));} + // if (th0i[i][7] > 0) {n2 = n2 + n0i[i][7] * th0i[i][7] * tanh(th0i[i][7] / + // T0); n1 = n1 + n0i[i][7] * log(cosh(th0i[i][7] / T0));} + // n0i[i][2] = n2 - n0i[i][3] * T0; + // n0i[i][3] = n0i[i][3] - 1; + // n0i[i][1] = n1 - n2 / T0 + n0i[i][3] * (1 + log(T0)) - log(d0); + // } + } + + /** + *

+ * main. + *

+ * + * @param args an array of {@link java.lang.String} objects + */ + @SuppressWarnings("unused") + public static void main(String[] args) { + DETAIL test = new DETAIL(); + test.SetupDetail(); + + double T = 400; + doubleW D = new doubleW(0.0); + doubleW P = new doubleW(50000.0d); + intW ierr = new intW(0); + doubleW Mm = new doubleW(0.0d); + doubleW Z = new doubleW(0.0d); + int iFlag = 0; + StringW herr = new StringW(""); + + double x[] = {0.0, 0.77824, 0.02, 0.06, 0.08, 0.03, 0.0015, 0.003, 0.0005, 0.00165, 0.00215, + 0.00088, 0.00024, 0.00015, 0.00009, 0.004, 0.005, 0.002, 0.0001, 0.0025, 0.007, 0.001}; + + test.MolarMassDetail(x, Mm); + + System.out.println("mol mass " + Mm.val); + + test.DensityDetail(T, P.val, x, D, ierr, herr); + System.out.println("density " + D.val); + test.PressureDetail(T, D.val, x, P, Z); + System.out.println("pressure " + P.val); + System.out.println("Z " + Z.val); + + doubleW dPdD = new doubleW(0.0d), d2PdD2 = new doubleW(0.0d), d2PdTD = new doubleW(0.0d), + dPdT = new doubleW(0.0d), U = new doubleW(0.0d), H = new doubleW(0.0d), + S = new doubleW(0.0d), A = new doubleW(0.0d), P2 = new doubleW(0.0d); + doubleW Cv = new doubleW(0.0d), Cp = new doubleW(0.0d), W = new doubleW(0.0d), + G = new doubleW(0.0d), JT = new doubleW(0.0d), Kappa = new doubleW(0.0d), + PP = new doubleW(0.0d); + + test.PropertiesDetail(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, + Kappa); + + System.out.println("JT " + JT.val); + System.out.println("Kappa " + Kappa.val); + } } diff --git a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java index 88f45f3f53..2422c71b86 100644 --- a/src/main/java/neqsim/thermo/util/GERG/GERG2008.java +++ b/src/main/java/neqsim/thermo/util/GERG/GERG2008.java @@ -14,67 +14,67 @@ */ public class GERG2008 { // Variables containing the common parameters in the GERG-2008 equations - double RGERG; - int NcGERG = 21; - int MaxFlds = 21; - int MaxMdl = 10; - int MaxTrmM = 12; - int MaxTrmP = 24; - double epsilon = 1e-15; - int[][] intcoik = new int[MaxFlds + 1][MaxTrmP + 1]; - int[][] coik = new int[MaxFlds + 1][MaxTrmP + 1]; - int[][] doik = new int[MaxFlds + 1][MaxTrmP + 1]; - int[][] dijk = new int[MaxMdl + 1][MaxTrmM + 1]; - - double Drold; - double Trold; - double Told; - double Trold2; - double[] xold = new double[MaxFlds + 1]; - int[][] mNumb = new int[MaxFlds + 1][MaxFlds + 1]; - int[] kpol = new int[MaxFlds + 1]; - int[] kexp = new int[MaxFlds + 1]; - int[] kpolij = new int[MaxMdl + 1]; - int[] kexpij = new int[MaxMdl + 1]; - - double[] Dc = new double[MaxFlds + 1]; - double[] Tc = new double[MaxFlds + 1]; - double[] MMiGERG = new double[MaxFlds + 1]; - double[] Vc3 = new double[MaxFlds + 1]; - double[] Tc2 = new double[MaxFlds + 1]; - - double[][] noik = new double[MaxFlds + 1][MaxTrmP + 1]; - double[][] toik = new double[MaxFlds + 1][MaxTrmP + 1]; - - double[][] cijk = new double[MaxMdl + 1][MaxTrmM + 1]; - - double[][] eijk = new double[MaxMdl + 1][MaxTrmM + 1]; - double[][] gijk = new double[MaxMdl + 1][MaxTrmM + 1]; - double[][] nijk = new double[MaxMdl + 1][MaxTrmM + 1]; - double[][] tijk = new double[MaxMdl + 1][MaxTrmM + 1]; - - double[][] btij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] bvij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] gtij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] gvij = new double[MaxFlds + 1][MaxFlds + 1]; - - double[][] fij = new double[MaxFlds + 1][MaxFlds + 1]; - double[][] th0i = new double[MaxFlds + 1][7 + 1]; - double[][] n0i = new double[MaxFlds + 1][7 + 1]; - - double[][] taup = new double[MaxFlds + 1][MaxTrmP + 1]; - double[][] taupijk = new double[MaxFlds + 1][MaxTrmM + 1]; - double dPdDsave; + double RGERG; + int NcGERG = 21; + int MaxFlds = 21; + int MaxMdl = 10; + int MaxTrmM = 12; + int MaxTrmP = 24; + double epsilon = 1e-15; + int[][] intcoik = new int[MaxFlds + 1][MaxTrmP + 1]; + int[][] coik = new int[MaxFlds + 1][MaxTrmP + 1]; + int[][] doik = new int[MaxFlds + 1][MaxTrmP + 1]; + int[][] dijk = new int[MaxMdl + 1][MaxTrmM + 1]; + + double Drold; + double Trold; + double Told; + double Trold2; + double[] xold = new double[MaxFlds + 1]; + int[][] mNumb = new int[MaxFlds + 1][MaxFlds + 1]; + int[] kpol = new int[MaxFlds + 1]; + int[] kexp = new int[MaxFlds + 1]; + int[] kpolij = new int[MaxMdl + 1]; + int[] kexpij = new int[MaxMdl + 1]; + + double[] Dc = new double[MaxFlds + 1]; + double[] Tc = new double[MaxFlds + 1]; + double[] MMiGERG = new double[MaxFlds + 1]; + double[] Vc3 = new double[MaxFlds + 1]; + double[] Tc2 = new double[MaxFlds + 1]; + + double[][] noik = new double[MaxFlds + 1][MaxTrmP + 1]; + double[][] toik = new double[MaxFlds + 1][MaxTrmP + 1]; + + double[][] cijk = new double[MaxMdl + 1][MaxTrmM + 1]; + + double[][] eijk = new double[MaxMdl + 1][MaxTrmM + 1]; + double[][] gijk = new double[MaxMdl + 1][MaxTrmM + 1]; + double[][] nijk = new double[MaxMdl + 1][MaxTrmM + 1]; + double[][] tijk = new double[MaxMdl + 1][MaxTrmM + 1]; + + double[][] btij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] bvij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] gtij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] gvij = new double[MaxFlds + 1][MaxFlds + 1]; + + double[][] fij = new double[MaxFlds + 1][MaxFlds + 1]; + double[][] th0i = new double[MaxFlds + 1][7 + 1]; + double[][] n0i = new double[MaxFlds + 1][7 + 1]; + + double[][] taup = new double[MaxFlds + 1][MaxTrmP + 1]; + double[][] taupijk = new double[MaxFlds + 1][MaxTrmM + 1]; + double dPdDsave; /** *

* MolarMassGERG. *

* - * @param x an array of {@link double} objects + * @param x an array of type double * @param Mm a {@link org.netlib.util.doubleW} object */ - public void MolarMassGERG(double[] x, doubleW Mm) { + public void MolarMassGERG(double[] x, doubleW Mm) { // Sub MolarMassGERG(x, Mm) // Calculate molar mass of the mixture with the compositions contained in the @@ -103,11 +103,11 @@ public void MolarMassGERG(double[] x, doubleW Mm) { * * @param T a double * @param D a double - * @param x an array of {@link double} objects + * @param x an array of type double * @param P a {@link org.netlib.util.doubleW} object * @param Z a {@link org.netlib.util.doubleW} object */ - public void PressureGERG(double T, double D, double[] x, doubleW P, doubleW Z) { + public void PressureGERG(double T, double D, double[] x, doubleW P, doubleW Z) { // Sub PressureGERG(T, D, x, P, Z) // Calculate pressure as a function of temperature and density. The derivative @@ -151,12 +151,12 @@ public void PressureGERG(double T, double D, double[] x, doubleW P, doubleW Z) * @param iFlag a int * @param T a double * @param P a double - * @param x an array of {@link double} objects + * @param x an array of type double * @param D a {@link org.netlib.util.doubleW} object * @param ierr a {@link org.netlib.util.intW} object * @param herr a {@link org.netlib.util.StringW} object */ - public void DensityGERG(int iFlag, double T, double P, double[] x, doubleW D, intW ierr, + public void DensityGERG(int iFlag, double T, double P, double[] x, doubleW D, intW ierr, StringW herr) { // Sub DensityGERG(iFlag, T, P, x, D, ierr, herr) @@ -334,7 +334,7 @@ public void DensityGERG(int iFlag, double T, double P, double[] x, doubleW D, i * * @param T a double * @param D a double - * @param x an array of {@link double} objects + * @param x an array of type double * @param P a {@link org.netlib.util.doubleW} object * @param Z a {@link org.netlib.util.doubleW} object * @param dPdD a {@link org.netlib.util.doubleW} object @@ -352,9 +352,9 @@ public void DensityGERG(int iFlag, double T, double P, double[] x, doubleW D, i * @param Kappa a {@link org.netlib.util.doubleW} object * @param A a {@link org.netlib.util.doubleW} object */ - public void PropertiesGERG(double T, double D, double[] x, doubleW P, doubleW Z, - doubleW dPdD, doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, doubleW S, - doubleW Cv, doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa, doubleW A) { + public void PropertiesGERG(double T, double D, double[] x, doubleW P, doubleW Z, doubleW dPdD, + doubleW d2PdD2, doubleW d2PdTD, doubleW dPdT, doubleW U, doubleW H, doubleW S, doubleW Cv, + doubleW Cp, doubleW W, doubleW G, doubleW JT, doubleW Kappa, doubleW A) { // Sub PropertiesGERG(T, D, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, // Cp, W, G, JT, Kappa, A) @@ -456,7 +456,7 @@ public void PropertiesGERG(double T, double D, double[] x, doubleW P, doubleW Z * @param Dr ... */ // The following routines are low-level routines that should not be called outside of this code. - void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { + void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { // Private Sub ReducingParametersGERG(x, Tr, Dr) // Calculate reducing variables. Only need to call this if the composition has @@ -521,7 +521,7 @@ void ReducingParametersGERG(double[] x, doubleW Tr, doubleW Dr) { * @param x ... * @param a0 ... */ - void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { + void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { // Private Sub Alpha0GERG(T, D, x, a0) // Calculate the ideal gas Helmholtz energy and its derivatives with respect to @@ -601,7 +601,7 @@ void Alpha0GERG(double T, double D, double[] x, doubleW[] a0) { * @param x .... * @param ar ... */ - void AlpharGERG(int itau, int idelta, double T, double D, double[] x, doubleW[][] ar) { + void AlpharGERG(int itau, int idelta, double T, double D, double[] x, doubleW[][] ar) { // Private Sub AlpharGERG(itau, idelta, T, D, x, ar) // Calculate dimensionless residual Helmholtz energy and its derivatives with @@ -760,7 +760,7 @@ void AlpharGERG(int itau, int idelta, double T, double D, double[] x, doubleW[][ * @param lntau ... * @param x .... */ - void tTermsGERG(double lntau, double[] x) { + void tTermsGERG(double lntau, double[] x) { // Private Sub tTermsGERG(lntau, x) // Calculate temperature dependent parts of the GERG-2008 equation of state @@ -808,7 +808,7 @@ void tTermsGERG(double lntau, double[] x) { * @param Tcx temperature in Kelvin * @param Dcx density */ - void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { + void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { // PseudoCriticalPointGERG(x, Tcx, Dcx) // Calculate a pseudo critical point as the mole fraction average of the @@ -833,7 +833,7 @@ void PseudoCriticalPointGERG(double[] x, doubleW Tcx, doubleW Dcx) { * SetupGERG. *

*/ - public void SetupGERG() { + public void SetupGERG() { // Initialize all the constants and parameters in the GERG-2008 model. // Some values are modified for calculations that do not depend on T, D, and x in order to // speed up the program. @@ -845,6 +845,7 @@ public void SetupGERG() { double T0; double d0; + // ThermodynamicConstantsInterface.R RGERG = 8.314472; Rs = 8.31451; Rsr = Rs / RGERG; @@ -3195,7 +3196,6 @@ public void SetupGERG() { n0i[i][2] = n0i[i][2] - T0; n0i[i][1] = n0i[i][1] - Math.log(d0); } - return; // Code to produce nearly exact values for n0(1) and n0(2) // This is not called in the current code, but included below to show how the values were @@ -3249,14 +3249,14 @@ public static void main(String[] args) { test.MolarMassGERG(x, Mm); - // System.out.println("mol mass " + Mm.val); + // System.out.println("mol mass " + Mm.val); - test.PressureGERG(T, D.val, x, P, Z); + test.PressureGERG(T, D.val, x, P, Z); - System.out.println("pressure " + P.val); - System.out.println("Z " + Z.val); + System.out.println("pressure " + P.val); + System.out.println("Z " + Z.val); - test.DensityGERG(iFlag, T, P.val, x, D, ierr, herr); + test.DensityGERG(iFlag, T, P.val, x, D, ierr, herr); System.out.println("density " + D.val); doubleW dPdD = new doubleW(0.0d); @@ -3276,20 +3276,20 @@ public static void main(String[] args) { doubleW JT = new doubleW(0.0d); doubleW Kappa = new doubleW(0.0d); doubleW PP = new doubleW(0.0d); - test.PropertiesGERG(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, - JT, Kappa, A); + test.PropertiesGERG(T, D.val, x, P, Z, dPdD, d2PdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, W, G, JT, + Kappa, A); /* * // test.PressureGERG(400, 12.798286, x); String herr = ""; test.DensityGERG(0, T, P, x, ierr, * herr); double pres = test.P; double molarmass = test.Mm; - * + * * // double dPdD=0.0, dPdD2=0.0, d2PdTD=0.0, dPdT=0.0, U=0.0, H=0.0, S=0.0, // Cv=0.0, Cp=0.0, * W=0.0, G=0.0, JT=0.0, Kappa=0.0, A=0.0; - * + * * // void DensityGERG(const int iFlag, const double T, const double P, const // * std::vector &x, double &D, int &ierr, std::string &herr) // test.DensityGERG(0, T, P, * x, ierr, herr); - * + * * // Sub PropertiesGERG(T, D, x, P, Z, dPdD, dPdD2, d2PdTD, dPdT, U, H, S, Cv, Cp, // W, G, JT, * Kappa) // test.PropertiesGERG(T, test.D, x); */ diff --git a/src/main/java/neqsim/thermo/util/GERG/NeqSimAGA8Detail.java b/src/main/java/neqsim/thermo/util/GERG/NeqSimAGA8Detail.java index fb8f4d2223..d880a5f9df 100644 --- a/src/main/java/neqsim/thermo/util/GERG/NeqSimAGA8Detail.java +++ b/src/main/java/neqsim/thermo/util/GERG/NeqSimAGA8Detail.java @@ -122,8 +122,8 @@ public double getMolarDensity() { StringW herr = new StringW(""); doubleW D = new doubleW(0.0); double pressure = phase.getPressure() * 100.0; - DETAIL.DensityDetail(phase.getTemperature(), pressure, - normalizedGERGComposition, D, ierr, herr); + DETAIL.DensityDetail(phase.getTemperature(), pressure, normalizedGERGComposition, D, ierr, + herr); return D.val; } @@ -133,7 +133,7 @@ public double getMolarDensity() { *

* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return an array of {@link double} objects + * @return an array of type double */ public double[] propertiesDetail(PhaseInterface phase) { this.setPhase(phase); @@ -147,7 +147,7 @@ public double[] propertiesDetail(PhaseInterface phase) { * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param properties an array of {@link java.lang.String} objects - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getProperties(PhaseInterface phase, String[] properties) { // double molarDens = getMolarDensity(phase); @@ -178,7 +178,7 @@ public double[] getProperties(PhaseInterface phase, String[] properties) { * propertiesDetail. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] propertiesDetail() { // int _x_offset = 0; @@ -302,7 +302,7 @@ public void setPhase(PhaseInterface phase) { if (molarMass > 121.0 / 1000.0) notNormalizedGERGComposition[14] += phase.getComponent(i).getx(); break; - }; + } } normalizeComposition(); } diff --git a/src/main/java/neqsim/thermo/util/GERG/NeqSimGERG2008.java b/src/main/java/neqsim/thermo/util/GERG/NeqSimGERG2008.java index dbd3fffb19..5066df0bed 100644 --- a/src/main/java/neqsim/thermo/util/GERG/NeqSimGERG2008.java +++ b/src/main/java/neqsim/thermo/util/GERG/NeqSimGERG2008.java @@ -134,7 +134,7 @@ public double getMolarDensity() { *

* * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object - * @return an array of {@link double} objects + * @return an array of type double */ public double[] propertiesGERG(PhaseInterface phase) { this.setPhase(phase); @@ -148,7 +148,7 @@ public double[] propertiesGERG(PhaseInterface phase) { * * @param phase a {@link neqsim.thermo.phase.PhaseInterface} object * @param properties an array of {@link java.lang.String} objects - * @return an array of {@link double} objects + * @return an array of type double */ public double[] getProperties(PhaseInterface phase, String[] properties) { double[] allProperties = propertiesGERG(); @@ -180,7 +180,7 @@ public double[] getProperties(PhaseInterface phase, String[] properties) { * propertiesGERG. *

* - * @return an array of {@link double} objects + * @return an array of type double */ public double[] propertiesGERG() { doubleW p = new doubleW(0.0); @@ -310,7 +310,7 @@ public void setPhase(PhaseInterface phase) { notNormalizedGERGComposition[14] += phase.getComponent(i).getx(); } break; - }; + } } normalizeComposition(); } diff --git a/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java b/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java index ef3c8f93f3..d058b7cf09 100644 --- a/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java +++ b/src/main/java/neqsim/thermo/util/JNI/GERG2004EOS.java @@ -371,7 +371,7 @@ public static native double AOTPX(double c1, double c2, double c3, double c4, do * @param c19 a double * @param c20 a double * @param IPHASE a int - * @return an array of {@link double} objects + * @return an array of type double */ public static native double[] SFUGOTPX(double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, @@ -404,7 +404,7 @@ public static native double[] SFUGOTPX(double c1, double c2, double c3, double c * @param c19 a double * @param c20 a double * @param IPHASE a int - * @return an array of {@link double} objects + * @return an array of type double */ public static native double[] SPHIOTPX(double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, @@ -470,7 +470,7 @@ public static native double CVOTPX(double c1, double c2, double c3, double c4, d * @param c19 a double * @param c20 a double * @param IPHASE a int - * @return an array of {@link double} objects + * @return an array of type double */ public static native double[] SALLOTPX(double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, diff --git a/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark.java b/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark.java index 83f89405b1..f269fdd783 100644 --- a/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark.java +++ b/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark.java @@ -27,7 +27,7 @@ public static void main(String args[]) { // SystemInterface testSystem = new SystemSrkCPAstatoil(303.15, 10.0); // SystemInterface testSystem = new SystemUMRPRUMCEos(303.0, 10.0); // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(298.15, - // 1.01325); + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); testSystem.addComponent("nitrogen", 0.0028941); diff --git a/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark_fullcomp.java b/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark_fullcomp.java index bf6ca88889..a9f32f244a 100644 --- a/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark_fullcomp.java +++ b/src/main/java/neqsim/thermo/util/benchmark/TPflash_benchmark_fullcomp.java @@ -28,7 +28,7 @@ public static void main(String args[]) { SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 - 5.0, 10.0); // SystemInterface testSystem = new SystemSrkSchwartzentruberEos(298.15, - // 1.01325); + // ThermodynamicConstantsInterface.referencePressure); ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); // testSystem.addComponent("CO2", 2.1); diff --git a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java index 5bf1bae416..0a960a4ae9 100644 --- a/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java +++ b/src/main/java/neqsim/thermo/util/constants/FurstElectrolyteConstants.java @@ -14,7 +14,7 @@ * @author esol * @version $Id: $Id */ -public class FurstElectrolyteConstants implements java.io.Serializable { +public final class FurstElectrolyteConstants implements java.io.Serializable { private static final long serialVersionUID = 1000; // public static double[] furstParams = {0.0982e-6, 7.003e-6, 77.22e-6, @@ -50,12 +50,11 @@ public class FurstElectrolyteConstants implements java.io.Serializable { // 0.0000001880, 0.0000014139, 0.0000284666, 0.0000389043, -0.0000000451, // 0.0000088136 + /** - *

- * 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 ACF = new ArrayList(); ArrayList MW = new ArrayList(); ArrayList SSHIFT = new ArrayList(); + ArrayList SSHIFTS = new ArrayList(); ArrayList TBOIL = new ArrayList(); ArrayList VCRIT = new ArrayList(); ArrayList PARACHOR = new ArrayList(); ArrayList ZI = new ArrayList(); ArrayList BIC = new ArrayList(); String EOS; - while ((st = br.readLine()) != null) { // System.out.println("EOS " +EOS ); if (st.trim().equals("EOS")) { EOS = br.readLine().replace("/", ""); if (EOS.contains("SRK")) { - fluid = new neqsim.thermo.system.SystemSrkEos(288.15, 100.01325); + fluid = new neqsim.thermo.system.SystemSrkEos(288.15, + ThermodynamicConstantsInterface.referencePressure); } else if (EOS.contains("PR")) { - fluid = new neqsim.thermo.system.SystemPrEos(288.15, 1.01325); - } else if (EOS.contains("PR78")) { - fluid = new neqsim.thermo.system.SystemPrEos1978(288.15, 1.01325); + String corr = br.readLine().replace("/", ""); + if (corr.equals("PRCORR")) { + fluid = new neqsim.thermo.system.SystemPrEos1978(288.15, + ThermodynamicConstantsInterface.referencePressure); + } else { + fluid = new neqsim.thermo.system.SystemPrEos(288.15, + ThermodynamicConstantsInterface.referencePressure); + } + } else { + fluid = new neqsim.thermo.system.SystemPrEos(288.15, + ThermodynamicConstantsInterface.referencePressure); } } if (st.equals("CNAMES")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } names.add(st); @@ -169,7 +187,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("TCRIT")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } TC.add(Double.parseDouble(st)); @@ -177,7 +195,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("PCRIT")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } PC.add(Double.parseDouble(st)); @@ -185,7 +203,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("ACF")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } ACF.add(Double.parseDouble(st)); @@ -193,7 +211,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("MW")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } MW.add(Double.parseDouble(st)); @@ -201,7 +219,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("TBOIL")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } TBOIL.add(Double.parseDouble(st)); @@ -209,7 +227,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("VCRIT")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } VCRIT.add(Double.parseDouble(st)); @@ -217,7 +235,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("SSHIFT")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } SSHIFT.add(Double.parseDouble(st)); @@ -225,7 +243,7 @@ public static SystemInterface read(String inputFile) { } if (st.equals("PARACHOR")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } PARACHOR.add(Double.parseDouble(st)); @@ -233,51 +251,51 @@ public static SystemInterface read(String inputFile) { } if (st.equals("ZI")) { while ((st = br.readLine().replace("/", "")) != null) { - if (st.startsWith("--")) { + if (st.startsWith("--") || st.isEmpty()) { break; } ZI.add(Double.parseDouble(st)); } } if (st.equals("BIC")) { - int numb = 0; - // kij = new double[ZI.size()][ZI.size()]; + int addedComps = 0; kij = new double[names.size()][names.size()]; - while ((st = br.readLine().replace("/", "")) != null) { - numb++; - if (st.startsWith("--")) { + int lengthLastLine = 0; + List list = new ArrayList(); + while ((st = br.readLine().replace("/", "")) != null && addedComps < names.size() - 1) { + if (st.startsWith("--") || st.isEmpty()) { break; } - - // String[] arr = st.replace(" ","").split(" "); String[] arr = st.split(" "); - if (arr.length == 1) { + List templist = new ArrayList(Arrays.asList(arr)); + list.addAll(templist); + list.removeAll(Arrays.asList("", null)); + if (lengthLastLine >= list.size()) { + continue; + } + lengthLastLine = list.size(); + for (int i = 0; i < list.size(); i++) { + BIC.add(Double.parseDouble(list.get(i))); + kij[i][addedComps + 1] = Double.parseDouble(list.get(i)); + kij[addedComps + 1][i] = kij[i][addedComps + 1]; + } + addedComps++; + list.clear(); + } + } + if (st.equals("SSHIFTS")) { + String line; + while ((line = br.readLine()) != null) { + st = line.replace("/", ""); + if (st.startsWith("--") || st.isEmpty()) { break; } - - // List list = Arrays.asList(arr); - for (int i = 0; i < arr.length - 1; i++) { - BIC.add(Double.parseDouble(arr[i + 1])); - kij[numb][i] = Double.parseDouble(arr[i + 1]); - kij[i][numb] = kij[numb][i]; - // kij[numb-1][i] = Double.parseDouble(arr[i+1]); - // kij[i][numb-1] = kij[numb-1][i] ; + try { + SSHIFTS.add(Double.parseDouble(st)); + } catch (NumberFormatException e) { + System.out.println("Error parsing double value: " + e.getMessage()); } - // numb++; - Double.parseDouble(arr[1]); - // System.out.println(list.size()); - // System.out.println(st); - // BIC.add(Double.parseDouble(st)); } - - /* - * numb =0; - * - * for (int i = 0; i < names.size(); i++) { for (int j = i; j < names.size(); j++) { - * if(i==j) continue; //System.out.println("ij " + i + " " + j+ " " + BIC.get(numb)); - * System.out.println("ij " + i + " " + j+ " " + kij[i][j] ); //kij[i][j] = BIC.get(numb); - * //kij[j][i] = kij[i][j]; numb++; } } - */ } } for (int counter = 0; counter < names.size(); counter++) { @@ -314,11 +332,13 @@ public static SystemInterface read(String inputFile) { fluid.addComponent(name, ZI.get(counter)); } else if (TC.get(counter) >= 00.0) { name = names.get(counter); - fluid.addTBPfraction(name, ZI.get(counter), MW.get(counter) / 1000.0, 0.9); + double stddensity = 0.5046 * MW.get(counter) / 1000.0 + 0.668468; + fluid.addTBPfraction(name, ZI.get(counter), MW.get(counter) / 1000.0, stddensity); name = name + "_PC"; } else { name = names.get(counter); - fluid.addTBPfraction(name, ZI.get(counter), MW.get(counter) / 1000.0, 0.9); + double stddensity = 0.5046 * MW.get(counter) / 1000.0 + 0.668468; + fluid.addTBPfraction(name, ZI.get(counter), MW.get(counter) / 1000.0, stddensity); name = name + "_PC"; // fluid.changeComponentName(name+"_PC", names.get(counter)); } @@ -331,7 +351,12 @@ public static SystemInterface read(String inputFile) { fluid.getPhase(i).getComponent(name).setNormalBoilingPoint(TBOIL.get(counter)); fluid.getPhase(i).getComponent(name).setCriticalVolume(VCRIT.get(counter)); fluid.getPhase(i).getComponent(name).setParachorParameter(PARACHOR.get(counter)); - fluid.getPhase(i).getComponent(name).setVolumeCorrectionConst(SSHIFT.get(counter)); + if (SSHIFTS.size() > 0) { + fluid.getPhase(i).getComponent(name).setVolumeCorrectionConst(SSHIFTS.get(counter)); + } else { + fluid.getPhase(i).getComponent(name).setVolumeCorrectionConst(SSHIFT.get(counter)); + } + fluid.getPhase(i).getComponent(name).setRacketZ(0.29056 - 0.08775 * ACF.get(counter)); } if (fluid.getPhase(0).getComponent(name).isIsTBPfraction()) { fluid.changeComponentName(name, names.get(counter).replaceAll("_PC", "") + pseudoName); diff --git a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java index 590f80893e..84eceb2b7c 100644 --- a/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java +++ b/src/main/java/neqsim/thermo/util/readwrite/TablePrinter.java @@ -4,8 +4,12 @@ /** * A utility class for pretty printing a 2D string table. + * + * @author Even Solbraa */ public class TablePrinter implements Serializable { + private static final long serialVersionUID = 1L; + /** * Prints a 2D string table in a formatted and visually appealing way. * @@ -68,7 +72,7 @@ private static void printHorizontalLine(int[] columnWidths) { /** * Prints a row of the table with appropriate padding based on column widths. * - * @param row The row of data to be printed. + * @param row The row of data to be printed. * @param columnWidths An array containing the maximum width of each column. */ private static void printRow(String[] row, int[] columnWidths) { @@ -84,4 +88,36 @@ private static void printRow(String[] row, int[] columnWidths) { } System.out.println(); } -} \ No newline at end of file + + /** + * Prints a 2D string table in a formatted and visually appealing way. + * + * @param table The 2D double table to be printed. + */ + public static void printTable(double[][] table) { + printTable(convertDoubleToString(table)); + } + + /** + * Returns a 2D string table in a formatted and visually appealing way. + * + * @param doubleArray The 2D double table to be printed. + * @return 2d string table + */ + public static String[][] convertDoubleToString(double[][] doubleArray) { + // Initialize the 2D String array with the same dimensions as the double array + String[][] stringArray = new String[doubleArray.length][]; + + for (int i = 0; i < doubleArray.length; i++) { + // Initialize the inner array with the same length as the corresponding double array + stringArray[i] = new String[doubleArray[i].length]; + + for (int j = 0; j < doubleArray[i].length; j++) { + // Convert each double value to string and store it + stringArray[i][j] = String.valueOf(doubleArray[i][j]); + } + } + + return stringArray; + } +} diff --git a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java index d8572ea4a6..d71e51f175 100644 --- a/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java +++ b/src/main/java/neqsim/thermodynamicOperations/OperationInterface.java @@ -30,7 +30,7 @@ public interface OperationInterface extends Runnable, java.io.Serializable { *

* * @param i a int - * @return an array of {@link double} objects + * @return an array of type double */ public double[][] getPoints(int i); @@ -40,7 +40,7 @@ public interface OperationInterface extends Runnable, java.io.Serializable { *

* * @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); @@ -68,7 +68,7 @@ public interface OperationInterface extends Runnable, java.io.Serializable { *

* * @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); diff --git a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java index 891a95a37a..ad07b72859 100644 --- a/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java +++ b/src/main/java/neqsim/thermodynamicOperations/ThermodynamicOperations.java @@ -2,19 +2,19 @@ import java.awt.BorderLayout; import java.awt.Container; +import java.util.Arrays; import java.util.List; - import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.api.ioc.CalculationResult; import neqsim.thermo.component.ComponentHydrate; +import neqsim.thermo.component.ComponentInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemProperties; +import neqsim.thermodynamicOperations.flashOps.CalcIonicComposition; import neqsim.thermodynamicOperations.flashOps.CriticalPointFlash; import neqsim.thermodynamicOperations.flashOps.PHflash; import neqsim.thermodynamicOperations.flashOps.PHflashSingleComp; @@ -30,7 +30,6 @@ import neqsim.thermodynamicOperations.flashOps.TVflash; import neqsim.thermodynamicOperations.flashOps.VHflashQfunc; import neqsim.thermodynamicOperations.flashOps.VUflashQfunc; -import neqsim.thermodynamicOperations.flashOps.calcIonicComposition; import neqsim.thermodynamicOperations.flashOps.dTPflash; import neqsim.thermodynamicOperations.flashOps.saturationOps.ConstantDutyFlashInterface; import neqsim.thermodynamicOperations.flashOps.saturationOps.HCdewPointPressureFlash; @@ -60,6 +59,7 @@ import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.CricondenThermFlash; import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.HPTphaseEnvelope; import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.pTphaseEnvelope; +import neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.pTphaseEnvelopeNew2; import neqsim.thermodynamicOperations.phaseEnvelopeOps.reactiveCurves.pLoadingCurve2; import neqsim.thermodynamicOperations.propertyGenerator.OLGApropertyTableGeneratorWaterStudents; import neqsim.thermodynamicOperations.propertyGenerator.OLGApropertyTableGeneratorWaterStudentsPH; @@ -146,7 +146,7 @@ public void TPVflash(double volumeSpec, String unit) { public void TPflash() { double flowRate = system.getTotalNumberOfMoles(); double minimumFlowRate = 1e-50; - if (flowRate < 1e-3) { + if (flowRate < 1e-5) { system.setTotalNumberOfMoles(1.0); system.init(1); } @@ -157,13 +157,13 @@ public void TPflash() { } else { run(); } - if (flowRate < 1e-3) { + if (flowRate < 1e-5) { if (flowRate < minimumFlowRate) { system.setTotalNumberOfMoles(minimumFlowRate); } else { system.setTotalNumberOfMoles(flowRate); } - system.init(2); + system.init(1); } } @@ -172,7 +172,7 @@ public void TPflash() { * TPflash. *

* - * @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 TPflash(boolean checkForSolids) { operation = new neqsim.thermodynamicOperations.flashOps.TPflash(system, checkForSolids); @@ -577,6 +577,18 @@ public void TVflash(double Vspec) { getOperation().run(); } + /** + *

+ * 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 Spec1, List Spec2, i String[] calculationError = new String[Spec1.size()]; Double[] sum = new Double[Spec1.size()]; + String[] systemComponents = this.system.getComponentNames(); + if (components != null) { + for (String inputCompName : components) { + if (!this.system.hasComponent(inputCompName)) { + for (int t = 0; t < Spec1.size(); t++) { + calculationError[t] = "Input component list does not match fluid component list."; + } + } + } + } else { + components = Arrays.asList(systemComponents); + } // Verify that sum of fractions equals 1/100, i.e., assume percentages - Boolean hasOnlineFractions = onlineFractions != null; + boolean hasOnlineFractions = onlineFractions != null; + if (hasOnlineFractions) { double range = 5; for (int t = 0; t < sum.length; t++) { @@ -1998,9 +2048,9 @@ public CalculationResult propertyFlash(List Spec1, List Spec2, i } else { /* * // New attempt: - * + * * // Have to init here to get correct MoleFractionsSum() this.system.init(0); - * + * * // Annoying that MoleFractionsSum is not normalized. sum[0] = * this.system.getMoleFractionsSum(); */ @@ -2017,6 +2067,9 @@ public CalculationResult propertyFlash(List Spec1, List Spec2, i for (int t = 0; t < Spec1.size(); t++) { calculationError[t] = "Sum of fractions must be approximately to 1 or 100, currently (" + String.valueOf(sum[0]) + ")"; + if (sum[0] == 0.0) { + calculationError[t] = calculationError[t] + ". Have you called init(0)?"; + } } } } @@ -2044,24 +2097,20 @@ public CalculationResult propertyFlash(List Spec1, List Spec2, i } if (hasOnlineFractions) { - /* - * // New attempt: - * - * this.system.setEmptyFluid(); - * - * // Components in system with no corresponding value in onlineFractions will be zero. - * for (int componentNumber = 0; componentNumber < onlineFractions .size(); - * componentNumber++) { this.system.addComponent(componentNumber, - * onlineFractions.get(componentNumber).get(t).doubleValue()); } - * - * if (this.system.getTotalNumberOfMoles() < 1e-5) { this.system.setTotalNumberOfMoles(1); - * } - */ - - // Remaining fractions will be set to 0.0 + // Assure that fraction is inserted for the correct component (in case of + // mismatch of + // component input and fluid component list) double[] fraction = new double[this.system.getNumberOfComponents()]; - for (int comp = 0; comp < onlineFractions.size(); comp++) { - fraction[comp] = onlineFractions.get(comp).get(t).doubleValue(); + // For all components defined in system + for (int compIndex = 0; compIndex < fraction.length; compIndex++) { + // Loop all input component names / fractions + for (int index = 0; index < components.size(); index++) { + if (systemComponents[compIndex] == ComponentInterface + .getComponentNameFromAlias(components.get(index))) { + fraction[compIndex] = onlineFractions.get(index).get(t).doubleValue(); + break; + } + } } this.system.setMolarComposition(fraction); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/CalcIonicComposition.java similarity index 91% rename from src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java rename to src/main/java/neqsim/thermodynamicOperations/flashOps/CalcIonicComposition.java index 5dea3c0208..5d36cd6522 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/calcIonicComposition.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/CalcIonicComposition.java @@ -1,5 +1,5 @@ /* - * calcIonicComposition.java + * CalcIonicComposition.java * * Created on 8. mars 2001, 10:56 */ @@ -14,28 +14,28 @@ /** *

- * 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. + *

+ * + * @return a {@link java.lang.String} object + */ + public static String getMethod() { + return RachfordRice.method; + } + + /** + *

+ * Setter for the field method. + *

+ * + * @param method a {@link java.lang.String} object + */ + public static void setMethod(String method) { + RachfordRice.method = 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. + *

+ * + * @return an array of type double + */ + public double[] getBeta() { + return 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 clonedSystem = new ArrayList(1); + // if (minimumGibbsEnergySystem == null) { + // minimumGibbsEnergySystem = system.clone(); + // } + minimumGibbsEnergySystem = system; + clonedSystem.add(system.clone()); + /* + * 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 + * (system.getPhase(0).getComponent(j).getz() < 1e-100) { numb = 0; } ( + * clonedSystem.get(i)).getPhase(1).getComponents()[j].setx(numb); } if + * (system.getPhase(0).getComponent(i).getIonicCharge() == 0) { ( clonedSystem.get(i)).init(1); + * } } + */ + + lowestGibbsEnergyPhase = 0; + /* + * // logger.info("low gibbs phase " + lowestGibbsEnergyPhase); 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)) { 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) { ( + * clonedSystem.get(k)).getPhase(1).getComponents()[i].setx(( + * clonedSystem.get(k)).getPhase(1).getComponents()[i].getx() / sumw[0]); } logger.info("x: " + + * ( clonedSystem.get(k)).getPhase(0).getComponents()[i].getx()); } if + * (system.getPhase(0).getComponent(k).getx() > 1e-100) { d[k] = + * Math.log(system.getPhase(0).getComponents()[k].getx()) + + * system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); + * if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents + * ()[k].getIonicCharge()!=0) d[k]=0; } //logger.info("dk: " + d[k]); } + */ + for (int k = 0; k < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); k++) { + if (system.getPhase(0).getComponent(k).getx() > 1e-100) { + d[k] = Math.log(system.getPhase(0).getComponents()[k].getx()) + + system.getPhase(0).getComponents()[k].getLogFugacityCoefficient(); + // if(minimumGibbsEnergySystem.getPhases()[lowestGibbsEnergyPhase].getComponents()[k].getIonicCharge()!=0) + // d[k]=0; + } + } + + for (int j = 0; j < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); j++) { + if (system.getPhase(0).getComponent(j).getz() > 1e-100) { + logWi[j] = 1.0; + } else { + logWi[j] = -10000.0; + } + } + + int hydrocarbonTestCompNumb = 0; + int lightTestCompNumb = 0; + double Mmax = 0; + double Mmin = 1e10; + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon()) { + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) > Mmax) { + Mmax = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); + } + if ((minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) < Mmin) { + Mmin = minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass(); + } + } + } + + for (int i = 0; i < minimumGibbsEnergySystem.getPhase(0).getNumberOfComponents(); i++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmax) < 1e-5) { + hydrocarbonTestCompNumb = i; + // logger.info("CHECKING heavy component " + hydrocarbonTestCompNumb); + } + } + + if (minimumGibbsEnergySystem.getPhase(0).getComponent(i).isHydrocarbon() + && minimumGibbsEnergySystem.getPhase(0).getComponent(i).getz() > 1e-50) { + if (Math.abs( + (minimumGibbsEnergySystem.getPhase(0).getComponent(i).getMolarMass()) - Mmin) < 1e-5) { + lightTestCompNumb = i; + // logger.info("CHECKING light component " + lightTestCompNumb); + } + } + } + + for (int j = 0; j < system.getNumberOfComponents(); j++) { + if (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getx() < 1e-100 + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).getIonicCharge() != 0) + || (minimumGibbsEnergySystem.getPhase(0).getComponent(j).isHydrocarbon() + && j != hydrocarbonTestCompNumb && j != lightTestCompNumb)) { + continue; + } + + double nomb = 0.0; + for (int cc = 0; cc < system.getPhase(0).getNumberOfComponents(); cc++) { + nomb = cc == j ? 1.0 : 1.0e-12; + if (system.getPhase(0).getComponent(cc).getz() < 1e-100) { + nomb = 0.0; + } + + if (clonedSystem.get(0).isPhase(1)) { + try { + clonedSystem.get(0).getPhase(1).getComponents()[cc].setx(nomb); + } catch (Exception ex) { + logger.warn(ex.getMessage()); + } + } + } + // if(minimumGibbsEnergySystem.getPhase(0).getComponent(j).getName().equals("water") + // && minimumGibbsEnergySystem.isChemicalSystem()) continue; + // logger.info("STAB CHECK COMP " + + // system.getPhase(0).getComponent(j).getComponentName()); + // 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 <= maxsucssubiter || !system.isImplementedCompositionDeriativesofFugacity()) { + if (iter % 7 == 0 && useaccsubst) { double vec1 = 0.0; double vec2 = 0.0; @@ -419,6 +773,10 @@ public void stabilityAnalysis() { 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 { @@ -507,7 +865,7 @@ public void stabilityAnalysis() { clonedSystem.get(0).getPhase(1).getComponents()[i].setx(1e-50); } } - } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 600); + } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < maxiter); // logger.info("err: " + err + " ITER " + iter); double xTrivialCheck0 = 0.0; double xTrivialCheck1 = 0.0; @@ -524,7 +882,7 @@ public void stabilityAnalysis() { 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 >= 599) { + if (iter >= maxiter - 1) { // logger.info("iter > maxiter multiphase stability "); // logger.info("error " + Math.abs(err)); // logger.info("tm: " + tm[j]); @@ -709,7 +1067,7 @@ public void stabilityAnalysis2() { iter++; err = 0; - if (iter <= 20 || !system.isImplementedCompositionDeriativesofFugacity()) { + if (iter <= 150 || !system.isImplementedCompositionDeriativesofFugacity()) { if (iter % 7 == 0) { double vec1 = 0.0; @@ -835,6 +1193,11 @@ public void stabilityAnalysis2() { } } } while ((Math.abs(err) > 1e-9 || err > errOld) && iter < 200); + if (iter > 198) { + // System.out.println("too many iterations....." + err + " temperature " + // + system.getTemperature("C") + " C " + system.getPressure("bara") + " bara"); + new Exception("to many iterations "); + } // logger.info("err: " + err + " ITER " + iter); double xTrivialCheck0 = 0.0; double xTrivialCheck1 = 0.0; @@ -922,6 +1285,7 @@ public void run() { double oldDiff = 1.0e10; double chemdev = 0; int iterOut = 0; + double maxerr = 1e-12; do { iterOut++; if (system.isChemicalSystem()) { @@ -963,11 +1327,16 @@ public void run() { // diff = Math.abs((system.getBeta(system.getNumberOfPhases() - 1) - oldBeta) / // oldBeta); // logger.info("diff multiphase " + diff); - } while (diff > 1e-12 && !removePhase && (diff < oldDiff || iterations < 50) + if (iterations % 50 == 0) { + maxerr *= 100.0; + } + } while (diff > maxerr && !removePhase && (diff < oldDiff || iterations < 50) && iterations < 200); // this.solveBeta(true); if (iterations >= 199) { logger.error("error in multiphase flash..did not solve in 200 iterations"); + logger.error("diff " + diff + " temperaure " + system.getTemperature("C") + " pressure " + + system.getPressure("bara")); diff = this.solveBeta(); } } while ((Math.abs(chemdev) > 1e-10 && iterOut < 100) @@ -1011,6 +1380,7 @@ public void run() { */ if (hasRemovedPhase && !secondTime) { secondTime = true; + stabilityAnalysis3(); run(); } /* diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflashWAX.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflashWAX.java index 8b6716c3df..eed4f4d726 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflashWAX.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflashWAX.java @@ -44,7 +44,7 @@ public TPmultiflashWAX(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 TPmultiflashWAX(SystemInterface system, boolean checkForSolids) { super(system, checkForSolids); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java index 70a895bb93..c034293c6f 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TPmultiflash_1.java @@ -48,7 +48,7 @@ public TPmultiflash_1(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_1(SystemInterface system, boolean checkForSolids) { super(system, checkForSolids); diff --git a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java index 60732baa32..92f6847277 100644 --- a/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java +++ b/src/main/java/neqsim/thermodynamicOperations/flashOps/TVflash.java @@ -38,18 +38,17 @@ public TVflash(SystemInterface system, double Vspec) { /** *

- * 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 dewPointTemperature = new ArrayList(); + ArrayList dewPointPressure = new ArrayList(); + ArrayList bubblePointTemperature = new ArrayList(); + ArrayList bubblePointPressure = new ArrayList(); + + ArrayList bubblePointEnthalpy = new ArrayList(); + ArrayList dewPointEnthalpy = new ArrayList(); + + ArrayList bubblePointEntropy = new ArrayList(); + ArrayList dewPointEntropy = new ArrayList(); + + ArrayList bubblePointVolume = new ArrayList(); + ArrayList dewPointVolume = new ArrayList(); + + double[] cricondenThermfirst = new double[3]; + double[] cricondenBarfirst = new double[3]; + double[] cricondenThermXfirst = new double[100]; + double[] cricondenThermYfirst = new double[100]; + double[] cricondenBarXfirst = new double[100]; + double[] cricondenBarYfirst = new double[100]; + + double[] dewPointTemperatureArray; + double[] dewPointPressureArray; + double[] dewPointEnthalpyArray; + double[] dewPointVolumeArray; + double[] dewPointEntropyArray; + + double[] bubblePointTemperatureArray; + double[] bubblePointPressureArray; + double[] bubblePointEnthalpyArray; + double[] bubblePointVolumeArray; + double[] bubblePointEntropyArray; + + /** + *

+ * 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. + *

+ * + * @return a {@link java.lang.String} object + */ + public String getName(); - /** - * Setter for property Name. - * - * @param name a {@link java.lang.String} object - */ - public void setName(String name); + /** + *

+ * Setter for the field name. + *

+ * + * @param name a {@link java.lang.String} object + */ + public void setName(String name); } diff --git a/src/main/java/neqsim/util/database/NeqSimContractDataBase.java b/src/main/java/neqsim/util/database/NeqSimContractDataBase.java index 6574a18456..4c25fa365c 100644 --- a/src/main/java/neqsim/util/database/NeqSimContractDataBase.java +++ b/src/main/java/neqsim/util/database/NeqSimContractDataBase.java @@ -55,17 +55,16 @@ public NeqSimContractDataBase() { } } - - /** - * 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, "commercial/" + tableName + ".csv"); } - + /** + *

+ * 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 an InvalidInputException 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 an InvalidOutputException 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 a NotImplementedException 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 calculate() { Z[i] = fluid.getZ(); viscosity[i] = fluid.getViscosity("cP"); enthalpy[i] = fluid.getEnthalpy("J/mol"); - entropy[i] = fluid.getEnthalpy("J/molK"); + entropy[i] = fluid.getEntropy("J/molK"); Cp[i] = fluid.getCp("kJ/kgK"); Cv[i] = fluid.getCp("kJ/kgK"); density[i] = fluid.getDensity("kg/m3"); diff --git a/src/main/java/neqsim/util/unit/BaseUnit.java b/src/main/java/neqsim/util/unit/BaseUnit.java index 65f31d4faa..7407e5963a 100644 --- a/src/main/java/neqsim/util/unit/BaseUnit.java +++ b/src/main/java/neqsim/util/unit/BaseUnit.java @@ -8,47 +8,48 @@ * @author esol * @version $Id: $Id */ -public class BaseUnit implements Unit, neqsim.thermo.ThermodynamicConstantsInterface { - private static final long serialVersionUID = 1000; - - protected double SIvalue = 0.0, invalue = 0.0, factor = 1.0; - protected String inunit = null; - - /** - *

- * 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. - *

- * - * @return the componentConcentrationUnit - */ - public String getComponentConcentrationUnit() { - return componentConcentrationUnit; - } + private String temperatureUnit = "K"; - /** - *

- * Setter for the field componentConcentrationUnit. - *

- * - * @param componentConcentrationUnit the componentConcentrationUnit to set - */ - public void setComponentConcentrationUnit(String componentConcentrationUnit) { - this.componentConcentrationUnit = componentConcentrationUnit; - } + private String pressureUnit = "bara"; - /** - *

- * Getter for the field flowRateUnit. - *

- * - * @return the flowRateUnit - */ - public String getFlowRateUnit() { - return flowRateUnit; - } + private String flowRateUnit = "mol/sec"; - /** - *

- * Setter for the field flowRateUnit. - *

- * - * @param flowRateUnit the flowRateUnit to set - */ - public void setFlowRateUnit(String flowRateUnit) { - this.flowRateUnit = flowRateUnit; - } + private String componentConcentrationUnit = "molefraction"; - /** - *

- * Getter for the field pressureUnit. - *

- * - * @return the pressureUnit - */ - public String getPressureUnit() { - return pressureUnit; - } + /** + *

+ * Getter for the field componentConcentrationUnit. + *

+ * + * @return the componentConcentrationUnit + */ + public String getComponentConcentrationUnit() { + return componentConcentrationUnit; + } - /** - *

- * Setter for the field pressureUnit. - *

- * - * @param pressureUnit the pressureUnit to set - */ - public void setPressureUnit(String pressureUnit) { - this.pressureUnit = pressureUnit; - } + /** + *

+ * Getter for the field flowRateUnit. + *

+ * + * @return the flowRateUnit + */ + public String getFlowRateUnit() { + return flowRateUnit; + } - /** - *

- * Getter for the field temperatureUnit. - *

- * - * @return the temperatureUnit - */ - public String getTemperatureUnit() { - return temperatureUnit; - } + /** + *

+ * Getter for the field pressureUnit. + *

+ * + * @return the pressureUnit + */ + public String getPressureUnit() { + return pressureUnit; + } - /** - *

- * Setter for the field temperatureUnit. - *

- * - * @param temperatureUnit the temperatureUnit to set - */ - public void setTemperatureUnit(String temperatureUnit) { - this.temperatureUnit = temperatureUnit; - } + /** + *

+ * Getter for the field temperatureUnit. + *

+ * + * @return the temperatureUnit + */ + public String getTemperatureUnit() { + return temperatureUnit; + } - private String temperatureUnit = "K"; - private String pressureUnit = "bara"; - private String flowRateUnit = "mol/sec"; - private String componentConcentrationUnit = "molefraction"; + /** + *

+ * Setter for the field componentConcentrationUnit. + *

+ * + * @param componentConcentrationUnit the componentConcentrationUnit to set + */ + public void setComponentConcentrationUnit(String componentConcentrationUnit) { + this.componentConcentrationUnit = componentConcentrationUnit; + } + /** + *

+ * Setter for the field flowRateUnit. + *

+ * + * @param flowRateUnit the flowRateUnit to set + */ + public void setFlowRateUnit(String flowRateUnit) { + this.flowRateUnit = flowRateUnit; + } + /** + *

+ * Setter for the field pressureUnit. + *

+ * + * @param pressureUnit the pressureUnit to set + */ + public void setPressureUnit(String pressureUnit) { + this.pressureUnit = pressureUnit; + } + /** + *

+ * Setter for the field temperatureUnit. + *

+ * + * @param temperatureUnit the temperatureUnit to set + */ + public void setTemperatureUnit(String temperatureUnit) { + this.temperatureUnit = temperatureUnit; + } } diff --git a/src/main/java/neqsim/util/unit/PressureUnit.java b/src/main/java/neqsim/util/unit/PressureUnit.java index 633d95ce45..5d8769fb92 100644 --- a/src/main/java/neqsim/util/unit/PressureUnit.java +++ b/src/main/java/neqsim/util/unit/PressureUnit.java @@ -26,28 +26,6 @@ public PressureUnit(double value, String unit) { super(value, unit); } - /** {@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; - } - if (inunit.equals("barg")) { - return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue - + ThermodynamicConstantsInterface.referencePressure; - } else { - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } - } - /** *

* 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; + } + } + + /** Constant activeUnits */ + public static HashMap activeUnits = new HashMap<>(); + /** Constant defaultUnits */ + public static HashMap defaultUnits = new HashMap<>(); + /** Constant metricUnits */ + public static HashMap metricUnits = new HashMap<>(); + private static HashMap siUnits = new HashMap<>(); + private static HashMap fieldUnits = new HashMap<>(); + + private static String[] pressureUnits = + new String[] {"Pa", "bara", "barg", "psi", "psig", "psia"}; + private static String[] temperatureUnits = new String[] {"K", "C", "F", "R"}; + private static String[] molarVolumeUnits = new String[] {"mol/m3", "litre/m3", "ft3/lbmole"}; + + /** + *

+ * 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. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getTemperatureUnits() { + return temperatureUnits; + } + + /** + *

+ * Getter for the field pressureUnits. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getPressureUnits() { + return pressureUnits; + } + + /** + *

+ * Getter for the field molarVolumeUnits. + *

+ * + * @return an array of {@link java.lang.String} objects + */ + public String[] getMolarVolumeUnits() { + return molarVolumeUnits; + } +} diff --git a/src/main/java/neqsim/util/util/DoubleCloneable.java b/src/main/java/neqsim/util/util/DoubleCloneable.java index 47a6f72fc7..29ae698ee6 100644 --- a/src/main/java/neqsim/util/util/DoubleCloneable.java +++ b/src/main/java/neqsim/util/util/DoubleCloneable.java @@ -49,23 +49,23 @@ public DoubleCloneable clone() { /** *

- * 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":"","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"java.lang.management.MemoryMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.MemoryManagerMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.MemoryPoolMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.MemoryUsage", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.MonitorInfo", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.PlatformLoggingMXBean", + "queryAllPublicMethods":true, + "methods":[{"name":"getLoggerLevel","parameterTypes":["java.lang.String"] }, {"name":"getLoggerNames","parameterTypes":[] }, {"name":"getParentLoggerName","parameterTypes":["java.lang.String"] }, {"name":"setLoggerLevel","parameterTypes":["java.lang.String","java.lang.String"] }] +}, +{ + "name":"java.lang.management.RuntimeMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"java.lang.management.ThreadInfo", + "queryAllPublicMethods":true +}, +{ + "name":"java.math.BigDecimal" +}, +{ + "name":"java.math.BigInteger" +}, +{ + "name":"java.sql.SQLException", + "fields":[{"name":"next"}] +}, +{ + "name":"java.util.Date" +}, +{ + "name":"java.util.PropertyPermission", + "methods":[{"name":"","parameterTypes":["java.lang.String","java.lang.String"] }] +}, +{ + "name":"java.util.ServiceLoader", + "methods":[{"name":"load","parameterTypes":["java.lang.Class","java.lang.ClassLoader"] }] +}, +{ + "name":"java.util.concurrent.atomic.AtomicBoolean", + "fields":[{"name":"value"}] +}, +{ + "name":"java.util.concurrent.atomic.AtomicReference", + "fields":[{"name":"value"}] +}, +{ + "name":"java.util.concurrent.atomic.Striped64", + "fields":[{"name":"base"}, {"name":"cellsBusy"}] +}, +{ + "name":"java.util.logging.LogManager", + "methods":[{"name":"getLoggingMXBean","parameterTypes":[] }] +}, +{ + "name":"java.util.logging.LoggingMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"javax.management.MBeanOperationInfo", + "queryAllPublicMethods":true, + "methods":[{"name":"getSignature","parameterTypes":[] }] +}, +{ + "name":"javax.management.MBeanServerBuilder", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"javax.management.NotificationBroadcasterSupport", + "methods":[{"name":"getNotificationInfo","parameterTypes":[] }] +}, +{ + "name":"javax.management.ObjectName" +}, +{ + "name":"javax.management.StandardEmitterMBean", + "methods":[{"name":"cacheMBeanInfo","parameterTypes":["javax.management.MBeanInfo"] }, {"name":"getCachedMBeanInfo","parameterTypes":[] }, {"name":"getMBeanInfo","parameterTypes":[] }] +}, +{ + "name":"javax.management.openmbean.CompositeData" +}, +{ + "name":"javax.management.openmbean.OpenMBeanOperationInfoSupport" +}, +{ + "name":"javax.management.openmbean.TabularData" +}, +{ + "name":"javax.servlet.Servlet" +}, +{ + "name":"jdk.management.jfr.ConfigurationInfo", + "queryAllPublicMethods":true +}, +{ + "name":"jdk.management.jfr.EventTypeInfo", + "queryAllPublicMethods":true +}, +{ + "name":"jdk.management.jfr.FlightRecorderMXBean", + "queryAllPublicMethods":true +}, +{ + "name":"jdk.management.jfr.FlightRecorderMXBeanImpl", + "queryAllPublicConstructors":true, + "methods":[{"name":"cacheMBeanInfo","parameterTypes":["javax.management.MBeanInfo"] }, {"name":"getCachedMBeanInfo","parameterTypes":[] }, {"name":"getMBeanInfo","parameterTypes":[] }, {"name":"getNotificationInfo","parameterTypes":[] }] +}, +{ + "name":"jdk.management.jfr.RecordingInfo", + "queryAllPublicMethods":true +}, +{ + "name":"jdk.management.jfr.SettingDescriptorInfo", + "queryAllPublicMethods":true +}, +{ + "name":"neqsim.thermo.system.SystemSrkEos", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.appender.AppenderSet" +}, +{ + "name":"org.apache.logging.log4j.core.appender.AsyncAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.ConsoleAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.CountingNoOpAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.FailoverAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.FailoversPlugin" +}, +{ + "name":"org.apache.logging.log4j.core.appender.FileAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.HttpAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.MemoryMappedFileAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.NullAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.OutputStreamAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.RandomAccessFileAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.RollingFileAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.ScriptAppenderSelector" +}, +{ + "name":"org.apache.logging.log4j.core.appender.SmtpAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.SocketAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.SyslogAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.WriterAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.ColumnMapping" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource" +}, +{ + "name":"org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.mom.JmsAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.nosql.NoSqlAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rewrite.LoggerNameLevelRewritePolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rewrite.MapRewritePolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rewrite.PropertiesRewritePolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rewrite.RewriteAppender" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.NoOpTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.DeleteAction" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfAll" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfAny" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfFileName" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfLastModified" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.IfNot" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.PosixViewAttributeAction" +}, +{ + "name":"org.apache.logging.log4j.core.appender.rolling.action.ScriptCondition" +}, +{ + "name":"org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy" +}, +{ + "name":"org.apache.logging.log4j.core.appender.routing.Route" +}, +{ + "name":"org.apache.logging.log4j.core.appender.routing.Routes" +}, +{ + "name":"org.apache.logging.log4j.core.appender.routing.RoutingAppender" +}, +{ + "name":"org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory" +}, +{ + "name":"org.apache.logging.log4j.core.async.AsyncLoggerConfig" +}, +{ + "name":"org.apache.logging.log4j.core.async.AsyncLoggerConfig$RootLogger" +}, +{ + "name":"org.apache.logging.log4j.core.async.AsyncWaitStrategyFactoryConfig" +}, +{ + "name":"org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory" +}, +{ + "name":"org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory" +}, +{ + "name":"org.apache.logging.log4j.core.async.LinkedTransferQueueFactory" +}, +{ + "name":"org.apache.logging.log4j.core.config.AppenderControlArraySet", + "fields":[{"name":"appenderArray"}] +}, +{ + "name":"org.apache.logging.log4j.core.config.AppenderRef" +}, +{ + "name":"org.apache.logging.log4j.core.config.AppendersPlugin" +}, +{ + "name":"org.apache.logging.log4j.core.config.CustomLevelConfig" +}, +{ + "name":"org.apache.logging.log4j.core.config.CustomLevels" +}, +{ + "name":"org.apache.logging.log4j.core.config.DefaultAdvertiser" +}, +{ + "name":"org.apache.logging.log4j.core.config.HttpWatcher" +}, +{ + "name":"org.apache.logging.log4j.core.config.LoggerConfig" +}, +{ + "name":"org.apache.logging.log4j.core.config.LoggerConfig$RootLogger" +}, +{ + "name":"org.apache.logging.log4j.core.config.LoggersPlugin" +}, +{ + "name":"org.apache.logging.log4j.core.config.PropertiesPlugin" +}, +{ + "name":"org.apache.logging.log4j.core.config.Property" +}, +{ + "name":"org.apache.logging.log4j.core.config.ScriptsPlugin" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.ClassArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.DefaultArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.EnvironmentArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.ScriptArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.SelectArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.arbiters.SystemPropertyArbiter" +}, +{ + "name":"org.apache.logging.log4j.core.config.json.JsonConfigurationFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BigDecimalConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BigIntegerConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$BooleanConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ByteArrayConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ByteConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharArrayConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharacterConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CharsetConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ClassConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$CronExpressionConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$DoubleConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$DurationConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$FileConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$FloatConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$InetAddressConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$IntegerConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$LevelConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$LongConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$PathConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$PatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$SecurityProviderConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$ShortConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$StringConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UriConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UrlConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.plugins.convert.TypeConverters$UuidConverter" +}, +{ + "name":"org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.filter.BurstFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.CompositeFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.DenyAllFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.DynamicThresholdFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.LevelMatchFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.LevelRangeFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.MapFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.MarkerFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.MutableThreadContextMapFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.NoMarkerFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.RegexFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.ScriptFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.StringMatchFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.StructuredDataFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.ThreadContextMapFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.ThresholdFilter" +}, +{ + "name":"org.apache.logging.log4j.core.filter.TimeFilter" +}, +{ + "name":"org.apache.logging.log4j.core.impl.Log4jContextFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.impl.Log4jProvider" +}, +{ + "name":"org.apache.logging.log4j.core.impl.ThreadContextDataProvider" +}, +{ + "name":"org.apache.logging.log4j.core.jmx.AppenderAdmin", + "queryAllPublicConstructors":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.AppenderAdminMBean", + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.ContextSelectorAdmin", + "queryAllPublicConstructors":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.ContextSelectorAdminMBean", + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.LoggerContextAdmin", + "queryAllPublicConstructors":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean", + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.StatusLoggerAdmin", + "queryAllPublicConstructors":true +}, +{ + "name":"org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean", + "queryAllPublicMethods":true +}, +{ + "name":"org.apache.logging.log4j.core.layout.CsvLogEventLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.CsvParameterLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.GelfLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.HtmlLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.JsonLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.LevelPatternSelector" +}, +{ + "name":"org.apache.logging.log4j.core.layout.LoggerFields" +}, +{ + "name":"org.apache.logging.log4j.core.layout.MarkerPatternSelector" +}, +{ + "name":"org.apache.logging.log4j.core.layout.MessageLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.PatternLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.PatternMatch" +}, +{ + "name":"org.apache.logging.log4j.core.layout.Rfc5424Layout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.ScriptPatternSelector" +}, +{ + "name":"org.apache.logging.log4j.core.layout.SerializedLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.SyslogLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.XmlLayout" +}, +{ + "name":"org.apache.logging.log4j.core.layout.YamlLayout" +}, +{ + "name":"org.apache.logging.log4j.core.lookup.ContextMapLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.DateLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.EnvironmentLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.EventLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.JavaLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.JndiLookup" +}, +{ + "name":"org.apache.logging.log4j.core.lookup.Log4jLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.LowerLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.MainMapLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.MapLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.MarkerLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.ResourceBundleLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.StructuredDataLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.SystemPropertiesLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.lookup.UpperLookup", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.core.net.MulticastDnsAdvertiser" +}, +{ + "name":"org.apache.logging.log4j.core.net.SocketAddress" +}, +{ + "name":"org.apache.logging.log4j.core.net.SocketOptions" +}, +{ + "name":"org.apache.logging.log4j.core.net.SocketPerformancePreferences" +}, +{ + "name":"org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration" +}, +{ + "name":"org.apache.logging.log4j.core.net.ssl.SslConfiguration" +}, +{ + "name":"org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Black" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Blue" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Cyan" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Green" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Magenta" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Red" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$White" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter$Yellow" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ClassNamePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.DatePatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.EncodingPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.EndOfBatchPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.EqualsIgnoreCaseReplacementConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.EqualsReplacementConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.FileDatePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.FileLocationPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.FullLocationPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.HighlightConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.IntegerPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.LevelPatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.LineLocationPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.LineSeparatorPatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.LoggerFqcnPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.LoggerPatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MapPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MarkerPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MarkerSimpleNamePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MaxLengthConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MdcPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MessagePatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["org.apache.logging.log4j.core.config.Configuration","java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.MethodLocationPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.NanoTimePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.NdcPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ProcessIdPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.RegexReplacement" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.RegexReplacementConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.RelativeTimePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.RepeatPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.RootThrowablePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.SequenceNumberPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.StyleConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ThreadIdPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ThreadNamePatternConverter", + "queryAllDeclaredMethods":true, + "methods":[{"name":"newInstance","parameterTypes":["java.lang.String[]"] }] +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ThreadPriorityPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.ThrowablePatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.UuidPatternConverter" +}, +{ + "name":"org.apache.logging.log4j.core.pattern.VariablesNotEmptyReplacementConverter" +}, +{ + "name":"org.apache.logging.log4j.core.script.Script" +}, +{ + "name":"org.apache.logging.log4j.core.script.ScriptFile" +}, +{ + "name":"org.apache.logging.log4j.core.script.ScriptRef" +}, +{ + "name":"org.apache.logging.log4j.core.util.KeyValuePair" +}, +{ + "name":"org.apache.logging.log4j.message.DefaultFlowMessageFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.message.ParameterizedMessageFactory", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.apache.logging.log4j.util.EnvironmentPropertySource" +}, +{ + "name":"org.apache.logging.log4j.util.SystemPropertiesPropertySource" +}, +{ + "name":"org.h2.Driver" +}, +{ + "name":"org.h2.mvstore.MVStore$TxCounter", + "fields":[{"name":"counter"}] +}, +{ + "name":"org.h2.mvstore.Page", + "fields":[{"name":"pos"}] +}, +{ + "name":"org.h2.store.fs.async.FilePathAsync", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.mem.FilePathMem", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.mem.FilePathMemLZF", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.niomapped.FilePathNioMapped", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.niomem.FilePathNioMem", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.niomem.FilePathNioMemLZF", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.retry.FilePathRetryOnInterrupt", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.split.FilePathSplit", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.h2.store.fs.zip.FilePathZip", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.locationtech.jts.geom.Geometry" +}, +{ + "name":"org.osgi.framework.FrameworkUtil" +}, +{ + "name":"sun.management.ClassLoadingImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.CompilationImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.ManagementFactoryHelper$1", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.ManagementFactoryHelper$PlatformLoggingImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.MemoryImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.MemoryManagerImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.MemoryPoolImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.management.RuntimeImpl", + "queryAllPublicConstructors":true +}, +{ + "name":"sun.security.provider.SHA2$SHA256", + "methods":[{"name":"","parameterTypes":[] }] +} +] diff --git a/src/main/resources/META-INF/native-image/resource-config.json b/src/main/resources/META-INF/native-image/resource-config.json new file mode 100644 index 0000000000..47727361d9 --- /dev/null +++ b/src/main/resources/META-INF/native-image/resource-config.json @@ -0,0 +1,134 @@ +{ + "resources":{ + "includes":[{ + "pattern":"\\QMETA-INF/log4j-provider.properties\\E" + }, { + "pattern":"\\QMETA-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat\\E" + }, { + "pattern":"\\QMETA-INF/services/java.lang.System$LoggerFinder\\E" + }, { + "pattern":"\\QMETA-INF/services/java.net.spi.InetAddressResolverProvider\\E" + }, { + "pattern":"\\QMETA-INF/services/java.sql.Driver\\E" + }, { + "pattern":"\\QMETA-INF/services/java.time.zone.ZoneRulesProvider\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.core.util.WatchEventService\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.spi.Provider\\E" + }, { + "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.util.PropertySource\\E" + }, { + "pattern":"\\Qdata/AdsorptionParameters.csv\\E" + }, { + "pattern":"\\Qdata/COMP.csv\\E" + }, { + "pattern":"\\Qdata/COMPSALT.csv\\E" + }, { + "pattern":"\\Qdata/INTER.csv\\E" + }, { + "pattern":"\\Qdata/ISO6976constants.csv\\E" + }, { + "pattern":"\\Qdata/ISO6976constants2016.csv\\E" + }, { + "pattern":"\\Qdata/MBWR32param.csv\\E" + }, { + "pattern":"\\Qdata/PIPEDATA.csv\\E" + }, { + "pattern":"\\Qdata/REACTIONDATA.csv\\E" + }, { + "pattern":"\\Qdata/ReactionKSPdata.csv\\E" + }, { + "pattern":"\\Qdata/STOCCOEFDATA.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACGroupParam.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParam.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamA_UMR.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamA_UMRMC.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamB.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamB_UMR.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamB_UMRMC.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamC.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamC_UMR.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACInterParamC_UMRMC.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACcomp.csv\\E" + }, { + "pattern":"\\Qdata/UNIFACcompUMRPRU.csv\\E" + }, { + "pattern":"\\Qdata/element.csv\\E" + }, { + "pattern":"\\Qlog4j2-test.jsn\\E" + }, { + "pattern":"\\Qlog4j2-test.json\\E" + }, { + "pattern":"\\Qlog4j2-test.properties\\E" + }, { + "pattern":"\\Qlog4j2-test.xml\\E" + }, { + "pattern":"\\Qlog4j2-test.yaml\\E" + }, { + "pattern":"\\Qlog4j2-test.yml\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.jsn\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.json\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.properties\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.xml\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.yaml\\E" + }, { + "pattern":"\\Qlog4j2-test76ed5528.yml\\E" + }, { + "pattern":"\\Qlog4j2.StatusLogger.properties\\E" + }, { + "pattern":"\\Qlog4j2.component.properties\\E" + }, { + "pattern":"\\Qlog4j2.jsn\\E" + }, { + "pattern":"\\Qlog4j2.json\\E" + }, { + "pattern":"\\Qlog4j2.properties\\E" + }, { + "pattern":"\\Qlog4j2.system.properties\\E" + }, { + "pattern":"\\Qlog4j2.xml\\E" + }, { + "pattern":"\\Qlog4j2.yaml\\E" + }, { + "pattern":"\\Qlog4j2.yml\\E" + }, { + "pattern":"\\Qlog4j276ed5528.jsn\\E" + }, { + "pattern":"\\Qlog4j276ed5528.json\\E" + }, { + "pattern":"\\Qlog4j276ed5528.properties\\E" + }, { + "pattern":"\\Qlog4j276ed5528.xml\\E" + }, { + "pattern":"\\Qlog4j276ed5528.yaml\\E" + }, { + "pattern":"\\Qlog4j276ed5528.yml\\E" + }, { + "pattern":"\\Qorg/h2/util/data.zip\\E" + }, { + "pattern":"jdk.jfr:\\Qjdk/jfr/internal/query/view.ini\\E" + }]}, + "bundles":[{ + "name":"sun.util.resources.cldr.CalendarData", + "locales":["und"] + }] +} diff --git a/src/main/resources/META-INF/native-image/serialization-config.json b/src/main/resources/META-INF/native-image/serialization-config.json new file mode 100644 index 0000000000..13e09223ed --- /dev/null +++ b/src/main/resources/META-INF/native-image/serialization-config.json @@ -0,0 +1,8 @@ +{ + "types":[ + ], + "lambdaCapturingTypes":[ + ], + "proxies":[ + ] +} diff --git a/src/main/resources/data/COMP.csv b/src/main/resources/data/COMP.csv index c5f8eaff23..d27a5b69cf 100644 --- a/src/main/resources/data/COMP.csv +++ b/src/main/resources/data/COMP.csv @@ -193,3 +193,9 @@ 1185,"trans-14-DM-cy-C6","2207-04-7","HC",147,"C",112.220000000,0.422182073,316.667016601,29.640000000,0.233980000,119.356011962,16.043000000,99.000000000,"Classic",66909.600000000,-68.400000000,0.897300000,-0.000513700,0.000000109,0.000000000,"log",39.205000000,-1324.400000000,-3.436600000,0.000031019,2.000000000,0.000000000,0.000000000,0.000000000,0.000000000,2.520000000,155.809006022,0.406998625,3,-26.870000000,1150.000000000,0.187000000,-0.000521000,-50500.000000000,2.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0,"solute",900.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.303000000,-0.000605000,-0.000003200,77.300000000,941.000000000,452.000000000,0.116656057,90.690000000,90.650000000,-74520.000000000,186.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,10200000.0000000,0.261000000,-0.147000000,0.222000000,0.000000000,0.100000000,0.585700000,-0.720600000,1.289900000,0.000000000,0.000000000,0.000000000,0.122841598,0.914470789,2.741978611,0,"0",0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,4.186260000,1,1.000000000,-6.680820000,0.000000000,9700,0.000015293,0.047920000,1594.000000000,0.012440000,2952.000000000,0.002317000,2777.000000000,1.076000000,1323.000000000,"yes",1.000000000,3.703900119,150.029998779,0.000000000,0.000000000,3.190710941,155.809006022,0.406998625,1.000000000,0,900.000000000,0.000621000,2760.000000000,0.421000000,1963.100000000,0.004048680,2636.750000000,0.295270000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.628820000,0.701140000,-0.784370000,0.000000000 1186,"PG","57-55-6","glycol",1186,"propyleneglycol",76.095000000,1.036000000,352.850000000,61.000000000,1.102000000,188.200000000,76.095000000,239.000000000,"Classic",32022.600000000,35.700000000,0.248400000,-0.000149700,0.000000030,0.000000000,"exp",13.629900000,6022.180000000,-28.250000000,0.000000000,0.000000000,2.308200000,0.215000000,0.248800000,0.000000000,3.626000000,481.800000000,0.000000000,3,-23.155244944,5694.484212533,0.023081509,0.000000000,57900.000000000,-19.290540000,29814.530000000,-0.019678500,0.013189000,0.031144000,0,"solvent",0.000000000,0.000000000,0.000000000,0.000000000,0.654009012,-3.955117195,3.671191916,0.517338954,-0.000798169,0.000000064,133.328650000,9958.000000000,904.000000000,0.000002420,260.150000000,260.150000000,-388000.000000000,324.000000000,21.400000000,0.000000000,0.000000000,0.000000000,0.000000000,1.315100000,0.251250000,719.700000000,0.218700000,0.000000000,82900000.0000000,0.427000000,0.000000000,0.000000000,0.000000000,1.117000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,4,"4C",0.000000000,0.000000000,0.019000000,17442.000000000,138360.000000000,6.750000000,0.937200000,108190.000000000,5.140000000,0.674400000,0.051400000,1,17.090887000,-7800.000000000,0.000000000,0,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,"no",0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,3.626000000,481.800000000,0.000000000,1.000000000,0,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,35540.000000000,436.780000000,-0.184860000,0.000000000,0.000000000,35540.000000000,436.780000000,-0.184860000,0.000000000,0.000000000,0.910030000,1.349960000,-1.890020000,151.817427819 1187,"ammonia","7664-41-7","other",1187,"NH3",17.031,0.73,132.25,113.0,0.250,-33.35,17.031,99.000000000,"Classic",11133.000000000,39.192196000,-0.058081604,0.000350102,-0.000000369,1.276199e-10,"pow10",5.202770000,1580.080000000,239.500000000,0.000000000,0.000000000,1.700000000,0.215000000,0.200000000,0.000000000,3.626000000,481.800000000,0.000000000,3,-39.350000000,4826.000000000,0.109100000,-0.000113000,57900.000000000,-19.290500000,29814.500000000,-0.019678000,0.013189000,0.031144000,0,"solvent",0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,-0.384000000,0.005250000,-0.000006370,73.069489067,3177.000000000,1000.000000000,0.006110000,175.500000000,175.500000000,-242000.000000000,189.000000000,30.585000000,0.000000000,0.000000000,0.000000000,0.000000000,2.288000000,0.268500000,512.640000000,0.245300000,0.000000000,52100000.0000000,0.320000000,-0.212000000,0.258000000,0.000000000,0.797000000,1.437100000,-0.799420000,0.327800000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,2,"2B",0.000000000,0.000000000,0.016100000,24591.000000000,40531.000000000,3.097800000,0.431020000,47052.000000000,3.300000000,0.903700000,0.044900000,1,17.387107060,-7582.406220000,0.000000000,0,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,"no",1.525500000,3.230000000,188.900000000,0.035176000,24106.443000000,3.626000000,481.800000000,0.000000000,1.000000000,0,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,0.000000000,-12706.000000000,958.780000000,-5.233200000,0.013152000,0.000000000,105800.000000000,-362.230000000,0.937900000,0.000000000,0.000000000,1.224003000,-0.273500000,-0.398230000,87.543852818 +1188,"chlorine",7782-50-5,chlorine,195,Cl2,70.906,1.5326431958562459,143.71540000000005,76.424,0.07,-33.952362112999964,70.906,124.069478908,Classic,0.0,25.4089891488,0.04465530069384,-6.73304954604e-05,4.73342196414e-08,-1.268453987088e-11,pow10KPa,9.0628,861.34,-26.82,0.0,0.0,0.0,0.215,0.2767,0.0,4.217,316.0,0.5203667,1,0.0,0.0,0.0,0.0,0.0,8.16976,0.0,0.0,0.0,0.0,0,solute,900.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,207.0,6400.0,1532.643195856246,0.013808478434799999,172.17,172.15,0.0,223.1,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,20280.90073241057,0.0,0.0,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,1A,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.0,0.0,6500.0,1.8927555303529247e-05,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,no,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.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,0.0,0.0,0.0,0.0,0.0 +1189,"ethylene",74-85-1,"ethylene",196,C2H4,28.05316,0.5665875959429861,9.200000000000045,50.418,0.0866,-103.77135156599996,28.05316,130.945481716,Classic,52560.0,35.0953348158,-0.0730175859636,0.00048182294541,-5.59479999942e-07,2.08776085578e-10,pow10KPa,8.91382,596.526,-16.78,0.0,0.0,0.0,0.215,0.2815,0.0,4.04838,169.08,0.7657779,3350.0,0.00121961941966,103.986,566.5875959429861,104.05,52560.0,9.627551137738643e-06,3450.0,13556.576228246833,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,219.3,no,1,207.0,8.16976,solute,900.0,0,1A,1,0,0.0,0.0,0.0,0.0,0.0,1.0 +1190,"propene",115-07-1,"propene",197,C3H6,42.07974,0.6071797165485592,91.06100000000004,45.55,0.146,-47.61912875399997,42.07974,183.250870442,Classic,20370.0,31.8776388732,0.0323681920014,0.00038978187542399996,-4.99948467774e-07,1.89819117234e-10,pow10KPa,8.95606,789.624,-25.57,0.0,0.0,0.36,0.215,0.2779,0.0,4.4902,282.43,1.1051818500000001,3003.0,7.471717723549999e-09,87.953,607.1797165485592,88.075,20370.0,1.0561747100848501e-05,3103.0,18504.676899839127,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,266.71,no,1,207.0,8.16976,solute,900.0,0,1A,1,0,0.0,0.0,0.0,0.0,0.0,1.0 +1191,"cis-butene",590-18-1,"cis-butene",198,C4H8,56.10632,0.6301087082074909,162.60000000000002,42.255,0.202,3.7235553570000093,56.10632,235.626767201,Classic,-7330.0,30.6720422022,0.1595045968032,0.00018541245354,-2.8485339274799996e-07,1.04429615088e-10,pow10KPa,9.00958,967.32,-35.277,0.0,0.0,0.26,0.215,0.2701,0.0,3.82,132.0,1.4164999999999999,7310.0,2.6364927810099997e-06,134.3,630.1087082074908,134.26,-7330.0,1.1258595759827091e-05,7410.0,23322.437236388218,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,301.17,no,1,207.0,8.16976,solute,900.0,0,1A,1,0,0.0,0.0,0.0,0.0,0.0,1.0 +1192,"trans-butene",624-64-6,"trans-butene",199,C4H8,56.10632,0.6247637226336263,155.46000000000004,40.273,0.21,0.8798965720000069,56.10632,237.360550676,Classic,-11180.0,46.42794352319999,-0.040657708422,0.0007593596135339999,-9.1251196305e-07,3.3964568283e-10,pow10KPa,9.00827,967.5,-32.31,0.0,0.0,0.0,0.215,0.272,0.0,3.82,132.0,1.367,9760.0,0.0007481658101809999,167.6,624.7637226336263,167.63,-11180.0,1.0933788266236188e-05,9860.0,22984.99404781112,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,296.48,no,1,207.0,8.16976,solute,900.0,0,1A,1,0,0.0,0.0,0.0,0.0,0.0,1.0 +1193,"iso-butene",115-11-7,"iso-butene",200,C4H8,56.10632,0.6172935303955316,144.94,40.098,0.193,-7.004207835999978,56.10632,239.80815347700002,Classic,-17600.0,26.8640196138,0.1741796183502,0.000192313455174,-3.28338017502e-07,1.30204440468e-10,pow10KPa,8.80956,866.25,-38.51,0.0,0.0,0.5,0.215,0.2728,0.0,3.82,132.0,1.4375,5920.0,6.7618898108400006e-06,132.4,617.2935303955315,132.95,-17600.0,1.0947338969965856e-05,6020.0,22077.0419048734,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,2.92,0.0,0.0,0.0,0.0,293.59,no,1,207.0,8.16976,solute,900.0,0,1A,1,0,0.0,0.0,0.0,0.0,0.0,1.0 diff --git a/src/main/resources/data/PIPEDATA.csv b/src/main/resources/data/PIPEDATA.csv new file mode 100644 index 0000000000..aceeaf0efa --- /dev/null +++ b/src/main/resources/data/PIPEDATA.csv @@ -0,0 +1,24 @@ +"ID","Size","OD","ED202","LD201","ES301","BD20A","BT75A","DD20A","FD201","FD20X","FD772","GC20A","GD20X","GD22A","TS31A","BC21A" +1,"0.5",21.3,2.77,3.73,2.77,2.77,2.77,2.77,2.77,2.77,,7.47,3.73,4.78,,4.78 +2,"0.75",26.7,2.87,3.91,2.87,2.87,2.87,2.87,2.87,2.87,,7.82,3.91,5.56,,5.56 +3,"1.0",33.4,3.38,6.35,3.38,2.77,3.38,3.38,3.38,3.38,,9.09,4.55,6.35,,6.35 +4,"1.5",48.3,3.68,7.14,3.68,2.77,2.77,3.68,3.68,3.68,,10.15,7.14,7.14,,5.08 +5,"2.0",60.3,3.91,8.74,2.77,2.77,2.77,3.91,3.91,3.91,,12.5,8.74,8.74,,5.54 +6,"3.0",88.9,5.49,15.24,5.49,3.05,3.05,5.49,5.49,5.49,,16,11.13,11.13,,5.49 +7,"4.0",114.3,6.02,17.12,6.02,3.05,6.02,6.02,8.56,8.56,,20,13.49,13.49,,6.02 +8,"5.0",141.3,,,,,,,,,,,,,, +9,"6.0",168.3,7.11,25,10.97,3.4,7.11,7.11,10.97,10.97,,30,21.95,18.26,,7.11 +10,"8.0",219.1,10.31,32,10.31,3.76,6.35,8.18,12.7,15.09,,36,25,23.01,,8.18 +11,"10.0",273.1,12.7,32,12.7,4.19,7.8,9.27,15.09,18.26,,45,32,28.58,,9.27 +12,"12.0",323.9,12.7,40,14.27,6.35,8.38,9.53,17.48,21.44,17.48,50,36,33.32,,10.31 +13,"14.0",355.6,15.09,45,15.09,6.35,9.53,11.13,19.05,19.05,,,40,,,11.13 +14,"16.0",406.4,16.66,50,16.66,6.35,12.7,12.7,26.19,,,,,,,12.7 +15,"18.0",457.2,19.05,,19.05,7.92,12.7,14.27,29.36,,,,,,,14.27 +16,"20.0",508,20.62,,20.62,9.53,12.7,15.09,32.54,,,,,,,15.09 +17,"24.0",609.6,24.61,,24.61,9.53,14.27,17.48,38.89,,,,,,,17.48 +18,"26.0",660.4,,,,,,,,,,,,,, +19,"28.0",711.2,,,,,,,,,,,,,, +20,"30.0",762,,,,,,,,,,,,,, +21,"32.0",813,,,,,,,,,,,,,, +22,"36.0",914,,,,,,,,,,,,,, +23,"40.0",1016,,,,,,,,,,,,,, diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java index 52fae0ed47..ca22f8f059 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantMassExpansionTest.java @@ -6,40 +6,53 @@ import neqsim.thermo.system.SystemSrkEos; public class ConstantMassExpansionTest { - @Test void testRunCalc() { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 73.0, 10.0); - tempSystem.addComponent("nitrogen", 0.972); - tempSystem.addComponent("CO2", 0.632); - tempSystem.addComponent("methane", 95.111); - tempSystem.addComponent("ethane", 2.553); - tempSystem.addComponent("propane", 0.104); - tempSystem.addComponent("i-butane", 0.121); - tempSystem.addComponent("n-butane", 0.021); - tempSystem.addComponent("i-pentane", 0.066); - tempSystem.addComponent("n-pentane", 0.02); - - tempSystem.addTBPfraction("C6", 0.058, 86.18 / 1000.0, 664.0e-3); - tempSystem.addTBPfraction("C7", 0.107, 96.0 / 1000.0, 738.0e-3); - tempSystem.addTBPfraction("C8", 0.073, 107.0 / 1000.0, 765.0e-3); - tempSystem.addTBPfraction("C9", 0.044, 121.0 / 1000.0, 781.0e-3); - tempSystem.addPlusFraction("C10", 0.118, 190.0 / 1000.0, 813.30e-3); + SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 350.0); + tempSystem.addComponent("nitrogen", 0.39); + tempSystem.addComponent("CO2", 0.3); + tempSystem.addComponent("methane", 40.2); + tempSystem.addComponent("ethane", 7.61); + tempSystem.addComponent("propane", 7.95); + tempSystem.addComponent("i-butane", 1.19); + tempSystem.addComponent("n-butane", 4.08); + tempSystem.addComponent("i-pentane", 1.39); + tempSystem.addComponent("n-pentane", 2.15); + tempSystem.addComponent("n-hexane", 2.79); + tempSystem.addTBPfraction("C7", 4.28, 95 / 1000.0, 0.729); + tempSystem.addTBPfraction("C8", 4.31, 106 / 1000.0, 0.749); + tempSystem.addTBPfraction("C9", 3.08, 121 / 1000.0, 0.77); + tempSystem.addTBPfraction("C10", 2.47, 135 / 1000.0, 0.786); + tempSystem.addTBPfraction("C11", 1.91, 148 / 1000.0, 0.792); + tempSystem.addTBPfraction("C12", 1.69, 161 / 1000.0, 0.804); + tempSystem.addTBPfraction("C13", 1.59, 175 / 1000.0, 0.819); + tempSystem.addTBPfraction("C14", 1.22, 196 / 1000.0, 0.833); + tempSystem.addTBPfraction("C15", 1.25, 206 / 1000.0, 0.836); + tempSystem.addTBPfraction("C16", 1.0, 225 / 1000.0, 0.843); + tempSystem.addTBPfraction("C17", 0.99, 236 / 1000.0, 0.840); + tempSystem.addTBPfraction("C18", 0.92, 245 / 1000.0, 0.846); + tempSystem.addTBPfraction("C19", 0.6, 265 / 1000.0, 0.857); + tempSystem.addPlusFraction("C20", 6.64, 453 / 1000.0, 0.918); tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); - tempSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); tempSystem.getCharacterization().characterisePlusFraction(); - tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); - tempSystem.init(0); + tempSystem.setMixingRule("classic"); ConstantMassExpansion CMEsim = new ConstantMassExpansion(tempSystem); - CMEsim.setTemperaturesAndPressures( - new double[] {273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9, 273.15 + 73.9}, - new double[] {400, 300.0, 250.0, 200.0, 100.0}); + double[] pressures = new double[] {351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 197.3, + 189.3, 183.3, 165.0, 131.2, 108.3, 85.3, 55.6}; + + CMEsim.setPressures(pressures); double[][] expData = {{0.95, 0.99, 1.12, 1.9}}; CMEsim.setExperimentalData(expData); + CMEsim.setTemperature(97.5, "C"); // CMEsim.runTuning(); CMEsim.runCalc(); - assertEquals(2.300467604746, CMEsim.getRelativeVolume()[4], 0.001); + + assertEquals(2.1873758493453708E-4, CMEsim.getIsoThermalCompressibility()[0], 0.00001); + assertEquals(0.956122065, CMEsim.getRelativeVolume()[0], 0.001); + assertEquals(0.994254912, CMEsim.getRelativeVolume()[6], 0.001); + assertEquals(1.3572659252241415, CMEsim.getRelativeVolume()[12], 0.001); + assertEquals(2.153242696868525, CMEsim.getYfactor()[12], 0.001); } } + diff --git a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java index 8ee021d442..f1f3e9184c 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/ConstantVolumeDepletionTest.java @@ -1,9 +1,11 @@ package neqsim.PVTsimulation.simulation; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.File; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; public class ConstantVolumeDepletionTest { @Test @@ -38,6 +40,43 @@ void testRunCalc() { new double[] {400, 300.0, 200.0, 100.0}); double[][] expData = {{0.95, 0.99, 1.0, 1.1}}; CVDsim.setExperimentalData(expData); - assertEquals(1.419637379033296, CVDsim.getRelativeVolume()[4], 0.001); + assertEquals(2.198101313307043 + + , CVDsim.getRelativeVolume()[4], 0.001); + } + + @Test + void testRunEclipseInput() { + File file = new File("src/test/java/neqsim/PVTsimulation/simulation"); + String fileFluid1 = file.getAbsolutePath() + "/EclipseModel.e300"; + SystemInterface fluid1 = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1); + // TODO: check why not working with multiphase + fluid1.setMultiPhaseCheck(true); + fluid1.setTemperature(90.0, "C"); + + SaturationPressure satPres = new SaturationPressure(fluid1); + satPres.run(); + assertEquals(199.4580707, fluid1.getPressure("bara"), 0.01); + + ConstantVolumeDepletion CVDsim = new ConstantVolumeDepletion(fluid1); + CVDsim.setTemperature(90.0, "C"); + CVDsim.setPressures( + new double[] {200.0, 154.0, 139.0, 127.0, 117.0, 108.0, 91.0, 82.0, 62.0, 38.0}); + CVDsim.runCalc(); + CVDsim.getThermoSystem().initPhysicalProperties("density"); + double gasdens = CVDsim.getThermoSystem().getPhase("gas").getDensity("kg/m3"); + double oildens = CVDsim.getThermoSystem().getPhase("oil").getDensity("kg/m3"); + + SystemInterface gasFluid = CVDsim.getThermoSystem().phaseToSystem("gas"); + gasFluid.initPhysicalProperties("density"); + + assertEquals(gasdens, gasFluid.getDensity("kg/m3"), 0.01); + + SystemInterface oilFluid = CVDsim.getThermoSystem().phaseToSystem("oil"); + ThermodynamicOperations ops = new ThermodynamicOperations(oilFluid); + ops.TPflash(); + oilFluid.initPhysicalProperties("density"); + + assertEquals(oildens, oilFluid.getDensity("kg/m3"), 0.1); } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java index 755f6a43f8..7d0b85ad56 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/DifferentialLiberationTest.java @@ -1,18 +1,68 @@ package neqsim.PVTsimulation.simulation; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import neqsim.thermo.FluidCreator; import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; public class DifferentialLiberationTest { - @Test void testRunCalc() { - SystemInterface tempSystem = FluidCreator.create("black oil"); + SystemInterface tempSystem = new SystemSrkEos(273.15 + 83.5, 350.0); + tempSystem.addComponent("nitrogen", 0.39); + tempSystem.addComponent("CO2", 0.3); + tempSystem.addComponent("methane", 40.2); + tempSystem.addComponent("ethane", 7.61); + tempSystem.addComponent("propane", 7.95); + tempSystem.addComponent("i-butane", 1.19); + tempSystem.addComponent("n-butane", 4.08); + tempSystem.addComponent("i-pentane", 1.39); + tempSystem.addComponent("n-pentane", 2.15); + tempSystem.addComponent("n-hexane", 2.79); + tempSystem.addTBPfraction("C7", 4.28, 95 / 1000.0, 0.729); + tempSystem.addTBPfraction("C8", 4.31, 106 / 1000.0, 0.749); + tempSystem.addTBPfraction("C9", 3.08, 121 / 1000.0, 0.77); + tempSystem.addTBPfraction("C10", 2.47, 135 / 1000.0, 0.786); + tempSystem.addTBPfraction("C11", 1.91, 148 / 1000.0, 0.792); + tempSystem.addTBPfraction("C12", 1.69, 161 / 1000.0, 0.804); + tempSystem.addTBPfraction("C13", 1.59, 175 / 1000.0, 0.819); + tempSystem.addTBPfraction("C14", 1.22, 196 / 1000.0, 0.833); + tempSystem.addTBPfraction("C15", 1.25, 206 / 1000.0, 0.836); + tempSystem.addTBPfraction("C16", 1.0, 225 / 1000.0, 0.843); + tempSystem.addTBPfraction("C17", 0.99, 236 / 1000.0, 0.840); + tempSystem.addTBPfraction("C18", 0.92, 245 / 1000.0, 0.846); + tempSystem.addTBPfraction("C19", 0.6, 265 / 1000.0, 0.857); + tempSystem.addPlusFraction("C20", 6.64, 453 / 1000.0, 0.918); + tempSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + tempSystem.getCharacterization().characterisePlusFraction(); + tempSystem.setMixingRule("classic"); + + SimulationInterface satPresSim = new SaturationPressure(tempSystem); + satPresSim.setTemperature(97.5, "C"); + satPresSim.run(); + assertEquals(193.24093437194824, satPresSim.getThermoSystem().getPressure(), 0.1); + // tempSystem.prettyPrint(); + + double[] pressures = new double[] {351.4, 323.2, 301.5, 275.9, 250.1, 226.1, 205.9, 179.1, + 154.6, 132.1, 109.0, 78.6, 53.6, 22.0, 1.0}; + DifferentialLiberation differentialLiberation = new DifferentialLiberation(tempSystem); + differentialLiberation.setPressures(pressures); + differentialLiberation.setTemperature(97.5, "C"); + differentialLiberation.runCalc(); - DifferentialLiberation CVDsim = new DifferentialLiberation(tempSystem); - CVDsim.setPressures(new double[] {300.0, 250.0, 200.0, 150.0, 100.0, 70.0, 50.0, 30.0, 10.0}); - CVDsim.setTemperature(310.0); - CVDsim.runCalc(); + assertEquals(1.689644811955, differentialLiberation.getBo()[0], 0.001); + assertEquals(212.71942595049242 + , differentialLiberation.getRs()[0], 0.001); + assertEquals(677.5970918499921 + , differentialLiberation.getOilDensity()[0], 0.001); + assertEquals(1.7616805, differentialLiberation.getBo()[pressures.length - 9], 0.001); + assertEquals(1.3111545517, differentialLiberation.getBo()[pressures.length - 2], 0.001); + assertEquals(55.10252632079461 + , differentialLiberation.getRs()[pressures.length - 2], 0.001); + assertEquals(0.0556167850, differentialLiberation.getBg()[pressures.length - 2], 0.001); + assertEquals(1.0533007759, differentialLiberation.getBo()[pressures.length - 1], 0.001); + assertEquals(0.0, differentialLiberation.getRs()[pressures.length - 1], 0.001); + assertEquals(805.6468027140055 + , differentialLiberation.getOilDensity()[pressures.length - 1], 0.001); } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 b/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 new file mode 100644 index 0000000000..404313f4a6 --- /dev/null +++ b/src/test/java/neqsim/PVTsimulation/simulation/EclipseModel.e300 @@ -0,0 +1,409 @@ +-- 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 + 40.00000 15.00000 / + +-- 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 + 1.28109672e-02 + 4.07891587e-03 + 7.81998245e-01 + 8.05686771e-02 + 5.63365242e-02 + 6.57958977e-03 + 1.95042684e-02 + 5.10039805e-03 + 7.18322821e-03 + 6.77963664e-03 + 6.77524344e-03 + 5.42636362e-03 + 2.90020939e-03 + 2.43723835e-03 + 1.16773808e-03 + 2.42607452e-04 + 9.72372911e-05 + 1.20626522e-05 + 7.21492804e-07 + 6.58127085e-08 + 8.26216983e-09 + 5.38317669e-08 / +-- 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 / diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java index f72e964ae9..6f887368cc 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/SaturationPressureTest.java @@ -10,27 +10,26 @@ class SaturationPressureTest extends neqsim.NeqSimTest { @BeforeAll static void setUpBeforeClass() throws Exception {} - @Test void testCalcSaturationPressure() { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 10.0); - tempSystem.addComponent("nitrogen", 0.34); - tempSystem.addComponent("CO2", 0.59); - tempSystem.addComponent("methane", 87.42); - tempSystem.addComponent("ethane", 3.02); - tempSystem.addComponent("propane", 4.31); - tempSystem.addComponent("i-butane", 0.93); - tempSystem.addComponent("n-butane", 1.71); - tempSystem.addComponent("i-pentane", 0.74); - tempSystem.addComponent("n-pentane", 0.85); - tempSystem.addComponent("n-hexane", 0.38); - tempSystem.addTBPfraction("C7", 0.05, 109.00 / 1000.0, 0.6912); - tempSystem.addTBPfraction("C8", 0.069, 120.20 / 1000.0, 0.7255); - tempSystem.addTBPfraction("C9", 0.014, 129.5 / 1000.0, 0.7454); - tempSystem.addTBPfraction("C10", 0.0078, 135.3 / 1000.0, 0.7864); - tempSystem.setMixingRule(2); - SimulationInterface satPresSim = new SaturationPressure(tempSystem); - satPresSim.run(); - assertEquals(satPresSim.getThermoSystem().getPressure(), 122.28338813781738, 0.1); - } + SystemInterface tempSystem = new SystemSrkEos(273.15 + 20, 10.0); + tempSystem.addComponent("nitrogen", 0.34); + tempSystem.addComponent("CO2", 0.59); + tempSystem.addComponent("methane", 87.42); + tempSystem.addComponent("ethane", 3.02); + tempSystem.addComponent("propane", 4.31); + tempSystem.addComponent("i-butane", 0.93); + tempSystem.addComponent("n-butane", 1.71); + tempSystem.addComponent("i-pentane", 0.74); + tempSystem.addComponent("n-pentane", 0.85); + tempSystem.addComponent("n-hexane", 0.38); + tempSystem.addTBPfraction("C7", 0.05, 109.00 / 1000.0, 0.6912); + tempSystem.addTBPfraction("C8", 0.069, 120.20 / 1000.0, 0.7255); + tempSystem.addTBPfraction("C9", 0.014, 129.5 / 1000.0, 0.7454); + tempSystem.addTBPfraction("C10", 0.0078, 135.3 / 1000.0, 0.7864); + tempSystem.setMixingRule(2); + SimulationInterface satPresSim = new SaturationPressure(tempSystem); + satPresSim.run(); + assertEquals(satPresSim.getThermoSystem().getPressure(), 126.1631355285644, 0.1); + } } diff --git a/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java b/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java index f80fce67b8..dd4f568883 100644 --- a/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java +++ b/src/test/java/neqsim/PVTsimulation/simulation/SaturationTemperatureTest.java @@ -1,51 +1,108 @@ package neqsim.PVTsimulation.simulation; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermo.system.SystemUMRPRUMCEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; /** * @author ESOL - * */ class SaturationTemperatureTest extends neqsim.NeqSimTest { - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception {} + /** + * @throws java.lang.Exception + */ + @BeforeAll + static void setUpBeforeClass() throws Exception {} - /** - * Test method for - * {@link neqsim.PVTsimulation.simulation.SaturationTemperature#calcSaturationTemperature()}. - */ - @Test - void testCalcSaturationTemperature() { - SystemInterface tempSystem = new SystemSrkEos(273.15 + 220, 60.0); - tempSystem.addComponent("nitrogen", 0.34); - tempSystem.addComponent("CO2", 3.59); - tempSystem.addComponent("methane", 67.42); - tempSystem.addComponent("ethane", 9.02); - tempSystem.addComponent("propane", 4.31); - tempSystem.addComponent("i-butane", 0.93); - tempSystem.addComponent("n-butane", 1.71); - tempSystem.addComponent("i-pentane", 0.74); - tempSystem.addComponent("n-pentane", 0.85); - tempSystem.addComponent("n-hexane", 0.38); - tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912); - tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255); - tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454); - tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864); - // tempSystem.createDatabase(true); - tempSystem.setMixingRule(2); // "HV", "UNIFAC_UMRPRU"); - tempSystem.init(0); - tempSystem.init(1); - // tempSystem.saveFluid(928); + /** + * Test method for + * {@link neqsim.PVTsimulation.simulation.SaturationTemperature#calcSaturationTemperature()}. + */ + @Test + void testCalcSaturationTemperature() { + SystemInterface tempSystem = new SystemSrkEos(273.15 + 220, 60.0); + tempSystem.addComponent("nitrogen", 0.34); + tempSystem.addComponent("CO2", 3.59); + tempSystem.addComponent("methane", 67.42); + tempSystem.addComponent("ethane", 9.02); + tempSystem.addComponent("propane", 4.31); + tempSystem.addComponent("i-butane", 0.93); + tempSystem.addComponent("n-butane", 1.71); + tempSystem.addComponent("i-pentane", 0.74); + tempSystem.addComponent("n-pentane", 0.85); + tempSystem.addComponent("n-hexane", 0.38); + tempSystem.addTBPfraction("C7", 0.5, 109.00 / 1000.0, 0.6912); + tempSystem.addTBPfraction("C8", 0.69, 120.20 / 1000.0, 0.7255); + tempSystem.addTBPfraction("C9", 0.14, 129.5 / 1000.0, 0.7454); + tempSystem.addTBPfraction("C10", 0.08, 135.3 / 1000.0, 0.7864); + // tempSystem.createDatabase(true); + tempSystem.setMixingRule(2); // "HV", "UNIFAC_UMRPRU"); + tempSystem.init(0); + tempSystem.init(1); + // tempSystem.saveFluid(928); - SimulationInterface satPresSim = new SaturationTemperature(tempSystem); - satPresSim.run(); - assertEquals(tempSystem.getTemperature(), 380.3071922, 0.1); + SimulationInterface satPresSim = new SaturationTemperature(tempSystem); + satPresSim.run(); + assertEquals(tempSystem.getTemperature(), 380.127567672, 0.1); + } + + /** + *

+ * 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 names = Element.getAllElementComponentNames(); diff --git a/src/test/java/neqsim/thermo/characterization/CharacteriseTest.java b/src/test/java/neqsim/thermo/characterization/CharacteriseTest.java index db7e836147..0273b5d776 100644 --- a/src/test/java/neqsim/thermo/characterization/CharacteriseTest.java +++ b/src/test/java/neqsim/thermo/characterization/CharacteriseTest.java @@ -4,8 +4,9 @@ import org.junit.jupiter.api.Test; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; -public class CharacteriseTest extends neqsim.NeqSimTest{ +public class CharacteriseTest extends neqsim.NeqSimTest { static SystemInterface thermoSystem = null; @Test @@ -18,7 +19,7 @@ void testCharacterisePlusFraction() { thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); thermoSystem.addTBPfraction("C8", 1.0, 120.0 / 1000.0, 0.76); thermoSystem.addTBPfraction("C9", 1.0, 140.0 / 1000.0, 0.79); - thermoSystem.addPlusFraction("C10", 11.0, 290.0/1000.0, 0.82); + thermoSystem.addPlusFraction("C10", 11.0, 290.0 / 1000.0, 0.82); thermoSystem.getCharacterization().setLumpingModel("no lumping"); thermoSystem.getCharacterization().characterisePlusFraction(); // logger.info("number of components " + thermoSystem.getNumberOfComponents()); @@ -32,11 +33,35 @@ void testCharacterisePlusFraction() { thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); thermoSystem.addTBPfraction("C8", 1.0, 120.0 / 1000.0, 0.76); thermoSystem.addTBPfraction("C9", 1.0, 140.0 / 1000.0, 0.79); - thermoSystem.addPlusFraction("C10", 11.0, 290.0/1000.0, 0.82); - thermoSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + thermoSystem.addPlusFraction("C10", 11.0, 290.0 / 1000.0, 0.82); + // thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(6); + // thermoSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); + thermoSystem.getCharacterization().setLumpingModel("no lumping"); + thermoSystem.getCharacterization().characterisePlusFraction(); + // assertEquals(15, thermoSystem.getNumberOfComponents()); + // thermoSystem.prettyPrint(); + } + + @Test + void testCharacterisePlusFractionGAMMA() { + thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addPlusFraction("C10", 11.0, 290.0 / 1000.0, 0.82); + thermoSystem.getCharacterization().setPlusFractionModel("Whitson Gamma Model"); thermoSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); + thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(15); thermoSystem.getCharacterization().characterisePlusFraction(); - assertEquals(15, thermoSystem.getNumberOfComponents()); + // logger.info("number of components " + thermoSystem.getNumberOfComponents()); + // assertEquals(86, thermoSystem.getNumberOfComponents()); + // System.out.println(thermoSystem.getComponent("C1-2_PC").getz()); + // thermoSystem.prettyPrint(); + + thermoSystem.setPressure(1, "bara"); + + ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem); + thermoOps.TPflash(); + thermoSystem.initProperties(); + // thermoSystem.prettyPrint(); } } diff --git a/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java b/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java new file mode 100644 index 0000000000..53a00e5c43 --- /dev/null +++ b/src/test/java/neqsim/thermo/characterization/PlusFractionModelTest.java @@ -0,0 +1,147 @@ +package neqsim.thermo.characterization; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.characterization.PlusFractionModel.WhitsonGammaModel; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class PlusFractionModelTest { + + @Test + void testPedersenPlusModelCharacterization() { + SystemInterface thermoSystem = null; + thermoSystem = new SystemSrkEos(298.0, 10.0); + + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.addComponent("propane", 1.0); + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + // adding oil components + + thermoSystem.addTBPfraction("C6", 1.0, 90.0 / 1000.0, 0.7); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + thermoSystem.addTBPfraction("C8", 1.0, 120.0 / 1000.0, 0.76); + thermoSystem.addTBPfraction("C9", 1.0, 140.0 / 1000.0, 0.79); + thermoSystem.addPlusFraction("C10", 11.0, 290.0 / 1000.0, 0.82); + + /* + * Specify that the Pedersen plus fraction model will be used for characterizing the plus + * component + */ + thermoSystem.getCharacterization().setPlusFractionModel("Pedersen"); + thermoSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); // this is default + // lumping model in + // neqsim. Needs to be + // set before calling + // characterisePlusFraction() + + thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(9); // specif + // numer + // of + // lumped + // components + // (C6-C80 + // components) + thermoSystem.getCharacterization().characterisePlusFraction(); + assertEquals(17, thermoSystem.getNumberOfComponents()); + + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + // thermoSystem.prettyPrint(); + assertEquals(0.76652495787, thermoSystem.getBeta(), 1e-4); + } + + @Test + void testPedersenHeavyOilPlusModelCharacterization() { + SystemInterface thermoSystem = null; + thermoSystem = new SystemSrkEos(298.0, 10.0); + + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.addComponent("propane", 1.0); + + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); // this need to be set before + // adding oil components + + thermoSystem.addTBPfraction("C6", 1.0, 90.0 / 1000.0, 0.7); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + thermoSystem.addTBPfraction("C8", 1.0, 120.0 / 1000.0, 0.76); + thermoSystem.addTBPfraction("C9", 1.0, 140.0 / 1000.0, 0.79); + thermoSystem.addPlusFraction("C10", 11.0, 590.0 / 1000.0, 0.90); + + /* + * Specify that the Pedersen heavy oil plus fraction model will be used for characterizing the + * plus component + */ + thermoSystem.getCharacterization().setPlusFractionModel("Pedersen Heavy Oil"); + + thermoSystem.getCharacterization().setLumpingModel("PVTlumpingModel"); // this is default + // lumping model in + // neqsim. Needs to be + // set before calling + // characterisePlusFraction() + thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(3); + thermoSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(8); + // specify + // numer + // of + // lumped + // components + // (C6-C80 + // components) + thermoSystem.getCharacterization().characterisePlusFraction(); + assertEquals(12, thermoSystem.getNumberOfComponents()); + + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + // thermoSystem.prettyPrint(); + assertEquals(0.767272255056255, thermoSystem.getBeta(), 1e-4); + } + + @Test + void testGammaModelCharacterization() { + SystemInterface thermoSystem = null; + thermoSystem = new SystemSrkEos(298.0, 10.0); + + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 1.0); + thermoSystem.addComponent("propane", 1.0); + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); + + thermoSystem.addTBPfraction("C6", 1.0, 90.0 / 1000.0, 0.7); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + thermoSystem.addTBPfraction("C8", 1.0, 120.0 / 1000.0, 0.76); + thermoSystem.addTBPfraction("C9", 1.0, 140.0 / 1000.0, 0.79); + thermoSystem.addPlusFraction("C10", 11.0, 290.0 / 1000.0, 0.82); + + thermoSystem.getCharacterization().setPlusFractionModel("Whitson Gamma Model"); + + // Add how to set parameters in the gamma model here + + thermoSystem.getCharacterization().getLumpingModel().setNumberOfPseudoComponents(12); + + thermoSystem.getCharacterization().characterisePlusFraction(); + thermoSystem.setMixingRule("classic"); + assertEquals(16, thermoSystem.getNumberOfComponents()); + + ThermodynamicOperations ops = new ThermodynamicOperations(thermoSystem); + ops.TPflash(); + // thermoSystem.prettyPrint(); + assertEquals(0.746485111, thermoSystem.getBeta(), 1e-4); + + // illustration of how to set parameters for the gamma model + ((WhitsonGammaModel) thermoSystem.getCharacterization().getPlusFractionModel()) + .setGammaParameters(1.0, 90); + double shape = ((WhitsonGammaModel) thermoSystem.getCharacterization().getPlusFractionModel()) + .getGammaParameters()[0]; + double minMW = ((WhitsonGammaModel) thermoSystem.getCharacterization().getPlusFractionModel()) + .getGammaParameters()[1]; + assertEquals(90.0, minMW, 1e-4); + } +} diff --git a/src/test/java/neqsim/thermo/characterization/TBPfractionModelTest.java b/src/test/java/neqsim/thermo/characterization/TBPfractionModelTest.java new file mode 100644 index 0000000000..6d9d2b9773 --- /dev/null +++ b/src/test/java/neqsim/thermo/characterization/TBPfractionModelTest.java @@ -0,0 +1,56 @@ +package neqsim.thermo.characterization; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemPrEos; +import neqsim.thermo.system.SystemSrkEos; + +public class TBPfractionModelTest { + @Test + void testTwuModel() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.getCharacterization().setTBPModel("Twu"); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + assertEquals(536.173400, thermoSystem.getComponent(0).getTC(), 1e-3); + assertEquals(26.52357312690, thermoSystem.getComponent(0).getPC(), 1e-3); + assertEquals(0.56001213933, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3); + assertEquals(437.335493, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3); + } + + @Test + void testLeeKeslerModel() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.getCharacterization().setTBPModel("Lee-Kesler"); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + assertEquals(562.4229803010662, thermoSystem.getComponent(0).getTC(), 1e-3); + assertEquals(28.322987349048354, thermoSystem.getComponent(0).getPC(), 1e-3); + assertEquals(0.3509842412742902, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3); + assertEquals(427.99744457199, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3); + } + + @Test + void testPedersenSRKModel() { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.getCharacterization().setTBPModel("PedersenSRK"); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + assertEquals(281.1685637, thermoSystem.getComponent(0).getTC() - 273.15, 1e-3); + assertEquals(26.341015469211726 + , thermoSystem.getComponent(0).getPC(), 1e-3); + assertEquals(0.508241, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3); + assertEquals(426.46717439, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3); + assertEquals(122.93500, thermoSystem.getComponent(0).getNormalBoilingPoint("C"), 1e-3); + } + + @Test + void testPedersenPRModel() { + SystemInterface thermoSystem = new SystemPrEos(298.0, 10.0); + thermoSystem.getCharacterization().setTBPModel("PedersenPR"); + thermoSystem.addTBPfraction("C7", 1.0, 110.0 / 1000.0, 0.73); + assertEquals(560.546, thermoSystem.getComponent(0).getTC(), 1e-3); + assertEquals(26.16934428134274, thermoSystem.getComponent(0).getPC(), 1e-3); + assertEquals(0.3838836222383, thermoSystem.getComponent(0).getAcentricFactor(), 1e-3); + assertEquals(444.07282144, thermoSystem.getComponent(0).getCriticalVolume(), 1e-3); + assertEquals(122.93500, thermoSystem.getComponent(0).getNormalBoilingPoint("C"), 1e-3); + } +} diff --git a/src/test/java/neqsim/thermo/component/AmmoniaTest.java b/src/test/java/neqsim/thermo/component/AmmoniaTest.java index 6e35cc548c..1c8ea75155 100644 --- a/src/test/java/neqsim/thermo/component/AmmoniaTest.java +++ b/src/test/java/neqsim/thermo/component/AmmoniaTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.system.SystemInterface; import neqsim.thermo.system.SystemSrkEos; import neqsim.thermodynamicOperations.ThermodynamicOperations; @@ -15,7 +16,7 @@ public class AmmoniaTest extends neqsim.NeqSimTest { */ @BeforeAll static void setUpBeforeClass() throws Exception { - thermoSystem = new SystemSrkEos(298.0, 1.01325); + thermoSystem = new SystemSrkEos(298.0, ThermodynamicConstantsInterface.referencePressure); thermoSystem.addComponent("ammonia", 1.0); thermoSystem.init(0); } diff --git a/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java b/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java index 1e0e256f34..97c69fefdb 100644 --- a/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java +++ b/src/test/java/neqsim/thermo/component/ComponentHydrateGFTest.java @@ -12,7 +12,6 @@ /** * @author ESOL - * */ class ComponentHydrateGFTest extends neqsim.NeqSimTest { static Logger logger = LogManager.getLogger(ComponentHydrateGFTest.class); diff --git a/src/test/java/neqsim/thermo/component/NewComponentTest.java b/src/test/java/neqsim/thermo/component/NewComponentTest.java index 28ed9e156b..4fbad4dfa9 100644 --- a/src/test/java/neqsim/thermo/component/NewComponentTest.java +++ b/src/test/java/neqsim/thermo/component/NewComponentTest.java @@ -4,8 +4,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import neqsim.thermo.ThermodynamicConstantsInterface; import neqsim.thermo.phase.PhaseSrkEos; import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemPrEos; import neqsim.thermo.system.SystemSrkEos; public class NewComponentTest extends neqsim.NeqSimTest { @@ -24,7 +26,7 @@ public void createComponentTest() { p.addComponent("", 0, 0, 0); }); Assertions.assertEquals( - "neqsim.util.exception.InvalidInputException: ComponentSrk:createComponent - Input component_name can not be empty", + "neqsim.util.exception.InvalidInputException: PhaseSrkEos:addcomponent - Input name can not be empty.", thrown.getMessage()); RuntimeException thrown_2 = Assertions.assertThrows(RuntimeException.class, () -> { @@ -33,14 +35,84 @@ public void createComponentTest() { Assertions.assertEquals( "neqsim.util.exception.InvalidInputException: PhaseSrkEos:addcomponent - Input name can not be null", thrown_2.getMessage()); + + RuntimeException thrown_3 = Assertions.assertThrows(RuntimeException.class, () -> { + p.addComponent("ethane", 0, 0, -1); + }); + Assertions.assertEquals( + "neqsim.util.exception.InvalidInputException: PhaseSrkEos:addComponent - Input compNumber must be valid index, i.e., between 0 and 100.", + thrown_3.getMessage()); + + p.addComponent("ethane", 0, 0, 0); + RuntimeException thrown_4 = Assertions.assertThrows(RuntimeException.class, () -> { + p.addComponent("methane", 0, 0, 0); + }); + Assertions.assertEquals( + "neqsim.util.exception.InvalidInputException: PhaseSrkEos:addComponent - Input compNumber number is already in use.", + thrown_4.getMessage()); } @Test public void newComponentTest() { - thermoSystem = new SystemSrkEos(298.0, 1.01325); + thermoSystem = new SystemSrkEos(298.0, ThermodynamicConstantsInterface.referencePressure); thermoSystem.addComponent("ammonia", 1.0); thermoSystem.init(0); assertEquals(0.01703052, thermoSystem.getMolarMass("kg/mol"), 0.01); assertEquals(405.4, thermoSystem.getComponent(0).getTC(), 0.01); } + + @Test + public void newComponentIsoButeneTest() { + thermoSystem = new SystemSrkEos(298.0, ThermodynamicConstantsInterface.referencePressure); + thermoSystem.addComponent("iso-butene", 1.0); + thermoSystem.init(0); + assertEquals(56.10632e-3, thermoSystem.getMolarMass("kg/mol"), 0.01); + } + + @Test + public void setTCPC_test() { + thermoSystem = new SystemSrkEos(298.0, ThermodynamicConstantsInterface.referencePressure); + thermoSystem.addComponent("iso-butene", 1.0); + thermoSystem.init(0); + thermoSystem.getPhase(0).getComponent(0).setTC(190.0); + assertEquals(190.0, thermoSystem.getPhase(0).getComponent(0).getTC(), 0.01); + + thermoSystem.getPhase(0).getComponent(0).setTC(190.0, "R"); + assertEquals(190.0, thermoSystem.getPhase(0).getComponent(0).getTC("R"), 0.01); + + thermoSystem.getPhase(0).getComponent(0).setTC(190.0, "R"); + assertEquals(105.55555, thermoSystem.getPhase(0).getComponent(0).getTC("K"), 0.01); + + thermoSystem.getPhase(0).getComponent(0).setPC(1290.0, "psia"); + assertEquals(1290.0, thermoSystem.getPhase(0).getComponent(0).getPC("psia"), 0.01); + assertEquals(88.9423690, thermoSystem.getPhase(0).getComponent(0).getPC("bara"), 0.01); + + thermoSystem.getPhase(0).getComponent(0).setMolarMass(0.090); + assertEquals(0.09, thermoSystem.getPhase(0).getComponent(0).getMolarMass(), 0.01); + assertEquals(90.0, thermoSystem.getPhase(0).getComponent(0).getMolarMass("gr/mol"), 0.01); + assertEquals(90.0, thermoSystem.getPhase(0).getComponent(0).getMolarMass("lbm/lbmol"), 0.01); + + thermoSystem.getPhase(0).getComponent(0).setMolarMass(85.0, "lbm/lbmol"); + assertEquals(85.0, thermoSystem.getPhase(0).getComponent(0).getMolarMass("gr/mol"), 0.01); + } + + @Test + public void volTransTtest() { + thermoSystem = new SystemPrEos(318.0, 20.01325); + thermoSystem.addComponent("CO2", 1.0); + thermoSystem.init(0); + thermoSystem.init(1); + thermoSystem.initPhysicalProperties("density"); + assertEquals(36.68212551, thermoSystem.getDensity("kg/m3"), 0.01); + + thermoSystem.getComponent("CO2").setVolumeCorrectionT(0.2); + + thermoSystem.initPhysicalProperties("density"); + assertEquals(37.6425616, thermoSystem.getDensity("kg/m3"), 0.01); + + thermoSystem.getComponent("CO2").setRacketZ(0.3); + + thermoSystem.initPhysicalProperties("density"); + assertEquals(37.557573, thermoSystem.getDensity("kg/m3"), 0.01); + } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseBWRSEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseBWRSEosTest.java index 5dc3770d56..3671e40d39 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseBWRSEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseBWRSEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseCSPsrkEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseCSPsrkEosTest.java index 4b9958fdf5..98b03d6cbe 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseCSPsrkEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseCSPsrkEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseDesmukhMatherTest.java b/src/test/java/neqsim/thermo/phase/PhaseDesmukhMatherTest.java index 496aa9df6c..e2d9263bcc 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseDesmukhMatherTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseDesmukhMatherTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseDuanSunTest.java b/src/test/java/neqsim/thermo/phase/PhaseDuanSunTest.java index d7971df15c..2d233b9829 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseDuanSunTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseDuanSunTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAOldTest.java b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAOldTest.java index 040b9f68eb..e520e086f2 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAOldTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAOldTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPATest.java b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPATest.java index 4e197f06ce..e25f080f82 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPATest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPATest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoilTest.java b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoilTest.java index c2e29a828f..ee8d32855f 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoilTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseElectrolyteCPAstatoilTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGENRTLTest.java b/src/test/java/neqsim/thermo/phase/PhaseGENRTLTest.java index 617c69c013..7301e653fe 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGENRTLTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGENRTLTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHVTest.java b/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHVTest.java index 2ea43070a8..8cc24b389f 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHVTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedHVTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWSTest.java b/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWSTest.java index ce93b42f5b..a3250c82da 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWSTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGENRTLmodifiedWSTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacPSRKTest.java b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacPSRKTest.java index 68fec9d31a..13a20df50e 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacPSRKTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacPSRKTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacTest.java b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacTest.java index d90a2fc322..d3062a9e2f 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRUTest.java b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRUTest.java index b269db4fbb..430badb6e2 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRUTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGEUnifacUMRPRUTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGEUniquacTest.java b/src/test/java/neqsim/thermo/phase/PhaseGEUniquacTest.java index 9d109f4a3f..991efd9076 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGEUniquacTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGEUniquacTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseGEWilsonTest.java b/src/test/java/neqsim/thermo/phase/PhaseGEWilsonTest.java index 1ac1808e8e..e5fe86d5e3 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseGEWilsonTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseGEWilsonTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseHydrateTest.java b/src/test/java/neqsim/thermo/phase/PhaseHydrateTest.java index f4a7814ffd..7964934a99 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseHydrateTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseHydrateTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseKentEisenbergTest.java b/src/test/java/neqsim/thermo/phase/PhaseKentEisenbergTest.java index df311e2500..a2d66172ed 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseKentEisenbergTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseKentEisenbergTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004Test.java b/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004Test.java index 8ccdf2b151..2b95a0e5e2 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004Test.java +++ b/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosMod2004Test.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosTest.java index 125383b831..9d65b2f1a9 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseModifiedFurstElectrolyteEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhasePCSAFTRahmatTest.java b/src/test/java/neqsim/thermo/phase/PhasePCSAFTRahmatTest.java index fc8c74a00d..1485258f1a 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePCSAFTRahmatTest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePCSAFTRahmatTest.java @@ -1,25 +1,398 @@ package neqsim.thermo.phase; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemPCSAFT; public class PhasePCSAFTRahmatTest { static PhasePCSAFTRahmat p; + static PhasePCSAFTRahmat p2; + static SystemPCSAFT testSystem; @BeforeEach void setUp() { - p = new PhasePCSAFTRahmat(); + testSystem = new SystemPCSAFT(150.0, 10.0); + testSystem.addComponent("methane", 100.0); + testSystem.addComponent("n-hexane", 1000.0001); + testSystem.setMixingRule(1); + testSystem.createDatabase(true); + testSystem.init(0); + testSystem.init(3); + + p = (PhasePCSAFTRahmat) testSystem.getPhase(0); } @Test void testAddcomponent() { - Assertions.assertEquals(0, p.getNumberOfComponents()); + p2 = new PhasePCSAFTRahmat(); + + Assertions.assertEquals(0, p2.getNumberOfComponents()); + + p2.addComponent("ethane", 0, 0, 0); + Assertions.assertEquals(1, p2.getNumberOfComponents()); + + p2.addComponent("methane", 0, 0, 1); + Assertions.assertEquals(2, p2.getNumberOfComponents()); + } + + @Test + void testF_DISP1_SAFT() { + double value = p.F_DISP1_SAFT(); + assertEquals(-2656.5606478696354, value); + } + + @Test + void testF_DISP2_SAFT() { + double value = p.F_DISP2_SAFT(); + assertEquals(-1929.2979666587207, value); + } + + @Test + void testF_HC_SAFT() { + double value = p.F_HC_SAFT(); + assertEquals(501.428925899878, value); + } + + @Test + void testCalcF1dispI1() { + double value = p.calcF1dispI1(); + assertEquals(0.7447173911719432, value); + } + + @Test + void testCalcF1dispI1dN() { + double value = p.calcF1dispI1dN(); + assertEquals(0.8885712115632445, value); + } + + @Test + void testCalcF1dispI1dNdN() { + double value = p.calcF1dispI1dNdN(); + assertEquals(-0.3783996289387171, value); + } + + @Test + void testCalcF1dispI1dNdNdN() { + double value = p.calcF1dispI1dNdNdN(); + assertEquals(-19.504810659834753, value); + } + + @Test + void testCalcF1dispI1dm() { + double value = p.calcF1dispI1dm(); + assertEquals(-0.04871346995167202, value); + } + + @Test + void testCalcF1dispSumTerm() { + double value = p.calcF1dispSumTerm(); + assertEquals(7.022486947548597E-28, value); + } + + @Test + void testCalcF2dispI2() { + double value = p.calcF2dispI2(); + assertEquals(0.5114103946892024, value); + } + + @Test + void testCalcF2dispI2dN() { + double value = p.calcF2dispI2dN(); + assertEquals(2.075396158614915, value); + } + + @Test + void testCalcF2dispI2dNdN() { + double value = p.calcF2dispI2dNdN(); + assertEquals(-10.085652314796853, value); + } + + @Test + void testCalcF2dispI2dNdNdN() { + double value = p.calcF2dispI2dNdNdN(); + assertEquals(53.904528812197945, value); + } + + @Test + void testCalcF2dispI2dm() { + double value = p.calcF2dispI2dm(); + assertEquals(-0.05282097926626965, value); + } + + @Test + void testCalcF2dispSumTerm() { + double value = p.calcF2dispSumTerm(); + assertEquals(1.0974418484311756E-27, value); + } + + @Test + void testCalcF2dispZHC() { + double value = p.calcF2dispZHC(); + assertEquals(0.47149436306641834, value); + } - p.addComponent("ethane", 0, 0, 0); - Assertions.assertEquals(1, p.getNumberOfComponents()); + @Test + void testCalcF2dispZHCdN() { + double value = p.calcF2dispZHCdN(); + assertEquals(-5.447711889103666, value); + } + + @Test + void testCalcF2dispZHCdNdN() { + double value = p.calcF2dispZHCdNdN(); + assertEquals(75.24049982033125, value); + } + + @Test + void testCalcF2dispZHCdNdNdN() { + double value = p.calcF2dispZHCdNdNdN(); + assertEquals(279935.2725213402, value, 0.001); + } + + @Test + void testCalcF2dispZHCdm() { + double value = p.calcF2dispZHCdm(); + assertEquals(-0.06098259714, value, 0.001); + } + + @Test + void testCalcdF1dispI1dT() { + double value = p.calcdF1dispI1dT(); + assertEquals(-2.467132676347459E-24, value, 1e-20); + } - p.addComponent("methane", 0, 0, 0); - Assertions.assertEquals(2, p.getNumberOfComponents()); + @Test + void testCalcdF1dispSumTermdT() { + double value = p.calcdF1dispSumTermdT(); + assertEquals(-4.6816579650323984E-30, value); + } + + @Test + void testCalcdF2dispI2dT() { + double value = p.calcdF2dispI2dT(); + assertEquals(-5.762371785911064E-24, value); + } + + @Test + void testCalcdF2dispSumTermdT() { + double value = p.calcdF2dispSumTermdT(); + assertEquals(-1.4632557979082342E-29, value); + } + + @Test + void testCalcdF2dispZHCdT() { + double value = p.calcdF2dispZHCdT(); + assertEquals(1.51244510048084E-23, value); + } + + @Test + void testCalcdSAFT() { + double value = p.calcdSAFT(); + assertEquals(1.5637585192262192E-28, value); } + + @Test + void testCalcdmeanSAFT() { + double value = p.calcdmeanSAFT(); + assertEquals(3.7908367828047096E-10, value); + } + + @Test + void testCalcmSAFT() { + double value = p.calcmSAFT(); + assertEquals(2.8705454715504115, value); + } + + @Test + void testCalcmdSAFT() { + double value = p.calcmdSAFT(); + assertEquals(1.5637585192262194E-28, value); + } + + @Test + void testCalcmmin1SAFT() { + double value = p.calcmmin1SAFT(); + assertEquals(1.8705454715504115, value); + } + + @Test + void testDF_DISP1_SAFTdT() {} + + @Test + void testDF_DISP1_SAFTdV() {} + + @Test + void testDF_DISP1_SAFTdVdV() {} + + @Test + void testDF_DISP1_SAFTdVdVdV() {} + + @Test + void testDF_DISP2_SAFTdT() {} + + @Test + void testDF_DISP2_SAFTdV() {} + + @Test + void testDF_DISP2_SAFTdVdV() {} + + @Test + void testDF_DISP2_SAFTdVdVdV() {} + + @Test + void testDF_HC_SAFTdT() {} + + @Test + void testDF_HC_SAFTdV() {} + + @Test + void testDF_HC_SAFTdVdV() {} + + @Test + void testDF_HC_SAFTdVdVdV() {} + + @Test + void testDFdT() {} + + @Test + void testDFdV() {} + + @Test + void testDFdVdV() {} + + @Test + void testDFdVdVdV() {} + + @Test + void testGetAHSSAFT() {} + + @Test + void testGetDSAFT() {} + + @Test + void testGetDgHSSAFTdN() {} + + @Test + void testGetDmeanSAFT() {} + + @Test + void testGetDnSAFTdV() {} + + @Test + void testGetF() {} + + @Test + void testGetF1dispI1() {} + + @Test + void testGetF1dispSumTerm() {} + + @Test + void testGetF1dispVolTerm() {} + + @Test + void testGetF2dispI2() {} + + @Test + void testGetF2dispSumTerm() {} + + @Test + void testGetF2dispZHC() {} + + @Test + void testGetF2dispZHCdN() {} + + @Test + void testGetF2dispZHCdm() {} + + @Test + void testGetGhsSAFT() {} + + @Test + void testGetMmin1SAFT() {} + + @Test + void testGetNSAFT() {} + + @Test + void testGetNmSAFT() {} + + @Test + void testGetVolumeSAFT() {} + + @Test + void testGetaSAFT() {} + + @Test + void testGetaSAFTdm() {} + + @Test + void testGetdDSAFTdT() {} + + @Test + void testGetmSAFT() {} + + @Test + void testGetmdSAFT() {} + + @Test + void testInit() { + p.init(); + } + + @Test + void testMolarVolume() {} + + @Test + void testSetAHSSAFT() {} + + @Test + void testSetDSAFT() {} + + @Test + void testSetDgHSSAFTdN() {} + + @Test + void testSetDmeanSAFT() {} + + @Test + void testSetDnSAFTdV() {} + + @Test + void testSetF1dispVolTerm() {} + + @Test + void testSetF2dispI2() {} + + @Test + void testSetF2dispSumTerm() {} + + @Test + void testSetF2dispZHC() {} + + @Test + void testSetF2dispZHCdm() {} + + @Test + void testSetGhsSAFT() {} + + @Test + void testSetMmin1SAFT() {} + + @Test + void testSetNSAFT() {} + + @Test + void testSetNmSAFT() {} + + @Test + void testSetVolumeSAFT() {} + + @Test + void testSetmSAFT() {} + + @Test + void testSetmdSAFT() {} } diff --git a/src/test/java/neqsim/thermo/phase/PhasePCSAFTTest.java b/src/test/java/neqsim/thermo/phase/PhasePCSAFTTest.java index f6e97a0be8..dcfbca06c3 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePCSAFTTest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePCSAFTTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhasePCSAFTaTest.java b/src/test/java/neqsim/thermo/phase/PhasePCSAFTaTest.java index 82fc574fe0..f1e8708a74 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePCSAFTaTest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePCSAFTaTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhasePrCPATest.java b/src/test/java/neqsim/thermo/phase/PhasePrCPATest.java index 69b0ef792c..61365244b3 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePrCPATest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePrCPATest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhasePrEosTest.java b/src/test/java/neqsim/thermo/phase/PhasePrEosTest.java index 3c82904a82..b77d9388c7 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePrEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePrEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhasePrEosvolcorTest.java b/src/test/java/neqsim/thermo/phase/PhasePrEosvolcorTest.java index 6a2d0c6a62..dad4efa572 100644 --- a/src/test/java/neqsim/thermo/phase/PhasePrEosvolcorTest.java +++ b/src/test/java/neqsim/thermo/phase/PhasePrEosvolcorTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseRKTest.java b/src/test/java/neqsim/thermo/phase/PhaseRKTest.java index 6a9b089968..c2004dfa40 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseRKTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseRKTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatricesTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatricesTest.java index 0b826d94f3..900df3df69 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatricesTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkCPA_proceduralMatricesTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAojAlgoTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAojAlgoTest.java index 4d4d65baa3..5da225d401 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAojAlgoTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAojAlgoTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsOldTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsOldTest.java index c33e4912ad..e3e52c750f 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsOldTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsOldTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsTest.java index 5feccc7d09..9d23b14f46 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkCPAsTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkEosTest.java index 2188a0811a..1472cafaed 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkEosTest.java @@ -15,12 +15,32 @@ void setUp() { @Test void testAddcomponent() { Assertions.assertEquals(0, p.getNumberOfComponents()); + Assertions.assertFalse(p.hasComponent("ethane")); p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + Assertions.assertTrue(p.hasComponent("ethane")); + + // Expects True because C2 normalized -> ethane + Assertions.assertTrue(p.hasComponent("C2")); + // Expects True because was created as ethane + Assertions.assertTrue(p.hasComponent("ethane", false)); + // expects False because C2 is not equal to ethane + Assertions.assertFalse(p.hasComponent("C2", false)); + + try { + p.addComponent("methane", 0, 0, 0); + } catch (Exception e) { + // Do nothing. + } + Assertions.assertEquals(1, p.getNumberOfComponents()); + + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); + String[] d = p.getComponentNames(); + Assertions.assertTrue(d[0].equals("ethane")); + Assertions.assertTrue(d[1].equals("methane")); } @Test diff --git a/src/test/java/neqsim/thermo/phase/PhaseSrkPenelouxEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseSrkPenelouxEosTest.java index a84d39d99a..b7715920ea 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseSrkPenelouxEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseSrkPenelouxEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseTSTEosTest.java b/src/test/java/neqsim/thermo/phase/PhaseTSTEosTest.java index cbe29234e3..196a189208 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseTSTEosTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseTSTEosTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseTypeTest.java b/src/test/java/neqsim/thermo/phase/PhaseTypeTest.java index 857621513e..6261c84b74 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseTypeTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseTypeTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; public class PhaseTypeTest { + @SuppressWarnings("deprecation") @Test void testValues() { for (PhaseType pt : PhaseType.values()) { diff --git a/src/test/java/neqsim/thermo/phase/PhaseUMRCPATest.java b/src/test/java/neqsim/thermo/phase/PhaseUMRCPATest.java index 711372a029..d1e8dedb67 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseUMRCPATest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseUMRCPATest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/phase/PhaseWaxTest.java b/src/test/java/neqsim/thermo/phase/PhaseWaxTest.java index 6693f17785..7bd9a42786 100644 --- a/src/test/java/neqsim/thermo/phase/PhaseWaxTest.java +++ b/src/test/java/neqsim/thermo/phase/PhaseWaxTest.java @@ -19,7 +19,7 @@ void testAddcomponent() { p.addComponent("ethane", 0, 0, 0); Assertions.assertEquals(1, p.getNumberOfComponents()); - p.addComponent("methane", 0, 0, 0); + p.addComponent("methane", 0, 0, 1); Assertions.assertEquals(2, p.getNumberOfComponents()); } } diff --git a/src/test/java/neqsim/thermo/system/SystemPCSAFTTest.java b/src/test/java/neqsim/thermo/system/SystemPCSAFTTest.java new file mode 100644 index 0000000000..157790342e --- /dev/null +++ b/src/test/java/neqsim/thermo/system/SystemPCSAFTTest.java @@ -0,0 +1,20 @@ +package neqsim.thermo.system; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class SystemPCSAFTTest { + @Test + public void testInit() { + SystemInterface testSystem = new SystemPCSAFT(250.0, 10.0); + testSystem.addComponent("methane", 1.0); + testSystem.addComponent("n-hexane", 1.0); + testSystem.setMixingRule(1); + ThermodynamicOperations ops = new ThermodynamicOperations(testSystem); + ops.TPflash(); + testSystem.initProperties(); + double cp = testSystem.getCp(); + assertEquals(208.85116193406583, cp, 0.1); + } +} diff --git a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java b/src/test/java/neqsim/thermo/system/SystemPrEoSTest.java similarity index 82% rename from src/test/java/neqsim/thermo/system/SystemPrEosTest.java rename to src/test/java/neqsim/thermo/system/SystemPrEoSTest.java index d07aaf513f..df738c0566 100644 --- a/src/test/java/neqsim/thermo/system/SystemPrEosTest.java +++ b/src/test/java/neqsim/thermo/system/SystemPrEoSTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; import neqsim.thermodynamicOperations.ThermodynamicOperations; -class SystemPrEoSTest extends neqsim.NeqSimTest { +public class SystemPrEoSTest extends neqsim.NeqSimTest { static neqsim.thermo.system.SystemInterface testSystem = null; static neqsim.thermo.ThermodynamicModelTest testModel = null; @@ -31,6 +31,29 @@ public static void setUp() { testSystem.initProperties(); } + /** + *

+ * 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}; + List Sp1 = + Arrays.asList(new Double[] {22.1, 23.2, 24.23, 25.98, 25.23, 26.1, 27.3, 28.7, 23.5, 22.7}); + List Sp2 = Arrays.asList( + new Double[] {288.1, 290.1, 295.1, 301.2, 299.3, 310.2, 315.3, 310.0, 305.2, 312.7}); + List components = Arrays.asList(new String[] {"O2", "N2"}); + List> onlineFractions = new ArrayList>(); + + for (double d : fractions) { + ArrayList l = new ArrayList(); + for (int i = 0; i < Sp1.size(); i++) { + l.add(d); + } + onlineFractions.add(l); + } + + SystemInterface fluid_static = new SystemSrkEos(273.15 + 45.0, 22.0); + fluid_static.addComponent("N2", fractions[0]); + fluid_static.addComponent("O2", fractions[1]); + fluid_static.setMixingRule(2); + fluid_static.useVolumeCorrection(true); + fluid_static.setMultiPhaseCheck(true); + // fluid_static.init(0); + + ThermodynamicOperations fluidOps_static = new ThermodynamicOperations(fluid_static); + CalculationResult res_static = fluidOps_static.propertyFlash(Sp1, Sp2, 1, null, null); + + for (String err : res_static.calculationError) { + Assertions.assertEquals(err, + "Sum of fractions must be approximately to 1 or 100, currently (0.0). Have you called init(0)?"); + } + // fluid_static.setTotalNumberOfMoles(1); + fluid_static.init(0); + res_static = fluidOps_static.propertyFlash(Sp1, Sp2, 1, null, null); + for (String err : res_static.calculationError) { + Assertions.assertEquals(err, null); + } + + SystemInterface fluid = new SystemSrkEos(273.15 + 45.0, 22.0); + fluid.addComponent("nitrogen", 0.79); + fluid.addComponent("oxygen", 0.21); + fluid.setMixingRule(2); + fluid.useVolumeCorrection(true); + fluid.setMultiPhaseCheck(true); + + ThermodynamicOperations fluidOps = new ThermodynamicOperations(fluid); + CalculationResult res = fluidOps.propertyFlash(Sp1, Sp2, 1, components, onlineFractions); + Assertions.assertEquals(Sp1.size(), res.calculationError.length); + for (String err : res.calculationError) { + Assertions.assertNull(err); + } + + fluid = new SystemSrkEos(273.15 + 45.0, 22.0); + fluid.addComponent("N2", 0.79); + fluid.addComponent("O2", 0.21); + fluid.setMixingRule(2); + fluid.useVolumeCorrection(true); + fluid.setMultiPhaseCheck(true); + + fluidOps = new ThermodynamicOperations(fluid); + CalculationResult res2 = fluidOps.propertyFlash(Sp1, Sp2, 1, components, onlineFractions); + Assertions.assertEquals(Sp1.size(), res2.calculationError.length); + for (String err : res2.calculationError) { + Assertions.assertNull(err); + } + + Assertions.assertEquals(res, res2); + // todo: why does below not work? + + // Assertions.assertArrayEquals(res_static.fluidProperties[0], res.fluidProperties[0]); + } + @Test void testNeqSimPython() { SystemInterface thermoSystem = new neqsim.thermo.system.SystemSrkEos(280.0, 10.0); @@ -105,7 +180,7 @@ void testNeqSimPython2() { new neqsim.thermodynamicOperations.ThermodynamicOperations(thermoSystem); double temp = 373.15; - double press = 60.0 + 1.013; + double press = 60.0 + ThermodynamicConstantsInterface.referencePressure; List jP = Arrays.asList(new Double[] {press}); List jT = Arrays.asList(new Double[] {temp}); @@ -269,6 +344,53 @@ void testpropertyFlashOnlineSingle() { Assertions.assertEquals(len, s.fluidProperties.length); } + @Test + void testpropertyFlashOnlineTooFewInputComponents() { + String[] components = {"nitrogen", "oxygen"}; + double[] fractions = {0.79, 0.21}; + int len = 10; + List> onlineFractions = createDummyRequest(fractions, len); + + Double[] pressure = {1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 4.0, 3.5, 3.0, 2.5}; + Double[] temperature = {301.0, 301.5, 302.0, 302.5, 303.0, 304.0, 304.0, 303.5, 303.0, 302.5}; + + SystemInterface fluid = new SystemSrkEos(298, 1.0); + // Add extra component C1 + fluid.addComponent("C1"); + fluid.addComponents(components); + // Add extra component iC4 + fluid.addComponent("iC4"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid); + CalculationResult s = ops.propertyFlash(Arrays.asList(pressure), Arrays.asList(temperature), 1, + Arrays.asList(components), onlineFractions); + Assertions.assertEquals(len, s.fluidProperties.length); + Assertions.assertNull(s.calculationError[0]); + } + + @Test + void testPropertyFlashTooManyInputComponents() { + int len = 10; + String[] components_too_many = {"nitrogen", "oxygen", "water"}; + double[] fractions_to_many = {0.79, 0.21, 0.01}; + + Double[] pressure = {1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 4.0, 3.5, 3.0, 2.5}; + Double[] temperature = {301.0, 301.5, 302.0, 302.5, 303.0, 304.0, 304.0, 303.5, 303.0, 302.5}; + + List> onlineFractions_too_many = createDummyRequest(fractions_to_many, len); + SystemInterface fluid = new SystemSrkEos(298, 1.0); + + // Add only two components to fluid + String[] components = {"nitrogen", "oxygen"}; + fluid.addComponents(components); + ThermodynamicOperations ops = new ThermodynamicOperations(fluid); + CalculationResult s = ops.propertyFlash(Arrays.asList(pressure), Arrays.asList(temperature), 1, + Arrays.asList(components_too_many), onlineFractions_too_many); + Assertions.assertEquals(len, s.fluidProperties.length); + Assertions.assertEquals("Input component list does not match fluid component list.", + s.calculationError[0]); + } + @Disabled @Test @SuppressWarnings("unchecked") @@ -287,7 +409,7 @@ void testpropertyFlashRegressions() throws IOException { ArrayList fractions = (ArrayList) inputData.get("fractions"); if (compNames == null) { - System.out.println("Skips test " + test.toString()); + // System.out.println("Skips test " + test.toString()); /* * for (int k = 0; k < fractions.size(); k++) { fluid.addComponent(k, fractions.get(k)); } */ @@ -329,6 +451,13 @@ void testpropertyFlashRegressions() throws IOException { } } + @Test + @Disabled + void testDisplay() { + ThermodynamicOperations ops = new ThermodynamicOperations(); + ops.display(); + } + private List> createDummyRequest(double[] fractions, int len) { List> onlineFractions = new ArrayList>(); @@ -431,7 +560,6 @@ public CalculationResult getOutput() throws IOException { for (int kProp = 0; kProp < calcresult.get(kSample).size(); kProp++) { try { calcResult[kSample][kProp] = calcresult.get(kSample).get(kProp); - } catch (Exception e) { calcResult[kSample][kProp] = Double.NaN; } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/Degasser.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/Degasser.java new file mode 100644 index 0000000000..fd0c0334fd --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/Degasser.java @@ -0,0 +1,189 @@ +package neqsim.thermodynamicOperations.flashOps; + +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermo.phase.PhaseEosInterface; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + */ +class Degasser { + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + /** + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception { + testSystem = new neqsim.thermo.system.SystemPrEos(243.15, 300.0); + testSystem.addComponent("methane", 90.0); + testSystem.addComponent("ethane", 0.0); + testSystem.addComponent("propane", 0.0); + testSystem.addComponent("i-butane", 0.0); + testSystem.addComponent("n-butane", 0.0); + testSystem.addComponent("i-pentane", 0.0); + testSystem.addComponent("n-pentane", 0.0); + testSystem.addComponent("n-hexane", 0.0); + testSystem.addComponent("nitrogen", 10.0); + testSystem.setMixingRule("classic"); + } + + /** + * Test method for + */ + @Test + void testRun() { + neqsim.thermo.system.SystemInterface fluid1 = + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); + + fluid1.addComponent("nitrogen", 0.110282450914383); + fluid1.addComponent("CO2", 8.92014980316162); + fluid1.addComponent("methane", 72.3870849609375); + fluid1.addComponent("ethane", 5.19349813461304); + fluid1.addComponent("propane", 5.20273065567017); + fluid1.addComponent("i-butane", 0.436239510774612); + fluid1.addComponent("n-butane", 1.39356422424316); + fluid1.addComponent("i-pentane", 0.769362509250641); + fluid1.addComponent("n-pentane", 0.543137490749359); + fluid1.addComponent("n-hexane", 3.90587639808655); + fluid1.addComponent("n-heptane", 3.90587639808655); + fluid1.addComponent("water", 40.0); + fluid1.setMixingRule(10); + fluid1.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(fluid1); + + testOps.TPflash(); + + double[] intParameter = {-0.24, // "CO2" + -0.721, // "methane" + 0.11, // "ethane" + 0.205, // "propane" + 0.081, // "i-butane" + 0.17, // "n-butane" + 0.051, // "i-pentane" + 0.1135, // "n-pentane" + 0.0832, // "n-hexane" + 0.0535 // "n-heptane" + }; + + String[] componentNames = fluid1.getComponentNames(); + + for (int i = 0; i < intParameter.length; i++) { + int componentIndex = findComponentIndex(componentNames, componentNames[i + 1]);// except + // nitrogen 0 + int waterIndex = findComponentIndex(componentNames, "water"); + + if (componentIndex != -1 && waterIndex != -1) { + ((PhaseEosInterface) fluid1.getPhases()[0]).getMixingRule() + .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); + + ((PhaseEosInterface) fluid1.getPhases()[1]).getMixingRule() + .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); + } else { + } + } + + testOps.TPflash(); + // fluid1.prettyPrint(); + + List molarComposition = new ArrayList<>(); + molarComposition.add(0.07649963805789309); + molarComposition.add(10.028287212684818); + molarComposition.add(49.52052228615394); + molarComposition.add(3.64093888905641); + molarComposition.add(3.6620992636511893); + molarComposition.add(0.2995511776378937); + molarComposition.add(0.9605423088257289); + molarComposition.add(0.5032398365065283); + molarComposition.add(0.36145746378993904); + molarComposition.add(0.2364703087561068); + molarComposition.add(2.732003176453634); + molarComposition.add(27.978388438425913); + + double[] molarCompositionArray = + molarComposition.stream().mapToDouble(Double::doubleValue).toArray(); + + neqsim.thermo.system.SystemInterface fluid_test_separator = fluid1.clone(); + fluid_test_separator.setMolarComposition(molarCompositionArray); + + neqsim.processSimulation.processEquipment.stream.Stream inlet_stream_test_sep = + new neqsim.processSimulation.processEquipment.stream.Stream("TEST_SEPARATOR_INLET", + fluid_test_separator); + inlet_stream_test_sep.setTemperature(72.6675872802734, "C"); + inlet_stream_test_sep.setPressure(10.6767892837524, "bara"); + inlet_stream_test_sep.setFlowRate(721.3143271348611, "kg/hr"); + inlet_stream_test_sep.run(); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator test_separator = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "TEST_SEPARATOR", inlet_stream_test_sep); + test_separator.run(); + test_separator.getWaterOutStream().getThermoSystem().prettyPrint(); + + 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(5.9061164855957 - 0.01, "bara"); + heater_TP_setter_test_stream.setOutTemperature(79.8487854003906, "C"); + heater_TP_setter_test_stream.run(); + // System.out.println("Gas out from degasser " + heater_TP_setter_test_stream.getOutStream() + // .getFluid().getPhase("gas").getFlowRate("kg/hr")); + heater_TP_setter_test_stream.getOutletStream().getThermoSystem().prettyPrint(); + + neqsim.processSimulation.processEquipment.heatExchanger.Heater heater_TP_setter_test_stream2 = + new neqsim.processSimulation.processEquipment.heatExchanger.Heater( + "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); + heater_TP_setter_test_stream2.setOutPressure(5.9061164855957, "bara"); + heater_TP_setter_test_stream2.setOutTemperature(79.8487854003906, "C"); + heater_TP_setter_test_stream2.run(); + + // System.out.println("Gas out from degasser2 " + heater_TP_setter_test_stream2.getOutStream() + // .getFluid().getPhase("gas").getFlowRate("kg/hr")); + } + + private int findComponentIndex(String[] componentNames, String componentName) { + for (int i = 0; i < componentNames.length; i++) { + if (componentNames[i].equals(componentName)) { + return i; + } + } + + return -1; // Component not found + } + + /** + * Test method for + */ + void testRun2() { + /* + * XStream xstream = new XStream(); xstream.addPermission(AnyTypePermission.ANY); // Specify the + * file path to read Path filePath = Paths.get( + * "/workspaces/neqsim/src/test/java/neqsim/thermodynamicOperations/flashOps/my_process.xml"); + * String xmlContents = ""; try { //xmlContents = Files.readString(filePath); } catch + * (IOException e) { e.printStackTrace(); } + * + * // Deserialize from xml neqsim.processSimulation.processSystem.ProcessSystem operationsCopy = + * (neqsim.processSimulation.processSystem.ProcessSystem) xstream.fromXML(xmlContents); + * operationsCopy.run(); neqsim.processSimulation.processEquipment.separator.Separator + * VD02Separator = (neqsim.processSimulation.processEquipment.separator.Separator) + * operationsCopy .getUnit("Separator after CFU gas"); + * neqsim.processSimulation.processEquipment.separator.Separator VD01Separator = + * (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy + * .getUnit("Separator after degasser gas"); + * neqsim.processSimulation.processEquipment.separator.Separator Degasser = + * (neqsim.processSimulation.processEquipment.separator.Separator) operationsCopy + * .getUnit("Degasser"); + * System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + + * Degasser.getGasOutStream().getFlowRate("kg/hr")); + * System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + + * VD01Separator.getGasOutStream().getFlowRate("kg/hr")); VD02Separator.getGasOutStream().run(); + * System.out.println("The gas flow rate should be < 200 kg/hr, the actual value is " + + * VD02Separator.getGasOutStream().getFlowRate("kg/hr")); + */ + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashCPATest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashCPATest.java new file mode 100644 index 0000000000..898ef5d1a8 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashCPATest.java @@ -0,0 +1,43 @@ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + */ +class PHFlashCPATest { + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + @Test + void testRun() { + testSystem = new neqsim.thermo.system.SystemSrkCPAstatoil(323.15, 100.0); + testSystem.addComponent("CO2", 9.0); + testSystem.addComponent("methane", 90.0); + testSystem.addComponent("ethane", 12.0); + testSystem.addComponent("propane", 1.0); + testSystem.addComponent("i-butane", 1.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("i-pentane", 1.0); + testSystem.addComponent("n-pentane", 1.0); + testSystem.addComponent("n-hexane", 0.001); + testSystem.addComponent("water", 10.0); + testSystem.addComponent("MEG", 10.0); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + double enthalpy = testSystem.getEnthalpy(); + double entropy = testSystem.getEntropy(); + testSystem.setPressure(50.0); + testOps.PHflash(enthalpy); + assertEquals(enthalpy, testSystem.getEnthalpy(), 1e-2); + assertEquals(307.5036701214, testSystem.getTemperature(), 1e-2); + testOps.PSflash(entropy); + assertEquals(287.0197047, testSystem.getTemperature(), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java index 46ed812aed..731e7d5f63 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashGERG2008Test.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class PHFlashGERG2008Test { static neqsim.thermo.system.SystemInterface testSystem = null; @@ -28,9 +27,6 @@ void setUp() throws Exception { testSystem.initProperties(); } - /** - * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlashGERG2008#run()}. - */ @Test void testRun() { double[] gergProps = testSystem.getPhase(0).getProperties_GERG2008(); diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java index 61f54b2937..f2239b838a 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PHFlashTest.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class PHFlashTest { static neqsim.thermo.system.SystemInterface testSystem = null; @@ -31,9 +30,6 @@ void setUp() throws Exception { testSystem.setMixingRule("classic"); } - /** - * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}. - */ @Test void testRun() { testOps = new ThermodynamicOperations(testSystem); diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java index 88f027f499..d7345039c1 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/PSFlashGERG2008Test.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class PSFlashGERG2008Test { static neqsim.thermo.system.SystemInterface testSystem = null; diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/RachfordRiceTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/RachfordRiceTest.java new file mode 100644 index 0000000000..9f7db4f95c --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/RachfordRiceTest.java @@ -0,0 +1,41 @@ +package neqsim.thermodynamicOperations.flashOps; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RachfordRiceTest { + @Test + void testCalcBeta() { + double[] z = new double[] {0.7, 0.3}; + double[] K = new double[] {2.0, 0.01}; + + try { + RachfordRice rachfordRice = new RachfordRice(); + Assertions.assertEquals(0.407070707, rachfordRice.calcBeta(K, z), 1e-6); + } catch (Exception e) { + e.printStackTrace(); + } + + try { + RachfordRice rachfordRice = new RachfordRice(); + rachfordRice.setMethod("Nielsen2023"); + Assertions.assertEquals(0.407070707, rachfordRice.calcBeta(K, z), 1e-6); + rachfordRice.setMethod("Michelsen2001"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + void testCalcBetaMethod2() { + double[] z = new double[] {0.7, 0.3}; + double[] K = new double[] {2.0, 0.01}; + + try { + RachfordRice rachfordRice = new RachfordRice(); + Assertions.assertEquals(0.407070707, rachfordRice.calcBeta(K, z), 1e-6); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWaterTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWaterTest.java new file mode 100644 index 0000000000..fac2ef054e --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/SaturateWithWaterTest.java @@ -0,0 +1,91 @@ +package neqsim.thermodynamicOperations.flashOps; + +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; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemPrEos; +import neqsim.thermo.system.SystemSrkCPAstatoil; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class SaturateWithWaterTest { + static Logger logger = LogManager.getLogger(SaturateWithWaterTest.class); + + @Test + void testRun() { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 70.0, 150.0); + + testSystem.addComponent("methane", 75.0); + testSystem.addComponent("ethane", 7.5); + testSystem.addComponent("propane", 4.0); + testSystem.addComponent("n-butane", 1.0); + testSystem.addComponent("i-butane", 0.6); + testSystem.addComponent("n-hexane", 0.3); + testSystem.addPlusFraction("C6", 1.3, 100.3 / 1000.0, 0.8232); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.saturateWithWater(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + assertEquals(0.0029033655101811814, testSystem.getComponent("water").getz(), 1e-5); + } + + @Test + void testRun2() { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 70.0, 150.0); + + testSystem.addComponent("methane", 75.0); + testSystem.addComponent("ethane", 7.5); + testSystem.addComponent("propane", 4.0); + testSystem.setMixingRule(10); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.saturateWithWater(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + assertEquals(0.002891748277007660, testSystem.getComponent("water").getz(), 1e-5); + } + + @Test + void testRun3() { + SystemInterface testSystem = new SystemSrkCPAstatoil(273.15 + 20.0, 150.0); + + testSystem.addComponent("methane", 2.0); + testSystem.addComponent("n-heptane", 75.0); + testSystem.setMixingRule(10); + testSystem.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.saturateWithWater(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + assertEquals(2.8465024974919816E-4, testSystem.getComponent("water").getz(), 1e-5); + } + + @Test + void testRun4() { + SystemInterface testSystem = new SystemPrEos(273.15 + 20.0, 150.0); + + testSystem.addComponent("methane", 2.0); + testSystem.addComponent("n-heptane", 75.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + + ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem); + try { + testOps.saturateWithWater(); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + assertEquals(2.4301370485671443E-4, testSystem.getComponent("water").getz(), 1e-5); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1Test.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1Test.java new file mode 100644 index 0000000000..6c21564fcd --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/SolidFlash1Test.java @@ -0,0 +1,22 @@ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class SolidFlash1Test { + @Test + void testPhaseCheck() { + SystemInterface fluid1 = new SystemSrkEos(); + fluid1.addComponent("CO2", 1.0); + fluid1.setPressure(15.448979591836736); + fluid1.setTemperature(273.15 + 46.734693877551024); + fluid1.setSolidPhaseCheck("CO2"); + fluid1.setMultiPhaseCheck(true); + ThermodynamicOperations flashOps = new ThermodynamicOperations(fluid1); + flashOps.TPSolidflash(); + assertEquals("gas",fluid1.getPhase(0).getType().getDesc()); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java index 6fff851397..fb3a5e9e65 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTest.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class TPFlashTest { static neqsim.thermo.system.SystemInterface testSystem = null; @@ -136,7 +135,38 @@ void testRun6() { testOps = new ThermodynamicOperations(testSystem5); testOps.TPflash(); testSystem5.initProperties(); - assertEquals(0.27697023508525664, testSystem5.getBeta(), 1e-6); + assertEquals(0.2838675588923609 + , testSystem5.getBeta(), 1e-6); assertEquals(3, testSystem5.getNumberOfPhases()); } + + @Test + void testTPflash1() { + testSystem = new neqsim.thermo.system.SystemSrkEos(273.15 + 290, 400.0); + testSystem.addComponent("water", 65.93229747922976); + testSystem.addComponent("NaCl", 0.784426208131475); + testSystem.addComponent("nitrogen", 0.578509157534656); + testSystem.addComponent("methane", 22.584113183429718); + testSystem.addComponent("ethane", 3.43870686718215); + testSystem.addComponent("propane", 0.26487350163523365); + testSystem.addComponent("i-butane", 0.04039429848533373); + testSystem.addComponent("n-butane", 0.1543856425679738); + testSystem.addComponent("i-pentane", 0.04039429848533373); + testSystem.addComponent("n-pentane", 0.1543856425679738); + testSystem.addTBPfraction("C6", 0.568724470114871, 84.93298402237961 / 1000.0, + 666.591171644071 / 1000.0); + testSystem.addTBPfraction("C7", 0.9478147516962493, 90.01311937418495 / 1000.0, + 746.9101810251765 / 1000.0); + testSystem.addTBPfraction("C8", 0.974840433764089, 102.34691375809437 / 1000.0, + 776.2927119017166 / 1000.0); + testSystem.addTBPfraction("C9", 0.5505907716430188, 116.06055719132209 / 1000.0, + 791.2983315058531 / 1000.0); + testSystem.addTBPfraction("C10", 1.9704404325720026, 221.831957 / 1000.0, 842.802708 / 1000.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + assertEquals(2, testSystem.getNumberOfPhases()); + // testSystem.prettyPrint(); + } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java index bf81197f26..4dac61a32a 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestHighTemp.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class TPFlashTestHighTemp { static neqsim.thermo.system.SystemInterface testSystem = null; diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java index d95732acf9..bdca57ff62 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPFlashTestWellFluid.java @@ -7,7 +7,6 @@ /** * @author ESOL - * */ class TPFlashTestWellFluid { static neqsim.thermo.system.SystemInterface wellFluid = null; @@ -70,6 +69,7 @@ void testTPflashComp2() { 8.96e-3, 1.539e-3, 5.9921e-1}); testOps = new ThermodynamicOperations(wellFluid); testOps.TPflash(); - assertEquals(1.4292538950216407, wellFluid.getPhase(0).getDensity(), 1e-5); + assertEquals(1.432253736300898 + , wellFluid.getPhase(0).getDensity(), 1e-5); } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TPsolidFlash.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPsolidFlash.java new file mode 100644 index 0000000000..ec2c5bdeaa --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TPsolidFlash.java @@ -0,0 +1,89 @@ +package neqsim.thermodynamicOperations.flashOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; +import neqsim.thermo.phase.PhaseType; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * @author ESOL + */ +class TPsolidFlash { + @Test + void testSolidFLash() { + neqsim.thermo.system.SystemPrEos testSystem = + new neqsim.thermo.system.SystemPrEos(283.15, 20.0); + testSystem.addComponent("CO2", 1.0); + testSystem.addComponent("methane", 80.0); + testSystem.addComponent("ethane", 5.0); + testSystem.addTBPfraction("C11", 0.01, 150.0 / 1000.0, 0.82); + testSystem.addTBPfraction("C12", 0.01, 170.0 / 1000.0, 0.84); + testSystem.addComponent("S8", 10.0); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + testSystem.setSolidPhaseCheck("S8"); + ThermodynamicOperations thermoops = new ThermodynamicOperations(testSystem); + // thermoops.TPflash(); + thermoops.TPSolidflash(); + // testSystem.prettyPrint(); + assertEquals(3, testSystem.getNumberOfPhases()); + assertTrue(testSystem.hasPhaseType(PhaseType.SOLID)); + + // System.out.println( + // "kg S8 per kg HC " + (testSystem.getPhase(0).getComponent("S8").getFlowRate("kg/hr") + // + testSystem.getPhase(1).getComponent("S8").getFlowRate("kg/hr")) + // / (testSystem.getPhase(0).getFlowRate("kg/hr") + // + testSystem.getPhase(1).getFlowRate("kg/hr"))); + } + + @Test + void testSolidFLash2() { + neqsim.thermo.system.SystemPrEos testSystem = + new neqsim.thermo.system.SystemPrEos(283.15, 100.0); + testSystem.addComponent("nitrogen", 1.75); + testSystem.addComponent("CO2", 0.23); + testSystem.addComponent("methane", 93.84); + testSystem.addComponent("ethane", 3.54); + testSystem.addComponent("propane", 0.585); + testSystem.addComponent("i-butane", 0.41); + testSystem.addComponent("n-butane", 0.13); + testSystem.addComponent("i-pentane", 0.0945); + testSystem.addComponent("n-pentane", 0.033); + testSystem.addTBPfraction("C6", 0.1, 82.23 / 1000.0, 0.6762); + testSystem.addTBPfraction("C7", 0.185, 88.65 / 1000.0, 0.757); + testSystem.addTBPfraction("C8", 0.118, 103.65 / 1000.0, 0.761); + testSystem.addTBPfraction("C9", 0.051, 120.65 / 1000.0, 0.775); + testSystem.addTBPfraction("C10", 0.0222, 134.65 / 1000.0, 0.795); + testSystem.addTBPfraction("C11", 0.0145, 147.65 / 1000.0, 0.813); + testSystem.addTBPfraction("C12", 0.0095, 161.65 / 1000.0, 0.83); + testSystem.addTBPfraction("C13", 0.0062, 175.65 / 1000.0, 0.845); + testSystem.addTBPfraction("C14", 0.004, 190.65 / 1000.0, 0.859); + testSystem.addTBPfraction("C15", 0.0026, 206.65 / 1000.0, 0.872); + testSystem.addTBPfraction("C16", 0.003, 222.65 / 1000.0, 0.885); + testSystem.addTBPfraction("C17", 0.0017, 222.65 / 1000.0, 0.885); + testSystem.addTBPfraction("C18", 0.0011, 237.65 / 1000.0, 0.898); + testSystem.addTBPfraction("C98", 0.0007, 251.65 / 1000.0, 0.907); + testSystem.addTBPfraction("C20", 0.0005, 263.65 / 1000.0, 0.918); + testSystem.addTBPfraction("C21", 0.0009, 301.65 / 1000.0, 0.945); + testSystem.addComponent("S8", 1.0e-5); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + testSystem.setTotalFlowRate(1.0, "MSm3/hr"); + testSystem.addComponent("S8", 100.0, "kg/hr"); + testSystem.setSolidPhaseCheck("S8"); + ThermodynamicOperations thermoops = new ThermodynamicOperations(testSystem); + thermoops.TPflash(); + // thermoops.TPSolidflash(); + // testSystem.prettyPrint(); + assertEquals(3, testSystem.getNumberOfPhases()); + assertTrue(testSystem.hasPhaseType(PhaseType.SOLID)); + + // System.out.println( + // "kg S8 per MSm3 gas " + (testSystem.getPhase(0).getComponent("S8").getFlowRate("kg/hr") + // + testSystem.getPhase(1).getComponent("S8").getFlowRate("kg/hr"))); + // System.out.println("m3 oil per MSm3 " + + // (testSystem.getPhase(PhaseType.OIL).getFlowRate("m3/hr") + // * 24 / testSystem.getPhase(PhaseType.GAS).getFlowRate("MSm3/day"))); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java index 3e5291d14a..9d4596f77c 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/TVFlashTest.java @@ -81,7 +81,7 @@ void testLiquidThermalExpansion() { testOps = new ThermodynamicOperations(testSystem); testOps.TPflash(); testSystem.initProperties(); - + double isothermalCompressibility = testSystem.getPhase(0).getIsothermalCompressibility(); double isobaricThermalExpansivity = testSystem.getPhase(0).getIsobaricThermalExpansivity(); diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/VUFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/VUFlashTest.java new file mode 100644 index 0000000000..6a09ad7d7e --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/VUFlashTest.java @@ -0,0 +1,46 @@ +package neqsim.thermodynamicOperations.flashOps; + +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.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +/** + * Test VUFlash. + */ +class VUFlashTest { + static Logger logger = LogManager.getLogger(VUFlashTest.class); + + static neqsim.thermo.system.SystemInterface testSystem = null; + static neqsim.thermo.system.SystemInterface testSystem2 = null; + static ThermodynamicOperations testOps = null; + + /** + * Sets up test system. + * + * @throws java.lang.Exception + */ + @BeforeEach + void setUp() throws Exception {} + + @Test + void testVUflash() { + testSystem = new neqsim.thermo.system.SystemUMRPRUMCEos(293.15, 23.5); + testSystem.addComponent("methane", 1.0); + testSystem.addComponent("ethane", 0.01); + testSystem.addComponent("n-pentane", 0.01); + testSystem.setMixingRule("classic"); + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + + double volume = testSystem.getVolume("m3"); + double internalenergy = testSystem.getInternalEnergy("J"); + + testOps.VUflash(volume * 1.1, internalenergy, "m3", "J"); + + assertEquals(21.387, testSystem.getPressure(), 0.01); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java index 98d7283308..c93f01a0ed 100644 --- a/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/WaxFlashTest.java @@ -11,7 +11,6 @@ /** * @author ESOL - * */ class WaxFlashTest { static Logger logger = LogManager.getLogger(WaxFlashTest.class); @@ -65,7 +64,7 @@ void testRun() { if (testSystem.hasPhaseType("wax")) { waxVolumeFrac = testSystem.getWtFraction(testSystem.getPhaseIndex("wax")); } - assertEquals(30.33516095, waxT, 0.001); + assertEquals(30.323689017118397, waxT, 0.001); assertEquals(3.236072552269342E-4, waxVolumeFrac, 0.0001); } } diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlashTest.java new file mode 100644 index 0000000000..bf1044044d --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/HydrateInhibitorwtFlashTest.java @@ -0,0 +1,49 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkCPAstatoil; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class HydrateInhibitorwtFlashTest { + @Test + void testRun() { + 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 { + // creates HydrateInhibitorwtFlash object and calls run on it. + 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()); + Assertions.assertEquals(98.54736778391424, cons, 1e-12); + } catch (Exception ex) { + ex.toString(); + } + // testSystem.display(); + + assertEquals(0.019690143220139962, + testSystem.getPhase(0).getComponent("MEG").getNumberOfmoles(), 1e-12); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java new file mode 100644 index 0000000000..78f9820386 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointPressureFlashTest.java @@ -0,0 +1,29 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class bubblePointPressureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(-50.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.bubblePointPressureFlash(false); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(65.150271897839, fluid0_HC.getPressure(), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java new file mode 100644 index 0000000000..1e94ace143 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/bubblePointTemperatureFlashTest.java @@ -0,0 +1,29 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class bubblePointTemperatureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(-150.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.bubblePointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(-117.7205968083, fluid0_HC.getTemperature("C"), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java new file mode 100644 index 0000000000..8764e39d70 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointPressureFlashTest.java @@ -0,0 +1,29 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class dewPointPressureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(0.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.dewPointPressureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(9.332383561, fluid0_HC.getPressure(), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java new file mode 100644 index 0000000000..da810feb75 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/flashOps/saturationOps/dewPointTemperatureFlashTest.java @@ -0,0 +1,29 @@ +package neqsim.thermodynamicOperations.flashOps.saturationOps; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.thermo.system.SystemSrkEos; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class dewPointTemperatureFlashTest { + @Test + void testRun() { + SystemSrkEos fluid0_HC = new SystemSrkEos(); + fluid0_HC.addComponent("methane", 0.7); + fluid0_HC.addComponent("ethane", 0.1); + fluid0_HC.addComponent("propane", 0.1); + fluid0_HC.addComponent("n-butane", 0.1); + fluid0_HC.setMixingRule("classic"); + + fluid0_HC.setPressure(10.0, "bara"); + fluid0_HC.setTemperature(0.0, "C"); + + ThermodynamicOperations ops = new ThermodynamicOperations(fluid0_HC); + try { + ops.dewPointTemperatureFlash(); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(1.7007677589821242, fluid0_HC.getTemperature("C"), 1e-2); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/PTPhaseEnvelopeTest.java b/src/test/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/PTPhaseEnvelopeTest.java new file mode 100644 index 0000000000..4faa6a5316 --- /dev/null +++ b/src/test/java/neqsim/thermodynamicOperations/phaseEnvelopeOps/multicomponentEnvelopeOps/PTPhaseEnvelopeTest.java @@ -0,0 +1,172 @@ +package neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import neqsim.thermodynamicOperations.ThermodynamicOperations; + +public class PTPhaseEnvelopeTest { + static neqsim.thermo.system.SystemInterface testSystem = null; + static ThermodynamicOperations testOps = null; + + @BeforeEach + void setUp() { + testSystem = new neqsim.thermo.system.SystemSrkEos(298.0, 50.0); + } + + /** + * Test method for + * {@link neqsim.thermodynamicOperations.phaseEnvelopeOps.multicomponentEnvelopeOps.pTphaseEnvelope}. + */ + @Test + void testDewP() { + testSystem.addComponent("nitrogen", 0.01); + testSystem.addComponent("CO2", 0.01); + testSystem.addComponent("methane", 0.98); + testSystem.setMixingRule("classic"); + + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + testOps.calcPTphaseEnvelope(); + double[] dewPointPressures = testOps.get("dewP"); + double[] expectedDewPointPressures = + new double[] {1.1051709180756477, 1.2214027581601699, 1.3498588075760032, + 1.4918246976412703, 1.6652911949458864, 1.8794891289619104, 2.1418131227502055, + 2.4690864123141987, 2.881197018974799, 3.404779997613969, 4.075230307874481, + 4.938583914869986, 6.051801019586486, 7.477304695462727, 9.260793952051571, + 11.364101185282063, 13.480106047577934, 14.53423776629387, 13.607498029406681, + 11.181207439509638, 9.189487040488075, 9.612827246459474, 10.706126846063928, + 12.501491987760147, 15.075672692089958, 18.51283799420178, 23.330378296334104, + 29.71319711031059, 37.25532259549197, 43.660805656603934, 45.75836660678656, + 46.42490219574348, 46.83203503669948, 46.869568345957006, 46.903557772489435}; + // System.out.println(Arrays.toString(dewPointPressures)); + assertArrayEquals(expectedDewPointPressures, dewPointPressures, 10E-10); + } + + @Test + void testFailingCaseWithWater() { + testSystem.addComponent("nitrogen", 0.04); + testSystem.addComponent("CO2", 0.06); + testSystem.addComponent("methane", 0.80); + testSystem.addComponent("water", 0.00000000001); + + testSystem.setMixingRule("classic"); + + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + + Exception exception = + assertThrows(ArrayIndexOutOfBoundsException.class, () -> testOps.calcPTphaseEnvelope()); + } + + @Test + void testSimpleCase() { + testSystem.addComponent("nitrogen", 0.88); + testSystem.addComponent("CO2", 5.7); + testSystem.addComponent("methane", 86.89); + testSystem.addComponent("ethane", 3.59); + testSystem.addComponent("propane", 1.25); + testSystem.addComponent("i-butane", 0.19); + testSystem.addComponent("n-butane", 0.35); + testSystem.addComponent("i-pentane", 0.12); + testSystem.addComponent("n-pentane", 0.12); + testSystem.setMixingRule("classic"); + testSystem.setMixingRule("classic"); + + testOps = new ThermodynamicOperations(testSystem); + testOps.calcPTphaseEnvelope2(); + // double[] dewPointPressures = testOps.get("dewP"); + double[] dewPointTemperatures = testOps.get("dewT"); + // double[] bubblePointPressures = testOps.get("bubP"); + double[] bubblePointTemperatures = testOps.get("bubT"); + // double[] cricondenbar = testOps.get("cricondenbar"); + // double[] criticalPoint1 = testOps.get("criticalPoint1"); + + assertTrue(dewPointTemperatures.length > 20); + assertTrue(bubblePointTemperatures.length > 10); + } + + @Test + void testFailingCase1() { + // testSystem.setTemperature(40, "C"); + // testSystem.setPressure(50, "bara"); + testSystem.addComponent("nitrogen", 0.88); + testSystem.addComponent("CO2", 5.7); + testSystem.addComponent("methane", 86.89); + testSystem.addComponent("ethane", 3.59); + testSystem.addComponent("propane", 1.25); + testSystem.addComponent("i-butane", 0.19); + testSystem.addComponent("n-butane", 0.35); + testSystem.addComponent("i-pentane", 0.12); + testSystem.addComponent("n-pentane", 0.12); + testSystem.addTBPfraction("C6", 0.15, 86 / 1000.0, 0.672); + testSystem.addTBPfraction("C7", 0.2, 96 / 1000.0, 0.737); + testSystem.addTBPfraction("C8", 0.22, 106 / 1000.0, 0.767); + testSystem.addTBPfraction("C9", 0.13, 121 / 1000.0, 0.783); + testSystem.addPlusFraction("C10+", 0.21, 172 / 1000.0, 0.818); + testSystem.setMixingRule("classic"); + testSystem.setMultiPhaseCheck(true); + testSystem.useVolumeCorrection(true); + testSystem.initPhysicalProperties(); + testSystem.setMixingRule("classic"); + + testOps = new ThermodynamicOperations(testSystem); + testOps.TPflash(); + testSystem.initProperties(); + + testOps.calcPTphaseEnvelope2(); + // double[] dewPointPressures = testOps.get("dewP"); + double[] dewPointTemperatures = testOps.get("dewT"); + // double[] bubblePointPressures = testOps.get("bubP"); + double[] bubblePointTemperatures = testOps.get("bubT"); + // double[] cricondenbar = testOps.get("cricondenbar"); + // double[] criticalPoint1 = testOps.get("criticalPoint1"); + + assertTrue(dewPointTemperatures.length > 20); + assertTrue(bubblePointTemperatures.length > 10); + } + + @Test + void testFailingCase2() { + // testSystem.setTemperature(40, "C"); + // testSystem.setPressure(50, "bara"); + neqsim.thermo.system.SystemInterface fluid0_HC = + new neqsim.thermo.system.SystemUMRPRUMCEos(298.0, 50.0); + fluid0_HC.addComponent("nitrogen", 2.5); + fluid0_HC.addComponent("CO2", 4.5); + fluid0_HC.addComponent("methane", 79.45); + fluid0_HC.addComponent("ethane", 10); + fluid0_HC.addComponent("propane", 2.5); + fluid0_HC.addComponent("i-butane", 0.3); + fluid0_HC.addComponent("n-butane", 0.5); + fluid0_HC.addComponent("22-dim-C3", 0.01); + fluid0_HC.addComponent("i-pentane", 0.05); + fluid0_HC.addComponent("n-pentane", 0.05); + fluid0_HC.addComponent("n-hexane", 0.05); + fluid0_HC.addComponent("benzene", 0.02); + fluid0_HC.addComponent("c-hexane", 0.02); + fluid0_HC.addComponent("n-heptane", 0.02); + fluid0_HC.addComponent("toluene", 0.01); + fluid0_HC.addComponent("n-octane", 0.01); + fluid0_HC.setMixingRule("HV", "UNIFAC_UMRPRU"); + testOps = new ThermodynamicOperations(fluid0_HC); + testOps.calcPTphaseEnvelope2(); + double[] dewPointPressures = testOps.get("dewP"); + double[] dewPointTemperatures = testOps.get("dewT"); + double[] bubblePointPressures = testOps.get("bubP"); + double[] bubblePointTemperatures = testOps.get("bubT"); + double[] bubblePointEnthalpies = testOps.get("bubH"); + double[] bubblePointVolumes = testOps.get("bubDens"); + // double[] cricondenbar = testOps.get("cricondenbar"); + // double[] criticalPoint1 = testOps.get("criticalPoint1"); + + assertTrue(dewPointTemperatures.length > 20); + assertTrue(bubblePointTemperatures.length > 20); + assertTrue(bubblePointEnthalpies.length > 20); + assertTrue(bubblePointVolumes.length > 20); + } +} diff --git a/src/test/java/neqsim/thermodynamicOperations/util/example/PhaseEnvelope.java b/src/test/java/neqsim/thermodynamicOperations/util/example/PhaseEnvelope.java index e5e15d1140..5cc91bae76 100644 --- a/src/test/java/neqsim/thermodynamicOperations/util/example/PhaseEnvelope.java +++ b/src/test/java/neqsim/thermodynamicOperations/util/example/PhaseEnvelope.java @@ -9,11 +9,11 @@ /* *

PhaseEnvelope 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"); + } +}