From 34e5e1d724f5d51cb77ce04292191b626cf3f35b Mon Sep 17 00:00:00 2001 From: Logan Ward Date: Mon, 4 Dec 2023 15:41:33 -0500 Subject: [PATCH] Remove translation and rotational modes, sample w/ replacement --- .../3_displace-along-vibrational-modes.ipynb | 41 ++++++++++++++++++- .../run-all-methods.sh | 2 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/notebooks/1_explore-sampling-methods/3_displace-along-vibrational-modes.ipynb b/notebooks/1_explore-sampling-methods/3_displace-along-vibrational-modes.ipynb index 097b41f..54078d9 100644 --- a/notebooks/1_explore-sampling-methods/3_displace-along-vibrational-modes.ipynb +++ b/notebooks/1_explore-sampling-methods/3_displace-along-vibrational-modes.ipynb @@ -176,6 +176,27 @@ "evalues, emodes = np.linalg.eigh(vib_data.get_hessian_2d())" ] }, + { + "cell_type": "markdown", + "id": "31bada31-2ea3-47b0-80d4-5bc98a4115ae", + "metadata": {}, + "source": [ + "Remove the six smallest eignvalues, which should be zero" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7c3ca6eb-dca1-4bab-8f7d-6c42ce429400", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "evalues = evalues[6:]\n", + "emodes = emodes[6:, :]" + ] + }, { "cell_type": "markdown", "id": "78563dd5-c6da-46d8-9b99-4928187023da", @@ -270,6 +291,24 @@ "print(f'Need to run {to_compute} calculations for full accuracy.')" ] }, + { + "cell_type": "markdown", + "id": "ed1742cd-45a7-44e4-8a38-ebf3d0ed321d", + "metadata": {}, + "source": [ + "Reduce the number of perturbations if too large" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "09e27062-59c4-421c-9de5-f5457bf0ad32", + "metadata": {}, + "outputs": [], + "source": [ + "perturbs_per_evaluation = min(scaled_modes.shape[0], perturbs_per_evaluation)" + ] + }, { "cell_type": "markdown", "id": "ad4c5d8e-96d4-4bb6-9bf2-6474d7563448", @@ -381,7 +420,7 @@ "iterator = tqdm(range(to_compute - num_done))\n", "for i in iterator:\n", " # Choose a number of perturbation vectors\n", - " to_disp = rng.choice(scaled_modes.shape[0], size=(perturbs_per_evaluation,))\n", + " to_disp = rng.choice(scaled_modes.shape[0], size=(perturbs_per_evaluation,), replace=False)\n", " \n", " # Pick a random magnitude for each\n", " disp = (scaled_modes[to_disp, :] * rng.uniform(-1, 1, size=(perturbs_per_evaluation, 1))).sum(axis=0)\n", diff --git a/notebooks/1_explore-sampling-methods/run-all-methods.sh b/notebooks/1_explore-sampling-methods/run-all-methods.sh index 55b6c58..42eea5d 100644 --- a/notebooks/1_explore-sampling-methods/run-all-methods.sh +++ b/notebooks/1_explore-sampling-methods/run-all-methods.sh @@ -17,7 +17,7 @@ done # Test with the vibrational modes notebook=3_displace-along-vibrational-modes.ipynb for step_size in 0.001 0.002; do - for n in 8 16 32; do + for n in 16 32 64; do papermill -p starting_geometry $xyz -p perturbs_per_evaluation $n -p step_size $step_size $notebook last.ipynb done done