253 | | AstroBEAR uses the [https://computation.llnl.gov/casc/hypre/software.html hypre] library to solve the self-gravity equations. To use hypre, you must first make sure that you link to the hypre library when compiling AstroBEAR. Look for the {{{HYPREFLAG}}} variable in {{{Makefile.inc}}} and make sure that it is set to {{{1}}}. |
254 | | |
255 | | 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. |
| 253 | AstroBEAR uses the [https://computation.llnl.gov/casc/hypre/software.html hypre] library to solve the self-gravity equations. To use self-gravity: |
| 254 | |
| 255 | 1. Look for the {{{HYPREFLAG}}} variable in {{{Makefile.inc}}} and make sure that it is set to {{{1}}}. |
| 256 | 2. Set the {{{lSelfGravity}}} flag in your {{{physics.data}}} file and set it to {{{T}}}. |
| 257 | |
| 258 | 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. |
| 259 | |
| 260 | ==== Sink Particles ==== |
| 261 | |
| 262 | The ability to form [SinkParticles sink particles] in AstroBEAR is tied to self-gravity. To simply enable sink particles: |
| 263 | |
| 264 | 1. Look for the {{{HYPREFLAG}}} variable in {{{Makefile.inc}}} and make sure that it is set to {{{1}}}. |
| 265 | 2. Set the {{{lSelfGravity}}} flag in your {{{physics.data}}} file and set it to {{{T}}}. |
| 266 | |
| 267 | 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()}}}: |
| 268 | |
| 269 | {{{ |
| 270 | NAMELIST /ProblemData/ nParticles |
| 271 | NAMELIST /ParticleData/ mass,xloc,vel |
| 272 | OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='problem.data', STATUS="OLD") |
| 273 | READ(PROBLEM_DATA_HANDLE,NML=ProblemData) |
| 274 | |
| 275 | IF (.NOT. lRestart) THEN |
| 276 | |
| 277 | DO i=1,nParticles |
| 278 | |
| 279 | READ(PROBLEM_DATA_HANDLE,NML=ParticleData) |
| 280 | NULLIFY(Particle) |
| 281 | CALL CreateParticle(Particle) |
| 282 | Particle%mass=mass |
| 283 | Particle%xloc=xloc |
| 284 | Particle%vel=vel |
| 285 | CALL AddSinkParticle(Particle) |
| 286 | |
| 287 | END DO |
| 288 | |
| 289 | CLOSE(PROBLEM_DATA_HANDLE) |
| 290 | OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='restart.data', STATUS="UNKNOWN") |
| 291 | WRITE(PROBLEM_DATA_HANDLE,NML=RestartData) |
| 292 | CLOSE(PROBLEM_DATA_HANDLE) |
| 293 | |
| 294 | END IF |
| 295 | }}} |
| 296 | |
| 297 | 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. |