The topological cluster classification (TCC) is a novel tool to measure the many-body correlation of the supercooled liquid and the gel systems. It’s documentation about setting it up is good for a laptop. But it need a bit modification to work on an HPC. Here I noted the major steps to make TCC work on the super computer in the university of Bristol, the BlueCrystal.


General steps

  1. Specifying necessary packages in the .bashrc file.
  2. Download the source code of TCC.
  3. Compile TCC.
  4. Running TCC.
  5. Using TCC inside Python.

1. Using Packages on BC

To use TCC, we need a C language compiler, and the GCC is a popular option. Then we need the software git to download the source code of TCC. Finally we need a building tool, the famous CMake, to help us compile the code.

Luckly, all of the softwares are already available on the BlueCrystal in UoB. We just need to “tell” the system that we will be using these tools. We do this by modifying the .bashrc file inside your $HOME directory. Typically we will need to append the following lines into .bashrc.

module add tools/git-2.18.0
module add languages/gcc-9.1.0
module add tools/cmake-3.13.4

This task can be challenging if you are not familiar with Vim/Emacs/Nano.

Using Vim to edit a file

Once you logged into the BlueCrystal, you will be in the $HOME directory. You can use the following command to edit the .bashrc file

vi .bashrc

Then we will enter the infamous text editor Vim. If you never used Vim before, think of it having two modes. The default one is a “safe mode” where you can not change the content.1 Then there is an “edit mode” where you can edit things.

Firsty we navigate our cursor to the bottom by pressing button. If you want to be old-fashioned, press j for the same movement.

Then we need to go to the edit mode. So press i, and type the following lines (you can copy and paste)

module add tools/git-2.18.0
module add languages/gcc-9.1.0
module add tools/cmake-3.13.4

Also,if you do not have your own Python2 on the blue crystal, I recommand using the latest version (version 3.7.7 in 2020). You get Python 3.7.7 by adding the the following line.

module add languages/python-3.7.7

In addition, I recommond adding the following line into the .bashrc file. The reason is written in the very long footnote. 3

export PATH=$PATH:$HOME/.local/bin

Then you need to press ESC to go back to the “safe mode”.

This is the end, and you can exit the editor with following options.

Applying the modification

We edited the .bashrc file, now we have to use command

source ~/.bashrc

to actually apply our modifications.

2. Downloading TCC source code

We will now going to download the source code of TCC from GitHub. You can download it via the following command

git clone https://github.com/royallgroup/TCC

After some seconds there will be a folder named TCC in the current folder. That is it!

3. Compiling TCC

Using the following command to compile TCC

cd TCC
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME/.local/bin ..
make
make install

The fourth line explictly tells cmake that we will put the tcc software in the folder $HOME/.local/bin

4. Using TCC

The normal way to to use the tcc software is running it directly inside a project directory. One example of such directory is TCC/examples/triclinic. The stucture is

triclinic/
├── box.txt
├── inputparameters.ini
├── README.md
└── tj.xyz

What you need to do is executing the follow commands.

cd triclinic
tcc

Then the software will be executed and you will get the results.

For more detailed descriptions about the meaning of different files, please go to the official documentation of TCC.

5. Using TCC inside Python

Peter, Josh and Francesco kindly wrote a python wrapper for TCC. This means we can run tcc directly inside our .py script.

We need firstly install the python module. Now going to the folder TCC. And type

python setup.py install --user

or

pip install . --user

The above commands will install the TCC wrapper. You can check it by importing the tcc module inside the interactive python console

YY@BC ~/tmp> python
Python 3.6.8 (default, Oct 30 2019, 10:39:13) 
[GCC 7.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tcc_python_scripts
>>> 

The tutorial about this python module is availabel on the offical documentation.

It is worth mentioning that since we put tcc into $HOME/.local/bin, we need specifying it in our python code. It is something like

TCC_setup = wrapper.TCCWrapper()
TCC_setup.set_tcc_executable_directory("/newhome/yy17363/.local/bin")

Please notice that you will need to specify the full absolute path of the folder that holds the tcc file. The yy17363 will be different on your account.

You can use the following script to check if your TCC wrapper is working or not.

import numpy as np
from tcc_python_scripts.tcc import wrapper


TCC_setup = wrapper.TCCWrapper()
# **** modify the following line for your account ****
TCC_setup.set_tcc_executable_directory("/newhome/yy17363/.local/bin")
TCC_setup.input_parameters['Run']['Frames'] = 1

# find TCC clusters in a random gas
# You will get something if you are very lucky
box = np.array([10, 10, 10])
frame = np.random.uniform(0, 10, (1000, 3))
results = TCC_setup.run(box, frame)

print(results)
  1. Actually the “safe mode” is called the command mode, and you can change the content of the file inside this mode. But it involves specific command that bind into special keys. For instance you can delete a word by typing dw, or delete 2 words by typing d2w.
    Indeed there are 3 different modes in Vim, being the command mode (safe mode), the insert mode (edit mode), and another view mode. These details do not really matter and you do not need to master Vim to get the job done. In case you somehow want to master Vim, I highly recommond this book

  2. The various versions of Python is a real pain currently (2020). It is a good idea to stick to 3.7.7 because it “works” in most cases. But sometimes I find myself being forced to go back to a specifc version. After a lot of pathetic attempt, I decided to follow Francesco’s advice to use pyenv. It really solved the version issue of Python and you may want to take a look at it if you are suffering too. 

  3. Originally TCC is designed to run on a personal computer, typicall with a linux operating system. In this case, softwares will be put into a common directory called /usr/local/bin. And you can use anything inside /usr/local/bin by just typing its name.
    For instance, if there is a software called wildcat who is being inside some random folder, for instance /usr/local/random. Then we will have to type
    /usr/local/random/wildcat to use the software wildcat.
    However, since tcc is inside /usr/local/bin, and this place is holy and special, we can just use tcc by typing only tcc instead of /usr/local/bin/tcc.
    While the idea of adding everything into /usr/local/bin sounds good and tempting, we can not do it on Blue Crystal. This is the rule, so that you won’t put a python2.7 into this place, renaming it to python3 and making everyone miserable.
    A popular options for HPC users are creating their own /usr/local/bin equivalent. And this place is normally chosen to be $HOME/.local/bin.
    However, this place is NOT special by default. And we have to make it special by adding export PATH=$PATH:$HOME/.local/bin into .bashrc. What we will do next, is to put the tcc software into $HOME/.local/bin, and since it is a special folder now, we can use tcc by just typing tcc