'str' object has no fractional atribute 'fractional_composition'

Dear Forum,

I have a problem when trying to generate a list for interfacial reactions with PyMatgen

After loging with materialsproject API key, and generating entries for my phase space of interest. I generate the phase diagram (‘pd’ in this post), to then generate possible interfacial reactions between A and B reactants.

But when trying to initialize the object for these reactions

ir = InterfacialReactivity(‘A’,‘B’,pd,use_hull_energy=True)

I get the following error

'~\Anaconda3\lib\site-packages\pymatgen\analysis\interface_reactions.py in init(self, c1, c2, pd, norm, include_no_mixing_energy, pd_non_grand, use_hull_energy)
107 if self.norm:
–> 108 self.c1 = c1.fractional_composition
109 self.c2 = c2.fractional_composition
110 self.comp1 = self.comp1.fractional_composition

AttributeError: ‘str’ object has no attribute ‘fractional_composition’’

Is this common? If so, how can I solve it?

Thanks in advance,



You have to give Composition objects not string compositions. Try something like this:

from pymatgen.core import Composition
ir = InterfacialReactivity(Composition(‘A’),Composition(‘B’),pd,use_hull_energy=True)
1 Like