mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 06:33:39 +01:00
103 lines
2.8 KiB
OCaml
103 lines
2.8 KiB
OCaml
(* [[file:ex_fci.org::*Header][Header:1]] *)
|
|
open Qcaml
|
|
open Common
|
|
open Linear_algebra
|
|
|
|
let () =
|
|
(* Header:1 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Definition][Definition:1]] *)
|
|
let open Command_line in
|
|
begin
|
|
set_header_doc (Sys.argv.(0));
|
|
set_description_doc "Computes the one- and two-electron hartree_fock on the Gaussian atomic basis set.";
|
|
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. Specify negative charges with 'm' instead of the minus sign, for example m1 instead of -1. Default is 0"; } ;
|
|
|
|
]
|
|
end;
|
|
(* Definition:1 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Interpretation][Interpretation:1]] *)
|
|
let basis_file = Util.of_some @@ Command_line.get "basis" in
|
|
let nuclei_file = Util.of_some @@ Command_line.get "xyz" in
|
|
|
|
let charge =
|
|
match Command_line.get "charge" with
|
|
| Some x -> ( if x.[0] = 'm' then
|
|
~- (int_of_string (String.sub x 1 (String.length x - 1)))
|
|
else
|
|
int_of_string x )
|
|
| None -> 0
|
|
in
|
|
|
|
let multiplicity =
|
|
match Command_line.get "multiplicity" with
|
|
| Some x -> int_of_string x
|
|
| None -> 1
|
|
in
|
|
(* Interpretation:1 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:1]] *)
|
|
let nuclei =
|
|
Particles.Nuclei.of_xyz_file nuclei_file
|
|
in
|
|
(* Computation:1 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:2]] *)
|
|
let ao_basis =
|
|
Ao.Basis.of_nuclei_and_basis_filename ~nuclei basis_file
|
|
in
|
|
(* Computation:2 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:3]] *)
|
|
let simulation =
|
|
Simulation.make ~multiplicity ~charge ~nuclei ao_basis
|
|
in
|
|
(* Computation:3 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:4]] *)
|
|
let hf =
|
|
Mo.Hartree_fock.make ~guess:`Huckel simulation
|
|
in
|
|
(* Computation:4 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:5]] *)
|
|
let mo_basis =
|
|
Mo.Basis.of_hartree_fock hf
|
|
in
|
|
|
|
let frozen_core =
|
|
Mo.Frozen_core.(make Large nuclei)
|
|
in
|
|
|
|
let det_space =
|
|
Ci.Determinant_space.fci_of_mo_basis ~frozen_core mo_basis
|
|
in
|
|
(* Computation:5 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Computation][Computation:6]] *)
|
|
let ci =
|
|
Ci.make ~det_space simulation
|
|
in
|
|
(* Computation:6 ends here *)
|
|
|
|
(* [[file:ex_fci.org::*Output][Output:1]] *)
|
|
Format.printf "@[HF energy : %f@]\n" (Mo.Hartree_fock.energy hf) ;
|
|
Format.printf "@[FCI energy : %a@]\n" Vector.pp (Ci.eigenvalues ci)
|
|
(* Output:1 ends here *)
|