prism-em / prismatic

C++/CUDA package for parallelized simulation of image formation in Scanning Transmission Electron Microscopy (STEM) using the PRISM and multislice algorithms
GNU General Public License v3.0
79 stars 40 forks source link

randomSeed does not seem to be respected (prismatic2.0 installed from conda forge) #114

Open ialxn opened 3 years ago

ialxn commented 3 years ago

I was running a test with the same input parameters in the GUI version, the CLI version and pyprismatic. In all case the randomSeed (123) is reported correctly in e.g. prismatic_gui_params.txt but from the terminal output it seems that different seeds are used. Both randomSeed (in the initial parameters section) and base random seed and the subsequent random seed in PRISM01_calcPotential are different in the three tests I was running and none of the reported seeds correspond to my input value.

Also, when I sum the datasets I get slightly different values. I assume that this is not because different threads are performing different amounts of work and thus use different length of their individual random sequences.

files = ['cli.h5',  'gui.h5',  'py.h5']

for file in files:
    with h5py.File(file, 'r') as inf:
        data_set = inf['4DSTEM_simulation']['data']['realslices']['virtual_detector_depth0000']['data']
        data = np.asarray(data_set)
        print(f'{file}: {data.sum()}')

cli.h5: 3628.4873046875
gui.h5: 3628.651611328125
py.h5: 3628.532470703125