Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 113f075

Browse files
madgalscemama
authored andcommitted
Added save iterations to Full_CI_ZMQ (#203)
* Added/Updated files to save iterations Modified EZFIO.cfg to include iteratively saved data if the keyword of "full_ci_zmq/iterative" is set to true in the ezfio. The default is false. Will save the number of total iterations in full_ci_zmq/n_iter Saves the number of determinants in full_ci_zmq/n_det_iter Saves the energy in full_ci_zmq/energy_iter. Saves the energy_pt2 in full_ci_zmq/energybefore_pt2_iter These results are the same as the output of the program at every iteration. Modified fci_zmq.irp.f to include calls to fci_iterations.irp.f at each iteration (starting at N_det==1 and including the final call to do the final pt2 correction) Created fci_iterations as a subroutine to save the number of determinants, energy, and energy+pt2 for every iteration and saves the results in the full_ci_zmq output directory. * Updated files to include 3 save options Updated "iterative" in EZFIO.cfg to be an integer that can take the values of 1 (Append), 2 (Overwrite), or 3 (Do not save). Updated fci_iterations to be simpler and include the three options. Also updated the output so that only N_det, energy, and pt2 are output. The user must manipulate from there. * Delete fci_iterations.irp.f The file was modified and moved to fci_iterations.f90 * Fixed the comments * Rename fci_iterations to dump_fci_iterations_value Changed name to be clear on purpose. * Updated files for iterative saving Renamed fci_iterations to dump_fci_iterations_value for clarity In EZFIO.cfg changed keyword "iterative" to "iterative_save" for clarity Update dump_fci_iterations_value with "iterative_save" keyword Removed call to dump_fci_iterations on line 27 in fci_zmq Updated fci_zmq with the name change for calls * Delete fci_zmq.irp.f * Delete fci_zmq_pt2.irp.f * Delete EZFIO.cfg * Get latest updates from master * Added calls to dump_fci_iterations_value * Readded dump_fci_iterations_value * Updated EZFIO.cfg
1 parent 5b70d17 commit 113f075

3 files changed

Lines changed: 114 additions & 1 deletion

File tree

plugins/Full_CI_ZMQ/EZFIO.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,31 @@ type: double precision
88
doc: Calculated FCI energy + PT2
99
interface: ezfio
1010

11+
[iterative_save]
12+
type: integer
13+
doc: Save data at each iteration : 1(Append) | 2(Overwrite) | 3(NoSave)
14+
interface: ezfio,ocaml
15+
default: 1
1116

17+
[n_iter]
18+
interface: ezfio
19+
doc: number of iterations
20+
type:integer
21+
22+
[n_det_iter]
23+
interface: ezfio
24+
doc: number of determinants at iteration
25+
type: integer
26+
size: (full_ci_zmq.n_iter)
27+
28+
[energy_iter]
29+
interface: ezfio
30+
doc: The energy without a pt2 correction for n_det
31+
type: double precision
32+
size: (full_ci_zmq.n_iter)
33+
34+
[pt2_iter]
35+
interface: ezfio
36+
doc: The pt2 correction for n_det
37+
type: double precision
38+
size: (full_ci_zmq.n_iter)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
subroutine dump_fci_iterations_value(n_determinants,energy,pt2)
2+
implicit none
3+
4+
! Not using an irp.f90 environment because the SAVE statement is needed for simpler code
5+
6+
! BEGIN_DOC
7+
!! Output the number of determinants, energy, and pt2 correction at each iteration
8+
! END_DOC
9+
integer :: n_determinants
10+
double precision :: energy, pt2
11+
integer :: N_iterations
12+
integer, allocatable :: n_determinants_list(:)
13+
double precision, allocatable :: energy_list(:)
14+
double precision, allocatable :: pt2_list(:)
15+
integer :: saveMethod
16+
logical :: hasIter
17+
logical,save :: firstAccess=.TRUE. !! every update of firstAccess will be saved
18+
19+
!!! Check to ensure that we should save iterations (default is Append)
20+
! saveMethod: 1==Append, 2==Overwrite, 3==NoSave
21+
call ezfio_get_full_ci_zmq_iterative_save(saveMethod)
22+
23+
!!! Check we are saving data
24+
if (saveMethod/=3) then
25+
26+
!!! If the iteration number exists get it
27+
!!! otherwise set it to zero
28+
call ezfio_has_full_ci_zmq_n_iter(hasIter)
29+
if (hasIter) then
30+
call ezfio_get_full_ci_zmq_n_iter(N_iterations)
31+
else
32+
N_iterations=0
33+
endif
34+
35+
!!! If it is append we don't have to do any more checks
36+
!!! N_iterations will be correct now.
37+
38+
!!! If we should overwrite and this is the first time
39+
!!! Then we need to reset N_iterations to zero
40+
if ((saveMethod==2).AND.(firstAccess)) then
41+
N_iterations=0
42+
endif
43+
44+
!! Now allocate the array for entire size needed
45+
allocate(n_determinants_list(N_iterations+1))
46+
allocate(energy_list(N_iterations+1))
47+
allocate(pt2_list(N_iterations+1))
48+
49+
!!! Pull previously written data
50+
!!! Unless it is at the beginning of a new/restarted calculation
51+
if((hasIter).AND.(N_iterations>0)) then
52+
call ezfio_get_full_ci_zmq_n_det_iter(n_determinants_list(1:N_iterations))
53+
call ezfio_get_full_ci_zmq_energy_iter(energy_list(1:N_iterations))
54+
call ezfio_get_full_ci_zmq_pt2_iter(pt2_list(1:N_iterations))
55+
endif
56+
57+
!! Now increment to the current iteration
58+
N_iterations = N_iterations+1
59+
60+
!! Add the data from latest iteration
61+
n_determinants_list(N_iterations) = n_determinants
62+
energy_list(N_iterations) = energy
63+
pt2_list(N_iterations) = pt2
64+
65+
! Reset the iteration number
66+
call ezfio_set_full_ci_zmq_n_iter(N_iterations)
67+
68+
!!!! Now reset the ezfio values
69+
!!!! To include the latest data
70+
call ezfio_set_full_ci_zmq_n_det_iter(n_determinants_list)
71+
call ezfio_set_full_ci_zmq_energy_iter(energy_list)
72+
call ezfio_set_full_ci_zmq_pt2_iter(pt2_list)
73+
74+
deallocate(n_determinants_list)
75+
deallocate(energy_list)
76+
deallocate(pt2_list)
77+
78+
endif
79+
80+
!!! set first access to false
81+
!!! it will be saved
82+
firstAccess=.FALSE.
83+
end subroutine

plugins/Full_CI_ZMQ/fci_zmq.irp.f

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ program fci_zmq
4444
print *, 'E+PT2 = ', CI_energy(k) + pt2(k)
4545
print *, '-----'
4646
enddo
47+
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
4748
endif
4849

4950

@@ -135,7 +136,7 @@ program fci_zmq
135136
call save_wavefunction
136137
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
137138
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
138-
139+
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
139140
enddo
140141
endif
141142

@@ -144,6 +145,7 @@ program fci_zmq
144145
call diagonalize_CI
145146
call save_wavefunction
146147
call ezfio_set_full_ci_zmq_energy(CI_energy(1))
148+
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
147149
endif
148150

149151
if (do_pt2) then
@@ -163,6 +165,7 @@ program fci_zmq
163165
call ZMQ_selection(0, pt2) ! Deterministic PT2
164166
endif
165167
call ezfio_set_full_ci_zmq_energy_pt2(CI_energy(1)+pt2(1))
168+
call dump_fci_iterations_value(N_det,CI_energy(1),pt2(1)) ! This call automatically appends data
166169
endif
167170

168171

0 commit comments

Comments
 (0)