Skip to content

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

FreeRCM

FreeRCM is a free, graphical-user-interfaced residue curve mapping tool that is helpful for designing distillation columns, especially for entrainer screening for extractive distillation columns. This specific program also allows for simulations to be saved as "*.rcm" files and opened later.

Important

Below is a quick guide on getting the program running, a bit of info on the methodology behind residue curve mapping, and (important!!) info on what units of measure and coefficients are used in the models. For more details on project structure, features, requirements, and more, see the README at freeRCM/README.md.

How to use:

Once you are in the freeRCM/ directory of the cloned repository, use the following command to ensure that you have the correct Python requirements:

pip install -r build/requirements/pyReqs.txt

With an Apple Silicon machine, the solver binaries come pre-compiled, so just execute with Python:

python launch.py

If your system has different architecture, you will have to compile the solver binaries:

cd build
make
cd ..

Note

I've been experimenting with building a standalone app using Nuitka; however, I'm still resolving some startup time issues with matplotlib and PySide6 so this is the best way for now.

1. Create a new or open an existing simulation:

The "Open Simulation" button will prompt a "*.rcm" file to be selected. Example simulations in docs/examples/ has been provided for you to play around with the program.

StartScreen

2. Set up or modify a simulation:

Add components by clicking the "Add Component" button and delete them by selecting a component and clicking "Delete Component." Make sure three components are in the "Selected Components" box before continuing. Components can be added to or removed from here by selecting a component and clicking ">>" or "<<."

SimSetUp

Additionally, you must also ensure that for your selected thermodynamic model, all parameters have been input. Click on "Input Parameters" and copy/paste parameters from Excel (or enter manually) to do this.

Important

All methods deal with temperature in units of Kelvin and pressure in units of bar. Also, it is HIGHLY recommended to use the extended Antoine equation (PLXANT) for calculating saturation pressure (as opposed to the regular Antoine equation) since the regular Antoine equation option often leads to bugs. I hypothesize that this is due to the fact that the extended Antoine equation is better at dealing with wider temperature ranges (RCMs keep pressure constant, temperature varies) and is overall more accurate, which leads to superior numerical stability when solving VLE equations.

InpParams

3. Create plots, have fun!

Either auto-generate curves or click on the plot to generate a curve. Click on "Save Simulation" to save a "*.rcm" to return to your simulation later.

Screenshot 2024-08-19 at 11 03 56 PM

Tip

If any lines don't come out smooth or don't solve correctly, decrease the step size, dxi, which is available under Solver Options. Don't worry about performance, I rewrote the solver in pure C and Fortran (because SciPy was slow and took awhile to load, also to become better at the two languages), so it can basically run on a potato.

How it works:

Residue curve mapping is used to determine, from any starting composition, the only possible path forward and backward in a distillation. From any point, there is only one possible path because residue curves do not intersect. Residue curves are determined from the the differential equation:

$$\frac{dx}{d\xi} = x - y$$

This can be solved forward and backwards in warped time, $\xi$, through the difference equation:

$$x_{i+1} = x_i + \Delta\xi(x_i - y_i)$$

During each step in warped time, $y_i$ is found via vapor-liquid equilibria relations with $x_i$. The result of this is displayed below:

firstExample

Important

The NRTL activity coefficient model sometimes comes in different forms. The form used in this program is as follows:

$$\ln{\gamma_i} = \frac{\sum_j x_j\tau_{ji}G_{ji}}{\sum_k x_kG_{ki}} + \sum_j \frac{x_jG_{ij}}{\sum_k x_kG_{{kj}}}\left(\tau_{ij} - \frac{\sum_m x_m\tau_{mj}G_{mj}}{\sum_k x_kG_{kj}}\right)$$

where: $G_{ij} = \text{exp}(-c_{ij}\tau_{ij})$ and $\tau_{ij} = a_{ij} + b_{ij}/T$

Note

The Extended Antoine equation used is as follows:

$$\ln{P_i^{SAT}} = C_{1,i} + \frac{C_{2,i}}{T+C_{3,i}} + C_{4,i}T + C_{5,i}\ln{T} + C_{6,i}T^{C_{7,i}}$$

Important

Other methods (like regular Antoine and SRK) use their most standard forms, so there should not be much ambiguity when inputting parameters. Please remember, as mentioned before, that all methods deal with temperature in units of Kelvin and pressure in units of bar.

Features to be added/bugs to be fixed in the future:

  1. Automatic acentricity prediction for SRK using Pitzer correlation.
  2. Add useful information to "Help" buttons.
  3. Build standalone app (with Nuitka or something). I've already done this, but startup time is horrendous because of matplotlib and PySide6 (takes about 15 seconds to initialize on my system). If anyone knows of any way around this (maybe lazy loading matplotlib), please let me know.
  4. Parameter auto-fill from databank?
  5. Possibly add a feature to display phase separation regions.
  6. Fix the way that windows are regenerated.

Additional Info

If you need a fast way to calculate NRTL activity coefficients, SRK fugacity coefficients, or SRK compressibilty factors in your Python projects, nifco.f90 can readily be compiled with f2py (now comes bundled with numpy) to become Python-callable.

If you need to recompile RCM_solver.so and something is wrong with the Makefile, follow these steps:

  1. Ensure you have the correct libraries installed, including:
  • GNU Scientific Library
  • MINPACK
  • GSL can be installed with your package manager or here. MINPACK can be found here under src/.
  1. Compile and link:
gcc -O3 -fPIC -I/path/to/gsl/2.8/include RCM_solv.c -c RCM_solv.o
gfortran -fPIC -c nifco.f90 nifco.o -O3 -mmacosx-version-min=14.4 -I/path/to/libminpack.so -I/path/to/minpack_module.mod
gcc -shared -o RCM_solver.so RCM_solv.o nifco.o -L/usr/local/lib -L/path/to/gsl/2.8/lib -L/path/to/gcc/current/ -L/path/to/libminpack.so -lgsl -lgslcblas -lgfortran -lminpack

Note

Note that (obviously) the library paths to files should be the paths to the directories in which they reside. Change the directories accordingly. Also, minpack_module.mod is compiled from the module provided with MINPACK.

References:

About

Free residue curve mapping tool for designing distillation columns, especially when it comes to entrainer screening for extractive distillation columns.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages