33 use const_gbl,
only: stdout
35 use mpi_gbl,
only: mpi_xermsg
37 use scatci_routines,
only: mkorbs, pmkorbs
53 integer :: orbital_number
57 integer :: positron_flag
58 integer :: electron_idx
70 logical :: initialized = .false.
71 integer :: total_num_spin_orbitals
72 integer :: total_num_orbitals
73 integer :: symmetry_type
74 integer :: num_symmetries
75 integer :: positron_flag
77 integer,
allocatable :: mcorb(:), mcon(:), nsrb(:)
79 integer,
allocatable :: orbital_map(:)
117 integer,
intent(in) :: nsrb, nsym, norb, symtype, positron_flag
119 this % total_num_spin_orbitals = nsrb
120 this % total_num_orbitals = norb
121 this % symmetry_type = symtype
122 this % num_symmetries = nsym
123 this % positron_flag = positron_flag
125 if (
allocated(this % spin_orbitals))
deallocate (this % spin_orbitals)
126 if (
allocated(this % mcon))
deallocate (this % mcon)
127 if (
allocated(this % nsrb))
deallocate (this % nsrb)
128 if (
allocated(this % mcorb))
deallocate (this % mcorb)
129 if (
allocated(this % orbital_map))
deallocate (this % orbital_map)
131 allocate(this % spin_orbitals(this % total_num_spin_orbitals))
132 allocate(this % mcon(this % total_num_spin_orbitals))
133 allocate(this % nsrb(this % total_num_spin_orbitals))
134 allocate(this % mcorb(this % total_num_orbitals))
135 allocate(this % orbital_map(this % total_num_orbitals))
155 subroutine construct_table (this, num_orbital_target_sym, num_orbital_target_sym_dinf, &
156 num_orbitals, num_elec_orbitals, num_orbitals_congen)
158 integer,
intent(in) :: num_orbital_target_sym(this % num_symmetries), &
159 num_orbital_target_sym_dinf(this % num_symmetries), &
160 num_orbitals(this % num_symmetries), &
161 num_elec_orbitals(this % num_symmetries), &
162 num_orbitals_congen(this % num_symmetries)
164 integer :: MN(this % total_num_spin_orbitals), MG(this % total_num_spin_orbitals), &
165 MM(this % total_num_spin_orbitals), MS(this % total_num_spin_orbitals), MPOS(this % total_num_spin_orbitals)
166 integer :: dummy_iposit = 0, dummy_lusme = 0, ido
168 if (this % positron_flag /= 0 .and. this % symmetry_type ==
symtype_d2h)
then
169 call pmkorbs(num_orbitals, num_elec_orbitals, num_orbitals_congen, this % num_symmetries, &
170 mn, mg, mm, ms, this % mcon, this % mcorb, this % total_num_orbitals, &
171 this % total_num_spin_orbitals, this % orbital_map, mpos, this % positron_flag, &
172 this % symmetry_type, dummy_lusme, stdout)
174 call mkorbs(this % num_symmetries, mn, mg, mm, ms, this % total_num_orbitals, &
175 this % total_num_spin_orbitals, this % orbital_map, mpos, this % mcon, &
176 this % mcorb, this % positron_flag, num_orbital_target_sym, &
177 num_orbital_target_sym_dinf, this % symmetry_type, dummy_lusme, stdout)
180 do ido = 1, this % total_num_spin_orbitals
181 this % spin_orbitals(ido) % orbital_number = mn(ido)
182 this % spin_orbitals(ido) % gerude = mg(ido)
183 this % spin_orbitals(ido) % m_quanta = mm(ido)
184 this % spin_orbitals(ido) % spin = ms(ido)
185 this % spin_orbitals(ido) % positron_flag = mpos(ido)
186 this % spin_orbitals(ido) % electron_idx = 0
200 integer,
intent(in) :: num_electrons
201 integer,
intent(in) :: reference_determinants(num_electrons)
205 do ido = 1, num_electrons
206 this % spin_orbitals(reference_determinants(ido)) % electron_idx = ido
214 integer,
intent(in) :: determinants(:), n
230 integer,
intent(in) :: dtrs(4), symmetry_type, flag
231 real(wp),
intent(in) :: coeff
236 integer :: KA, KB, lpositron = 0
237 integer :: NSFA, NSFB, MLA, MLB
240 if (this % positron_flag /= 0) lpositron = this % add_positron(dtrs, 1, 4)
243 p = this % spin_orbitals(dtrs(1))
244 q = this % spin_orbitals(dtrs(2))
245 r = this % spin_orbitals(dtrs(3))
246 s = this % spin_orbitals(dtrs(4))
249 if(p % spin + q % spin == 1 .or. r % spin + s % spin == 1 .or. p % positron_flag /= q % positron_flag)
then
255 ka = max(dtrs(1), dtrs(2))
256 kb = max(dtrs(3), dtrs(4))
258 if (r % m_quanta * s % m_quanta < 0) mla = 1
260 if(p % m_quanta * q % m_quanta < 0) mla = 1
266 if (p % spin + s % spin == 1 .or. q % spin + r % spin == 1 .or. r % positron_flag /= s % positron_flag)
then
272 ka = max(dtrs(1), dtrs(4))
273 kb = max(dtrs(3), dtrs(2))
275 if (q % m_quanta * r % m_quanta < 0) mlb = 1
277 if (p % m_quanta * s % m_quanta < 0) mlb = 1
283 if (nsfa == 0 .and. nsfb == 0)
return
286 if (lpositron == 1) sign = -1_wp
290 call this % evaluate_case_other(p % orbital_number, q % orbital_number, r % orbital_number, &
291 s % orbital_number, mla, 0, sign * coeff, symbol)
294 call this % evaluate_case_other(p % orbital_number, s % orbital_number, r % orbital_number, &
295 q % orbital_number, mlb, 1, sign * coeff, symbol)
297 else if (p % orbital_number == q % orbital_number .and. r % orbital_number == s % orbital_number)
then
299 call this % evaluate_case_one(p % orbital_number, r % orbital_number, nsfa, nsfb, mla, mlb, sign * coeff, symbol)
301 else if (p % orbital_number == q % orbital_number .or. r % orbital_number == s % orbital_number)
then
303 call this % evaluate_case_other(p % orbital_number, q % orbital_number, r % orbital_number, &
304 s % orbital_number, mla, 0, sign * coeff, symbol)
307 call this % evaluate_case_other(p % orbital_number, s % orbital_number, r % orbital_number, &
308 q % orbital_number, mlb, 1, sign * coeff, symbol)
310 else if (p % orbital_number == r % orbital_number .and. q % orbital_number == s % orbital_number)
then
312 call this % evaluate_case_three(p % orbital_number, r % orbital_number, nsfa, nsfb, mla, mlb, sign * coeff, symbol)
314 else if (p % orbital_number == r % orbital_number)
then
316 call this % evaluate_case_other(p % orbital_number, q % orbital_number, r % orbital_number, &
317 s % orbital_number, mla, 0, sign * coeff, symbol)
320 call this % evaluate_case_other(p % orbital_number, s % orbital_number, r % orbital_number, &
321 q % orbital_number, mlb, 1, sign * coeff, symbol)
323 else if(p % orbital_number == s % orbital_number .and. q % orbital_number == r % orbital_number)
then
325 call this % evaluate_case_two(p % orbital_number, r % orbital_number, nsfa, nsfb, mla, mlb, sign * coeff, symbol)
329 call this % evaluate_case_other(p % orbital_number, q % orbital_number, r % orbital_number, &
330 s % orbital_number, mla, 0, sign * coeff, symbol)
333 call this % evaluate_case_other(p % orbital_number, s % orbital_number, r % orbital_number, &
334 q % orbital_number, mlb, 1, sign * coeff, symbol)
343 integer,
intent(in) :: p, r, NSFA, NSFB, MLA, MLB
344 real(wp),
intent(in) :: coeff
359 call symbol % insert_ijklm_symbol(i, i, j, j, 0, coeff)
361 call symbol % insert_ijklm_symbol(i, i, j, j, 1, coeff)
367 call symbol % insert_ijklm_symbol(i, j, i, j, 0, -coeff)
369 call symbol % insert_ijklm_symbol(i, j, i, j, 1, -coeff)
378 integer,
intent(in) :: p, q, NSFA, NSFB, MLA, MLB
379 real(wp),
intent(in) :: coeff
394 call symbol % insert_ijklm_symbol(i, j, i, j, 1, coeff)
396 call symbol % insert_ijklm_symbol(i, j, i, j, 0, coeff)
402 call symbol % insert_ijklm_symbol(i, i, j, j, 1, -coeff)
404 call symbol % insert_ijklm_symbol(i, i, j, j, 0, -coeff)
413 integer,
intent(in) :: p, q, NSFA, NSFB, MLA, MLB
414 real(wp),
intent(in) :: coeff
429 call symbol % insert_ijklm_symbol(i, j, i, j, 1, coeff)
431 call symbol % insert_ijklm_symbol(i, j, i, j, 0, coeff)
437 call symbol % insert_ijklm_symbol(i, j, i, j, 1, -coeff)
439 call symbol % insert_ijklm_symbol(i, j, i, j, 0, -coeff)
448 integer,
intent(in) :: p, q, r, s, mla, ms
449 real(wp),
intent(in) :: coeff
453 integer :: I, J, K, L
471 if (ms /= 0) cfd = -cfd
473 if (i > k .or. (i == k .and. j > l))
then
474 call symbol % insert_ijklm_symbol(i, j, k, l, mla, cfd)
476 call symbol % insert_ijklm_symbol(k, l, i, j, mla, cfd)
486 integer,
intent(in) :: spin_orbital
488 if (spin_orbital > this % total_num_spin_orbitals .or. spin_orbital < 1)
then
489 write (stdout,
"('Orbital selected: ',2i12)") spin_orbital, this % total_num_spin_orbitals
491 call mpi_xermsg(
'Orbital_module',
'get_orbital_number',
'Selected orbital not within range', 1, 1)
502 integer,
intent(in) :: spin_orbital
504 if (spin_orbital > this % total_num_spin_orbitals .or. spin_orbital < 1)
then
505 write (stdout,
"('Orbital selected: ',2i12)") spin_orbital, this % total_num_spin_orbitals
507 call mpi_xermsg(
'Orbital_module',
'get_spin',
'Selected orbital not within range', 1, 1)
510 get_spin = this % spin_orbitals(spin_orbital) % spin
517 integer,
intent(in) :: spin_orbital
519 if (spin_orbital > this % total_num_spin_orbitals .or. spin_orbital < 1)
then
520 write (stdout,
"('Orbital selected: ',2i12)") spin_orbital, this % total_num_spin_orbitals
522 call mpi_xermsg(
'Orbital_module',
'get_gerude',
'Selected orbital not within range', 1, 1)
525 get_gerude = this % spin_orbitals(spin_orbital) % gerude
532 integer,
intent(in) :: spin_orbital
534 if (spin_orbital > this % total_num_spin_orbitals .or. spin_orbital < 1)
then
535 write (stdout,
"('Orbital selected: ',2i12)") spin_orbital, this % total_num_spin_orbitals
537 call mpi_xermsg(
'Orbital_module',
'get_electron_number',
'Selected orbital not within range', 1, 1)
547 integer,
intent(in) :: determinants(4)
553 this % mcon(determinants(2)), &
554 this % mcon(determinants(3)), &
555 this % mcon(determinants(4)))
562 integer,
intent(in) :: spin_orbital
564 if (spin_orbital > this % total_num_spin_orbitals .or. spin_orbital < 1)
then
565 write (stdout,
"('Orbital selected: ',2i12)") spin_orbital, this % total_num_spin_orbitals
567 call mpi_xermsg(
'Orbital_module',
'get_mcon',
'Selected orbital not within range', 1, 1)
570 get_mcon = this % mcon(spin_orbital)
577 integer,
intent(in) :: determinant_one, determinant_two
586 integer,
intent(in) :: determinants(4), ia, ib
587 integer :: icount, ido, ip
593 ip = determinants(ido)
594 if (this % spin_orbitals(ip) % positron_flag /= 0) icount = icount + 1
597 if (icount == 0)
return
598 if (icount == 2)
then
603 write (stdout,
"(' ICOUNT ',i4,' NDTC = ',4i4)") icount, determinants(:)
605 call mpi_xermsg(
'Orbital_module',
'add_positron',
'Invalid count', 1, 1)