Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OMalenfantThuot/ML_Calc_Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
OMalenfantThuot committed Jul 27, 2023
2 parents 4ff8707 + 5a3948a commit 77bc595
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions mlcalcdriver/workflows/phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77bc595

Please sign in to comment.