GPAW installation with pip

Between installation with conda and compilation of libraries, an intermediate path – installation of GPAW with pip – is a compromise for those who wish to text specific GPAW branches or packages.

For example, I wish to text self-interaction error correction (SIC) and evaluate Bader charges with pybader. Neither SIC nor pybader is compatible with the recent GPAW. Here is not to get a workable version.

# numba in pybader is not compatible with python 3.11, so create a conda environment with python 3.10
conda create -n gpaw-pip python=3.10 
conda activate gpaw-pip

conda install -c conda-forge libxc libvdwxc
conda install -c conda-forge ase
# ensure that you install the right openmpi (not external)
conda install -c conda-forge openmpi ucx
conda install -c conda-forge compilers
conda install -c conda-forge openblas scalapack
conda install -c conda-forge pytest
pip install pybader

# Get a developer version of GPAW with SIC
git clone -b dm_sic_mom_update
cd gpaw

# In the rewrite
fftw = True
scalapack = True
if scalapack:
    libraries += ['scalapack']

unset CC
python -m pip install -e .
gpaw info

Some pictures on preparing my MSCA proposal

While preparing the final report on the past MSCA project, I found some memorable pictures. Here me, my wife and nephew are building a LEGO illustration for the project proposal. Yes, we had some fun while I was thinking about the concept.

The results looks pretty.

Still, as the concept illustration, I draw this figure. Today, I have reused it for the report illustration.

Visualizing ASE atoms in Jupyter notebooks

For a long time I wanted to see ASE atoms in my Jupyter notebook. My previous attempts were usually unsuccessful. Today I decided to try again. First ASE wiki suggests x3d and webngl:

view(atoms, viewer='x3d')
view(atoms, viewer='ngl')

Łucasz Mentel gives some useful tips in his blogpost from 2017.

In my case x3d works and webngl fails. The x3d picture is not enought, and I do not want to spend much time on fixing webngl.

ASE-notebook is what works for me.

conda create -n "jupyter"
conda activate jupyter
conda install -c conda-forge ase-notebook
conda install -c conda-forge jupyterlab

By the way, the model is from my “Surface Curvature Effect on Dual-Atom Site Oxygen Electrocatalysis” paper, which you can read at chemRxiv until it turns Gold Open Access.

Creating scientific figures with versioning

While working on the “Potential of monolayer charge” letter, we learned that saving figure versions is essential. In particular, while working on the first Figure (representing the concept), we started with this sketch as an intermediate of a cartoon from “Overscreening versus Crowding” and MD snapshots from “Interfaces between Charged Surfaces and Ionic Liquids.”

With chatGPT, we created a wavy electrode and arranged ions in Matplotlib. Then, we created over 30 versions in Inkscape, as shown in this animation (also made with guidance from chatGPT):

Versions of Figure 1

It was crucial to have versions instead of working on the same file because we often reverted to previous versions after trying new visual elements. Our final figure illustrates that the Potential of Monolayer Charge (PMC) is right between overscreening and crowding regimes. Moreover, the PMC can fit into the electrochemical stability window by lowering its absolute value with varying ion area. Read more in the “Potential of monolayer charge” letter.

A cappella by ChatGPT

Here are two examples of lyrics generated by ChatGPT. To make it even more fun, copy-paste the text to (better than google translate) and make it read/sign the lyrics. melobytes is not good at all.

Verse 1:
Carbon in the air, causing so much harm
But we can make a change, with carbon capture
Trapping it away, before it can do more
We can reduce the harm, and protect our shore

Carbon capture, carbon capture
A solution for our planet’s future
Carbon capture, carbon capture
Together we can make it happen

Verse 2:
Technology is key, to making it a success
We can power our lives, while reducing the excess
Carbon in the air, will no longer be a threat
With carbon capture, we can make a new bet

Carbon capture, carbon capture
A solution for our planet’s future
Carbon capture, carbon capture
Together we can make it happen

We can make a difference, with every step we take
Towards a brighter future, for the sake of those who’ll come
Let’s work together, and make this dream come true
With carbon capture, we can make a better future for you

Carbon capture, carbon capture
A solution for our planet’s future
Carbon capture, carbon capture
Together we can make it happen.

and another one

Electricity, oh electricity
Flowing through a circuit so free
But when it comes to ionic liquids
There’s more to it, as you’ll see

The electric double layer
Is a fascinating thing
It forms between the electrodes
And the ionic liquids they bring

The ions in the liquid
Are attracted to the metal
They line up in a layer
It’s really quite essential

This double layer of charge
Controls the flow of electricity
It’s a key part of the circuit
That makes our technology so advanced, you see

So next time you flip a switch
Or plug in your phone to charge
Think of the electric double layer
Making it all possible, oh so large!

k-points with kplib and gpaw

Choosing optimal k-points is a tricky task. In GPAW, one can set them manually, using size or density and following a rule of thumb:

calc = GPAW(kpts={'size': (4, 4, 4), 'gamma': True})
# or
calc = GPAW(kpts={'density': 2.5, 'gamma': True})

A rule of thumb for choosing the initial k-point sampling is, that the product, ka, between the number of k-points, k, in any direction, and the length of the basis vector in this direction, a, should be:

  • ka ~ 30 Å, for d band metals
  • ka ~ 25 Å, for simple metals
  • ka ~ 20 Å, for semiconductors
  • ka ~ 15 Å, for insulators

Remember that convergence in this parameter should always be checked.

The corresponding densities (ka/2π) are:

  • ka/2π ~ 4.8 Å, for d band metals
  • ka/2π ~ 4.0 Å, for simple metals
  • ka/2π ~ 3.2 Å, for semiconductors
  • ka/2π ~ 2.4 Å, for insulators

With the recent update, I can start using kplib (see paper) to choose the optimal generalized k-point grids. The main variable in kplib is min_distance, which is analogous to the density×2π. Read more about the min_distance at

Here is an example of my conda environment

conda create -n gpaw23 python=3.9
conda activate gpaw23
conda install -c conda-forge cxx-compiler
pip install kplib # from
conda install -c conda-forge gpaw

Here is a working example:

from ase import Atoms
from ase.parallel import parprint
from gpaw import GPAW, PW
from kpLib import get_kpoints
from import AseAtomsAdaptor

atoms = Atoms(cell=[[1.608145, -2.785389, 0.0], [1.608145, 2.785389, 0.0], [0.0, 0.0, 5.239962]],
              symbols=['Ga', 'Ga', 'N', 'N'],
              positions=[[ 1.608145  , -0.92846486,  2.61536983],
                         [ 1.608145  ,  0.92846486,  5.23535083],
                         [ 1.608145  , -0.92846486,  4.58957792],
                         [ 1.608145  ,  0.92846486,  1.96959692]],
structure = AseAtomsAdaptor.get_structure(atoms)
kpts_data = get_kpoints(structure, minDistance=30, include_gamma=False)
parprint("Found lattice with kplib: ")
parprint(f"Nominal kpts: {kpts_data['num_total_kpts']}")
parprint(f"Distinct kpts: {kpts_data['num_distinct_kpts']}")

atoms.calc = GPAW(xc='PBE',
                  symmetry={'point_group': True,
                            'time_reversal': True,
                            'symmorphic': False,
                            'tolerance': 1e-4},
energy = atoms.get_total_energy()

parprint(f"Total energy: {energy}")
parprint(f"kpts passed to GPAW: {len(atoms.calc.get_bz_k_points())}")
parprint(f"kpts in GPAW IBZ: {len(atoms.calc.get_ibz_k_points())}")

Working with RSS

RSS is a site summary – a format used to create feeds with articles’ metadata, including Graphical Abstract, Title, Publication data, Authors, and Abstract.

Here is my way of organizing RSS flows. Let us take as an example ACS journals. Their RSS feeds are all given on one page:

I have copied them all by opening the html-code and taking the urls, which I then merge into a single opml-file at

Then I uploaded the opml-file to a very old but still working webpage:

feedrinse merges all feeds into one “channel” feed. Here is my merged feed:

Using feedrince’s interface is tricky. Check this blogposts for a step-by-step instruction:

In my case, feedrince’s filters do not work. So, I turned to , where one can set up a regex filter. You can check your regex expression at Here is my example:


which finds all words containing “electro” or “cataly” or “double”.

From siftrss I got a new feed that I entered to my RSS reader.

I am currently using online and mobile RSS readers, which are synced together. Namely, I use Nextcloud News, because I have a Nextcloud account.

In these RSS readers, one can see the essential info about each article and star articles. It is a pleasure to swipe articles on the mobile phone and star interesting articles. Later one can open the stared articles from the online reader and go to the publisher’s webpage. At that stage, I also use Reader View (in Firefox) and listen to the abstract.

Nextcloud news
Nextcloud News (mobile)

P.S. Here are all ACS feeds (as for dec 2022):

Playing with Galactica

Installation of Galactica is as easy as:

conda create -n papers python=3.8
conda activate papers
pip install galai transformers accelerate

Now you can work with the simplest Galactica models (125m, 1.3b, 6.7b) using CPUs. Here is my script:

from transformers import AutoTokenizer, OPTForCausalLM
import sys

tokenizer = AutoTokenizer.from_pretrained("facebook/galactica-6.7b")
tokenizer.pad_token_id = 1
tokenizer.padding_side = 'left'
tokenizer.model_max_length = 200
model = OPTForCausalLM.from_pretrained("facebook/galactica-6.7b", device_map="auto")

#input_text = '# Introduction \n\n The main idea of the paper "Supervised hashing for image retrieval via image representation learning" is'
#input_text = "# Review \n\n The main idea of the paper 'On the thickness of the double layer in ionic liquids'"
#input_text = "# Review High entropy alloys in electrocatalysis"
input_text = str(sys.argv[1])
input_ids = tokenizer(input_text, padding='max_length', return_tensors="pt").input_ids

outputs = model.generate(input_ids, max_new_tokens=200,

Run it on your laptop as:

python "YOUR QUERY"

For example, let us check what Galactica know about HEA:

python "High entropy alloys in catalysis "

6.7b model will give:

High entropy alloy catalysis (HEAC) is a new concept for catalytic applications. A series of HEAs with a similar chemical composition (CoCrFeNiMn) were prepared by arc-melting and characterized by X-ray diffraction (XRD), X-ray photoelectron spectroscopy (XPS), and high resolution transmission electron microscopy (HRTEM). The catalytic performance of the HEAs was tested in the CO oxidation reaction. The catalytic activity of the HEAs is compared with that of the pure metals and the HEA-supported Pt catalysts. The results show that the HEAs are active in the CO oxidation reaction, and that the activity is comparable to that of the Pt catalysts. The HEAs have a much lower activity than the pure metals. XPS and HRTEM results show that the HEAs have a different surface structure than the pure metals, which is probably the reason for the high catalytic activity of the HEA.


Also, let us review a paper by the CHEAC founders:

python '# Introduction \n\n The main idea of the paper "Self-supported Pt–CoO networks combining high specific activity with high surface area for oxygen reduction" is'

“Self-supported Pt–CoO networks combining high specific activity with high surface area for oxygen reduction” is to report the synthesis of highly porous self-supported electrocatalysts, which combine high surface area with high specific activity for the oxygen reduction reaction (ORR). The synthesis is based on a self-supported network of Pt doped CoO (Pt-CoO) nanoparticles, which are prepared by a two-step process. In the first step, Pt-doped Co₃O₄ (Pt-Co₃O₄) nanoparticles are formed via the thermal decomposition of Co- and Pt-oleate complexes, followed by the oxidation of Pt-Co₃O₄ to Pt-CoO at 550 °C. The resulting porous self-supported network consists of Pt-CoO nanoparticles with diameters of 4–5 nm and a high surface area of 130 m2/g. The specific activity of the Pt-CoO network for the ORR is 2.6 times higher than that of the Pt/C catalyst, and the mass activity is 2.


You can run the same code in Google Drive with colab.

Here are some links:

P.S. seems to be much cooler!

Positive writing

Here are my notes and thoughts about positive writing.

Positive writing helps to communicate better with readers. Naturally, positive writing is more concrete than the negative one. For instance, just removing “not” in  “bananas are not vegetables” or “bananas are not blue” and turning it into positive “bananas are yellow fruits” results in a clear undeniable statement. Another aspect of positive writing is tuning the reader’s attitude towards your ideas. Psychologically, after going through easily agreeable sentences, like “bananas are sweet” and “bananas are colorful”, the reader will be more ready to agree on your conclusion that “a banana is a comfort and nutritious choice for a lunchbox”.

More text with examples are under editing 🙂

External XC libraries for GPAW

There are two libraries of XC functionals that can be used in GPAW. These are libxc and libvdwxc. Conda installation of GPAW automatically picks them. You can check whether your GPAW connects to libxc and libvdwxc like gpaw info.

libvdwxc is useful when you wish to run calculations with vdW-functionals and GPAW. Such as BEEF-vdW. Herewith, libvdwxc implementation of vdW-functionals are better parallelized than the native GPAW implementation. For example, add the following line to your GPAW calculator xc={'name':'BEEF-vdW','backend':'libvdwxc'} to run a calculation with the BEEF-vdW functional. BEEF-vdW calculations with libvdwxc can run as fast as PBE-like calculations if you use the proper grid, like parallel={'augment_grids':True,'sl_auto':True}. Here is a list of libvdwxc functionals:

Note that the following GPAW page is somewhat outdated:

libxc is useful when you wish to run calculations with functionals that are not implemented in GPAW. Note that GPAW implementation is more efficient. There are many ways to call for libxc. For example, add the following line to your GPAW calculator xc='MGGA_X_SCAN+MGGA_C_SCAN' to run a calculation with the SCAN functional. Nore that GPAW setups are for LDA, PBE, and RPBE. You can generate setups specifically for your functional if it is GGA or HGGA. Here is a list of libxc functionals: