-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
361 additions
and
12 deletions.
There are no files selected for viewing
359 changes: 359 additions & 0 deletions
359
docs/source/ichor_core_examples/summing_over_atomic_multipole_moments.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,359 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Summing over atomic multipole moments to recover molecular multipole moments\n", | ||
"\n", | ||
"Each set of atomic multipole moments (associated with an atom) uses the origin of that atom as the origin of the multipole expansion. In order to sum over the atomic multipole moments to recover the molecular multipole moment, all atomic multipole moments must be shifted to use the exact same origin.\n", | ||
"\n", | ||
"This allows one to compare how well the recovered molecular multipole moment is compared to the true Gaussian molecular multipole moment. Note that Gaussian uses (0,0,0) as the origin. However, this is now always the case, as other programs (for example ORCA) use a different origin for the molecular multipole moment expansion (not (0,0,0)). So care must be taken to ensure that the exact same origin is used. Below, we are comparing to Gaussian, and we assume that the origin is always (0,0,0). The implemented equations can also be used to obtain the molecular or atomic multipole moments with an origin different from (0,0,0).\n", | ||
"\n", | ||
"Note that it is possible to only sum over a fraction of the atoms in a system. Therefore, it is possible to obtain the fragment multipole moments (e.g. the molecular dipole moment of a central water molecule which is surrounded by many other water molecules). I.e. it is possible to obtain \"molecular\" multipole moments of systems that are solvated.\n", | ||
"\n", | ||
"Below are examples of getting the traceless molecular moments from Gaussian and the recovered ones from AIMAll. Note that these are moments are in the Cartesian tensor representation. You can also use ichor to then convert them to spherical tensor representation or to even change the origins of these to some other (if you want to compare to a third program such as ORCA)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Loading Gaussian and AIMAll files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ichor.core.files import GaussianOutput, IntDirectory\n", | ||
"\n", | ||
"gaussian_output = GaussianOutput(\"../../../example_files/example_point_directory/WD0000.pointdir/WD0000.gau\")\n", | ||
"ints_dir = IntDirectory(\"../../../example_files/example_point_directory/WD0000.pointdir/WD0000_atomicfiles\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Recovering Dipole Moment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Gaussian dipole Debye: [ 2.3127 1.7623 -1.2825]\n", | ||
"AIMAll recovered dipole Debye [ 2.31283624 1.76227924 -1.28256335]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from ichor.core.multipoles import get_gaussian_and_aimall_molecular_dipole\n", | ||
"\n", | ||
"gaussian_dipole, aimall_recovered_dipole = get_gaussian_and_aimall_molecular_dipole(gaussian_output, ints_dir)\n", | ||
"\n", | ||
"print(\"Gaussian dipole Debye:\", gaussian_dipole)\n", | ||
"print(\"AIMAll recovered dipole Debye\", aimall_recovered_dipole)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Example of only summing over a specific set of atoms\n", | ||
"\n", | ||
"Summing over a subset of atoms in a system can be done as follows:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"['O1', 'H2', 'H3', 'O4', 'H5', 'H6']\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# determine atom names\n", | ||
"atom_names = gaussian_output.atoms.atom_names\n", | ||
"print(atom_names)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"now that we know the names, let's just sum over the O1, H2, and H3 atoms " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Gaussian dipole Debye: [ 2.3127 1.7623 -1.2825]\n", | ||
"AIMAll recovered dipole Debye [1.07007664 1.43327127 0.04653186]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from ichor.core.multipoles import get_gaussian_and_aimall_molecular_dipole\n", | ||
"\n", | ||
"gaussian_dipole, aimall_recovered_dipole = get_gaussian_and_aimall_molecular_dipole(gaussian_output, ints_dir, atom_names=[\"O1\", \"H2\", \"H3\"])\n", | ||
"\n", | ||
"print(\"Gaussian dipole Debye:\", gaussian_dipole)\n", | ||
"print(\"AIMAll recovered dipole Debye\", aimall_recovered_dipole)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"as you can see, the Gaussian molecular dipole moment stays exactly the same (because Gaussian only gives the molecular dipole moment for the whole system, which in this case is a water dimer). However, the aimall \"fragment\" molecular multipole moment over sums over the O1, H2, and H3 atoms. The exact same procedure can be used for the higher order multipole moments." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Recovering Quadrupole Moment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Gaussian traceless quadrupole, Debye Angstrom:\n", | ||
"[[-3.53026667 -1.3315 0.6097 ]\n", | ||
" [-1.3315 0.60693333 2.486 ]\n", | ||
" [ 0.6097 2.486 2.92333333]]\n", | ||
"AIMAll recovered traceless quadrupole, Debye Angstrom\n", | ||
"[[-3.5304387 -1.33154174 0.60948612]\n", | ||
" [-1.33154174 0.60716953 2.48606843]\n", | ||
" [ 0.60948612 2.48606843 2.92326917]]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from ichor.core.multipoles import get_gaussian_and_aimall_molecular_quadrupole\n", | ||
"\n", | ||
"gaussian_quadrupole, aimall_recovered_quadrupole = get_gaussian_and_aimall_molecular_quadrupole(gaussian_output, ints_dir)\n", | ||
"\n", | ||
"print(\"Gaussian traceless quadrupole, Debye Angstrom:\")\n", | ||
"print(gaussian_quadrupole)\n", | ||
"print(\"AIMAll recovered traceless quadrupole, Debye Angstrom\")\n", | ||
"print(aimall_recovered_quadrupole)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Recovering Octupole Moment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Gaussian traceless octupole, Debye Angstrom^2:\n", | ||
"[[[10.17942 3.51948 5.8568 ]\n", | ||
" [ 3.51948 -3.09276 -4.4422 ]\n", | ||
" [ 5.8568 -4.4422 -7.08666]]\n", | ||
"\n", | ||
" [[ 3.51948 -3.09276 -4.4422 ]\n", | ||
" [-3.09276 5.09964 -2.4823 ]\n", | ||
" [-4.4422 -2.4823 -8.61912]]\n", | ||
"\n", | ||
" [[ 5.8568 -4.4422 -7.08666]\n", | ||
" [-4.4422 -2.4823 -8.61912]\n", | ||
" [-7.08666 -8.61912 -3.3745 ]]]\n", | ||
"AIMAll recovered traceless octupole, Debye Angstrom^2\n", | ||
"[[[10.17918164 3.51974246 5.85720944]\n", | ||
" [ 3.51974246 -3.09299343 -4.44209396]\n", | ||
" [ 5.85720944 -4.44209396 -7.0861882 ]]\n", | ||
"\n", | ||
" [[ 3.51974246 -3.09299343 -4.44209396]\n", | ||
" [-3.09299343 5.09923935 -2.48296655]\n", | ||
" [-4.44209396 -2.48296655 -8.6189818 ]]\n", | ||
"\n", | ||
" [[ 5.85720944 -4.44209396 -7.0861882 ]\n", | ||
" [-4.44209396 -2.48296655 -8.6189818 ]\n", | ||
" [-7.0861882 -8.6189818 -3.37424289]]]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from ichor.core.multipoles import get_gaussian_and_aimall_molecular_octupole\n", | ||
"\n", | ||
"gaussian_octupole, aimall_recovered_octupole = get_gaussian_and_aimall_molecular_octupole(gaussian_output, ints_dir)\n", | ||
"\n", | ||
"print(\"Gaussian traceless octupole, Debye Angstrom^2:\")\n", | ||
"print(gaussian_octupole)\n", | ||
"print(\"AIMAll recovered traceless octupole, Debye Angstrom^2\")\n", | ||
"print(aimall_recovered_octupole)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Recovering Hexadecapole moment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Gaussian traceless hexadecapole, Debye Angstrom^3:\n", | ||
"[[[[ -4.85802286 -14.3341 -21.00351429]\n", | ||
" [-14.3341 3.85986857 -0.49908571]\n", | ||
" [-21.00351429 -0.49908571 0.99815429]]\n", | ||
"\n", | ||
" [[-14.3341 3.85986857 -0.49908571]\n", | ||
" [ 3.85986857 -1.7703 10.35412857]\n", | ||
" [ -0.49908571 10.35412857 16.1044 ]]\n", | ||
"\n", | ||
" [[-21.00351429 -0.49908571 0.99815429]\n", | ||
" [ -0.49908571 10.35412857 16.1044 ]\n", | ||
" [ 0.99815429 16.1044 10.64938571]]]\n", | ||
"\n", | ||
"\n", | ||
" [[[-14.3341 3.85986857 -0.49908571]\n", | ||
" [ 3.85986857 -1.7703 10.35412857]\n", | ||
" [ -0.49908571 10.35412857 16.1044 ]]\n", | ||
"\n", | ||
" [[ 3.85986857 -1.7703 10.35412857]\n", | ||
" [ -1.7703 -14.75476571 -7.47805714]\n", | ||
" [ 10.35412857 -7.47805714 10.89489714]]\n", | ||
"\n", | ||
" [[ -0.49908571 10.35412857 16.1044 ]\n", | ||
" [ 10.35412857 -7.47805714 10.89489714]\n", | ||
" [ 16.1044 10.89489714 7.97714286]]]\n", | ||
"\n", | ||
"\n", | ||
" [[[-21.00351429 -0.49908571 0.99815429]\n", | ||
" [ -0.49908571 10.35412857 16.1044 ]\n", | ||
" [ 0.99815429 16.1044 10.64938571]]\n", | ||
"\n", | ||
" [[ -0.49908571 10.35412857 16.1044 ]\n", | ||
" [ 10.35412857 -7.47805714 10.89489714]\n", | ||
" [ 16.1044 10.89489714 7.97714286]]\n", | ||
"\n", | ||
" [[ 0.99815429 16.1044 10.64938571]\n", | ||
" [ 16.1044 10.89489714 7.97714286]\n", | ||
" [ 10.64938571 7.97714286 -11.89305143]]]]\n", | ||
"AIMAll recovered traceless hexadecapole, Debye Angstrom^3\n", | ||
"[[[[ -4.85674706 -14.33429475 -21.00330269]\n", | ||
" [-14.33429475 3.85965285 -0.49988504]\n", | ||
" [-21.00330269 -0.49988504 0.99709421]]\n", | ||
"\n", | ||
" [[-14.33429475 3.85965285 -0.49988504]\n", | ||
" [ 3.85965285 -1.7695718 10.3548661 ]\n", | ||
" [ -0.49988504 10.3548661 16.10386655]]\n", | ||
"\n", | ||
" [[-21.00330269 -0.49988504 0.99709421]\n", | ||
" [ -0.49988504 10.3548661 16.10386655]\n", | ||
" [ 0.99709421 16.10386655 10.64843659]]]\n", | ||
"\n", | ||
"\n", | ||
" [[[-14.33429475 3.85965285 -0.49988504]\n", | ||
" [ 3.85965285 -1.7695718 10.3548661 ]\n", | ||
" [ -0.49988504 10.3548661 16.10386655]]\n", | ||
"\n", | ||
" [[ 3.85965285 -1.7695718 10.3548661 ]\n", | ||
" [ -1.7695718 -14.75579424 -7.47692049]\n", | ||
" [ 10.3548661 -7.47692049 10.89614139]]\n", | ||
"\n", | ||
" [[ -0.49988504 10.3548661 16.10386655]\n", | ||
" [ 10.3548661 -7.47692049 10.89614139]\n", | ||
" [ 16.10386655 10.89614139 7.97680553]]]\n", | ||
"\n", | ||
"\n", | ||
" [[[-21.00330269 -0.49988504 0.99709421]\n", | ||
" [ -0.49988504 10.3548661 16.10386655]\n", | ||
" [ 0.99709421 16.10386655 10.64843659]]\n", | ||
"\n", | ||
" [[ -0.49988504 10.3548661 16.10386655]\n", | ||
" [ 10.3548661 -7.47692049 10.89614139]\n", | ||
" [ 16.10386655 10.89614139 7.97680553]]\n", | ||
"\n", | ||
" [[ 0.99709421 16.10386655 10.64843659]\n", | ||
" [ 16.10386655 10.89614139 7.97680553]\n", | ||
" [ 10.64843659 7.97680553 -11.8932356 ]]]]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from ichor.core.multipoles import get_gaussian_and_aimall_molecular_hexadecapole\n", | ||
"\n", | ||
"gaussian_hexadecapole, aimall_recovered_hexadecapole = get_gaussian_and_aimall_molecular_hexadecapole(gaussian_output, ints_dir)\n", | ||
"\n", | ||
"print(\"Gaussian traceless hexadecapole, Debye Angstrom^3:\")\n", | ||
"print(gaussian_hexadecapole)\n", | ||
"print(\"AIMAll recovered traceless hexadecapole, Debye Angstrom^3\")\n", | ||
"print(aimall_recovered_hexadecapole)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"##" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "ichor", | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.