materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.48k stars 850 forks source link

get_reduced_structure method of IStructure not work #330

Closed hlyang1992 closed 8 years ago

hlyang1992 commented 8 years ago

System

get_reduced_structure method of IStructure not work,

fn = "Si-51688.cif"
si = mg.IStructure.from_file(fn)
p = Poscar(si.get_reduced_structure())
print(p) 

output is:

Si8
1.0
5.430530 -0.000000 0.000000
0.000000 5.430530 0.000000
-0.000000 -0.000000 5.430530
Si
8
direct
0.250000 0.250000 0.250000 Si0+
0.000000 0.000000 0.000000 Si0+
0.250000 0.750000 0.750000 Si0+
0.750000 0.250000 0.750000 Si0+
0.750000 0.750000 0.250000 Si0+
0.000000 0.500000 0.500000 Si0+
0.500000 0.000000 0.500000 Si0+
0.500000 0.500000 1.000000 Si0+

but when use read_structure read structure file, get_reduced_structure will work:

from pymatgen.io.smart import read_structure
fn = "Si-51688.cif"
si = read_structure(fn)
p = Poscar(si.get_reduced_structure())
print(p)

output is:

Si2
1.0
2.715265 2.715265 0.000000
2.715265 0.000000 -2.715265
0.000000 2.715265 -2.715265
Si
2
direct
0.750000 0.750000 0.750000 Si0+
0.000000 0.000000 0.000000 Si0+
shyuep commented 8 years ago

This is not a problem with get_reduced_structure. When you use from_file, it does not reduce your structure to a primitive cell by default. If you add primitive=True, it should work as intended.

shyuep commented 8 years ago

Fixed in https://github.com/materialsproject/pymatgen/commit/0cfa800a56c850edfa6084ac9656db532de3639a

hlyang1992 commented 8 years ago

I think this is a problem with get_reduced_structure @shyuep . If I don't reduce structure when use from_file, I will not able to use structure.get_reduced_structure method to get a reduced structure. It will affect VaspInputSet, such as in DictVaspInputSet of sets.py: get_poscar

If I use from_file without primitive=True and give this structure to DictVaspInputSet with reduce_structure="niggli", I can't get reduce structure by using write_input method.

shyuep commented 8 years ago

This is not a problem with get_reduced_structure. You misunderstand what "reduced" means. "Reduced" is lattice vector reduction, which means that the shortest vectors are found. It does not mean primitive cell reduction. If you want to do primitive cell, you should call structure.get_primitive_structure() first.

hlyang1992 commented 8 years ago

Thank you very much.