Force constant models¶
ForceConstantPotential¶

class
hiphive.
ForceConstantPotential
(cs, parameters)[source]¶ A finalized force constant model. Can produce force constants for any structure compatible with the structure for which the model was set up.
Parameters:  cs (ClusterSpace) – The cluster space the model is based upon
 parameters (numpy.ndarray) – The fitted paramteres

get_force_constants
(atoms)[source]¶ Return the force constants of a compatible structure.
Parameters: atoms (ase.Atoms) – input structure Returns: force constants Return type: ForceConstants

orbit_data
¶ list of dictionaries containing detailed information for each orbit, e.g. cluster radius and force constant
Type: list

static
read
(f)[source]¶ Reads a force constant potential from file.
Parameters: f (str or file object) – name of input file (str) or stream to load from (file object) Returns: the original object as stored in the file Return type: ForceConstantPotential

symprec
¶
ForceConstantCalculator¶

class
hiphive.calculators.
ForceConstantCalculator
(fcs)[source]¶ This class provides an ASE calculator that can be used in conjunction with integrators and optimizers with the atomic simulation environment (ASE). To initialize an object of this class one must provide the ideal atomic configuration along with a compatible force constant model.
Parameters: fcs (ForceConstants) – the force constants instance must contain atoms. 
calculate
(atoms=None, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]¶ Do the calculation.
 properties: list of str
 List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
 system_changes: list of str
 List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.

compute_energy_and_forces
()[source]¶ Compute energy and forces.
Returns: energy and forces Return type: float, list(list(float))

implemented_properties
= ['energy', 'forces']¶

ForceConstants¶

class
hiphive.
ForceConstants
(fc_dict=None, cluster_groups=None, fc_list=None, atoms=None)[source]¶ Container class for force constants.
Either specify fc_dict or both cluster_groups and fc_list.
Parameters:  fc_dict (dict) – dict which holds all force constants with clusters as keys and the respective force constant as value
 cluster_groups (list) – list of groups of clusters, clusters in the same group should have identical force constants.
 fc_list (list) – list of force constants, one force constant for each cluster group
 atoms (ase.Atoms) – supercell corresponding to the fcs

_fc_dict
¶ dictionary that holds all force constants with clusters as keys and the respective force constant as value
Type: dict

assert_acoustic_sum_rules
(order=None, tol=1e06)[source]¶ Asserts that acoustic sum rules are enforced for force constants.
Parameters:  order (int) – specifies which order to check, if None all are checked
 tol (float) – numeric tolerance for checking sum rules
Raises: AssertionError
– if acoustic sum rules are not enforced

clusters
¶ sorted list of clusters (identified as tuple of site indices)
Type: list

get_fc_array
(order, format='phonopy')[source]¶ Returns force constants in array format for specified order.
Parameters:  order (int) – force constants for this order will be returned
 format (str) – specify which format (shape) the NumPy array should have, possible values are phonopy and ase
Returns: NumPy array with shape (N,)*order + (3,)*order where N is the number of atoms
Return type:

get_fc_dict
(order=None, permutations=False)[source]¶ Returns force constant dictionary for one specific order.
Parameters:  order (int) – fcs returned for this order
 permutations (bool) – if True returns all permutations of cluster, else only force constants for sorted cluster
Returns: dictionary with keys corresponding to clusters and values to the respective force constant
Return type: dict

natoms
¶ number of atoms (maximum index in a cluster +1)
Type: int

orders
¶ orders for which force constants exist
Type: list

print_cluster
(cluster)[source]¶ Prints force constants for a cluster in a nice format.
Parameters: cluster (tuple(int)) – sites belonging to the cluster

static
read
(f)[source]¶ Reads force constants from file.
Parameters: f (str or file object) – name of input file (str) or stream to load from (file object)

sparse
¶ if True the object was initialized with sparse data
Type: bool
Constraints¶

hiphive.
enforce_rotational_sum_rules
(cs, parameters, sum_rules, **kwargs)[source] Enforces rotational sum rules by projecting parameters.
Note
The interface to this function might change in future releases.
Parameters:  cs (ClusterSpace) – the underlying cluster space
 parameters (numpy.ndarray) – parameters to be constrained
 sum_rules (list(str)) – type of sum rules to enforce; possible values: ‘Huang’, ‘BornHuang’
 ridge_alpha (float) – hyperparameter to the ridge regression algorithm; keyword argument passed to the optimizer; larger values specify stronger regularization, i.e. less correction but higher stability [default: 1e6]
 iterations (int) – number of iterations to run the projection since each step projects the solution down to each nullspace in serial; keyword argument passed to the optimizer [default: 10]
Returns: constrained parameters
Return type: Examples
The rotational sum rules can be enforced to the parameters before constructing a force constant potential as illustrated by the following snippet:
cs = ClusterSpace(reference_structure, cutoffs) sc = StructureContainer(cs) # add structures to structure container opt = Optimizer(sc.get_fit_data()) opt.train() new_params = enforce_rotational_sum_rules(cs, opt.parameters, sum_rules=['Huang', 'BornHuang']) fcp = ForceConstantPotential(cs, new_params)