jparkhill / TensorMol

Tensorflow + Molecules = TensorMol
http://blogs.nd.edu/parkhillgroup
GNU General Public License v3.0
271 stars 75 forks source link

bug in Periodic.py? #34

Open mkrompiec opened 5 years ago

mkrompiec commented 5 years ago

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_aRc"], 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) (kJ/mol): %.5f <|a|>(m/s2): %.5f (Eh): %.5f (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.EPotKJPERHARTREE,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 commented 5 years ago

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