{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "20d493cf-f68b-4cbc-b272-c57cb612a2a4",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import basis_set_exchange as bse\n",
"from pyscf import gto, lib\n",
"import pyscf.gto.basis.parse_gaussian"
]
},
{
"cell_type": "markdown",
"id": "4cc9b09f-6202-4c47-b7b5-91b4f829c18e",
"metadata": {},
"source": [
"## typical cases"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7f88b3ad-1194-42e2-be6b-299758209bd3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(13, 9, 29.963738021815416, -74.71909470205469)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"simple_h2o_xyz_631g\"\n",
"xyz = \"\"\"\n",
"O 0.0 0.0 1.0\n",
"H 1.2 0.5 1.3\n",
"H -0.7 1.2 0.1\n",
"\"\"\"\n",
"basis = bse.get_basis(\"6-31G\", fmt=\"NWChem\")\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b085ee51-8193-47fa-a306-5185b1e01dfc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(43, 19, 240.82414038242027, -455.36011189734484)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"simple_h2o_zmat_def2tzvp\"\n",
"xyz = \"\"\"\n",
"O; H 1 0.94; H 1 0.94 2 104.5\n",
"\"\"\"\n",
"basis = \"def2-TZVP\"\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "55e20b38-27e4-4494-864f-cb2f675541ea",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(215, 26, 117.86354585363418, -82.98711934741058)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"simple_h2o_xyz_avqz\"\n",
"xyz = \"\"\"\n",
"O 0.0 0.0 1.0\n",
"H 1.2 0.5 1.3\n",
"H -0.7 1.2 0.1\n",
"\"\"\"\n",
"basis = bse.get_basis(\"aug-cc-pVQZ\", fmt=\"NWChem\")\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=True).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "de174dfa-4f27-4a14-8379-0a382463eee7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(127, 27, 26.883841020740512, -100.6569835983665)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"difbas_ch4_zmat\"\n",
"xyz = \"\"\"\n",
"C\n",
"H1 1 1.1\n",
"H 1 1.1 2 109.47\n",
"H2 1 1.1 2 109.47 3 120\n",
"H1 1 1.1 2 109.47 4 120\n",
"\"\"\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"aug-cc-pVQZ\", fmt=\"NWChem\"),\n",
" \"H2\": bse.get_basis(\"def2-TZVP\", fmt=\"NWChem\"),\n",
" \"default\": bse.get_basis(\"6-31G\", fmt=\"NWChem\"),\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=True).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "98aa7d96-65c2-4b8c-bf21-4eb4d7c149a0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(127, 27, 26.883841020740512, -100.6569835983665)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"difbas_ch4_fmthybrid\"\n",
"xyz = \"\"\"\n",
"C\n",
"H1 1 1.1\n",
"H 1 1.1 2 109.47\n",
"H2 1 1.1 2 109.47 3 120\n",
"H1 1 1.1 2 109.47 4 120\n",
"\"\"\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"aug-cc-pVQZ\", fmt=\"NWChem\"),\n",
" \"H2\": bse.get_basis(\"def2-TZVP\", fmt=\"NWChem\"),\n",
" \"default\": bse.get_basis(\"6-31G\", fmt=\"NWChem\"),\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=True).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "b62bd1f4-a21d-412c-b632-7bc1ea24870c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(115, 31, 22.917103194160873, -59.51548379533634)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"ghost_ch4_fmthybrid\"\n",
"xyz = \"\"\"\n",
"C\n",
"H1 1 1.1\n",
"H 1 1.1 2 109.47\n",
"H2 1 1.1 2 109.47 3 120\n",
"H1 1 1.1 2 109.47 4 120\n",
"GHOST-H2 1 1.1 2 50 4 60\n",
"\"\"\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"aug-cc-pVQZ\", fmt=\"NWChem\"),\n",
" \"H2\": bse.get_basis(\"def2-TZVP\", fmt=\"NWChem\"),\n",
" \"GHOST-H2\": bse.get_basis(\"def2-TZVP\", fmt=\"NWChem\"),\n",
" \"default\": bse.get_basis(\"6-31G\", fmt=\"NWChem\"),\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=False).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "4c41b648-90c0-4daa-9bce-a0d5cc4cacb3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(115, 43, 22.917103194160873, -59.51548379533635)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"ghost_ch4_uncontract_general\"\n",
"xyz = \"\"\"\n",
"C\n",
"H1 1 1.1\n",
"H 1 1.1 2 109.47\n",
"H2 1 1.1 2 109.47 3 120\n",
"H1 1 1.1 2 109.47 4 120\n",
"GHOST-H2 1 1.1 2 50 4 60\n",
"\"\"\"\n",
"basis = {\n",
" \"H1\": gto.basis.parse_gaussian.parse(bse.get_basis(\"aug-cc-pVQZ\", fmt=\"gaussian94\", elements=\"H\")),\n",
" \"H2\": gto.basis.parse_gaussian.parse(bse.get_basis(\"def2-TZVP\", fmt=\"gaussian94\", elements=\"H\")),\n",
" \"GHOST-H2\": gto.basis.parse_gaussian.parse(bse.get_basis(\"def2-TZVP\", fmt=\"gaussian94\", elements=\"H\")),\n",
" \"C\": gto.basis.parse_gaussian.parse(bse.get_basis(\"6-31G\", fmt=\"gaussian94\", elements=\"C\")),\n",
" \"H\": gto.basis.parse_gaussian.parse(bse.get_basis(\"6-31G\", fmt=\"gaussian94\", elements=\"H\")),\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=False).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "59908942-2401-4776-9830-2f351251b063",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Warning: Basis not found for atom 2 H\n"
]
},
{
"data": {
"text/plain": [
"(113, 29, 25.5437545117713, -218.53479925755568)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"empty_basis\"\n",
"xyz = \"\"\"\n",
"C\n",
"H1 1 1.1\n",
"H 1 1.1 2 109.47\n",
"H2 1 1.1 2 109.47 3 120\n",
"H1 1 1.1 2 109.47 4 120\n",
"GHOST-H2 1 1.1 2 50 4 60\n",
"\"\"\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"aug-cc-pVQZ\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"H2\": bse.get_basis(\"def2-TZVP\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"GHOST-H2\": bse.get_basis(\"def2-TZVP\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"C\": bse.get_basis(\"6-31G\", fmt=\"nwchem\", elements=\"C\"),\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, cart=False).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\")))"
]
},
{
"cell_type": "markdown",
"id": "2f011b77-97b2-4aa0-82c4-186abb900a68",
"metadata": {},
"source": [
"## ECP"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a27db304-d7c9-4a10-9c54-4ed2160cafeb",
"metadata": {},
"outputs": [],
"source": [
"xyz = \"\"\"\n",
"Sb -1.33937843 0.44597852 -1.27279684\n",
"Sb1 1.33937843 -0.44597852 -1.27279684\n",
"C1 -1.40429524 1.10441871 0.83468205\n",
"C -2.16210130 -1.56132398 -0.84717555\n",
"C2 2.16210130 1.56132398 -0.84717555\n",
"C 1.40429524 -1.10441871 0.83468205\n",
"H1 -0.69918639 1.91987631 1.00872018\n",
"H1 -1.16111477 0.29030616 1.51873028\n",
"H1 -2.40124532 1.47235562 1.08516843\n",
"H1 -2.02002046 -2.22909286 -1.69887295\n",
"H -1.69052287 -2.01612927 0.02577778\n",
"H-1 -3.23450854 -1.49489801 -0.65423339\n",
"H-1 2.02002046 2.22909286 -1.69887295\n",
"H-1 3.23450854 1.49489801 -0.65423339\n",
"H 1.69052287 2.01612927 0.02577778\n",
"H 0.69918639 -1.91987631 1.00872018\n",
"H@2 2.40124532 -1.47235562 1.08516843\n",
"H@2 1.16111477 -0.29030616 1.51873028\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "d076128e-e3bf-4993-828a-127eb81cbbd0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"ECP def2-TZVP not found for H@2\n",
"ECP def2-TZVP not found for H1\n",
"ECP def2-TZVP not found for C\n",
"ECP def2-TZVP not found for H-1\n",
"ECP def2-TZVP not found for H\n",
"ECP def2-TZVP not found for C1\n",
"ECP def2-TZVP not found for C2\n"
]
},
{
"data": {
"text/plain": [
"(296, 124, 46.36693654819834, -85.3713246949453, -382.5298577424865)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"simple_ecp\"\n",
"basis = bse.get_basis(\"def2-TZVP\", fmt=\"nwchem\")\n",
"ecp = \"def2-TZVP\"\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, ecp=ecp).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\"))), float(lib.fp(mol.intor(\"ECPscalar_iprinv\")))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "ed8af19d-5626-40f9-97aa-efcd830526cd",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"ECP lanl2dz not found for H@2\n",
"ECP lanl2dz not found for H1\n",
"ECP lanl2dz not found for C\n",
"ECP lanl2dz not found for H-1\n",
"ECP lanl2dz not found for H\n",
"ECP lanl2dz not found for C1\n",
"ECP lanl2dz not found for C2\n"
]
},
{
"data": {
"text/plain": [
"(296, 124, 46.36693654819834, -101.63816733519229, -356.64926629582527)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"simple_ecp\"\n",
"basis = bse.get_basis(\"def2-TZVP\", fmt=\"nwchem\")\n",
"ecp = \"lanl2dz\"\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, ecp=ecp).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\"))), float(lib.fp(mol.intor(\"ECPscalar_iprinv\")))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "7ec508d7-dde6-4068-a9d5-7ca51b4640f5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(499, 149, 56669463.51097445, -33390.20950360246, 241.4214981674055)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"complicated_ecp\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"2ZaPa-NR\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"H@2\": bse.get_basis(\"AHGBSP1-5\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"C1\": bse.get_basis(\"Ahlrichs VDZ\", fmt=\"nwchem\", elements=\"C\"),\n",
" \"C\": bse.get_basis(\"pcS-3\", fmt=\"nwchem\", elements=\"C\"),\n",
" # PySCF does not count C2 as C\n",
" \"C2\": bse.get_basis(\"pcS-3\", fmt=\"nwchem\", elements=\"C\"),\n",
" \"Sb1\": bse.get_basis(\"dyall-v2z\", fmt=\"nwchem\", elements=\"Sb\"),\n",
" \"default\": bse.get_basis(\"def2-SVP\", fmt=\"nwchem\")\n",
"}\n",
"ecp = {\n",
" \"C2\": \"ECP\" + bse.get_basis(\"pSBKJC\", fmt=\"nwchem\", elements=\"C\").split(\"ECP\")[-1],\n",
" \"Sb1\": \"ECP\" + bse.get_basis(\"lanl2dz\", fmt=\"nwchem\", elements=\"Sb\").split(\"ECP\")[-1],\n",
" # PySCF need to explicitly define ECP separately\n",
" \"Sb\": \"ECP\" + bse.get_basis(\"def2-SVP\", fmt=\"nwchem\", elements=\"Sb\").split(\"ECP\")[-1],\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, ecp=ecp).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\"))), float(lib.fp(mol.intor(\"ECPscalar_iprinv\")))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "98fd032a-0402-45fe-8ba2-99e21fac9318",
"metadata": {},
"outputs": [],
"source": [
"xyz = \"\"\"\n",
"Sb -1.33937843 0.44597852 -1.27279684\n",
"Sb1 1.33937843 -0.44597852 -1.27279684\n",
"C1 -1.40429524 1.10441871 0.83468205\n",
"C -2.16210130 -1.56132398 -0.84717555\n",
"C2 2.16210130 1.56132398 -0.84717555\n",
"C 1.40429524 -1.10441871 0.83468205\n",
"H1 -0.69918639 1.91987631 1.00872018\n",
"H1 -1.16111477 0.29030616 1.51873028\n",
"H1 -2.40124532 1.47235562 1.08516843\n",
"H1 -2.02002046 -2.22909286 -1.69887295\n",
"H -1.69052287 -2.01612927 0.02577778\n",
"H-1 -3.23450854 -1.49489801 -0.65423339\n",
"H-1 2.02002046 2.22909286 -1.69887295\n",
"H-1 3.23450854 1.49489801 -0.65423339\n",
"H 1.69052287 2.01612927 0.02577778\n",
"H 0.69918639 -1.91987631 1.00872018\n",
"H@2 2.40124532 -1.47235562 1.08516843\n",
"H@2 1.16111477 -0.29030616 1.51873028\n",
"GHOST-Sb -2.33937843 1.44597852 -1.27279684\n",
"GHOST-Sb1 2.33937843 -1.44597852 -1.27279684\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "6a16140b-75c6-436d-b6d0-6649cb8a474f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(646, 206, 64220631.18409411, 26146.394518924033, -41.935106631928406)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"case_name = \"ghost_heavy\"\n",
"basis = {\n",
" \"H1\": bse.get_basis(\"2ZaPa-NR\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"H@2\": bse.get_basis(\"AHGBSP1-5\", fmt=\"nwchem\", elements=\"H\"),\n",
" \"C1\": bse.get_basis(\"Ahlrichs VDZ\", fmt=\"nwchem\", elements=\"C\"),\n",
" \"C\": bse.get_basis(\"pcS-3\", fmt=\"nwchem\", elements=\"C\"),\n",
" # PySCF does not count C2 as C\n",
" \"C2\": bse.get_basis(\"pcS-3\", fmt=\"nwchem\", elements=\"C\"),\n",
" \"Sb1\": bse.get_basis(\"dyall-v2z\", fmt=\"nwchem\", elements=\"Sb\"),\n",
" \"GHOST-Sb1\": bse.get_basis(\"dyall-v2z\", fmt=\"nwchem\", elements=\"Sb\"),\n",
" \"default\": bse.get_basis(\"def2-SVP\", fmt=\"nwchem\")\n",
"}\n",
"ecp = {\n",
" \"C2\": \"ECP\" + bse.get_basis(\"pSBKJC\", fmt=\"nwchem\", elements=\"C\").split(\"ECP\")[-1],\n",
" \"Sb1\": \"ECP\" + bse.get_basis(\"lanl2dz\", fmt=\"nwchem\", elements=\"Sb\").split(\"ECP\")[-1],\n",
" # PySCF need to explicitly define ECP separately\n",
" \"Sb\": \"ECP\" + bse.get_basis(\"def2-SVP\", fmt=\"nwchem\", elements=\"Sb\").split(\"ECP\")[-1],\n",
"}\n",
"\n",
"mol = gto.Mole(atom=xyz, basis=basis, ecp=ecp).build()\n",
"mol.nao, mol.nbas, float(lib.fp(mol.intor(\"int1e_kin\"))), float(lib.fp(mol.intor(\"int1e_nuc\"))), float(lib.fp(mol.intor(\"ECPscalar_iprinv\")))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}