[SciPy-User] optimize.fmin_cg and optimize.fmin_bgfs optimize to 0
Pauli Virtanen
pav at iki.fi
Wed Jun 8 10:00:16 EDT 2011
Tue, 07 Jun 2011 15:23:46 -0400, Patrick Holvey wrote:
[clip]
> However, when
> I use the gradient in the optimization, all of the atom positions shoot
> right to the origin (so they're all at 0,0,0) after just 2 function
> calls and 1 gradient call, which seems very odd to me. So I tried
> fmin_bgfs with the gradient and the same thing happened. Does anyone
> have any experience with analytic gradients where this has happened to
> them? I'm confused as to whether the problem is in my gradient
> implementation or in how I'm passing the gradient or what.
Your Box.Forces(self, xyz) method modifies the input `xyz` argument.
This you should not do --- the optimizer expects that you do not alter
the current position this way.
Try replacing
vectorfield=xyz
with
vectorfield = numpy.zeros_like(xyz)
or put
xyz = xyz.copy()
in the beginning of the routine.
More information about the SciPy-User
mailing list