m3g / packmol

Packmol - Initial configurations for molecular dynamics simulations
http://m3g.github.io/packmol
MIT License
214 stars 48 forks source link

Is there any plan to bind packmol with python? #52

Closed Roy-Kid closed 11 months ago

Roy-Kid commented 1 year ago

Hi, I want to ask is there any plan to bind packmol with python. It will be very useful in the workflow~

lmiq commented 1 year ago

No, not really. Bind in what sense? There are quite a few python packages that call packmol already.

Roy-Kid commented 1 year ago

My point is, I can directly pass molecules' position in numpy to packmol and get the optimized data back. So i can avoid to convert the model to pdb format.

I am trying to bind it with f2py. I want to bind those methods in src and invoke them by rewriting packmol.f90 in python. But I'm having some difficulty, maybe jacobi.f90 is written with the syntax of f77? I am not sure as well

By the way, which package have wrapped the packmol. I have searched it in github and found no one.

lmiq commented 1 year ago

I'm not a python user, so I cannot tell how useful are these packages, but from googling a bit I found:

https://pypi.org/project/packmol-step/

https://github.com/MDAnalysis/MDAPackmol

https://github.com/virtualzx-nad/pypackmol

The gencan.f source is a fortran77-style file. The jacobi.f90 is a literal translation of an old routine to Fortran90 but yes, it is pretty old.

I'm not sure how hard is to wrap packmol to be called directly using numpy arrays, I guess that's not very easy, because there are quite a few auxiliary arrays that need to be allocated to make packmol work, and the package is not structured in a very modular fashion.

That said, currently I am developing a new version of Packmol in Julia (https:://github.com/m3g/Packmol.jl) which will be more modular and easy to interface with numpy as you suggest (it will be also faster, parallel, and more flexible). But that's still in early development, it is probably something for the mid-next year.

lmiq commented 1 year ago

In summary: I don't have any plan to bind packmol with python, at least not this version of Packmol. But if you are willing to work on that, I'm happy to help if possible.