Skip to content

Commit

Permalink
Removed vtens_parts and gpos_parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Rogge authored and Sven Rogge committed Feb 13, 2016
1 parent 332ef1f commit 7202037
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
16 changes: 8 additions & 8 deletions yaff/pes/ext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ from yaff.log import log
__all__ = [
'Cell', 'nlist_status_init', 'nlist_build', 'nlist_status_finish',
'nlist_recompute', 'nlist_inc_r', 'Hammer', 'Switch3', 'PairPot',
'PairPotLJ', 'PairPotMM3', 'PairPotGrimme', 'PairPotExpRep',
'PairPotQMDFFRep', 'PairPotLJCross', 'PairPotDampDisp',
'PairPotDisp68BJDamp', 'PairPotEI', 'PairPotEIDip',
'PairPotEiSlater1s1sCorr', 'PairPotEiSlater1sp1spCorr',
'PairPotOlpSlater1s1s','PairPotChargeTransferSlater1s1s',
'compute_ewald_reci', 'compute_ewald_reci_dd', 'compute_ewald_corr_dd',
'compute_ewald_corr', 'dlist_forward', 'dlist_back', 'iclist_forward',
'PairPotLJ', 'PairPotMM3', 'PairPotGrimme', 'PairPotExpRep',
'PairPotQMDFFRep', 'PairPotLJCross', 'PairPotDampDisp',
'PairPotDisp68BJDamp', 'PairPotEI', 'PairPotEIDip',
'PairPotEiSlater1s1sCorr', 'PairPotEiSlater1sp1spCorr',
'PairPotOlpSlater1s1s','PairPotChargeTransferSlater1s1s',
'compute_ewald_reci', 'compute_ewald_reci_dd', 'compute_ewald_corr_dd',
'compute_ewald_corr', 'dlist_forward', 'dlist_back', 'iclist_forward',
'iclist_back', 'vlist_forward', 'vlist_back', 'compute_grid3d',
]

Expand Down Expand Up @@ -1606,7 +1606,7 @@ cdef class PairPotDisp68BJDamp(PairPot):
return pair_pot.pair_data_disp68bjdamp_get_bj_b(self._c_pair_pot)

bj_b = property(_get_bj_b)

def _get_global_pars(self):
'''Global parameters'''
return [self.c6_scale,self.c8_scale,self.bj_a,self.bj_b]
Expand Down
20 changes: 1 addition & 19 deletions yaff/pes/ff.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ def __init__(self, system, parts, nlist=None):
self.needs_nlist_update = nlist is not None
for part in parts:
self.add_part(part)
self.gpos_parts = np.zeros((len(parts), system.pos.shape[0], system.pos.shape[1]), float)
self.vtens_parts = np.zeros((len(parts), 3, 3), float)
if log.do_medium:
with log.section('FFINIT'):
log('Force field with %i parts:&%s.' % (
Expand All @@ -208,14 +206,6 @@ def add_part(self, part):
if name in self.__dict__:
raise ValueError('The part %s occurs twice in the force field.' % name)
self.__dict__[name] = part
# Extend the matrices containing the gpos and vtens parts
gpos_parts_new = np.zeros((len(self.parts), self.system.pos.shape[0], self.system.pos.shape[1]), float)
vtens_parts_new = np.zeros((len(self.parts), 3, 3), float)
for i in xrange(len(self.parts)-1):
gpos_parts_new[i,:,:] = self.gpos_parts[i,:,:]
vtens_parts_new[i,:,:] = self.vtens_parts[i,:,:]
self.gpos_parts = gpos_parts_new.copy()
self.vtens_parts = vtens_parts_new.copy()

@classmethod
def generate(cls, system, parameters, **kwargs):
Expand Down Expand Up @@ -272,15 +262,7 @@ def _internal_compute(self, gpos, vtens):
if self.needs_nlist_update:
self.nlist.update()
self.needs_nlist_update = False
self.gpos_parts[:] = 0.0
self.vtens_parts[:] = 0.0
result = 0.0
for i, part in enumerate(self.parts):
result += part.compute(self.gpos_parts[i,:,:], self.vtens_parts[i,:,:])
if gpos is not None:
gpos[:] = np.sum(self.gpos_parts, axis=0)
if vtens is not None:
vtens[:] = np.sum(self.vtens_parts, axis=0)
result = sum([part.compute(gpos, vtens) for part in self.parts])
return result


Expand Down
2 changes: 1 addition & 1 deletion yaff/pes/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def process_pars(self, pardef, conversions, nffatype, par_info=None):
'''
tmp = Generator.process_pars(self, pardef, conversions, nffatype, par_info=par_info)
par_table = {}

for key, oldpars in tmp.iteritems():
K = oldpars[0][0]
r0 = oldpars[0][1]
Expand Down
10 changes: 5 additions & 5 deletions yaff/pes/test/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def test_generator_water32_d3bj():
c8HH = 5.74321564987e+00
c8HO = 5.01673173654e+00
c8OO = 3.13071058512e+00

c6_cross = d3bj.pair_pot.c6_cross
assert c6_cross.shape == (2,2)
assert abs(c6_cross[0,0] - c6HH) < 1e-10
Expand All @@ -536,7 +536,7 @@ def test_generator_water32_d3bj():
assert abs(gps[1] - 2.0) < 1e-10
assert abs(gps[2] - 3.0) < 1e-10
assert abs(gps[3] - 4.0) < 1e-10

R_cross = d3bj.pair_pot.R_cross
assert R_cross.shape == (2,2)
assert abs(R_cross[0,0] - np.sqrt(c8HH/c6HH)) < 1e-10
Expand All @@ -552,7 +552,7 @@ def test_generator_water32_qmdffrep():
ff = ForceField.generate(system, fn_pars)
assert len(ff.parts) == 1
qmdffrep = ff.part_pair_qmdffrep
# check parameters
# check parameters
A_cross = qmdffrep.pair_pot.amp_cross
assert A_cross.shape == (2,2)
print A_cross
Expand All @@ -567,8 +567,8 @@ def test_generator_water32_qmdffrep():
assert abs(B_cross[0,1] - 5.00924416592e+00) < 1e-10
assert abs(B_cross[1,0] - 5.00924416592e+00) < 1e-10
assert abs(B_cross[1,1] - 6.34212100945e+00) < 1e-10
# check scalings

# check scalings
scalings = qmdffrep.scalings
assert abs(scalings.scale1 - 0.0) < 1e-10
assert abs(scalings.scale2 - 0.0) < 1e-10
Expand Down
3 changes: 0 additions & 3 deletions yaff/sampling/verlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class VerletIntegrator(Iterative):
AttributeStateItem('cons_err'),
AttributeStateItem('ptens'),
AttributeStateItem('vtens'),
AttributeStateItem('vtens_parts'),
AttributeStateItem('press'),
DipoleStateItem(),
DipoleVelStateItem(),
Expand Down Expand Up @@ -375,8 +374,6 @@ def compute_properties(self, restart_h5=None):
for hook in self.hooks:
if isinstance(hook, VerletHook):
self.econs += hook.econs_correction
self.gpos_parts = self.ff.gpos_parts
self.vtens_parts = self.ff.vtens_parts
if restart_h5 is not None:
self.econs = restart_h5['trajectory/econs'][-1]
else:
Expand Down

0 comments on commit 7202037

Please sign in to comment.