diff --git a/ducktrack/elements.py b/ducktrack/elements.py index a6a4c1b85..9d08df03b 100644 --- a/ducktrack/elements.py +++ b/ducktrack/elements.py @@ -731,6 +731,8 @@ def track(self,p): # both the position and the momentum are scaled, # rather than only the momentum. if self.energy_ref_increment != 0: + old_px = p.px.copy() + old_py = p.py.copy() new_energy0 = p.mass0*p.gamma0 + self.energy_ref_increment new_p0c = sqrt(new_energy0*new_energy0-p.mass0*p.mass0) new_beta0 = new_p0c / new_energy0 @@ -739,10 +741,12 @@ def track(self,p): p.p0c = new_p0c + import pdb; pdb.set_trace() + p.x *= geo_emit_factor - p.px *= geo_emit_factor + p.px = old_px * geo_emit_factor p.y *= geo_emit_factor - p.py *= geo_emit_factor + p.py = old_py * geo_emit_factor if self.damping_rate_x < 0.0 or self.damping_rate_y < 0.0 or self.damping_rate_s < 0.0: raise ValueError("Damping rates cannot be negative") diff --git a/xtrack/beam_elements/elements_src/linesegmentmap.h b/xtrack/beam_elements/elements_src/linesegmentmap.h index 99fc0d612..1da6d0525 100644 --- a/xtrack/beam_elements/elements_src/linesegmentmap.h +++ b/xtrack/beam_elements/elements_src/linesegmentmap.h @@ -304,6 +304,8 @@ void energy_and_reference_increments(LocalParticle *part0, // both the position and the momentum are scaled, // rather than only the momentum. if (energy_ref_increment != 0){ + printf("px = %e\n", LocalParticle_get_px(part)); + printf("py = %e\n", LocalParticle_get_py(part)); double const old_px = LocalParticle_get_px(part); double const old_py = LocalParticle_get_py(part); double const new_energy0 = LocalParticle_get_mass0(part) @@ -319,6 +321,9 @@ void energy_and_reference_increments(LocalParticle *part0, LocalParticle_set_py(part, old_py * geo_emit_factor); LocalParticle_scale_x(part, geo_emit_factor); LocalParticle_scale_y(part, geo_emit_factor); + printf("geo emit factor = %e\n", geo_emit_factor); + printf("px = %e\n", LocalParticle_get_px(part)); + printf("py = %e\n", LocalParticle_get_py(part)); } //end_per_particle_block