Skip to content

Commit 921d7e0

Browse files
authored
Merge pull request #256 from DaehoHan/ldr
Fix coefficient initialization in LDR
2 parents e545f92 + c9fa4db commit 921d7e0

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/libra_py/dynamics/ldr_torch/compute.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# *********************************************************************************
2-
# * Copyright (C) 2025 Alexey V. Akimov
2+
# * Copyright (C) 2025 Daeho Han and Alexey V. Akimov
33
# *
44
# * This file is distributed under the terms of the GNU General Public License
55
# * as published by the Free Software Foundation, either version 3 of
@@ -18,13 +18,13 @@
1818
List of classes:
1919
* ldr_solver
2020
21-
.. moduleauthor:: Alexey V. Akimov, Daeho Han
21+
.. moduleauthor:: Daeho Han and Alexey V. Akimov
2222
2323
"""
2424

25-
__author__ = "Alexey V. Akimov"
25+
__author__ = "Daeho Han, Alexey V. Akimov"
2626
__copyright__ = "Copyright 2025 Alexey V. Akimov"
27-
__credits__ = ["Alexey V. Akimov"]
27+
__credits__ = ["Daeho Han", "Alexey V. Akimov"]
2828
__license__ = "GNU-3"
2929
__version__ = "1.0"
3030
__maintainer__ = "Alexey V. Akimov"
@@ -184,23 +184,38 @@ def initialize_C(self):
184184
Initialize coefficient vector self.C0 at t=0, assuming:
185185
- electronic state self.istate
186186
- nuclear wavefunction is a Gaussian centered at self.q0 and self.p0, i.e.
187-
chi0 = exp( alpha0 * (qgrid point - self.q0)**2 + i * self.p0 * (qgrid point - self.q0) )
187+
chi0(q;q0,p0) = exp( - alpha0 * (q - self.q0)**2 + i * self.p0 * (q - self.q0) )
188188
alpha0 = 0.5/s_q **2; s_q = (1/(self.k * self.mass)) **0.25
189+
190+
For the Gaussian overlap calculation, consult with the formula in Begušić, T.; Vaníček, J. J. Chem. Phys. 2020, 153 (18), 184110.
191+
189192
Sets:
190193
self.C0 : complex-valued coefficient vector of shape (ndim)
191194
"""
192195
N, ist = self.ngrids, self.istate
193196

194-
s_q = (1.0/(self.k*self.mass)) ** 0.25
195-
alpha0 = 1/(2*s_q**2)
197+
q0 = self.q0.to(torch.cdouble)
198+
p0 = self.p0.to(torch.cdouble)
199+
qgrid = self.qgrid.to(torch.cdouble)
200+
alpha = self.alpha.to(torch.cdouble)
201+
202+
s_q = (1.0 / (self.k*self.mass) ) ** 0.25
203+
alpha0 = 1 / ( 2 * s_q **2 )
204+
alpha0 = alpha0.to(torch.cdouble)
205+
206+
# Width matrix
207+
Ag, A = torch.diag(2.j * self.alpha), torch.diag(2.j * alpha0)
208+
delta_A = A - Ag.conj()
209+
delta_A_inv = torch.torch.linalg.inv(delta_A)
196210

197211
# Compute Gaussian nuclear wavefunction at each grid point
198212
for n in range(N):
199213
index = ist * N + n
200214

201-
qn = self.qgrid[n] # (D,)
202-
delta = qn - self.q0 # (D,)
203-
exponent = -torch.dot(alpha0, delta**2) + .1j * torch.dot(self.p0, delta)
215+
xi0, xig = p0 - torch.matmul(A, q0), -torch.matmul(Ag, qgrid[n])
216+
delta_xi = xi0 - xig.conj()
217+
delta_eta = -0.5 * torch.dot(xi0 + p0, q0) + 0.5 * torch.dot(xig, qgrid[n]).conj()
218+
exponent = -1.j * 0.5 * torch.dot(delta_xi, torch.matmul(delta_A_inv, delta_xi)) + 1.j * delta_eta
204219

205220
self.C0[index] = torch.exp(exponent)
206221

0 commit comments

Comments
 (0)