From 72020374ec343a1ce483de3ec5215ba34ab6a7c5 Mon Sep 17 00:00:00 2001 From: Sven Rogge Date: Sat, 13 Feb 2016 19:58:15 +0100 Subject: [PATCH] Removed vtens_parts and gpos_parts --- yaff/pes/ext.pyx | 16 ++++++++-------- yaff/pes/ff.py | 20 +------------------- yaff/pes/generator.py | 2 +- yaff/pes/test/test_generator.py | 10 +++++----- yaff/sampling/verlet.py | 3 --- 5 files changed, 15 insertions(+), 36 deletions(-) diff --git a/yaff/pes/ext.pyx b/yaff/pes/ext.pyx index 6c2bf1fd..dd0a561c 100644 --- a/yaff/pes/ext.pyx +++ b/yaff/pes/ext.pyx @@ -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', ] @@ -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] diff --git a/yaff/pes/ff.py b/yaff/pes/ff.py index e44fced4..5c095d1c 100644 --- a/yaff/pes/ff.py +++ b/yaff/pes/ff.py @@ -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.' % ( @@ -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): @@ -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 diff --git a/yaff/pes/generator.py b/yaff/pes/generator.py index ce88b2f5..58be9ca1 100644 --- a/yaff/pes/generator.py +++ b/yaff/pes/generator.py @@ -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] diff --git a/yaff/pes/test/test_generator.py b/yaff/pes/test/test_generator.py index e1f6a93b..61cc7bc7 100644 --- a/yaff/pes/test/test_generator.py +++ b/yaff/pes/test/test_generator.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/yaff/sampling/verlet.py b/yaff/sampling/verlet.py index 63b81504..65b00b64 100644 --- a/yaff/sampling/verlet.py +++ b/yaff/sampling/verlet.py @@ -69,7 +69,6 @@ class VerletIntegrator(Iterative): AttributeStateItem('cons_err'), AttributeStateItem('ptens'), AttributeStateItem('vtens'), - AttributeStateItem('vtens_parts'), AttributeStateItem('press'), DipoleStateItem(), DipoleVelStateItem(), @@ -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: