Skip to content

Commit

Permalink
Update time simulation parameters z
Browse files Browse the repository at this point in the history
  • Loading branch information
fuodorov committed Aug 7, 2024
1 parent 50a6f8f commit 96fac34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion redpic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

NAME = "redpic"

VERSION = "0.11.7"
VERSION = "0.11.8"

AUTHOR = "Vyacheslav Fedorov"

Expand Down
6 changes: 6 additions & 0 deletions redpic/solver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ def __init__(
t_start: float = 0.0e0,
t_stop: float = 0.0e0,
dt: float = 0.0e0,
z_start: float = 0.0e0,
z_stop: float = 0.0e0,
dz: float = 0.0e0,
):
self.beams = beam if isinstance(beam, Iterable) else [beam]
self.acc = accelerator
self.result = {}
self.t_start = t_start
self.t_stop = t_stop if t_stop else (self.acc.z_stop - self.acc.z_start) / const.c
self.dt = dt if dt else self.acc.dz / const.c
self.z_start = z_start if z_start else self.acc.z_start
self.z_stop = z_stop if z_stop else self.acc.z_stop
self.dz = dz if dz else const.c * self.dt

@abstractmethod
def _track(self, *, n_files: int) -> None:
Expand Down
8 changes: 4 additions & 4 deletions redpic/solver/red.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _second_step_red_cuda(

def _track(self, *, n_files: int = cfg.DEFAULT_TRACK_SAVE_N_FILES) -> None:
# Init parameters
z_start, z_stop, dz = self.acc.z_start, self.acc.z_stop, self.acc.dz
z_start, z_stop, dz = self.z_start, self.z_stop, self.dz
t_start, t_stop, dt = self.t_start, self.t_stop, self.dt

Y = np.transpose(np.concatenate([beam.df.to_numpy() for beam in self.beams]))
Expand Down Expand Up @@ -224,16 +224,16 @@ def _track(self, *, n_files: int = cfg.DEFAULT_TRACK_SAVE_N_FILES) -> None:
Bx, By, Bz = Bx * gamma * B0, By * gamma * B0, Bz * gamma * B0
Ex, Ey, Ez = Ex * E0, Ey * E0, Ez * E0

progress, meters = t / t_stop * 100, z_start + t * const.c
progress = t / t_stop * 100
if progress % (100 // n_files) < 2 * dt / t_stop * 100:
self.result.update(
{
round(meters, 3): pd.DataFrame(
round(progress, 3): pd.DataFrame(
np.transpose(
np.vstack((Y[0], Y[1], Y[2], Y[3], Y[4], Y[5], Bx, By, Bz, Ex, Ey, Ez, macro_q))
),
columns=["x", "y", "z", "px", "py", "pz", "Bx", "By", "Bz", "Ex", "Ey", "Ez", "charge"],
)
}
)
print("\rz = %.2f m (%.1f %%) " % (meters, progress), end="")
print("\r%.1f %% " % progress, end="")

0 comments on commit 96fac34

Please sign in to comment.