Skip to content

Commit

Permalink
Cleaning up promolecule nci notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
FanwangM committed Oct 5, 2024
1 parent ef3740f commit 1e93795
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions website/examples/promolecule_nci.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"# # Install packages in Google Colab. \n",
"# # Install packages in Google Colab.\n",
"# # Don't run this cell if packages/data is already in your environment\n",
"# ! pip install git+https://github.com/theochem/iodata.git\n",
"# ! pip install git+https://github.com/theochem/grid.git\n",
Expand Down Expand Up @@ -91,7 +91,7 @@
"from importlib_resources import files\n",
"\n",
"# Load the H2O dimer from a .xyz file\n",
"data_file= 'data/h2o_dimer.xyz'\n",
"data_file = files(atomdb).joinpath(\"../docs/notebooks/data/h2o_dimer.xyz\")\n",
"mol_data = iodata.load_one(data_file)\n",
"\n",
"atnums = mol_data.atcorenums\n",
Expand All @@ -104,8 +104,7 @@
"print(\"Atomic coordinates dimer:\\n\", atcoords)\n",
"\n",
"print(\"Atomic numbers monomer:\\n\", atnums_mono)\n",
"print(\"Atomic coordinates monomer:\\n\", atcoords_mono)\n",
"\n"
"print(\"Atomic coordinates monomer:\\n\", atcoords_mono)"
]
},
{
Expand Down Expand Up @@ -174,8 +173,8 @@
"source": [
"import numpy as np\n",
"\n",
"dimer_promol = atomdb.make_promolecule(atnums=atnums, coords=atcoords, dataset='slater')\n",
"mono_promol = atomdb.make_promolecule(atnums=atnums_mono, coords=atcoords_mono, dataset='slater')\n",
"dimer_promol = atomdb.make_promolecule(atnums=atnums, coords=atcoords, dataset=\"slater\")\n",
"mono_promol = atomdb.make_promolecule(atnums=atnums_mono, coords=atcoords_mono, dataset=\"slater\")\n",
"\n",
"# compute the density and gradient of the density at the grid points\n",
"dimer_rho = dimer_promol.density(cubgrid.points, log=True)\n",
Expand Down Expand Up @@ -233,7 +232,7 @@
"import matplotlib.pyplot as plt\n",
"\n",
"# compute the reduced density gradient for the dimer\n",
"coeff = 2 * (3 * np.pi ** 2) ** (1 / 3)\n",
"coeff = 2 * (3 * np.pi**2) ** (1 / 3)\n",
"dimer_grad_norm = np.linalg.norm(dimer_grad_rho, axis=1)\n",
"dimer_rdg = dimer_grad_norm / (coeff * dimer_rho ** (4 / 3))\n",
"\n",
Expand All @@ -244,10 +243,10 @@
"import matplotlib.pyplot as plt\n",
"\n",
"# Plot the reduced gradient as a function of the density\n",
"plt.scatter(dimer_rho, dimer_rdg, label='Water dimer')\n",
"plt.scatter(mono_rho, mono_rdg, label='Water monomer')\n",
"plt.xlabel(r'$\\rho(R)$')\n",
"plt.ylabel(r'Reduced gradient')\n",
"plt.scatter(dimer_rho, dimer_rdg, label=\"Water dimer\")\n",
"plt.scatter(mono_rho, mono_rdg, label=\"Water monomer\")\n",
"plt.xlabel(r\"$\\rho(R)$\")\n",
"plt.ylabel(r\"Reduced gradient\")\n",
"\n",
"# Set y-axis limits from 0 to 1\n",
"plt.ylim(0, 2)\n",
Expand Down

0 comments on commit 1e93795

Please sign in to comment.