Skip to content

Commit c3bee4b

Browse files
committed
The Jupyter notebooks now automatically try to install required 3rd-party-dependencies that live on PIPy.
Signed-off-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
1 parent 4417afa commit c3bee4b

20 files changed

+580
-134535
lines changed

docs/contents/notebooks/adld_dftd4.ipynb

Lines changed: 93 additions & 478 deletions
Large diffs are not rendered by default.

docs/contents/notebooks/adld_hfld.ipynb

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,36 @@
1919
"9. Generating the Cube File."
2020
]
2121
},
22+
{
23+
"cell_type": "markdown",
24+
"id": "858e9ec2-0a90-47e0-adba-e026372ce209",
25+
"metadata": {},
26+
"source": [
27+
"## Step 1: Installing 3rd-party Dependencies"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"id": "723ed3ff-335c-4516-b967-b8b1019ccbc0",
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"import sys\n",
38+
"!{sys.executable} -m pip install --upgrade numpy py3Dmol"
39+
]
40+
},
2241
{
2342
"cell_type": "markdown",
2443
"id": "0e7b75a9",
2544
"metadata": {},
2645
"source": [
27-
"## Step 1: Import Dependencies\n",
46+
"## Step 2: Import Dependencies\n",
2847
"\n",
2948
"We start by importing the modules needed for:\n",
3049
"- Interfacing with ORCA input/output\n",
3150
"- Numerical calculations and data handling\n",
32-
"- Plotting results\n",
33-
"\n",
34-
"> **Note:** We additionally import modules for visualization/plotting like `py3Dmol`. For this, it might be necessary to install `py3Dmol` into your OPI `venv` (e.g., by activating the `.venv` and using `uv pip install py3Dmol`)."
51+
"- Plotting results"
3552
]
3653
},
3754
{
@@ -46,6 +63,8 @@
4663
"\n",
4764
"# > pandas and numpy for data handling\n",
4865
"import numpy as np\n",
66+
"# > For visualization of molecules\n",
67+
"import py3Dmol\n",
4968
"\n",
5069
"# > OPI imports for performing ORCA calculations and reading output\n",
5170
"from opi.core import Calculator\n",
@@ -54,18 +73,15 @@
5473
" Scf, AuxBasisSet, Approximation\n",
5574
"from opi.input.structures.structure import Structure\n",
5675
"from opi.input.blocks import BlockFrag\n",
57-
"from opi.utils.units import AU_TO_KCAL\n",
58-
"\n",
59-
"# > For visualization of molecules\n",
60-
"import py3Dmol"
76+
"from opi.utils.units import AU_TO_KCAL"
6177
]
6278
},
6379
{
6480
"cell_type": "markdown",
6581
"id": "28791864",
6682
"metadata": {},
6783
"source": [
68-
"## Step 2: Working Directory and Conversion Factor\n",
84+
"## Step 3: Working Directory and Conversion Factor\n",
6985
"\n",
7086
"We define a subfolder `adld_hfld` in which the actual ORCA calculations will take place. Also, we define a conversion factor, since we want the resulting interaction energies in kcal/mol for better interpretability."
7187
]
@@ -89,7 +105,7 @@
89105
"id": "5f638574",
90106
"metadata": {},
91107
"source": [
92-
"## Step 3: Setup the Input Structure\n",
108+
"## Step 4: Setup the Input Structure\n",
93109
"\n",
94110
"As an example we will decompose the LD interaction in an cubane dimer. The 3D structure in Cartesian coordinates is defined and visualized:\n"
95111
]
@@ -217,7 +233,7 @@
217233
"id": "951edfa2",
218234
"metadata": {},
219235
"source": [
220-
"## Step 4: Run HFLD for the Supramolecular System\n",
236+
"## Step 5: Run HFLD for the Supramolecular System\n",
221237
"\n",
222238
"We run a HFLD/def2-TZVP calculation for the complete system. We choose the moderate def2-TZVP basis set, because the HFLD London dispersion energy is dependent on the basis and this is a good compromise for computational costs vs. accuracy. The fragments in the calculation will automatically be defined by ORCA (in this example two fragments, one for each monomer). We define and run three helper functions: `setup_calc`, `run_calc`, and `check_and_parse_output`. \n",
223239
"\n",
@@ -348,7 +364,7 @@
348364
"id": "71352834",
349365
"metadata": {},
350366
"source": [
351-
"## Step 5: Processing of ADLD Energies\n",
367+
"## Step 6: Processing of ADLD Energies\n",
352368
"\n",
353369
"Now we perform the post-processing for the ADLD. First, we gather atomic contributions of the LD. "
354370
]
@@ -420,7 +436,7 @@
420436
"id": "feed6238",
421437
"metadata": {},
422438
"source": [
423-
"## Step 6: Crude Visualization of ADLD Contributions\n",
439+
"## Step 7: Crude Visualization of ADLD Contributions\n",
424440
"\n",
425441
"In the original ADLD publication, the `rho_disp` function was evaluated on a grid and the results was written to a `.cube` file for visualization. For the sake of a simple visualization within this notebook, we will first evaluate this function only on the atomic positions and color the atoms by the values at their centers. These plots offer a qualitative analysis of the data and may differ in detail from those published. Further below, we also generate the cube file for the full visualization. We refer the interested reader to the [LDDsuite](https://github.com/bistonigroup/LDDsuite) on GitHub.\n",
426442
"\n",
@@ -627,7 +643,7 @@
627643
"id": "68b8fc69",
628644
"metadata": {},
629645
"source": [
630-
"## Step 7: Generating the Cube File\n",
646+
"## Step 8: Generating the Cube File\n",
631647
"\n",
632648
"For the correct visualization, also the cube file can be generated that might be plotted separately:"
633649
]
@@ -731,7 +747,7 @@
731747
"notebook_metadata_filter": "-all"
732748
},
733749
"kernelspec": {
734-
"display_name": "orca-pi",
750+
"display_name": "Python 3 (ipykernel)",
735751
"language": "python",
736752
"name": "python3"
737753
},
@@ -745,7 +761,7 @@
745761
"name": "python",
746762
"nbconvert_exporter": "python",
747763
"pygments_lexer": "ipython3",
748-
"version": "3.11.11"
764+
"version": "3.14.3"
749765
}
750766
},
751767
"nbformat": 4,

docs/contents/notebooks/atomic_fukui_indices.ipynb

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,31 @@
1818
"6. 3D Visualization of Fukui Functions"
1919
]
2020
},
21+
{
22+
"cell_type": "markdown",
23+
"id": "58ced5af-c115-4f4e-b027-f2f755a557ba",
24+
"metadata": {},
25+
"source": [
26+
"## Step 1: Installing 3rd-party Dependencies"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"id": "5dd025a9-6b8f-4a37-898c-315df496252e",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"import sys\n",
37+
"!{sys.executable} -m pip install --upgrade numpy py3Dmol"
38+
]
39+
},
2140
{
2241
"cell_type": "markdown",
2342
"id": "7d7a65f3",
2443
"metadata": {},
2544
"source": [
26-
"## Step 1: Import Dependencies\n",
45+
"## Step 2: Import Dependencies\n",
2746
"\n",
2847
"We start by importing the modules needed for:\n",
2948
"- Interfacing with ORCA input/output\n",
@@ -47,24 +66,23 @@
4766
"\n",
4867
"# > Import numpy for data handling and numerical operations\n",
4968
"import numpy as np\n",
69+
"# > Import libraries for visualization\n",
70+
"import py3Dmol\n",
71+
"from IPython.display import display, HTML\n",
5072
"\n",
5173
"# > OPI imports for performing ORCA calculations and reading output\n",
5274
"from opi.core import Calculator\n",
5375
"from opi.output.core import Output\n",
5476
"from opi.input.simple_keywords import BasisSet, Dft, DispersionCorrection\n",
55-
"from opi.input.structures.structure import Structure\n",
56-
"\n",
57-
"# > Import libraries for visualization\n",
58-
"import py3Dmol\n",
59-
"from IPython.display import display, HTML"
77+
"from opi.input.structures.structure import Structure"
6078
]
6179
},
6280
{
6381
"cell_type": "markdown",
6482
"id": "19d64ad1",
6583
"metadata": {},
6684
"source": [
67-
"## Step 2: Define Working directory\n",
85+
"## Step 3: Define Working directory\n",
6886
"\n",
6987
"All actual calculations will be performed in a subfolder `atomic_fukui_indices`."
7088
]
@@ -88,7 +106,7 @@
88106
"id": "0feaf89a",
89107
"metadata": {},
90108
"source": [
91-
"## Step 3: Setup an Input Structure\n",
109+
"## Step 4: Setup an Input Structure\n",
92110
"\n",
93111
"We use formaldehyde as our example molecule. The 3D structure in Cartesian coordinates is defined in XYZ format and visualized."
94112
]
@@ -185,7 +203,7 @@
185203
"id": "b2dd2579",
186204
"metadata": {},
187205
"source": [
188-
"## Step 4: ORCA Calculations\n",
206+
"## Step 5: ORCA Calculations\n",
189207
"\n",
190208
"We perform single-point energy calculations for three electronic states of the molecule:\n",
191209
"- Neutral (default)\n",
@@ -368,7 +386,7 @@
368386
"id": "33e27272",
369387
"metadata": {},
370388
"source": [
371-
"## Step 5: Charge Extraction and Fukui Function Computation"
389+
"## Step 6: Charge Extraction and Fukui Function Computation"
372390
]
373391
},
374392
{
@@ -421,7 +439,7 @@
421439
"id": "870c0c4c",
422440
"metadata": {},
423441
"source": [
424-
"## Step 6: 3D Visualization of Fukui Functions"
442+
"## Step 7: 3D Visualization of Fukui Functions"
425443
]
426444
},
427445
{
@@ -759,7 +777,7 @@
759777
],
760778
"metadata": {
761779
"kernelspec": {
762-
"display_name": "orca-pi",
780+
"display_name": "Python 3 (ipykernel)",
763781
"language": "python",
764782
"name": "python3"
765783
},
@@ -773,7 +791,7 @@
773791
"name": "python",
774792
"nbconvert_exporter": "python",
775793
"pygments_lexer": "ipython3",
776-
"version": "3.12.3"
794+
"version": "3.14.3"
777795
}
778796
},
779797
"nbformat": 4,

docs/contents/notebooks/chemeleon_orca.ipynb

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,31 @@
2626
"This featurizer is best used from Python code, but you can add it to your local installation of Chemprop to make it accessible via the CLI."
2727
]
2828
},
29+
{
30+
"cell_type": "markdown",
31+
"id": "26119eb8-4bc1-4313-9a32-daa0c0b26fd2",
32+
"metadata": {},
33+
"source": [
34+
"## Step 1: Installing 3rd-party Dependencies"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"id": "8efe1d96-068a-40ad-9f61-7de42c887405",
41+
"metadata": {},
42+
"outputs": [],
43+
"source": [
44+
"import sys\n",
45+
"!{sys.executable} -m pip install --upgrade pandas chemprop"
46+
]
47+
},
2948
{
3049
"cell_type": "markdown",
3150
"id": "03dacd04",
3251
"metadata": {},
3352
"source": [
34-
"## Step 1: Data Loading\n",
53+
"## Step 2: Data Loading\n",
3554
"\n",
3655
"First we'll load the training data for this study, which are HOMO-LUMO gaps calculated at the GW level of theory (very accurate)."
3756
]
@@ -223,7 +242,7 @@
223242
"id": "10850cc7",
224243
"metadata": {},
225244
"source": [
226-
"## Step 2: `featurizer` Setup\n",
245+
"## Step 3: `featurizer` Setup\n",
227246
"\n",
228247
"Next we need to set up the `featurizer`, which is Chemprop's way of translating a molecular structure, atom, or bond into a computer-readable vector.\n",
229248
"\n",
@@ -250,6 +269,7 @@
250269
"from rdkit import Chem\n",
251270
"from rdkit.Chem import AllChem\n",
252271
"from rdkit.Chem import rdDistGeom\n",
272+
"\n",
253273
"from opi.core import Calculator\n",
254274
"from opi.input.simple_keywords import BasisSet, Wft\n",
255275
"from opi.input.structures.structure import Structure\n"
@@ -434,7 +454,7 @@
434454
"id": "5227704f",
435455
"metadata": {},
436456
"source": [
437-
"## Step 3: Chemprop Training\n",
457+
"## Step 4: Chemprop Training\n",
438458
"\n",
439459
"Now we will get Chemprop set up, including:\n",
440460
" - `import`s for required classes\n",
@@ -1018,7 +1038,7 @@
10181038
"id": "4ed3d337",
10191039
"metadata": {},
10201040
"source": [
1021-
"## Step 4: Visualizing Results\n",
1041+
"## Step 5: Visualizing Results\n",
10221042
"\n",
10231043
"Using `matplotlib` we can compare how well the Force Field//Hartree-Fock+STO-3G HOMO-LUMO gaps and their CheMeleon-improved versions compare against the 'true' values from the GW dataset.\n",
10241044
"We've downsampled this dataset significantly for the purpose of a quick demo, but the same point still comes across!"
@@ -1114,7 +1134,7 @@
11141134
"notebook_metadata_filter": "-all"
11151135
},
11161136
"kernelspec": {
1117-
"display_name": "opi",
1137+
"display_name": "Python 3 (ipykernel)",
11181138
"language": "python",
11191139
"name": "python3"
11201140
},
@@ -1128,7 +1148,7 @@
11281148
"name": "python",
11291149
"nbconvert_exporter": "python",
11301150
"pygments_lexer": "ipython3",
1131-
"version": "3.12.3"
1151+
"version": "3.14.3"
11321152
}
11331153
},
11341154
"nbformat": 4,

0 commit comments

Comments
 (0)