You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thanks for this nice library. I encountered an issue that seems related to #127. Please see the reproducer below:
Everything was tested on Python 3.12.1 and trexio==2.4.2.
It mimics the reading & writing of information from an unrestricted calculation done on 2 atoms with a total of 2 AOs and 2 alpha MOs Ca and 2 beta MOs Cb.
frompathlibimportPathimportnumpyasnpimporttrexionp.set_printoptions(suppress=True, precision=4, linewidth=180)
nucleus_num=2ao_num=2fn=Path("issue.h5")
iffn.exists():
fn.unlink()
tf=trexio.File(str(fn), mode="w", back_end=trexio.TREXIO_HDF5)
# Write filecoords3d=np.zeros((2, 3))
coords3d[1, 2] =1.889trexio.write_nucleus_num(tf, nucleus_num)
trexio.write_nucleus_coord(tf, coords3d)
mo_num=ao_numCa=np.random.rand(ao_num, mo_num)
Cb=np.random.rand(ao_num, mo_num)
# Mos are in columns; C.shape is (num_ao, 2*num_ao)# Concatenate alpha and beta MOsC=np.concatenate((Ca, Cb), axis=1)
mo_spin= ([0] *mo_num) + ([1] *mo_num)
mo_num=C.shape[1]
trexio.write_ao_num(tf, ao_num)
trexio.write_mo_num(tf, mo_num)
trexio.write_mo_coefficient(tf, C)
trexio.write_mo_spin(tf, mo_spin)
tf.close()
# Read againwithtrexio.File(str(fn), mode="r", back_end=trexio.TREXIO_HDF5) astf:
coords3d_read=trexio.read_nucleus_coord(tf)
# coords3d is finenp.testing.assert_allclose(coords3d, coords3d_read)
C_read=trexio.read_mo_coefficient(tf)
# C_read is mangled ...np.testing.assert_allclose(C, C_read)
When the MO-coefficients are stored with the shape outlined in the paper/documentation (ao_num, mo_num) the coefficients get mangled, when read again.
When I build the matrix C with shape (mo_num, ao_num) and store it, then everything is fine, but then C is also read again this shape, which seems not consistent with the documentation.
On the contrary, the 3d Cartesian coordinates seem fine; nothing gets transposed. So it is not like that I have to provide the data with column-major order initially.
So, did I misuse the API or is this a bug/documentation issue?
All the best
Johannes
The text was updated successfully, but these errors were encountered:
Hello,
I think that you are confused by the column-major ordering :-)
In the documentation, the nuclear coordinates are:
coord float (3,nucleus.num) Coordinates of the atoms
So in Python, if you use the default ordering (row major), you are supposed to make a numpy array of shape (nucleus_num, 3). This is indeed what you do:
coords3d = np.zeros((2, 3))
and everything is fine.
For the MO coefficients, the documentation states that it is:
coefficient float (ao.num, mo.num)
So in Python, you should use a numpy array of shape (mo_num, ao_num) where mo_num = 2*ao_num in your particular case. But your MO coefficients array in Python has shape (ao_num, mo_num), which is wrong.
Thanks for giving feedback. As you are the 2nd person getting confused with this, we will try to make things clearer in the documentation.
Thanks for getting back to me so quickly. I seem to have misread the shape of the coordinate array ... Good to know the library is fine and that the error is on my side.
Dear developers,
thanks for this nice library. I encountered an issue that seems related to #127. Please see the reproducer below:
Everything was tested on
Python 3.12.1
andtrexio==2.4.2
.It mimics the reading & writing of information from an unrestricted calculation done on 2 atoms with a total of 2 AOs and 2 alpha MOs
Ca
and 2 beta MOsCb
.When the MO-coefficients are stored with the shape outlined in the paper/documentation
(ao_num, mo_num)
the coefficients get mangled, when read again.When I build the matrix C with shape (mo_num, ao_num) and store it, then everything is fine, but then
C
is also read again this shape, which seems not consistent with the documentation.On the contrary, the 3d Cartesian coordinates seem fine; nothing gets transposed. So it is not like that I have to provide the data with column-major order initially.
So, did I misuse the API or is this a bug/documentation issue?
All the best
Johannes
The text was updated successfully, but these errors were encountered: