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

Added species specific energy grids #113

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,10 @@ test1_run:
cd ${TESTDIR1}; ${MPIRUN} ./ram_scb.exe | tee runlog

test1_check:
${SCRIPTDIR}/DiffNum.pl -b -a=1e-9 \
${TESTDIR1}/output_ram/log_d20130317_t000000.log \
${IMDIR}/output/test1/log.ref \
> test1.diff
${SCRIPTDIR}/DiffNum.pl -b -a=1e-9 \
${TESTDIR1}/output_ram/pressure_d20130317_t001500.dat \
${IMDIR}/output/test1/pressure.ref \
>> test1.diff
> test1.diff
ncdump -v "Flux_H","B_xyz" \
${TESTDIR1}/output_ram/sat1_d20130317_t000000.nc \
| sed -e '1,/data:/d' > \
Expand Down
Binary file modified input/initialization.nc
Binary file not shown.
6 changes: 3 additions & 3 deletions src/ModRamBoundary.f90
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ subroutine get_geomlt_flux(NameParticleIn, fluxOut_II)
! outside of the files energy range.
rE = 0
lE = 0
if (eGrid_SI(iSpec,1).gt.EkeV(1)) lE = 1
if (eGrid_SI(iSpec,NEL_).lt.EkeV(nE)) rE = 1
if (eGrid_SI(iSpec,1).gt.EkeV(iSpec, 1)) lE = 1
if (eGrid_SI(iSpec,NEL_).lt.EkeV(iSpec, nE)) rE = 1
pE = rE + lE
allocate(flux_II(0:NTL,NEL_+pE), logFlux_II(nT,NEL_+pE), logELan(NEL_+pE), logERam(nE))
flux_II = 0.0; logFlux_II = 0.0; logELan = 0.0; logERam = 0.0
Expand Down Expand Up @@ -201,7 +201,7 @@ subroutine get_geomlt_flux(NameParticleIn, fluxOut_II)
logELan(1+lE:NEL_+le) = log10(eGrid_SI(iSpec,1:NEL_))
if (lE.eq.1) logELan(1) = log10(0.1000)
if (rE.eq.1) logELan(NEL_+pE) = log10(1000.00)
logERam = log10(Ekev)
logERam = log10(Ekev(iSpec,:))

! Interpolate/Extrapolate in energy space; return to normal units.
! Interpolation in Log space isn't really needed with the GSL interpolation
Expand Down
10 changes: 5 additions & 5 deletions src/ModRamCoul.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ SUBROUTINE COULPARA(S)
!...Collisions with plasmaspheric ions
COULI(S,K,1)=-CCI*VBND(S,K)*CCO*GRBND(S,K)**2
!...Energy deposition rate [eV/cm2/s] in 1 hemisphere, check:
CEDR(S,K,1)=EDRCO*EKEV(K)*EDRE*(GREL(S,K)+1)/GREL(S,K)**2/V(S,K)**2
CIDR(S,K,1)=EDRCO*EKEV(K)*EDRI*(GREL(S,K)+1)/GREL(S,K)**2/V(S,K)**2
CEDR(S,K,1)=EDRCO*EKEV(S,K)*EDRE*(GREL(S,K)+1)/GREL(S,K)**2/V(S,K)**2
CIDR(S,K,1)=EDRCO*EKEV(S,K)*EDRI*(GREL(S,K)+1)/GREL(S,K)**2/V(S,K)**2
!...Coulomb scattering
CCDE=CCD*CDE*GREL(S,K)/(GREL(S,K)**2-1)**(1.5)
CCDI=CCD*CDI*GREL(S,K)/(GREL(S,K)**2-1)**(1.5)
Expand Down Expand Up @@ -152,7 +152,7 @@ SUBROUTINE COULEN(S)

T=TimeRamElapsed

EZERO=EKEV(1)-WE(1)
EZERO=EKEV(S,1)-WE(S,1)
GRZERO(S)=1.+EZERO*1000.*Q/RMAS(S)/CS/CS
F(NE+1)=0.
F(NE+2)=0.
Expand Down Expand Up @@ -201,14 +201,14 @@ SUBROUTINE COULEN(S)
IF (R.LE.0) FBND(K)=FUP
IF (R.GT.0) THEN
LIMITER=MAX(MIN(BetaLim*R,1.),MIN(R,BetaLim))
CORR=-0.5*(CccolE(K)/DE(K)-ISIGN)*X
CORR=-0.5*(CccolE(K)/DE(S,K)-ISIGN)*X
FBND(K)=FUP+LIMITER*CORR
END IF
END IF
END DO

DO K=2,NE
F2(S,I,J,K,L)=F2(S,I,J,K,L)-CccolE(K)/WE(K)*FBND(K)+CccolE(K-1)/WE(K)*FBND(K-1)
F2(S,I,J,K,L)=F2(S,I,J,K,L)-CccolE(K)/WE(S,K)*FBND(K)+CccolE(K-1)/WE(S,K)*FBND(K-1)
if (f2(s,i,j,k,l) < 0._dp) then
! write(*,*) 'in COULEN f2<0 ', S,i,j,k,l, f2(S,i,j,k,l)
f2(S,i,j,k,l)=1E-15
Expand Down
4 changes: 2 additions & 2 deletions src/ModRamCouple.f90
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ subroutine generate_flux

! Convert from moments to fluxes:
do iE=1, nE
eCent = 1000.0 * Ekev(iE) ! Center of energy bin in eV.
factor=4.0E6*Ekev(iE) ! Unit conversion factor * eCent in KeV.
do iT=1, nT
select case(TypeMhd)
case('single')
if (NameDistrib .eq. 'MAXW') then
! Assuming a maxwellian distribution about MHD temperature, divide
! densities into energy bins and calculate fluxes.
do iS = 1, nS
eCent = 1000.0 * Ekev(iS,iE) ! Center of energy bin in eV.
factor=4.0E6*Ekev(iS,iE) ! Unit conversion factor * eCent in KeV.
FluxBats_IIS(iE,iT,iS) = 1./sqrt(species(iS)%s_mass) &
*exp(-1.0*eCent/MhdDensPres_VII(2,iT,iS)) &
*factor*MhdDensPres_VII(1,iT,iS) &
Expand Down
18 changes: 9 additions & 9 deletions src/ModRamDrift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SUBROUTINE DRIFTPARA(S)
P1(I)=DTs/DPHI/2/MDR/RLZ(I)
END DO
DO K=1,NE
P2(I,K)=DTs*EKEV(K)*1000*(GREL(S,K)+1)/GREL(S,K)/RLZ(I)**2/DPHI/QS
P2(I,K)=DTs*EKEV(S,K)*1000*(GREL(S,K)+1)/GREL(S,K)/RLZ(I)**2/DPHI/QS
END DO
END DO

Expand All @@ -80,7 +80,7 @@ SUBROUTINE DRIFTPARA(S)
END DO
MUDOT(I,NPA)=0.
DO K=1,NE
EDOT(I,K)=EBND(K)*DTs/RLZ(I)*(GRBND(S,K)+1)/GRBND(S,K)/2.
EDOT(I,K)=EBND(S,K)*DTs/RLZ(I)*(GRBND(S,K)+1)/GRBND(S,K)/2.
END DO
END DO

Expand Down Expand Up @@ -128,7 +128,7 @@ SUBROUTINE DRIFTR(S)

! Gradient Curvature Radial Drift
DO K=1,NE
P4=DTs*EKEV(K)*1000.0*(GREL(S,K)+1)/GREL(S,K)/DPHI/MDR/QS
P4=DTs*EKEV(S,K)*1000.0*(GREL(S,K)+1)/GREL(S,K)/DPHI/MDR/QS
DO L=1,NPA
DO J=1,NT
F(1:NR) = F2(S,:,J,K,L)
Expand Down Expand Up @@ -307,7 +307,7 @@ SUBROUTINE DRIFTE(S)

DtDriftE(S)=10000.0
OME=7.3E-5
EZERO=EKEV(1)-WE(1)
EZERO=EKEV(S,1)-WE(S,1)
GRZERO(S)=1.+EZERO*1000.*Q/RMAS(S)/CS/CS
F(NE+1)=0.
F(NE+2)=0.
Expand All @@ -334,15 +334,15 @@ SUBROUTINE DRIFTE(S)
F(1) = F(2)*GREL(S,1)/GREL(S,2)*SQRT((GREL(S,2)**2-1)/(GREL(S,1)**2-1))
F(0) = F(1)*GRZERO(S)/GREL(S,1)*SQRT((GREL(S,1)**2-1)/(GRZERO(S)**2-1))
DO K=1,NE
EDT1 = EBND(K)*1e3*(GRBND(S,K)+1)/2/GRBND(S,K)/FNHS(I,J,L)/RLZ(I)/BNES(I,J)/QS
EDT1 = EBND(S,K)*1e3*(GRBND(S,K)+1)/2/GRBND(S,K)/FNHS(I,J,L)/RLZ(I)/BNES(I,J)/QS
DRDT = DRD1+EDT1*DRD2*RLZ(I)
DPDT = DPD1-EDT1*DPD2
dBdt1 = dBdt(I,J)*(1.-FNIS(I,J,L)/2./FNHS(I,J,L))*RLZ(I)/BNES(I,J)
dIdt1 = -dIdt(I,J,L)*RLZ(I)/FNHS(I,J,L)
CDriftE(I,J,K,L) = EDOT(I,K)*((GPR1+GPR2+GPR3)*DRDT+(GPP1+GPP2)*DPDT+dBdt1+dIdt1)
if (outsideMGNP(i,j) == 0) then
ctemp = max(abs(CDriftE(I,J,K,L)),1E-10)
DtDriftE(S) = min(DtDriftE(S), FracCFL*DTs*DE(K)/ctemp)
DtDriftE(S) = min(DtDriftE(S), FracCFL*DTs*DE(S,K)/ctemp)
endif
sgn = 1
if (CDriftE(I,J,K,L).lt.0) sgn = -1
Expand All @@ -355,13 +355,13 @@ SUBROUTINE DRIFTE(S)
IF (R.LE.0) FBND(K)=FUP
IF (R.GT.0) THEN
LIMITER=MAX(MIN(BetaLim*R,1.),MIN(R,BetaLim))
CORR=-0.5*(CDriftE(I,J,K,L)/DE(K)-sgn)*X
CORR=-0.5*(CDriftE(I,J,K,L)/DE(S,K)-sgn)*X
FBND(K)=FUP+LIMITER*CORR
END IF
END IF
END DO
DO K=2,NE
F2(S,I,J,K,L)=F2(S,I,J,K,L)-CDriftE(I,J,K,L)/WE(K)*FBND(K)+CDriftE(I,J,K-1,L)/WE(K)*FBND(K-1)
F2(S,I,J,K,L)=F2(S,I,J,K,L)-CDriftE(I,J,K,L)/WE(S,K)*FBND(K)+CDriftE(I,J,K-1,L)/WE(S,K)*FBND(K-1)
if (f2(s,i,j,k,l).lt.0) then
! write(*,*) 'in DRIFTE f2<0 ', S,i,j,k,l, f2(S,i,j,k,l)
f2(S,i,j,k,l)=1E-15
Expand Down Expand Up @@ -421,7 +421,7 @@ SUBROUTINE DRIFTMU(S)
GMR3 = (BOUNIS(I+1,J,L)-BOUNIS(I-1,J,L))/2/MDR/BOUNIS(I,J,L)
GMP1 = (BNES(I,J1)-BNES(I,J0))/4/DPHI/BNES(I,J)
GMP2 = (BOUNIS(I,J1,L)-BOUNIS(I,J0,L))/2/DPHI/BOUNIS(I,J,L)
EDT = EKEV(K)*1e3*(GREL(S,K)+1)/2/GREL(S,K)/BOUNHS(I,J,L)/RLZ(I)/BNES(I,J)/QS
EDT = EKEV(S,K)*1e3*(GREL(S,K)+1)/2/GREL(S,K)/BOUNHS(I,J,L)/RLZ(I)/BNES(I,J)/QS
DRM2 = (BOUNIS(I,J1,L)-BOUNIS(I,J0,L))/2/DPHI+(BOUNIS(I,J,L)-2*BOUNHS(I,J,L)) &
*(BNES(I,J1)-BNES(I,J0))/4/BNES(I,J)/DPHI
DPM2 = BOUNIS(I,J,L)+(BOUNIS(I+1,J,L)-BOUNIS(I-1,J,L))*RLZ(I)/2/MDR &
Expand Down
2 changes: 1 addition & 1 deletion src/ModRamFunctions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ subroutine get_ramdst(dstOut)
if(l.ge.uPa(i))cycle
do j=1, nT-1
if (outsideMGNP(i,j) == 0) then
sumEnergy=sumEnergy+f2(s,i,j,k,l)*wE(k)*wMu(L)*eKeV(k)
sumEnergy=sumEnergy+f2(s,i,j,k,l)*wE(S,k)*wMu(L)*eKeV(s,k)
endif
end do
end do; end do; end do; end do
Expand Down
Loading