QCaml/Notebooks/F12_matrix.ipynb

591 lines
25 KiB
Plaintext
Raw Normal View History

2019-11-30 10:41:07 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test of F12 matrix elements"
]
},
{
2019-12-02 14:58:48 +01:00
"cell_type": "markdown",
2019-11-30 10:41:07 +01:00
"metadata": {},
2019-12-02 14:58:48 +01:00
"source": [
"## Initialization"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
2019-11-30 10:41:07 +01:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"- : unit = ()\n",
"Findlib has been successfully loaded. Additional directives:\n",
" #require \"package\";; to load a package\n",
" #list;; to list the available packages\n",
" #camlp4o;; to load camlp4 (standard syntax)\n",
" #camlp4r;; to load camlp4 (revised syntax)\n",
" #predicates \"p,q,...\";; to set these predicates\n",
" Topfind.reset();; to force that packages will be reloaded\n",
" #thread;; to enable threads\n",
"\n",
"- : unit = ()\n"
]
2019-12-02 14:58:48 +01:00
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/scemama/qp2/external/opam/4.07.1/lib/bytes: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/base64: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/base64/base64.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ocaml/compiler-libs: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/result: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/result/result.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ppx_deriving/runtime: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ppx_deriving/runtime/ppx_deriving_runtime.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ppx_deriving_yojson/runtime: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ppx_deriving_yojson/runtime/ppx_deriving_yojson_runtime.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ocaml/unix.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/uuidm: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/uuidm/uuidm.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/easy-format: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/easy-format/easy_format.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/biniou: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/biniou/biniou.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/yojson: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/yojson/yojson.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/jupyter: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/jupyter/jupyter.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/jupyter/notebook: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/jupyter/notebook/jupyter_notebook.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ocaml/bigarray.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/lacaml: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/lacaml/lacaml.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/astring: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/astring/astring.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/cmdliner: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/cmdliner/cmdliner.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/seq: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/stdlib-shims: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/stdlib-shims/stdlib_shims.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/fmt: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/fmt/fmt.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/fmt/fmt_cli.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/fmt/fmt_tty.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/alcotest: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/alcotest/alcotest.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/ocaml/str.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/zarith: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/zarith/zarith.cma: loaded\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/getopt: added to search path\n",
"/home/scemama/qp2/external/opam/4.07.1/lib/getopt/getopt.cma: loaded\n"
]
2019-11-30 10:41:07 +01:00
}
],
"source": [
"#cd \"/home/scemama/QCaml\";;\n",
"#use \"topfind\";;\n",
"#require \"jupyter.notebook\";;\n",
"\n",
"#require \"lacaml\";;\n",
"#require \"alcotest\";;\n",
2019-12-02 14:58:48 +01:00
"#require \"str\";;\n",
"#require \"bigarray\";;\n",
2019-11-30 10:41:07 +01:00
"#require \"zarith\";;\n",
"#require \"getopt\";;\n",
"#directory \"_build\";;\n",
"#directory \"_build/Basis\";;\n",
"#directory \"_build/CI\";;\n",
"#directory \"_build/MOBasis\";;\n",
"#directory \"_build/Nuclei\";;\n",
"#directory \"_build/Parallel\";;\n",
"#directory \"_build/Perturbation\";;\n",
"#directory \"_build/SCF\";;\n",
2019-12-02 14:58:48 +01:00
"#directory \"_build/Utils\";;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Modules to load"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
2019-11-30 10:41:07 +01:00
"#load \"Constants.cmo\";;\n",
"#load_rec \"Util.cma\";;\n",
"#load_rec \"Matrix.cmo\";;\n",
"#load_rec \"Simulation.cmo\";;\n",
2019-12-02 14:58:48 +01:00
"#load_rec \"Simulation.cmo\";;\n",
"#load_rec \"HartreeFock.cmo\";;\n",
"\n",
"open Lacaml.D;;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Printers"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"#install_printer AngularMomentum.pp_string ;;\n",
"#install_printer Basis.pp ;;\n",
"#install_printer Charge.pp ;;\n",
"#install_printer Coordinate.pp ;;\n",
"#install_printer Vector.pp;;\n",
"#install_printer Matrix.pp;;\n",
"#install_printer Util.pp_float_2darray;;\n",
"#install_printer Util.pp_float_array;;\n",
"#install_printer Util.pp_matrix;;\n",
"#install_printer HartreeFock.pp ;;\n",
"#install_printer Fock.pp ;;\n"
2019-11-30 10:41:07 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2019-12-02 14:58:48 +01:00
"## Run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Simulation\n"
2019-11-30 10:41:07 +01:00
]
},
{
"cell_type": "code",
2019-12-02 14:58:48 +01:00
"execution_count": 4,
2019-11-30 10:41:07 +01:00
"metadata": {},
"outputs": [
{
2019-12-02 14:58:48 +01:00
"data": {
"text/plain": [
"val basis_filename : string = \"/home/scemama/qp2/data/basis/cc-pvdz\"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val aux_basis_filename : string = \"/home/scemama/qp2/data/basis/cc-pvtz\"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val nuclei : Nuclei.t = [|(Element.Be, 0.0000 0.0000 0.0000)|]\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val basis : Basis.t =\n",
" \n",
" Atomic Basis set\n",
" ----------------\n",
"\n",
"-----------------------------------------------------------------------\n",
" # Angular Coordinates (Bohr) Exponents Coefficients\n",
" Momentum X Y Z\n",
"-----------------------------------------------------------------------\n",
" 1-3 S 0.0000 0.0000 0.0000 2.94000000e+03 6.80000000e-04\n",
" 4.41200000e+02 5.23600000e-03\n",
" 1.00500000e+02 2.66060000e-02\n",
" 2.84300000e+01 9.99930000e-02\n",
" 9.16900000e+00 2.69702000e-01\n",
" 3.19600000e+00 4.51469000e-01\n",
" 1.15900000e+00 2.95074000e-01\n",
" 1.81100000e-01 1.25870000e-02\n",
" \n",
" 2.94000000e+03 -1.23000000e-04\n",
" 4.41200000e+02 -9.66000000e-04\n",
" 1.00500000e+02 -4.83100000e-03\n",
" 2.84300000e+01 -1.93140000e-02\n",
" 9.16900000e+00 -5.32800000e-02\n",
" 3.19600000e+00 -1.20723000e-01\n",
" 1.15900000e+00 -1.33435000e-01\n",
" 1.81100000e-01 5.30767000e-01\n",
" \n",
" 5.89000000e-02 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
" 4-9 P 0.0000 0.0000 0.0000 3.61900000e+00 2.91110000e-02\n",
" 7.11000000e-01 1.69365000e-01\n",
" 1.95100000e-01 5.13458000e-01\n",
" \n",
" 6.01800000e-02 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
" 10-15 D 0.0000 0.0000 0.0000 2.38000000e-01 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val aux_basis : Basis.t =\n",
" \n",
" Atomic Basis set\n",
" ----------------\n",
"\n",
"-----------------------------------------------------------------------\n",
" # Angular Coordinates (Bohr) Exponents Coefficients\n",
" Momentum X Y Z\n",
"-----------------------------------------------------------------------\n",
" 1-7 S 0.0000 0.0000 0.0000 2.94000000e+03 6.80000000e-04\n",
" 4.41200000e+02 5.23600000e-03\n",
" 1.00500000e+02 2.66060000e-02\n",
" 2.84300000e+01 9.99930000e-02\n",
" 9.16900000e+00 2.69702000e-01\n",
" 3.19600000e+00 4.51469000e-01\n",
" 1.15900000e+00 2.95074000e-01\n",
" 1.81100000e-01 1.25870000e-02\n",
" \n",
" 2.94000000e+03 -1.23000000e-04\n",
" 4.41200000e+02 -9.66000000e-04\n",
" 1.00500000e+02 -4.83100000e-03\n",
" 2.84300000e+01 -1.93140000e-02\n",
" 9.16900000e+00 -5.32800000e-02\n",
" 3.19600000e+00 -1.20723000e-01\n",
" 1.15900000e+00 -1.33435000e-01\n",
" 1.81100000e-01 5.30767000e-01\n",
" \n",
" 5.89000000e-02 1.00000000e+00\n",
" \n",
" 6.86300000e+03 2.36000000e-04\n",
" 1.03000000e+03 1.82600000e-03\n",
" 2.34700000e+02 9.45200000e-03\n",
" 6.65600000e+01 3.79570000e-02\n",
" 2.16900000e+01 1.19965000e-01\n",
" 7.73400000e+00 2.82162000e-01\n",
" 2.91600000e+00 4.27404000e-01\n",
" 1.13000000e+00 2.66278000e-01\n",
" 1.10100000e-01 -7.27500000e-03\n",
" \n",
" 6.86300000e+03 -4.30000000e-05\n",
" 1.03000000e+03 -3.33000000e-04\n",
" 2.34700000e+02 -1.73600000e-03\n",
" 6.65600000e+01 -7.01200000e-03\n",
" 2.16900000e+01 -2.31260000e-02\n",
" 7.73400000e+00 -5.81380000e-02\n",
" 2.91600000e+00 -1.14556000e-01\n",
" 1.13000000e+00 -1.35908000e-01\n",
" 1.10100000e-01 5.77441000e-01\n",
" \n",
" 2.57700000e-01 1.00000000e+00\n",
" \n",
" 4.40900000e-02 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
" 4-18 P 0.0000 0.0000 0.0000 3.61900000e+00 2.91110000e-02\n",
" 7.11000000e-01 1.69365000e-01\n",
" 1.95100000e-01 5.13458000e-01\n",
" \n",
" 6.01800000e-02 1.00000000e+00\n",
" \n",
" 7.43600000e+00 1.07360000e-02\n",
" 1.57700000e+00 6.28540000e-02\n",
" 4.35200000e-01 2.48180000e-01\n",
" \n",
" 1.43800000e-01 1.00000000e+00\n",
" \n",
" 4.99400000e-02 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
" 10-27 D 0.0000 0.0000 0.0000 2.38000000e-01 1.00000000e+00\n",
" \n",
" 3.48000000e-01 1.00000000e+00\n",
" \n",
" 1.80300000e-01 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
" 41-50 F 0.0000 0.0000 0.0000 3.25000000e-01 1.00000000e+00\n",
" \n",
" \n",
"-----------------------------------------------------------------------\n",
"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val f12 : F12factor.t =\n",
" {F12factor.expo_s = 1.;\n",
" gaussian =\n",
" {GaussianOperator.coef_g =\n",
" [ -0.314400 -0.303700 -0.168100 -0.098110 -0.060240 -0.037260 ];\n",
" expo_sg =\n",
" [ 0.220900 1.004000 3.622000 12.160000 45.870000 254.400000 ];\n",
" expo_sg_inv =\n",
" [ 4.526935 0.996016 0.276091 0.082237 0.021801 0.003931 ]}}\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val charge : int = 0\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
2019-11-30 10:41:07 +01:00
},
{
"data": {
"text/plain": [
2019-12-02 14:58:48 +01:00
"val multiplicity : int = 1\n"
2019-11-30 10:41:07 +01:00
]
},
2019-12-02 14:58:48 +01:00
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"val simulation : Simulation.t = <abstr>\n"
]
},
"execution_count": 4,
2019-11-30 10:41:07 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2019-12-02 14:58:48 +01:00
"let basis_filename = \"/home/scemama/qp2/data/basis/cc-pvdz\" \n",
"let aux_basis_filename = \"/home/scemama/qp2/data/basis/cc-pvtz\" \n",
"let nuclei = Nuclei.of_zmt_string \"be\" \n",
2019-11-30 10:41:07 +01:00
"\n",
2019-12-02 14:58:48 +01:00
"let basis = Basis.of_nuclei_and_basis_filenames ~nuclei [basis_filename] \n",
"let aux_basis = Basis.of_nuclei_and_basis_filenames ~nuclei (basis_filename :: aux_basis_filename :: []) \n",
"let f12 = F12factor.gaussian_geminal 1.0 \n",
"let charge = 0 \n",
"let multiplicity = 1 \n",
2019-11-30 10:41:07 +01:00
"\n",
"\n",
"let simulation =\n",
2019-12-02 14:58:48 +01:00
" Simulation.make \n",
" ~f12 ~charge ~multiplicity ~nuclei\n",
" ~cartesian:true\n",
" basis\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hartree-Fock"
2019-11-30 10:41:07 +01:00
]
},
{
"cell_type": "code",
2019-12-02 14:58:48 +01:00
"execution_count": 7,
2019-11-30 10:41:07 +01:00
"metadata": {},
"outputs": [
{
2019-12-02 14:58:48 +01:00
"name": "stdout",
"output_type": "stream",
"text": [
"MOs =\n",
"\n",
"\n",
" -- 1 -- -- 2 -- -- 3 -- -- 4 -- -- 5 --\n",
" 1 1.0006 0.00028918 -0 -0 0\n",
" 2 0.00576322 1.00367 -7.13815E-16 -0 0\n",
" 3 -0.00181801 0.582215 4.68436E-16 -6.48338E-16 0\n",
" ... ... ... ... ...\n",
" 13 -0.00209072 -0.00172308 -0 -0 0\n",
" 14 -0 -0 -0 -0 0\n",
" 15 -0.00209072 -0.00172308 -0 -8.65517E-16 0\n",
" \n",
"\n",
" -- 6 -- -- 7 -- -- 8 -- -- 9 -- -- 10 --\n",
" 1 0.549926 -7.88204E-16 0 0 -5.10457E-16\n",
" 2 2.77214 -4.20928E-15 0 -8.18142E-16 -6.26457E-16\n",
" 3 -1.826 2.68321E-15 0 0 4.82834E-15\n",
" ... ... ... ... ...\n",
" 13 0.224421 0 0 0 -0.995373\n",
" 14 -0 0 0 0 -0.00304009\n",
" 15 0.224421 0 0 0 0.534433\n",
" \n",
"\n",
" -- 11 -- -- 12 -- -- 13 -- -- 14 -- -- 15 --\n",
" 1 -8.47272E-16 4.18722E-16 0 0 0.516133\n",
" 2 -7.29877E-15 3.26085E-15 -5.13582E-16 0 4.52711\n",
" 3 -1.53999E-15 0 0 0 1.08073\n",
" ... ... ... ... ...\n",
" 13 0.0741226 0.0584492 -0.01795 0.000120624 -1.45115\n",
" 14 0.00668622 0.201298 0.848372 -0.489582 0\n",
" 15 0.750441 -0.380516 0.0792247 -0.0122393 -1.45115\n",
" \n"
2019-11-30 10:41:07 +01:00
]
2019-12-02 14:58:48 +01:00
},
{
"data": {
"text/plain": [
"val hf : HartreeFock.t = \n",
"======================================================================\n",
" Restricted Hartree-Fock \n",
"======================================================================\n",
"\n",
" ------------------------------------------------------------\n",
" # HF energy Convergence HOMO-LUMO\n",
" ------------------------------------------------------------\n",
" 1 -14.05142130 8.0958e-01 0.2991\n",
" 2 -14.51982122 2.7933e-01 0.3600\n",
" 3 -14.56519147 8.3990e-02 0.3674\n",
" 4 -14.57117146 2.6217e-02 0.3679\n",
" 5 -14.57214606 1.0744e-02 0.3676\n",
" 6 -14.57232209 5.0392e-03 0.3675\n",
" 7 -14.57235521 2.2956e-03 0.3674\n",
" 8 -14.57236154 1.0293e-03 0.3673\n",
" 9 -14.57236304 4.1738e-08 0.3673\n",
" 10 -14.57236304 4.9181e-09 0.3673\n",
" ------------------------------------------------------------\n",
"\n",
"\n",
" ============================================================\n",
" One-electron energy -19.0610711155\n",
" Kinetic 14.5598880887\n",
" Potential -33.6209592042\n",
" -------------------------------------------------------- \n",
" Two-electron energy 4.4887080772\n",
" Coulomb 7.1543328046\n",
" Exchange -2.6656247274\n",
" -------------------------------------------------------- \n",
" HF HOMO -8.4100296422\n",
" HF LUMO 1.5842692336\n",
" HF LUMO-LUMO 9.9942988758\n",
" -------------------------------------------------------- \n",
" Electronic energy -14.5723630383\n",
" Nuclear repulsion 0.0000000000\n",
" Hartree-Fock energy -14.5723630383\n",
" ============================================================\n",
" \n",
"\n"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
2019-11-30 10:41:07 +01:00
}
],
2019-12-02 14:58:48 +01:00
"source": [
"let hf = \n",
" HartreeFock.make ~guess:`Hcore simulation \n"
]
2019-11-30 10:41:07 +01:00
},
{
"cell_type": "code",
2019-12-02 14:58:48 +01:00
"execution_count": 8,
2019-11-30 10:41:07 +01:00
"metadata": {},
2019-12-02 14:58:48 +01:00
"outputs": [
{
"data": {
"text/plain": [
"val ints : ERI.t = <abstr>\n"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"- : float = 0.\n"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
2019-11-30 10:41:07 +01:00
"source": [
2019-12-02 14:58:48 +01:00
"let ints = Simulation.ao_basis simulation\n",
"|> AOBasis.ee_ints ;;\n",
"ERI.get_phys ints 1 1 1 4"
2019-11-30 10:41:07 +01:00
]
2019-12-02 14:58:48 +01:00
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2019-11-30 10:41:07 +01:00
}
],
"metadata": {
"kernelspec": {
2019-12-02 14:58:48 +01:00
"display_name": "OCaml 4.07.1",
2019-11-30 10:41:07 +01:00
"language": "OCaml",
"name": "ocaml-jupyter"
},
"language_info": {
"codemirror_mode": "text/x-ocaml",
"file_extension": ".ml",
"mimetype": "text/x-ocaml",
"name": "OCaml",
"nbconverter_exporter": null,
"pygments_lexer": "OCaml",
"version": "4.07.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}