10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-23 12:56:14 +01:00

Merge pull request #118 from scemama/master

Corrected bug with multiple basis sets
This commit is contained in:
Anthony Scemama 2015-11-22 15:25:18 +01:00
commit 764e8588bf
2 changed files with 24 additions and 30 deletions

View File

@ -100,26 +100,21 @@ let run ?o b c d m p xyz_file =
match Hashtbl.find basis_table key with match Hashtbl.find basis_table key with
| Some in_channel -> | Some in_channel ->
in_channel in_channel
| None -> | None ->
begin let msg =
Printf.printf "%s is not defined in basis %s.\nEnter alternate basis : %!" Printf.sprintf "%s is not defined in basis %s.%!"
(Element.to_long_string element) b ; (Element.to_long_string element) b ;
let bas = in
match In_channel.input_line stdin with failwith msg
| Some line -> String.strip line |> String.lowercase
| None -> failwith "Aborted"
in
let new_channel = In_channel.create
(Qpackage.root ^ "/data/basis/" ^ bas)
in
Hashtbl.add_exn basis_table ~key:key ~data:new_channel;
new_channel
end
in in
let temp_filename = let temp_filename =
Filename.temp_file "qp_create_" ".basis" Filename.temp_file "qp_create_" ".basis"
in in
let () =
Sys.remove temp_filename
in
let rec build_basis = function let rec build_basis = function
| [] -> () | [] -> ()
| elem_and_basis_name :: rest -> | elem_and_basis_name :: rest ->
@ -130,10 +125,10 @@ let run ?o b c d m p xyz_file =
let command = let command =
if (p) then if (p) then
Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename
^ "\" \"" ^ basis ^"\" pseudo" ^ "." ^ basis ^ "\" \"" ^ basis ^"\" pseudo"
else else
Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename
^ "\" \"" ^ basis ^"\"" ^ "." ^ basis ^ "\" \"" ^ basis ^"\""
in in
begin begin
let filename = let filename =
@ -163,8 +158,8 @@ let run ?o b c d m p xyz_file =
Element.to_string elem Element.to_string elem
in in
let command = let command =
Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename ^ Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename
"\" \"" ^ basis ^ "\" " ^ key ^ "." ^ basis ^ "\" \"" ^ basis ^ "\" "
in in
begin begin
let filename = let filename =
@ -232,11 +227,15 @@ let run ?o b c d m p xyz_file =
(* Write Basis set *) (* Write Basis set *)
let basis = let basis =
let nmax = Nucl_number.get_max () in let nmax =
Nucl_number.get_max ()
in
let rec do_work (accu:(Atom.t*Nucl_number.t) list) (n:int) = function let rec do_work (accu:(Atom.t*Nucl_number.t) list) (n:int) = function
| [] -> accu | [] -> accu
| e::tail -> | e::tail ->
let new_accu = (e,(Nucl_number.of_int ~max:nmax n))::accu in let new_accu =
(e,(Nucl_number.of_int ~max:nmax n))::accu
in
do_work new_accu (n+1) tail do_work new_accu (n+1) tail
in in
let result = do_work [] 1 nuclei let result = do_work [] 1 nuclei
@ -250,15 +249,8 @@ let run ?o b c d m p xyz_file =
in in
Basis.read_element (basis_channel x.Atom.element) i e Basis.read_element (basis_channel x.Atom.element) i e
with with
| End_of_file -> | End_of_file -> failwith
begin ("Element "^(Element.to_string x.Atom.element)^" not found in basis set.")
let alt_channel = basis_channel x.Atom.element in
try
Basis.read_element alt_channel i x.Atom.element
with
End_of_file -> failwith
("Element "^(Element.to_string x.Atom.element)^" not found")
end
) )
|> List.concat |> List.concat
in in

View File

@ -8,6 +8,8 @@
# Prints in stdout the name of a temporary file containing the basis set. # Prints in stdout the name of a temporary file containing the basis set.
# #
#DEBUG:
#echo $0 $@ 1>&2
if [[ -z ${QP_ROOT} ]] if [[ -z ${QP_ROOT} ]]
then then