{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b053468d-38ce-44e1-a037-33d68dfe154d",
"metadata": {},
"outputs": [],
"source": [
"from pyscf import gto, lib\n",
"import numpy as np\n",
"\n",
"np.set_printoptions(16, suppress=False, linewidth=300)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8b7bd1bf-b2a3-4b01-b78c-090bfa9e35d8",
"metadata": {},
"outputs": [],
"source": [
"mol1 = gto.Mole(atom=\"O; H 1 0.94; H 1 0.94 2 104.5\", basis=\"def2-TZVP\").build()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3b8edc24-a96c-43c0-9a3b-0afbc016a404",
"metadata": {},
"outputs": [],
"source": [
"basis = {\n",
" \"C\": \"cc-pVTZ\",\n",
" \"H\": \"cc-pVTZ\",\n",
" \"Sb\": \"cc-pVTZ-PP\",\n",
"}\n",
"\n",
"basis_ecp = {\n",
" \"Sb\": \"cc-pVTZ-PP\",\n",
"}\n",
"\n",
"mol2 = gto.Mole(atom=\"\"\"\n",
"Sb -1.33937843 0.44597852 -1.27279684\n",
"Sb 1.33937843 -0.44597852 -1.27279684\n",
"C -1.40429524 1.10441871 0.83468205\n",
"C -2.16210130 -1.56132398 -0.84717555\n",
"C 2.16210130 1.56132398 -0.84717555\n",
"C 1.40429524 -1.10441871 0.83468205\n",
"H -0.69918639 1.91987631 1.00872018\n",
"H -1.16111477 0.29030616 1.51873028\n",
"H -2.40124532 1.47235562 1.08516843\n",
"H -2.02002046 -2.22909286 -1.69887295\n",
"H -1.69052287 -2.01612927 0.02577778\n",
"H -3.23450854 -1.49489801 -0.65423339\n",
"H 2.02002046 2.22909286 -1.69887295\n",
"H 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.40124532 -1.47235562 1.08516843\n",
"H 1.16111477 -0.29030616 1.51873028\n",
"\"\"\", basis=basis, ecp=basis_ecp).build()"
]
},
{
"cell_type": "markdown",
"id": "90e29984-a4d3-4414-9a57-9835011ba66a",
"metadata": {},
"source": [
"## concat molecules"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e656e8ce-3e9d-4d3c-99ca-add5a515e8a4",
"metadata": {},
"outputs": [],
"source": [
"mol = mol1 + mol1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "8af5565d-a8c5-43be-8199-38e8c05ed1f0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(220.2819072746202, 149.65011901575278, -7210.728997361069, 0.0)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lib.fp(mol._atm), lib.fp(mol._bas), lib.fp(mol._env), lib.fp(mol._ecpbas)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "47125417-ca0c-4ea9-8c73-ec331b333ec5",
"metadata": {},
"outputs": [],
"source": [
"mol = mol1 + mol2"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "65c3873d-af0a-4270-a51f-8a8c8387bdc3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-68.54444636475233,\n",
" -58.06413507172557,\n",
" 26407.797117689446,\n",
" 164.89860996992238)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lib.fp(mol._atm), lib.fp(mol._bas), lib.fp(mol._env), lib.fp(mol._ecpbas)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "57b83e3e-c300-4b05-a6bf-d90d5fb5f4ee",
"metadata": {},
"outputs": [],
"source": [
"mol = mol2 + mol1"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "06658de8-993f-4a0a-a0b6-a71a925dd19b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-714.6455874682379, -99.88753072795852, -32210.1073858801, 110.04541227168156)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lib.fp(mol._atm), lib.fp(mol._bas), lib.fp(mol._env), lib.fp(mol._ecpbas)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a60874a8-2d43-4e67-91fc-17756c27995a",
"metadata": {},
"outputs": [],
"source": [
"mol = mol2 + mol2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "bd05e1b7-71c8-408d-9313-cee3d5cfe64d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1355.7032887239495, -589.9932899367334, 1519.3261601043766, 779.9379788456364)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lib.fp(mol._atm), lib.fp(mol._bas), lib.fp(mol._env), lib.fp(mol._ecpbas)"
]
},
{
"cell_type": "markdown",
"id": "20b8e78a-bbc6-4003-af60-c6d9c56cbc77",
"metadata": {},
"source": [
"## fakemol for charges"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "76c0a126-3595-46a6-985e-696a28b0f690",
"metadata": {},
"outputs": [],
"source": [
"coords = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 1.5, 2.3], [3.0, 4.0, 5.0]]\n",
"exponent = 0.5\n",
"fakemol = gto.fakemol_for_charges(np.array(coords), exponent)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "329c03bc-d326-4e5c-8ff4-5fe97c3ebc2e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(80.41184821237731, 3.9145826029379323, 1.4694722804235696, 0.0)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lib.fp(fakemol._atm), lib.fp(fakemol._bas), lib.fp(fakemol._env), lib.fp(fakemol._ecpbas)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "23847e73-a1d8-486e-bf5f-ca7d8a857f3a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.3218956097258599, (43, 4))"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"out = gto.intor_cross(\"int1e_ovlp\", mol1, fakemol)\n",
"lib.fp(out.T), out.shape"
]
},
{
"cell_type": "markdown",
"id": "0da12fcf-0fb4-4f18-b58c-9d03d6b60f36",
"metadata": {},
"source": [
"## with-clauses"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "17332611-6f04-4401-9135-d6aa764e95f0",
"metadata": {},
"outputs": [],
"source": [
"mol = mol1.copy()"
]
},
{
"cell_type": "markdown",
"id": "a5405564-5a50-4659-b01c-8a7aec673150",
"metadata": {},
"source": [
"### common_orig"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "8e9242ce-59f3-48c1-9f3c-e7d796e34b4d",
"metadata": {},
"outputs": [],
"source": [
"assert abs(lib.fp(mol.intor(\"int1e_r\")) - -0.7587292491644675) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "a16de009-4e02-49d8-8f09-7b567ae91237",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_common_orig([0, 1, 2]):\n",
" assert abs(lib.fp(mol.intor(\"int1e_r\")) - 71.88577867872883) < 1e-10"
]
},
{
"cell_type": "markdown",
"id": "371d8205-33a5-4571-9ab8-4bc0a0125877",
"metadata": {},
"source": [
"### rinv_orig"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "a35c85e9-9e65-4f06-9332-c4bcb25fb1e8",
"metadata": {},
"outputs": [],
"source": [
"assert abs(lib.fp(mol.intor(\"int1e_rinv\")) - 51.806443495904794) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "2ab5e35d-db1a-4773-8c6c-f21e7a531bd6",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_rinv_orig([0, 1, 2]):\n",
" assert abs(lib.fp(mol.intor(\"int1e_rinv\")) - 15.72929399764994) < 1e-10"
]
},
{
"cell_type": "markdown",
"id": "d87dae12-aef9-4fd6-a1a4-9a28e947c496",
"metadata": {},
"source": [
"### rinv_at_nucleus"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "9c2ff815-a841-4db5-b530-06dd4ea7d237",
"metadata": {},
"outputs": [],
"source": [
"assert abs(lib.fp(mol.intor(\"int1e_rinv\")) - 51.806443495904794) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "35f74776-95e9-48f3-8d43-450cd2ce6bec",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_rinv_at_nucleus(1):\n",
" assert abs(lib.fp(mol.intor(\"int1e_rinv\")) - 20.940503856155193) < 1e-10"
]
},
{
"cell_type": "markdown",
"id": "35beeb46-fc06-4a6d-8e61-7ef83b29dfc8",
"metadata": {},
"source": [
"### with_range_coulomb"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "766b7a2d-c19c-4ea8-bff2-2f50c6d39952",
"metadata": {},
"outputs": [],
"source": [
"assert abs(lib.fp(mol.intor(\"int2e\")) - 70.00106603114841) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "50ba6391-752c-4769-852b-9e803c0b7184",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_range_coulomb(0.5):\n",
" assert abs(lib.fp(mol.intor(\"int2e\")) - 23.8282413132626) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "ee1bc984-d23c-4ef8-ad9d-69e010164d3a",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_range_coulomb(-0.5):\n",
" assert abs(lib.fp(mol.intor(\"int2e\")) - 46.17282471793578) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "ab504abb-00df-4de2-a8df-4cee90eefa60",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_long_range_coulomb(0.5):\n",
" assert abs(lib.fp(mol.intor(\"int2e\")) - 23.8282413132626) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "2353a759-ad06-47a1-a5ba-317f481f9ebb",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_short_range_coulomb(0.5):\n",
" assert abs(lib.fp(mol.intor(\"int2e\")) - 46.17282471793578) < 1e-10"
]
},
{
"cell_type": "markdown",
"id": "2375d0dc-f853-47ad-822c-e784181e9e68",
"metadata": {},
"source": [
"### rinv_at_nucleus (ECP)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "3bdd43e5-88d9-438a-96d8-ecfc2c3257b9",
"metadata": {},
"outputs": [],
"source": [
"mol = mol2.copy()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "ca31bbd6-67c9-49a4-ab72-7df739bee1df",
"metadata": {},
"outputs": [],
"source": [
"assert abs(lib.fp(mol.intor(\"ECPscalar_iprinvip\")) - 324.13737563392084) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "d808c463-bebe-4648-b791-2e7565df3cbb",
"metadata": {},
"outputs": [],
"source": [
"with mol.with_rinv_at_nucleus(1):\n",
" assert abs(lib.fp(mol.intor(\"ECPscalar_iprinvip\")) - 302.6772698217352) < 1e-10"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b38e7c4-6774-4282-9ad4-eb6f03d575c9",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ab0abca-599f-4d60-9ce0-6e0d8f941a90",
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}