Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extended XYZ file output for static run and structural optimization #318

Merged
merged 7 commits into from
Feb 16, 2024
38 changes: 25 additions & 13 deletions src/control.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
!! Added SQNM maximum step size (sqnm_trust_step) as user-adjustable parameter
!! 2023/09/13 lu
!! Added XSF and XSF output frequency as user-adjustable parameter
!! 2024/01/18 lin
!! Added extended XYZ file output for run types of static, cg, lbfgs, sqnm, and optcell
!! SOURCE
!!
module control
Expand Down Expand Up @@ -152,6 +154,8 @@ subroutine control_run(fixed_potential, vary_mu, total_energy)
flag_opt_cell, optcell_method, min_layer, flag_DM_converged
use input_module, only: leqi
use store_matrix, only: dump_pos_and_matrices
use io_module, only: write_extxyz
use md_control, only: flag_write_extxyz

implicit none

Expand Down Expand Up @@ -184,6 +188,7 @@ subroutine control_run(fixed_potential, vary_mu, total_energy)
endif
call get_E_and_F(fixed_potential, vary_mu, total_energy,&
flag_ff, flag_wf, level=backtrace_level)
if (flag_write_extxyz) call write_extxyz('trajectory.xyz', total_energy, tot_force)
!
else if ( leqi(runtype, 'cg') ) then
if (flag_opt_cell) then
Expand Down Expand Up @@ -491,6 +496,7 @@ subroutine cg_run(fixed_potential, vary_mu, total_energy)
end if
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Analyse forces
g0 = dot(length, tot_force, 1, tot_force, 1)
call get_maxf(max)
Expand Down Expand Up @@ -1504,14 +1510,14 @@ subroutine lbfgs(fixed_potential, vary_mu, total_energy)
use GenBlas, only: dot
use force_module, only: tot_force
use io_module, only: write_atomic_positions, pdb_template, &
check_stop, write_xsf
check_stop, write_xsf, write_extxyz
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use primary_module, only: bundle
use store_matrix, only: dump_pos_and_matrices
use mult_module, ONLY: matK, S_trans, matrix_scale, matL, L_trans
use matrix_data, ONLY: Hrange, Lrange
use dimens, only: r_super_x, r_super_y, r_super_z
use md_control, only: flag_write_xsf
use md_control, only: flag_write_xsf, flag_write_extxyz

implicit none

Expand Down Expand Up @@ -1662,6 +1668,7 @@ subroutine lbfgs(fixed_potential, vary_mu, total_energy)
! Add call to write_atomic_positions and write_xsf (2020/01/17: smujahed)
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Build q
do i=iter, iter_low, -1
! Indexing
Expand Down Expand Up @@ -1792,12 +1799,12 @@ subroutine sqnm(fixed_potential, vary_mu, total_energy)
use GenComms, only: myid, inode, ionode
use GenBlas, only: dot, syev
use force_module, only: tot_force
use io_module, only: write_atomic_positions, pdb_template, &
use io_module, only: write_atomic_positions, pdb_template, write_extxyz, &
check_stop, write_xsf, print_atomic_positions, return_prefix
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use store_matrix, only: dump_pos_and_matrices
use dimens, only: r_super_x, r_super_y, r_super_z
use md_control, only: flag_write_xsf
use md_control, only: flag_write_xsf, flag_write_extxyz

implicit none

Expand Down Expand Up @@ -1971,6 +1978,7 @@ subroutine sqnm(fixed_potential, vary_mu, total_energy)
! Add call to write_atomic_positions and write_xsf (2020/01/17: smujahed)
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Build significant subspace
Sij = zero
omega = zero
Expand Down Expand Up @@ -2204,12 +2212,12 @@ subroutine cell_sqnm(fixed_potential, vary_mu, total_energy)
use GenBlas, only: dot, syev
use force_module, only: stress, tot_force
use io_module, only: write_atomic_positions, pdb_template, &
check_stop, write_xsf, leqi
check_stop, write_xsf, leqi, write_extxyz
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use timer_module
use dimens, ONLY: r_super_x, r_super_y, r_super_z
use store_matrix, only: dump_pos_and_matrices
use md_control, only: target_pressure, flag_write_xsf
use md_control, only: target_pressure, flag_write_xsf, flag_write_extxyz

implicit none

Expand Down Expand Up @@ -2380,6 +2388,7 @@ subroutine cell_sqnm(fixed_potential, vary_mu, total_energy)
! Add call to write_atomic_positions and write_xsf (2020/01/17: smujahed)
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Build significant subspace
Sij = zero
omega = zero
Expand Down Expand Up @@ -2611,14 +2620,14 @@ subroutine full_sqnm(fixed_potential, vary_mu, total_energy)
use GenBlas, only: dot, syev
use force_module, only: tot_force, stress
use io_module, only: write_atomic_positions, pdb_template, &
check_stop, write_xsf
check_stop, write_xsf, write_extxyz
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use primary_module, only: bundle
use store_matrix, only: dump_pos_and_matrices
use mult_module, ONLY: matK, S_trans, matrix_scale, matL, L_trans
use matrix_data, ONLY: Hrange, Lrange
use dimens, only: r_super_x, r_super_y, r_super_z
use md_control, only: flag_write_xsf, target_pressure
use md_control, only: flag_write_xsf, flag_write_extxyz, target_pressure

implicit none

Expand Down Expand Up @@ -2829,6 +2838,7 @@ subroutine full_sqnm(fixed_potential, vary_mu, total_energy)
! Add call to write_atomic_positions and write_xsf (2020/01/17: smujahed)
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Build significant subspace
Sij = zero
omega = zero
Expand Down Expand Up @@ -3068,13 +3078,13 @@ subroutine cell_cg_run(fixed_potential, vary_mu, total_energy)
use GenBlas, only: dot
use force_module, only: stress, tot_force
use io_module, only: write_atomic_positions, pdb_template, &
check_stop, print_atomic_positions, return_prefix
check_stop, print_atomic_positions, return_prefix, write_extxyz
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use timer_module
use io_module, only: leqi
use dimens, ONLY: r_super_x, r_super_y, r_super_z
use store_matrix, only: dump_pos_and_matrices
use md_control, only: target_pressure
use md_control, only: target_pressure, flag_write_extxyz

implicit none

Expand Down Expand Up @@ -3228,7 +3238,7 @@ subroutine cell_cg_run(fixed_potential, vary_mu, total_energy)
rcellx, d_units(dist_units), rcelly, d_units(dist_units), rcellz, d_units(dist_units)
end if
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))

if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)
! Analyse Stresses and energies
dH = enthalpy1 - enthalpy0
volume = rcellx*rcelly*rcellz
Expand Down Expand Up @@ -4119,11 +4129,12 @@ subroutine full_cg_run_single_vector(fixed_potential, vary_mu, total_energy)
use GenBlas, only: dot
use force_module, only: tot_force, stress
use io_module, only: write_atomic_positions, pdb_template, &
check_stop, write_xsf, return_prefix, print_atomic_positions
check_stop, write_xsf, return_prefix, print_atomic_positions, &
write_extxyz
use memory_module, only: reg_alloc_mem, reg_dealloc_mem, type_dbl
use timer_module
use store_matrix, ONLY: dump_InfoMatGlobal, dump_pos_and_matrices
use md_control, only: flag_write_xsf, target_pressure
use md_control, only: flag_write_xsf, flag_write_extxyz, target_pressure

implicit none

Expand Down Expand Up @@ -4295,6 +4306,7 @@ subroutine full_cg_run_single_vector(fixed_potential, vary_mu, total_energy)
end if
call write_atomic_positions("UpdatedAtoms.dat", trim(pdb_template))
if (flag_write_xsf) call write_xsf('trajectory.xsf', iter)
if (flag_write_extxyz .and. mod(iter,XYZfreq) == 0) call write_extxyz('trajectory.xyz', energy1, tot_force)

! Analyse forces and stress
g0 = dot(length-3, tot_force, 1, tot_force, 1)
Expand Down
6 changes: 5 additions & 1 deletion src/initial_read_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,11 @@ subroutine read_input(start, start_L, titles, vary_mu,&
MDn_steps = fdf_integer('AtomMove.NumSteps', 100 )
MDfreq = fdf_integer('AtomMove.OutputFreq', 50 )
XSFfreq = fdf_integer('AtomMove.XsfFreq', MDfreq )
XYZfreq = fdf_integer('AtomMove.XyzFreq', MDfreq )
if (leqi(runtype,'md')) then
XYZfreq = fdf_integer('AtomMove.XyzFreq', MDfreq )
else
XYZfreq = fdf_integer('AtomMove.XyzFreq', 1 )
end if
MDtimestep = fdf_double ('AtomMove.Timestep', 0.5_double)
MDcgtol = fdf_double ('AtomMove.MaxForceTol',0.0005_double)
sqnm_trust_step = fdf_double ('AtomMove.MaxSQNMStep',0.2_double )
Expand Down
Loading