mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-03 10:05:57 +01:00
Bug when saving excited states solevd
This commit is contained in:
parent
acbe7599ba
commit
3530cb67d1
@ -368,16 +368,35 @@ end = struct
|
||||
let mo_tot_num = Ezfio.get_mo_basis_mo_tot_num () in
|
||||
let mo_tot_num = MO_number.of_int mo_tot_num ~max:mo_tot_num in
|
||||
let det_text =
|
||||
List.map2_exn ~f:(fun coef det ->
|
||||
Printf.sprintf " %F\n%s\n"
|
||||
(Det_coef.to_float coef)
|
||||
(Determinant.to_string ~mo_tot_num:mo_tot_num det
|
||||
let nstates =
|
||||
States_number.to_int b.n_states
|
||||
and ndet =
|
||||
Det_number.to_int b.n_det
|
||||
in
|
||||
let coefs_string i =
|
||||
Array.init nstates (fun j ->
|
||||
let ishift =
|
||||
j*ndet
|
||||
in
|
||||
if (ishift < Array.length b.psi_coef) then
|
||||
b.psi_coef.(i+ishift)
|
||||
|> Det_coef.to_float
|
||||
|> Float.to_string
|
||||
else
|
||||
"0."
|
||||
)
|
||||
|> String.concat_array ~sep:"\t"
|
||||
in
|
||||
Array.init ndet ~f:(fun i ->
|
||||
Printf.sprintf " %s\n%s\n"
|
||||
(coefs_string i)
|
||||
(Determinant.to_string ~mo_tot_num:mo_tot_num b.psi_det.(i)
|
||||
|> String.split ~on:'\n'
|
||||
|> List.map ~f:(fun x -> " "^x)
|
||||
|> String.concat ~sep:"\n"
|
||||
)
|
||||
) (Array.to_list b.psi_coef) (Array.to_list b.psi_det)
|
||||
|> String.concat ~sep:"\n"
|
||||
)
|
||||
|> String.concat_array ~sep:"\n"
|
||||
in
|
||||
Printf.sprintf "
|
||||
Read the current wave function ::
|
||||
@ -511,17 +530,34 @@ psi_det = %s
|
||||
| ""::""::tail -> read_coefs accu tail
|
||||
| ""::c::tail ->
|
||||
let c =
|
||||
Float.of_string c
|
||||
|> Det_coef.of_float
|
||||
String.split ~on:'\t' c
|
||||
|> List.map ~f:(fun x -> Det_coef.of_float (Float.of_string x))
|
||||
|> Array.of_list
|
||||
in
|
||||
read_coefs (c::accu) tail
|
||||
| _::tail -> read_coefs accu tail
|
||||
in
|
||||
let a =
|
||||
let buffer =
|
||||
read_coefs [] dets
|
||||
|> List.map ~f:(fun x -> Det_coef.to_string x)
|
||||
in
|
||||
let nstates =
|
||||
List.hd_exn buffer
|
||||
|> Array.length
|
||||
in
|
||||
let extract_state i =
|
||||
let i =
|
||||
i-1
|
||||
in
|
||||
List.map ~f:(fun x -> Det_coef.to_string x.(i)) buffer
|
||||
|> String.concat ~sep:" "
|
||||
in
|
||||
let rec build_result = function
|
||||
| 1 -> extract_state 1
|
||||
| i -> (build_result (i-1))^" "^(extract_state i)
|
||||
in
|
||||
build_result nstates
|
||||
in
|
||||
"(psi_coef ("^a^"))"
|
||||
in
|
||||
|
||||
|
@ -726,18 +726,18 @@ subroutine save_wavefunction
|
||||
BEGIN_DOC
|
||||
! Save the wave function into the EZFIO file
|
||||
END_DOC
|
||||
call save_wavefunction_general(N_det,N_states,psi_det_sorted,psi_coef_sorted)
|
||||
call save_wavefunction_general(N_det,N_states,psi_det_sorted,size(psi_coef_sorted,1),psi_coef_sorted)
|
||||
end
|
||||
|
||||
subroutine save_wavefunction_general(ndet,nstates,psidet,psicoef)
|
||||
subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Save the wave function into the EZFIO file
|
||||
END_DOC
|
||||
use bitmasks
|
||||
integer, intent(in) :: ndet,nstates
|
||||
integer, intent(in) :: ndet,nstates,dim_psicoef
|
||||
integer(bit_kind), intent(in) :: psidet(N_int,2,ndet)
|
||||
double precision, intent(in) :: psicoef(ndet,nstates)
|
||||
double precision, intent(in) :: psicoef(dim_psicoef,nstates)
|
||||
integer*8, allocatable :: psi_det_save(:,:,:)
|
||||
double precision, allocatable :: psi_coef_save(:,:)
|
||||
integer*8 :: det_8(100)
|
||||
|
Loading…
Reference in New Issue
Block a user