-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation_parameters.py
50 lines (43 loc) · 1.77 KB
/
simulation_parameters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
from dataclasses import dataclass
from typing import Optional
from warnings import warn
@dataclass(frozen=True)
class SimulationParameters:
""" Contains all the information about the simulation parameters.
Attributes
----------
n_cells : int
Number of cells in each direction.
The edges_cells property is [n_cells, n_cells, n_cells].
(This is for generality, in the future we may want to have different number of cells in each direction)
cc : float
Numerical speed of light.
q_over_m : float
Charge to mass ratio.
gamma_syn : Optional[float]
Synchrotron drag coefficient. If set to None, no synchrotron drag is applied.
gamma_ic : Optional[float]
Inverse compton drag coefficient. If set to None, no inverse compton drag is applied.
beta_rec : float
Fiducial magnetic energy extraction rate.
particle_lifetime : Optional[float]
Particle lifetime in light box crossing time. If set to None, particles have infinite lifetime.
"""
n_cells: int = 4*160
cc: float = 0.45
q_over_m: float = -1.
gamma_syn: Optional[float] = 10.
gamma_ic: Optional[float] = 10.
beta_rec: float = 0.1
particle_lifetime: Optional[float] = None
def __post_init__(self):
if self.cc > 0.5:
warn(f"Numerical velocity of light (CC={self.cc}) is too high (> 0.5), simulation will be unstable")
@property
def edges_cells(self):
return np.array([self.n_cells, self.n_cells, self.n_cells])
@property
def as_array(self):
""" Turns the parameters into a numpy array so that it can be easily used in h5py """
return np.array([self.n_cells, self.cc, self.q_over_m, self.gamma_syn, self.gamma_ic, self.beta_rec])