简体   繁体   中英

TypeError:unsupported operand type(s) for -: 'str' and 'int'

I want to convert pmma85compositedata.initeq to a acceptable data file for lammps but I face with this error:

import lmpsdata, copy
data=lmpsdata.Lmpsdata('pmma85compositedata.initeq','full')
polymer=lmpsdata.molecules(data,1,19,'atom') #'atom
nanoparticle=lmpsdata.molecules(data,20,20,'atom')
surface=lmpsdata.particlesurface(nanoparticle[0], 1.94, 8,'full')

Error:

polymer=lmpsdata.molecules(data,1,19,'atom') #'atom
File "/home/marham/...../lmpsdata.py", line 1193, in molecules
p=Pool(processors)
File "/usr/lib/python2.7/multiprocessing/__init__.py", line 232, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 159, in __init__
self._repopulate_pool()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 214, in        _repopulate_pool
for i in range(self._processes - len(self._pool)):
TypeError: unsupported operand type(s) for -: 'str' and 'int'

Looking at the source code for the lmpsdata.molecules() function, you are missing a parameter: the number of processors in the pool. Try:

polymer = lmpsdata.molecules(data, 1, 19, 8, 'atom')
nanoparticle = lmpsdata.molecules(data, 20, 20, 8, 'atom')

...or replace 8 with however many processors you have at your disposal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM