Closed joaander closed 2 years ago
I'm interested in contributing to this.
In connection with #398 a new table potential API might expose a property that provides a proxy interface to the tables. Tables would be stored on the C++ side and exposed to python as numpy arrays.
When this gets revisited, I wanted to note that there is a small bug in set_from_file
, where the file handle is opened without an explicit call to close. This handle is sometimes not closed correctly. Opening the file as a context should fix this.
Thanks for pointing that out. It isn't documented here but the plan will be to offer numpy array access to table data. I would expect to remove the set_from_file and functional evaluation syntactic sugar and let the user use standard python tools to read or evaluate table data in whatever form they choose (HDF5 file, text file, sympy expression, etc..)
That's even better! We are currently wrapping hoomd in some software that will support multiple simulation packages. Our pair potentials are callable objects that we have already tabulated, so it would be great if we could just set the table values directly. We started by dumping to disk & reading back in, then we caught this warning about the file handle from a unittest, so now we're bypassing the file and wrapping the tables in interpolating functions (like what set_from_file
is doing anyway). It'd be great to skip all that.
As an aside, would it also be possible to support tables with different widths per pair? Maybe by aligning the internal memory to the largest table or by allocating each table separately? It's nice that each pair can have a different rmin / rmax, but the constant table width means that you can't hold the spacing dr constant if rmin and rmax are not the same.
@mphoward #965 enables different widths per type pair in the v3 API for pair potentials. The PR is awaiting final review from @b-butler and then it will be merged.
We haven't currently started work on table potentials for bonds, angles, or dihedrals. We could implement the same features and follow the implementation in #965 but only if we complete #490 first. Given the complexity of this work and that I'd like to get a 3.0.0 release complete sooner rather than laster, we may defer this work for a future 3.x release.
Great! This looks like it will work nicely. I agree that #490 should be done before porting the other types of potentials, but this would be a decent amount of work.
Bond, angle, and dihedral potentials are not commonly used or requested. In the interests of completing 3.0.0 soon, I am deferring their implementation to a future 3.x release.
HOOMD's tabulated potential implementation and API are being very widely used. Their implementation, and Python API in particular, could use a thorough review and be improved if possible.