Hi Ngan Huynh,
The point is, you have not initialized your Lattice object yet. You can look at the source code in pymatgen/core/lattice.py at init method. You have to provide three vectors that define your Lattice. For example,
l = Lattice([[10, 0, 0], [20, 10, 0], [0, 0, 30]])
with lattice vectors [10, 0, 0], [20, 10, 0] and [0, 0, 30].
Another way more convenient, you can use Vasprun to get structure from vasprun.xml file.
from pymatgen.io.vasp.outputs import Vasprun
run = Vasprun(“vasprun.xml”)
struct = run.final_structure
lattice = struct.lattice()
And now you have a lattice object.
Thank you for the explanation. I will give it a try. I also found that if I called .cartesian_coord from Structure, I could get the coordinates too. Just not so sure if they are correct
No, it does not. The init method of Structure class in pymatgen/core/structure.py has a variable coords_are_cartesian: bool = False/True which just clarifies that the “coords” you use to initialize Structure are given in Cartesian or fractional coordinates.
Structure contains site objects. For example, you have structure object (defined through Structure class), then try
sites = structure.sites
for site in sites:
where, site.coords and site.frac_coords give you Cartesian and fractional coordinates, respectively.
Sorry for a misunderstanding. I don’t remember the Structure has cartesian_coord attribute as you mentioned but you can try and compare with the coordinates from site objects.
Thank you for helping and explaining!
I just tried both, and I got the same coords. So happy to solve this one.
One thing for the for-loop is that if we print out both frac and cartesian, the coords will be sorted.
Thank you again!