[ase-users] magnetic moments

Carsten Rostgaard Carsten.Rostgaard at fysik.dtu.dk
Fri Jan 16 11:34:07 CET 2009


Ahh... I forgot one point.

To clarify:
atoms.get_magnetic_moments() returns the calculated local magnetic moments
atoms.get_initial_magnetic_moments() returns the value of magmoms, set 
in the constructor of the Atoms class

But:
atoms.set_magnetic_moments() Set the *initial* magnetic moments, i.e. 
the Atoms attribute, which does not depend on the calculation.

Maybe we should rename the latter to atoms.set_initial_magnetic_moments() ?

ps. this explains why
atoms.set_magnetic_moments(1)
print atoms.get_magnetic_moments()
does not give the same value.

Carsten Rostgaard wrote:
> No, they are written / read correctly, but a few weird things happen. 
> Consider the follwing
>
> from ase import *
> from gpaw import *
>
> calc = GPAW()
> atoms = molecule('CH', calculator=calc, cell=[5, 6, 7])
> atoms.center()
> atoms.get_potential_energy()
>
> print atoms.get_magnetic_moment() # 1
> print atoms.get_magnetic_moments() # array([ 1.01433322, -0.01433322])
> print atoms.get_initial_magnetic_moments() # array([ 1.,  0.])
>
> calc.write('test.gpw')
>
> atoms, calc = restart('test.gpw')
> print atoms.get_magnetic_moment() # 0
> print atoms.get_magnetic_moments() # array([ 1.01433322, -0.01433322])
> print atoms.get_initial_magnetic_moments() # array([ 1.01433322, 
> -0.01433322])
>
> The commented values are the outputs.
>
> As you see, the total magnetic moment is lost when writing a gpw file 
> (this is a bug I reported back in May 2008 
> https://trac.fysik.dtu.dk/projects/gpaw/ticket/43).
>
> The second weird thing is that the initial magnetic moments property 
> on the atoms gets changed to the calculated local magnetic moments 
> after dumping to file. I think this is intentional though, as this 
> will be a better starting guess if you restart a calculation.
>
> Cheers,
> Carsten
>
>
> Vivien Petzold wrote:
>> Dear ASE users,
>>
>> I have made some mysterious observations by doing the following:
>>
>> > from gpaw import restart
>> > atoms, calc = restart(<myfile>)
>>
>> <myfile> is a gpw-file containing an originally spin-polarized 
>> calculation of a Cl2 molecule. Both atoms had magmom=1 in the 
>> calculation that generated myfile.
>>
>> > atoms.get_magnetic_moments()
>> array([ 0.,  0.])
>> > atoms[0]
>> Atom('Cl', [6.0, 6.5, 8.007541], tag=0, magmom=0.0, index=0)
>> > atoms[1]
>> Atom('Cl', [6.0, 6.5, 5.992459], tag=0, magmom=0.0, index=1)
>>
>> The information of the initial magmoms is apparently lost. So, I am 
>> setting them again:
>>
>> > atoms.set_magnetic_moments((1,1))
>> > atoms.get_magnetic_moments()
>> array([ 0.,  0.])
>>
>> Hmmm ...? But, interestingly
>>
>> > atoms[0]
>> Atom('Cl', [6.0, 6.5, 8.007541], tag=0, magmom=1.0, index=0)
>> > atoms[1]
>> Atom('Cl', [6.0, 6.5, 5.992459], tag=0, magmom=1.0, index=1)
>>
>> What is going on? Are the magnetic moments set or not? And why are 
>> they not stored in the gpw-file (a question that should rather go to 
>> the gpaw mailing list)?
>>
>> Thanks for any help,
>> Vivien
>> _______________________________________________
>> ase-users mailing list
>> ase-users at listserv.fysik.dtu.dk
>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>

-- 
Carsten Rostgaard
Ph.D. Student, M.Sc.Eng (Applied Physics)
CAMD, Department of Physics, Technical University of Denmark
Room 221, Building 307, DTU, DK-2800 Kongens Lyngby, Denmark
E-mail: Carsten.Rostgaard at fysik.dtu.dk - Phone: +45 4525 3185




More information about the ase-users mailing list