示例#1
0
    def __call__(self, x, do_gradient=False):
        """Compute the energy (and gradient) for a set of Cartesian coordinates

           Argument:
            | ``x``  --  the Cartesian coordinates
            | ``do_gradient``  --  when set to True, the gradient is also
                                   computed and returned. [default=False]
        """
        x = x.reshape((-1, 3))
        result = 0.0

        gradient = np.zeros(x.shape, float)
        if self.dm_quad > 0.0:
            result += ff_dm_quad(x, self.dm0, self.dmk, self.dm_quad, gradient,
                                 self.matrix, self.reciprocal)
        if self.dm_reci:
            result += ff_dm_reci(x, self.vdw_radii, self.dm, self.dm_reci,
                                 gradient, self.matrix, self.reciprocal)
        if self.bond_quad:
            result += ff_bond_quad(x, self.bond_edges, self.bond_lengths,
                                   self.bond_quad, gradient, self.matrix,
                                   self.reciprocal)
        if self.span_quad:
            result += ff_bond_quad(x, self.span_edges, self.span_lengths,
                                   self.span_quad, gradient, self.matrix,
                                   self.reciprocal)
        if self.bond_hyper:
            result += ff_bond_hyper(x, self.bond_edges, self.bond_lengths,
                                    self.bond_hyper_scale, self.bond_hyper,
                                    gradient, self.matrix, self.reciprocal)

        if do_gradient:
            return result, gradient.ravel()
        else:
            return result
示例#2
0
    def __call__(self, x, do_gradient=False):
        """Compute the energy (and gradient) for a set of Cartesian coordinates

           Argument:
            | ``x``  --  the Cartesian coordinates
            | ``do_gradient``  --  when set to True, the gradient is also
                                   computed and returned. [default=False]
        """
        x = x.reshape((-1, 3))
        result = 0.0

        gradient = numpy.zeros(x.shape, float)
        if self.dm_quad > 0.0:
            result += ff_dm_quad(x, self.dm0, self.dmk, self.dm_quad,
                                 gradient, self.matrix, self.reciprocal)
        if self.dm_reci:
            result += ff_dm_reci(x, self.vdw_radii, self.dm, self.dm_reci,
                                 gradient, self.matrix, self.reciprocal)
        if self.bond_quad:
            result += ff_bond_quad(x, self.bond_edges, self.bond_lengths,
                                   self.bond_quad, gradient, self.matrix,
                                   self.reciprocal)
        if self.span_quad:
            result += ff_bond_quad(x, self.span_edges, self.span_lengths,
                                   self.span_quad, gradient, self.matrix,
                                   self.reciprocal)
        if self.bond_hyper:
            result += ff_bond_hyper(x, self.bond_edges, self.bond_lengths,
                                    self.bond_hyper_scale, self.bond_hyper,
                                    gradient, self.matrix, self.reciprocal)

        if do_gradient:
            return result, gradient.ravel()
        else:
            return result
示例#3
0
    def __call__(self, x, do_gradient=False):
        x = x.reshape((-1,3))
        result = 0.0

        gradient = numpy.zeros(x.shape, float)
        if self.dm_quad > 0.0:
            result += ff_dm_quad(x, self.dm0, self.dmk, self.dm_quad, self.unitcell, self.unitcell_reciproke, self.unitcell_active, gradient)
        if self.dm_reci:
            result += ff_dm_reci(1.0*self.vdw_radii, x, self.dm, self.dm_reci, self.unitcell, self.unitcell_reciproke, self.unitcell_active, gradient)
        if self.bond_quad:
            result += ff_bond_quad(x, self.bond_pairs, self.bond_lengths, self.bond_quad, self.unitcell, self.unitcell_reciproke, self.unitcell_active, gradient)
        if self.span_quad:
            result += ff_bond_quad(x, self.span_pairs, self.span_lengths, self.span_quad, self.unitcell, self.unitcell_reciproke, self.unitcell_active, gradient)
        if self.bond_hyper:
            result += ff_bond_hyper(x, self.bond_pairs, self.bond_lengths, 5.0, self.bond_hyper, self.unitcell, self.unitcell_reciproke, self.unitcell_active, gradient)

        if do_gradient:
            return result, gradient.ravel()
        else:
            return result