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 = 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 mo_tot_num = MO_number.of_int mo_tot_num ~max:mo_tot_num in
|
||||||
let det_text =
|
let det_text =
|
||||||
List.map2_exn ~f:(fun coef det ->
|
let nstates =
|
||||||
Printf.sprintf " %F\n%s\n"
|
States_number.to_int b.n_states
|
||||||
(Det_coef.to_float coef)
|
and ndet =
|
||||||
(Determinant.to_string ~mo_tot_num:mo_tot_num det
|
Det_number.to_int b.n_det
|
||||||
|> String.split ~on:'\n'
|
in
|
||||||
|> List.map ~f:(fun x -> " "^x)
|
let coefs_string i =
|
||||||
|> String.concat ~sep:"\n"
|
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."
|
||||||
)
|
)
|
||||||
) (Array.to_list b.psi_coef) (Array.to_list b.psi_det)
|
|> String.concat_array ~sep:"\t"
|
||||||
|> String.concat ~sep:"\n"
|
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"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|> String.concat_array ~sep:"\n"
|
||||||
in
|
in
|
||||||
Printf.sprintf "
|
Printf.sprintf "
|
||||||
Read the current wave function ::
|
Read the current wave function ::
|
||||||
@ -498,8 +517,8 @@ psi_det = %s
|
|||||||
|
|
||||||
(* Handle determinant coefs *)
|
(* Handle determinant coefs *)
|
||||||
let dets = match ( dets
|
let dets = match ( dets
|
||||||
|> String.split ~on:'\n'
|
|> String.split ~on:'\n'
|
||||||
|> List.map ~f:(String.strip)
|
|> List.map ~f:(String.strip)
|
||||||
) with
|
) with
|
||||||
| _::lines -> lines
|
| _::lines -> lines
|
||||||
| _ -> failwith "Error in determinants"
|
| _ -> failwith "Error in determinants"
|
||||||
@ -511,16 +530,33 @@ psi_det = %s
|
|||||||
| ""::""::tail -> read_coefs accu tail
|
| ""::""::tail -> read_coefs accu tail
|
||||||
| ""::c::tail ->
|
| ""::c::tail ->
|
||||||
let c =
|
let c =
|
||||||
Float.of_string c
|
String.split ~on:'\t' c
|
||||||
|> Det_coef.of_float
|
|> List.map ~f:(fun x -> Det_coef.of_float (Float.of_string x))
|
||||||
|
|> Array.of_list
|
||||||
in
|
in
|
||||||
read_coefs (c::accu) tail
|
read_coefs (c::accu) tail
|
||||||
| _::tail -> read_coefs accu tail
|
| _::tail -> read_coefs accu tail
|
||||||
in
|
in
|
||||||
let a =
|
let a =
|
||||||
read_coefs [] dets
|
let buffer =
|
||||||
|> List.map ~f:(fun x -> Det_coef.to_string x)
|
read_coefs [] dets
|
||||||
|> String.concat ~sep:" "
|
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
|
in
|
||||||
"(psi_coef ("^a^"))"
|
"(psi_coef ("^a^"))"
|
||||||
in
|
in
|
||||||
|
@ -11,11 +11,11 @@ BEGIN_PROVIDER [ integer, N_det ]
|
|||||||
if (read_wf) then
|
if (read_wf) then
|
||||||
call ezfio_has_determinants_n_det(exists)
|
call ezfio_has_determinants_n_det(exists)
|
||||||
if (exists) then
|
if (exists) then
|
||||||
call ezfio_has_determinants_mo_label(exists)
|
call ezfio_has_determinants_mo_label(exists)
|
||||||
if (exists) then
|
if (exists) then
|
||||||
call ezfio_get_determinants_mo_label(label)
|
call ezfio_get_determinants_mo_label(label)
|
||||||
exists = (label == mo_label)
|
exists = (label == mo_label)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if (exists) then
|
if (exists) then
|
||||||
call ezfio_get_determinants_n_det(N_det)
|
call ezfio_get_determinants_n_det(N_det)
|
||||||
@ -726,18 +726,18 @@ subroutine save_wavefunction
|
|||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Save the wave function into the EZFIO file
|
! Save the wave function into the EZFIO file
|
||||||
END_DOC
|
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
|
end
|
||||||
|
|
||||||
subroutine save_wavefunction_general(ndet,nstates,psidet,psicoef)
|
subroutine save_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psicoef)
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Save the wave function into the EZFIO file
|
! Save the wave function into the EZFIO file
|
||||||
END_DOC
|
END_DOC
|
||||||
use bitmasks
|
use bitmasks
|
||||||
integer, intent(in) :: ndet,nstates
|
integer, intent(in) :: ndet,nstates,dim_psicoef
|
||||||
integer(bit_kind), intent(in) :: psidet(N_int,2,ndet)
|
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(:,:,:)
|
integer*8, allocatable :: psi_det_save(:,:,:)
|
||||||
double precision, allocatable :: psi_coef_save(:,:)
|
double precision, allocatable :: psi_coef_save(:,:)
|
||||||
integer*8 :: det_8(100)
|
integer*8 :: det_8(100)
|
||||||
|
Loading…
Reference in New Issue
Block a user