Пример #1
0
 def __str__(self):
     return "InternalRepresentation of {} with coordinates\n{}".format(
         shortstr(self.molecule),
         indented('\n'.join('[{}] {}: {}'.format(
             i, shortstr(coord), str(coord.value_with_units)
         ) for i, coord in enumerate(self.coords)))
     )
Пример #2
0
 def __str__(self):
     ret_val = "CartesianRepresentation of molecule {}, in {}:\n".format(
         shortstr(self.molecule), self.units)
     for i, (x, y, z) in enumerate(grouper(3, self)):
         ret_val += indent(
             '{:>9} {:12.8f} {:12.8f} {:12.8f}\n'.format(
                 '[{}-{}]'.format(3 * i, 3 * i + 2), x.value, y.value,
                 z.value), 2)
     return ret_val
Пример #3
0
 def validate(self):
     bmat = self.b_matrix
     evals = np.linalg.eigvalsh(bmat * bmat.T)
     nvalid = len([e for e in evals if abs(e) > InternalRepresentation.zero_eigenvalue])
     if nvalid != self.molecule.ninternals:
         raise RepresentationError("Have {} nonredundant internal coordinates, but need {}.\nCoordnates are:\n{}".format(
             nvalid,
             self.molecule.ninternals,
             indented('\n'.join('[' + str(i) + '] ' + shortstr(c) for i, c in enumerate(self.coords)))
         ))
Пример #4
0
 def __str__(self):
     ret_val = "CartesianRepresentation of molecule {}, in {}:\n".format(shortstr(self.molecule), self.units)
     for i, (x, y, z) in enumerate(grouper(3, self)):
         ret_val += indent(
             "{:>9} {:12.8f} {:12.8f} {:12.8f}\n".format(
                 "[{}-{}]".format(3 * i, 3 * i + 2), x.value, y.value, z.value
             ),
             2,
         )
     return ret_val
Пример #5
0
 def validate(self):
     bmat = self.b_matrix
     evals = np.linalg.eigvalsh(bmat * bmat.T)
     nvalid = len([
         e for e in evals if abs(e) > InternalRepresentation.zero_eigenvalue
     ])
     if nvalid != self.molecule.ninternals:
         raise RepresentationError(
             "Have {} nonredundant internal coordinates, but need {}.\nCoordnates are:\n{}"
             .format(
                 nvalid, self.molecule.ninternals,
                 indented('\n'.join('[' + str(i) + '] ' + shortstr(c)
                                    for i, c in enumerate(self.coords)))))
Пример #6
0
 def __str__(self):
     namestrs = []
     valstrs = []
     it = np.nditer(self, flags=['multi_index'])
     for x in it:
         namestrs.append(", ".join(shortstr(self.representation[i]) for i in it.multi_index))
         valstrs.append("{: .8f}{}".format(float(x), (" " + str(self.units) if hasunits(self) else '')))
     width=max(len(s) for s in namestrs) + 4
     ret_val = self.__class__.__name__ + ":\n"
     for name, val in zip(namestrs, valstrs):
         ret_val += ("{:>"+str(width)+"}: {}\n").format(name, val)
     ret_val += "  for representation:\n{}".format(indent(str(self.representation)))
     return ret_val
Пример #7
0
 def __str__(self):
     namestrs = []
     valstrs = []
     it = np.nditer(self, flags=['multi_index'])
     for x in it:
         namestrs.append(", ".join(
             shortstr(self.representation[i]) for i in it.multi_index))
         valstrs.append("{: .8f}{}".format(
             float(x), (" " + str(self.units) if hasunits(self) else '')))
     width = max(len(s) for s in namestrs) + 4
     ret_val = self.__class__.__name__ + ":\n"
     for name, val in zip(namestrs, valstrs):
         ret_val += ("{:>" + str(width) + "}: {}\n").format(name, val)
     ret_val += "  for representation:\n{}".format(
         indent(str(self.representation)))
     return ret_val
Пример #8
0
 def __str__(self):
     return "InternalRepresentation of {} with coordinates\n{}".format(
         shortstr(self.molecule),
         indented('\n'.join('[{}] {}: {}'.format(
             i, shortstr(coord), str(coord.value_with_units))
                            for i, coord in enumerate(self.coords))))