Skip to content
This repository was archived by the owner on May 5, 2026. It is now read-only.

Commit ef6eb06

Browse files
authored
Add files via upload
1 parent 9296fcc commit ef6eb06

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

multioptpy/ModelHessian/o1numhess.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
class O1NumHessCalculator:
1313
"""
1414
O1NumHess: Semi-numerical Hessian generation using Optimal 1-sided differentiation.
15-
Ref: https://doi.org/10.1021/acs.jctc.5c01354, https://doi.org/10.48550/arXiv.2508.07544
16-
17-
Notice:
18-
This implementation is experimental and lacks formal validation against the performance benchmarks established in the original paper.
19-
It is intended for reference only and does not serve as a basis for contesting the validity of the referenced methodology, regardless of the performance outcomes.
15+
Ref: https://doi.org/10.1021/acs.jctc.5c01354
2016
2117
CORRECTED VERSION - Fixes:
2218
1. Added initial 7 displacement directions (translations, rotations, breathing)
@@ -171,6 +167,7 @@ def compute_hessian(self, current_coords_ang):
171167
for i in range(ndispl_final):
172168
# Displacement: x_new = x0 + delta * d
173169
d_vec = displdir[:, i]
170+
d_vec_norm = np.linalg.norm(d_vec)
174171

175172
# Skip translations (indices 0-2): gradient is always zero
176173
if i < 3:
@@ -183,19 +180,19 @@ def compute_hessian(self, current_coords_ang):
183180

184181
# FIXED: Double-sided differentiation for breathing mode (index 6)
185182
if i == 6:
186-
x_fwd_bohr = x0_bohr + self.delta * d_vec
183+
x_fwd_bohr = x0_bohr + self.delta * d_vec / d_vec_norm
187184
x_fwd_ang = x_fwd_bohr.reshape(-1, 3) * self.bohr2ang
188185
g_fwd = self._get_gradient(x_fwd_ang).flatten()
189186

190-
x_bwd_bohr = x0_bohr - self.delta * d_vec
187+
x_bwd_bohr = x0_bohr - self.delta * d_vec / d_vec_norm
191188
x_bwd_ang = x_bwd_bohr.reshape(-1, 3) * self.bohr2ang
192189
g_bwd = self._get_gradient(x_bwd_ang).flatten()
193190

194191
# Central difference
195192
g_displ[:, i] = (g_fwd - g_bwd) / (2.0 * self.delta)
196193
else:
197194
# Single-sided differentiation for other directions
198-
x_new_bohr = x0_bohr + self.delta * d_vec
195+
x_new_bohr = x0_bohr + self.delta * d_vec / d_vec_norm
199196
x_new_ang = x_new_bohr.reshape(-1, 3) * self.bohr2ang
200197
g_new = self._get_gradient(x_new_ang).flatten()
201198

0 commit comments

Comments
 (0)