Hello,
I am trying to run a powder diffraction model using multiple threads on windows.
If i try and set config.NTHREADS to any number, it does not seem to make an observable difference on the run time, and from CPU load it does not appear any multiprocessing is going on.
I attempted to write my own multiprocessing script using Pool() but it appears that this cannot be done since the code as implemented already parallelizes over the 2theta angle.
for reference, i am running this as a python script with python=3.11 .
Is there a straightforward way to enable parallelization on windows?
Code is attached, cif file is arbitrary.
code
```
import matplotlib.pyplot as pp
import numpy as np
import xrayutilities as xu
import multiprocessing as mp
from xrayutilities import config
config.NTHREADS=16
def main():
BB= xu.materials.Crystal.fromCIF("Crystal.cif")
tt= np.arange(5,80,0.02)
size=np.arange(1,51,1)
Ntt=len(tt)
intensities= np.zeros((len(tt),len(size)))
print("Frame Size",np.shape(intensities))
def compute(s):
BB_powder=xu.simpack.Powder(BB,volume = 1 ,crystallite_size_gauss=s*1e-9)
pm = xu.simpack.PowderModel(BB_powder,I0=100)
sim = pm.simulate(tt)
pm.close()
return sim
for s in size:
print("Num: ",s)
intensities[:,s-1]= compute(s)
print("Complete")
pp.figure(figsize=(12,3))
pp.xlim(8,15)
for s in range(5):
pp.plot(tt,intensities[:,10*s-1],label=str(s*10))
pp.legend(bbox_to_anchor=(1,.5))
if __name__ == '__main__':
mp.freeze_support()
main()
Hello,
I am trying to run a powder diffraction model using multiple threads on windows.
If i try and set
config.NTHREADSto any number, it does not seem to make an observable difference on the run time, and from CPU load it does not appear any multiprocessing is going on.I attempted to write my own multiprocessing script using
Pool()but it appears that this cannot be done since the code as implemented already parallelizes over the2thetaangle.for reference, i am running this as a python script with
python=3.11.Is there a straightforward way to enable parallelization on windows?
Code is attached, cif file is arbitrary.
code
```