Skip to content

Commit 21b3350

Browse files
committedNov 28, 2023
Merge commit 'a5e8d853b08bff237d3b29ee9cbbcfea459c65a9'
2 parents b5bc687 + a5e8d85 commit 21b3350

15 files changed

+3612
-0
lines changed
 

‎patches/qespresso-7.2.config

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
3+
function plumed_preliminary_test(){
4+
# check if the README.md contains the word ESPRESSO and if qe has been already configured
5+
grep -q ESPRESSO README.md 1>/dev/null 2>/dev/null && test -f make.inc
6+
}
7+
8+
function plumed_before_patch(){
9+
cp make.inc make.inc.plumedbck
10+
PWD=`pwd`
11+
echo "include ${PWD}/Plumed.inc ">make.inc
12+
awk '{if($1=="QELIBS" && $2=="="){sub("=","= $(PLUMED_LOAD)"); print}else{print }}' make.inc.plumedbck >> make.inc
13+
}
14+
15+
function plumed_after_revert(){
16+
mv make.inc.plumedbck make.inc
17+
}
18+
19+
function plumed_patch_info(){
20+
echo ""
21+
echo "For more information on Quantum Espresso you should visit http://www.quantum-espresso.org"
22+
echo "To apply this patch configure Quantum Espresso by running ./configure first."
23+
echo "The newer CMake installation workflow is not supported yet."
24+
echo "To enable PLUMED on md runs use pw.x -plumed < md.in > md.out."
25+
echo "A fixed PLUMED input file name 'plumed.dat' is used."
26+
echo "This patch was kindly provided by Ralf Meyer, email: meyer.ralf(at)yahoo.com"
27+
}
28+
+249
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
#/a Makefile for Modules
2+
3+
include ../make.inc
4+
5+
# location of needed modules
6+
MODFLAGS=$(BASEMOD_FLAGS) \
7+
$(MOD_FLAG)../ELPA/src
8+
9+
# list of modules
10+
11+
MODULES = \
12+
additional_kpoints.o \
13+
autopilot.o \
14+
basic_algebra_routines.o \
15+
becmod.o \
16+
bfgs_module.o \
17+
bspline.o \
18+
bz_form.o \
19+
cell_base.o \
20+
check_stop.o \
21+
command_line_options.o \
22+
compute_dipole.o \
23+
constants.o \
24+
constraints_module.o \
25+
control_flags.o \
26+
coulomb_vcut.o \
27+
dist.o \
28+
electrons_base.o \
29+
environ_base_module.o \
30+
environment.o \
31+
extffield.o \
32+
fd_gradient.o \
33+
fft_base.o \
34+
fft_rho.o \
35+
fft_wave.o \
36+
fsockets.o \
37+
funct.o \
38+
generate_function.o \
39+
gradutils.o \
40+
gvecw.o \
41+
input_parameters.o \
42+
invmat.o \
43+
io_files.o \
44+
io_global.o \
45+
ions_base.o \
46+
kind.o \
47+
lmdif.o \
48+
mdiis.o \
49+
mm_dispersion.o \
50+
mp_bands.o \
51+
mp_exx.o \
52+
mp_global.o \
53+
mp_images.o \
54+
mp_pools.o \
55+
mp_wave.o \
56+
mp_world.o \
57+
noncol.o \
58+
open_close_input_file.o \
59+
parameters.o \
60+
parser.o \
61+
plugin_flags.o \
62+
plugin_arguments.o \
63+
plugin_variables.o \
64+
pw_dot.o \
65+
qmmm.o \
66+
random_numbers.o \
67+
read_cards.o \
68+
read_input.o \
69+
read_namelists.o \
70+
read_pseudo.o \
71+
recvec.o \
72+
recvec_subs.o \
73+
run_info.o \
74+
space_group.o \
75+
set_para_diag.o \
76+
set_signal.o \
77+
set_vdw_corr.o \
78+
setqf.o \
79+
timestep.o\
80+
tsvdw.o\
81+
mbdlib.o\
82+
version.o \
83+
wannier_gw.o\
84+
wannier_new.o \
85+
wavefunctions.o \
86+
ws_base.o \
87+
xc_vdW_DF.o \
88+
xc_rVV10.o \
89+
io_base.o \
90+
qes_types_module.o \
91+
qes_libs_module.o \
92+
qes_write_module.o \
93+
qes_read_module.o \
94+
qes_reset_module.o \
95+
qes_init_module.o \
96+
qes_bcast_module.o \
97+
qexsd.o \
98+
qexsd_copy.o \
99+
qexsd_init.o \
100+
qexsd_input.o \
101+
hdf5_qe.o\
102+
qeh5_module.o\
103+
fox_init_module.o \
104+
xsf.o \
105+
wyckoff.o \
106+
wypos.o \
107+
zvscal.o \
108+
wave_gauge.o \
109+
plumed.o
110+
111+
# list of RISM's modules
112+
113+
RISMLIB = \
114+
allocate_fft_3drism.o \
115+
chempot.o \
116+
chempot_lauerism.o \
117+
closure.o \
118+
corrdipole_laue.o \
119+
correctat0_vv.o \
120+
corrgxy0_laue.o \
121+
cryst_to_car_2d.o \
122+
data_structure_3drism.o \
123+
do_1drism.o \
124+
do_3drism.o \
125+
do_lauerism.o \
126+
eqn_1drism.o \
127+
eqn_3drism.o \
128+
eqn_lauedipole.o \
129+
eqn_lauegxy0.o \
130+
eqn_lauelong.o \
131+
eqn_lauerism.o \
132+
eqn_laueshort.o \
133+
eqn_lauevoid.o \
134+
err_rism.o \
135+
guess_3drism.o \
136+
init_1drism.o \
137+
init_3drism.o \
138+
input_1drism.o \
139+
input_3drism.o \
140+
io_rism_xml.o \
141+
lauefft.o \
142+
lauefft_subs.o \
143+
lj_forcefield.o \
144+
lj_solute.o \
145+
molecorr_vv.o \
146+
molebridge_vv.o \
147+
molecule_const.o \
148+
molecule_types.o \
149+
mp_rism.o \
150+
mp_swap_ax_rism.o \
151+
normalize_lauerism.o \
152+
plot_rism.o \
153+
potential_3drism.o \
154+
potential_esm.o \
155+
potential_vv.o \
156+
print_chempot_3drism.o \
157+
print_chempot_lauerism.o \
158+
print_chempot_vv.o \
159+
print_corr_vv.o \
160+
print_solvavg.o \
161+
radfft.o \
162+
read_mol.o \
163+
read_solv.o \
164+
recvec_3drism.o \
165+
rism.o \
166+
rism1d_facade.o \
167+
rism3d_facade.o \
168+
rms_residual.o \
169+
scale_fft_3drism.o \
170+
scale_fft_lauerism.o \
171+
solute.o \
172+
solvation_3drism.o \
173+
solvation_esm.o \
174+
solvation_force.o \
175+
solvation_lauerism.o \
176+
solvation_pbc.o \
177+
solvation_stress.o \
178+
solvavg.o \
179+
solvmol.o \
180+
summary_1drism.o \
181+
summary_3drism.o \
182+
suscept_g0.o \
183+
suscept_laue.o \
184+
suscept_laueint.o \
185+
suscept_vv.o \
186+
write_rism_type.o \
187+
xml_io_rism.o
188+
189+
# list of subroutines and functions (not modules) previously found in flib/clib
190+
191+
OBJS = \
192+
atom_weight.o \
193+
capital.o \
194+
cryst_to_car.o \
195+
expint.o \
196+
generate_k_along_lines.o \
197+
has_xml.o \
198+
inpfile.o \
199+
int_to_char.o \
200+
latgen.o \
201+
linpack.o \
202+
matches.o \
203+
plot_io.o \
204+
radial_gradients.o \
205+
rgen.o \
206+
recips.o \
207+
remove_tot_torque.o \
208+
sort.o \
209+
trimcheck.o \
210+
test_input_file.o \
211+
date_and_tim.o \
212+
volume.o \
213+
wgauss.o \
214+
w0gauss.o \
215+
w1gauss.o \
216+
deviatoric.o \
217+
customize_signals.o \
218+
qmmm_aux.o \
219+
sockets.o \
220+
stack.o
221+
222+
# GPU versions of modules
223+
MODULES += \
224+
wavefunctions_gpu.o \
225+
becmod_gpu.o \
226+
becmod_subs_gpu.o \
227+
cuda_subroutines.o \
228+
random_numbers_gpu.o
229+
230+
TLDEPS= libfox libla libfft libutil libmbd librxc libupf
231+
232+
all : libqemod.a
233+
234+
libqemod.a: $(MODULES) $(OBJS) $(RISMLIB)
235+
$(AR) $(ARFLAGS) $@ $?
236+
$(RANLIB) $@
237+
238+
tldeps :
239+
if test -n "$(TLDEPS)" ; then \
240+
( cd ../.. ; $(MAKE) $(TLDEPS) || exit 1 ) ; fi
241+
242+
243+
clean :
244+
- /bin/rm -f *.o *.a *.d *.i *~ *_tmp.f90 *.mod *.L plumed.f90
245+
246+
plumed.f90:
247+
cp $(PLUMED_FORTRAN) plumed.f90
248+
249+
include make.depend
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
#/a Makefile for Modules
2+
3+
include ../make.inc
4+
5+
# location of needed modules
6+
MODFLAGS=$(BASEMOD_FLAGS)
7+
8+
# list of modules
9+
10+
MODULES = \
11+
additional_kpoints.o \
12+
autopilot.o \
13+
basic_algebra_routines.o \
14+
becmod.o \
15+
bfgs_module.o \
16+
bspline.o \
17+
bz_form.o \
18+
cell_base.o \
19+
check_stop.o \
20+
command_line_options.o \
21+
compute_dipole.o \
22+
constants.o \
23+
constraints_module.o \
24+
control_flags.o \
25+
coulomb_vcut.o \
26+
dist.o \
27+
electrons_base.o \
28+
environ_base_module.o \
29+
environment.o \
30+
extffield.o \
31+
fd_gradient.o \
32+
fft_base.o \
33+
fft_rho.o \
34+
fft_wave.o \
35+
fsockets.o \
36+
funct.o \
37+
generate_function.o \
38+
gradutils.o \
39+
gvecw.o \
40+
input_parameters.o \
41+
invmat.o \
42+
io_files.o \
43+
io_global.o \
44+
ions_base.o \
45+
kind.o \
46+
lmdif.o \
47+
mdiis.o \
48+
mm_dispersion.o \
49+
mp_bands.o \
50+
mp_exx.o \
51+
mp_global.o \
52+
mp_images.o \
53+
mp_pools.o \
54+
mp_wave.o \
55+
mp_world.o \
56+
noncol.o \
57+
open_close_input_file.o \
58+
parameters.o \
59+
parser.o \
60+
plugin_flags.o \
61+
plugin_arguments.o \
62+
plugin_variables.o \
63+
pw_dot.o \
64+
qmmm.o \
65+
random_numbers.o \
66+
read_cards.o \
67+
read_input.o \
68+
read_namelists.o \
69+
read_pseudo.o \
70+
recvec.o \
71+
recvec_subs.o \
72+
run_info.o \
73+
space_group.o \
74+
set_para_diag.o \
75+
set_signal.o \
76+
set_vdw_corr.o \
77+
setqf.o \
78+
timestep.o\
79+
tsvdw.o\
80+
mbdlib.o\
81+
version.o \
82+
wannier_gw.o\
83+
wannier_new.o \
84+
wavefunctions.o \
85+
ws_base.o \
86+
xc_vdW_DF.o \
87+
xc_rVV10.o \
88+
io_base.o \
89+
qes_types_module.o \
90+
qes_libs_module.o \
91+
qes_write_module.o \
92+
qes_read_module.o \
93+
qes_reset_module.o \
94+
qes_init_module.o \
95+
qes_bcast_module.o \
96+
qexsd.o \
97+
qexsd_copy.o \
98+
qexsd_init.o \
99+
qexsd_input.o \
100+
hdf5_qe.o\
101+
qeh5_module.o\
102+
fox_init_module.o \
103+
xsf.o \
104+
wyckoff.o \
105+
wypos.o \
106+
zvscal.o \
107+
wave_gauge.o
108+
109+
# list of RISM's modules
110+
111+
RISMLIB = \
112+
allocate_fft_3drism.o \
113+
chempot.o \
114+
chempot_lauerism.o \
115+
closure.o \
116+
corrdipole_laue.o \
117+
correctat0_vv.o \
118+
corrgxy0_laue.o \
119+
cryst_to_car_2d.o \
120+
data_structure_3drism.o \
121+
do_1drism.o \
122+
do_3drism.o \
123+
do_lauerism.o \
124+
eqn_1drism.o \
125+
eqn_3drism.o \
126+
eqn_lauedipole.o \
127+
eqn_lauegxy0.o \
128+
eqn_lauelong.o \
129+
eqn_lauerism.o \
130+
eqn_laueshort.o \
131+
eqn_lauevoid.o \
132+
err_rism.o \
133+
guess_3drism.o \
134+
init_1drism.o \
135+
init_3drism.o \
136+
input_1drism.o \
137+
input_3drism.o \
138+
io_rism_xml.o \
139+
lauefft.o \
140+
lauefft_subs.o \
141+
lj_forcefield.o \
142+
lj_solute.o \
143+
molecorr_vv.o \
144+
molebridge_vv.o \
145+
molecule_const.o \
146+
molecule_types.o \
147+
mp_rism.o \
148+
mp_swap_ax_rism.o \
149+
normalize_lauerism.o \
150+
plot_rism.o \
151+
potential_3drism.o \
152+
potential_esm.o \
153+
potential_vv.o \
154+
print_chempot_3drism.o \
155+
print_chempot_lauerism.o \
156+
print_chempot_vv.o \
157+
print_corr_vv.o \
158+
print_solvavg.o \
159+
radfft.o \
160+
read_mol.o \
161+
read_solv.o \
162+
recvec_3drism.o \
163+
rism.o \
164+
rism1d_facade.o \
165+
rism3d_facade.o \
166+
rms_residual.o \
167+
scale_fft_3drism.o \
168+
scale_fft_lauerism.o \
169+
solute.o \
170+
solvation_3drism.o \
171+
solvation_esm.o \
172+
solvation_force.o \
173+
solvation_lauerism.o \
174+
solvation_pbc.o \
175+
solvation_stress.o \
176+
solvavg.o \
177+
solvmol.o \
178+
summary_1drism.o \
179+
summary_3drism.o \
180+
suscept_g0.o \
181+
suscept_laue.o \
182+
suscept_laueint.o \
183+
suscept_vv.o \
184+
write_rism_type.o \
185+
xml_io_rism.o
186+
187+
# list of subroutines and functions (not modules) previously found in flib/clib
188+
189+
OBJS = \
190+
atom_weight.o \
191+
capital.o \
192+
cryst_to_car.o \
193+
expint.o \
194+
generate_k_along_lines.o \
195+
has_xml.o \
196+
inpfile.o \
197+
int_to_char.o \
198+
latgen.o \
199+
linpack.o \
200+
matches.o \
201+
plot_io.o \
202+
radial_gradients.o \
203+
rgen.o \
204+
recips.o \
205+
remove_tot_torque.o \
206+
sort.o \
207+
trimcheck.o \
208+
test_input_file.o \
209+
date_and_tim.o \
210+
volume.o \
211+
wgauss.o \
212+
w0gauss.o \
213+
w1gauss.o \
214+
deviatoric.o \
215+
customize_signals.o \
216+
qmmm_aux.o \
217+
sockets.o \
218+
stack.o
219+
220+
# GPU versions of modules
221+
MODULES += \
222+
wavefunctions_gpu.o \
223+
becmod_gpu.o \
224+
becmod_subs_gpu.o \
225+
cuda_subroutines.o \
226+
random_numbers_gpu.o
227+
228+
TLDEPS= libfox libla libfft libutil libmbd librxc libupf
229+
230+
all : libqemod.a
231+
232+
libqemod.a: $(MODULES) $(OBJS) $(RISMLIB)
233+
$(AR) $(ARFLAGS) $@ $?
234+
$(RANLIB) $@
235+
236+
tldeps :
237+
if test -n "$(TLDEPS)" ; then \
238+
( cd ../.. ; $(MAKE) $(TLDEPS) || exit 1 ) ; fi
239+
240+
241+
clean :
242+
- /bin/rm -f *.o *.a *.d *.i *~ *_tmp.f90 *.mod *.L
243+
244+
include make.depend

‎patches/qespresso-7.2.diff/PW/src/forces.f90

+532
Large diffs are not rendered by default.

‎patches/qespresso-7.2.diff/PW/src/forces.f90.preplumed

+535
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
!
2+
! Copyright (C) 2001-2009 Quantum ESPRESSO group
3+
! This file is distributed under the terms of the
4+
! GNU General Public License. See the file `License'
5+
! in the root directory of the present distribution,
6+
! or http://www.gnu.org/copyleft/gpl.txt .
7+
!
8+
!----------------------------------------------------------------------------
9+
SUBROUTINE plugin_ext_forces()
10+
!----------------------------------------------------------------------------
11+
!
12+
!
13+
USE mp, ONLY : mp_bcast
14+
USE mp_images, ONLY : intra_image_comm
15+
USE io_global, ONLY : stdout, ionode, ionode_id
16+
USE kinds, ONLY : DP
17+
!
18+
USE plugin_flags, ONLY : use_plumed
19+
!
20+
USE cell_base, ONLY : alat, at
21+
USE ions_base, ONLY : tau, nat, amass, ityp
22+
USE force_mod, ONLY : force,sigma
23+
USE control_flags, ONLY : istep
24+
USE ener, ONLY : etot
25+
26+
USE plumed_module, ONLY: plumed_f_gcmd
27+
!
28+
IMPLICIT NONE
29+
!
30+
INTEGER:: i,j,ia
31+
REAL(DP) :: at_plumed(3,3)
32+
REAL(DP) :: virial(3,3)
33+
REAL(DP) :: volume
34+
REAL(DP), ALLOCATABLE :: tau_plumed(:,:)
35+
REAL(DP) :: masses_plumed(nat)
36+
!
37+
masses_plumed = 0.0_DP
38+
IF(use_plumed) then
39+
IF(ionode)THEN
40+
at_plumed=alat*at; ! the cell, rescaled properly
41+
allocate(tau_plumed(3,nat))
42+
tau_plumed=alat*tau
43+
volume=+at_plumed(1,1)*at_plumed(2,2)*at_plumed(3,3) &
44+
+at_plumed(1,2)*at_plumed(2,3)*at_plumed(3,1) &
45+
+at_plumed(1,3)*at_plumed(2,1)*at_plumed(3,2) &
46+
-at_plumed(1,1)*at_plumed(3,2)*at_plumed(2,3) &
47+
-at_plumed(1,2)*at_plumed(3,3)*at_plumed(2,1) &
48+
-at_plumed(1,3)*at_plumed(3,1)*at_plumed(2,2)
49+
virial=-sigma*volume
50+
51+
! the masses in QE are stored per type, see q-e//Modules/ions_base.f90
52+
do ia=1,nat
53+
masses_plumed(ia)=amass(ityp(ia))
54+
end do
55+
56+
CALL plumed_f_gcmd("setStep"//char(0),istep)
57+
CALL plumed_f_gcmd("setMasses"//char(0),masses_plumed)
58+
CALL plumed_f_gcmd("setForces"//char(0),force)
59+
CALL plumed_f_gcmd("setPositions"//char(0),tau_plumed)
60+
CALL plumed_f_gcmd("setBox"//char(0),at_plumed)
61+
CALL plumed_f_gcmd("setVirial"//char(0),virial)
62+
CALL plumed_f_gcmd("setEnergy"//char(0),etot)
63+
CALL plumed_f_gcmd("calc"//char(0),0)
64+
65+
sigma=-virial/volume
66+
67+
deallocate(tau_plumed)
68+
ENDIF
69+
CALL mp_bcast(force, ionode_id, intra_image_comm)
70+
CALL mp_bcast(sigma, ionode_id, intra_image_comm)
71+
ENDIF
72+
!
73+
!
74+
END SUBROUTINE plugin_ext_forces
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
!
2+
! Copyright (C) 2001-2009 Quantum ESPRESSO group
3+
! This file is distributed under the terms of the
4+
! GNU General Public License. See the file `License'
5+
! in the root directory of the present distribution,
6+
! or http://www.gnu.org/copyleft/gpl.txt .
7+
!
8+
!----------------------------------------------------------------------------
9+
SUBROUTINE plugin_ext_forces()
10+
!----------------------------------------------------------------------------
11+
!
12+
!
13+
USE mp, ONLY : mp_bcast
14+
USE mp_images, ONLY : intra_image_comm
15+
USE io_global, ONLY : stdout, ionode, ionode_id
16+
USE kinds, ONLY : DP
17+
!
18+
USE plugin_flags
19+
!
20+
IMPLICIT NONE
21+
!
22+
!
23+
END SUBROUTINE plugin_ext_forces
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
!
2+
! Copyright (C) 2010 Quantum ESPRESSO group
3+
! This file is distributed under the terms of the
4+
! GNU General Public License. See the file `License'
5+
! in the root directory of the present distribution,
6+
! or http://www.gnu.org/copyleft/gpl.txt .
7+
!
8+
!----------------------------------------------------------------------------
9+
SUBROUTINE plugin_initialization()
10+
!----------------------------------------------------------------------------
11+
!
12+
USE io_global, ONLY : stdout, ionode
13+
USE kinds, ONLY : DP
14+
USE io_files, ONLY : tmp_dir
15+
!
16+
USE plugin_flags, ONLY : use_plumed
17+
!
18+
USE ions_base, ONLY : amass, ityp, nat
19+
!
20+
USE dynamics_module, ONLY : dt
21+
USE constants, ONLY : au_ps
22+
23+
USE plumed_module, ONLY : plumed_f_installed, plumed_f_gcreate, plumed_f_gcmd
24+
!
25+
!
26+
IMPLICIT NONE
27+
!
28+
INTEGER :: na
29+
INTEGER :: plumedavailable
30+
REAL*8 :: energyUnits,lengthUnits,timeUnits
31+
!
32+
IF(use_plumed) then
33+
34+
CALL plumed_f_installed(plumedavailable)
35+
36+
IF(plumedavailable<=0)THEN
37+
write(stdout,*)"YOU ARE LOOKING FOR PLUMED BUT LOOKS LIKE IT IS NOT AVAILABLE: DO YOU HAVE IT IN YOUR LD_LIBRARY_PATH?"
38+
STOP
39+
ELSE
40+
IF (ionode) THEN
41+
42+
write(stdout,*)" CREATING PLUMED FROM THE PROGRAM"
43+
call plumed_f_gcreate()
44+
CALL plumed_f_gcmd("setRealPrecision"//char(0),8)
45+
energyUnits=1312.75 ! Ry to kjoule mol
46+
lengthUnits=0.0529177249 ! bohr to nm
47+
timeUnits=2*au_ps ! internal time to ps
48+
call plumed_f_gcmd("setMDEnergyUnits"//char(0),energyUnits)
49+
call plumed_f_gcmd("setMDLengthUnits"//char(0),lengthUnits)
50+
call plumed_f_gcmd("setMDTimeUnits"//char(0),timeUnits)
51+
call plumed_f_gcmd("setPlumedDat"//char(0),"plumed.dat"//char(0))
52+
call plumed_f_gcmd("setLogFile"//char(0),"PLUMED.OUT"//char(0))
53+
call plumed_f_gcmd("setNatoms"//char(0),nat)
54+
call plumed_f_gcmd("setMDEngine"//char(0),"qespresso");
55+
call plumed_f_gcmd("setTimestep"//char(0),dt);
56+
call plumed_f_gcmd("init"//char(0),0);
57+
58+
59+
ENDIF
60+
ENDIF
61+
ENDIF
62+
!
63+
!
64+
END SUBROUTINE plugin_initialization
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
!
2+
! Copyright (C) 2010 Quantum ESPRESSO group
3+
! This file is distributed under the terms of the
4+
! GNU General Public License. See the file `License'
5+
! in the root directory of the present distribution,
6+
! or http://www.gnu.org/copyleft/gpl.txt .
7+
!
8+
!----------------------------------------------------------------------------
9+
SUBROUTINE plugin_initialization()
10+
!----------------------------------------------------------------------------
11+
!
12+
USE io_global, ONLY : stdout, ionode
13+
USE kinds, ONLY : DP
14+
USE io_files, ONLY : tmp_dir
15+
!
16+
USE plugin_flags
17+
!
18+
IMPLICIT NONE
19+
!
20+
!
21+
END SUBROUTINE plugin_initialization

‎patches/qespresso-7.2.diff/PW/src/run_pwscf.f90

+569
Large diffs are not rendered by default.

‎patches/qespresso-7.2.diff/PW/src/run_pwscf.f90.preplumed

+560
Large diffs are not rendered by default.

‎user-doc/tutorials/a-advanced-methods.txt

+504
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ATOM 1 1HH3 ACE 1 15.700 13.120 -0.270 1.00 0.00
2+
ATOM 2 CH3 ACE 1 14.670 12.910 -0.560 1.00 0.00
3+
ATOM 3 2HH3 ACE 1 14.080 12.680 0.330 1.00 0.00
4+
ATOM 4 3HH3 ACE 1 14.550 12.130 -1.310 1.00 0.00
5+
ATOM 5 C ACE 1 14.140 14.180 -1.210 1.00 0.00
6+
ATOM 6 O ACE 1 12.990 14.170 -1.650 1.00 0.00
7+
ATOM 7 N ALA 2 14.940 15.200 -1.540 1.00 0.00
8+
ATOM 8 H ALA 2 15.870 15.140 -1.150 1.00 0.00
9+
ATOM 9 CA ALA 2 14.600 16.550 -1.940 1.00 0.00
10+
ATOM 10 HA ALA 2 13.610 16.860 -1.590 1.00 0.00
11+
ATOM 11 CB ALA 2 15.650 17.430 -1.260 1.00 0.00
12+
ATOM 12 HB1 ALA 2 16.670 17.190 -1.550 1.00 0.00
13+
ATOM 13 HB2 ALA 2 15.420 18.460 -1.520 1.00 0.00
14+
ATOM 14 HB3 ALA 2 15.490 17.340 -0.190 1.00 0.00
15+
ATOM 15 C ALA 2 14.330 16.660 -3.430 1.00 0.00
16+
ATOM 16 O ALA 2 14.330 17.750 -4.010 1.00 0.00
17+
ATOM 17 N NME 3 14.120 15.510 -4.080 1.00 0.00
18+
ATOM 18 H NME 3 13.940 14.630 -3.620 1.00 0.00
19+
ATOM 19 CH3 NME 3 13.800 15.620 -5.490 1.00 0.00
20+
ATOM 20 1HH3 NME 3 13.140 14.830 -5.860 1.00 0.00
21+
ATOM 21 2HH3 NME 3 13.250 16.540 -5.710 1.00 0.00
22+
ATOM 22 3HH3 NME 3 14.690 15.590 -6.120 1.00 0.00
23+
TER
24+
ENDMDL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import math
2+
import sys
3+
import numpy as np
4+
5+
# Arguments of do_block_fes.py
6+
# - FILE: input file, 1 column per CV + weights (optional)
7+
# - NCV: number of CVs
8+
# - *MIN: minimum value of CV
9+
# - *MAX: max value of CV
10+
# - *NBIN: # points in output free energy
11+
# - KBT: temperature in energy units (kJoule/mol)
12+
# - N: Block size
13+
#
14+
# * = repeat this block for each CV
15+
# Example with 2 CVs:
16+
# python3 do_block_fes.py phi_psi_w.dat 2 -3.141593 3.141593 50 -3.141593 3.141593 50 2.494339 100
17+
#
18+
#
19+
# Author: Max Bonomi (mbonomi@pasteur.fr)
20+
#
21+
#
22+
# useful functions
23+
# nD indexes from 1D index
24+
def get_indexes_from_index(index, nbin):
25+
indexes = []
26+
# get first index
27+
indexes.append(index%nbin[0])
28+
# loop
29+
kk = index
30+
for i in range(1, len(nbin)-1):
31+
kk = ( kk - indexes[i-1] ) / nbin[i-1]
32+
indexes.append(kk%nbin[i])
33+
if(len(nbin)>=2):
34+
indexes.append( ( kk - indexes[len(nbin)-2] ) / nbin[len(nbin) -2] )
35+
return tuple(indexes)
36+
37+
# nD indexes from values
38+
def get_indexes_from_cvs(cvs, gmin, dx, nbin):
39+
idx = []
40+
for i in range(0, len(cvs)):
41+
j = int( round( ( cvs[i] - gmin[i] ) / dx[i] ) )
42+
# check boundaries
43+
if(j>=nbin[i]):
44+
print("Point outside grid, check boundaries!")
45+
exit()
46+
idx.append(j)
47+
return tuple(idx)
48+
49+
# 1D index from values
50+
def get_index_from_cvs(cvs, gmin, dx, nbin):
51+
# get nD indices from value
52+
idx = get_indexes_from_cvs(cvs, gmin, dx, nbin)
53+
# transform in 1D index
54+
i = idx[-1]
55+
for j in range(len(nbin)-1,0,-1):
56+
i = i*nbin[j-1]+idx[j-1]
57+
return i
58+
59+
# grid points from nD indexes
60+
def get_points_from_indexes(idx, gmin, dx):
61+
xs = []
62+
for i in range(0, len(idx)):
63+
xs.append(gmin[i] + float(idx[i]) * dx[i])
64+
return xs
65+
66+
# read CV/weight file and create numpy arrays
67+
def read_file(filename,gmin,dx,nbin):
68+
# read file and store lists
69+
cvs=[]; ws=[]
70+
# number of cv
71+
ncv = len(gmin)
72+
for lines in open(filename, "r").readlines():
73+
riga = lines.strip().split()
74+
# check format
75+
if(len(riga)!=ncv and len(riga)!=ncv+1):
76+
print (filename,"is in the wrong format!")
77+
exit()
78+
# read CVs
79+
cv = []
80+
for i in range(0, ncv): cv.append(float(riga[i]))
81+
# get index in flattened array
82+
idx = get_index_from_cvs(cv, gmin, dx, nbin)
83+
# read weight, if present
84+
if(len(riga)==ncv+1):
85+
w = float(riga[ncv])
86+
else: w = 1.0
87+
# store into cv and weight lists
88+
cvs.append(idx)
89+
ws.append(w)
90+
# return numpy arrays
91+
return np.array(cvs),np.array(ws)
92+
93+
# 1) READ INPUT parameters
94+
# FILE with CV trajectory and (optionally) weights
95+
FILENAME_ = sys.argv[1]
96+
# number of CVs
97+
NCV_ = int(sys.argv[2])
98+
# read minimum, maximum and number of bins for FES grid
99+
gmin = []; gmax = []; nbin = []
100+
for i in range(0, NCV_):
101+
i0 = 3*i + 3
102+
gmin.append(float(sys.argv[i0]))
103+
gmax.append(float(sys.argv[i0+1]))
104+
nbin.append(int(sys.argv[i0+2]))
105+
# read KBT_
106+
KBT_ = float(sys.argv[3*NCV_+3])
107+
# block size
108+
BSIZE_ = int(sys.argv[-1])
109+
110+
# 2) SETUP
111+
# define bin sizes
112+
dx = []
113+
for i in range(0, NCV_):
114+
dx.append( (gmax[i]-gmin[i])/float(nbin[i]-1) )
115+
# total numbers of bins
116+
nbins = 1
117+
for i in range(0, len(nbin)): nbins *= nbin[i]
118+
# read file and store arrays
119+
cv, w = read_file(FILENAME_, gmin, dx, nbin)
120+
# total number of data points
121+
ndata = cv.shape[0]
122+
# number of blocks
123+
nblock = int(ndata/BSIZE_)
124+
# prepare numpy arrays for histogram and normalization
125+
histo = np.zeros((nbins,nblock))
126+
norm = np.zeros(nblock)
127+
128+
# 3) FILL IN HISTOGRAM ARRAY
129+
for iblock in range(0, nblock):
130+
# define range
131+
i0 = iblock * BSIZE_
132+
i1 = i0 + BSIZE_
133+
# cycle on points in the block
134+
for i in range(i0, i1):
135+
# update histogram
136+
histo[cv[i],iblock] += w[i]
137+
# calculate normalization of the block
138+
norm[iblock] = np.sum(w[i0:i1])
139+
# normalize block
140+
histo[:,iblock] /= norm[iblock]
141+
142+
# 4) CALCULATE WEIGHTED AVERAGE AND VARIANCE
143+
# now we calculate weighted average across blocks
144+
ave = np.sum(histo*norm, axis=1) / np.sum(norm)
145+
avet = np.transpose(np.tile(ave, (nblock,1)))
146+
# and variance
147+
var = np.sum(np.power( norm * (histo-avet), 2), axis=1) / np.power(np.sum(norm), 2)
148+
149+
# 5) PRINT FES + ERROR
150+
log = open("fes."+str(BSIZE_)+".dat", "w")
151+
# this is needed to add a blank line
152+
xs_old = []
153+
for i in range(0, nbins):
154+
# get the indexes in the multi-dimensional grid
155+
idx = get_indexes_from_index(i, nbin)
156+
# get values for grid point
157+
xs = get_points_from_indexes(idx, gmin, dx)
158+
# add a blank line for gnuplot
159+
if(i == 0):
160+
xs_old = xs[:]
161+
else:
162+
flag = 0
163+
for j in range(1,len(xs)):
164+
if(xs[j] != xs_old[j]):
165+
flag = 1
166+
xs_old = xs[:]
167+
if (flag == 1): log.write("\n")
168+
# print grid point
169+
for x in xs:
170+
log.write("%12.6lf " % x)
171+
# calculate fes and error
172+
try:
173+
# fes
174+
fes = -KBT_ * math.log(ave[i])
175+
# variance fes
176+
varf = math.pow( KBT_ / ave[i], 2.0) * var[i]
177+
# error fes
178+
errf = math.sqrt(varf)
179+
# printout
180+
log.write(" %12.6lf %12.6lf\n" % (fes, errf))
181+
except ValueError:
182+
log.write(" %12s %12s\n" % ("Inf","Inf"))
183+
except OverflowError:
184+
log.write(" %12s %12s\n" % ("Inf","Inf"))
185+
log.close()
9.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.