forked from BrianMarre/picongpuAtomicPhysicsTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheck_totalWeight.py
executable file
·40 lines (29 loc) · 984 Bytes
/
Check_totalWeight.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
import openpmd_api as io
import numpy as np
import math
filename = "/home/marre55/picongpuOutput/testMacroCount/simOutput/openPMD/simOutput_%T.bp"
speciesName = "C"
series = io.Series(filename, io.Access.read_only)
totWeightingNumpy = {}
totWeightingFsum = {}
totWeightingDumb = {}
totWeightingSorted = {}
for iteration in series.iterations:
step = series.iterations[iteration]
weighting = step.particles[speciesName]["weighting"][io.Mesh_Record_Component.SCALAR]
dataWeightings = weighting.load_chunk()
series.flush()
totWeightingNumpy[iteration] = np.sum(dataWeightings)
totWeightingFsum[iteration] = math.fsum(dataWeightings)
sum = 0
for weight in sorted(dataWeightings):
sum += weight
totWeightingSorted[iteration] = sum
sum = 0
for weight in dataWeightings:
sum += weight
totWeightingDumb[iteration] = sum
print(totWeightingNumpy)
print(totWeightingFsum)
print(totWeightingSorted)
print(totWeightingDumb)