234 | | === Additional Physics === |
235 | | |
236 | | 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. |
237 | | |
238 | | ==== MHD ==== |
239 | | |
240 | | Enabling MHD requires two changes to the data files: |
241 | | * In {{{global.data}}}, set the {{{MaintainAuxArrays}}} flag to {{{T}}}. |
242 | | * In {{{physics.data}}}, set {{{lMHD}}} to {{{T}}}. |
243 | | |
244 | | 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: |
245 | | |
246 | | {{{ |
247 | | Info%q(i,j,k,iBx) = half * (Info%aux(i,j,k,1) + Info%aux(i+1,j,k,1)) |
248 | | Info%q(i,j,k,iBy) = half * (Info%aux(i,j,k,1) + Info%aux(i,j+1,k,2)) |
249 | | Info%q(i,j,k,iBz) = half * (Info%aux(i,j,k,1) + Info%aux(i,j,k+1,3)) |
250 | | }}} |
251 | | |
252 | | ==== Cooling ==== |
253 | | |
254 | | 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: |
255 | | |
256 | | {{{ |
257 | | IF(iCooling>0) THEN |
258 | | IF (.NOT. lRestart) THEN |
259 | | ! see sources/cooling.f90::CreateCoolingObject for |
260 | | ! default values of a cooling source term |
261 | | CALL CreateCoolingObject(coolingobj) |
262 | | ELSE |
263 | | coolingobj => firstcoolingobj |
264 | | END IF |
265 | | END IF |
266 | | |
267 | | coolingobj%iCooling=iCooling |
268 | | SELECT CASE(iCooling) ! cases defined in sources/cooling.f90 |
269 | | CASE(NoCool) |
270 | | CASE(AnalyticCool) |
271 | | coolingobj%alpha=alpha |
272 | | coolingobj%beta=beta |
273 | | CASE(DMCool) |
274 | | CASE(IICool) |
275 | | CASE DEFAULT |
276 | | END SELECT |
277 | | |
278 | | coolingobj%floortemp=1d0 |
279 | | coolingobj%mintemp=0.001 |
280 | | }}} |
281 | | |
282 | | 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. |
283 | | |
284 | | ==== Self-Gravity ==== |
285 | | |
286 | | AstroBEAR uses the [https://computation.llnl.gov/casc/hypre/software.html hypre] library to solve the self-gravity equations. To use self-gravity: |
287 | | |
288 | | 1. Look for the {{{HYPREFLAG}}} variable in {{{Makefile.inc}}} and make sure that it is set to {{{1}}}. |
289 | | 2. Set the {{{lSelfGravity}}} flag in your {{{physics.data}}} file and set it to {{{T}}}. |
290 | | |
291 | | 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 [http://mathworld.wolfram.com/SingularMatrix.html 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. |
292 | | |
293 | | ==== Sink Particles ==== |
294 | | |
295 | | The ability to form [SinkParticles sink particles] in AstroBEAR is tied to self-gravity. To simply enable sink particles: |
296 | | |
297 | | 1. Look for the {{{HYPREFLAG}}} variable in {{{Makefile.inc}}} and make sure that it is set to {{{1}}}. |
298 | | 2. Set the {{{lSelfGravity}}} flag in your {{{physics.data}}} file and set it to {{{T}}}. |
299 | | |
300 | | 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()}}}: |
301 | | |
302 | | {{{ |
303 | | NAMELIST /ProblemData/ nParticles |
304 | | NAMELIST /ParticleData/ mass,xloc,vel |
305 | | OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='problem.data', STATUS="OLD") |
306 | | READ(PROBLEM_DATA_HANDLE,NML=ProblemData) |
307 | | |
308 | | IF (.NOT. lRestart) THEN |
309 | | |
310 | | DO i=1,nParticles |
311 | | |
312 | | READ(PROBLEM_DATA_HANDLE,NML=ParticleData) |
313 | | NULLIFY(Particle) |
314 | | CALL CreateParticle(Particle) |
315 | | Particle%mass=mass |
316 | | Particle%xloc=xloc |
317 | | Particle%vel=vel |
318 | | CALL AddSinkParticle(Particle) |
319 | | |
320 | | END DO |
321 | | |
322 | | CLOSE(PROBLEM_DATA_HANDLE) |
323 | | OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='restart.data', STATUS="UNKNOWN") |
324 | | WRITE(PROBLEM_DATA_HANDLE,NML=RestartData) |
325 | | CLOSE(PROBLEM_DATA_HANDLE) |
326 | | |
327 | | END IF |
328 | | }}} |
329 | | |
330 | | Depending on the features of your simulation, more [AstroBearObjects 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. |