@@ -243,18 +243,19 @@ subroutine gle_init(dt)
243
243
end if
244
244
close (122 )
245
245
246
+ ! WARNING: gA is rewritten here
247
+ ! TODO: do not overwrite gA
246
248
call compute_propagator(gA, gC, gT, gS, dt)
247
249
248
-
249
- ! then, we must initialize the auxiliary vectors. we keep general - as we might be
250
- ! using non-diagonal C to break detailed balance - and we use cholesky decomposition
251
- ! of C. again, since one would like to initialize correctly the velocities in
252
- ! case of generic C, we use an extra slot for gp for the physical momentum, as we
253
- ! could then use it to initialize the momentum in the calling code
250
+ ! Initialize the auxiliary vectors.
251
+ ! we keep general - as we might be using non-diagonal C
252
+ ! to break detailed balance - and we use cholesky decomposition of C
253
+ ! since one would like to initialize correctly the velocities in
254
254
255
255
! DH: ps rewritten in init.f90 if irest.eq.1
256
- ! always initialize, maybe rewritten in restart
257
256
257
+ ! TODO: Do not overwrite gA
258
+ ! TODO: Move this inside initialize_momenta
258
259
gA = gC
259
260
call cholesky(gA, gC, ns+1 )
260
261
@@ -286,9 +287,9 @@ subroutine gle_init(dt)
286
287
end subroutine gle_init
287
288
288
289
subroutine initialize_momenta (C , iw )
289
- ! use mod_arrays, only: px, py, pz
290
+ ! use mod_arrays, only: px, py, pz, vx, vy, vz, amt
290
291
use mod_general, only: natom
291
- use mod_utils, only: abinerror
292
+ use mod_utils, only: abinerror, print_xyz_arrays
292
293
real (DP), intent (in ) :: C(:,:)
293
294
integer , intent (in ) :: iw
294
295
real (DP),allocatable :: gr(:)
@@ -301,14 +302,27 @@ subroutine initialize_momenta(C, iw)
301
302
302
303
allocate (gr(ns+1 ))
303
304
304
- do j= 1 , natom* 3
305
+ do j = 1 , natom * 3
305
306
call gautrg(gr, ns + 1 )
306
- ! TODO, actually pass this to initialize momenta
307
307
gp(j,:) = matmul (C, gr)
308
308
end do
309
309
310
- do j= 1 ,natom* 3
311
- do i= 1 ,ns
310
+ ! TODO, actually pass this to initialize momenta
311
+ ! case of generic C, we use an extra slot for gp for the physical momentum
312
+ ! do i = 1, natom
313
+ ! px(i,iw) = gp(i,1)
314
+ ! py(i,iw) = gp(i + natom,1)
315
+ ! pz(i,iw) = gp(i + 2*natom,1)
316
+ ! end do
317
+ ! vx = px / amt
318
+ ! vy = py / amt
319
+ ! vz = pz / amt
320
+
321
+ ! call print_xyz_arrays(px, py, pz)
322
+ ! call print_xyz_arrays(vx, vy, vz)
323
+
324
+ do j = 1 , natom* 3
325
+ do i = 1 , ns
312
326
ps(j,i,iw) = gp(j,i+1 )
313
327
enddo
314
328
enddo
@@ -330,17 +344,18 @@ subroutine finalize_gle()
330
344
end subroutine finalize_gle
331
345
332
346
347
+ ! Matrix A is rewritten on output
333
348
subroutine compute_propagator (A , C , T , S , dt )
334
- ! Matrix A is rewritten on output
335
349
real (DP), intent (inout ) :: A(:,:)
336
350
real (DP), intent (in ) :: C(:,:)
337
351
real (DP), intent (out ) :: T(:,:), S(:,:)
338
352
real (DP), intent (in ) :: dt
339
353
340
- ! the deterministic part of the propagator is obtained in a second
354
+ ! the deterministic part of the propagator
341
355
call matrix_exp(- dt* A, ns+1 , 15 , 15 , T)
342
356
343
- ! the stochastic part is just as easy. we use gA as a temporary array
357
+ ! the stochastic part, we use A as a temporary array
358
+ ! TODO: Do not overwrite A, makes things confusing
344
359
A = C - matmul (T, matmul (C, transpose (T)) )
345
360
call cholesky(A, S, ns+1 )
346
361
@@ -477,8 +492,8 @@ subroutine matrix_exp(M, n, j, k, EM)
477
492
enddo
478
493
end subroutine matrix_exp
479
494
480
- ! TODO: replace by more stable procedure from i-Py???
481
- ! brute -force "stabilized" cholesky decomposition.
495
+ ! TODO: replace by more stable procedure from i-Py.
496
+ ! Brute -force "stabilized" cholesky decomposition.
482
497
! in practice, we compute LDL^T decomposition, and force
483
498
! to zero negative eigenvalues.
484
499
subroutine cholesky (SST , S , n )
0 commit comments