10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-10-31 19:23:40 +01:00
QCaml/run_fci.ml

69 lines
1.9 KiB
OCaml
Raw Normal View History

2019-02-26 11:58:53 +01:00
let () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QCaml command");
set_description_doc "Runs a Hartree-Fock calculation";
set_specs
[ { short='b' ; long="basis" ; opt=Mandatory;
arg=With_arg "<string>";
doc="Name of the file containing the basis set"; } ;
{ short='x' ; long="xyz" ; opt=Mandatory;
arg=With_arg "<string>";
doc="Name of the file containing the nuclear coordinates in xyz format"; } ;
{ short='m' ; long="multiplicity" ; opt=Optional;
arg=With_arg "<int>";
doc="Spin multiplicity (2S+1). Default is singlet"; } ;
{ short='c' ; long="charge" ; opt=Optional;
arg=With_arg "<int>";
doc="Total charge of the molecule. Default is 0"; } ;
]
end;
(* Handle options *)
2019-03-01 21:56:46 +01:00
let basis_file = Util.of_some @@ Command_line.get "basis" in
2019-02-26 11:58:53 +01:00
2019-03-01 21:56:46 +01:00
let nuclei_file = Util.of_some @@ Command_line.get "xyz" in
2019-02-26 11:58:53 +01:00
let charge =
match Command_line.get "charge" with
| Some x -> int_of_string x
| None -> 0
in
let multiplicity =
match Command_line.get "multiplicity" with
| Some x -> int_of_string x
| None -> 1
in
2019-03-02 18:50:12 +01:00
let ppf =
if Parallel.master then Format.std_formatter
else Printing.ppf_dev_null
in
2019-02-26 11:58:53 +01:00
let s =
Simulation.of_filenames ~charge ~multiplicity ~nuclei:nuclei_file basis_file
in
let hf = HartreeFock.make s in
2019-12-02 14:58:48 +01:00
Format.fprintf ppf "@[%a@]@." HartreeFock.pp hf;
2019-03-02 18:50:12 +01:00
2019-02-26 11:58:53 +01:00
let mos =
MOBasis.of_hartree_fock hf
in
2019-03-02 18:50:12 +01:00
2019-02-26 11:58:53 +01:00
let space =
2019-03-22 19:15:59 +01:00
DeterminantSpace.fci_of_mo_basis ~frozen_core:false mos
2019-02-26 11:58:53 +01:00
in
let ci = CI.make space in
2019-03-02 18:50:12 +01:00
Format.fprintf ppf "FCI energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s);
2019-02-26 11:58:53 +01:00
(*
let s2 = Util.xt_o_x ~o:(CI.s2_matrix ci) ~x:(CI.eigenvectors ci) in
2019-03-04 22:56:03 +01:00
Util.list_range 1 (DeterminantSpace.size space)
2019-02-26 11:58:53 +01:00
|> List.iter (fun i -> Format.printf "@[%f@]@;" s2.{i,i});
*)