Checks whether quasi-neutrality is satisfied to some tol
subroutine quasineutrality_check
!+ Checks whether quasi-neutrality is satisfied to some tol
real(Float64) :: tol = 0.01
real(Float64), dimension(:,:,:), allocatable :: quasi, deni
integer :: i, quasi_cnt
allocate(deni(inter_grid%nr,inter_grid%nz,inter_grid%nphi))
deni = 0.d0
do i=1,n_thermal
deni = deni + equil%plasma%deni(i)
enddo
!! Quasi-neutrality check
allocate(quasi(inter_grid%nr,inter_grid%nz,inter_grid%nphi))
where(equil%mask.ge.0.5)
quasi = equil%plasma%dene - (deni + impurity_charge*equil%plasma%denimp + equil%plasma%denf)
end where
quasi_cnt = count(abs(quasi).gt.(tol*equil%plasma%dene))
if(inputs%verbose.ge.1) then
write(*,'(a)') '---- Quasi-neutrality Check ----'
write(*,'(T2, a, f5.2, "%")') 'Tolerance: ',tol*100
write(*,'(T2, a, f6.2, "%")') 'Percent Failure: ', &
100.0*quasi_cnt/size(quasi)
write(*,*) ''
endif
deallocate(deni,quasi)
end subroutine quasineutrality_check