[ase-users] set_initial_magnetic_moments not working in loop?

Punit Kumar ip.punit.2016 at gmail.com
Fri Jun 5 08:54:20 CEST 2020


Hi Christoph

On Fri, 5 Jun 2020 at 12:06, Christoph Wolf via ase-users <
ase-users at listserv.fysik.dtu.dk> wrote:

> Dear all,
>
> I have a molecule as Atoms object, I was trying to loop through all atoms
> in that molecule to set the magnetic moment on only one of the species but
> ase does not seem to allow that:
>
> molecule=ase.build.molecule('methylenecyclopropane')
>
>
> molecule.set_initial_magnetic_moments([0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0])
>
> for atom in molecule:
>     if atom.symbol == 'C':
>         print(atom.index)
>         atom.set_initial_magnetic_moments([1.0])
>

You cannot use set_initial_magnetic_moments() with in a loop. Use
atom.magmom = 1.0 instead of set_initial_magnetic_moments([1.0]). It will
fix your problem.

Regards
Punit

>
>
> Traceback (most recent call last):
>   File "test_magmom.py", line 21, in <module>
>     atom.set_initial_magnetic_moments([0.1])
> AttributeError: 'Atom' object has no attribute
> 'set_initial_magnetic_moments'
>
> Is there a way to do this?
>
> Thanks in advance and have a great weekend everyone!
>
> Chris
> --
> Postdoctoral Researcher
> Center for Quantum Nanoscience, Institute for Basic Science
> Ewha Womans University, Seoul, South Korea
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20200605/87a09f73/attachment.html>


More information about the ase-users mailing list