Rachford-Rice Contest
This is the 25 + 1 year anniversary version of the 1995 Rachford-Rice contest. Can you solve the Rachford-Rice problem for all these cases? With the initiative of Curtis Hays Whitson, and the extensive help by Aaron Zick, the original Rachford-Rice contest offered $1000 to any student who could solve the problem for all cases. Only three people were able to develop procedures that passed all the test, and none of these were students.
Today we are happy to re-release the Rachford-Rice contest, but now for Python. There are several differences between the original contest and this version, the main one being that this version will focus mainly on passing all the tests and not that much on speed. A timer will be set for your calculations, so if you want to optimize for speed as well you are free to do so.
To access the original version of the Rachford-Rice contest, go to this link.
Table of Contents
- How do you access the code?
- How do you enter your code?
- Basic theory about Rachford-Rice problem
- List of participants who have successfully completed
How do you access the code?
You can either use Git to clone the repository using
git clone https://github.com/WhitsonAS/Rachford-Rice-Contest.git
If you do not want to use Git or know how to use Git, you can manually download the repository by clicking the green code button and press the option called "Download ZIP".
How do you enter your code?
The main stucture of the code is not to be modified at all, so you are only supposed to write code in certain designated files or functions. The file that contains the function which you have to change is called rachford_rice_solution.py
and the function is called rachford_rice_solver()
. This is the only place where you can change anything.
The function takes in the number of components (Nc
) as an integer, the composition (zi
) as a numpy array, and the K-values (Ki
) as a numpy array.
The output of the function must be given in the following order, as the following types. The number of iterations used (N
) as an integer, the vapor molar composition (yi
) as a numpy array, the liquid molar composition (xi
) as a numpy array, the vapor molar fraction (V
) as a float, and the liquid molar fraction (L
) as a float.
For debugging purposes, there is an option in section (3) in the main.py
file in the function called is_converged()
where you can turn on an optinal variable called print_to_console
(which is False
by default) by setting it to True
. This feature will print some useful information about which tests pass / fail for each case.
See video 5 for an example of how to add you code.
Note that you're not allowed to change the floating point precision to get the desired threshold! The goal is that your algorithm should be able to have a threshold equal to your floating point precision. Any solution based on floating point manipulation of this kind will be disqualified.
When you have developed a code that you want to submit, make a folder within the folder called Solutions
with the date of your submission (YYYYMMDD) and your name (e.g. 20211015-Markus-Hays-Nielsen
) and add a file called solution.py
within this folder (the relative path should look like this: Solutions/20211015-Markus-Hays-Nielsen/solution-py
). The solution file should be possible to copy and paste straight into rachford_rice_solution.py
and run with no modifications needed. If there is any issue with running your solution, you will be contacted and asked to fix the issue. If no answer is recived, the solution will be removed. This is meant to make everything easier for the reviewer and anyone else who wants to try your code.
The procedure for adding your code to the repository is to first make a new branch with your name (e.g. markus-hays-nielsen
) and once you are ready to submit you can create a pull request with your file(s) in the structure detailed above. Once your code has been reviewed, we will add your code to the main branch and it will become public.
If you want to submit you solution privately, please contact us by mail at [email protected].
Basic theory about Rachford-Rice problem
The Rachford-Rice equation is a combination of (1) the material balance equation, (2) the assumption that the vapor (yi) and liquid (xi) compositions are defined by a constant set of K-values (Ki) and (3) that the sum of vapor and liquid molar fractions sum to one.
The equation is given by
where zi is the total molar composition of component i, and V is the vapor molar fraction defined by
where nV is the total molar amount of the vapor phase and nL is the total molar amount of the liquid phase.
The constraints for passing the contest are given by a set of test functions (R) and are given by
Vapor composition test
Liquid composition test
Vapor and liquid fraction test
Material balance test
K-value test
where the threshold value (εt) is set to be 10-15.
The tests will be judged based on their severity which is given by
For more information about the Rachford-Rice solution, watch the following videos:
List of participants who have successfully completed
- Aaron Zick
- Michael Michelsen
- Kim Knudsen