entity-toolkit / entity

New generation astrophysical plasma simulation code with CPU/GPU portability
https://entity-toolkit.github.io/wiki/
Other
29 stars 2 forks source link

Dev/moments #8

Closed haykh closed 1 year ago

haykh commented 1 year ago
  1. Evaluating moments from particle distribution for the output (* details below)
  2. Abstraction for the output fields
  3. Minor reformatting

(*) Users can now provide [output] fields = [..., ...] parameter in the input with the desired fields to be written at runtime.

Regular field components are addressed as Ex, Bz, Jy etc. To output all 3 components of the given field add Ei (where the code will automatically assume i=1,2,3 for E-field).

Rho and N stand for the mass and the number densities. T stands for the energy-stress tensor, which should be followed by two component identifiers. For instance, T01 or T0x or Ttx stands for the momentum flux in the x-direction. T0i will be automatically unraveled into 3 components with i=1,2,3. Tij will be unraveled into 6 independent components of the spatial part of the energy-momentum tensor i=1,2,3; i<j<=3. Tii will be interpreted as only the diagonal components, i.e., T11, T22, T33. One may also provide only the particular components, e.g., T23, T11, etc.

All the particle-based moments (densities, and the energy-stress tensor) will be computed by default using the distributions of all massive particles. If needed, one can specify the particular species for which to compute Rho, N and/or T separately. Simply pad the definition by the species indices, separated by the underscore _. For example, T03_2_4 computes the z-direction momentum flux for species 2 and 4, Tij_1 computes the stress-energy tensor components for the species 1.

Usage example

Assume the simulation has 4 species (electrons/positrons + ions + photons) and we want to output all the B-field components, the Ez, the pair density, the photon density, the total pressure-tensor of the plasma, and the photon momentum flux in all directions. Our input file might look something like this.

[particles]
n_species = 4

[species_1]
label    = "e-"
mass     = 1.0
charge   = -1.0

[species_2]
label    = "e+"
mass     = 1.0
charge   = 1.0

[species_3]
label    = "i"
mass     = 1800.0
charge   = 1.0

[species_4]
label    = "ph"
mass     = 0.0
charge   = 0.0

[output] 
fields = [ "Bi", "Ez", "Rho_1_2",  "Rho_4", "Tij_1_2_3", "T0i_4" ]