Scrambler  1
cylindrical.f90
Go to the documentation of this file.
00001 !#########################################################################
00002 !               
00003 !    Copyright (C) 2003-2012 Department of Physics and Astronomy,
00004 !                            University of Rochester,
00005 !                            Rochester, NY
00006 !
00007 !    cylindrical.f90 is part of AstroBEAR.
00008 !
00009 !    AstroBEAR is free software: you can redistribute it and/or modify    
00010 !    it under the terms of the GNU General Public License as published by 
00011 !    the Free Software Foundation, either version 3 of the License, or    
00012 !    (at your option) any later version.
00013 !
00014 !    AstroBEAR is distributed in the hope that it will be useful, 
00015 !    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 !    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 !    GNU General Public License for more details.
00018 !
00019 !    You should have received a copy of the GNU General Public License
00020 !    along with AstroBEAR.  If not, see <http://www.gnu.org/licenses/>.
00021 !
00022 !#########################################################################
00023 MODULE CylindricalSrc
00024 
00025   USE DataDeclarations
00026   USE PhysicsDeclarations
00027   USE EOS
00028   USE SourceDeclarations
00029 
00030   IMPLICIT NONE
00031   PRIVATE
00032   PUBLIC Cylindrical
00033 
00034 CONTAINS
00035 
00036   SUBROUTINE Cylindrical(q,dqdt,pos,lform)
00037     ! Interface declarations
00038     REAL(KIND=qPrec) :: q(:)
00039     REAL(KIND=qPrec),INTENT(INOUT) :: dqdt(:)
00040     REAL(KIND=xPrec) :: pos(:)
00041     LOGICAL :: lform
00042 !    RETURN
00043        SELECT CASE(lform)
00044        CASE(PRIMITIVE)
00045           CALL PrimCyl(q,dqdt,pos)
00046        CASE(CONSERVATIVE)
00047           CALL ConsCyl(q,dqdt,pos)
00048        END SELECT
00049 
00050   END SUBROUTINE Cylindrical
00051 
00053   SUBROUTINE PrimCyl(q,dqdt,pos)
00054     ! Interface declarations
00055     REAL(KIND=qPrec) :: q(:)
00056     REAL(KIND=qPrec),INTENT(INOUT) :: dqdt(:)
00057     REAL(KIND=xPrec) :: pos(:)
00058     ! Local declarations
00059     REAL(KIND=xPrec) :: r
00060     REAL(KIND=qPrec) :: P, vr, vz, vphi, Br, Bz, Bphi, uB
00061     REAL(KIND=qPrec),DIMENSION(NrVars) :: dqlocal
00062 
00063     ! local vars for readability
00064 
00065     r=pos(irDir)
00066     P=PrimPress(q)
00067     vr=q(imom(irdir))
00068 
00069     !--- Hydro contributions ---!
00070          dqlocal=0d0
00071     dqlocal(1) = q(1)*vr
00072     IF(iE .NE. 0) dqlocal(iE) = vr*(q(iE)+P)
00073     IF(NrTracerVars>0) dqlocal(nTracerLO:nTracerHI) = vr*q(nTracerLO:nTracerHI)
00074     IF (iCylindrical==WithAngMom) THEN
00075        dqlocal(imom(irDir))=-q(m_high)**2
00076        dqlocal(m_high) = q(imom(irdir))*q(m_high)
00077     END IF
00078 
00079     !--- MHD contributions ---!
00080     IF(lMHD) THEN
00081        vz=q(imom(izdir))
00082        Br=q(iB(irdir))
00083        Bz=q(iB(izdir))
00084        Bphi=q(iBz)
00085        vphi=0d0
00086        IF(iCylindrical==WithAngMom) vphi=q(m_high)
00087        uB = vr*Br + vz*Bz + vphi*Bphi
00088 
00089        dqlocal(imom(izDir)) = -Br*Bz/q(1)
00090        IF(iE .NE. 0) dqlocal(iE) = dqlocal(iE) + Br*uB
00091        dqlocal(iBy) = -Br*vz + Bz*vr
00092        IF(iCylindrical==WithAngMom) THEN
00093           dqlocal(imom(irDir)) = dqlocal(imom(irDir)) - (Br**2-Bphi**2)/q(1)
00094           dqlocal(m_high) = dqlocal(m_high) - 2d0*Br*Bphi/q(1)
00095        END IF       
00096     END IF
00097 
00098     dqdt = dqdt + (-dqlocal/r)
00099   END SUBROUTINE PrimCyl
00100 
00101 
00103   SUBROUTINE ConsCyl(q,dqdt,pos)!,cylobj)
00104     ! Interface declarations
00105     REAL(KIND=qPrec) :: q(:)
00106     REAL(KIND=qPrec),INTENT(INOUT) :: dqdt(:)
00107     REAL(KIND=xPrec) :: pos(:)
00108     ! Local declarations
00109     REAL(KIND=xPrec) :: r
00110     REAL(KIND=qPrec) :: P, vr, vz, vphi, Br, Bz, Bphi, Bsq, uB
00111     REAL(KIND=qPrec),DIMENSION(NrVars) :: dqlocal
00112 
00113     ! local vars for readability
00114     r=pos(irDir)
00115 
00116     P=Press(q)
00117     vr = q(imom(irdir))/q(1)
00118 
00119     dqlocal=0d0
00120     !--- Hydro contributions ---!
00121     dqlocal(1)     = q(imom(irdir))
00122     dqlocal(imom(irDir)) = vr*q(imom(irDir))
00123     dqlocal(imom(izDir)) = vr*q(imom(izdir))
00124     IF(iE .NE. 0) dqlocal(iE) = vr*(q(iE)+P)
00125     IF(NrTracerVars>0) dqlocal(nTracerLO:nTracerHI) = vr*q(nTracerLO:nTracerHI)
00126     IF(iCylindrical==WithAngMom) THEN
00127        dqlocal(m_high)  = 2.d0*vr*q(m_high)
00128        dqlocal(imom(irDir))    = dqlocal(imom(irDir)) - q(m_high)**2/q(1)
00129     END IF
00130 
00131     !--- MHD  contributions ---!
00132     IF(lMHD) THEN
00133        vz=q(imom(izdir))/q(1)
00134        vphi=0d0
00135        IF(iCylindrical==WithAngMom) vphi=q(m_high)/q(1)
00136        Br=q(iB(irdir))
00137        Bz=q(iB(izdir))
00138        Bphi=q(iBz)
00139        Bsq = Br**2 + Bz**2 + Bphi**2
00140        uB = vr*Br + vz*Bz + vphi*Bphi
00141 
00142        dqlocal(imom(irDir)) = dqlocal(imom(irDir)) - Br**2 + Bphi**2
00143        dqlocal(imom(izDir)) = dqlocal(imom(izDir)) - Br*Bz
00144        dqlocal(iBy) = ( vr*Bz - vz*Br )
00145        IF(iE .NE. 0) dqlocal(iE) = dqlocal(iE) + vr*half*Bsq - Br*uB
00146         IF(iCylindrical==WithAngMom) THEN
00147            dqlocal(m_high) = dqlocal(m_high) - 2d0*Bphi*Br
00148         END IF
00149     END IF
00150 
00151     dqdt = dqdt + (-dqlocal/r)
00152   END SUBROUTINE ConsCyl
00153 END MODULE CylindricalSrc
 All Classes Files Functions Variables