Skip to content

Commit 4794527

Browse files
committed
fixed formatting & replaced x_init with z_init
1 parent 590fbc9 commit 4794527

File tree

2 files changed

+65
-87
lines changed

2 files changed

+65
-87
lines changed

src/test_particle_sim_1d/particles.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Species:
3434
allocated length of all arrays (number of available slots)
3535
N : int
3636
current number of active particles
37-
x, vx : np.ndarray
37+
z, vx : np.ndarray
3838
arrays for position (m) and velocity (m/s) (1D simulation)
3939
weight : np.ndarray
4040
particle weights (used for scaling particle contribution to charge density)
@@ -62,10 +62,11 @@ def __init__(
6262
self.N = 0 # number of active particles
6363

6464
# allocate SoA storage (1D arrays for 1D sim); preallocate if capacity > 0
65-
self.x = np.zeros(self.capacity, dtype=self.dtype)
65+
self.z = np.zeros(self.capacity, dtype=self.dtype)
6666
self.vx = np.zeros(self.capacity, dtype=self.dtype)
67-
self.vy = np.zeros(self.capacity, dtype=self.dtype)
68-
self.vz = np.zeros(self.capacity, dtype=self.dtype)
67+
self.vy = np.zeros(self.capacity, dtype=self.dtype)
68+
self.vz = np.zeros(self.capacity, dtype=self.dtype)
69+
6970
# allocate auxiliary bookkeeping arrays
7071
self.weight = np.ones(self.capacity, dtype=self.dtype) # weighting factors
7172
self.alive = np.ones(self.capacity, dtype=bool) # true = active
@@ -77,7 +78,7 @@ def add_particles(self, z_init: np.ndarray, v_init: np.ndarray) -> None:
7778
7879
Parameters
7980
----------
80-
x_init : np.ndarray
81+
z_init : np.ndarray
8182
Initial positions of new particles
8283
vx_init : np.ndarray
8384
Initial velocities of new particles
@@ -89,7 +90,7 @@ def add_particles(self, z_init: np.ndarray, v_init: np.ndarray) -> None:
8990
"""
9091

9192
# number of new particles being added
92-
n_new = len(x_init)
93+
n_new = len(z_init)
9394

9495
# check if enough space; if not, allocate more
9596
self._ensure_capacity(self.N + n_new)
@@ -143,7 +144,7 @@ def initialize_uniform(
143144
# all velocities start with the same value v0
144145
if v0 is None:
145146
v_new = np.zeros((n, 3), dtype=self.dtype)
146-
else:
147+
else:
147148
v_new = np.tile(v0, (n, 1))
148149

149150
# reuse add_particles to avoid repeating logic (DRY principle)

0 commit comments

Comments
 (0)