-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN energy when calling Atomistica potentials via ASE #48
Comments
Here's a slightly simpler but equivalent example: using PyCall
using JuLIP
@pyimport atomistica
@pyimport ase
atoms = ASEAtoms(ASE.ase_io.read("atoms_broken_relaxed.xyz"))
calc = ASECalculator(atomistica.TersoffScr())
set_calculator!(atoms, calc)
set_constraint!(atoms, FixedCell(atoms))
println(energy(atoms))
set_positions!(atoms, positions(atoms))
println(energy(atoms)) |
Changing the definition of positions(at::ASEAtoms) = copy( pyarrayref(at.po["positions"]) ) |> vecs to positions(at::ASEAtoms) = at.po[:get_positions]()' |> vecs appears to solve this problem. I don't fully understand why, but since a copy is made in either case, avoiding the |
The fix makes 2 copies. Ok to make sure t works but we should find the bug. |
Yes, I just realised that. I'll try with |
I'm homing in on the problem. If |
The plot thickens... I finally understand why this happens when reading from an .xyz file but not when creating structures with |
very interesting. |
There is this issue, which discusses a |
I think it's just a bug in the ASE XYZ reader: I assemble the columns using |
thats fine for me if there is a guarantee that ASE will always use the memory layout we assume now? It just never occurred to before that it might not, but now I am worried. |
I think it should always be in C order, but the problem is that from Python you often don't notice if the memory is in C or Fortran order since numpy abstracts it completely, unless you look very carefully (or notice slow downs). |
If we are worried we could actually check the flags of the numpy array before doing the |
this is my point - can we guarantee that ASE will always have positions stored in C order? If not then we need to check before we import them into JuLIP. |
right, that's what I meant. And maybe for the time being, if positions are stored in F order then let |
Probably |
Ok then let's raise an error for now and switch it to TransposeMatrix once it exists.
C
…Sent from my iPhone
On 16 Feb 2017, at 21:16, James Kermode <notifications@github.com<mailto:notifications@github.com>> wrote:
Probably unsafe_positions should raise an error rather than returning a copy, otherwise you might be expecting to be able to modify in place. But positions() should be made to return a copy in correct memory layout.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#48 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AHVRQwohJLes_AGbzQnlK1gVSOCRiLF-ks5rdLy6gaJpZM4MDSZe>.
|
I guess this will be fixed once we create a pure Julia Atoms. |
closing for now - we can reopen if it comes up again |
The following script demonstrates the error. We tracked it down as far as
set_position_dofs!()
.atoms_broken_relaxed.xyz.txt
Results are:
i.e. second call to
energy(atoms, dofs(atoms))
gives a NaN result.The text was updated successfully, but these errors were encountered: