Add notebook

This commit is contained in:
Anthony Scemama 2020-04-21 12:28:27 +02:00
parent af0a46dcd7
commit 88f6b2549f
3 changed files with 1076 additions and 396 deletions

View File

@ -1,396 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jastrow factors"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## H2O"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"onedet = \"Jastrows/H2O/H2O-cc-pcvTz.wfj-1det_J2.ud_exp.dat\"\n",
"os = 1.-7.92535494e-01\n",
"\n",
"multidet = \"Jastrows/H2O/H2O-cc-pcvTz-multidet.wfj_J2.ud_exp.dat\"\n",
"ms = 1.-8.59001137e-01\n",
"\n",
"onedet_H = \"Jastrows/H2O/H2O-cc-pcvTz.wfj-1det_J1.H_exp.dat\"\n",
"ohs = 1.-1.03221118e+00\n",
"onedet_O = \"Jastrows/H2O/H2O-cc-pcvTz.wfj-1det_J1.O_exp.dat\"\n",
"oos = 1.-1.43887500e+00\n",
"\n",
"#onedet = \"Jastrows/N2H4/N2H4-tr6.wfj_J2.ud_exp.dat\"\n",
"#os = 1.-8.03464242e-01\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set yrange [1:1.4]\n",
"set xrange [0:3]\n",
"set grid\n",
"set xlabel \"r_{12} (a.u.)\"\n",
"set format y \"%.2f\"\n",
"set format x \"%.1f\"\n",
"set key bottom right\n",
"\n",
"plot onedet u 1:($2+os) w l title \"HF\"\\\n",
", multidet u 1:($2+ms) w l title \"FCI\"\n",
"\n",
"set yrange [0:1]\n",
"plot onedet_O u 1:($2+oos) w l title \"O\"\\\n",
", onedet_H u 1:($2+ohs) w l title \"H\"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"f1(x) = exp(a_1 * x/(1. + b_1*x))\n",
"f2(x) = exp(a_2 * x/(1. + b_2*x))\n",
"f3(x) = exp(a_3 * x**2+b_3)\n",
"f4(x) = exp(a_4 * x**2+b_4)\n",
"a_1 = 0.5\n",
"a_2 = 0.5\n",
"a_3 = 0.5\n",
"a_4 = 0.5\n",
"b_1 = 1.\n",
"b_2 = 1.\n",
"b_3 = 1.\n",
"b_4 = 1.\n",
"\n",
"fit f1(x) onedet u 1:($2+os) via b_1\n",
"fit f2(x) multidet u 1:($2+ms) via b_2\n",
"fit [0:1] f3(x) onedet_O u 1:($2+oos) via a_3, b_3\n",
"fit [0:1] f4(x) onedet_H u 1:($2+ohs) via a_4, b_4\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set xrange [0:3]\n",
"set yrange [1.:1.3]\n",
"set grid\n",
"set xlabel \"r_{12} (a.u.)\"\n",
"set format y \"%.2f\"\n",
"set format x \"%.1f\"\n",
"set key bottom right\n",
"\n",
"plot onedet u 1:($2+os) w l title \"HF\"\\\n",
", multidet u 1:($2+ms) w l title \"FCI\"\\\n",
", f1(x) title \"exp(- 0.5 r_{12} / (1. + 1.93 r_{12}))\"\\\n",
", f2(x) title \"exp(- 0.5 r_{12} / (1. + 3.99 r_{12}))\"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set xrange [0:1]\n",
"set yrange [0.6:1.]\n",
"set grid\n",
"set xlabel \"r_{12} (a.u.)\"\n",
"set format y \"%.2f\"\n",
"set format x \"%.1f\"\n",
"set key bottom right\n",
"\n",
"plot onedet_O u 1:($2+oos) w l title \"O\"\\\n",
", onedet_H u 1:($2+ohs) w l title \"H\"\\\n",
", f3(x) title \"exp(- 0.5 r_{12} / (1. + 1.93 r_{12}))\"\\\n",
", f4(x) title \"exp(- 0.5 r_{12} / (1. + 3.99 r_{12}))\"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#set term pdf font \"Times,15pt\"\n",
"#set output \"jastrow_h2o.pdf\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Range-separated Coulomb operator"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"w(x) = 1./x\n",
"w_lr(mu,x) = erf(mu*x)/x\n",
"w_sr(mu,x) = w(x) - w_lr(mu,x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set xrange [0:4]\n",
"set yrange [0:3]\n",
"set key top right\n",
"plot w(x) title '1/r_{12}',\\\n",
" w_lr(0.5,x) title '{/Symbol m}=0.5' ls 2,\\\n",
" w_sr(0.5,x) notitle ls 2, \\\n",
" w_lr(1.0,x) title '{/Symbol m}=1.0' ls 4,\\\n",
" w_sr(1.0,x) notitle ls 4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DMC Energies"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Single-determinant"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = \"Jastrows/data_dmc\"\n",
"set key top right\n",
"set xrange [0:7.5]\n",
"set xlabel \"{/Symbol m} (a.u.)\"\n",
"set ylabel \"Energy (a.u.)\"\n",
"set format y \"%.4f\"\n",
"set yrange [-76.4115:-76.4095]\n",
"plot data index 0 u 1:5:6 w errorlines title \"1 det / cc-pVDZ\"\n",
"set yrange [-76.4215:-76.4195]\n",
"plot data index 1 u 1:5:6 w errorlines title \"1 det / cc-pVTZ\"\n",
"set yrange [-76.4232:-76.4212]\n",
"plot data index 2 u 1:5:6 w errorlines title \"1 det / cc-pVQZ\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Multi-determinant"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = \"Jastrows/data_dmc\"\n",
"set key top right\n",
"set xrange [0:7.5]\n",
"set xlabel \"{/Symbol m} (a.u.)\"\n",
"set ylabel \"Energy (a.u.)\"\n",
"set format y \"%.3f\"\n",
"set yrange [-76.44:-76.405]\n",
"plot data index 0 u 1:7:8 w errorlines title \"CIPSI / cc-pVDZ\", \\\n",
"data index 1 u 1:7:8 w errorlines title \"CIPSI / cc-pVTZ\", \\\n",
"data index 2 u 1:7:8 w errorlines title \"CIPSI / cc-pVQZ\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Fit $\\mu$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"-----\n",
"$\\Psi(r_1,\\dots,r_N)$ is a CI trial wave function:\n",
"$$\n",
"|\\Psi \\rangle = \\sum_{I \\in \\mathcal{B}} c_I |I\\rangle\n",
"$$\n",
"When running a FN-DMC calculation, the fixed-node wave function can be written as $\\Phi(r_1,\\dots,r_N) = \\Psi(r_1,\\dots,r_N)\\times w(r_1,\\dots,r_N)$, where $w$ is a positive function, such that\n",
"$$\n",
"E = \\min_w \\frac{ \\langle w \\Psi | H | \\Psi \\rangle } {\\langle w \\Psi | \\Psi \\rangle}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We want to find the change in the potential that would model the effect of the FN-DMC. This corresponds to removing some short-range potential:\n",
"\n",
"$$\n",
"\\frac{ \\langle w \\Psi | V_{ee} | w \\Psi \\rangle } {\\langle w \\Psi | w \\Psi \\rangle} = \n",
"\\frac{ \\langle \\Psi | V_{ee} - \\delta V_{ee} | \\Psi \\rangle } {\\langle \\Psi | \\Psi \\rangle} \n",
"$$\n",
"where\n",
"\n",
"$$\n",
"V_{ee} = \\frac{1}{r_{12}} \n",
"$$\n",
"and\n",
"$$\n",
"\\delta V_{ee} = \n",
"\\alpha \\left( \\frac{1}{r_{12}} - \\frac{\\text{erf}( \\mu r_{12})}{r_{12}} \\right).\n",
"$$\n",
"\n",
"\n",
"$$\n",
"\\frac{ \\langle w \\Psi | V_{ee} | w \\Psi \\rangle } {\\langle w \\Psi | w \\Psi \\rangle} = \n",
"\\frac{ \\langle \\Psi | V_{ee} | \\Psi \\rangle } {\\langle \\Psi | \\Psi \\rangle} -\n",
"\\alpha \\frac{ \\langle \\Psi | V_{ee} | \\Psi \\rangle } {\\langle \\Psi | \\Psi \\rangle} +\n",
"\\alpha \\frac{ \\langle \\Psi | V_{ee}^{lr} | \\Psi \\rangle } {\\langle \\Psi | \\Psi \\rangle} \n",
"$$\n",
"\n",
"$$\n",
"\\frac{\\langle \\Psi | w^2 V_{ee} | \\Psi \\rangle}\n",
"{\\langle w \\Psi | w \\Psi \\rangle}\n",
"=\n",
"(1-\\alpha) \\langle \\Psi | V_{ee} | \\Psi \\rangle +\n",
"\\alpha \\langle \\Psi | V_{ee}^{lr} | \\Psi \\rangle \n",
"$$\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\n",
"w^2 = \\left[ (1-\\alpha) + \\alpha\\, \\text{erf}(\\mu\\, r_{12}) \\right]\\langle w \\Psi | w \\Psi \\rangle\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To find the parameter $\\mu$, we minimize\n",
"$$\n",
"\\int \\left|a\\, \\text{erf}(\\mu\\,r_{12}) + b - w(r_{12})^2 \\right|^2 \\text{d}r_{12}\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set yrange [1:1.3]\n",
"set xrange [0:3]\n",
"set grid\n",
"set xlabel \"r_{12} (a.u.)\"\n",
"set format y \"%.2f\"\n",
"set format x \"%.1f\"\n",
"set key bottom right\n",
"\n",
"f(x) = (a * (erf(mu*x)) +b)\n",
"mu = 2.\n",
"b=1.\n",
"a = 1.\n",
"fit f(x) multidet u 1:( ($2+ms)**2 ) via a, b, mu\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot f(x), multidet u 1:( ($2+ms)**2) title \"{/Symbol m}=3.05\" w l"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"set yrange [1:1.7]\n",
"set xrange [0:2.5]\n",
"set grid\n",
"set xlabel \"r_{12} (a.u.)\"\n",
"set format y \"%.2f\"\n",
"set format x \"%.1f\"\n",
"set key bottom right\n",
"\n",
"f(x) = (a * (erf(mu*x)) +b)\n",
"mu = 2.\n",
"b=1.\n",
"a = 1.\n",
"fit f(x) onedet u 1:( ($2+os)**2) via a, b, mu\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot f(x), onedet u 1:( ($2+os)**2 ) title \"{/Symbol m}=0.94\" w l"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "gnuplot",
"language": "gnuplot",
"name": "gnuplot"
},
"language_info": {
"codemirror_mode": "Octave",
"file_extension": ".gp",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://metakernel.readthedocs.io/en/latest/source/README.html"
}
],
"mimetype": "text/x-gnuplot",
"name": "gnuplot"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

1076
Data/Notebook.ipynb Normal file

File diff suppressed because one or more lines are too long

BIN
Data/Notebook.pdf Normal file

Binary file not shown.