From 656993b116a7f4ca25502f64e69681f786252ce3 Mon Sep 17 00:00:00 2001 From: Olivier Malenfant-Thuot Date: Thu, 27 Jul 2023 15:17:39 -0400 Subject: [PATCH] added warnings --- mlcalcdriver/workflows/phonon.py | 12 ++++++++---- requirements_dev.txt | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mlcalcdriver/workflows/phonon.py b/mlcalcdriver/workflows/phonon.py index f0cfdef..3395ba6 100644 --- a/mlcalcdriver/workflows/phonon.py +++ b/mlcalcdriver/workflows/phonon.py @@ -4,12 +4,13 @@ learning trained model. """ -import numpy as np -from mlcalcdriver import Job, Posinp from mlcalcdriver.calculators.calculator import Calculator, DummyCalculator +from mlcalcdriver.globals import ANG_TO_B, B_TO_ANG, EV_TO_HA, HA_TO_CMM1, AMU_TO_EMU from mlcalcdriver.workflows import Geopt from copy import deepcopy -from mlcalcdriver.globals import ANG_TO_B, B_TO_ANG, EV_TO_HA, HA_TO_CMM1, AMU_TO_EMU +from mlcalcdriver import Job, Posinp +import numpy as np +import warnings class Phonon: @@ -298,6 +299,9 @@ def _compute_hessian(self, job): ) return (h + h.T) / 2.0 else: + warnings.warn( + "The hessian matrix is approximated by a numerical derivative." + ) hessian = np.zeros((3 * n_at, 3 * n_at)) forces = np.array(job.results["forces"]) * EV_TO_HA * B_TO_ANG for i in range(3 * n_at): @@ -306,7 +310,7 @@ def _compute_hessian(self, job): + forces[4 * i + 3].flatten() + 8 * (forces[4 * i + 1].flatten() - forces[4 * i + 2].flatten()) ) / (12 * self.translation_amplitudes * ANG_TO_B) - return -(hessian + hessian.T) / 2.0 + return -(hessian + hessian.T) / 2.0 def _solve_dyn_mat(self): r""" diff --git a/requirements_dev.txt b/requirements_dev.txt index 03b1b92..a16e00c 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,7 +2,7 @@ pip==23.1.2 wheel==0.40.0 black==23.3.0 flake8==6.0.0 -numpy==1.23.2 +numpy==1.23.0 -f https://download.pytorch.org/whl/cu117/torch_stable.html torch==2.0.1 twine==4.0.2