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

Merge branch 'fix-CavityResonator-init' into 'develop'

[Fix] CavityResonator.init_phasor_track and CavityResonator.init_phasor

See merge request !24
parents 6dd997dd 7864c7e8
Branches
Tags
2 merge requests!280.8.0,!24[Fix] CavityResonator.init_phasor_track and CavityResonator.init_phasor
...@@ -387,10 +387,11 @@ class CavityResonator(): ...@@ -387,10 +387,11 @@ class CavityResonator():
if beam.mpi_switch: if beam.mpi_switch:
# get shared bunch profile for current bunch # get shared bunch profile for current bunch
beam.mpi.share_distributions(beam, n_bin=self.n_bin)
center = beam.mpi.tau_center[j] center = beam.mpi.tau_center[j]
profile = beam.mpi.tau_profile[j] profile = beam.mpi.tau_profile[j]
bin_length = beam.mpi.tau_bin_length[j] bin_length = float(beam.mpi.tau_bin_length[j][0])
charge_per_mp = beam.mpi.charge_per_mp_all[j] charge_per_mp = float(beam.mpi.charge_per_mp_all[j])
else: else:
if i == 0: if i == 0:
# get bunch profile for current bunch # get bunch profile for current bunch
...@@ -529,8 +530,8 @@ class CavityResonator(): ...@@ -529,8 +530,8 @@ class CavityResonator():
beam.mpi.share_distributions(beam, n_bin=self.n_bin) beam.mpi.share_distributions(beam, n_bin=self.n_bin)
center[:, index] = beam.mpi.tau_center[j] center[:, index] = beam.mpi.tau_center[j]
profile[:, index] = beam.mpi.tau_profile[j] profile[:, index] = beam.mpi.tau_profile[j]
bin_length[index] = beam.mpi.bin_length[j] bin_length[index] = float(beam.mpi.tau_bin_length[j][0])
charge_per_mp[index] = beam.mpi.charge_per_mp_all[j] charge_per_mp[index] = float(beam.mpi.charge_per_mp_all[j])
else: else:
(bins[:, index], sorted_index, profile[:, index], (bins[:, index], sorted_index, profile[:, index],
center[:, index]) = bunch.binning(n_bin=self.n_bin) center[:, index]) = bunch.binning(n_bin=self.n_bin)
......
...@@ -105,6 +105,19 @@ class TestCavityResonator: ...@@ -105,6 +105,19 @@ class TestCavityResonator:
assert phasor_init_phasor_track != init_phasor assert phasor_init_phasor_track != init_phasor
assert np.allclose(phasor_init_phasor, phasor_init_phasor_track, rtol=1e-2) assert np.allclose(phasor_init_phasor, phasor_init_phasor_track, rtol=1e-2)
def test_phasor_init_mpi(self, cav_res, beam_1bunch_mpi):
init_phasor = cav_res.beam_phasor
cav_res.init_phasor_track(beam_1bunch_mpi)
phasor_init_phasor_track = cav_res.beam_phasor
cav_res.beam_phasor = init_phasor
cav_res.init_phasor(beam_1bunch_mpi)
phasor_init_phasor = cav_res.beam_phasor
assert phasor_init_phasor != init_phasor
assert phasor_init_phasor_track != init_phasor
assert np.allclose(phasor_init_phasor, phasor_init_phasor_track, rtol=1e-2)
# Setting detune updates _detune, _fr, _wr, and _psi correctly # Setting detune updates _detune, _fr, _wr, and _psi correctly
def test_detune(self, cav_res): def test_detune(self, cav_res):
detune_value = 1000 detune_value = 1000
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment