arm61 / pylj

Teaching Utility for Classical Atomistic Simulation.
https://pythoninchemistry.org/pylj
MIT License
29 stars 21 forks source link

Buckingham energy/force don't work for arrays #46

Closed sansona closed 5 years ago

sansona commented 5 years ago

In writing tests, I discovered that the Buckingham forcefield functions run into a TypeError if the dr input is not a single float (i.e [dr] or for an array of different values).

Here's the error that comes up: TypeError: can't multiply sequence by non-int of type 'float'

arm61 commented 5 years ago

Interesting @symmy596 wrote the Buckingham potential stuff but I cannot see anything that should give this error. Can you provide the code for the test

sansona commented 5 years ago

The test I wrote was for under test_buckingham_energy:

b = forcefields.buckingham([2.0], [1.0, 1.0, 1.0])

This should be equivalent to the test already there, but it raises a TypeError. Same thing is Dr is an array of different length - [2.0, 2.0]. It seems something isn't working when dr is an array

On Wed, May 8, 2019, 04:58 Andrew McCluskey notifications@github.com wrote:

Interesting @symmy596 https://github.com/symmy596 wrote the Buckingham potential stuff but I cannot see anything that should give this error. Can you provide the code for the test

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arm61/pylj/issues/46#issuecomment-490457712, or mute the thread https://github.com/notifications/unsubscribe-auth/AEHPG26ES5NR724OULQ3J43PUK57XANCNFSM4HLNVF3Q .

arm61 commented 5 years ago

As mentioned on https://github.com/arm61/pylj/pull/47 the object being passed is a list but the function expects either floats or np.ndarray objects (it has been a while since I looked at this code in detail so I could be mistaken)

arm61 commented 5 years ago

Resolved in #47 and #48