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.
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:
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
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.
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.