Commit d7e57f98 authored by Remi Perenon's avatar Remi Perenon
Browse files

Fixed complete removal of oldnumeric deps

parent e894cae8
......@@ -320,11 +320,11 @@ class GroupOfAtoms(object):
:returns: the normalizing transformation
:rtype: Scientific.Geometry.Transformation.RigidBodyTransformation
"""
from numpy.linalg.linalg import det
cm, inertia = self.centerAndMomentOfInertia()
ev, diag = inertia.diagonalization()
if det(diag.array) < 0:
diag.array[0] = -diag.array[0]
ev, diag = numpy.linalg.eig(inertia)
diag = numpy.transpose(diag)
if numpy.linalg.det(diag) < 0:
diag[0] = -diag[0]
if repr != None:
seq = numpy.argsort(ev)
if repr == 'Ir':
......@@ -339,7 +339,7 @@ class GroupOfAtoms(object):
seq[0:2] = numpy.array([seq[1], seq[0]])
elif repr != 'IIIr':
print 'unknown representation'
diag.array = numpy.take(diag.array, seq)
diag = numpy.take(diag, seq)
return Transformation.Rotation(diag)*Transformation.Translation(-cm)
def applyTransformation(self, t):
......
......@@ -203,11 +203,11 @@ class BondAngle(InternalCoordinate):
cm1, th1 = self.fragment1.centerAndMomentOfInertia()
r1 = self.universe.distanceVector(self.atoms[1], cm1)
th1 -= self.fragment1.mass()*((r1*r1)*delta-r1.dyadicProduct(r1))
i1 = axis*(th1*axis)
i1 = numpy.dot(axis, numpy.dot(th1, axis))
cm2, th2 = self.fragment2.centerAndMomentOfInertia()
r2 = self.universe.distanceVector(self.atoms[1], cm2)
th2 -= self.fragment2.mass()*((r2*r2)*delta-r2.dyadicProduct(r2))
i2 = axis*(th2*axis)
i2 = numpy.dot(axis, numpy.dot(th2, axis))
d1 = i2*d/(i1+i2)
d2 = d1-d
self.fragment1.rotateAroundAxis(self.atoms[1].position(),
......@@ -284,11 +284,11 @@ class DihedralAngle(InternalCoordinate):
cm1, th1 = self.fragment1.centerAndMomentOfInertia()
r1 = self.universe.distanceVector(self.atoms[1], cm1)
th1 -= self.fragment1.mass()*((r1*r1)*delta-r1.dyadicProduct(r1))
i1 = axis*(th1*axis)
i1 = numpy.dot(axis, numpy.dot(th1, axis))
cm2, th2 = self.fragment2.centerAndMomentOfInertia()
r2 = self.universe.distanceVector(self.atoms[2], cm2)
th2 -= self.fragment2.mass()*((r2*r2)*delta-r2.dyadicProduct(r2))
i2 = axis*(th2*axis)
i2 = numpy.dot(axis, numpy.dot(th2, axis))
d1 = i2*d/(i1+i2)
d2 = d1-d
self.fragment1.rotateAroundAxis(self.atoms[1].position(),
......
......@@ -198,7 +198,7 @@ class NormalModes(object):
# Calculate eigenvalues and eigenvectors of self.array
_symmetrize(self.array)
ev, modes = numpy.linalg.eigh(self.array, overwrite_a=True)
ev, modes = numpy.linalg.eigh(self.array)
self.array = numpy.transpose(modes)
if self.basis is not None:
......@@ -222,7 +222,7 @@ class NormalModes(object):
for i in range(nexcluded):
self.basis[i] = numpy.ravel(excluded[i].array*self.weights)
_,sv,self.basis = numpy.linalg(self.basis,False)
_,sv,self.basis = numpy.linalg.svd(self.basis,False)
svmax = numpy.maximum.reduce(sv)
nexcluded = numpy.add.reduce(numpy.greater(sv, 1.e-10*svmax))
......@@ -230,7 +230,7 @@ class NormalModes(object):
for i in range(nmodes):
self.basis[i+nexcluded] = numpy.ravel(basis[i].array*self.weights)
_,sv,self.basis = numpy.linalg(self.basis,False)
_,sv,self.basis = numpy.linalg.svd(self.basis,False)
svmax = numpy.maximum.reduce(sv)
ntotal = numpy.add.reduce(numpy.greater(sv, 1.e-10*svmax))
......@@ -244,7 +244,7 @@ class NormalModes(object):
numpy.multiply(self.basis, self.weights, self.basis)
self.basis.shape = (nmodes, 3*natoms)
_,sv,self.basis = numpy.linalg(self.basis,False)
_,sv,self.basis = numpy.linalg.svd(self.basis,False)
svmax = numpy.maximum.reduce(sv)
nmodes = numpy.add.reduce(numpy.greater(sv, 1.e-10*svmax))
......
......@@ -113,7 +113,11 @@ def randomVelocity(temperature, mass):
:rtype: Scientific.Geometry.Vector
"""
sigma = numpy.sqrt((temperature*Units.k_B)/(mass*Units.amu))
return Vector(numpy.random.normal(0., sigma, (3,)))
# Handle zero sigma case
if sigma == 0.0:
return Vector(numpy.array([0,0,0]))
else:
return Vector(numpy.random.normal(0., sigma, (3,)))
#
# Random ParticleVector (gaussian)
......
......@@ -265,7 +265,7 @@ class Trajectory(object):
else:
return var[:]
else:
return numpy.ravel(numpy.array(var))[:len(self)]
return numpy.ravel(numpy.array(var[:]))[:len(self)]
def defaultStep(self):
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment