Skip to content

Commit

Permalink
replace extent in weighting and displacement
Browse files Browse the repository at this point in the history
store extent value in n_particles
  • Loading branch information
IlianCS authored and ax3l committed Aug 18, 2023
1 parent e31e4dd commit 5de95b3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/9_particle_write_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if __name__ == "__main__":
# open file for writing
f = Series(
"../samples/7_particle_write_serial_py.h5",
"../samples/9_particle_write_serial_py.h5",
Access.create
)

Expand All @@ -35,25 +35,29 @@
"Electrons... the necessary evil for ion acceleration! ",
"Just kidding.")

n_particles = 234

# let's set a weird user-defined record this time
electrons["displacement"].unit_dimension = {Unit_Dimension.M: 1}
electrons["displacement"][SCALAR].unit_SI = 1.e-6
dset = Dataset(np.dtype("float64"), extent=[2])
dset = Dataset(np.dtype("float64"), extent=[n_particles])
electrons["displacement"][SCALAR].reset_dataset(dset)
electrons["displacement"][SCALAR].make_constant(42.43)
# don't like it anymore? remove it with:
# del electrons["displacement"]

electrons["weighting"][SCALAR].make_constant(1.e-5)
electrons["weighting"][SCALAR] \
.reset_dataset(Dataset(np.dtype("float32"), extent=[n_particles])) \
.make_constant(1.e-5)

particlePos_x = np.random.rand(234).astype(np.float32)
particlePos_y = np.random.rand(234).astype(np.float32)
particlePos_x = np.random.rand(n_particles).astype(np.float32)
particlePos_y = np.random.rand(n_particles).astype(np.float32)
d = Dataset(particlePos_x.dtype, extent=particlePos_x.shape)
electrons["position"]["x"].reset_dataset(d)
electrons["position"]["y"].reset_dataset(d)

particleOff_x = np.arange(234, dtype=np.uint)
particleOff_y = np.arange(234, dtype=np.uint)
particleOff_x = np.arange(n_particles, dtype=np.uint)
particleOff_y = np.arange(n_particles, dtype=np.uint)
d = Dataset(particleOff_x.dtype, particleOff_x.shape)
electrons["positionOffset"]["x"].reset_dataset(d)
electrons["positionOffset"]["y"].reset_dataset(d)
Expand Down

0 comments on commit 5de95b3

Please sign in to comment.