Skip to content

Commit

Permalink
Merge pull request #2 from fedebenelli/Pxvelopes
Browse files Browse the repository at this point in the history
Merging Px envelopes branch
  • Loading branch information
fedebenelli authored Sep 18, 2023
2 parents 568f7f2 + d4c2af1 commit d47e46b
Show file tree
Hide file tree
Showing 25 changed files with 2,390 additions and 1,807 deletions.
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

0 comments on commit d47e46b

Please sign in to comment.