diff --git a/ocaml/Input_determinants.ml b/ocaml/Input_determinants.ml index af4fc08f..9af2b7c0 100644 --- a/ocaml/Input_determinants.ml +++ b/ocaml/Input_determinants.ml @@ -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 - |> String.split ~on:'\n' - |> List.map ~f:(fun x -> " "^x) - |> String.concat ~sep:"\n" + 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." ) - ) (Array.to_list b.psi_coef) (Array.to_list b.psi_det) - |> String.concat ~sep:"\n" + |> 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" + ) + ) + |> String.concat_array ~sep:"\n" in Printf.sprintf " Read the current wave function :: @@ -498,8 +517,8 @@ psi_det = %s (* Handle determinant coefs *) let dets = match ( dets - |> String.split ~on:'\n' - |> List.map ~f:(String.strip) + |> String.split ~on:'\n' + |> List.map ~f:(String.strip) ) with | _::lines -> lines | _ -> failwith "Error in determinants" @@ -511,16 +530,33 @@ 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 = - read_coefs [] dets - |> List.map ~f:(fun x -> Det_coef.to_string x) - |> String.concat ~sep:" " + let buffer = + read_coefs [] dets + 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 diff --git a/src/Dets/determinants.irp.f b/src/Dets/determinants.irp.f index 70af8ab6..c75028b6 100644 --- a/src/Dets/determinants.irp.f +++ b/src/Dets/determinants.irp.f @@ -11,11 +11,11 @@ BEGIN_PROVIDER [ integer, N_det ] if (read_wf) then call ezfio_has_determinants_n_det(exists) if (exists) then - call ezfio_has_determinants_mo_label(exists) - if (exists) then - call ezfio_get_determinants_mo_label(label) - exists = (label == mo_label) - endif + call ezfio_has_determinants_mo_label(exists) + if (exists) then + call ezfio_get_determinants_mo_label(label) + exists = (label == mo_label) + endif endif if (exists) then call ezfio_get_determinants_n_det(N_det) @@ -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)