wiki:MultiPhysics

Version 1 (modified by Jonathan, 12 years ago) ( diff )

Additional Physics

AstroBEAR supports hydrodynamics and AMR by default. Other physical processes such as magnetic fields and source terms require extra overhead, so they must be enabled by the user.

MHD

Enabling MHD requires two changes to the data files:

  • In global.data, set the MaintainAuxArrays flag to T.
  • In physics.data, set lMHD to T.

You will also need to initialize the aux arrays in your module file. In fact, magnetic fields are often initialized by setting the aux values first, and then calculating the cell-centered magnetic fields in q by averaging the aux values on either side of a cell:

Info%q(i,j,k,iBx) = half * (Info%aux(i,j,k,1) + Info%aux(i+1,j,k,1))
Info%q(i,j,k,iBy) = half * (Info%aux(i,j,k,1) + Info%aux(i,j+1,k,2))
Info%q(i,j,k,iBz) = half * (Info%aux(i,j,k,1) + Info%aux(i,j,k+1,3))

Cooling

Two things are required to turn on cooling: the lCooling flag to indicate that cooling is active in this simulation, and iCooling to specify the type of cooling to use. These values are usually included in the problem.data file. The user must also create a cooling object in ProblemModuleInit() to manage the cooling settings. An example of cooling object creation can be seen below:

    IF(iCooling>0) THEN
       IF (.NOT. lRestart) THEN
           ! see sources/cooling.f90::CreateCoolingObject for
           ! default values of a cooling source term
           CALL CreateCoolingObject(coolingobj)
       ELSE
           coolingobj => firstcoolingobj
       END IF
    END IF

    coolingobj%iCooling=iCooling
    SELECT CASE(iCooling) ! cases defined in sources/cooling.f90
    CASE(NoCool)
    CASE(AnalyticCool)
       coolingobj%alpha=alpha
       coolingobj%beta=beta
    CASE(DMCool)
    CASE(IICool)
    CASE DEFAULT
    END SELECT

    coolingobj%floortemp=1d0
    coolingobj%mintemp=0.001

The .NOT. lRestart conditional prevents AstroBEAR from creating a new cooling object on restarts; this is because the cooling objects will be read in from the restart files.

Self-Gravity

AstroBEAR uses the hypre library to solve the self-gravity equations. To use self-gravity:

  1. Look for the HYPREFLAG variable in Makefile.inc and make sure that it is set to 1.
  2. Set the lSelfGravity flag in your physics.data file and set it to T.

Hypre will automatically initialize the potential field using the density. The only caveat is that the initial density cannot be uniform. When the density is uniform, hypre produces a singular matrix that it can't solve. Fortunately, a small density perturbation takes care of this problem without substantially affecting the dynamics of the domain. AstroBEAR comes with a Perturbation object type that can be used for this.

Sink Particles

The ability to form sink particles in AstroBEAR is tied to self-gravity. To simply enable sink particles:

  1. Look for the HYPREFLAG variable in Makefile.inc and make sure that it is set to 1.
  2. Set the lSelfGravity flag in your physics.data file and set it to T.

If you just want your simulation to have the option of forming sink particles, no further action is required. If you want to start your simulation off with sink particles, then you will have to create one in problem.f90::ProblemModuleInit():

      NAMELIST /ProblemData/ nParticles
      NAMELIST /ParticleData/ mass,xloc,vel
      OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='problem.data', STATUS="OLD")
      READ(PROBLEM_DATA_HANDLE,NML=ProblemData)

      IF (.NOT. lRestart) THEN

         DO i=1,nParticles

            READ(PROBLEM_DATA_HANDLE,NML=ParticleData)
            NULLIFY(Particle)
            CALL CreateParticle(Particle)
            Particle%mass=mass
            Particle%xloc=xloc
            Particle%vel=vel         
            CALL AddSinkParticle(Particle)
 
         END DO

         CLOSE(PROBLEM_DATA_HANDLE)      
         OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='restart.data', STATUS="UNKNOWN")
         WRITE(PROBLEM_DATA_HANDLE,NML=RestartData)
         CLOSE(PROBLEM_DATA_HANDLE)

      END IF

Depending on the features of your simulation, more objects might have to be declared in conjunction with the sink particle. The .NOT. lRestart conditional is important, as it prevents AstroBEAR from adding the same particle again on a restart.

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.