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:
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 – list of dictionaries containing detailed information for each orbit, e.g. cluster radius and force constant

primitive_structure

ase.Atoms – atomic structure

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
write(f)[source]

Writes a force constant potential to file.

Parameters:f (str or file object) – name of input file (str) or stream to write to (file object)

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]
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

dict – dictionary that holds all force constants with clusters as keys and the respective force constant as value

assert_acoustic_sum_rules(order=None, tol=1e-06)[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

atoms

ase.Atoms – supercell corresponding to force constants

clusters

list – sorted list of clusters (identified as tuple of site indices)

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:

numpy.ndarray

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

int – number of atoms (maximum index in a cluster +1)

orders

list – orders for which force constants exist

print_cluster(cluster: tuple)[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

bool – if True the object was initialized with sparse data

write(f)[source]

Writes force constants to file.

Parameters:f (str or file object) – name of input file (str) or stream to write to (file object)

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’, ‘Born-Huang’
  • 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: 1e-6]
  • 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:

numpy.ndarray

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', 'Born-Huang'])
fcp = ForceConstantPotential(cs, new_params)