structopt.common.individual.Individual¶

class
structopt.common.individual.
Individual
(id=None, load_modules=True, relaxation_parameters=None, fitness_parameters=None, mutation_parameters=None, pso_moves_parameters=None, generator_parameters=None, **kwargs)¶ Bases:
ase.atoms.Atoms
An abstract base class for a structure.

adsorbate_info
¶ Return the adsorbate information set by one of the surface builder functions. This function is only supplied in order to give a warning if this attribute (atoms.adsorbate_info) is asked for. The dictionary with adsorbate information has been moved to the info dictionary, i.e. atoms.info[‘adsorbate_info’].

append
(atom)¶ Append atom to end.

calc
¶ Calculator object.

calculate_fitness
()¶ Perform the fitness calculations on an individual.
 Args:
 individual (Individual): the individual to evaluate
(@parallel) Designed to run code that runs differently on different cores. The MPI functionality should be implemented inside these functions.

cell
¶ Attribute for direct manipulation of the unit cell.

center
(vacuum=None, axis=(0, 1, 2), about=None)¶ Center atoms in unit cell.
Centers the atoms in the unit cell, so there is the same amount of vacuum on all sides.
 vacuum: float (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: int or sequence of ints
 Axis or axes to act on. Default: Act on all axes.
 about: float or array (default: None)
 If specified, center the atoms about <about>. I.e., about=(0., 0., 0.) (or just “about=0.”, interpreted identically), to center about the origin.

clear
()¶

constraints
¶ Constraints of the atoms.

copy
(include_atoms=True)¶ Return a copy.

edit
()¶ Modify atoms interactively through ASE’s GUI viewer.
Conflicts leading to undesirable behaviour might arise when matplotlib has been preimported with certain incompatible backends and while trying to use the plot feature inside the interactive GUI. To circumvent, please set matplotlib.use(‘gtk’) before calling this method.

euler_rotate
(phi=0.0, theta=0.0, psi=0.0, center=(0, 0, 0))¶ Rotate atoms via Euler angles (in degrees).
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.

extend
(other)¶ Extend atoms object by appending atoms from other.

fitness
¶ The total fitness of the individual.

fits
¶

generate
()¶ Generate an individual using generator_kwargs parameter. By defualt it extends the current atoms object

get_all_distances
(mic=False)¶ Return distances of all of the atoms with all of the atoms.
Use mic=True to use the Minimum Image Convention.

get_angle
(a1, a2=None, a3=None, mic=False)¶ Get angle formed by three atoms.
calculate angle in degrees between the vectors a2>a1 and a2>a3.
Use mic=True to use the Minimum Image Convention and calculate the angle across periodic boundaries.

get_angular_momentum
()¶ Get total angular momentum with respect to the center of mass.

get_array
(name, copy=True)¶ Get an array.
Returns a copy unless the optional argument copy is false.

get_atom_indices_within_distance_of_atom
(atom_index, distance)¶

get_atomic_numbers
()¶ Get integer array of atomic numbers.

get_calculator
()¶ Get currently attached calculator object.

get_cell
(complete=False)¶ Get the three unit cell vectors as a 3x3 ndarray.

get_cell_lengths_and_angles
()¶ Get unit cell parameters. Sequence of 6 numbers.
First three are unit cell vector lengths and second three are angles between them:
[len(a), len(b), len(c), angle(a,b), angle(a,c), angle(b,c)]
in degrees.

get_celldisp
()¶ Get the unit cell displacement vectors.

get_center_of_mass
(scaled=False)¶ Get the center of mass.
If scaled=True the center of mass in scaled coordinates is returned.

get_charges
()¶ Get calculated charges.

get_chemical_formula
(mode='hill')¶ Get the chemial formula as a string based on the chemical symbols.
Parameters:
 mode: str
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.
‘metal’: The list of checmical symbols (alphabetical metals, and alphabetical nonmetals)

get_chemical_symbols
()¶ Get list of chemical symbol strings.

get_dihedral
(a1, a2=None, a3=None, a4=None, mic=False)¶ Calculate dihedral angle.
Calculate dihedral angle (in degrees) between the vectors a1>a2 and a3>a4.
Use mic=True to use the Minimum Image Convention and calculate the angle across periodic boundaries.

get_dipole_moment
()¶ Calculate the electric dipole moment for the atoms object.
Only available for calculators which has a get_dipole_moment() method.

get_distance
(a0, a1, mic=False, vector=False)¶ Return distance between two atoms.
Use mic=True to use the Minimum Image Convention. vector=True gives the distance vector (from a0 to a1).

get_distances
(a, indices, mic=False, vector=False)¶ Return distances of atom No.i with a list of atoms.
Use mic=True to use the Minimum Image Convention. vector=True gives the distance vector (from a to self[indices]).

get_forces
(apply_constraint=True, md=False)¶ Calculate atomic forces.
Ask the attached calculator to calculate the forces and apply constraints. Use apply_constraint=False to get the raw forces.
For molecular dynamics (md=True) we don’t apply the constraint to the forces but to the momenta.

get_initial_charges
()¶ Get array of initial charges.

get_initial_magnetic_moments
()¶ Get array of initial magnetic moments.

get_kinetic_energy
()¶ Get the kinetic energy.

get_magnetic_moment
()¶ Get calculated total magnetic moment.

get_magnetic_moments
()¶ Get calculated local magnetic moments.

get_masses
()¶ Get array of masses.

get_momenta
()¶ Get array of momenta.

get_moments_of_inertia
(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_nearest_atom_indices
(atom_index, count)¶

get_number_of_atoms
()¶ Returns the global number of atoms in a distributedatoms parallel simulation.
DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING!
Equivalent to len(atoms) in the standard ASE Atoms class. You should normally use len(atoms) instead. This function’s only purpose is to make compatibility between ASE and Asap easier to maintain by having a few places in ASE use this function instead. It is typically only when counting the global number of degrees of freedom or in similar situations.

get_pbc
()¶ Get periodic boundary condition flags.

get_positions
(wrap=False)¶ Get array of positions. If wrap==True, wraps atoms back into unit cell.

get_potential_energies
()¶ Calculate the potential energies of all the atoms.
Only available with calculators supporting peratom energies (e.g. classical potentials).

get_potential_energy
(force_consistent=False, apply_constraint=True)¶ Calculate potential energy.
Ask the attached calculator to calculate the potential energy and apply constraints. Use apply_constraint=False to get the raw forces.
When supported by the calculator, either the energy extrapolated to zero Kelvin or the energy consistent with the forces (the free energy) can be returned.

get_reciprocal_cell
()¶ 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
(wrap=True)¶ Get positions relative to unit cell.
If wrap is True, 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
(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
()¶ Calculate the stresstensor of all the atoms.
Only available with calculators supporting peratom energies and stresses (e.g. classical potentials). Even for such calculators there is a certain arbitrariness in defining peratom stresses.
Get integer array of tags.

get_temperature
()¶ Get the temperature in Kelvin.

get_total_energy
()¶ Get the total energy  potential plus kinetic energy.

get_velocities
()¶ Get array of velocities.

get_volume
()¶ Get volume of unit cell.

has
(name)¶ Check for existence of array.
name must be one of: ‘tags’, ‘momenta’, ‘masses’, ‘magmoms’, ‘charges’.

load_modules
()¶ Loads the relevant modules.
(@parallel) Designed to run code that runs differently on different cores. The MPI functionality should be implemented inside these functions.

mutate
(select_new=True)¶ Mutate an individual.
 Args:
 individual (Individual): the individual to mutate
(@parallel) Designed to run code that runs differently on different cores. The MPI functionality should be implemented inside these functions.

new_array
(name, a, dtype=None, shape=None)¶ Add new array.
If shape is not None, the shape of a will be checked.

number_of_lattice_vectors
¶ Number of (nonzero) lattice vectors.

numbers
¶ Attribute for direct manipulation of the atomic numbers.

pbc
¶ Attribute for direct manipulation of the periodic boundary condition flags.

pop
(i=1)¶ Remove and return atom at index i (default last).

positions
¶

rattle
(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!

relax
()¶ Relax an individual.
 Args:
 individual (Individual): the individual to relax
(@parallel) Designed to run code that runs differently on different cores. The MPI functionality should be implemented inside these functions.

repeat
(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
(a, v=None, center=(0, 0, 0), rotate_cell=False)¶ Rotate atoms based on a vector and an angle, or two vectors.
Parameters:
 a = None:
 Angle that the atoms is rotated around the vecor ‘v’. ‘a’ can also be a vector and then ‘a’ is rotated into ‘v’.
 v:
 Vector to rotate the atoms around. Vectors can be given as strings: ‘x’, ‘x’, ‘y’, … .
 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 zaxis, so that the xaxis is rotated into the yaxis:
>>> from math import pi >>> atoms = Atoms() >>> atoms.rotate(90, 'z') >>> atoms.rotate(90, (0, 0, 1)) >>> atoms.rotate(90, 'z') >>> atoms.rotate('x', 'y')

rotate_dihedral
(a1, a2=None, a3=None, a4=None, angle=None, 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
(center=(0, 0, 0), phi=0.0, theta=0.0, psi=0.0)¶

set_angle
(a1, a2=None, a3=None, angle=None, mask=None)¶ Set angle (in degrees) formed by three atoms.
Sets the angle between vectors a2>a1 and a2>a3.
Same usage as in set_dihedral().

set_array
(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
(numbers)¶ Set atomic numbers.

set_calculator
(calc=None)¶ Attach calculator object.

set_cell
(cell, scale_atoms=False)¶ Set unit cell vectors.
Parameters:
 cell: 3x3 matrix or length 3 or 6 vector
 Unit cell. A 3x3 matrix (the three unit cell vectors) or just three numbers for an orthorhombic cell. Another option is 6 numbers, which describes unit cell with lengths of unit cell vectors and with angles between them (in degrees), in following order: [len(a), len(b), len(c), angle(b,c), angle(a,c), angle(a,b)]. First vector will lie in xdirection, second in xyplane, and the third one in zpositive subspace.
 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:
>>> atoms = Atoms('He') >>> a, b, c = 7, 7.5, 8 >>> atoms.set_cell([a, b, c]) >>> atoms.set_cell([(a, 0, 0), (0, b, 0), (0, 0, c)])
FCC unit cell:
>>> atoms.set_cell([(0, b, b), (b, 0, b), (b, b, 0)])
Hexagonal unit cell:
>>> atoms.set_cell([a, a, c, 90, 90, 120])
Rhombohedral unit cell:
>>> alpha = 77 >>> atoms.set_cell([a, a, a, alpha, alpha, alpha])

set_celldisp
(celldisp)¶ Set the unit cell displacement vectors.

set_chemical_symbols
(symbols)¶ Set chemical symbols.

set_constraint
(constraint=None)¶ Apply one or more constrains.
The constraint argument must be one constraint object or a list of constraint objects.

set_dihedral
(a1, a2=None, a3=None, a4=None, angle=None, mask=None, indices=None)¶ Set the dihedral angle (degrees) between vectors a1>a2 and a3>a4 by changing the atom indexed by a4 if mask is not None, all the atoms described in mask (read: the entire subgroup) are moved. Alternatively to the mask, the indices of the atoms to be rotated can be supplied.
example: the following defines a very crude ethanelike molecule and twists one half of it by 30 degrees.
>>> from math import pi >>> 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, 210, mask=[0, 0, 0, 1, 1, 1])

set_distance
(a0, a1, distance, fix=0.5, mic=False)¶ 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
(charges=None)¶ Set the initial charges.

set_initial_magnetic_moments
(magmoms=None)¶ Set the initial magnetic moments.
Use either one or three numbers for every atom (collinear or noncollinear spins).

set_masses
(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
(momenta, apply_constraint=True)¶ Set momenta.

set_pbc
(pbc)¶ Set periodic boundary condition flags.

set_positions
(newpositions, apply_constraint=True)¶ Set positions, honoring any constraints. To ignore constraints, use apply_constraint=False.

set_scaled_positions
(scaled)¶ Set positions relative to unit cell.
Set tags for all atoms. If only one tag is supplied, it is applied to all atoms.

set_velocities
(velocities)¶ Set the momenta by specifying the velocities.

translate
(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).

velocities
¶

wrap
(center=(0.5, 0.5, 0.5), pbc=None, eps=1e07)¶

write
(filename, format=None, **kwargs)¶ Write atoms object to a file.
see ase.io.write for formats. kwargs are passed to ase.io.write.
