To solve the error: "TypeError: 'CompoundPhaseDiagram' object is not iterable"

Dear Maintainers & Developers,
It’s my first time to use pymatgen, when I use the command of ‘CompoundPhaseDiagram’, the error listed below occurred, how to solve this ‘TypeError’? Can you give me some suggestions?


CompoundPhaseDiagram is itself a PhaseDiagram, i.e. it is a child class of PhaseDiagram. You do not need to initialize it by passing pd to PhaseDiagram. The PhaseDiagram constructor takes a list of entries as input, which is the thing it is trying to iterate in the error message, but it finds your object pd instead.

2 Likes

:wave:thanks for replying, Iet me have a try.

Dear Mr.Nicholas,

I have the typeError: ‘PhaseDiagram’ object is not iterable,
I was try your suggestion, but it sill error,
So can you instruct to me for slove this problem with other way?
Thank for your helping,

Dear @buithitham

ChempotDiagram requires “entries” to work.
In your case, it looks like you put in a PhaseDiagram.

Refer this code:

from mp_api.client import MPRester
from pymatgen.entries.computed_entries import GibbsComputedStructureEntry
from rxn_network.thermo.chempot_diagram import ChempotDiagram
with MPRester('xxxx') as mpr:  
    entries = mpr.get_entries_in_chemsys("Li-Co-O")
entries_RT = GibbsComputedStructureEntry.from_entries(entries, 300)
cpd_from_rxn = ChempotDiagram(entries_RT)
cpd_from_rxn.get_plot()

You can get this ChempotDiagram

Dear Mr.Kim,

I was solve my problems,
Thank for your hepling!

1 Like

Hi @buithitham,

Glad you were able to get it fixed! Note that your issue differs from the original issue in this post (which was about CompoundPhaseDiagram).

I also wanted to give a heads-up that you are importing ChempotDiagram from the rxn_network package, but the class ChempotDiagram only exists to add features I wanted to include in the analysis of reaction networks.

So to avoid future confusion and more dependencies, you should probably import it as follows:

from pymatgen.analysis.chempot_diagram import ChemicalPotentialDiagram
2 Likes

Dear Mr.mattmcdermott
Thank you so much for helping!