Skip to content

Commit dce3e95

Browse files
committed
WIP: broken, but integral progress
1 parent f2713f5 commit dce3e95

1 file changed

Lines changed: 81 additions & 26 deletions

File tree

stride/sym.f

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ SUBROUTINE symmetrize(dp)
2929

3030
COMPLEX(r8), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: dp
3131

32-
INTEGER :: m,ising,jsing,itheta,mthsurf,npsi,ipsi
32+
INTEGER :: m,ising,jsing,itheta,mthsurf,ipsi,jpsi,npsi,idx
3333
INTEGER, DIMENSION(mpert) :: mvec
34-
REAL(r8) :: resnum,resm_sing, I
34+
REAL(r8) :: resnum,resm_sing,min_diff,dtheta
3535
INTEGER, DIMENSION(msing) :: resm
3636
LOGICAL :: is_hermitian
37-
REAL(r8) :: tolerance
37+
REAL(r8) :: tolerance, dx
3838
REAL(r8), DIMENSION(0:mtheta) :: r,z,theta
39-
39+
REAL(r8), DIMENSION(sq%mx+1) :: I_psin
4040
REAL(r8),DIMENSION(msing) :: L,f_L,f_S,nu_L,nu_S,DI,J,rho,shear
4141

4242
COMPLEX(r8), DIMENSION(msing,msing) :: A_prime,B_prime,
@@ -51,10 +51,15 @@ SUBROUTINE symmetrize(dp)
5151
REAL(r8), DIMENSION(2,2) :: w
5252
TYPE(spline_type) :: spl
5353

54-
npsi = sq%mx+1
54+
npsi = sq%mx
5555

5656
psi_a=0.1 !!!!!!!!!!!!!!
5757

58+
WRITE(*,*)"sq%mx=",sq%mx
59+
WRITE(*,*)"npsi=",npsi
60+
!WRITE(*,*)"sq%xs=",sq%xs
61+
62+
5863
! construct PEST3 matching data (keep synced with RDCON!)
5964
A_prime=0.0
6065
B_prime=0.0
@@ -89,36 +94,86 @@ SUBROUTINE symmetrize(dp)
8994
resm(ising)=resm_sing
9095
ENDDO
9196

97+
!WRITE(*,*)"respsi=",respsi
98+
WRITE(*,*)"resnum=",resnum
99+
WRITE(*,*)"resm=",resm
100+
92101
! STILL NEED psi_a
93-
I = 0
94-
DO ipsi=1,npsi
95-
!CALL spline_eval(sq,psi(ipsi),0)
96-
I = I + 2.0*(sq%f(4) / (sq%fs(ipsi,1)/twopi)) !DB this is F!
97-
ENDDO
102+
!I = 0
103+
!DO ipsi=1,npsi
104+
! !CALL spline_eval(sq,psi(ipsi),0)
105+
! I = I + 2.0*(sq%f(4) / (sq%fs(ipsi,1)/twopi)) !DB this is F!
106+
!ENDDO
98107

99-
DO ising=1,msing
100-
!resnum=NINT(sing(ising)%q*nn)-mlow+1
101-
respsi=sing(ising)%psifac
102-
CALL spline_eval(sq,respsi,1)
108+
I_psin(1) = 0.0 ! integral at x=0 is 0
109+
110+
!WRITE(*,*)"sq%fs(:,4)=",sq%fs(:,4)
111+
!WRITE(*,*)"SIZE(sq%fs(:,4))=",SIZE(sq%fs(:,4))
103112

104-
DO itheta=0,mthsurf
105-
CALL bicube_eval(rzphi,respsi,theta(itheta),1)
106-
jac=rzphi%f(4)
107-
w(1,1)=(1+rzphi%fy(2))*twopi**2*rfac*r(itheta)/jac
108-
w(1,2)=-rzphi%fy(1)*pi*r(itheta)/(rfac*jac)
109-
delpsi=SQRT(w(1,1)**2+w(1,2)**2)
113+
!WRITE(*,*)"sq%fs(npsi,4)=",sq%fs(npsi,4)
110114

111-
J(ising)=J(ising)+(1.0/delpsi**2)*jac!*(1.0/twopi) !DB !!!
112-
ENDDO
115+
!WRITE(*,*)"sq%fs(5,4)=",sq%fs(5,4)
116+
117+
DO ipsi = 2, npsi
118+
I_psin(ipsi) = 0.0
119+
DO jpsi = 1, ipsi-1
120+
dx = sq%xs(jpsi+1) - sq%xs(jpsi)
121+
I_psin(ipsi) = I_psin(ipsi) +
122+
$ (2.0*sq%fs(jpsi,4)/(sq%fs(jpsi,1)/twopi))*dx ! check q
123+
END DO
124+
END DO
113125

114-
rho(ising) = (J(ising) * (sq%fs(respsi,1)/twopi))/sq%f(4) !DB
126+
!WRITE(*,*)"I_psin=",I_psin
127+
128+
DO ising=1,msing
129+
!resnum=NINT(sing(ising)%q*nn)-mlow+1
130+
respsi=sing(ising)%psifac
131+
WRITE(*,*)"respsi=",respsi
132+
133+
!!! FIND CORRECT I_PSIN INDEX
134+
min_diff = abs(sq%xs(1) - respsi)
135+
idx = 1
136+
137+
do ipsi = 2, npsi
138+
if (abs(sq%xs(ipsi) - respsi) < min_diff) then
139+
min_diff = abs(sq%xs(ipsi) - respsi)
140+
idx = ipsi
141+
end if
142+
end do
143+
144+
WRITE(*,*)"idx=",idx
145+
146+
!CALL spline_eval(sq,respsi,1)
147+
dtheta = twopi / real(mthsurf)
148+
149+
!DO itheta=0,mthsurf
150+
! CALL bicube_eval(rzphi,respsi,theta(itheta),1)
151+
! jac=rzphi%f(4)
152+
! w(1,1)=(1+rzphi%fy(2))*twopi**2*rfac*r(itheta)/jac
153+
! w(1,2)=-rzphi%fy(1)*pi*r(itheta)/(rfac*jac)
154+
! delpsi=SQRT(w(1,1)**2+w(1,2)**2)
155+
! WRITE(*,*)"delpsi=",delpsi
156+
157+
! J(ising)=J(ising)+(1.0/delpsi**2)*0.5*dtheta!jac!*(1.0/twopi) !DB !!!
158+
!ENDDO
159+
160+
WRITE(*,*)"J=",J
161+
162+
rho(ising) = (J(ising) * (sq%fs(idx,1)/twopi))/sq%f(4) !DB
115163
shear(ising)=sing(ising)%q1
164+
WRITE(*,*)"rho=",rho
165+
WRITE(*,*)"sq%f(4)=",sq%f(4)
166+
167+
L(ising)=I_psin(idx)*(J(ising)*((resm(ising)*
168+
$ (sq%fs(idx,1)/twopi))/sq%f(4))**2+(nn * psi_a)**2 ) !DB
116169

117-
L(ising)=I*(J(ising)*((resm(ising)*(sq%fs(respsi,1)/twopi)
118-
$ )/sq%f(4))**2+(nn * psi_a)**2 ) !DB
170+
WRITE(*,*)"L=",L
171+
WRITE(*,*)"sq%fs(respsi,1)=",sq%fs(respsi,1)
172+
WRITE(*,*)"sq%fs(idx,1)=",sq%fs(idx,1)
119173

120174
! CALL mercier_mod
121-
DI(ising) = locstab%fs(respsi,1)/sq%xs(respsi) !DB
175+
DI(ising) = locstab%fs(idx,1)/sq%xs(idx) !DB
176+
WRITE(*,*)"DI=",DI
122177

123178
nu_L(ising) = 0.5 - SQRT(-DI(ising)) !DB
124179
nu_S(ising) = 0.5 + SQRT(-DI(ising)) !DB

0 commit comments

Comments
 (0)