| 62 | | 8. [https://astrobear.pas.rochester.edu/trac/wiki/u/adebrech/Matlab/IonizationFront Ionization front] |
| | 62 | 9. [https://astrobear.pas.rochester.edu/trac/wiki/u/adebrech/Matlab/IonizationFront Ionization front] |
| | 63 | |
| | 64 | == Current code == |
| | 65 | |
| | 66 | {{{ |
| | 67 | ! Goal is to take input flux and integrate equations across grid to find ionization rate and heating rate |
| | 68 | ! Flux has units of number per area per time in computational units |
| | 69 | ! Data has computational units of the density of neutral hydrogen, ionized hydrogen, ionization rate, and heating rate |
| | 70 | SUBROUTINE DoLineTransfer(data, rates) |
| | 71 | INTEGER :: i,j,k |
| | 72 | REAL(KIND=qPREC) :: emtau, f, dx, tau, dtau |
| | 73 | REAL(KIND=qpREC), DIMENSION(:,:,:,:) :: data, rates |
| | 74 | !Scale parameters to computational scales |
| | 75 | |
| | 76 | dx=levels(MaxLevel)%dx |
| | 77 | ! write(*,*) LineTransferFlux |
| | 78 | |
| | 79 | !$OMP PARALLEL DO SCHEDULE(STATIC) COLLAPSE(2) SHARED(sigmaH_scale, egamma_scale, dx, rates, data, LineTransferFlux) PRIVATE(i,j,k,tau,f,dtau,emtau) DEFAULT(NONE) |
| | 80 | DO j=1,size(data,2) |
| | 81 | DO k=1,size(data,3) |
| | 82 | tau=0d0 |
| | 83 | f=LineTransferFlux |
| | 84 | !write(*,'(A4,20A25)'), 'i', 'f', 'nH','nHII', 'exp(-tau)', 'dtau', 'sigmaH_scale', 'dx' |
| | 85 | DO i=1,size(data,1) |
| | 86 | |
| | 87 | !First calculate exp(-tau) where tau =sigmaH*nH+sigmad*nHII |
| | 88 | ! emtau=exp(-(sigmaH_scale*data(i,j,k,iH) + sigmad_scale*data(i,j,k,iHII))*dx) ) |
| | 89 | dtau=(sigmaH_scale*data(i,j,k,lt_iH)*dx) |
| | 90 | emtau=exp(-dtau) |
| | 91 | !if (emtau /= 1.) write(*,'(I4,20E25.15)') i, f, data(i,j,k,iH:iHII), emtau,(sigmaH_scale*data(i,j,k,iH))*dx, sigmaH_scale, dx |
| | 92 | !Store the photon absorption rate used to calculate the heating and ionization rates |
| | 93 | rates(i,j,k,iioniz)=f*(1d0-emtau)/dx !has computational units of number per volume per second |
| | 94 | ! rates(i,j,k,iheat)=0 |
| | 95 | rates(i,j,k,iheat)=f*(1d0-emtau)/dx*egamma_scale !has computational units of energy per volume per second |
| | 96 | |
| | 97 | !Update the flux for the next cell along this ray |
| | 98 | f=f*emtau |
| | 99 | tau=tau+dtau |
| | 100 | data(i,j,k,lt_iD)=tau |
| | 101 | END DO |
| | 102 | END DO |
| | 103 | END DO |
| | 104 | !$OMP END PARALLEL DO |
| | 105 | END SUBROUTINE DoLineTransfer |
| | 106 | }}} |
| | 107 | |
| | 108 | |