[ase-users] ase.db and magnetic moments
Steen Lysgaard
stly at dtu.dk
Thu May 22 11:01:13 CEST 2014
Hi,
I am having some difficulty extracting the magnetic moment assigned to
each atom in an atoms object from a .db file. I think the reason is that
magmoms and initial_magmoms are mixed up during the whole
atoms->dict->row->dict->atoms transformation. Consider the following:
>>> from ase.db import connect
>>> from ase.lattice.surface import fcc111
>>> db = connect('magmom.db')
>>> atoms = fcc111('Ni',(2,2,3))
>>> atoms.set_initial_magnetic_moments([0.6 for _ in range(len(atoms))])
>>> print atoms[0].magmom
0.6
>>> db.write(atoms,keywords=['magmom'])
1
>>> new_atoms = db.get_atoms(1)
>>> print new_atoms[0].magmom
0.0
>>> print new_atoms.get_initial_magnetic_moments()
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Doing this:
Index: ase/db/core.py
===================================================================
--- ase/db/core.py (revision 3638)
+++ ase/db/core.py (working copy)
@@ -497,7 +497,7 @@
dct['positions'],
cell=dct['cell'],
pbc=dct['pbc'],
- magmoms=dct.get('initial_magmoms'),
+ magmoms=dct.get('magmoms'),
charges=dct.get('initial_charges'),
tags=dct.get('tags'),
masses=dct.get('masses'),
fixes the exampleabove. But I am not sure that this will not mix up the
differentiation between magmoms and initial_magmoms further.
Best regards,
Steen
--
Steen Lysgaard
Post doc
Department of Energy Conversion and Storage
Technical University of Denmark
-------------------------------------------
Frederiksborgvej 399, P.O. Box 49
4000 Roskilde
Mobile +45 5194 4886
stly at dtu.dk
http://www.dtu.dk
More information about the ase-users
mailing list