Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solenoid in Segment behaves like a Quadrupole in plot_overview() #366

Open
emrecosgun314 opened this issue Mar 5, 2025 · 1 comment · May be fixed by #380
Open

Solenoid in Segment behaves like a Quadrupole in plot_overview() #366

emrecosgun314 opened this issue Mar 5, 2025 · 1 comment · May be fixed by #380
Assignees
Labels
enhancement New feature or request

Comments

@emrecosgun314
Copy link

Hi,

I encountered an issue where Solenoid elements inside a Segment behave like Quadrupoles when using plot_overview().

In the following basic example, particles are transported through a Solenoid magnet, but the resulting plot seems to apply quadrupole transportation.
Thanks,

beam_twiss = ParticleBeam.from_twiss(
num_particles=torch.tensor(10_000_000),
beta_x=torch.tensor(5.912),
alpha_x=torch.tensor(1.0),
emittance_x=torch.tensor(3.494e-09),
beta_y=torch.tensor(5.912),
alpha_y=torch.tensor(1.0),
emittance_y=torch.tensor(3.494e-09),
energy=torch.tensor(6e6),)
single_sol = Solenoid(length=torch.tensor(0.5), k=torch.tensor(1.5))

segment_single = Segment(elements=[
Drift(length=torch.tensor(0.5)),
single_sol,
Drift(length=torch.tensor(0.5)),
])
outgoing_beam = segment_single.track(beam_twiss)

segment_single.plot_overview(incoming=outgoing_beam)
outgoing_beam.alpha_x, outgoing_beam.alpha_y ##output tensor(0.3604), tensor(0.3607)

Image

@cr-xu
Copy link
Member

cr-xu commented Mar 12, 2025

Hi,

the plot_overview should take the incoming beam upstream of the section, so in your MWE, the line
segment_single.plot_overview(incoming=outgoing_beam)
should be
segment_single.plot_overview(incoming= beam_twiss).

The visualization error for the solenoid is also due to the split method being not implemented yet.

@cr-xu cr-xu self-assigned this Mar 12, 2025
@cr-xu cr-xu added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Mar 12, 2025
@cr-xu cr-xu linked a pull request Mar 12, 2025 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants