1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-04-25 09:54:44 +02:00

Add UHF possibility (#96)

This commit is contained in:
Anthony Scemama 2022-07-04 14:35:24 +02:00 committed by GitHub
parent 2b20776615
commit a8c3619655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 145 additions and 98 deletions

View File

@ -6,6 +6,7 @@ CHANGES
- Added `trexio_has_group` functionality
- Added OCaml binding
- Added spin and energy in MOs
2.2
---

View File

@ -63,6 +63,8 @@ subroutine test_write(file_name, back_end)
character(len=:), allocatable :: sym_str
character(len=:), allocatable :: label(:)
double precision, allocatable :: energy(:)
integer , allocatable :: spin(:)
! sparse data
integer(4) :: index_sparse_ao_2e_int_eri(4,100)
@ -183,6 +185,23 @@ subroutine test_write(file_name, back_end)
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE MO NUM')
endif
allocate(energy(mo_num))
do i=1,mo_num
energy(i) = dble(i)-100.d0
enddo
rc = trexio_write_mo_energy(trex_file, energy)
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE ENERGY')
deallocate(energy)
allocate(spin(mo_num))
spin(:) = 0
do i=mo_num/2+1,mo_num
spin(i) = 1
enddo
rc = trexio_write_mo_spin(trex_file, spin)
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE SPIN')
deallocate(spin)
offset = 0
do i = 1,n_buffers
@ -252,6 +271,9 @@ subroutine test_read(file_name, back_end)
character(len=4) :: label(12) ! also works with allocatable arrays
character(len=32) :: sym_str
integer :: mo_num
double precision, allocatable :: energy(:)
integer , allocatable :: spin(:)
! sparse data
integer(4) :: index_sparse_ao_2e_int_eri(4,20)
@ -455,6 +477,26 @@ subroutine test_read(file_name, back_end)
call exit(-1)
endif
rc = trexio_read_mo_num(trex_file, mo_num)
call trexio_assert(rc, TREXIO_SUCCESS)
allocate(spin(mo_num), energy(mo_num))
rc = trexio_read_mo_energy(trex_file, energy)
call trexio_assert(rc, TREXIO_SUCCESS)
if (energy(10) /= -90.d0) then
print *, 'Failure to read MO energy: ', energy(10)
call exit(-1)
end if
rc = trexio_read_mo_spin(trex_file, spin)
call trexio_assert(rc, TREXIO_SUCCESS)
if (sum(spin) /= mo_num/2) then
print *, 'Failure to read MO spin', mo_num, sum(spin)
call exit(-1)
end if
! close the file
rc = trexio_close(trex_file)
call trexio_assert(rc, TREXIO_SUCCESS)

View File

@ -70,7 +70,7 @@ means that the source code is not produced by the generator, but hand-written.
#+CALL: json(data=metadata, title="metadata")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"metadata": {
"code_num" : [ "dim", [] ]
@ -82,7 +82,7 @@ means that the source code is not produced by the generator, but hand-written.
, "unsafe" : [ "int", [] ]
} ,
#+end_src
:END:
:end:
* Electron (electron group)
@ -197,7 +197,7 @@ If you encounter the aforementioned issue, please report it to our [[https://git
#+CALL: json(data=ecp, title="ecp")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"ecp": {
"max_ang_mom_plus_1" : [ "int" , [ "nucleus.num" ] ]
@ -210,7 +210,7 @@ If you encounter the aforementioned issue, please report it to our [[https://git
, "power" : [ "int" , [ "ecp.num" ] ]
} ,
#+end_src
:END:
:end:
** Example
@ -324,7 +324,7 @@ power = [
#+CALL: json(data=basis, title="basis")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"basis": {
"type" : [ "str" , [] ]
@ -339,7 +339,7 @@ power = [
, "prim_factor" : [ "float", [ "basis.prim_num" ] ]
} ,
#+end_src
:END:
:end:
** Example
@ -470,7 +470,7 @@ prim_factor =
#+CALL: json(data=ao, title="ao")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"ao": {
"cartesian" : [ "int" , [] ]
@ -479,7 +479,7 @@ prim_factor =
, "normalization" : [ "float", [ "ao.num" ] ]
} ,
#+end_src
:END:
:end:
** One-electron integrals (~ao_1e_int~ group)
:PROPERTIES:
@ -514,7 +514,7 @@ prim_factor =
#+CALL: json(data=ao_1e_int, title="ao_1e_int")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"ao_1e_int": {
"overlap" : [ "float", [ "ao.num", "ao.num" ] ]
@ -529,7 +529,7 @@ prim_factor =
, "core_hamiltonian_im" : [ "float", [ "ao.num", "ao.num" ] ]
} ,
#+end_src
:END:
:end:
** Two-electron integrals (~ao_2e_int~ group)
:PROPERTIES:
@ -581,11 +581,13 @@ prim_factor =
| ~class~ | ~str~ | ~(mo.num)~ | Choose among: Core, Inactive, Active, Virtual, Deleted |
| ~symmetry~ | ~str~ | ~(mo.num)~ | Symmetry in the point group |
| ~occupation~ | ~float~ | ~(mo.num)~ | Occupation number |
| ~energy~ | ~float~ | ~(mo.num)~ | For canonical MOs, corresponding eigenvalue |
| ~spin~ | ~int~ | ~(mo.num)~ | For UHF wave functions, 0 is $\alpha$ and 1 is $\beta$ |
#+CALL: json(data=mo, title="mo")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"mo": {
"type" : [ "str" , [] ]
@ -595,9 +597,11 @@ prim_factor =
, "class" : [ "str" , [ "mo.num" ] ]
, "symmetry" : [ "str" , [ "mo.num" ] ]
, "occupation" : [ "float", [ "mo.num" ] ]
, "energy" : [ "float", [ "mo.num" ] ]
, "spin" : [ "int" , [ "mo.num" ] ]
} ,
#+end_src
:END:
:end:
** One-electron integrals (~mo_1e_int~ group)
@ -622,7 +626,7 @@ prim_factor =
#+CALL: json(data=mo_1e_int, title="mo_1e_int")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"mo_1e_int": {
"overlap" : [ "float", [ "mo.num", "mo.num" ] ]
@ -637,7 +641,7 @@ prim_factor =
, "core_hamiltonian_im" : [ "float", [ "mo.num", "mo.num" ] ]
} ,
#+end_src
:END:
:end:
** Two-electron integrals (~mo_2e_int~ group)
@ -701,7 +705,7 @@ prim_factor =
#+CALL: json(data=determinant, title="determinant")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"determinant": {
"num" : [ "dim readonly" , [] ]
@ -709,7 +713,7 @@ prim_factor =
, "coefficient" : [ "float special", [ "determinant.num", "state.num" ] ]
} ,
#+end_src
:END:
:end:
* Excited states (state group)
@ -727,14 +731,14 @@ prim_factor =
#+CALL: json(data=state, title="state")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"state": {
"num" : [ "dim", [] ]
, "label" : [ "str", [ "state.num" ] ]
} ,
#+end_src
:END:
:end:
* Reduced density matrices (rdm group)
@ -819,7 +823,7 @@ prim_factor =
#+CALL: json(data=cell, title="cell")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"cell": {
"a" : [ "float", [ "3" ] ]
@ -827,7 +831,7 @@ prim_factor =
, "c" : [ "float", [ "3" ] ]
} ,
#+end_src
:END:
:end:
* Periodic boundary calculations (pbc group)
@ -840,14 +844,14 @@ prim_factor =
#+CALL: json(data=pbc, title="pbc")
#+RESULTS:
:RESULTS:
:results:
#+begin_src python :tangle trex.json
"pbc": {
"periodic" : [ "int" , [] ]
, "k_point" : [ "float", [ "3" ] ]
} ,
#+end_src
:END:
:end:
* Quantum Monte Carlo data (qmc group)