Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Jul 17, 2017
1 parent 1dd9619 commit 1a03b44
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion moldesign/_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,6 @@ def generate_grid(g, g2=None):
ranges = np.ones((3, 2))*5.0*width
ranges[:, 0] *= -1
ranges += ((g.center + g2.center)/2.0)[:, None]
grid = mathutils.VolumetricGrid(*ranges, 64)
grid = mathutils.VolumetricGrid(*ranges, npoints=64)
allpoints = grid.allpoints()
return allpoints, grid
2 changes: 1 addition & 1 deletion moldesign/_tests/test_gaussian_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _make_rando_linear_combination(withunits=True):
moldesign.orbitals.CartesianGaussian(
center=center,
powers=pwr,
alpha=10.0 * random.random()/(length**2),
alpha=(10.0 * (random.random()+3))/(length**2),
coeff=1/(np.sqrt(3.0))))
lc = moldesign.orbitals.PrimitiveSum(gaussians)
lc.ndims = 3 # so it works with the test suite
Expand Down
15 changes: 8 additions & 7 deletions moldesign/mathutils/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ class VolumetricGrid(object):
xrange (Tuple[len=2]): (min,max) in x direction
yrange (Tuple[len=2]): (min,max) in y direction
zrange (Tuple[len=2]): (min,max) in z direction
xpoints (int): number of grid lines in x direction (default: 25)
ypoints (int): number of grid lines in y direction (default: xpoints)
zpoints (int): number of grid lines in z direction (default: xpoints)
npoints (int): default number of grid lines in each direction (default: 32)
xpoints (int): number of grid lines in x direction (default: npoints)
ypoints (int): number of grid lines in y direction (default: npoints)
zpoints (int): number of grid lines in z direction (default: npoints)
"""
dx, dy, dz = (utils.IndexView('deltas', i) for i in range(3))
xr, yr, zr = (utils.IndexView('ranges', i) for i in range(3))
xpoints, ypoints, zpoints = (utils.IndexView('points', i) for i in range(3))
xspace, yspace, zspace = (utils.IndexView('spaces', i) for i in range(3))

def __init__(self, xrange, yrange, zrange,
xpoints=32, ypoints=None, zpoints=None):
npoints=32, xpoints=None, ypoints=None, zpoints=None):

self.points = np.array([xpoints,
ypoints if ypoints is not None else xpoints,
zpoints if zpoints is not None else xpoints],
self.points = np.array([xpoints if xpoints is not None else npoints,
ypoints if ypoints is not None else npoints,
zpoints if zpoints is not None else npoints],
dtype='int')

self.ranges = u.array([xrange, yrange, zrange])
Expand Down
1 change: 0 additions & 1 deletion moldesign/models/pyscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ def _get_ao_basis_functions(self):
assert l == angular
# Note: this is for metadata only, should not be used in any calculations
n = int(''.join(x for x in label[2] if x.isdigit()))

primitives = [orbitals.SphericalGaussian(atom.position.copy(),
exp, l, m,
coeff=coeff[ictr],
Expand Down
2 changes: 1 addition & 1 deletion moldesign/orbitals/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, center, alpha, powers, coeff=None, normalized=True):
def __repr__(self):
return ("<{ndim}-D cartesian gaussian (norm: {norm:4.2f}, "
"cartesian powers: {powers}, "
"width: {exp:4.2f}, "
"alpha: {exp:4.2f}, "
"center: {center}>").format(
ndim=self.ndim,
center=self.center, exp=self.alpha,
Expand Down
4 changes: 2 additions & 2 deletions moldesign/orbitals/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(self, center, alpha, l, m, coeff=None, normalized=True):

def __repr__(self):
return ("<3D Gaussian (Spherical) (coeff: {coeff:4.2f}, "
"width: {alpha:4.2f}, "
"(l,m) = {qnums}").format(
"alpha: {alpha:4.2f}, "
"(l,m) = {qnums}>").format(
center=self.center, alpha=self.alpha, coeff=self.coeff,
qnums=(self.l, self.m))

Expand Down
4 changes: 3 additions & 1 deletion moldesign/orbitals/wfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def align_orbital_phases(self, other, assert_same=True):
"""
for orbtype in self.orbitals:
if orbtype not in other.orbitals:
if assert_same: assert False, '%s has orbital type %s, but %s does not.' % (self, orbtype, other)
if assert_same:
assert False, '%s has orbital type %s, but %s does not.' % (
self, orbtype, other)
else: continue
self.orbitals[orbtype].align_phases(other.orbitals[orbtype])

Expand Down

0 comments on commit 1a03b44

Please sign in to comment.