Skip to content
Snippets Groups Projects
Commit f082a411 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann :seedling:
Browse files

debug miller + staggered grid (for loop error)

parent 8a8294db
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ MODULE miller ...@@ -6,7 +6,7 @@ MODULE miller
USE basic USE basic
USE parallel, ONLY: my_id, num_procs_z, nbr_U, nbr_D, comm0 USE parallel, ONLY: my_id, num_procs_z, nbr_U, nbr_D, comm0
! use coordinates,only: gcoor, get_dzprimedz ! use coordinates,only: gcoor, get_dzprimedz
USE grid, ONLY: local_Nky, local_Nkx, local_nz, ngz, nzgrid, kyarray, kxarray, zarray, total_nz, local_nz_offset, iodd, ieven USE grid, ONLY: local_Nky, local_Nkx, local_nz, ngz, nzgrid, kyarray, kxarray, zarray, total_nz, local_nz_offset, iodd, ieven, deltaz
! use discretization ! use discretization
USE lagrange_interpolation USE lagrange_interpolation
...@@ -516,6 +516,7 @@ CONTAINS ...@@ -516,6 +516,7 @@ CONTAINS
!(R,Z) derivatives for visualization !(R,Z) derivatives for visualization
dxdR_s = dx_drho/drPsi*psi1_s*cosu_s dxdR_s = dx_drho/drPsi*psi1_s*cosu_s
dxdZ_s = dx_drho/drPsi*psi1_s*sinu_s dxdZ_s = dx_drho/drPsi*psi1_s*sinu_s
! GHOSTS ADAPTED VERSION ! GHOSTS ADAPTED VERSION
if (edge_opt==0._xp) then if (edge_opt==0._xp) then
!gyacomo z-grid wo ghosts !gyacomo z-grid wo ghosts
...@@ -524,45 +525,49 @@ CONTAINS ...@@ -524,45 +525,49 @@ CONTAINS
chi_out=linspace(-pi*Npol-4._xp*pi*Npol/total_nz,pi*Npol+2._xp*pi*Npol/total_nz,total_nz+ngz) chi_out=linspace(-pi*Npol-4._xp*pi*Npol/total_nz,pi*Npol+2._xp*pi*Npol/total_nz,total_nz+ngz)
else else
ERROR STOP '>> ERROR << ghosts not implemented for edge_opt yet' ERROR STOP '>> ERROR << ghosts not implemented for edge_opt yet'
!new parallel coordinate chi_out==zprime !new parallel coordinate chi_out==zprime
!see also tracer_aux.F90 !see also tracer_aux.F90
if (Npol>1) ERROR STOP '>> ERROR << Npol>1 has not been implemented for edge_opt=\=0._xp' if (Npol>1) ERROR STOP '>> ERROR << Npol>1 has not been implemented for edge_opt=\=0._xp'
do k=1,total_nz do k=1,total_nz
chi_out(k)=sinh((-pi+k*2._xp*pi/total_nz)*log(edge_opt*pi+sqrt(edge_opt**2*pi**2+1))/pi)/edge_opt chi_out(k)=sinh((-pi+k*2._xp*pi/total_nz)*log(edge_opt*pi+sqrt(edge_opt**2*pi**2+1))/pi)/edge_opt
enddo enddo
!transform metrics according to chain rule !transform metrics according to chain rule
do k=1,np_s do k=1,np_s
!>dz'/dz conversion for edge_opt as function of z !>dz'/dz conversion for edge_opt as function of z
if (edge_opt.gt.0) then if (edge_opt.gt.0) then
dzprimedz = edge_opt*pi/log(edge_opt*pi+sqrt((edge_opt*pi)**2+1._xp))/& dzprimedz = edge_opt*pi/log(edge_opt*pi+sqrt((edge_opt*pi)**2+1._xp))/&
sqrt((edge_opt*chi_s(k))**2+1) sqrt((edge_opt*chi_s(k))**2+1)
else else
dzprimedz = 1.0 dzprimedz = 1.0
endif endif
gxz(k)=gxz(k)*dzprimedz gxz(k)=gxz(k)*dzprimedz
gyz(k)=gyz(k)*dzprimedz gyz(k)=gyz(k)*dzprimedz
gzz(k)=gzz(k)*dzprimedz**2 gzz(k)=gzz(k)*dzprimedz**2
jacobian(k)=jacobian(k)/dzprimedz jacobian(k)=jacobian(k)/dzprimedz
dBdz(k)=dBdz(k)/dzprimedz dBdz(k)=dBdz(k)/dzprimedz
enddo enddo
endif !edge_opt endif !edge_opt
! interpolate with ghosts
call lag3interp(gxx,chi_s,np_s,gxx_out,chi_out,total_nz+ngz) !! Loop over the z-grids and interpolate the results on it
call lag3interp(gxy,chi_s,np_s,gxy_out,chi_out,total_nz+ngz) do eo=ieven,iodd
call lag3interp(gxz,chi_s,np_s,gxz_out,chi_out,total_nz+ngz) ! Shift the grid
call lag3interp(gyy,chi_s,np_s,gyy_out,chi_out,total_nz+ngz) chi_out = chi_out + REAL(eo-1,xp)*0.5*deltaz
call lag3interp(gyz,chi_s,np_s,gyz_out,chi_out,total_nz+ngz) ! interpolate with ghosts
call lag3interp(gzz,chi_s,np_s,gzz_out,chi_out,total_nz+ngz) call lag3interp(gxx,chi_s,np_s,gxx_out,chi_out,total_nz+ngz)
call lag3interp(B_s,chi_s,np_s,Bfield_out,chi_out,total_nz+ngz) call lag3interp(gxy,chi_s,np_s,gxy_out,chi_out,total_nz+ngz)
call lag3interp(dBdx,chi_s,np_s,dBdx_out,chi_out,total_nz+ngz) call lag3interp(gxz,chi_s,np_s,gxz_out,chi_out,total_nz+ngz)
call lag3interp(dBdz,chi_s,np_s,dBdz_out,chi_out,total_nz+ngz) call lag3interp(gyy,chi_s,np_s,gyy_out,chi_out,total_nz+ngz)
call lag3interp(jacobian,chi_s,np_s,jacobian_out,chi_out,total_nz+ngz) call lag3interp(gyz,chi_s,np_s,gyz_out,chi_out,total_nz+ngz)
call lag3interp(R_s,chi_s,np_s,R_out,chi_out,total_nz+ngz) call lag3interp(gzz,chi_s,np_s,gzz_out,chi_out,total_nz+ngz)
call lag3interp(Z_s,chi_s,np_s,Z_out,chi_out,total_nz+ngz) call lag3interp(B_s,chi_s,np_s,Bfield_out,chi_out,total_nz+ngz)
call lag3interp(dxdR_s,chi_s,np_s,dxdR_out,chi_out,total_nz+ngz) call lag3interp(dBdx,chi_s,np_s,dBdx_out,chi_out,total_nz+ngz)
call lag3interp(dxdZ_s,chi_s,np_s,dxdZ_out,chi_out,total_nz+ngz) call lag3interp(dBdz,chi_s,np_s,dBdz_out,chi_out,total_nz+ngz)
! Fill the local geom arrays with the results call lag3interp(jacobian,chi_s,np_s,jacobian_out,chi_out,total_nz+ngz)
do eo=iodd,ieven call lag3interp(R_s,chi_s,np_s,R_out,chi_out,total_nz+ngz)
call lag3interp(Z_s,chi_s,np_s,Z_out,chi_out,total_nz+ngz)
call lag3interp(dxdR_s,chi_s,np_s,dxdR_out,chi_out,total_nz+ngz)
call lag3interp(dxdZ_s,chi_s,np_s,dxdZ_out,chi_out,total_nz+ngz)
! Fill the local geom arrays with the results
DO iz = 1,local_nz + ngz DO iz = 1,local_nz + ngz
gxx_(iz,eo) = gxx_out(iz+local_nz_offset) gxx_(iz,eo) = gxx_out(iz+local_nz_offset)
gxy_(iz,eo) = gxy_out(iz+local_nz_offset) gxy_(iz,eo) = gxy_out(iz+local_nz_offset)
...@@ -580,7 +585,7 @@ CONTAINS ...@@ -580,7 +585,7 @@ CONTAINS
dxdR_(iz,eo) = dxdR_out(iz+local_nz_offset) dxdR_(iz,eo) = dxdR_out(iz+local_nz_offset)
dxdZ_(iz,eo) = dxdZ_out(iz+local_nz_offset) dxdZ_(iz,eo) = dxdZ_out(iz+local_nz_offset)
ENDDO ENDDO
ENDDO ENDDO
contains contains
!> Generate an equidistant array from min to max with n points !> Generate an equidistant array from min to max with n points
function linspace(min,max,n) result(out) function linspace(min,max,n) result(out)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment