Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magnetic axis data saved in axis_r,phi,z #90

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sources/globals.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module globals
!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!


CHARACTER(10), parameter :: version='v0.18.00' ! version number
CHARACTER(10), parameter :: version='v0.18.01' ! version number


!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!
Expand Down Expand Up @@ -238,6 +238,7 @@ module globals
INTEGER :: pp_nsteps = 1
INTEGER :: pp_nfp = 1
REAL :: pp_xtol = 1.000D-06
INTEGER :: axis_npoints = 360

namelist / focusin / &
IsQuiet ,&
Expand Down Expand Up @@ -337,7 +338,7 @@ module globals
Nmax ,&
sdelta ,&
case_optimize ,&
fdiff_delta ,&
fdiff_delta ,&
exit_tol ,&
DF_maxiter ,&
DF_xtol ,&
Expand Down Expand Up @@ -376,7 +377,8 @@ module globals
pp_maxiter ,&
pp_nsteps ,&
pp_nfp ,&
pp_xtol
pp_xtol ,&
axis_npoints

!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!

Expand Down Expand Up @@ -538,7 +540,7 @@ module globals
!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!

! fieldline tracing
REAL, ALLOCATABLE :: XYZB(:,:,:), ppr(:,:), ppz(:,:), iota(:)
REAL, ALLOCATABLE :: XYZB(:,:,:), ppr(:,:), ppz(:,:), iota(:), axis_phi(:), axis_r(:), axis_z(:)
INTEGER :: tor_num, total_num, booz_mpol, booz_ntor, booz_mn
LOGICAL :: lboozmn = .false.
INTEGER, ALLOCATABLE :: bmim(:), bmin(:)
Expand Down
25 changes: 22 additions & 3 deletions sources/poinplot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ END SUBROUTINE poinplot
!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!

SUBROUTINE find_axis(RZ, MAXFEV, XTOL)
USE globals, only : dp, myid, ounit, zero, pp_phi
USE globals, only : dp, myid, ounit, zero, pi2, sqrtmachprec, &
pp_phi, pp_xtol, axis_phi, axis_r, axis_z, axis_npoints
USE mpi
IMPLICIT NONE

Expand All @@ -155,11 +156,13 @@ SUBROUTINE find_axis(RZ, MAXFEV, XTOL)

INTEGER, parameter :: n=2
INTEGER :: ml,mu,mode,nprint,info,nfev,ldfjac,lr
INTEGER :: iwork(5), ierr, astat, ifail, i
REAL :: epsfcn,factor
REAL :: fvec(n),diag(n),qtf(n),wa1(n),wa2(n),wa3(n),wa4(n)
REAL :: rz_end(n), phi_init, phi_stop, relerr, abserr, work(100+21*N)
REAL, allocatable :: fjac(:,:),r(:)
external :: axis_fcn
external :: axis_fcn, BRpZ

LR = N*(N+1)/2
LDFJAC = N
ml = n-1
Expand Down Expand Up @@ -195,6 +198,22 @@ SUBROUTINE find_axis(RZ, MAXFEV, XTOL)
write(ounit,'("findaxis: info="I2", something wrong with the axis finding subroutine.")') info
end select
endif

! save axis data
SALLOCATE(axis_phi, (1:axis_npoints), zero)
SALLOCATE(axis_r , (1:axis_npoints), zero)
SALLOCATE(axis_z , (1:axis_npoints), zero)
relerr = pp_xtol
abserr = sqrtmachprec
rz_end = RZ
do i = 1, axis_npoints
axis_phi(i) = pp_phi + (i - 1) * pi2 / axis_npoints
axis_r(i) = rz_end(1) ; axis_z(i) = rz_end(2)
ifail = 1
phi_init = axis_phi(i)
phi_stop = phi_init + pi2 / axis_npoints
call ode( BRpZ, n, rz_end, phi_init, phi_stop, relerr, abserr, ifail, work, iwork )
enddo

return

Expand Down
4 changes: 4 additions & 0 deletions sources/saving.f90
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ subroutine saving
HWRITEIV( 1 , pp_ns , pp_ns )
HWRITEIV( 1 , pp_maxiter , pp_maxiter )
HWRITERV( 1 , pp_xtol , pp_xtol )
HWRITEIV( 1 , axis_npoints , axis_npoints )

HWRITEIV( 1 , Nfp , surf(plasma)%Nfp )
HWRITERV( 1 , surf_vol , surf(plasma)%vol )
Expand Down Expand Up @@ -346,6 +347,9 @@ subroutine saving
HWRITERA( pp_ns, pp_maxiter+1, ppr , ppr(1:pp_ns, 0:pp_maxiter) )
HWRITERA( pp_ns, pp_maxiter+1, ppz , ppz(1:pp_ns, 0:pp_maxiter) )
HWRITERV( pp_ns , iota , iota(1:pp_ns) )
HWRITERV( axis_npoints , axis_phi , axis_phi(1:axis_npoints) )
HWRITERV( axis_npoints , axis_r , axis_r(1:axis_npoints) )
HWRITERV( axis_npoints , axis_z , axis_z(1:axis_npoints) )
endif

if (allocated(XYZB)) then
Expand Down