Scrambler
1
|
00001 !######################################################################### 00002 ! 00003 ! Copyright (C) 2003-2012 Department of Physics and Astronomy, 00004 ! University of Rochester, 00005 ! Rochester, NY 00006 ! 00007 ! physics_declarations.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 !######################################################################### 00025 00029 00032 MODULE PhysicsDeclarations 00033 00034 USE GlobalDeclarations 00035 00036 IMPLICIT NONE 00037 PUBLIC 00038 SAVE 00039 ! Variables used by user modules and advance modules 00040 INTEGER, PARAMETER :: MaxVars=20 ! 00041 INTEGER, PARAMETER :: LOGSCALE=0, LINEARSCALE=1 00042 00043 ! Universal constants in CGS units 00044 REAL (KIND=qPrec), PARAMETER :: Boltzmann = 1.3806503d-16, 00045 mSolar = 1.99d33, 00046 G = 6.6731d-8, 00047 hMass = 1.67262158d-24, 00048 au = 1.496d13, 00049 Pi = 3.1415926535897932384626433832795d0, 00050 yr = 31556926 , 00051 pc = 3.08568025e18 00052 00053 00054 ! Cool module related global parameters. 00055 REAL(KIND=qprec), PUBLIC, PARAMETER :: ev=1.60217646263d-12, ! ergs/eV 00056 IonH = 13.5984 * ev, 00057 IonHe = 24.5874 * ev, 00058 BindH2 = 4.476 * ev, ! molecular binding energy 00059 AMU = 1.66044d-24, ! g/AMU 00060 planck = 6.62606876d-27, 00061 emass = 9.10938188d-28 00062 00063 ! molecular weight mumbo jumbo, amu's 00064 REAL(KIND=qprec), PUBLIC, PARAMETER :: mue = 5.48612529209125d-04 , 00065 muH = 1.00794d0, 00066 muHII = half*muH, 00067 muH2 = 2.d0*muH, 00068 muHe = 4.002602d0, 00069 gammaH = 5.d0/3.d0, 00070 gammaH2 = 7.d0/5.d0 00071 00072 00073 ! Variables specified by user at runtime 00074 00075 LOGICAL :: lMHD=.false. 00076 LOGICAL :: lCheckDivergence=.false. 00077 LOGICAL :: lCanAddTracers=.false. 00078 LOGICAL :: lGravityPeriodic=.false. 00079 00080 ! Protection related parameters and variables 00081 INTEGER, PARAMETER :: MIN_TEMP=0, MIN_NEARBY_PRESS=1, AVG_NEARBY_PRESS=2, MIN_NEARBY_TEMP=3, AVG_NEARBY_TEMP=4 00082 INTEGER, PARAMETER :: MIN_DENSITY=0, MIN_NEARBY_DENSITY=1, AVG_NEARBY_DENSITY=2 00083 INTEGER, PARAMETER :: CONSERVE_MOMENTUM=0, CLEAR_MOMENTUM=1, AVG_NEARBY_VEL=2 00084 LOGICAL :: lRestartOnPressureProtections = .false. 00085 LOGICAL :: lRestartOnDensityProtections = .false. 00086 LOGICAL :: lRestartonHypreMaxIters = .true. 00087 INTEGER :: iDensityProtect = AVG_NEARBY_DENSITY 00088 INTEGER :: iMomentumProtect = AVG_NEARBY_VEL 00089 INTEGER :: iPressureProtect = AVG_NEARBY_TEMP 00090 REAL(KIND=qPrec) :: MinTemp=1d-10, MinDensity=1d-10 00091 REAL (KIND=qPrec) :: SrcPrecision = 1d-3 !Source precision 00092 00093 REAL (KIND=qPrec) :: Xmu=1d0 ! mean molecular weight per particle 00094 REAL (KIND=qPrec) :: rScale=0d0, nScale=0d0, TempScale=0d0, pScale=0d0, lScale=0d0, VelScale, TimeScale, BScale, mScale, ScaleGrav!, ScaleCool, !Scales 00095 00096 REAL(KIND=qPREC) :: mean_density=0d0 00097 00098 INTEGER, PARAMETER :: MAXFIELDLENGTH = 20 00099 INTEGER, PARAMETER :: MAXFIELDVARS=40 00100 CHARACTER(LEN = MAXFIELDLENGTH), DIMENSION(0:MAXFIELDVARS) :: FieldNames 00101 ! Indices for mapping quantities to position in q array 00102 00103 INTEGER :: irho = 0, iE = 0,ivx = 0, ivy = 0, ivz = 0, iBx = 0, iBy = 0, iBz = 0, iPhiDot, iPhiGas, iEntropy, iAngMom,imom(3),ivOld(3),irhoOld, iB(3) 00104 INTEGER :: nTracerLO,nTracerHI ! Passive tracer indices 00105 INTEGER :: NrHydroVars=0 00106 INTEGER :: NrTracerVars=0 00107 INTEGER :: NrOutputVars=0 00108 INTEGER :: NrPhysicalVars=0 00109 INTEGER :: NrBackupVars=0 00110 00111 INTEGER, DIMENSION(8) :: var_index 00112 00113 REAL(KIND=qPREC) :: R2DEff 00114 LOGICAL :: lSelfGravity=.false., lSinkParticles=.false., lSourceTerms=.true., luniformgravity=.false. 00115 REAL(KIND=qpREC) :: UniformGravity=0d0 00116 REAL(KIND=qPREC) :: OmegaRot=0d0 00117 REAL(KIND=qPREC) :: CellsPerJeansLength=4d0 00118 00119 LOGICAL :: lResistive = .false. 00120 INTEGER :: ResType 00121 REAL(KIND=qPREC) :: resistivity 00122 00123 LOGICAL :: lConductive = .false. 00124 INTEGER :: ConType 00125 REAL(kIND=qPREC) :: conductivity 00126 LOGICAL :: lThermalFluxLimiter 00127 LOGICAL :: lIsoDiff 00128 00129 LOGICAL :: lViscous = .false. 00130 INTEGER :: VisType 00131 REAL(KIND=qPREC) :: bviscosity 00132 00133 INTEGER :: iCylindrical! , iCooling , iSymAxis ! Source switches 00134 INTEGER,PARAMETER :: NoCyl=0, NoAngMom=1, WithAngMom=2 00135 INTEGER, PARAMETER:: irdir=1,izdir=2 !Cylindrical directions 00136 00137 INTEGER :: myDim !physical dimension (=3 for Cylindrical systems) 00138 INTEGER :: GravityDim !physical dimension for Point Gravity Objects 00139 00140 ! Other physical variables used globally 00141 REAL(KIND=qPrec) :: Iso_Speed2, Iso_Speed 00142 00143 ! Various gamma-related constants for the exact Riemann solver 00144 REAL (KIND=qPrec) :: gamma=5d0/3d0, gamma1,gamma2,gamma3,gamma4,gamma5,gamma6, 00145 gamma7,gamma8,gamma9,gamma10,gamma11,gamma12,gamma13,gamma14, gamma15 00146 00147 00148 INTEGER, PARAMETER :: EOS_IDEAL_GAS = 0 00149 INTEGER, PARAMETER :: EOS_VANDERWAALS = 3 00150 INTEGER, PARAMETER :: EOS_ISOTHERMAL = 4 00151 INTEGER :: iEOS=EOS_IDEAL_GAS ! Index for the desired equation of state. 00152 INTEGER, DIMENSION(maxVars) :: InterpOpts=0 00153 REAL(KIND=qPREC), DIMENSION(maxVars) :: refineVariableFactor=1d0 00154 00155 ! General declarations 00156 ! File unit numbers 00157 INTEGER, PARAMETER :: OK=0 00158 00159 NAMELIST /PhysicsData/ gamma,Xmu,MinTemp,MinDensity,nScale,rScale,TempScale,lSelfGravity, iCylindrical, & 00160 pScale,lScale,iEOS, NrTracerVars, lCheckDivergence, InterpOpts, lMHD, refineVariableFactor, UniformGravity, & 00161 lResistive, ResType, resistivity, & 00162 lConductive, ConType, conductivity, lThermalFluxLimiter, lIsoDiff, & 00163 lViscous, VisType, bviscosity, & 00164 lRestartOnDensityProtections, lRestartOnPressureProtections, lRestartOnHypreMaxIters, iPressureProtect, iDensityProtect, iMomentumProtect, SrcPrecision, OmegaRot 00165 00166 NAMELIST /ScalesData/ TimeScale,lScale,mScale,rScale,VelScale,pScale,nScale,BScale,TempScale,ScaleGrav 00167 00168 00169 !Stuff needed by sweep method should be declared and initialized within sweep module 00170 INTEGER :: iEx,iEy, iEz, NrCons, m_low, m_high, NrFieldVars, NrWaves 00171 00172 00173 00174 00175 INTEGER, PARAMETER :: MAXTRACERLENGTH = 20 00176 INTEGER, PARAMETER :: MAXTRACERVARS=40 00177 00178 CHARACTER(LEN = MAXTRACERLENGTH), DIMENSION(0:MAXTRACERVARS) :: TracerNames 00179 00180 00181 INTEGER, ALLOCATABLE, DIMENSION(:) :: oneDx_i 00182 INTEGER, ALLOCATABLE, DIMENSION(:) :: oneDy_i 00183 INTEGER, ALLOCATABLE, DIMENSION(:) :: oneDz_i 00184 INTEGER, ALLOCATABLE, DIMENSION(:) :: wDx_i 00185 INTEGER, ALLOCATABLE, DIMENSION(:) :: wDy_i 00186 INTEGER, ALLOCATABLE, DIMENSION(:) :: wDz_i 00187 INTEGER, ALLOCATABLE, DIMENSION(:) :: fDx_i 00188 INTEGER, ALLOCATABLE, DIMENSION(:) :: fDy_i 00189 INTEGER, ALLOCATABLE, DIMENSION(:) :: fDz_i 00190 00191 00192 CONTAINS 00193 00197 SUBROUTINE AddTracer(i, str) 00198 INTEGER :: i 00199 CHARACTER(LEN=*), OPTIONAL :: str 00200 IF (lCanAddTracers) THEN 00201 i=GetNextTracerIndex() 00202 NrTracerVars=NrTracerVars+1 00203 IF (NrTracerVars <= MaxTracerVars) THEN 00204 IF (Present(str)) THEN 00205 TracerNames(NrTracerVars)=str(1:min(len(str), len(TracerNames(NrTracerVars)))) 00206 ELSE 00207 write(TracerNames(NrTracervars), '(A6I3.3)') 'Tracer', NrTracerVars 00208 END IF 00209 ELSE 00210 IF (MPI_ID == 0) THEN 00211 PRINT*, 'Warning: Unable to store name of tracer variable without increasing MaxTracers in processing_declarations.f90' 00212 END IF 00213 END IF 00214 ELSE 00215 IF (MPI_ID == 0) THEN 00216 PRINT*, 'Warning: Tracers should be added during problem module init or in source init' 00217 END IF 00218 i=0 00219 END IF 00220 END SUBROUTINE AddTracer 00221 00222 FUNCTION GetNextTracerIndex() 00223 INTEGER :: GetNextTracerIndex 00224 GetNextTracerIndex = nTracerLo+NrTracerVars 00225 END FUNCTION GetNextTracerIndex 00226 00229 FUNCTION TracerName(i) 00230 INTEGER :: i 00231 CHARACTER(LEN=MAXTRACERLENGTH) :: TracerName 00232 00233 IF (i <= MaxTracerVars) THEN 00234 TracerName=TracerNames(i) 00235 ELSE 00236 write(TracerName, '(A10I3.3)') 'Tracer', NrTracerVars 00237 END IF 00238 00239 END FUNCTION TracerName 00240 00241 00245 SUBROUTINE AddFieldVar(i, str) 00246 INTEGER :: i 00247 CHARACTER(LEN=*), OPTIONAL :: str 00248 i=1+NrFieldVars 00249 NrFieldVars=NrFieldVars+1 00250 IF (NrFieldVars <= MaxFieldVars) THEN 00251 IF (Present(str)) THEN 00252 FieldNames(NrFieldVars)=str(1:min(len(str), len(FieldNames(NrFieldVars)))) 00253 ELSE 00254 write(FieldNames(NrFieldvars), '(A10I3.3)') 'Field', NrFieldVars 00255 END IF 00256 ELSE 00257 IF (MPI_ID == 0) THEN 00258 PRINT*, 'Warning: Unable to store name of diagnostic variable without increasing MaxFieldVars in processing_declarations.f90' 00259 END IF 00260 END IF 00261 END SUBROUTINE AddFieldVar 00262 00265 FUNCTION FieldName(i) 00266 INTEGER :: i 00267 CHARACTER(LEN=MAXFIELDLENGTH) :: FieldName 00268 00269 IF (i <= MaxFieldVars) THEN 00270 FieldName=FieldNames(i) 00271 ELSE 00272 write(FieldName, '(A10I3.3)') 'Field', NrFieldVars 00273 END IF 00274 00275 END FUNCTION FieldName 00276 00277 00278 END MODULE PhysicsDeclarations