Problems in calculating the reaction energy between different compounds

Hi there,
I want to find and calculate the reaction energy between different compound (‘Li’, ‘Al’, ‘CO2’, ‘O2’) using the command of CompoundPhaseDiagram.
The input is “el1 = ‘Li’ el2 = ‘Al’”.
I tried to find the reactants and products, and also to fix the reaction formula. However, I met the error below when it proceeded to line 123. I listed the error in the picture.

Can anyone kindly help me to improve and fix the code?

The error is “IndexError: list index out of range”.

It might help to print out multiplicity - the error most likely indicates that multiplicity.split() returns a list with only one item, so you can’t access the second item of the list.

1 Like

Hi @davetao-py,

I am not quite sure how to troubleshoot your specific code from just the screenshots, but for computing reaction energies, I would recommend taking a different approach that I personally find a lot easier and more robust than manual inspection of the phase diagram.

You can either use:

  1. The ComputedReaction class in pymatgen to automatically balance and find reaction energies if you have the ComputedEntry objects for both the reactants and products:
    pymatgen.analysis.reaction_calculator module — pymatgen 2022.2.10 documentation

  2. Or the InterfacialReactivity class in pymatgen to automatically find all computed reactions between two phases which result in a decrease in the free energy of the system; this is akin to inspection from the phase diagram:
    pymatgen.analysis.interface_reactions module — pymatgen 2022.2.10 documentation

Hopefully this helps.

1 Like

Yes, you are right. The list returned is empty. I need to revise the code thoroughly, but I am not familiar with pymatgen package. That will take me a long time.

Hi, thanks for replying, the ComputedReaction class may help, then let me have a try.

1 Like