def __init__(self, atom, direction, parent=None, parent_internal_coordinate=None, index=None, value=None, freeze_value=False, units=DistanceUnit.default, **kwargs): """ Constructor :Parameters: atom : `Atom` The atom represented by the coordinate index : `int` The index of the coordinate in the parent representation direction : `int` The direction (x, y, or z) that the coordinate describes. (0 for x, 1 for y, 2 for z, which are also class constants) parent : `CartesianRepresentation` The representation containing the coordinate `self` """ self._atom = atom self._direction = direction if freeze_value: # TODO think through the implications of this when I'm a little more cogent if value is not None: self._value = strip_units(value, units) elif not self.is_orphaned(): self._value = strip_units( atom.position[direction] if value is None else value, units) else: raise ValueError( "don't know how to get value for orphaned CartesianCoordinate" ) elif value is not None: raise NotImplementedError( "value given for CartesianCoordinate, but" " 'freeze_value' was not set to True; this sort" " of functionality is not yet implemented.") if parent_internal_coordinate is not None: self.parent_internal_coordinate = parent_internal_coordinate self._index = index super(CartesianCoordinate, self)._init(units=units, parent=parent, freeze_value=freeze_value, **kwargs) if not self.is_orphaned(): self._index = self.molecule.index(atom) * 3 + self.direction
def __init__(self, atom, direction, parent=None, parent_internal_coordinate=None, index=None, value=None, freeze_value=False, units=DistanceUnit.default, **kwargs): """ Constructor :Parameters: atom : `Atom` The atom represented by the coordinate index : `int` The index of the coordinate in the parent representation direction : `int` The direction (x, y, or z) that the coordinate describes. (0 for x, 1 for y, 2 for z, which are also class constants) parent : `CartesianRepresentation` The representation containing the coordinate `self` """ self._atom = atom self._direction = direction if freeze_value: # TODO think through the implications of this when I'm a little more cogent if value is not None: self._value = strip_units(value, units) elif not self.is_orphaned(): self._value = strip_units(atom.position[direction] if value is None else value, units) else: raise ValueError("don't know how to get value for orphaned CartesianCoordinate") elif value is not None: raise NotImplementedError("value given for CartesianCoordinate, but" " 'freeze_value' was not set to True; this sort" " of functionality is not yet implemented.") if parent_internal_coordinate is not None: self.parent_internal_coordinate = parent_internal_coordinate self._index = index super(CartesianCoordinate, self)._init( units=units, parent=parent, freeze_value=freeze_value, **kwargs ) if not self.is_orphaned(): self._index = self.molecule.index(atom) * 3 + self.direction
def __init__(self, robustness=InternalCoordinate.b_tensor_finite_difference_rigor, delta=InternalCoordinate.b_tensor_finite_difference_delta, units=None, forward=False): self.robustness = robustness self.delta = delta if self.cartesian_representation is not None: self.delta = strip_units(self.delta, units) self.forward = forward self.displaced_molecules = {} self.displaced_coordinates = {} self.fdiff_instances = {}
def is_zero(self, cutoff=None): """ Returns True if all elements of `self` have absolute values less than `cutoff`, which defaults to `Tensor.zero_cutoff` .. note:: `Tensor.zero_cutoff` is treated as a pseudo-class attribute for Tensor instances, meaning individual instances can also set a `zero_cutoff` attribute which will take precidence over the class-level default. """ if cutoff: cutoff = strip_units(cutoff, self.units) else: cutoff = self.zero_cutoff return super(Tensor, self).is_zero(cutoff)