|
16 | 16 | if __name__ == "__main__": |
17 | 17 | # open file for writing |
18 | 18 | f = Series( |
19 | | - "../samples/7_particle_write_serial_py.h5", |
| 19 | + "../samples/9_particle_write_serial_py.h5", |
20 | 20 | Access.create |
21 | 21 | ) |
22 | 22 |
|
|
35 | 35 | "Electrons... the necessary evil for ion acceleration! ", |
36 | 36 | "Just kidding.") |
37 | 37 |
|
| 38 | + n_particles = 234 |
| 39 | + |
38 | 40 | # let's set a weird user-defined record this time |
39 | 41 | electrons["displacement"].unit_dimension = {Unit_Dimension.M: 1} |
40 | 42 | electrons["displacement"][SCALAR].unit_SI = 1.e-6 |
41 | | - dset = Dataset(np.dtype("float64"), extent=[2]) |
| 43 | + dset = Dataset(np.dtype("float64"), extent=[n_particles]) |
42 | 44 | electrons["displacement"][SCALAR].reset_dataset(dset) |
43 | 45 | electrons["displacement"][SCALAR].make_constant(42.43) |
44 | 46 | # don't like it anymore? remove it with: |
45 | 47 | # del electrons["displacement"] |
46 | 48 |
|
47 | | - electrons["weighting"][SCALAR].make_constant(1.e-5) |
| 49 | + electrons["weighting"][SCALAR] \ |
| 50 | + .reset_dataset(Dataset(np.dtype("float32"), extent=[n_particles])) \ |
| 51 | + .make_constant(1.e-5) |
48 | 52 |
|
49 | | - particlePos_x = np.random.rand(234).astype(np.float32) |
50 | | - particlePos_y = np.random.rand(234).astype(np.float32) |
| 53 | + particlePos_x = np.random.rand(n_particles).astype(np.float32) |
| 54 | + particlePos_y = np.random.rand(n_particles).astype(np.float32) |
51 | 55 | d = Dataset(particlePos_x.dtype, extent=particlePos_x.shape) |
52 | 56 | electrons["position"]["x"].reset_dataset(d) |
53 | 57 | electrons["position"]["y"].reset_dataset(d) |
54 | 58 |
|
55 | | - particleOff_x = np.arange(234, dtype=np.uint) |
56 | | - particleOff_y = np.arange(234, dtype=np.uint) |
| 59 | + particleOff_x = np.arange(n_particles, dtype=np.uint) |
| 60 | + particleOff_y = np.arange(n_particles, dtype=np.uint) |
57 | 61 | d = Dataset(particleOff_x.dtype, particleOff_x.shape) |
58 | 62 | electrons["positionOffset"]["x"].reset_dataset(d) |
59 | 63 | electrons["positionOffset"]["y"].reset_dataset(d) |
|
0 commit comments