-
Notifications
You must be signed in to change notification settings - Fork 33
Enforce C contiguous array order for NumPy array #49
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
While using xtb-python together with PySCF, I noticed a strange behaviour. Different energies would be obtained whether I got the coordinates from the PySCF Mole object or read them myself from an xyz file. I think the problem here is that PySCF uses F contiguous arrays, while xtb-python expects C contiguous. The problem is fixed by changing the order with np.ascontiguousarray. I guess that ideally this check + conversion should be done on the xib-python side.
mol = gto.Mole(verbose=0, basis="def2svp").fromfile("xtbopt.xyz", format="xyz")
elements = mol.atom_charges()
coordinates = mol.atom_coords()coordinates.flags
C_CONTIGUOUS : False
F_CONTIGUOUS : True
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False
calc_r = Calculator(get_method("GFNFF"), elements, coordinates)
results = calc_r.singlepoint()
results.get_energy()5.134599834832412
coordinates = np.ascontiguousarray(mol.atom_coords())
coordinates.flags C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
UPDATEIFCOPY : False
calc_r = Calculator(get_method("GFNFF"), elements, coordinates)
results = calc_r.singlepoint()
results.get_energy()-4.0651143277974615
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working