Esempio n. 1
0
 def __short_str__(self):
     tyname = self.__class__.__name__
     if not self.is_orphaned():
         return "{} for atom indices {}".format(tyname,
                                                andjoin(self.atom_indices))
     else:
         return "(orphaned) {} with atoms {}".format(
             tyname, andjoin(self.atom_indices))
 def __str__(self):
     """
     """
     tyname = self.__class__.__name__
     if self.is_orphaned():
         return "(orphaned) {} for atoms {}".format(tyname, andjoin([str(atom) for atom in self.atoms]))
     else:
         mol_short_name = short_str(self.molecule)
         return "{} for atom indices {} of {}".format(tyname, andjoin(self.atom_indices), mol_short_name)
Esempio n. 3
0
 def __str__(self):
     """
     """
     tyname = self.__class__.__name__
     if self.is_orphaned():
         return "(orphaned) {} for atoms {}".format(
             tyname, andjoin([str(atom) for atom in self.atoms]))
     else:
         mol_short_name = short_str(self.molecule)
         return "{} for atom indices {} of {}".format(
             tyname, andjoin(self.atom_indices), mol_short_name)
Esempio n. 4
0
 def b_tensor_element(self, *cart_coords_or_indices):
     """
     Retrieve an element of the Coordinate's B tensor using CartesianCoordinate instances
     and/or integer indices *in the molecule's indexing scheme*.
     """
     if self._btensor is None:
         self._init_btensor()
     if all(isinstance(c, CartesianCoordinate) for c in cart_coords_or_indices):
         idxs = cart_coords_or_indices
     elif all(isinstance(c, int) for c in cart_coords_or_indices):
         try:
             idxs = self.internal_indices_for(cart_coords_or_indices)
         except CoordinateDependencyError:
             #TODO raise an error here instead?
             raise
             #return 0.0
     else:
         raise TypeError(
             "arguments to b_tensor_element must be all integers (in the molecule's"
             " indexing scheme) or all CartesianCoordinate instances."
             " Mixing of CartesianCoordinates and integers in b_tensor_element"
             " arguments is confusing and thus no longer allowed."
             " indices were ('{}')".format(
                 "', '".join(str(c) for c in cart_coords_or_indices)
             )
         )
     if not self.is_orphaned():
         try:
             if self._btensor.has_order(len(cart_coords_or_indices)):
                 return self._btensor[idxs]
             else:
                 self.fill_b_tensor_analytically(order=len(cart_coords_or_indices))
                 return self._btensor[idxs]
         except CoordinateDependencyError:
             #TODO raise an error here instead?
             raise
             #return 0.0
     else:
         if sanity_checking_enabled:
             if not all(isinstance(cart, int) for cart in cart_coords_or_indices):
                 raise ValueError(
                     "b_tensor elements may not be retrieved for orphaned coordinates by"
                     " anything but integer indices (got indices of types {})".format(
                         andjoin("'" + type(item).__name__ + "'" for item in cart_coords_or_indices)
                     )
                 )
         order = len(idxs)
         if not self._btensor.has_order(order):
             response = self.fill_b_tensor_analytically(order=order)
             if response is NotImplemented:
                 self._btensor[...] = self.finite_difference_b_tensor(order=order)
         try:
             return self._btensor.for_order(order)[idxs]
         except IndexError:
             raise
 def __short_str__(self):
     tyname = self.__class__.__name__
     if not self.is_orphaned():
         return "{} for atom indices {}".format(tyname, andjoin(self.atom_indices))
     else:
         return "(orphaned) {} with atoms {}".format(tyname, andjoin(self.atom_indices))