Skip to content

Commit 920bf0f

Browse files
committed
WIP: Attempt for better initialize GLE
Does not seem to work so commented out for now. Trying to solve #25
1 parent f7b66e3 commit 920bf0f

File tree

4 files changed

+46
-31
lines changed

4 files changed

+46
-31
lines changed

abin.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ program abin_dyn
9797

9898
! End of transformations
9999

100-
!-----Note that amt equals am if staging is off
100+
! Note that 'amt' equals 'am' for non-PI simulations
101101
px = amt * vx
102102
py = amt * vy
103103
pz = amt * vz

force_tera.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ subroutine connect_terachem( itera )
404404

405405
end if
406406

407-
write(6,'(2a)') 'Establishing connection to TeraChem port: ', trim(port_name)
407+
write(6,'(a)') 'Establishing connection to TeraChem...'
408408
! ----------------------------------------
409409
! Establish new communicator via port name
410410
! ----------------------------------------
411411
call flush(6)
412412
call MPI_COMM_CONNECT(port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF, newcomm, ierr)
413413
call handle_mpi_error(ierr)
414-
write(6,'(a,i0)') 'Established new communicator:', newcomm
414+
write(6,'(a,i0)') 'Established a new communicator:', newcomm
415415

416416
newcomms(itera) = newcomm
417417

gle.F90

+33-18
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,19 @@ subroutine gle_init(dt)
243243
end if
244244
close(122)
245245

246+
! WARNING: gA is rewritten here
247+
! TODO: do not overwrite gA
246248
call compute_propagator(gA, gC, gT, gS, dt)
247249

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
254254

255255
! DH: ps rewritten in init.f90 if irest.eq.1
256-
! always initialize, maybe rewritten in restart
257256

257+
! TODO: Do not overwrite gA
258+
! TODO: Move this inside initialize_momenta
258259
gA = gC
259260
call cholesky(gA, gC, ns+1)
260261

@@ -286,9 +287,9 @@ subroutine gle_init(dt)
286287
end subroutine gle_init
287288

288289
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
290291
use mod_general, only: natom
291-
use mod_utils, only: abinerror
292+
use mod_utils, only: abinerror, print_xyz_arrays
292293
real(DP), intent(in) :: C(:,:)
293294
integer, intent(in) :: iw
294295
real(DP),allocatable :: gr(:)
@@ -301,14 +302,27 @@ subroutine initialize_momenta(C, iw)
301302

302303
allocate(gr(ns+1))
303304

304-
do j=1,natom*3
305+
do j = 1, natom * 3
305306
call gautrg(gr, ns + 1)
306-
! TODO, actually pass this to initialize momenta
307307
gp(j,:) = matmul(C, gr)
308308
end do
309309

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
312326
ps(j,i,iw) = gp(j,i+1)
313327
enddo
314328
enddo
@@ -330,17 +344,18 @@ subroutine finalize_gle()
330344
end subroutine finalize_gle
331345

332346

347+
! Matrix A is rewritten on output
333348
subroutine compute_propagator(A, C, T, S, dt)
334-
! Matrix A is rewritten on output
335349
real(DP), intent(inout) :: A(:,:)
336350
real(DP), intent(in) :: C(:,:)
337351
real(DP), intent(out) :: T(:,:), S(:,:)
338352
real(DP), intent(in) :: dt
339353

340-
! the deterministic part of the propagator is obtained in a second
354+
! the deterministic part of the propagator
341355
call matrix_exp(-dt*A, ns+1, 15, 15, T)
342356

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
344359
A = C - matmul(T, matmul(C, transpose(T)) )
345360
call cholesky(A, S, ns+1)
346361

@@ -477,8 +492,8 @@ subroutine matrix_exp(M, n, j, k, EM)
477492
enddo
478493
end subroutine matrix_exp
479494

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.
482497
! in practice, we compute LDL^T decomposition, and force
483498
! to zero negative eigenvalues.
484499
subroutine cholesky(SST, S, n)

init.F90

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ subroutine init(dt)
6262
character(len=60) :: chdivider
6363
character(len=60) :: mdtype
6464
LOGICAL :: file_exists
65-
logical :: rem_comvel, rem_comrot
65+
logical :: rem_comvel, rem_comrot
6666
! real(DP) :: wnw=5.0d-5
6767
! Used for MPI calls
6868
integer :: ierr
@@ -505,11 +505,11 @@ subroutine init(dt)
505505

506506
if (my_rank.eq.0)then
507507
if (temp0.gt.0)then
508-
write(*,*)'Initial temperature in Kelvins =', temp0
508+
write(*,*)'Initial temperature [K] =', temp0
509509
else
510-
write(*,*)'Initial temperature in Kelvins =', temp
510+
write(*,*)'Initial temperature [K] =', temp
511511
end if
512-
if (inose.ne.0) write(*,*)'Target temperature in Kelvins =', temp
512+
if (inose.ne.0) write(*,*)'Target temperature [K] =', temp
513513
end if
514514

515515
! conversion of temperature from K to au
@@ -574,10 +574,11 @@ subroutine init(dt)
574574

575575
! SETTING initial velocities according to the Maxwell-Boltzmann distribution
576576
if(irest.eq.0.and.chveloc.eq.'')then
577+
! TODO: GLE thermostat, initialize momenta in gle_init
577578
if (temp0.ge.0)then
578-
call vinit(TEMP0, am, vx, vy, vz)
579+
call vinit(temp0, am, vx, vy, vz)
579580
else
580-
call vinit(TEMP, am, vx, vy, vz)
581+
call vinit(temp, am, vx, vy, vz)
581582
end if
582583
end if
583584

@@ -624,12 +625,11 @@ subroutine init(dt)
624625
! Otherwise, just print the temperature.
625626
call ScaleVelocities(vx, vy, vz)
626627

627-
628-
!-----some stuff for spherical boundary onditions
628+
! Initialize spherical boundary onditions
629629
if(isbc.eq.1) call sbc_init(x,y,z)
630630

631-
!-----inames initialization for the MM part.
632-
!-----We do this also because string comparison is very costly
631+
! inames initialization for the MM part.
632+
! We do this also because string comparison is very costly
633633
if(iqmmm.eq.3.or.pot.eq.'mm') allocate( inames(natom) )
634634

635635
if(iqmmm.eq.3.or.pot.eq.'mm')then

0 commit comments

Comments
 (0)