Skip to content
Snippets Groups Projects
Commit 08c96b9d authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Add share_stds method to Mpi

Can be used to compute the bunch standard deviations and share it between the different bunches.
parent 0ed7c616
No related branches found
No related tags found
No related merge requests found
...@@ -48,13 +48,16 @@ class Mpi: ...@@ -48,13 +48,16 @@ class Mpi:
Compute the bunch profiles and share it between the different bunches. Compute the bunch profiles and share it between the different bunches.
share_means(beam) share_means(beam)
Compute the bunch means and share it between the different bunches. Compute the bunch means and share it between the different bunches.
share_stds(beam)
Compute the bunch standard deviations and share it between the
different bunches.
References References
---------- ----------
[1] L. Dalcin, P. Kler, R. Paz, and A. Cosimo, Parallel Distributed [1] L. Dalcin, P. Kler, R. Paz, and A. Cosimo, Parallel Distributed
Computing using Python, Advances in Water Resources, 34(9):1124-1139, 2011. Computing using Python, Advances in Water Resources, 34(9):1124-1139, 2011.
"""
"""
def __init__(self, filling_pattern): def __init__(self, filling_pattern):
from mpi4py import MPI from mpi4py import MPI
self.MPI = MPI self.MPI = MPI
...@@ -214,4 +217,29 @@ class Mpi: ...@@ -214,4 +217,29 @@ class Mpi:
else: else:
mean = np.zeros((6,), dtype=np.float64) mean = np.zeros((6,), dtype=np.float64)
self.comm.Allgather([mean, self.MPI.DOUBLE], [self.mean_all, self.MPI.DOUBLE]) self.comm.Allgather([mean, self.MPI.DOUBLE], [self.mean_all, self.MPI.DOUBLE])
def share_stds(self, beam):
"""
Compute the bunch standard deviations and share it between the
different bunches.
Parameters
----------
beam : Beam object
"""
if(beam.mpi_switch == False):
print("Error, mpi is not initialised.")
bunch = beam[self.bunch_num]
charge_all = self.comm.allgather(bunch.charge)
self.charge_all = charge_all
self.std_all = np.empty((self.size, 6), dtype=np.float64)
if len(bunch) != 0:
std = bunch.std
else:
std = np.zeros((6,), dtype=np.float64)
self.comm.Allgather([std, self.MPI.DOUBLE], [self.std_all, self.MPI.DOUBLE])
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment