Skip to content

Commit

Permalink
Adapt also ducktrack
Browse files Browse the repository at this point in the history
  • Loading branch information
giadarol committed Jan 11, 2024
1 parent 72bcefc commit dc67773
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ducktrack/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions xtrack/beam_elements/elements_src/linesegmentmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit dc67773

Please sign in to comment.