QCaml/run_integrals.ml

61 lines
1.5 KiB
OCaml
Raw Normal View History

2018-01-18 00:21:05 +01:00
let basis_file : string option ref = ref None
let coord_file : string option ref = ref None
2018-01-19 03:14:06 +01:00
let out_file : string option ref = ref None
2018-01-18 00:21:05 +01:00
let speclist = [
2018-01-19 03:14:06 +01:00
( "-b" , Arg.String (fun x -> basis_file := Some x) ,
"File containing the atomic basis set") ;
( "-c" , Arg.String (fun x -> coord_file := Some x) ,
"File containing the nuclear coordinates") ;
( "-o" , Arg.String (fun x -> out_file := Some x) ,
"Output file") ;
2018-01-18 00:21:05 +01:00
]
2018-01-19 03:14:06 +01:00
let run ~coord ~basis ~out =
2018-01-18 00:21:05 +01:00
let coord_file =
match coord with
2018-01-19 03:14:06 +01:00
| None -> raise (Invalid_argument "Coordinate file should be specified with -c")
2018-01-18 00:21:05 +01:00
| Some x -> x
and basis_file =
match basis with
2018-01-19 03:14:06 +01:00
| None -> raise (Invalid_argument "Basis set file should be specified with -b")
| Some x -> x
and out_file =
match out with
| None -> raise (Invalid_argument "Output file should be specified with -o")
2018-01-18 00:21:05 +01:00
| Some x -> x
in
2018-01-19 03:14:06 +01:00
2018-01-18 00:21:05 +01:00
let nuclei =
Nuclei.of_xyz_file ~filename:coord_file
in
2018-01-18 17:39:10 +01:00
print_endline @@ Nuclei.to_string nuclei;
2018-01-18 00:21:05 +01:00
let basis =
2018-01-19 03:14:06 +01:00
let general_basis =
Gamess_reader.read ~filename:basis_file
in
2018-01-18 00:21:05 +01:00
Basis.of_nuclei_and_general_basis nuclei general_basis
in
2018-01-19 03:14:06 +01:00
print_endline @@ Basis.to_string basis;
ERI.to_file ~filename:out_file basis
2018-01-18 00:21:05 +01:00
let () =
2018-01-18 14:56:08 +01:00
let usage_msg = "Available options:" in
2018-01-18 00:21:05 +01:00
Arg.parse speclist (fun _ -> ()) usage_msg;
2018-01-19 03:14:06 +01:00
run ~coord:!coord_file ~basis:!basis_file ~out:!out_file
2018-01-19 20:20:19 +01:00
(*
try
2018-01-18 14:56:08 +01:00
with
| Invalid_argument e ->
2018-01-19 03:14:06 +01:00
begin
print_string "Error: " ; print_endline e; print_newline ();
Arg.usage speclist usage_msg
end
2018-01-19 20:20:19 +01:00
*)
2018-01-19 03:14:06 +01:00