7
$\begingroup$

I have atom_row from ase_db. I have tried various methods but they all fail. Seems like I'm missing a lattice, but I don't know what that is and where I can get it for my structure.

$\endgroup$
1
  • 3
    $\begingroup$ Could you detail the various methods you tried and how they fail so that we don't ended up suggesting what you already tried? $\endgroup$
    – Hebo
    Mar 31, 2022 at 8:31

2 Answers 2

6
$\begingroup$

Try AseAtomsAdaptor.get_structure method from pymatgen.io.ase, it actually serves exactly this purpose.

$\endgroup$
3
  • $\begingroup$ I tried this method but got an error, most likely because my atoms don't have bonds $\endgroup$ Apr 14, 2022 at 10:16
  • $\begingroup$ @Dmitry Sokolov please, post your code and exact error stack trace here $\endgroup$ Apr 14, 2022 at 19:55
  • $\begingroup$ code: from pymatgen.io.ase import AseAtomsAdaptor row = database.get(1) AseAtomsAdaptor.get_structure(row.toatoms()) error: /opt/conda/lib/python3.7/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_singular(err, flag) 86 87 def _raise_linalgerror_singular(err, flag): ---> 88 raise LinAlgError("Singular matrix") 89 90 def _raise_linalgerror_nonposdef(err, flag): LinAlgError: Singular matrix I also have tried matador package, error was like no lattice or smth, I don't remember $\endgroup$ Apr 15, 2022 at 16:49
1
$\begingroup$

This is how I wound up getting things working.

I saved atom as xyz:

atoms = row.toatoms()
atoms.write(f"./{dir_}/{i}_{str(atoms.symbols)}.xyz")

Then, I opened the xyz in pymatgen:

from pymatgen.core import Molecule
structures = [Molecule.from_file(train_path 
               + '/' + file) for file in train_files]
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .