Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Merging Px envelopes branch #2

Merged
merged 48 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a48b410
feat(envelopes): basic fluid injection module
fedebenelli Aug 5, 2023
a0b30fe
refactor: Moved the envelopes logic to single subroutines
fedebenelli Aug 18, 2023
02afdb5
feat(setup): Logic to read input files
fedebenelli Aug 18, 2023
23a1d0e
feat(PT envelopes): Calculation of 2ph-PT envelopes
fedebenelli Aug 18, 2023
19b675b
feat(Px envelopes): Main logic to calculate the system of Px envelopes
fedebenelli Aug 18, 2023
c1990b8
format
fedebenelli Aug 18, 2023
03f23b1
feat(linalg): interpolation function
fedebenelli Aug 18, 2023
d760afe
feat(intersections): Get the inteserction between two lines
fedebenelli Aug 18, 2023
d60bf97
feat(intersect): Function to get a self cross
fedebenelli Aug 18, 2023
f1e6a25
feat(intersect): Two lines intersection
fedebenelli Aug 18, 2023
bfc5c10
refactor(types): Moved point dtype to linalg
fedebenelli Aug 18, 2023
93975e7
feat(testing): Simple test to check intersections
fedebenelli Aug 18, 2023
f7896fe
refactor(crossings): Removed crossings logic
fedebenelli Aug 18, 2023
803f9eb
feat: Px envelopes module
fedebenelli Aug 18, 2023
40a854f
format
fedebenelli Aug 18, 2023
5569f3b
feat(input): New namelist
fedebenelli Aug 18, 2023
18f1525
test data
fedebenelli Aug 18, 2023
f91b97e
refactor: EoS framework
fedebenelli Aug 23, 2023
bfb923d
refactor(eos): Now using legacy eos from yaeos
fedebenelli Sep 12, 2023
c7ce25e
feat(main): Adding a cli logic to the main program.
fedebenelli Sep 12, 2023
4377d74
feat(PT): Find intersections between PT lines
fedebenelli Sep 12, 2023
d3fdf40
feat(Px): 3ph-Px lines
fedebenelli Sep 12, 2023
153c83a
feat(Px): Detection of intersections
fedebenelli Sep 12, 2023
e81db16
fprettified
fedebenelli Sep 12, 2023
fc927b5
New dependencies
fedebenelli Sep 12, 2023
65be855
refactor(PT): Minor details
fedebenelli Sep 12, 2023
c0ad155
feat(PX): Added calculation routines for 3ph-Px
fedebenelli Sep 12, 2023
0a11ce6
fix(newton): Newton solver details
fedebenelli Sep 12, 2023
18e4d9c
feat(PX): Delimited some break conditions for solving
fedebenelli Sep 12, 2023
bd704ff
refactor(Px): Moved out calculation of z and dzda
fedebenelli Sep 12, 2023
a3d0bba
refactor(Px_mod): Format
fedebenelli Sep 12, 2023
03b7f08
fix(interserction): Modified tolerances
fedebenelli Sep 12, 2023
c8e1a8a
refactor(linalg): Format and deleted some prints
fedebenelli Sep 12, 2023
8e40597
interpol
fedebenelli Sep 12, 2023
dc23670
Simple plotter of Pxvelopes
fedebenelli Sep 12, 2023
c6395ba
test
fedebenelli Sep 12, 2023
09db282
test(Px): Comparison between num jacobian and analitical
fedebenelli Sep 12, 2023
d8e9998
Added Flash subroutine in a phase_equilibria module
fedebenelli Sep 13, 2023
544f41f
fpm details
fedebenelli Sep 18, 2023
42d2490
Some (very little) standarization of Flash routine
fedebenelli Sep 18, 2023
86bcd88
refactor(envelopes)
fedebenelli Sep 18, 2023
71a62f5
feat(CI and docs)
fedebenelli Sep 18, 2023
e361c1d
moved out gnuplotting
fedebenelli Sep 18, 2023
52bcfbc
external tools
fedebenelli Sep 18, 2023
8774113
Added minpack dependency to CI
fedebenelli Sep 18, 2023
2b8e8fb
refactor(output_dir)
fedebenelli Sep 18, 2023
881fa94
Updated readme
fedebenelli Sep 18, 2023
d4c2af1
test infile
fedebenelli Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI
on: [push]

jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
gcc_v: [10] # Version of GFortran we want to use.
python-version: [3.9]
env:
FC: gfortran-${{ matrix.gcc_v }}
GCC_V: ${{ matrix.gcc_v }}

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Install Python
uses: actions/setup-python@v1 # Use pip to install latest CMake, & FORD/Jin2For, etc.
with:
python-version: ${{ matrix.python-version }}

- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1

- name: Setup Fortran Package Manager
uses: fortran-lang/setup-fpm@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python dependencies
if: contains( matrix.os, 'ubuntu')
run: |
python -m pip install --upgrade pip
pip install ford numpy matplotlib
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Install GFortran Linux
if: contains( matrix.os, 'ubuntu')
run: |
sudo apt-get install lcov
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc_v }} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.gcc_v }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.gcc_v }}

- name: Install dependencies
if: contains( matrix.os, 'ubuntu')
run: |
sudo apt-get install minpack-dev

# - name: Compile
# run: fpm build --profile release

- name: Run tests
run: fpm test --profile debug --flag -coverage

# - name: Create coverage report
# run: |
# mkdir -p ${{ env.COV_DIR }}
# lcov --capture --initial --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.base
# lcov --capture --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.capture
# lcov --add-tracefile ${{ env.COV_DIR }}/coverage.base --add-tracefile ${{ env.COV_DIR }}/coverage.capture --output-file ${{ env.COV_DIR }}/coverage.info
# env:
# COV_DIR: build/coverage

# - name: Upload coverage report
# uses: codecov/codecov-action@v2
# with:
# files: build/coverage/coverage.info
48 changes: 48 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Deploy Documentation

on: [push, pull_request]

jobs:
documentation:
runs-on: ubuntu-22.04

env:
FC: gfortran
GCC_V: 12

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Dependencies Ubuntu
run: |
sudo apt-get update
sudo apt install -y gfortran-${GCC_V} python3-dev graphviz
sudo pip install ford markdown==3.3.4

- name: Build Developer Documentation
run: |
ford doc/ford-front-matter.md

- name: Upload Documentation
uses: actions/upload-artifact@v2
with:
name: documentation
path: doc/ford_site
if-no-files-found: error

- name: Broken Link Check
if: ${{ github.ref == 'refs/heads/main'}}
uses: technote-space/broken-link-checker-action@v1
with:
TARGET: file://${{ github.workspace }}/ford_site/index.html
RECURSIVE: true
ASSIGNEES: ${{ github.actor }}

- name: Deploy API Documentation
uses: JamesIves/[email protected]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: doc/ford_site
108 changes: 85 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
# envelopes
Simple program to calculate biphasic phase envolopes
# fenvelopes
Fortran program to calculate phase envelopes.

## Input files
The program assumes there is a `input.nml` file at it's path, which contains
all the relevant data for the system.
This is an ongoing project that intends te be a fully fledged generator of phase
equilibria diagrams using Equations of State.

## Capabilities
Right now `fenvelopes` calculates three kinds of phase-envelopes.

- [x] Two-phase PT envelopes
- [ ] Three-phase PT envelopes
- [x] Two-phase Px envelopes
- [ ] Three-phase Px envelopes
- [x] Px envelopes based on double saturation points.
- [ ] Isolated Px envelopes.
- [ ] Python wrappers to ease up scripting and plotting.

## Usage
This program is intended to be used as a `CLI` software. The command used to
calculate phase diagrams is:

```bash
fenvelopes --infile input_file.nml
```

This will generate an `fenvelopes_output` directory. Which contains all the
generated output files with the relevant data.

### Input files
The input files

```fortran
! input.nml
!
! Namelist based input file
! =========================
!
Expand All @@ -17,24 +43,26 @@ all the relevant data for the system.


&nml_setup
! General settings
nc=5, ! Number of components
model="PR78", ! SRK PR76 PR78
mixrule="ClassicVdW" ! only ClassicVdW
mixrule="ClassicVdW" ! only ClassicVdW for now
/

&nml_composition
names="PC1" "PC2" "PC3" "PC4" "H2O"
spec="critical", ! critical or parameters
spec="critical", ! critical or parameters specification
z=0.15 0.10 0.10 0.15 0.50
/

&nml_classicvdw
&nml_classicvdw ! Classic VdW mixing rule parameters
! kij matrix
kij(1, :)=0 0 0 0 0.7192
kij(2, :)=0 0 0 0 0.4598
kij(3, :)=0 0 0 0 0.2673
kij(4, :)=0 0 0 0 0.2417
kij(5, :)=0.7192 0.4598 0.2673 0.2417 0
kij(1, :)=0 0 0 0 0.7192
kij(2, :)=0 0 0 0 0.4598
kij(3, :)=0 0 0 0 0.2673
kij(4, :)=0 0 0 0 0.2417
kij(5, :)=0.7192 0.4598 0.2673 0.2417 0

! lij matrix
lij(:, :) = 0
/
Expand All @@ -51,18 +79,52 @@ all the relevant data for the system.
! Acentric Factor
w=0.098 0.535 0.891 1.085 0.344
/

&nml_px ! Px envelopes relevant info
! Temperature
T=350.0

! Initial composition, ussualy the same as the main fluid.
z_0=0.15 0.10 0.10 0.15 0.50

! Injection fluid composition
z_injection=1 0 0 0 0

! Which kind of injection to realize
injection_case="displace" ! [dilute|displace]
/
```

## Execution
This program is intended to work with `fpm`, to run it just use `fpm run`
### Output
All the output is directed to a generated folder `fenvelopes_output`. With the files

`env-<nphases>ph-<env_kind>_<envnumber>.dat`

Were all the envelope's calculated points are written in a `csv-like` format,
delimited by spaces.

## Installation
This program uses [`fpm`](https://fpm.fortran-lang.org) as a builder. `fpm`
handles all the needed dependencies and compiling procedures.
It is distributed in many ways, but we recommend the `pip` distribution.

## Output
Several output files are produced, `X_it*` files correspond to each iteration
point, `ENV2_OUT*` files correspond to the phase envelope structured to plot
with gnuplot, and there is also an `output.csv` file that contains the same
information but on another format.
```bash
# using pipx
pipx install fpm
```

To install this program is as simple as:

```
git clone https://www.github.com/fedebenelli/envelopes
cd envelopes
fpm install --profile release
```
This will make `fenvelopes` accessible from any directory of your computer

There is a simple `gnuplot` script to plot the phase envelope, just run
`gnuplot plot.gnu` to make the plot. It should look like this:
If you don't want to install the program and just run it you can also run it
with `fpm`

![](figs/example.png)
```bash
fpm run --profile release -- --infile <infile.nml PATH>
```
Loading
Loading