33 use const_gbl,
only: stdout
57 integer :: target_symmetry
76 integer,
intent(in) :: target_symmetry
78 this % target_symmetry = target_symmetry
79 if (this % options % csf_type ==
normal_csf)
then
80 this % csf_skip = this % options % num_continuum_orbitals_target(target_symmetry)
85 this % initialized = .true.
99 class(
basematrix),
intent(inout) :: matrix_elements
101 integer :: starting_index, num_csfs, ido, jdo, csf_a_idx, csf_b_idx, pzero_, num_elements
102 real(wp) :: mat_coeff, element_one
111 this % phase_flag = 0
114 num_csfs = this % options % num_ci_target_sym(this % target_symmetry)
117 call matrix_elements % initialize_matrix_structure(num_csfs,
mat_dense, num_csfs)
120 call symbolic_elements % construct
121 call symbolic_elements % clear
122 call ref_symbolic_elements % construct
126 do ido = 2, this % target_symmetry
127 starting_index = starting_index + this % options % num_ci_target_sym(ido - 1) * this % csf_skip
130 this % orbitals % MFLG = 0
133 csf_a_idx = starting_index
136 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_a_idx), ref_symbolic_elements, 0, .false.)
139 if (.not. ref_symbolic_elements % is_empty())
then
140 mat_coeff = this % evaluate_integrals(ref_symbolic_elements, 0)
141 this % element_one = mat_coeff
143 if (grid % mygrow == 0 .and. grid % mygcol == 0)
call matrix_elements % insert_matrix_element(1, 1, mat_coeff)
144 call matrix_elements % update_pure_L2(.false.)
149 call symbolic_elements % clear
153 call matrix_elements % update_pure_L2(.false.)
154 csf_a_idx = csf_a_idx + this % csf_skip
155 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_a_idx), symbolic_elements, 0)
156 if (symbolic_elements % is_empty()) cycle
158 if (this % diagonal_flag == 0)
call symbolic_elements % add_symbols(ref_symbolic_elements, -1.0_wp)
159 mat_coeff = this%evaluate_integrals(symbolic_elements,0)
160 if (this % diagonal_flag == 0) mat_coeff = mat_coeff + this % element_one
161 num_elements = num_elements + 1
163 call matrix_elements % insert_matrix_element(ido, ido, mat_coeff)
164 call symbolic_elements % clear
167 this % orbitals % MFLG = 1
169 csf_a_idx = starting_index - this % csf_skip
171 do ido = 1, num_csfs - 1
173 csf_a_idx = csf_a_idx + this % csf_skip
175 csf_b_idx = csf_a_idx
177 do jdo = ido + 1, num_csfs
179 csf_b_idx = csf_b_idx + this % csf_skip
181 call matrix_elements % update_pure_L2(.false.)
183 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_b_idx), symbolic_elements, 1)
185 if (symbolic_elements % is_empty()) cycle
187 num_elements = num_elements + 1
189 mat_coeff = this % evaluate_integrals(symbolic_elements, 0)
192 call matrix_elements % insert_matrix_element(jdo, ido, mat_coeff)
194 call symbolic_elements % clear
198 call matrix_elements % update_pure_L2(.true.)
201 call symbolic_elements % destroy
202 call ref_symbolic_elements % destroy
205 call matrix_elements % finalize_matrix
222 class(
basematrix),
intent(inout) :: matrix_elements
224 integer :: starting_index, num_csfs, ido, jdo, csf_a_idx, csf_b_idx, pzero_, loop_idx, total_vals
225 integer :: num_elements,begin_csf,loop_skip,my_idx,loop_ido,m_flag
226 real(wp) :: mat_coeff, element_one
235 this % phase_flag = 0
239 num_csfs = this % options % num_ci_target_sym(this % target_symmetry)
242 call matrix_elements % initialize_matrix_structure(num_csfs,
mat_dense, num_csfs)
245 call symbolic_elements % construct
246 call symbolic_elements % clear
247 call ref_symbolic_elements % construct
251 do ido = 2, this % target_symmetry
252 starting_index = starting_index + this % options % num_ci_target_sym(ido - 1) * this % csf_skip
258 csf_a_idx = starting_index
261 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_a_idx), ref_symbolic_elements, m_flag, .false.)
264 if (.not. ref_symbolic_elements % is_empty())
then
265 mat_coeff = this % evaluate_integrals(ref_symbolic_elements, 0)
266 this % element_one = mat_coeff
268 if (grid % mygrow == 0 .and. grid % mygcol == 0)
call matrix_elements % insert_matrix_element(1, 1, mat_coeff)
269 call matrix_elements % update_pure_L2(.false.)
274 call symbolic_elements % clear
278 call matrix_elements % update_pure_L2(.false.)
279 csf_a_idx = csf_a_idx + this % csf_skip
281 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_a_idx), symbolic_elements, 0)
282 if (symbolic_elements % is_empty()) cycle
284 if (this % diagonal_flag == 0)
call symbolic_elements % add_symbols(ref_symbolic_elements, -1.0_wp)
285 mat_coeff = this % evaluate_integrals(symbolic_elements, 0)
286 if (this % diagonal_flag == 0) mat_coeff = mat_coeff + this % element_one
287 num_elements = num_elements + 1
289 call matrix_elements % insert_matrix_element(ido, ido, mat_coeff)
290 call symbolic_elements % clear
293 begin_csf = starting_index - this % csf_skip
295 loop_skip = max(1, grid % gprocs)
296 my_idx = max(grid % grank, 0)
298 do loop_ido = 1, total_vals, loop_skip
299 loop_idx = loop_ido + my_idx
300 call matrix_elements % update_pure_L2(.false.)
301 if (loop_idx > total_vals) cycle
304 if (ido <= jdo) cycle
306 csf_a_idx = begin_csf + ido * this % csf_skip
307 csf_b_idx = begin_csf + jdo * this % csf_skip
309 call this % slater_rules(this % csfs(csf_a_idx), this % csfs(csf_b_idx), symbolic_elements, 1, .false.)
311 if (symbolic_elements % is_empty()) cycle
313 num_elements = num_elements + 1
314 mat_coeff = this % evaluate_integrals(symbolic_elements, this % options % phase_correction_flag)
316 call matrix_elements % insert_matrix_element(ido, jdo, mat_coeff)
317 call symbolic_elements % clear
320 call matrix_elements % update_pure_L2(.true.)
321 call symbolic_elements % destroy
322 call matrix_elements % finalize_matrix
324 write (stdout,
"('Num of elements = ',i0)") num_elements