TensorMol icon indicating copy to clipboard operation
TensorMol copied to clipboard

bug in Periodic.py?

Open mkrompiec opened this issue 7 years ago • 1 comments

I'm trying to run an MD simulation in PBC, using ChemSpider-trained network:

def EnAndForce(z_, x_, nreal_, DoForce = True): mtmp = Mol(z_,x_) en,f = manager.EvalBPDirectEEUpdateSinglePeriodic(mtmp, PARAMS["AN1_r_Rc"], PARAMS["AN1_a_Rc"], PARAMS["EECutoffOff"], nreal_,True) return en[0], f[0]

lat=Lattice(np.eye(3)*70) # 70 angstrom box m.properties["Lattice"]=lat PARAMS["MDThermostat"] = "Nose" PARAMS["MDTemp"] = 300 PARAMS["MDdt"] = 0.1 # fs PARAMS["RemoveInvariant"]=True PARAMS["MDV0"] = "Random" PARAMS["MDMaxStep"] = 10000 PF = PeriodicForce(m,np.eye(3)*70) #m.properties["Lattice"]) PF.BindForce(EnAndForce, 70.0) PARAMS["MDTemp"] = 300.0 PARAMS["MDdt"] = 0.05 # In fs. traj = PeriodicVelocityVerlet(PF,"sim_300K") traj.Prop()

Traceback (most recent call last): File "runmd.py", line 79, in traj.Prop() File "/mainfs/scratch/mk1a18/TensorMol/TensorMol/Simulations/PeriodicMD.py", line 144, in Prop LOGGER.info("Step: %i time: %.1f(fs) <KE>(kJ/mol): %.5f <|a|>(m/s2): %.5f <EPot>(Eh): %.5f <Etot>(kJ/mol): %.5f Rho(g/cm**3): %.5f Teff(K): %.5f", step, self.t, self.KE/1000.0, np.linalg.norm(self.a) , self.EPot, self.KE/1000.0+self.EPot*KJPERHARTREE,self.Density(), Teff) File "/mainfs/scratch/mk1a18/TensorMol/TensorMol/Simulations/PeriodicMD.py", line 106, in Density return self.PForce.Density() File "/mainfs/scratch/mk1a18/TensorMol/TensorMol/ForceModifiers/Periodic.py", line 309, in Density m = np.array(map(lambda x: ATOMICMASSES[x-1], self.mol0.atoms))*1000.0 TypeError: unsupported operand type(s) for *: 'map' and 'float'

mkrompiec avatar Jul 06 '18 12:07 mkrompiec

I think this is a Python 2->3 bug. I changed line 309 in Periodic.py: m = np.array(map(lambda x: ATOMICMASSES[x-1], self.mol0.atoms))*1000.0 to: m = np.array(list(map(lambda x: ATOMICMASSES[x-1], self.mol0.atoms)))*1000.0 and it seems to be working

mkrompiec avatar Jul 06 '18 12:07 mkrompiec