Scrambler  1
MultiJets/problem.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 !    problem.f90 of module MultiJets 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 
00028 
00032 
00035 MODULE Problem
00036   USE DataDeclarations
00037   USE Ambients
00038   USE Fields
00039   USE Refinements
00040   USE Clumps
00041   USE ProcessingDeclarations
00042   IMPLICIT NONE
00043   SAVE
00044 
00045   PUBLIC ProblemModuleInit, ProblemGridInit, &
00046        ProblemBeforeStep, ProblemAfterStep, ProblemSetErrFlag, ProblemBeforeGlobalStep
00047 CONTAINS
00048 
00050    SUBROUTINE ProblemModuleInit()
00051      TYPE(AmbientDef), POINTER :: Ambient
00052      REAL(KIND=qPREC) :: density !Background density
00053      REAL(KIND=qPREC) :: Mach !mach number of induced turbulence
00054      REAL(KIND=qPREC) :: length !length scale of injection
00055      REAL(KIND=qPREC) :: eta !percent in mass increase per turbulence time scale
00056      REAL(KIND=qPREC) :: Temp !temperature of background 
00057      REAL(KIND=qPREC) :: decay_frac !Fraction of duration to use for decay
00058      REAL(KIND=qPREC) :: nOverlap !number of active overlapping outflows per interaction scale (sets duration)
00059      REAL(KIND=qPREC) :: numcellsinradius !sets size of outflow sphere
00060      REAL(KIND=qPREC) :: numcellsinshell !sets thickness of accelerating region  
00061      TYPE(OutflowDef), POINTER :: Outflow
00062      REAL(KIND=qPREC) :: outflow_density, outflow_temp, outflow_duration, outflow_radius, outflow_decay, outflow_velocity
00063      REAL(KIND=qPREC) :: velocity, momentum, volrate, time, LaunchPeriod, massloss, rand
00064      INTEGER :: i,j,nOutflows
00065      NAMELIST /ProblemData/ density, Mach, length, eta, Temp, numcellsinradius, numcellsinshell, nOverlap, decay_frac
00066      NAMELIST /OutflowData/ velocity, momentum, volrate, nOutflows, time, LaunchPeriod, massloss, outflow_temp, outflow_velocity, outflow_density, outflow_radius, outflow_duration, outflow_decay
00067 
00068      OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='problem.data', STATUS="OLD")
00069      READ(PROBLEM_DATA_HANDLE,NML=ProblemData)
00070      CALL CreateAmbient(Ambient)
00071      Temp=Temp/TempScale
00072      Ambient%density=density    
00073      IF (iE == EOS_ISOTHERMAL) Temp=Iso_Speed2
00074      Ambient%pressure=density*Temp
00075      
00076      ! Use density, mach, length
00077      ! to get P, S, and V (from eta)
00078 
00079 
00080      IF (.NOT. lRestart) THEN
00081         velocity=sqrt(gamma*Ambient%pressure/Ambient%density)*Mach
00082         
00083         momentum = density*length**(nDim)*velocity
00084         volrate = length**(-nDim-1)*velocity
00085         nOutflows=volrate*product(GxBounds(1:nDim,2)-GxBounds(1:nDim,1))*(final_time-start_time)
00086         time=length*velocity
00087         LaunchPeriod=1d0/(product(GxBounds(1:nDim,2)-GxBounds(1:nDim,1))*volrate)
00088         massloss=eta*Ambient%density/(volrate*time)
00089         outflow_temp=Temp
00090         outflow_velocity=momentum/massloss
00091         outflow_radius=levels(MaxLevel)%dx*(numcellsinradius)
00092 
00093         outflow_duration=nOverlap*time
00094         outflow_decay=outflow_duration*decay_frac
00095         IF (nDim == 2) THEN
00096            outflow_density=massloss/(outflow_duration*2d0*Pi*outflow_radius*outflow_velocity)
00097         ELSEIF (nDim == 3) THEN
00098            outflow_density=massloss/(outflow_duration*4d0*Pi*outflow_radius**2*outflow_velocity)
00099         END IF
00100 
00101         IF (MPI_ID == 0) THEN
00102            write(*,NML=ProblemData)
00103            write(*,NML=OutflowData)
00104         END IF
00105         DO i=1,nOutflows
00106            NULLIFY(Outflow)
00107            CALL CreateOutflowObject(Outflow)
00108            DO j=1,nDim
00109               CALL random_number(rand)
00110               Outflow%position(j)=GxBounds(j,1)+rand*(GxBounds(j,2)-GxBounds(j,1))
00111            END DO
00112            write(*,*) 'outflow%position=', outflow%position
00113            Outflow%open_angle=half*Pi
00114            Outflow%radius=levels(MaxLevel)%dx*(numcellsinradius-numcellsinshell)
00115            Outflow%thickness=levels(MaxLevel)%dx*numcellsinshell
00116            Outflow%begin=LaunchPeriod*(1d0*i-1d0)
00117            Outflow%velocity=outflow_velocity
00118            Outflow%duration=outflow_duration
00119            Outflow%decay=outflow_decay
00120            Outflow%density=outflow_density
00121            Outflow%temperature=outflow_temp
00122            CALL UpdateOutflow(Outflow)
00123         END DO
00124 
00125      ELSE
00126         ! Need to write IO routines for restarts...
00127 
00128      END IF
00129    END SUBROUTINE ProblemModuleInit
00130 
00133   SUBROUTINE ProblemGridInit(Info)
00134     TYPE(InfoDef) :: Info
00135     INTEGER :: j
00136   END SUBROUTINE ProblemGridInit
00137 
00140   SUBROUTINE ProblemBeforeStep(Info)
00141     TYPE(InfoDef) :: Info
00142     INTEGER :: i
00143 !    Info%q(1,1,1,iE)=0
00144   END SUBROUTINE ProblemBeforeStep
00145 
00148   SUBROUTINE ProblemAfterStep(Info)
00149     TYPE(InfoDef) :: Info
00150   END SUBROUTINE ProblemAfterStep
00151 
00154   SUBROUTINE ProblemSetErrFlag(Info)
00155     TYPE(InfoDef) :: Info
00156     INTEGER, DIMENSION(3,2) :: mO
00157 !    mO(:,1)=max(1, RefineBox(:,1)-Info%mGlobal(:,1)+1)
00158 !    mO(:,2)=min(Info%mX, RefineBox(:,2)-Info%mGlobal(:,1)+1)
00159 !    Info%ErrFlag(mO(1,1):mO(1,2), mO(2,1):mO(2,2), mO(3,1):mO(3,2))=1
00160   END SUBROUTINE ProblemSetErrFlag
00161 
00162   SUBROUTINE ProblemBeforeGlobalStep(n)
00163      INTEGER :: n
00164   END SUBROUTINE ProblemBeforeGlobalStep
00165 
00166 END MODULE Problem
00167 
 All Classes Files Functions Variables