seminar:atoms_object
ase.atoms index /usr/local/lib/python2.7/dist-packages/ase/atoms.py Definition of the Atoms class. This module defines the central object in the ASE package: the Atoms object. Modules numpy ase.units warnings Classes __builtin__.object Atoms class Atoms(__builtin__.object) Atoms object. The Atoms object can represent an isolated molecule, or a periodically repeated structure. It has a unit cell and there may be periodic boundary conditions along any of the three unit cell axes. Information about the atoms (atomic numbers and position) is stored in ndarrays. Optionally, there can be information about tags, momenta, masses, magnetic moments and charges. In order to calculate energies, forces and stresses, a calculator object has to attached to the atoms object. Parameters: symbols: str (formula) or list of str Can be a string formula, a list of symbols or a list of Atom objects. Examples: 'H2O', 'COPt12', ['H', 'H', 'O'], [Atom('Ne', (x, y, z)), ...]. positions: list of xyz-positions Atomic positions. Anything that can be converted to an ndarray of shape (n, 3) will do: [(x1,y1,z1), (x2,y2,z2), ...]. scaled_positions: list of scaled-positions Like positions, but given in units of the unit cell. Can not be set at the same time as positions. numbers: list of int Atomic numbers (use only one of symbols/numbers). tags: list of int Special purpose tags. momenta: list of xyz-momenta Momenta for all atoms. masses: list of float Atomic masses in atomic units. magmoms: list of float or list of xyz-values Magnetic moments. Can be either a single value for each atom for collinear calculations or three numbers for each atom for non-collinear calculations. charges: list of float Atomic charges. cell: 3x3 matrix Unit cell vectors. Can also be given as just three numbers for orthorhombic cells. Default value: [1, 1, 1]. celldisp: Vector Unit cell displacement vector. To visualize a displaced cell around the center of mass of a Systems of atoms. Default value = (0,0,0) pbc: one or three bool Periodic boundary conditions flags. Examples: True, False, 0, 1, (1, 1, 0), (True, False, False). Default value: False. constraint: constraint object(s) Used for applying one or more constraints during structure optimization. calculator: calculator object Used to attach a calculator for calculating energies and atomic forces. info: dict of key-value pairs Dictionary of key-value pairs with additional information about the system. The following keys may be used by ase: - spacegroup: Spacegroup instance - unit_cell: 'conventional' | 'primitive' | int | 3 ints - adsorbate_info: Items in the info attribute survives copy and slicing and can be store to and retrieved from trajectory files given that the key is a string, the value is picklable and, if the value is a user-defined object, its base class is importable. One should not make any assumptions about the existence of keys. Examples: These three are equivalent: >>> d = 1.104 # N2 bondlength >>> a = Atoms('N2', [(0, 0, 0), (0, 0, d)]) >>> a = Atoms(numbers=[7, 7], positions=[(0, 0, 0), (0, 0, d)]) >>> a = Atoms([Atom('N', (0, 0, 0)), Atom('N', (0, 0, d)]) FCC gold: >>> a = 4.05 # Gold lattice constant >>> b = a / 2 >>> fcc = Atoms('Au', ... cell=[(0, b, b), (b, 0, b), (b, b, 0)], ... pbc=True) Hydrogen wire: >>> d = 0.9 # H-H distance >>> L = 7.0 >>> h = Atoms('H', positions=[(0, L / 2, L / 2)], ... cell=(d, L, L), ... pbc=(1, 0, 0)) Methods defined here: __add__(self, other) __delitem__(self, i) __eq__(self, other) Check for identity of two atoms objects. Identity means: same positions, atomic numbers, unit cell and periodic boundary conditions. __getitem__(self, i) Return a subset of the atoms. i -- scalar integer, list of integers, or slice object describing which atoms to return. If i is a scalar, return an Atom object. If i is a list or a slice, return an Atoms object with the same cell, pbc, and other associated info as the original Atoms object. The indices of the constraints will be shuffled so that they match the indexing in the subset returned. __iadd__ = extend(self, other) __imul__(self, m) In-place repeat of atoms. __init__(self, symbols=None, positions=None, numbers=None, tags=None, momenta=None, masses=None, magmoms=None, charges=None, scaled_positions=None, cell=None, pbc=None, celldisp=None, constraint=None, calculator=None, info=None) __len__(self) __mul__ = repeat(self, rep) __ne__(self, other) __repr__(self) append(self, atom) Append atom to end. center(self, vacuum=None, axis=None) Center atoms in unit cell. Centers the atoms in the unit cell, so there is the same amount of vacuum on all sides. Parameters: vacuum (default: None): If specified adjust the amount of vacuum when centering. If vacuum=10.0 there will thus be 10 Angstrom of vacuum on each side. axis (default: None): If specified, only act on the specified axis. Default: Act on all axes. copy(self) Return a copy. edit(self) Modify atoms interactively through ag viewer. Conflicts leading to undesirable behaviour might arise when matplotlib has been pre-imported with certain incompatible backends and while trying to use the plot feature inside the interactive ag. To circumvent, please set matplotlib.use('gtk') before calling this method. extend(self, other) Extend atoms object by appending atoms from *other*. get_angle(self, list) Get angle formed by three atoms. calculate angle between the vectors list[1]->list[0] and list[1]->list[2], where list contains the atomic indexes in question. get_angular_momentum(self) Get total angular momentum with respect to the center of mass. get_array(self, name, copy=True) Get an array. Returns a copy unless the optional argument copy is false. get_atomic_numbers(self) Get integer array of atomic numbers. get_calculation_done(self) Let the calculator calculate its thing, using the current input. get_calculator(self) Get currently attached calculator object. get_cell(self) Get the three unit cell vectors as a 3x3 ndarray. get_celldisp(self) Get the unit cell displacement vectors . get_center_of_mass(self, scaled=False) Get the center of mass. If scaled=True the center of mass in scaled coordinates is returned. get_charges(self) Get calculated charges. get_chemical_formula(self, mode='hill') Get the chemial formula as a string based on the chemical symbols. Parameters: mode: There are three different modes available: 'all': The list of chemical symbols are contracted to at string, e.g. ['C', 'H', 'H', 'H', 'O', 'H'] becomes 'CHHHOH'. 'reduce': The same as 'all' where repeated elements are contracted to a single symbol and a number, e.g. 'CHHHOCHHH' is reduced to 'CH3OCH3'. 'hill': The list of chemical symbols are contracted to a string following the Hill notation (alphabetical order with C and H first), e.g. 'CHHHOCHHH' is reduced to 'C2H6O' and 'SOOHOHO' to 'H2O4S'. This is default. get_chemical_symbols(self, reduce=False) Get list of chemical symbol strings. get_dihedral(self, list) Calculate dihedral angle. Calculate dihedral angle between the vectors list[0]->list[1] and list[2]->list[3], where list contains the atomic indexes in question. get_dipole_moment(self) Calculate the electric dipole moment for the atoms object. Only available for calculators which has a get_dipole_moment() method. get_distance(self, a0, a1, mic=False) Return distance between two atoms. Use mic=True to use the Minimum Image Convention. get_forces(self, apply_constraint=True) Calculate atomic forces. Ask the attached calculator to calculate the forces and apply constraints. Use *apply_constraint=False* to get the raw forces. get_initial_charges(self) Get array of initial charges. get_initial_magnetic_moments(self) Get array of initial magnetic moments. get_isotropic_pressure(self, stress) Get the current calculated pressure, assume isotropic medium. in Bar get_kinetic_energy(self) Get the kinetic energy. get_magnetic_moment(self) Get calculated total magnetic moment. get_magnetic_moments(self) Get calculated local magnetic moments. get_masses(self) Get array of masses. get_momenta(self) Get array of momenta. get_moments_of_inertia(self, vectors=False) Get the moments of inertia along the principal axes. The three principal moments of inertia are computed from the eigenvalues of the symmetric inertial tensor. Periodic boundary conditions are ignored. Units of the moments of inertia are amu*angstrom**2. get_name(self) get_number_of_atoms(self) Returns the number of atoms. Equivalent to len(atoms) in the standard ASE Atoms class. get_pbc(self) Get periodic boundary condition flags. get_positions(self, wrap=False) Get array of positions. If wrap==True, wraps atoms back into unit cell. get_potential_energies(self) Calculate the potential energies of all the atoms. Only available with calculators supporting per-atom energies (e.g. classical potentials). get_potential_energy(self) Calculate potential energy. get_reciprocal_cell(self) Get the three reciprocal lattice vectors as a 3x3 ndarray. Note that the commonly used factor of 2 pi for Fourier transforms is not included here. get_scaled_positions(self) Get positions relative to unit cell. Atoms outside the unit cell will be wrapped into the cell in those directions with periodic boundary conditions so that the scaled coordinates are between zero and one. get_stress(self, voigt=True) Calculate stress tensor. Returns an array of the six independent components of the symmetric stress tensor, in the traditional Voigt order (xx, yy, zz, yz, xz, xy) or as a 3x3 matrix. Default is Voigt order. get_stresses(self) Calculate the stress-tensor of all the atoms. Only available with calculators supporting per-atom energies and stresses (e.g. classical potentials). Even for such calculators there is a certain arbitrariness in defining per-atom stresses. get_tags(self) Get integer array of tags. get_temperature(self) Get the temperature. in Kelvin get_total_energy(self) Get the total energy - potential plus kinetic energy. get_velocities(self) Get array of velocities. get_volume(self) Get volume of unit cell. has(self, name) Check for existence of array. name must be one of: 'tags', 'momenta', 'masses', 'magmoms', 'charges'. new_array(self, name, a, dtype=None, shape=None) Add new array. If *shape* is not *None*, the shape of *a* will be checked. pop(self, i=-1) Remove and return atom at index *i* (default last). rattle(self, stdev=0.001, seed=42) Randomly displace atoms. This method adds random displacements to the atomic positions, taking a possible constraint into account. The random numbers are drawn from a normal distribution of standard deviation stdev. For a parallel calculation, it is important to use the same seed on all processors! repeat(self, rep) Create new repeated atoms object. The *rep* argument should be a sequence of three positive integers like *(2,3,1)* or a single integer (*r*) equivalent to *(r,r,r)*. rotate(self, v, a=None, center=(0, 0, 0), rotate_cell=False) Rotate atoms based on a vector and an angle, or two vectors. Parameters: v: Vector to rotate the atoms around. Vectors can be given as strings: 'x', '-x', 'y', ... . a = None: Angle that the atoms is rotated around the vecor 'v'. If an angle is not specified, the length of 'v' is used as the angle (default). The angle can also be a vector and then 'v' is rotated into 'a'. center = (0, 0, 0): The center is kept fixed under the rotation. Use 'COM' to fix the center of mass, 'COP' to fix the center of positions or 'COU' to fix the center of cell. rotate_cell = False: If true the cell is also rotated. Examples: Rotate 90 degrees around the z-axis, so that the x-axis is rotated into the y-axis: >>> a = pi / 2 >>> atoms.rotate('z', a) >>> atoms.rotate((0, 0, 1), a) >>> atoms.rotate('-z', -a) >>> atoms.rotate((0, 0, a)) >>> atoms.rotate('x', 'y') rotate_dihedral(self, list, angle, mask=None) Rotate dihedral angle. Complementing the two routines above: rotate a group by a predefined dihedral angle, starting from its current configuration rotate_euler(self, center=(0, 0, 0), phi=0.0, theta=0.0, psi=0.0) Rotate atoms via Euler angles. See e.g http://mathworld.wolfram.com/EulerAngles.html for explanation. Parameters: center : The point to rotate about. A sequence of length 3 with the coordinates, or 'COM' to select the center of mass, 'COP' to select center of positions or 'COU' to select center of cell. phi : The 1st rotation angle around the z axis. theta : Rotation around the x axis. psi : 2nd rotation around the z axis. set_angle(self, list, angle, mask=None) Set angle formed by three atoms. Sets the angle between vectors list[1]->list[0] and list[1]->list[2]. Same usage as in set_dihedral. set_array(self, name, a, dtype=None, shape=None) Update array. If *shape* is not *None*, the shape of *a* will be checked. If *a* is *None*, then the array is deleted. set_atomic_numbers(self, numbers) Set atomic numbers. set_calculator(self, calc=None) Attach calculator object. set_cell(self, cell, scale_atoms=False, fix=None) Set unit cell vectors. Parameters: cell : Unit cell. A 3x3 matrix (the three unit cell vectors) or just three numbers for an orthorhombic cell. scale_atoms : bool Fix atomic positions or move atoms with the unit cell? Default behavior is to *not* move the atoms (scale_atoms=False). Examples: Two equivalent ways to define an orthorhombic cell: >>> a.set_cell([a, b, c]) >>> a.set_cell([(a, 0, 0), (0, b, 0), (0, 0, c)]) FCC unit cell: >>> a.set_cell([(0, b, b), (b, 0, b), (b, b, 0)]) set_celldisp(self, celldisp) set_charges(self, charges=None) Deprecated method. Use set_initial_charges. set_chemical_symbols(self, symbols) Set chemical symbols. set_constraint(self, constraint=None) Apply one or more constrains. The *constraint* argument must be one constraint object or a list of constraint objects. set_dihedral(self, list, angle, mask=None) set the dihedral angle between vectors list[0]->list[1] and list[2]->list[3] by changing the atom indexed by list[3] if mask is not None, all the atoms described in mask (read: the entire subgroup) are moved example: the following defines a very crude ethane-like molecule and twists one half of it by 30 degrees. >>> atoms = Atoms('HHCCHH', [[-1, 1, 0], [-1, -1, 0], [0, 0, 0], [1, 0, 0], [2, 1, 0], [2, -1, 0]]) >>> atoms.set_dihedral([1,2,3,4],7*pi/6,mask=[0,0,0,1,1,1]) set_distance(self, a0, a1, distance, fix=0.5) Set the distance between two atoms. Set the distance between atoms *a0* and *a1* to *distance*. By default, the center of the two atoms will be fixed. Use *fix=0* to fix the first atom, *fix=1* to fix the second atom and *fix=0.5* (default) to fix the center of the bond. set_initial_charges(self, charges=None) Set the initial charges. set_initial_magnetic_moments(self, magmoms=None) Set the initial magnetic moments. Use either one or three numbers for every atom (collinear or non-collinear spins). set_masses(self, masses='defaults') Set atomic masses. The array masses should contain a list of masses. In case the masses argument is not given or for those elements of the masses list that are None, standard values are set. set_momenta(self, momenta) Set momenta. set_pbc(self, pbc) Set periodic boundary condition flags. set_positions(self, newpositions) Set positions, honoring any constraints. set_scaled_positions(self, scaled) Set positions relative to unit cell. set_tags(self, tags) Set tags for all atoms. If only one tag is supplied, it is applied to all atoms. set_velocities(self, velocities) Set the momenta by specifying the velocities. translate(self, displacement) Translate atomic positions. The displacement argument can be a float an xyz vector or an nx3 array (where n is the number of atoms). write(self, filename, format=None, **kwargs) Write yourself to a file. Data descriptors defined here: __dict__ dictionary for instance variables (if defined) __weakref__ list of weak references to the object (if defined) calc Calculator object. cell Attribute for direct manipulation of the unit cell. constraints Constraints of the atoms. numbers Attribute for direct manipulation of the atomic numbers. pbc Attribute for direct manipulation of the periodic boundary condition flags. positions Attribute for direct manipulation of the positions. Data and other attributes defined here: __hash__ = None Functions cos(...) cos(x) Return the cosine of x (measured in radians). default(data, dflt) Helper function for setting default values. sin(...) sin(x) Return the sine of x (measured in radians). string2symbols(s) Convert string to list of chemical symbols. string2vector(v) symbols2numbers(symbols) Data atomic_masses = array([ 0. , 1.00794, 4.0026 , 6.... nan, nan, nan, nan]) atomic_numbers = {'Ac': 89, 'Ag': 47, 'Al': 13, 'Am': 95, 'Ar': 18, 'As': 33, 'At': 85, 'Au': 79, 'B': 5, 'Ba': 56, ...} chemical_symbols = ['X', 'H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', ...]
seminar/atoms_object.txt · 最終更新: 2022/08/23 13:34 by 127.0.0.1