ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>ASE</strong> <strong>Manual</strong>, <strong>Release</strong> 3.6.1.2828<br />
>>> OH = Atoms(’OH’)<br />
>>> OH[0].charge = -1<br />
>>> OH.get_charges()<br />
array([-1., 0.])<br />
Another example:<br />
>>> for atom in bulk:<br />
... if atom.symbol = ’Ni’:<br />
... atom.magmom = 0.7 # set initial magnetic moment<br />
The different properties of an atom can be obtained and changed via attributes (position, number, tag,<br />
momentum, mass, magmom, charge, x, y, z):<br />
>>> a1.position = [1, 0, 0]<br />
>>> a1.position<br />
array([ 1., 0., 0.])<br />
>>> a1.z = 2.5<br />
>>> a1.position<br />
array([ 1. , 0. , 2.5])<br />
>>> a2.magmom = 1.0<br />
That last line will set the initial magnetic moment that some calulators use (similar to the<br />
set_initial_magnetic_moments() method).<br />
Note: The position and momentum attributes refer to mutable objects, so in some cases, you may want to<br />
use a1.position.copy() in order to avoid changing the position of a1 by accident.<br />
7.2.1 Getting an Atom from an Atoms object<br />
Indexing an Atoms object returns an Atom object still remembering that it belongs to the collective Atoms:<br />
Modifying it will also change the atoms object:<br />
>>> atoms = ase.data.molecules.molecule(’CH4’)<br />
>>> atoms.get_positions()<br />
array([[ 0. , 0. , 0. ],<br />
[ 0.629118, 0.629118, 0.629118],<br />
[-0.629118, -0.629118, 0.629118],<br />
[ 0.629118, -0.629118, -0.629118],<br />
[-0.629118, 0.629118, -0.629118]])<br />
>>> a = atoms[2]<br />
>>> a<br />
Atom(’H’, [-0.62911799999999996, -0.62911799999999996, 0.62911799999999996], index=2)<br />
>>> a.x = 0<br />
>>> atoms.get_positions()<br />
array([[ 0. , 0. , 0. ],<br />
[ 0.629118, 0.629118, 0.629118],<br />
[ 0. , -0.629118, 0.629118],<br />
[ 0.629118, -0.629118, -0.629118],<br />
[-0.629118, 0.629118, -0.629118]])<br />
See Also:<br />
Atom: All the details!<br />
atoms: More information about how to use collections of atoms.<br />
calculators: Information about how to calculate forces and energies of atoms.<br />
66 Chapter 7. Documentation for modules in <strong>ASE</strong>