You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/wiki/Initial-Conditions.md
+266-2Lines changed: 266 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -290,8 +290,272 @@ See also
290
290
[[ Add Problem-specific Grid Fields and Particle Attributes | Adding-New-Simulations#v-add-problem-specific-grid-fields-and-particle-attributes ]] for adding user-defined particle attributes.
291
291
292
292
GAMER has a built-in routine for constructing a particle initial condition in equilibrium
293
-
(e.g., Plummer, NFW, tabular). Please refer to the test problem `Hydro/ParticleEquilibriumIC`
294
-
for its usage.
293
+
(e.g., Plummer, NFW, tabular). Here are the steps to use it:
294
+
295
+
1. Step 1: Include the header in the test problem source code file:
296
+
297
+
```C++
298
+
#include"Par_EquilibriumIC.h"
299
+
```
300
+
301
+
2. Step 2: Declare a constructor object of class `Par_EquilibriumIC` inside `Par_Init_ByFunction()`:
302
+
303
+
```C++
304
+
Par_EquilibriumIC( const char* Cloud_Type );
305
+
```
306
+
307
+
- Parameters
308
+
309
+
- `Cloud_Type` : `char*`
310
+
311
+
Type of this particle cloud.
312
+
Supported types include "Table", "Plummer", "NFW", "Burkert", "Jaffe", "Hernquist", and "Einasto".
313
+
314
+
- Example Usage
315
+
316
+
`Par_EquilibriumIC Cloud_Constructor( "Plummer" );` creates a cloud of the Plummer model.
317
+
318
+
3. Step 3: Set the parameters for the constructor object by calling the following functions:
319
+
320
+
a. Set the parameters related to the construction of the particle cloud
321
+
322
+
```C++
323
+
setParticleParameters( const long ParNum, const double MaxR, const int NBin, const int RSeed )
324
+
```
325
+
326
+
- Parameters
327
+
328
+
- `ParNum` : `long`
329
+
330
+
Number of particles of the particle cloud.
331
+
332
+
- `MaxR` : `double`
333
+
334
+
Maximum radius for the scattered particles in this cloud.
335
+
336
+
- `NBin` : `int`
337
+
338
+
Number of bins of radial profiles inside the `MaxR`.
339
+
340
+
- `RSeed` : `int`
341
+
342
+
Random seed for setting the particle position and velocity.
343
+
344
+
- Notes
345
+
346
+
- These parameters are mandatory in all cases.
347
+
348
+
- Example Usage
349
+
350
+
`Cloud_Constructor.setParticleParameters( 1000000, 10.0, 1024, 123 );` sets the number of particles as `1000000`, the maximum radius as `10.0` (in code units), the number of bins as `1024`, and the random seed as `123`.
- The scale density and scale radius are general but may have different names in different models. Please check the definition in `AnalyticalDensProf_*` in `src/Particle/Par_EquilibriumIC.cpp` for details.
391
+
392
+
- Required only for `Cloud_Type != "Table"`; useless for `Cloud_Type == "Table"`.
393
+
394
+
- Example Usage:
395
+
396
+
`Cloud_Constructor.setModelParameters( 1.0, 0.1 );` sets the scale density as `1.0` and scale radius as `0.1` in code units.
- Required for `constructParticles()`, as this only shifts the positions and velocities of all the particles and does not affect the internal distribution.
494
+
495
+
- Example Usage
496
+
497
+
`Cloud_Constructor.setCenterAndBulkVel( 1.0, 2.0, 3.0, 0.1, 0.2, 0.3 );` sets the cloud to be located at `[1.0, 2.0, 3.0]` and with a bulk velocity of `[0.1, 0.2, 0.3]` in code units.
498
+
499
+
4. Step 4: Call the construction function to calculate the radial profiles and distribution function for this cloud:
500
+
501
+
```C++
502
+
constructDistribution()
503
+
```
504
+
505
+
- Notes
506
+
507
+
- One must have called `set*()` in advance (as in the previous step).
508
+
509
+
- This should be called before `constructParticles()`.
510
+
511
+
- Example Usage
512
+
513
+
`Cloud_Constructor.constructDistribution();`
514
+
515
+
5. Step 5: Call the following function to set the particle initial conditions for a cloud that is in an equilibrium state:
An array of all particles' position vectors to be set.
530
+
531
+
- `Vel_AllRank` : `real_par*`
532
+
533
+
An array of all particles' velocity vectors to be set.
534
+
535
+
- `Par_Idx0` : `long`
536
+
537
+
Starting index of particles in this cloud.
538
+
539
+
- Notes
540
+
541
+
- One must have called `constructDistribution()` in advance (as in the previous step).
542
+
543
+
- Note that this function is not parallelized currently. One can only call it by the root rank and scatter the constructed particles to other ranks later.
544
+
545
+
- Example Usage
546
+
547
+
`Cloud_Constructor.constructParticles( ParMass, ParPosX, ParVelX, (long)0 );` sets the particles' attributes in `Par_Init_ByFunction()` in a serial case.
548
+
For parallelized simulations, please see `src/TestProblem/Hydro/ParticleEquilibriumIC/Par_Init_ByFunction_ParEqmIC.cpp` for instructions on how to construct all particles by one rank and scatter them out.
549
+
550
+
6. After the particles are constructed, one can access the object’s following attributes to check the numerical results:
551
+
552
+
- `Cloud_Constructor.TotCloudMass` is the total enclosed mass within the maximum radius of this cloud.
553
+
554
+
- `Cloud_Constructor.ParticleMass` is the particle mass as the total enclosed mass divided by the number of particles in the cloud.
555
+
556
+
- `Cloud_Constructor.TotCloudMassError` is the total enclosed mass relative error compared to the analytical expectation.
557
+
558
+
For pratical examples, please refer to the test problems `Hydro/ParticleEquilibriumIC` and `ELBDM/HaloMerger`.
0 commit comments