gensec package¶
Submodules¶
gensec.alphas module¶
-
gensec.alphas.
find_alpha
(A, B, Cutoff, threshold)¶
-
gensec.alphas.
func
(alpha, R0, R)¶
-
gensec.alphas.
get_R0AB
(A, B)¶
-
gensec.alphas.
save_obj
(obj, name)¶
gensec.coefficients module¶
gensec.defaults module¶
Default parameters for optimizer class - currently just sets max step size
gensec.known module¶
Summary
-
class
gensec.known.
Known
(structure, parameters)¶ Bases:
object
Handling of the known structures
Class for keeping of already known structures in order to avoid repetative calculations and generate unique structures.
- Attributes:
- coms (TYPE): Description criteria (str): Description orientations (TYPE): Description torsional_diff_degree (int): Description torsions (TYPE): Description
-
add_to_known
(t, o, c)¶ Summary
- Args:
- t (TYPE): Description o (TYPE): Description c (TYPE): Description
-
add_to_known_coms
(c)¶ Summary
- Args:
- c (TYPE): Description
-
add_to_known_orientations
(o)¶ Summary
- Args:
- o (TYPE): Description
-
add_to_known_torsions
(t)¶ Summary
- Args:
- t (TYPE): Description
-
angle_between
(vec2)¶ Summary
- Args:
- vec1 (TYPE): Description vec2 (TYPE): Description
- Returns:
- TYPE: Description
-
coms_diff
(point, vector)¶ Summary
- Args:
- point (TYPE): Description vector (TYPE): Description
- Returns:
- TYPE: Description
-
find_in_known
(coords, parameters, structure, fixed_frame, criteria, t)¶ Summary
- Args:
- coords (TYPE): Description parameters (TYPE): Description structure (TYPE): Description fixed_frame (TYPE): Description criteria (TYPE): Description t (TYPE): Description
-
find_traj
(directory)¶ Summary
- Args:
- directory (TYPE): Description
- Returns:
- TYPE: Description
-
get_internal_vector
(configuration, structure, fixed_frame, parameters)¶ Summary
- Args:
- configuration (TYPE): Description structure (TYPE): Description fixed_frame (TYPE): Description parameters (TYPE): Description
-
get_known
()¶ Summary
-
get_len
()¶ Summary
- Returns:
- TYPE: Description
-
static
minimal_angle
(x, y)¶ Summary
- Args:
- x (TYPE): Description y (TYPE): Description
- Returns:
- TYPE: Description
-
orientational_diff
(point, vector)¶ Summary
- Args:
- point (TYPE): Description vector (TYPE): Description
- Returns:
- TYPE: Description
-
torsional_diff
(point, vector, criteria, t)¶ Summary
- Args:
- point (TYPE): Description vector (TYPE): Description criteria (TYPE): Description t (TYPE): Description
- Returns:
- TYPE: Description
gensec.modules module¶
Summary
-
gensec.modules.
Rotation
(coord, point, quaternion)¶ Summary
- Args:
- coord (TYPE): Description point (TYPE): Description quaternion (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
align_to_axes
(atoms, atom_1_indx, atom_2_indx)¶ Summary
- Args:
- atoms (TYPE): Description atom_1_indx (TYPE): Description atom_2_indx (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
all_right
(structure, fixed_frame)¶ Summary
- Args:
- structure (TYPE): Description fixed_frame (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
angle_between
(v1, v2)¶ Returns angle between two vectors
- Args:
- v1 (TYPE): Description v2 (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
carried_atoms
(connectivity_matrix_isolated, positions)¶ Returns list of carried atoms
- Args:
- connectivity_matrix_isolated (TYPE): Description positions (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
clashes_with_fixed_frame
(structure, fixed_frame)¶ Checks for clashes between molecules and fixed frame
Claculates distances between all atoms in all molecules with all atoms in the fixed frame. Passed if all the distances are greater than 2.0 A. Periodic boundary conditions are taken into account with use of the mic=fixed_frame.mic
- Arguments:
- structure (TYPE): Description fixed_frame (TYPE): Description structure {list} – list of the molecules fixed_frame {Atoms object} – atoms in fixed frame
- Returns:
- boolean – False if all the distances are greater than 2.0 A
-
gensec.modules.
construct_graph
(connectivity_matrix)¶ Construct the graph from connectivity matrix
- Args:
- connectivity_matrix {matrix}: ASE connectivity matrix
- Returns:
- Dictionary: graph of connected atoms
-
gensec.modules.
create_connectivity_matrix
(atoms, bothways)¶ Summary
- Args:
- atoms (TYPE): Description bothways (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
create_torsion_list
(bond, graph, atoms)¶ Summary
- Args:
- bond (TYPE): Description graph (TYPE): Description atoms (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
detect_cycles
(connectivity_matrix)¶ Summary
- Args:
- connectivity_matrix (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
detect_rotatble
(connectivity_matrix, atoms)¶ Detection of all rotatable bonds 2. The bonds does not contain terminate atoms 2. 3.
- Args:
- connectivity_matrix (TYPE): Description atoms (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
exclude_rotatable_from_cycles
(list_of_torsions, cycles)¶ Summary
- Args:
- list_of_torsions (TYPE): Description cycles (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
getroots
(aNeigh)¶ Summary
- Args:
- aNeigh (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
insertbreak
(graph, atom1, atom2)¶ Insert the break in the graph
Creates two disconnected graphs from one connected graph
- Arguments:
- graph (TYPE): Description atom1 (TYPE): Description atom2 (TYPE): Description graph {graph} – Graph representation of the system atom1 {atom number} – Terminate atom fro the first graph atom2 {atom number} – Terminate atom for the second graph
- Returns:
- Graph – Now the graph will not have connection between atom1 and atom2
-
gensec.modules.
internal_clashes
(structure)¶ Check for internal clashes within molecule
Iterates over the molecules and compare their connectivity matrices with template’s one. Periodic boundary conditions are taken into account with use of the flag “bothways = True”.
- Arguments:
- structure {list} – list of the molecules
- Returns:
- bollean – False if no clashes found
-
gensec.modules.
intramolecular_clashes
(structure)¶ Checks for intermolecular clashes
Claculates distances between all atoms that belong to the different molecules. Passed if all the distances are greater than 1.4 A. Periodic boundary conditions are taken into account with use of the mic=structure.mic
- Arguments:
- structure (TYPE): Description structure {list} – list of the molecules
- Returns:
- boolean – False if no cllashes found
-
gensec.modules.
make_canonical_pyranosering
(atoms, cycle)¶ Summary
- Args:
- atoms (TYPE): Description cycle (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
measure_quaternion
(atoms, atom_1_indx, atom_2_indx)¶ Summary
- Args:
- atoms (TYPE): Description atom_1_indx (TYPE): Description atom_2_indx (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
measure_torsion_of_last
(atoms, list_of_torsions)¶ Summary
- Args:
- atoms (TYPE): Description list_of_torsions (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
merge_together
(structure, fixed_frame)¶ Merging together structure and fixed frame
Used for convenient way for output of resulting structure.
- Args:
- structure (GenSec structure): Structure object fixed_frame (GenSec fixed frame): Fixed Frame object
- Returns:
- ASE Atoms: All atoms together
-
gensec.modules.
mult_quats
(q_1, q_2)¶ Summary
- Args:
- q_1 (TYPE): Description q_2 (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
produce_quaternion
(angle, vector)¶ Summary
- Args:
- angle (TYPE): Description vector (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
quaternion_set
(atoms, quaternion, atom_1_indx, atom_2_indx)¶ Summary
- Args:
- atoms (TYPE): Description quaternion (TYPE): Description atom_1_indx (TYPE): Description atom_2_indx (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
rotation_quat
(coord, q)¶ Summary
- Args:
- coord (TYPE): Description q (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
set_centre_of_mass
(atoms, new_com)¶ Summary
- Args:
- atoms (TYPE): Description new_com (TYPE): Description
-
gensec.modules.
translate
(point, coord)¶ Summary
- Args:
- point (TYPE): Description coord (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
translate_back
(point, coord)¶ Summary
- Args:
- point (TYPE): Description coord (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
unit_quaternion
(q)¶ Summary
- Args:
- q (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.modules.
unit_vector
(vector)¶ Returns the unit vector of the vector.
- Args:
- vector (TYPE): Description
- Returns:
- TYPE: Description
gensec.optimize module¶
Structure optimization.
-
class
gensec.optimize.
BFGSLineSearch_mod
(atoms, restart=None, logfile='-', trajectory=None, maxstep=None, master=None, initial=None, rmsd_dev=1000.0, molindixes=None, structure=None, H0=None, fixed_frame=None, parameters=None, mu=None, A=None, known=None, c1=0.23, c2=0.46, alpha=10.0, stpmax=50.0, force_consistent=True)¶ Bases:
ase.optimize.bfgslinesearch.BFGSLineSearch
Summary
- Attributes:
- fixed_frame (TYPE): Description fmax_last (TYPE): Description H (TYPE): Description H0 (TYPE): Description I (TYPE): Description initial (TYPE): Description molindixes (TYPE): Description parameters (TYPE): Description rmsd_dev (TYPE): Description steps_in_row (int): Description structure (TYPE): Description
-
update
(r, g, r0, g0, p0)¶ Summary
- Args:
- r (TYPE): Description g (TYPE): Description r0 (TYPE): Description g0 (TYPE): Description p0 (TYPE): Description
- Returns:
- TYPE: Description
-
class
gensec.optimize.
BFGS_mod
(atoms, restart=None, logfile='-', trajectory=None, maxstep=0.04, master=None, initial=None, rmsd_dev=1000.0, molindixes=None, structure=None, H0=None, fixed_frame=None, parameters=None, mu=None, A=None, known=None)¶ Bases:
ase.optimize.bfgs.BFGS
Summary
- Attributes:
- fixed_frame (TYPE): Description H (TYPE): Description H0 (TYPE): Description initial (TYPE): Description molindixes (TYPE): Description parameters (TYPE): Description rmsd_dev (TYPE): Description structure (TYPE): Description
-
update
(r, f, r0, f0)¶ Summary
- Args:
- r (TYPE): Description f (TYPE): Description r0 (TYPE): Description f0 (TYPE): Description
- Returns:
- TYPE: Description
-
class
gensec.optimize.
LBFGS_Linesearch_mod
(atoms, restart=None, logfile='-', trajectory=None, maxstep=None, master=None, initial=None, rmsd_dev=1000.0, molindixes=None, structure=None, H0_init=None, fixed_frame=None, parameters=None, mu=None, A=None, known=None, alpha=70.0, damping=1.0, memory=100, force_consistent=True, use_line_search=True)¶ Bases:
ase.optimize.lbfgs.LBFGS
Summary
- Attributes:
- f0 (TYPE): Description fixed_frame (TYPE): Description fmax_last (TYPE): Description Hinv (TYPE): Description initial (TYPE): Description iteration (int): Description molindixes (TYPE): Description p (TYPE): Description parameters (TYPE): Description r0 (TYPE): Description rho (list): Description rmsd_dev (TYPE): Description s (list): Description steps_in_row (int): Description structure (TYPE): Description y (list): Description
-
log
(forces=None)¶ Summary
- Args:
- forces (None, optional): Description
- Returns:
- TYPE: Description
-
reset_hessian
()¶ Delete the history of the Hessian
-
step
(f=None)¶ Take a single step
Use the given forces, update the history and calculate the next step – then take it
- Args:
- f (None, optional): Description
-
class
gensec.optimize.
PreconLBFGS_mod
(atoms, restart=None, logfile='-', trajectory=None, maxstep=None, memory=100, damping=1.0, alpha=70.0, master=None, precon='ID', variable_cell=False, use_armijo=False, c1=0.23, c2=0.46, a_min=None, rigid_units=None, rotation_factors=None, Hinv=None, structure=None, H0=None, fixed_frame=None, parameters=None, initial=None, rmsd_dev=1000.0, molindixes=None)¶ Bases:
ase.optimize.precon.lbfgs.PreconLBFGS
Summary
- Attributes:
- f0 (TYPE): Description fixed_frame (TYPE): Description Hinv (TYPE): Description initial (TYPE): Description molindixes (TYPE): Description p (TYPE): Description parameters (TYPE): Description r0 (TYPE): Description rmsd_dev (TYPE): Description structure (TYPE): Description
-
step
(f=None)¶ Take a single step
Use the given forces, update the history and calculate the next step – then take it
- Args:
- f (None, optional): Description
-
class
gensec.optimize.
TRM_BFGS
(atoms, restart=None, logfile='-', trajectory=None, maxstep=1.0, master=None, initial=None, rmsd_dev=1000.0, molindixes=None, structure=None, H0=None, fixed_frame=None, parameters=None, mu=None, A=None, known=None, tr=1.0, eta=0.001, r=0.5)¶ Bases:
ase.optimize.bfgs.BFGS
Summary
- Attributes:
- f0 (TYPE): Description fixed_frame (TYPE): Description H (TYPE): Description H0 (TYPE): Description initial (TYPE): Description log_accept (bool): Description maxstep (TYPE): Description molindixes (TYPE): Description parameters (TYPE): Description r0 (TYPE): Description rmsd_dev (TYPE): Description structure (TYPE): Description tr (TYPE): Description
-
log
(forces=None)¶ Summary
- Args:
- forces (None, optional): Description
-
log_rejected
(forces=None)¶ Summary
- Args:
- forces (None, optional): Description
-
min_trm
(f, H, tr)¶ Return the minimum of E(dx) = -(F * dx + 0.5 * ( dx * H * dx ), whithin dx**2 <tr IN f = forces (n,) h = hessian (nxn) tr = trust-radius OUT DX = displacement in cartesian basis INTERNAL ndim = dimension d = hessian eigenvalues w = hessian eigenvector (in columns) g = gradient in cartesian basis gE = gradient in eigenvector basis DX = displacement in cartesian basis DXE = displacement in eigenvector basis
- Args:
- f (TYPE): Description H (TYPE): Description tr (TYPE): Description
- Returns:
- TYPE: Description
-
step
(f=None)¶ Summary
- Args:
- f (None, optional): Description
-
update_BFGS
(r, f, r0, f0)¶ Summary
- Args:
- r (TYPE): Description f (TYPE): Description r0 (TYPE): Description f0 (TYPE): Description
- Returns:
- TYPE: Description
-
update_H
(dx, df)¶ Input: DX = X -X_old
DF = F -F_old DG = -DF H = hessian Task: updated hessian
- Args:
- dx (TYPE): Description df (TYPE): Description
-
class
gensec.optimize.
TRM_BFGS_IPI
(atoms, restart=None, logfile='-', trajectory=None, maxstep=0.15, master=None, initial=None, rmsd_dev=1000.0, molindixes=None, structure=None, H0=None, fixed_frame=None, parameters=None, mu=None, A=None, known=None, tr=0.04, eta=0.001, r=0.5)¶ Bases:
ase.optimize.bfgs.BFGS
Summary
- Attributes:
- f0 (TYPE): Description fixed_frame (TYPE): Description H (TYPE): Description H0 (TYPE): Description initial (TYPE): Description lastforce (TYPE): Description log_accept (bool): Description maxstep (TYPE): Description molindixes (TYPE): Description parameters (TYPE): Description r0 (TYPE): Description restart (TYPE): Description rmsd_dev (TYPE): Description steps (int): Description structure (TYPE): Description tr (TYPE): Description tr_init (TYPE): Description
-
log
(forces=None)¶ Summary
- Args:
- forces (None, optional): Description
-
log_rejected
(forces=None)¶ Summary
- Args:
- forces (None, optional): Description
-
min_trm
(f, h, tr)¶ Return the minimum of E(dx) = -(F * dx + 0.5 * ( dx * H * dx ), whithin dx**2 <tr
- INTERNAL
- ndim = dimension d = hessian eigenvalues w = hessian eigenvector (in columns) g = gradient in cartesian basis gE = gradient in eigenvector basis DX = displacement in cartesian basis DXE = displacement in eigenvector basis
- Args:
- f (array): forces h (matrix): Hessian tr (float): trust-radius
- Returns:
- DX: displacement in cartesian basis
-
step
(f=None)¶ Summary
- Args:
- f (None, optional): Description
-
update_H
(dx, df)¶ Update the Hessian matrix
- Args:
- dx {array}: displacements x -x_old df {array}: force gradient f -f_old
gensec.outputs module¶
-
class
gensec.outputs.
Directories
(parameters)¶ Bases:
object
-
create_directory
(parameters)¶
-
current_dir
(parameters)¶
-
find_last_dir
(parameters)¶
-
finished
(parameters)¶
-
known
(parameters)¶
-
remove_last_directory
(parameters)¶
-
save_to_directory
(ensemble, parameters)¶
-
-
class
gensec.outputs.
Output
(report_file)¶ Bases:
object
-
write_configuration
(configuration)¶
-
write_parameters
(parameters, structure, known, dirs)¶
-
write_successfull_generate
(parameters, configuration, dirs)¶
-
write_successfull_relax
(parameters, structure, known, dirs)¶
-
write_to_report
(text)¶
-
-
class
gensec.outputs.
Workflow
¶ Bases:
object
-
gensec.outputs.
load_parameters
(parameters_file)¶
gensec.precon module¶
Create the preconditioner based on the geometry.
- Attributes:
- abohr (float): convert Bohr to Angstrom hartree (float): convert Hartree to eV k_bending (TYPE): Description k_bond (TYPE): Description k_torsion (TYPE): Description ref_ds (TYPE): Description
-
gensec.precon.
ASR
(hessian)¶ Acoustic sum rule (ASR)
ASR comes from the continous translational invariance of the periodic system. With translation of the whole system by a uniform displacement, there should be no forces acting on the atoms. This function restores the ASR for the given Hessian matrix. Calculates the block-diagonal elements as sum of the corresponding x y or z elements of the other elements in the row.
- Arguments:
- hessian (matrix): 3Nx3N where N is lenght of atoms
- Returns:
- matrix: Hessian matrix with correct ASR
-
class
gensec.precon.
Bravais
(lattice_vectors)¶ Bases:
object
Provide tools related to some given Bravais lattice.
May be initialized by a list of one, two, or three Bravais vectors. Provides tools to fold a vector or several vectors into the central parallel epipede (into_pe) and to retrieve a list of lattice vectors within a given radius (all_within).
- Attributes:
- bra (TYPE): Description ibra (TYPE): Description n (TYPE): Description rec (TYPE): Description
-
all_within
(Rcut, add_base_PE=False)¶ Return a list of all lattice vector indices shorter than Rcut.
- Examples:
>>> cos60, sin60 = np.cos(np.pi/3), np.sin(np.pi/3) >>> lat = Bravais([[1,0,0], [cos60, sin60, 0], [0,0,1.5]]) >>> lat.all_within(0.5) == [(0, 0, 0)] True >>> (1, 0, 0) in lat.all_within(1.1) True >>> set1 = lat.all_within(1.2) >>> len(set1) 7 >>> len(lat.all_within(0.2, add_base_PE=True)) 27
- The resulting vectors are sorted:
>>> lat.all_within(2.2)[0] == (0, 0, 0) True
- Args:
- Rcut (float): Cutoff distance for the exponent add_base_PE (bool, optional): if True, add one parallel epipede (PE) to the region.
- Returns:
- list: all lattice vector indices shorter than Rcut
-
latvec
(abc)¶ Return a lattice vector from integer Bravais indices.
- Args:
- abc (tuple): three Bravais indices
- Returns:
- list: lattice vector
-
gensec.precon.
C12AB
(A, B, C6)¶ C12 coefficients between A and B
Based on the C6 coefficients calculate the C12 C12 coefficients are in eV*Angstr^6. Args:
A (str): chemical symbol of A B (str): chemical symbol of B C6 (float): C6 coefficients between A and B- Returns:
- float: C12 coefficient between A and B
-
gensec.precon.
C6AB
(A, B)¶ Calculates C6 coefficients
C6 coefficients calculated based on the static dipole polarizabilites. Tkatchenko-Scheffler scheme. The units are converted to eV*Angstr^6.
- Args:
- A (atom type): Chemical symbol of the atom A B (atom type): type): Chemical symbol of the atom B
- Returns:
- float: C6 coefficient
-
gensec.precon.
ExpHessian
(atoms, mu=1, A=3.0, recalc_mu=False)¶ Callls Exp Hessian implemented in ASE
- Args:
- atoms (ASE atoms object): atoms mu (int, optional): scaling coefficient mu A (float, optional): user specific value recalc_mu (bool, optional): recalculates mu if True
- Returns:
- TYPE: Description
-
class
gensec.precon.
HessianBuilder
(n_atom, n_dyn_periodic)¶ Bases:
object
Builder object for Hessians by rank-one additions.
For a Hessian which is built successively as a sum of rank-one updates: H_{nu i, mu j} = sum_k fac v_{nu i} v_{mu j} where each update vector is assumed to be sparse wrt the number of associated atoms. The rank-one update is done by: HB.add_rank1(fac, vec) where vec == {nu: [x,y,z], …}
>>> HB = HessianBuilder(2, 0) >>> HB.add_rank1(1.0, {0: [1., 0., 0.]}) >>> HB.add_rank1(0.5, {1: [0., 0., 1.]}) >>> HD = np.zeros((2, 3, 2, 3)) >>> HD[0,0,0,0] = 1.0 >>> HD[1,2,1,2] = 0.5 >>> np.allclose(HB.to_array(), HD) True
- Attributes:
- Hdict (dict): Hessian matrix in dictionary representation. n_atom (int): Number of atoms n_dyn_periodic (int): number of periodic cells n_vec (int): number of atoms with periodic Bravais lattice
-
add_rank1
(fac, vec)¶ Add rank-one term vec * vec * vec^T.
- Args:
- fac (float): prefactor calculated from dumping object that enters in the formula like fac * k_bond vec (dict): {i_atom: np.array([xi, yi, zi]), …}
-
add_rank1_from_atlist
(fac, dq_datom, atlist)¶ Add rank-one term vec * vec * vec^T.
- Args:
- fac (float): prefactor calculated from dumping object that enters in the formula like fac * k_bond dq_datom (list): [np.array([xi, yi, zi]), …] atlist (list): [(i_tau, (a, b, c)), …]
-
add_unity
(fac)¶ Add multiple of unity.
- Args:
- fac (float): prefactor calculated from dumping object that enters in the formula like fac * k_bond
-
to_array
()¶ Construct full np.ndarray (only atomic coordinates, no stress).
- Returns:
- matrix: Hessian matrix
-
gensec.precon.
Kabsh_rmsd
(atoms, initial, molindixes, removeHs=False)¶ Root-mean-square deviation (RMSD) between tructures
Finds the optimal rotation for alignment of two structures with use of Kabsh algorithm and then calculates RMSD between all the corresponding atoms. Takes the atoms of structure and the reference structure by selecting all the atoms from inixes stored in molindixes. If necessary removes all the Hydrogen atoms from structure. Aligns centers of masses of the structures. Calculates the optimal rotation for aligning. Aligns structures and calculates deviation between positions of the corresponding atoms in both structures. Takes the square root of the sum square of those deviations.
- Args:
- atoms (ASE Atoms object): The structure to calculate RMSD with the reference geometry. initial (ASE Atoms object): The reference geometry molindixes (list): list of indexes of the atoms object that should be taken into consideration while calculation of RMSD value removeHs (bool, optional): True if Hydrogens should be taken into consideration
- Returns:
- float: Root-mean-square deviation value between two structures
-
class
gensec.precon.
LindhExponent
(atom2row, alphas=array([[3.57106484, 1.4102135 , 1.4102135 ], [1.4102135 , 0.99989815, 0.99989815], [1.4102135 , 0.99989815, 0.99989815]]), ref_ds=array([[0.71438923, 1.11127214, 1.33881834], [1.11127214, 1.51873859, 1.79920251], [1.33881834, 1.79920251, 1.79920251]]))¶ Bases:
object
Class of the LINDH object which provides the exponent factors.
A Lindh Damper is an object that can judge the importance of an atom pair from the interatomic distance and the atom numbers.
- Attributes:
- alphas (TYPE): reference alpha values for rows i and j used as the dumping coefficient in the exponent. atom2row (TYPE): list of numbers where for each atom in the structure the row in periodic table is associated. ref_ds (matrix): reference distance values rij from the paper for more details: R. Lindh et al. / Chemical Physics Letters 241 (199s) 423-428
-
Rcut
(max_exponent)¶ Return the maximum distance for given exponent.
- Args:
- max_exponent (float): Description
- Returns:
- float: cutoff distance
-
exponent
(AB, i_atom, j_atom)¶ Return the exponent for distance AB of given types.
- Args:
- AB (float): Distance between A and B i_atom (int): Number of the atom i in the structure j_atom (int): Number of the atom j in the structure
- Returns:
- float: Lindh Exponent
-
gensec.precon.
LindhHessian
(atoms)¶ Construction of Lindh preconditioned Hessian matrix
- Args:
- atoms (ASE atoms object): atoms of the system
- Returns:
- matrix: Lindh Hesian
-
class
gensec.precon.
Pairs
(bra, atom, damper, max_sing_thres)¶ Bases:
object
Find chains (pairs, triples, …) of atoms.
- Example:
- # Chain of pairs, one at zero, one slightly distorted. >>> bra = [[1, 0, 0]] >>> atom = [[0, 0, 0], [0.01, 0.25, 0]] >>> pairs = Pairs(bra, atom, SimpleDamper(), 1.5) >>> bonds = list(pairs.chains(2, 1.01)) # all bonds up to length 1. >>> for damp, atlist in bonds: # only intracell and its own images. … assert len(atlist) == 2 … print “%6.4f %s” % (damp, atlist) 0.2502 [(0, (0, 0, 0)), (1, (0, 0, 0))] 1.0000 [(0, (0, 0, 0)), (0, (1, 0, 0))] 1.0000 [(1, (0, 0, 0)), (1, (1, 0, 0))] >>> bendings = list(pairs.chains(3, 1.251)) # 1.251: one short 1->2 bond. >>> for damp, atlist in bendings: … assert len(atlist) == 3 … print “%6.4f %s” % (damp, atlist) 1.2502 [(0, (0, 0, 0)), (0, (-1, 0, 0)), (1, (-1, 0, 0))] 1.2502 [(0, (0, 0, 0)), (0, (1, 0, 0)), (1, (1, 0, 0))] 1.2502 [(0, (0, 0, 0)), (1, (0, 0, 0)), (1, (-1, 0, 0))] 1.2502 [(0, (0, 0, 0)), (1, (0, 0, 0)), (1, (1, 0, 0))]
- Attributes:
- abcs (array of tuples): bravais lattice multipliers atom (array): coordinates of atoms damper (object): Lindh exponent lat (array): lattice vectors max_sing_thres (float): threshold for dumber n_atom (int): Number of atoms pairs (list): for each atom corresponding with list of atoms that are within cutoff distance periodicatoms (array): coordinates of atoms within lattice vectors
-
chains
(n, thres, directed=True)¶ Return a list of (damp, [(i, abc), …]) tuples of n-chains.
This is the main workhorse and returns a weight-sorted list of bonds (n=2), bendings (n=3), or torsions (n=3).
- Args:
- n (int): number of n-chain thres (float): threshhold, default=15.0 directed (bool, optional): Specifies the direction in Bravais lattice
- Returns:
- list: list of (damp, [(i, abc), …]) tuples of n-chains
-
getvec
(iabc)¶ Summary
- Args:
- iabc (int, tuple): atom index and Bravais multipliers
- Returns:
- array: coordinate of atom multiplied by lattice vector and Bravais multiplier
-
gensec.precon.
RAB
(cell_h, cell_ih, qi, qj)¶ Calculates the vector separating two atoms.
This file is part of i-PI. i-PI Copyright (C) 2014-2015 i-PI developers
Note that minimum image convention is used, so only the image of atom j that is the shortest distance from atom i is considered.
Also note that while this may not work if the simulation box is highly skewed from orthorhombic, as in this case it is possible to return a distance less than the nearest neighbour distance. However, this will not be of importance unless the cut-off radius is more than half the width of the shortest face-face distance of the simulation box, which should never be the case. rij is in Angstroms
- Args:
- cell_h: The simulation box cell vector matrix. cell_ih: The inverse of the simulation box cell vector matrix. qi: The position vector of atom i. qj: The position vectors of one or many atoms j shaped as (N, 3).
- Returns:
- dij: The vectors separating atoms i and {j}. rij: The distances between atoms i and {j}.
-
gensec.precon.
add_jitter
(hessian, jitter)¶ Add jitter to the diagonal
For the reasons of numerical stability adding jitter parameter to the diagonal of the matrix allows inverting of the matrix without problems. creates the Identity matrix with scale of jitter and adds it to the input hessian.
- Arguments:
- hessian (matrix): 3Nx3N where N is lenght of atoms jitter (float): small value that is added to diagonal
- Returns:
- matrix: Hessian with jitter value added to the diagonal
-
gensec.precon.
canonize
(atom_name)¶ Return canonical name of atom_name.
The canonical name is the first capital of the string with an optional minuskel.
- Example:
>>> print canonize("Ru"), canonize("-H3"), canonize("CT") Ru H C
- Args:
- atom_name (str): Symbol of the element
- Returns:
- TYPE: Canonical representation of Chemical symbol
-
gensec.precon.
check_positive_symmetric
(hessian)¶ Check properties of Hessian matrix
The function in quazi-Newton’s method has to be strongly convex which is true if Hessian is positive definite and symmetric matrix. Symmetric if all the values of the Hessian after substracting of it’s transpose are smaller than 1e-10. Positive definite if all the eigenvalues are positive.
- Arguments:
- hessian (matrix): 3Nx3N where N is lenght of atoms
- Returns:
- boolean, boolean: True and True if Hessian symmetric and positive definite
-
gensec.precon.
dd_arccos
(val_d)¶ Arccosine between parameter and derivatives
- Args:
- vec1_d (tuple): parameter1 and derivatives1 vec2_d (tuple): parameter2 and derivatives2
- Returns:
- tuple: angle between parameter and derivatives
-
gensec.precon.
dd_arcsin
(val_d)¶ Arcsine angle between parameter and derivatives
- Args:
- vec1_d (tuple): parameter1 and derivatives1 vec2_d (tuple): parameter2 and derivatives2
- Returns:
- tuple: Arcsine of the angle between parameter and derivatives
-
gensec.precon.
dd_cosv1v2
(vec1_d, vec2_d)¶ Cosine between parameter and derivatives
- Args:
- vec1_d (tuple): parameter1 and derivatives1 vec2_d (tuple): parameter2 and derivatives2
- Returns:
- tuple: angle between parameter and derivatives
-
gensec.precon.
dd_cross
(vec1_d, vec2_d)¶ Cross product of the value and derivatives
- Args:
- vec1_d (tuple): value1 and derivative1 vec2_d (tuple): value2 and derivative2
- Returns:
- (array, array): cross product of value1 and value2 and sum of the cross products of corresponding value and derivatives
-
gensec.precon.
dd_directed_angle
(vec1_d, vec2_d, dir_d)¶ Angle and derivative of the parameter
- Args:
- vec1_d (tuple): parameter1 and derivative1 vec2_d (tuple): parameter2 and derivative2 dir_d (tuple): (direction, np.c_[np.zeros((3, 3)), np.zeros((3, 3)), np.zeros((3, 3))])
- Returns:
- tuple: Angle and derivative of the parameter
-
gensec.precon.
dd_dot
(vec1_d, vec2_d)¶ Dot product of the value and derivatives
- Args:
- vec1_d (tuple): value1 and derivative1 vec2_d (tuple): value2 and derivative2
- Returns:
- (array, array): dot product of value1 and value2 and sum of the tensorproducts corresponding value and derivatives
-
gensec.precon.
dd_mult
(vec_d, fac)¶ Multiply value and derivative by the factor
- Args:
- vec_d (tuple): value and derivative fac (float): multiplication factor
- Returns:
- (array, array): value*factor, derivative*factor
-
gensec.precon.
dd_norm
(vec_d)¶ Norm of the parameter and derivative
- Args:
- vec_d (tuple): parameter and derivative
- Returns:
- tuple: Normalized parameter and derivative
-
gensec.precon.
dd_normalized
(vec_d)¶ Norm of the parameter and derivative
- Args:
- vec_d (tuple): parameter and derivative
- Returns:
- tuple: value divided by it’s norm and derivative and sum of the products : norm of parameter*derivative and parameter* norm of derivative.
-
gensec.precon.
dd_power
(var_d, n)¶ Power value and derivative to n
- Args:
- var_d (tuple): value and derivative n (float): power
- Returns:
- (array, array): value**n, n * (var ** (n - 1)) * dvar
-
gensec.precon.
dd_prod
(*arg_ds)¶ Product of the value and derivatives
- Args:
- arg_ds: tuple that contains all the value and derivatives
- Returns:
- (array, array): product of the value and derivatives
-
gensec.precon.
dd_sum
(*arg_ds)¶ Summation of the value and derivatives
- Args:
- arg_ds: tuple that contains all the value and derivatives
- Returns:
- (array, array): summ of the value and derivatives
-
gensec.precon.
get_R0AB
(A, B)¶ Get the average of the two vdW radi of atoms.
Takes the vdW radii of atom A and B and calculates their average. The units converted to Angstroms
- Args:
- A (atom type): Chemical symbol of the atom A B (atom type): type): Chemical symbol of the atom B
- Returns:
- float: average vdW radii of two atoms.
-
gensec.precon.
get_pairs
(atoms1, atoms2, Rcut, use_scipy=True)¶ Feor eac atom get pairs within cutoff distance
- Args:
- atoms1 (array): coordinates of atoms1 atoms2 (array): coordinates of atoms2 Rcut (float): cutoff distance use_scipy (bool, optional): Use scipyif available
- Returns:
- list: lists of atoms for each atom a list that is within cutoff distance.
-
gensec.precon.
isposvec
(vec, eps=1e-10, noself=True)¶ Return if vector is in some special sense ‘positive’.
Positiveness is defined by the rightmost non-zero dimension: >>> isposvec(np.array([1., 0., -1.])) False >>> isposvec(np.array([1., 0., 0.])) True >>> isposvec(np.array([-1., 0., 1.])) True
- Args:
- vec (vector): vector eps (float, optional): threshhold noself (bool, optional): Description
- Returns:
- TYPE: True if the vector is positive definite
- Raises:
- ValueError: If vector is zero
-
gensec.precon.
makeorthvec
(orth)¶ Construct a (3 component) vector orthogonal to orth.
- Args:
- orth (vector): vector
- Returns:
- vector: Orthonormal to the input vector
-
gensec.precon.
model_matrix
(bra, atom, builder, damper, thres, logfile=None)¶ Construct model Hessian. Returns the HessianBuilder object.
Implementation of the Lindh Hessian preconditioner routine
- Args:
- bra (matrix): bravais lattice vectors atom (array): Coordinates of atoms builder (object): Hessian builder damper (object): Lindh damping function LindhExponent(atom2row=[0, 0]) two Hydrogens in this case thres (float): cutoff distance for atom pairs and so on logfile (None, optional): Logfile for output. Disabled in the module version of the implementation.
- Returns:
- object: Builder object that produces Hessian matrix
-
gensec.precon.
name2row
(atom_name)¶ Name to row
Returns row number of atom type (starting with 0, max 2).
- Args:
- atom_name (str): Symbol of the element
- Returns:
- (int): Number of row of element
-
gensec.precon.
preconditioned_hessian
(structure, fixed_frame, parameters, atoms_current, H, task='update')¶ Summary
- Args:
- structure (ASE Atoms object): template structure object fixed_frame (ASE Atoms object): atoms in the fixed frame parameters (dict): parameters loaded from parameters file atoms_current (ASE Atoms object): atoms H (matrix): Current Hessian matrix task (str, optional): “update” or “initial”
-
gensec.precon.
q_bending
(Avec, Bvec, Cvec, direction=None)¶ Bond angle and derivative wrt vectors AB and BC.
- Test:
>>> A = np.array([ 1, 1, 1]) >>> B = np.zeros(3) >>> C = np.array([-1,-1, 1]) >>> print round(np.rad2deg(q_bending(A, B, C)[0]), 1) 109.5 >>> assert _test_qgrad(q_bending, 3) < 1e-5
- Args:
- Avec (array): coordinate A Bvec (array): coordinate B Cvec (array): coordinate C direction (None, optional): order of atoms A, B and C
- Returns:
- (float, array): Bond angle and derivative with respect to vectors Ab and BC
-
gensec.precon.
q_bond
(Avec, Bvec)¶ Bond length and derivative with respect to vector AB.
- Test:
>>> np.allclose(q_bond([0., 0., 0.], [1., 1., 1.])[0], np.sqrt(3.)) True >>> assert _test_qgrad(q_bond, 2) < 1e-5
- Args:
- Avec (array): coordinate A Bvec (array): coordinate B
- Returns:
- (float, array): Bond length and derivative with respect to vector AB
-
gensec.precon.
q_torsion
(Avec, Bvec, Cvec, Dvec)¶ Bond torsion and derivative wrt vectors AB, BC, and CD.
- Test:
>>> A = np.array([0., 0., 1.]) >>> B = np.array([0., 0., 0.]) >>> C = np.array([1., 0., 0.]) >>> D = np.array([1., 1., 0.]) >>> print round(np.rad2deg(q_torsion(A, B, C, D)[0]), 5) 90.0 >>> try: ... assert _test_qgrad(q_torsion, 4) < 1e-5 ... except ValueError: # May happen with bad luck. ... pass
- Args:
- Avec (array): coordinate A Bvec (array): coordinate B Cvec (array): coordinate C Dvec (array): coordinate D
- Returns:
- (float, array): Bond torsion and derivative with respect to vectors AB, BC, and CD.
-
gensec.precon.
rho_ij
(A, B, R)¶ Calculates rho between A and B atoms
- Args:
- A (str): chemical symbol of A B (str): chemical symbol of B R (float): Distance between atoms
- Returns:
- float: rho between A and B
-
gensec.precon.
set_constrains
(atoms, parameters)¶ Set the constrains
Adds the constrains for geometry optimizations to the Atoms object. During geometry optimization the forces on the constrained atoms will be always zero. Multiple variants for setting of constrains are possible for setting of the constrains.
- Args:
- atoms (ASE Atoms object): Geometry to optimize parameters (file): file with parameters for constrainings
-
gensec.precon.
vdW_element
(k, l, C6, C12, R0, R, qi, qj)¶ VdW element
- Args:
- k (int): index of cartesian coordinates 0, 1 or 2 l (int): index of cartesian coordinates 0, 1 or 2 C6 (float): C6 coefficients between A and B C12 (float): C12 coefficients between A and B R0 (float): average vdW radii of atoms A and B R (float): distance between atoms A and B qi (float): Cartesian coordinates of atom A qj (float): Cartesian coordinates of atom B
- Returns:
- vdW element (float): vdW element of k and l
-
gensec.precon.
vdwHessian
(atoms)¶ vdW Preconditioning scheme
Calculates Hessian matrix with use of vdW preconditioning scheme.
- Args:
- atoms (ASE atoms object): atoms for which vdW Hessian is calculated
- Returns:
- matrix: Hessian matrix obtained with vdW preconditioning scheme.
gensec.protocols module¶
Create different search protocols
gensec.relaxation module¶
Summary
-
class
gensec.relaxation.
Calculator
(parameters)¶ Bases:
object
Creates ASE calculator for performing of the geometry optimizations
- Attributes:
- calculator (TYPE): ASE calculator
-
estimate_mu
(structure, fixed_frame, parameters)¶ Estimate scaling parameter mu for Expoential preconditioner scheme. For more implementation detail see Packwood et. al: A universal preconditioner for simulating condensed phase materials, J. Chem. Phys. 144, 164109 (2016). https://aip.scitation.org/doi/full/10.1063/1.4947024
and
https://wiki.fysik.dtu.dk/ase/ase/optimize.html
First reads the parameters file and checks if the estimation of mu is necessary. Then Estimates mu with default parameters of r_cut=2*r_NN, where r_NN is estimated nearest neighbour distance. Parameter A=3.0 set to default value as was mentioned in the paper.
- Args:
- structure {GenSec structure}: structure object fixed_frame {GenSec fixed frame}: fixed frame object parameters {JSON} : Parameters from file
- Returns:
- float: Scaling parameter mu
-
finish_relaxation
(structure, fixed_frame, parameters, calculator)¶ Finishes unfinished calculation
Reads the output in logfile and compares to the convergence criteria in parameters.json file. If no “finished” reads the trajectory file and relax the structure.
- Arguments:
- structure {GenSec structure}: structure object fixed_frame {GenSec fixed frame}: fixed frame object parameters {JSON} : Parameters from file directory {str} – Directory, where the calculation was carried out calculator (ASE Calculator): Calculator for performing relaxation
-
finished
(directory)¶ Mark, that calculation finished successfully
Write file “finished” if the geometry optimiztion is finished
- Arguments:
- directory {str} – Directory, where the calculation was carried out
-
relax
(structure, fixed_frame, parameters, directory)¶ Perform geometry optimization with specified ASE calculator.
Merge the fixed frame and structure object into the Atoms object that enters then the geometry optimization routine.
- Args:
- structure {GenSec structure}: structure object fixed_frame {GenSec fixed frame}: fixed frame object parameters {JSON} : Parameters from file directory {str} – Directory, where the calculation was carried out
-
set_constrains
(atoms, parameters)¶ Setting the constrains for geometry optimization
For now only freezing of the atoms within specified values of z-coordinate is implemented.
- Args:
- atoms {Atoms}: ASE Atoms object parameters {JSON} : Parameters from file
gensec.structure module¶
Summary
-
class
gensec.structure.
Fixed_frame
(parameters)¶ Bases:
object
Object for fixed frame.
- Attributes:
- fixed_frame (ASE Atoms): Atoms from specified file mic (bool): Description pbc (TYPE): Description
-
get_len
()¶ Summary
- Returns:
- TYPE: Description
-
set_fixed_frame_positions
(structure, atoms)¶ Apply the coordinates from atoms object
Set the coordinates from atoms to fixed_frame object
- Arguments:
- structure (TYPE): Description atoms (TYPE): Description atoms {ase atoms object} – ASE Atoms object with cordinates
-
class
gensec.structure.
Structure
(parameters)¶ Bases:
object
Crates the structure object with multiple molecules
- Attributes:
- atoms (TYPE): Description connectivity_matrix_full (TYPE): Description connectivity_matrix_isolated (TYPE): Description list_of_torsions (TYPE): Description mic (bool): Description molecules (TYPE): Description mu (TYPE): Description pbc (TYPE): Description
-
apply_conf
(conf)¶ Apply confiruration to the structure object
Getting the configuration in the form of dictionary and applies it to the structure object
- Arguments:
- conf (TYPE): Description conf {dictionary} – Dictionary with configuration stored
-
apply_configuration
(configuration)¶ Summary
- Args:
- configuration (TYPE): Description
-
apply_torsions
(configuration)¶ Summary
- Args:
- configuration (TYPE): Description
-
atoms_object
()¶ Convert Structure object to ASE Atoms object
Goes through Molecules in Structure object and join them to one ASE Atoms object
- Returns:
- [ASE Atoms] – ASE Atoms object
-
create_configuration
(parameters)¶ Summary
- Args:
- parameters (TYPE): Description
- Returns:
- TYPE: Description
-
extract_conf_keys_from_row
()¶ Extract configurtion keys
From the row of the database all keys are read and the configuration is returned as list of keys that correspond to the torsional, rotational and positional degrees of freedom of the structure object
- Returns:
- [list] – list of keys reflectin the configuration
- on internal degrees of freedom
-
find_in_database
(conf, database, parameters)¶ Check if the configuration is stored in database
[description]
- Arguments:
- conf (TYPE): Description database (TYPE): Description parameters (TYPE): Description conf {dictionary} – Conformation stored in dictionary database {ASE database} – ASE database with other configurations parameters {JSON} : Parameters from file
- Returns:
- [boolean] – True if the configuration found in database
-
read_configuration
(atoms_positions)¶ Read the configuration from atoms positions
Read the atoms positions and calculate the values of degrees of freedom using the template and list of torsions stored in the structure object
- Arguments:
- atoms_positions (TYPE): Description atoms_positions {ASE Atoms} – ASE Atoms object
- Returns:
- [dictionary] – Dictionary reflecting the cinfiguration on internal degrees of freedom
-
set_structure_positions
(atoms)¶ Apply the coordinates from atoms object
Set the coordinates from atoms to structure object
- Arguments:
- atoms (TYPE): Description atoms {ase atoms object} – ASE Atoms object with cordinates
-
torsions_from_conf
(configuration)¶ Summary
- Args:
- configuration (TYPE): Description
- Returns:
- TYPE: Description
-
gensec.structure.
random
() → x in the interval [0, 1).¶