10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-07-13 14:44:31 +02:00
QCaml/Notebooks/F12_matrix.ipynb
2019-12-03 09:13:57 +01:00

30 KiB

None <html> <head> </head>

Test of F12 matrix elements

Initialization

In [1]:
#cd "/home/scemama/QCaml";;
#use "topfind";;
#require "jupyter.notebook";;

#require "lacaml";;
#require "alcotest";;
#require "str";;
#require "bigarray";;
#require "zarith";;
#require "getopt";;
#directory "_build";;
#directory "_build/Basis";;
#directory "_build/CI";;
#directory "_build/MOBasis";;
#directory "_build/Nuclei";;
#directory "_build/Parallel";;
#directory "_build/Perturbation";;
#directory "_build/SCF";;
#directory "_build/Utils";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

- : unit = ()
/home/scemama/qp2/external/opam/default/lib/bytes: added to search path
/home/scemama/qp2/external/opam/default/lib/base64: added to search path
/home/scemama/qp2/external/opam/default/lib/base64/base64.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ocaml/compiler-libs: added to search path
/home/scemama/qp2/external/opam/default/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded
/home/scemama/qp2/external/opam/default/lib/result: added to search path
/home/scemama/qp2/external/opam/default/lib/result/result.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ppx_deriving/runtime: added to search path
/home/scemama/qp2/external/opam/default/lib/ppx_deriving/runtime/ppx_deriving_runtime.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ppx_deriving_yojson/runtime: added to search path
/home/scemama/qp2/external/opam/default/lib/ppx_deriving_yojson/runtime/ppx_deriving_yojson_runtime.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ocaml/unix.cma: loaded
/home/scemama/qp2/external/opam/default/lib/uuidm: added to search path
/home/scemama/qp2/external/opam/default/lib/uuidm/uuidm.cma: loaded
/home/scemama/qp2/external/opam/default/lib/easy-format: added to search path
/home/scemama/qp2/external/opam/default/lib/easy-format/easy_format.cma: loaded
/home/scemama/qp2/external/opam/default/lib/biniou: added to search path
/home/scemama/qp2/external/opam/default/lib/biniou/biniou.cma: loaded
/home/scemama/qp2/external/opam/default/lib/yojson: added to search path
/home/scemama/qp2/external/opam/default/lib/yojson/yojson.cma: loaded
/home/scemama/qp2/external/opam/default/lib/jupyter: added to search path
/home/scemama/qp2/external/opam/default/lib/jupyter/jupyter.cma: loaded
/home/scemama/qp2/external/opam/default/lib/jupyter/notebook: added to search path
/home/scemama/qp2/external/opam/default/lib/jupyter/notebook/jupyter_notebook.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ocaml/bigarray.cma: loaded
/home/scemama/qp2/external/opam/default/lib/lacaml: added to search path
/home/scemama/qp2/external/opam/default/lib/lacaml/lacaml.cma: loaded
/home/scemama/qp2/external/opam/default/lib/astring: added to search path
/home/scemama/qp2/external/opam/default/lib/astring/astring.cma: loaded
/home/scemama/qp2/external/opam/default/lib/cmdliner: added to search path
/home/scemama/qp2/external/opam/default/lib/cmdliner/cmdliner.cma: loaded
/home/scemama/qp2/external/opam/default/lib/seq: added to search path
/home/scemama/qp2/external/opam/default/lib/stdlib-shims: added to search path
/home/scemama/qp2/external/opam/default/lib/stdlib-shims/stdlib_shims.cma: loaded
/home/scemama/qp2/external/opam/default/lib/fmt: added to search path
/home/scemama/qp2/external/opam/default/lib/fmt/fmt.cma: loaded
/home/scemama/qp2/external/opam/default/lib/fmt/fmt_cli.cma: loaded
/home/scemama/qp2/external/opam/default/lib/fmt/fmt_tty.cma: loaded
/home/scemama/qp2/external/opam/default/lib/alcotest: added to search path
/home/scemama/qp2/external/opam/default/lib/alcotest/alcotest.cma: loaded
/home/scemama/qp2/external/opam/default/lib/ocaml/str.cma: loaded
/home/scemama/qp2/external/opam/default/lib/zarith: added to search path
/home/scemama/qp2/external/opam/default/lib/zarith/zarith.cma: loaded
/home/scemama/qp2/external/opam/default/lib/getopt: added to search path
/home/scemama/qp2/external/opam/default/lib/getopt/getopt.cma: loaded

Modules to load

In [2]:
#load "Constants.cmo";;
#load_rec "Util.cma";;
#load_rec "Matrix.cmo";;
#load_rec "Simulation.cmo";;
#load_rec "Simulation.cmo";;
#load_rec "HartreeFock.cmo";;
#load_rec "MOBasis.cmo";;
#load_rec "F12CI.cmo";;

open Lacaml.D;;

Printers

In [3]:
#install_printer AngularMomentum.pp_string ;;
#install_printer Basis.pp ;;
#install_printer Charge.pp ;;
#install_printer Coordinate.pp ;;
#install_printer Vector.pp;;
#install_printer Matrix.pp;;
#install_printer Util.pp_float_2darray;;
#install_printer Util.pp_float_array;;
#install_printer Util.pp_matrix;;
#install_printer HartreeFock.pp ;;
#install_printer Fock.pp ;;
let f ppf t = MOBasis.pp ~start:1 ~finish:0 ppf t ;;
#install_printer f;;
Out[3]:
val f : Format.formatter -> MOBasis.t -> unit = <fun>

Run

Simulation

In [4]:
let basis_filename  = "/home/scemama/qp2/data/basis/cc-pvdz" 
let aux_basis_filename = "/home/scemama/qp2/data/basis/cc-pvtz" 
let nuclei = Nuclei.of_zmt_string "be" 
let multiplicity = 1
let state = 1

let basis =  Basis.of_nuclei_and_basis_filenames ~nuclei [basis_filename] 
let aux_basis =  Basis.of_nuclei_and_basis_filenames ~nuclei (basis_filename :: aux_basis_filename :: []) 
let f12 = F12factor.gaussian_geminal 1.0 
let charge = 0 


let simulation =
    Simulation.make 
        ~f12 ~charge ~multiplicity ~nuclei
        ~cartesian:true
        basis
Out[4]:
val basis_filename : string = "/home/scemama/qp2/data/basis/cc-pvdz"
Out[4]:
val aux_basis_filename : string = "/home/scemama/qp2/data/basis/cc-pvtz"
Out[4]:
val nuclei : Nuclei.t = [|(Element.Be,   0.0000   0.0000   0.0000)|]
Out[4]:
val multiplicity : int = 1
Out[4]:
val state : int = 1
Out[4]:
val basis : Basis.t =
  
                          Atomic Basis set
                          ----------------

-----------------------------------------------------------------------
 #   Angular   Coordinates (Bohr)       Exponents       Coefficients
    Momentum  X        Y        Z
-----------------------------------------------------------------------
  1-3  S   0.0000   0.0000   0.0000   2.94000000e+03    6.80000000e-04
                                      4.41200000e+02    5.23600000e-03
                                      1.00500000e+02    2.66060000e-02
                                      2.84300000e+01    9.99930000e-02
                                      9.16900000e+00    2.69702000e-01
                                      3.19600000e+00    4.51469000e-01
                                      1.15900000e+00    2.95074000e-01
                                      1.81100000e-01    1.25870000e-02
                                    
                                      2.94000000e+03   -1.23000000e-04
                                      4.41200000e+02   -9.66000000e-04
                                      1.00500000e+02   -4.83100000e-03
                                      2.84300000e+01   -1.93140000e-02
                                      9.16900000e+00   -5.32800000e-02
                                      3.19600000e+00   -1.20723000e-01
                                      1.15900000e+00   -1.33435000e-01
                                      1.81100000e-01    5.30767000e-01
                                    
                                      5.89000000e-02    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------
  4-9  P   0.0000   0.0000   0.0000   3.61900000e+00    2.91110000e-02
                                      7.11000000e-01    1.69365000e-01
                                      1.95100000e-01    5.13458000e-01
                                    
                                      6.01800000e-02    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------
 10-15 D   0.0000   0.0000   0.0000   2.38000000e-01    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------

Out[4]:
val aux_basis : Basis.t =
  
                          Atomic Basis set
                          ----------------

-----------------------------------------------------------------------
 #   Angular   Coordinates (Bohr)       Exponents       Coefficients
    Momentum  X        Y        Z
-----------------------------------------------------------------------
  1-7  S   0.0000   0.0000   0.0000   2.94000000e+03    6.80000000e-04
                                      4.41200000e+02    5.23600000e-03
                                      1.00500000e+02    2.66060000e-02
                                      2.84300000e+01    9.99930000e-02
                                      9.16900000e+00    2.69702000e-01
                                      3.19600000e+00    4.51469000e-01
                                      1.15900000e+00    2.95074000e-01
                                      1.81100000e-01    1.25870000e-02
                                    
                                      2.94000000e+03   -1.23000000e-04
                                      4.41200000e+02   -9.66000000e-04
                                      1.00500000e+02   -4.83100000e-03
                                      2.84300000e+01   -1.93140000e-02
                                      9.16900000e+00   -5.32800000e-02
                                      3.19600000e+00   -1.20723000e-01
                                      1.15900000e+00   -1.33435000e-01
                                      1.81100000e-01    5.30767000e-01
                                    
                                      5.89000000e-02    1.00000000e+00
                                    
                                      6.86300000e+03    2.36000000e-04
                                      1.03000000e+03    1.82600000e-03
                                      2.34700000e+02    9.45200000e-03
                                      6.65600000e+01    3.79570000e-02
                                      2.16900000e+01    1.19965000e-01
                                      7.73400000e+00    2.82162000e-01
                                      2.91600000e+00    4.27404000e-01
                                      1.13000000e+00    2.66278000e-01
                                      1.10100000e-01   -7.27500000e-03
                                    
                                      6.86300000e+03   -4.30000000e-05
                                      1.03000000e+03   -3.33000000e-04
                                      2.34700000e+02   -1.73600000e-03
                                      6.65600000e+01   -7.01200000e-03
                                      2.16900000e+01   -2.31260000e-02
                                      7.73400000e+00   -5.81380000e-02
                                      2.91600000e+00   -1.14556000e-01
                                      1.13000000e+00   -1.35908000e-01
                                      1.10100000e-01    5.77441000e-01
                                    
                                      2.57700000e-01    1.00000000e+00
                                    
                                      4.40900000e-02    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------
  4-18 P   0.0000   0.0000   0.0000   3.61900000e+00    2.91110000e-02
                                      7.11000000e-01    1.69365000e-01
                                      1.95100000e-01    5.13458000e-01
                                    
                                      6.01800000e-02    1.00000000e+00
                                    
                                      7.43600000e+00    1.07360000e-02
                                      1.57700000e+00    6.28540000e-02
                                      4.35200000e-01    2.48180000e-01
                                    
                                      1.43800000e-01    1.00000000e+00
                                    
                                      4.99400000e-02    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------
 10-27 D   0.0000   0.0000   0.0000   2.38000000e-01    1.00000000e+00
                                    
                                      3.48000000e-01    1.00000000e+00
                                    
                                      1.80300000e-01    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------
 41-50 F   0.0000   0.0000   0.0000   3.25000000e-01    1.00000000e+00
                                    
                                    
-----------------------------------------------------------------------

Out[4]:
val f12 : F12factor.t =
  {F12factor.expo_s = 1.;
   gaussian =
    {GaussianOperator.coef_g =
      [  -0.314400  -0.303700  -0.168100  -0.098110  -0.060240  -0.037260 ];
     expo_sg =
      [   0.220900   1.004000   3.622000  12.160000  45.870000 254.400000 ];
     expo_sg_inv =
      [   4.526935   0.996016   0.276091   0.082237   0.021801   0.003931 ]}}
Out[4]:
val charge : int = 0
Out[4]:
val simulation : Simulation.t = <abstr>

Hartree-Fock

In [5]:
let hf =  HartreeFock.make ~guess:`Hcore  simulation  ;;

let mo_basis = MOBasis.of_hartree_fock hf
21 significant shell pairs computed in 0.055000 seconds
1
2
3
6
9
Computed ERIs in 0.238291 seconds
MOs =


             -- 1 --     -- 2 --      -- 3 --      -- 4 --      -- 5 --
             1        1.0006  0.00028918            0            0            0
             2    0.00576322     1.00367            0  1.02041E-15  1.08506E-15
             3   -0.00181801    0.582215            0 -8.39813E-16 -8.40021E-16
                         ...         ...          ...          ...          ...
            13   -0.00209072 -0.00172308  9.60612E-16            0            0
            14             0          -0            0            0            0
            15   -0.00209072 -0.00172308 -1.26705E-15            0  4.17104E-16
      

          -- 6 -- -- 7 --      -- 8 --      -- 9 --     -- 10 --
             1   0.549926       0 -2.88529E-15           -0  8.58482E-16
             2    2.77214       0   -1.582E-14           -0  3.81097E-15
             3     -1.826       0  9.32169E-15           -0 -3.39771E-15
                      ...     ...          ...          ...          ...
            13   0.224421       0 -1.20926E-15           -0   -0.0220572
            14          0       0           -0 -1.20416E-15    0.0718784
            15   0.224421       0           -0           -0     0.847943
      

             -- 11 --   -- 12 --    -- 13 --   -- 14 -- -- 15 --
             1   -1.28321E-15          0           0          0 0.516133
             2   -1.06861E-14          0 1.77725E-15          0  4.52711
             3   -1.84016E-15          0 1.31997E-15          0  1.08073
                          ...        ...         ...        ...      ...
            13      -0.964125 -0.0163169    0.262399  0.0292786 -1.45115
            14      0.0475417  0.0403496   0.0724528   0.992822       -0
            15       0.406875   0.061849   -0.328775 -0.0593936 -1.45115
      
Out[5]:
val hf : HartreeFock.t = 
======================================================================
                        Restricted Hartree-Fock                      
======================================================================

    ------------------------------------------------------------
        #     HF energy       Convergence  HOMO-LUMO
    ------------------------------------------------------------
        1    -14.05142130      8.0958e-01     0.2991
        2    -14.51982122      2.7933e-01     0.3600
        3    -14.56519147      8.3990e-02     0.3674
        4    -14.57117146      2.6217e-02     0.3679
        5    -14.57214606      1.0744e-02     0.3676
        6    -14.57232209      5.0392e-03     0.3675
        7    -14.57235521      2.2956e-03     0.3674
        8    -14.57236154      1.0293e-03     0.3673
        9    -14.57236304      1.3825e-08     0.3673
       10    -14.57236304      1.6054e-09     0.3673
    ------------------------------------------------------------


    ============================================================
               One-electron energy  -19.0610711219
                           Kinetic   14.5598880943
                         Potential  -33.6209592162
      --------------------------------------------------------  
               Two-electron energy    4.4887080836
                           Coulomb    7.1543328124
                          Exchange   -2.6656247288
      --------------------------------------------------------  
                           HF HOMO   -8.4100296256
                           HF LUMO    1.5842692516
                      HF LUMO-LUMO    9.9942988772
      --------------------------------------------------------  
               Electronic   energy  -14.5723630383
               Nuclear   repulsion    0.0000000000
               Hartree-Fock energy  -14.5723630383
    ============================================================
    

Out[5]:
val mo_basis : MOBasis.t =
  Eigenvalues:    -4.732765    -0.309063     0.058221     0.058221     0.058221 
               -- 1 --     -- 2 --      -- 3 --      -- 4 --      -- 5 --
       1        1.0006  0.00028918            0            0            0
       2    0.00576322     1.00367            0  1.02041E-15  1.08506E-15
       3   -0.00181801    0.582215            0 -8.39813E-16 -8.40021E-16
                   ...         ...          ...          ...          ...
      13   -0.00209072 -0.00172308  9.60612E-16            0            0
      14             0          -0            0            0            0
      15   -0.00209072 -0.00172308 -1.26705E-15            0  4.17104E-16
  
  Eigenvalues:     0.277480     0.350137     0.350137     0.350137     0.650740 
            -- 6 -- -- 7 --      -- 8 --      -- 9 --     -- 10 --
       1   0.549926       0 -2.88529E-15           -0  8.58482E-16
       2    2.77214       0   -1.582E-14           -0  3.81097E-15
       3     -1.826       0  9.32169E-15           -0 -3.39771E-15
                ...     ...          ...          ...          ...
      13   0.224421       0 -1.20926E-15           -0   -0.0220572
      14          0       0           -0 -1.20416E-15    0.0718784
      15   0.224421       0           -0           -0     0.847943
  
  Eigenvalues:     0.650740     0.650740     0.650740     0.650740     1.188790 
               -- 11 --   -- 12 --    -- 13 --   -- 14 -- -- 15 --
       1   -1.28321E-15          0           0          0 0.516133
       2   -1.06861E-14          0 1.77725E-15          0  4.52711
       3   -1.84016E-15          0 1.31997E-15          0  1.08073
                    ...        ...         ...        ...      ...
      13      -0.964125 -0.0163169    0.262399  0.0292786 -1.45115
      14      0.0475417  0.0403496   0.0724528   0.992822       -0
      15       0.406875   0.061849   -0.328775 -0.0593936 -1.45115
  
  

FCI-F12

In [21]:
let fcif12 =
    F12CI.make ~simulation ~frozen_core:false ~mo_basis ~aux_basis_filename ~state ()
Number of determinants : 105 105 11025
4-idx transformation 
15 / 15
136 significant shell pairs computed in 2.999540 seconds
1
2
3
6
9
15
16
17
18
19
22
25
28
34
40
Computed ERIs in 110.013171 seconds
4-idx transformation 
44 / 44
136 significant shell pairs computed in 0.279177 seconds
1
2
3
6
9
15
16
17
18
19
22
25
28
34
40
Computed ERIs in 8.198963 seconds
4-idx transformation 
44 / 44
Computing HF12 integrals
Exception: Invalid_argument "index out of bounds".
Raised by primitive operation at unknown location
Called from file "CI/CIMatrixElement.ml", line 37, characters 47-66
Called from file "list.ml", line 117, characters 24-34
Called from file "CI/CIMatrixElement.ml", line 37, characters 8-76
Called from file "list.ml", line 88, characters 20-23
Called from file "CI/CI.ml", line 64, characters 2-54
Called from file "CI/CI.ml", line 641, characters 12-44
Called from file "src/vec4_D.ml", line 57, characters 29-32
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from file "CI/CI.ml", line 687, characters 8-112
Called from file "camlinternalLazy.ml", line 27, characters 17-27
Re-raised at file "camlinternalLazy.ml", line 34, characters 10-11
Called from unknown location
Called from file "[21]", line 2, characters 4-85
Called from file "toplevel/toploop.ml", line 180, characters 17-56
In [7]:
%load_ext itikz
File "[7]", line 1, characters 0-1:
Error: Syntax error
   1: %load_ext itikz
In [ ]:

</html>