@@ -110,10 +110,10 @@ SUBROUTINE vb_anal(input, input_declaration, para_env, globenv)
110110 CHARACTER(LEN=default_string_length) :: description_d, description_p
111111 INTEGER :: handle, i, icoord, icoordm, icoordp, ierr, imap, iounit, ip1, ip2, iparticle1, &
112112 iparticle2, iseq, iw, j, k, natoms, ncoord, nfrozen, nrep, nres, nRotTrM, nvib, &
113- output_unit, output_unit_eig, prep, print_grrm, print_scine, proc_dist_type
113+ output_unit, output_unit_eig, prep, print_grrm, print_namd, print_scine, proc_dist_type
114114 INTEGER, DIMENSION(:), POINTER :: Clist, Mlist
115115 LOGICAL :: calc_intens, calc_thchdata, do_mode_tracking, intens_ir, intens_raman, &
116- keep_rotations, lprint_namd, row_force, something_frozen
116+ keep_rotations, row_force, something_frozen
117117 REAL(KIND=dp) :: a1, a2, a3, conver, dummy, dx, &
118118 inertia(3), minimum_energy, norm, &
119119 tc_press, tc_temp, tmp
@@ -167,7 +167,7 @@ SUBROUTINE vb_anal(input, input_declaration, para_env, globenv)
167167 CALL section_vals_val_get(vib_section, "THERMOCHEMISTRY", l_val=calc_thchdata)
168168 CALL section_vals_val_get(vib_section, "TC_TEMPERATURE", r_val=tc_temp)
169169 CALL section_vals_val_get(vib_section, "TC_PRESSURE", r_val=tc_press)
170- CALL section_vals_val_get(vib_section, "NAMD_PRINT", l_val=lprint_namd)
170+
171171 tc_temp = tc_temp*kelvin
172172 tc_press = tc_press*pascal
173173
@@ -520,6 +520,52 @@ SUBROUTINE vb_anal(input, input_declaration, para_env, globenv)
520520 END IF
521521 CALL cp_print_key_finished_output(print_scine, logger, force_env_section, "PRINT%SCINE")
522522 !
523+ ! Print NEWTONX interface file
524+ print_namd = cp_print_key_unit_nr(logger, print_section, "NAMD_PRINT", &
525+ extension=".eig", file_status="REPLACE", &
526+ file_action="WRITE", do_backup=.TRUE., &
527+ file_form="UNFORMATTED")
528+ IF (print_namd > 0) THEN
529+ ! NewtonX requires normalized Cartesian frequencies and eigenvectors
530+ ! in full matrix format (ncoord x ncoord)
531+ NULLIFY (Dfull)
532+ ALLOCATE (Dfull(ncoord, ncoord))
533+ ALLOCATE (Hint2Dfull(SIZE(Dfull, 2), SIZE(Dfull, 2)))
534+ ALLOCATE (HeigvalDfull(SIZE(Dfull, 2)))
535+ ALLOCATE (MatM(ncoord, ncoord))
536+ ALLOCATE (rmass(SIZE(Dfull, 2)))
537+ Dfull = 0.0_dp
538+ ! Dfull in dimension of degrees of freedom
539+ CALL build_D_matrix(RotTrM, nRotTrM, Dfull, full=.TRUE., natoms=natoms)
540+ ! TEST MatM = MATMUL(TRANSPOSE(Dfull),Dfull)= 1
541+ ! Hessian in MWC -> Hessian in INT (Hint2Dfull)
542+ Hint2Dfull(:, :) = MATMUL(TRANSPOSE(Dfull), MATMUL(Hessian, Dfull))
543+ ! Heig = L^T Hint2Dfull L
544+ CALL diamat_all(Hint2Dfull, HeigvalDfull)
545+ ! TEST MatM = MATMUL(TRANSPOSE(Hint2Dfull),Hint2Dfull) = 1
546+ ! TEST MatM=MATMUL(TRANSPOSE(MATMUL(Dfull,Hint2Dfull)),MATMUL(Dfull,Hint2Dfull)) = 1
547+ MatM = 0.0_dp
548+ DO i = 1, natoms
549+ DO j = 1, 3
550+ MatM((i - 1)*3 + j, (i - 1)*3 + j) = 1.0_dp/mass(i) ! mass is sqrt(mass)
551+ END DO
552+ END DO
553+ ! Dfull = Cartesian displacements of the normal modes
554+ Dfull = MATMUL(MatM, MATMUL(Dfull, Hint2Dfull)) !Dfull=D L / sqrt(m)
555+ DO i = 1, ncoord
556+ ! Renormalize displacements
557+ norm = 1.0_dp/SUM(Dfull(:, i)*Dfull(:, i))
558+ rmass(i) = norm/massunit
559+ Dfull(:, i) = SQRT(norm)*(Dfull(:, i))
560+ END DO
561+ CALL write_eigs_unformatted(print_namd, ncoord, HeigvalDfull, Dfull)
562+ DEALLOCATE (HeigvalDfull)
563+ DEALLOCATE (Hint2Dfull)
564+ DEALLOCATE (Dfull)
565+ DEALLOCATE (MatM)
566+ DEALLOCATE (rmass)
567+ END IF !print_namd
568+ !
523569 nvib = ncoord - nRotTrM
524570 ALLOCATE (H_eigval1(ncoord))
525571 ALLOCATE (H_eigval2(SIZE(D, 2)))
@@ -552,35 +598,7 @@ SUBROUTINE vb_anal(input, input_declaration, para_env, globenv)
552598 END IF
553599 ! write frequencies and eigenvectors to cartesian eig file
554600 IF (output_unit_eig > 0) THEN
555- IF (lprint_namd) THEN
556- ! NewtonX requires normalized Cartesian frequencies and eigenvectors
557- ! in full matrix format (ncoord x ncoord)
558- NULLIFY (Dfull)
559- ALLOCATE (Dfull(ncoord, ncoord))
560- ALLOCATE (Hint2Dfull(SIZE(Dfull, 2), SIZE(Dfull, 2)))
561- ALLOCATE (HeigvalDfull(SIZE(Dfull, 2)))
562- ALLOCATE (MatM(ncoord, ncoord))
563- Dfull = 0.0_dp
564- CALL build_D_matrix(RotTrM, nRotTrM, Dfull, full=.TRUE., natoms=natoms)
565- Hint2Dfull(:, :) = MATMUL(TRANSPOSE(Dfull), MATMUL(Hessian, Dfull)) ! MWC -> INT
566- CALL diamat_all(Hint2Dfull, HeigvalDfull)
567- MatM = 0.0_dp
568- DO i = 1, natoms
569- DO j = 1, 3
570- MatM((i - 1)*3 + j, (i - 1)*3 + j) = 1.0_dp/mass(i)
571- END DO
572- END DO
573- ! Cartesian displacements of the normal modes
574- Dfull = MATMUL(MatM, MATMUL(Dfull, Hint2Dfull)) !!! this is !D L / sqrt(m)
575- ! CALL write_eigs_unformatted(output_unit_eig, ncoord, H_eigval1, Dfull)
576- CALL write_eigs_unformatted(output_unit_eig, ncoord, HeigvalDfull, Dfull)
577- DEALLOCATE (HeigvalDfull)
578- DEALLOCATE (Hint2Dfull)
579- DEALLOCATE (Dfull)
580- DEALLOCATE (MatM)
581- END IF
582- CALL write_eigs_unformatted(output_unit_eig, &
583- ncoord, H_eigval1, Hint1)
601+ CALL write_eigs_unformatted(output_unit_eig, ncoord, H_eigval1, Hint1)
584602 END IF
585603 IF (nvib /= 0) THEN
586604 Hint2(:, :) = MATMUL(TRANSPOSE(D), MATMUL(Hessian, D))
0 commit comments