9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-04 02:48:24 +01:00

Fix basis bugs when working on trexio

This commit is contained in:
Anthony Scemama 2021-12-30 14:43:14 +01:00
parent 7fba7a1209
commit 2a98378fca
2 changed files with 38 additions and 28 deletions

View File

@ -91,7 +91,7 @@ let run ?o b au c d m p cart xyz_file =
| Element e -> Element.to_string e
| Int_elem (i,e) -> Printf.sprintf "%d,%s" (Nucl_number.to_int i) (Element.to_string e)
in
Hashtbl.find basis_table key
Hashtbl.find basis_table key
in
let temp_filename =
@ -132,7 +132,7 @@ let run ?o b au c d m p cart xyz_file =
Element.to_string elem.Atom.element
in
Hashtbl.add basis_table key new_channel
) nuclei
) nuclei
end
| Some (key, basis) -> (*Aux basis *)
begin
@ -277,6 +277,16 @@ let run ?o b au c d m p cart xyz_file =
) nuclei
in
let z_core =
List.map (fun x ->
Positive_int.to_int x.Pseudo.n_elec
|> float_of_int
) pseudo
in
let nucl_num = (List.length z_core) in
Ezfio.set_pseudo_nucl_charge_remove (Ezfio.ezfio_array_of_list
~rank:1 ~dim:[| nucl_num |] ~data:z_core);
let molecule =
let n_elec_to_remove =
List.fold_left (fun accu x ->
@ -293,13 +303,13 @@ let run ?o b au c d m p cart xyz_file =
Molecule.nuclei =
let charges =
list_map (fun x -> Positive_int.to_int x.Pseudo.n_elec
|> Float.of_int) pseudo
|> Float.of_int) pseudo
|> Array.of_list
in
List.mapi (fun i x ->
{ x with Atom.charge = (Charge.to_float x.Atom.charge) -. charges.(i)
|> Charge.of_float }
) molecule.Molecule.nuclei
) molecule.Molecule.nuclei
}
in
let nuclei =
@ -356,11 +366,11 @@ let run ?o b au c d m p cart xyz_file =
in
if (x > accu) then x
else accu
) 0 x.Pseudo.non_local
) 0 x.Pseudo.non_local
in
if (x > accu) then x
else accu
) 0 pseudo
) 0 pseudo
in
let kmax =
@ -368,10 +378,10 @@ let run ?o b au c d m p cart xyz_file =
list_map (fun x ->
List.filter (fun (y,_) ->
(Positive_int.to_int y.Pseudo.GaussianPrimitive_non_local.proj) = i)
x.Pseudo.non_local
|> List.length ) pseudo
x.Pseudo.non_local
|> List.length ) pseudo
|> List.fold_left (fun accu x ->
if accu > x then accu else x) 0
if accu > x then accu else x) 0
)
|> Array.fold_left (fun accu i ->
if i > accu then i else accu) 0
@ -396,11 +406,11 @@ let run ?o b au c d m p cart xyz_file =
in
tmp_array_dz_k.(i).(j) <- y;
tmp_array_n_k.(i).(j) <- z;
) x.Pseudo.local
) x.Pseudo.local
) pseudo ;
let concat_2d tmp_array =
let data =
Array.map Array.to_list tmp_array
Array.map Array.to_list tmp_array
|> Array.to_list
|> List.concat
in
@ -438,14 +448,14 @@ let run ?o b au c d m p cart xyz_file =
tmp_array_dz_kl.(k).(i).(j) <- y;
tmp_array_n_kl.(k).(i).(j) <- z;
last_idx.(k) <- i+1;
) x.Pseudo.non_local
) x.Pseudo.non_local
) pseudo ;
let concat_3d tmp_array =
let data =
Array.map (fun x ->
Array.map Array.to_list x
|> Array.to_list
|> List.concat) tmp_array
|> List.concat) tmp_array
|> Array.to_list
|> List.concat
in
@ -513,8 +523,8 @@ let run ?o b au c d m p cart xyz_file =
Ezfio.set_ao_basis_ao_num ao_num;
Ezfio.set_ao_basis_ao_basis b;
Ezfio.set_basis_basis b;
let ao_prim_num = list_map (fun (_,g,_) -> List.length g.Gto.lc) long_basis
and ao_nucl = list_map (fun (_,_,n) -> Nucl_number.to_int n) long_basis
let ao_prim_num = list_map (fun (_,g,_) -> List.length g.Gto.lc) long_basis
and ao_nucl = list_map (fun (_,_,n) -> Nucl_number.to_int n) long_basis
and ao_power=
let l = list_map (fun (x,_,_) -> x) long_basis in
(list_map (fun t -> Positive_int.to_int Angmom.Xyz.(t.x)) l)@
@ -526,7 +536,7 @@ let run ?o b au c d m p cart xyz_file =
else s) 0 ao_prim_num
in
let gtos =
list_map (fun (_,x,_) -> x) long_basis
list_map (fun (_,x,_) -> x) long_basis
in
let create_expo_coef ec =
@ -534,10 +544,10 @@ let run ?o b au c d m p cart xyz_file =
begin match ec with
| `Coefs -> list_map (fun x->
list_map (fun (_,coef) ->
AO_coef.to_float coef) x.Gto.lc) gtos
AO_coef.to_float coef) x.Gto.lc) gtos
| `Expos -> list_map (fun x->
list_map (fun (prim,_) -> AO_expo.to_float
prim.GaussianPrimitive.expo) x.Gto.lc) gtos
prim.GaussianPrimitive.expo) x.Gto.lc) gtos
end
in
let rec get_n n accu = function
@ -567,7 +577,7 @@ let run ?o b au c d m p cart xyz_file =
list_map ( fun (g,_) -> g.Gto.lc ) basis
in
let ang_mom =
list_map (fun (l : (GaussianPrimitive.t * Qptypes.AO_coef.t) list) ->
list_map (fun (l : (GaussianPrimitive.t * Qptypes.AO_coef.t) list) ->
let x, _ = List.hd l in
Angmom.to_l x.GaussianPrimitive.sym |> Qptypes.Positive_int.to_int
) lc
@ -577,7 +587,7 @@ let run ?o b au c d m p cart xyz_file =
|> List.concat
in
let coef =
list_map (fun l ->
list_map (fun l ->
list_map (fun (_,x) -> Qptypes.AO_coef.to_float x) l
) lc
|> List.concat
@ -610,14 +620,14 @@ let run ?o b au c d m p cart xyz_file =
~rank:1 ~dim:[| prim_num |] ~data:shell_idx) ;
Ezfio.set_basis_basis_nucleus_index (Ezfio.ezfio_array_of_list
~rank:1 ~dim:[| shell_num |]
~data:( list_map (fun (_,n) -> Nucl_number.to_int n) basis)
~data:( list_map (fun (_,n) -> Nucl_number.to_int n) basis)
) ;
Ezfio.set_basis_nucleus_shell_num(Ezfio.ezfio_array_of_list
~rank:1 ~dim:[| nucl_num |]
~data:(
list_map (fun (_,n) -> Nucl_number.to_int n) basis
|> List.fold_left (fun accu i ->
match accu with
|> List.fold_left (fun accu i ->
match accu with
| [] -> [(1,i)]
| (h,j) :: rest -> if j == i then ((h+1,j)::rest) else ((1,i)::(h,j)::rest)
) []
@ -713,7 +723,7 @@ If a file with the same name as the basis set exists, this file will be read. O
anonymous "FILE" Mandatory "Input file in xyz format or z-matrix.";
]
|> set_specs
|> set_specs
end;
@ -737,7 +747,7 @@ If a file with the same name as the basis set exists, this file will be read. O
| None -> 0
| Some x -> ( if x.[0] = 'm' then
~- (int_of_string (String.sub x 1 (String.length x - 1)))
else
else
int_of_string x )
in

View File

@ -10,7 +10,7 @@ type:integer
interface: ezfio,provider
[pseudo_n_k]
doc: Number of gaussians in the local component
doc: Powers of r - 2 in the local component
type: integer
interface: ezfio,provider
size: (nuclei.nucl_num,pseudo.pseudo_klocmax)
@ -38,7 +38,7 @@ type:integer
interface: ezfio,provider
[pseudo_n_kl]
doc: Number of functions in the non-local component
doc: Powers of r - 2 in the non-local component
type: integer
interface: ezfio,provider
size: (nuclei.nucl_num,pseudo.pseudo_kmax,0:pseudo.pseudo_lmax)
@ -69,7 +69,7 @@ default: 1000
[pseudo_grid_rmax]
type: double precision
doc: R_max of the QMC grid
doc: R_max of the QMC grid
interface: ezfio,provider,ocaml
default: 10.0