1!!  gen1int: compute one-electron integrals using rotational London atomic-orbitals
2!!  Copyright 2009-2012 Bin Gao, and Andreas Thorvaldsen
3!!
4!!  gen1int is free software: you can redistribute it and/or modify
5!!  it under the terms of the GNU Lesser General Public License as published by
6!!  the Free Software Foundation, either version 3 of the License, or
7!!  (at your option) any later version.
8!!
9!!  gen1int is distributed in the hope that it will be useful,
10!!  but WITHOUT ANY WARRANTY; without even the implied warranty of
11!!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!!  GNU Lesser General Public License for more details.
13!!
14!!  You should have received a copy of the GNU Lesser General Public License
15!!  along with gen1int. If not, see <http://www.gnu.org/licenses/>.
16!!
17!!  This file contains the recurrence relations of constructing magnetic
18!!  and total rotational angular momentum derivatives (at zero filed) with
19!!  rotational London atomic-orbitals.
20!!
21!!  2010-11-01, Bin Gao
22!!  * first version
23
24!  !> \brief constructs total magnetic or total rotational angular momentum
25!  !>        derivatives (at zero field, with rotational London atomic-orbitals)
26!  !>        from their partial couterparts, using the recurrence relation of
27!  !>        \f$\{i+1,jk\}=\frac{i+1}{i+1-K_{0}}[\{ij,k+1\}+\{i,j+1,k\}]\f$
28!  !> \author Bin Gao
29!  !> \date 2010-11-01
30!  !> \param order_total is the order (\f$i\f$) of total derivative
31!  !> \param order_operator is the order \f$K_{0}\f$, derivative on the operator
32!  !> \param part_deriv contains the partial derivatives \f$\{0j_{1}k_{1}\}\f$,
33!  !>        where \f$j_{1}+k_{1}=i+j+k\f$, \f$j\le j_{1}\le j+i\f$, and
34!  !>        \f$k\le k_{1}\le k+i\f$; on exit, it is destroyed
35!  !> \return total_deriv is \f$\{ijk\}\f$
36!  subroutine mag_deriv_total(order_total, order_operator, part_deriv, total_deriv)
37!    implicit none
38!    integer, intent(in) :: order_total
39!    integer, intent(in) :: order_operator
40!    real(8), intent(inout) :: part_deriv(order_total+1)
41!    real(8), intent(out) :: total_deriv(dim_cints,num_bra_mag,num_ket_mag,num_tot_mag)
42!!f2py intent(in) :: order_total
43!!f2py intent(in) :: order_operator
44!!f2py intent(inout) :: part_deriv
45!!f2py depend(order_total) :: part_deriv
46!!f2py intent(out) :: total_deriv
47!    integer iorder, jorder    !incremental recorders
48!    real(8) curr_tot_order    !current total order
49!    real(8) curr_denominator  !\f$i+1-K_{0}\f$
50!    real(8) scal_factor       !scale factor \f$\frac{i+1}{i+1-K_{0}}\f$
51!    curr_tot_order = dfloat(order_operator)+1.0D+00
52!    curr_denominator = 1.0D+00
53!    do iorder = 0, order_total-2
54!      scal_factor = curr_tot_order/curr_denominator
55!      ! \f$\{i+1,jk\}=\frac{i+1}{i+1-K_{0}}[\{ij,k+1\}+\{i,j+1,k\}]\f$
56!      do jorder = 1, order_total-iorder
57!        part_deriv(jorder) = scal_factor*(part_deriv(jorder)+part_deriv(jorder+1))
58!      end do
59!      curr_tot_order = curr_tot_order+1.0D+00
60!      curr_denominator = curr_denominator+1.0D+00
61!    end do
62!    scal_factor = curr_tot_order/curr_denominator
63!    total_deriv = scal_factor*(part_deriv(1)+part_deriv(2))
64!    return
65!  end subroutine mag_deriv_total
66
67  !> \brief constructs partial magnetic derivatives (at zero field, with London
68  !>        atomic-orbitals)
69  !> \author Bin Gao
70  !> \date 2011-02-07
71  !> \param order_aux is the order of auxiliary integrals
72  !> \param low_geo is the lower order of geometric derivatives
73  !> \param up_geo is the upper order of geometric derivatives
74  !> \param order_mag is the required order of magnetic derivatives
75  !> \param val_aux(order_aux,low_geo:up_geo)
76  !> \return val_mag(low_geo+:up_geo,order_mag)
77  subroutine drecurr_lgto_zero_geo_mag(dparams, order_aux, low_geo, up_geo, order_mag)
78    implicit none
79    real(8), intent(in) :: dparams
80    integer, intent(in) :: order_aux
81    integer, intent(in) :: low_geo
82    integer, intent(in) :: up_geo
83    integer, intent(in) :: order_mag
84!>>>>!f2py intent(in) :: dparams
85!>>>>!f2py intent(in) :: order_aux
86!>>>>!f2py intent(in) :: low_geo
87!>>>>!f2py intent(in) :: up_geo
88!>>>>!f2py intent(in) :: order_mag
89!>>>>! number of xyz components for given orders
90!>>>>#include "tri_size.h"
91!>>>>    integer curr_order_aux  !current order of auxiliary integrals
92!>>>>    integer curr_size_aux   !current size of xyz triangular auxiliary integrals
93!>>>>    integer next_low_geo    !order of next lower order geometric derivatives
94!>>>>    integer curr_size_glow  !current size of xyz triangular lower order geometric derivatives
95!>>>>    integer curr_size_gup   !current size of xyz triangular upper order geometric derivatives
96!>>>>    integer iorder, jorder  !incremental recorders of order of derivatives
97!>>>>    integer iterm, jterm    !incremental recorders of xyz components of derivatives
98!>>>>    ! magnetic derivatives only
99!>>>>    if (up_geo==0) then
100!>>>>      curr_order_aux = order_aux
101!>>>>      ! recurrence relations of getting required order of magnetic derivatives
102!>>>>      ! from auxiliary integrals (order decreasing), order by order
103!>>>>      do iorder = 1, order_mag
104!>>>>        ! recurrence relations along x, y and z directions, respectively
105!>>>>        do iterm = iorder, 1, -1
106!>>>>          do jterm = 1, iterm
107!>>>>            call drecurr_lgto_zero_aux_x(curr_order_aux)
108!>>>>          end do
109!>>>>          call drecurr_lgto_zero_aux_y(curr_order_aux)
110!>>>>        end do
111!>>>>        call drecurr_lgto_zero_aux_z(curr_order_aux)
112!>>>>        ! decreases the order of auxiliary integrals
113!>>>>        curr_order_aux = curr_order_aux-1
114!>>>>      end do
115!>>>>    ! mixed magnetic and geometric derivatives
116!>>>>    else
117!>>>>      ! computes the sizes of xyz triangles
118!>>>>      iorder = min(order_aux, low_geo)
119!>>>>      jorder = max(order_aux, up_geo)
120!>>>>      curr_order_aux = order_aux
121!>>>>      ! recurrence relations of getting required order of magnetic derivatives
122!>>>>      ! from auxiliary integrals (order decreasing), order by order
123!>>>>      do iorder = 1, order_mag
124!>>>>        next_low_geo = low_geo+iorder
125!>>>>        curr_size_aux = TRI_SIZE(curr_order_aux)
126!>>>>        ! recurrence relations along x, y and z directions, respectively
127!>>>>        do iterm = iorder, 1, -1
128!>>>>          do jterm = 1, iterm
129!>>>>            ! recurrence relations by considering geometric derivatives
130!>>>>            do jorder = next_low_geo, up_geo
131!>>>>              curr_size_glow = TRI_SIZE(next_low_geo-1)
132!>>>>              curr_size_gup = TRI_SIZE(next_low_geo)
133!>>>>
134!>>>>              ! recurrence relations along x direction
135!>>>>              call drecurr_lgto_zero_aux_x(curr_order_aux)
136!>>>>            end do
137!>>>>          end do
138!>>>>          ! recurrence relations by considering geometric derivatives
139!>>>>          do jorder = next_low_geo, up_geo
140!>>>>            curr_size_glow = TRI_SIZE(next_low_geo-1)
141!>>>>            curr_size_gup = TRI_SIZE(next_low_geo)
142!>>>>            ! recurrence relations along y direction
143!>>>>
144!>>>>          end do
145!>>>>        end do
146!>>>>        ! recurrence relations by considering geometric derivatives
147!>>>>        do jorder = next_low_geo, up_geo
148!>>>>          curr_size_glow = TRI_SIZE(next_low_geo-1)
149!>>>>          curr_size_gup = TRI_SIZE(next_low_geo)
150!>>>>          ! recurrence relations along z direction
151!>>>>
152!>>>>        end do
153!>>>>        ! decreases the order of auxiliary integrals
154!>>>>        curr_order_aux = curr_order_aux-1
155!>>>>      end do
156!>>>>    end if
157    return
158  end subroutine drecurr_lgto_zero_geo_mag
159
160  subroutine drecurr_lgto_zero_mag_x()
161    implicit none
162    return
163  end subroutine drecurr_lgto_zero_mag_x
164
165  subroutine drecurr_lgto_zero_mag_y()
166    implicit none
167    return
168  end subroutine drecurr_lgto_zero_mag_y
169
170  subroutine drecurr_lgto_zero_mag_z()
171    implicit none
172    return
173  end subroutine drecurr_lgto_zero_mag_z
174
175  !> \brief two-term recurrence relation by transferring the xyz triangluar auxiliary integrals
176  !>        to magnetic derivatives along x direction
177  !> \author Bin Gao
178  !> \date 2011-02-07
179  !> \param order_aux is the order of auxiliary integrals
180  subroutine drecurr_lgto_zero_aux_x(order_aux)
181    implicit none
182    integer, intent(in) :: order_aux
183!f2py intent(in) :: order_aux
184    integer iorder          !incremental recorder of order of derivatives
185    integer iterm, jterm    !incremental recorders of xyz components of derivatives
186    integer up_order_aux    !order of auxiliary integrals plus 1
187    write(6,*) 'x direction'
188    up_order_aux = order_aux+1
189    iterm = 1
190    do iorder = 1, order_aux
191      do jterm = iterm, iterm+order_aux-iorder
192        write(6,*) jterm, jterm+iorder, jterm+up_order_aux
193      end do
194      iterm = iterm+up_order_aux-iorder
195    end do
196    return
197  end subroutine drecurr_lgto_zero_aux_x
198
199  !> \brief two-term recurrence relation by transferring the xyz triangluar auxiliary integrals
200  !>        to magnetic derivatives along y direction
201  !> \author Bin Gao
202  !> \date 2011-02-07
203  !> \param order_aux is the order of auxiliary integrals
204  subroutine drecurr_lgto_zero_aux_y(order_aux)
205    implicit none
206    integer, intent(in) :: order_aux
207!f2py intent(in) :: order_aux
208    integer iorder, jorder  !incremental recorders of order of derivatives
209    integer iterm, jterm    !incremental recorders of xyz components of derivatives
210    integer up_order_aux    !order of auxiliary integrals plus 1
211    write(6,*) 'y direction'
212    up_order_aux = order_aux+1
213    iterm = 1
214    do iorder = 1, order_aux
215      jorder = iorder-1
216      do jterm = iterm, iterm+order_aux-iorder
217        write(6,*) jterm, jterm+jorder, jterm+up_order_aux
218      end do
219      iterm = iterm+up_order_aux-iorder
220    end do
221    return
222  end subroutine drecurr_lgto_zero_aux_y
223
224  !> \brief two-term recurrence relation by transferring the xyz triangluar auxiliary integrals
225  !>        to magnetic derivatives along z direction
226  !> \author Bin Gao
227  !> \date 2011-02-07
228  !> \param order_aux is the order of auxiliary integrals
229  subroutine drecurr_lgto_zero_aux_z(order_aux)
230    implicit none
231    integer, intent(in) :: order_aux
232!f2py intent(in) :: order_aux
233    integer iorder, jorder  !incremental recorders of order of derivatives
234    integer iterm, jterm    !incremental recorders of xyz components of derivatives
235    integer up_order_aux    !order of auxiliary integrals plus 1
236    write(6,*) 'z direction'
237    up_order_aux = order_aux+1
238    iterm = 1
239    do iorder = 1, order_aux
240      jorder = iorder-1
241      do jterm = iterm, iterm+order_aux-iorder
242        write(6,*) jterm, jterm+jorder, jterm+iorder
243      end do
244      iterm = iterm+up_order_aux-iorder
245    end do
246    return
247  end subroutine drecurr_lgto_zero_aux_z
248
249! 3 terms
250  subroutine drecurr_lgto_zero_aux_ygeo_x()
251    implicit none
252    return
253  end subroutine drecurr_lgto_zero_aux_ygeo_x
254
255  subroutine drecurr_lgto_zero_aux_zgeo_x()
256    implicit none
257    return
258  end subroutine drecurr_lgto_zero_aux_zgeo_x
259
260  subroutine drecurr_lgto_zero_aux_zgeo_y()
261    implicit none
262    return
263  end subroutine drecurr_lgto_zero_aux_zgeo_y
264
265  subroutine drecurr_lgto_zero_aux_xgeo_y()
266    implicit none
267    return
268  end subroutine drecurr_lgto_zero_aux_xgeo_y
269
270  subroutine drecurr_lgto_zero_aux_xgeo_z()
271    implicit none
272    return
273  end subroutine drecurr_lgto_zero_aux_xgeo_z
274
275  subroutine drecurr_lgto_zero_aux_ygeo_z()
276    implicit none
277    return
278  end subroutine drecurr_lgto_zero_aux_ygeo_z
279
280! 4 terms
281  subroutine drecurr_lgto_zero_aux_geo_x()
282    implicit none
283    return
284  end subroutine drecurr_lgto_zero_aux_geo_x
285
286  subroutine drecurr_lgto_zero_aux_geo_y()
287    implicit none
288    return
289  end subroutine drecurr_lgto_zero_aux_geo_y
290
291  subroutine drecurr_lgto_zero_aux_geo_z()
292    implicit none
293    return
294  end subroutine drecurr_lgto_zero_aux_geo_z
295
296!  !> \brief constructs partial derivatives with respect to the total rotational
297!  !>        angular momentum (at zero field, with rotational London atomic-orbitals)
298!  !> \author Bin Gao
299!  !> \date 2010-11-01
300!  !> \param
301!  !> \return
302!  subroutine drecurr_lgto_zero_geo_rot()
303!    implicit none
304!    return
305!  end subroutine drecurr_lgto_zero_geo_rot
306