Skip to content

Conversation

@ax3l
Copy link
Member

@ax3l ax3l commented Jul 11, 2025

Quick plot of a lattice over s.

Implement #887 (comment)

Example

import matplotlib.pyplot as plt

sim.lattice.plot_survey(ref=ref)
plt.show()
Figure_1 HTU Beamline: #1042

To Do

  • add a legend
  • add a test
  • update the bends to use the sign of rc
  • rename to plot_survey
  • solve discrepancies to HTU plot (e.g, quad +/- is inverted?): charge-to-mass ratio of ref particle influences focusing/defocusing
  • user-facing doc

Follow-Up

  • make color-palette configurable for users (store profiles in a common place, e.g., named "cern-lhc", "lbnl-als", "slac-lcls", "lbnl-htu", ...)
  • improve plotting of combined function elements: plot on top of each other with correct colors & different heights & opacities
  • sneakily remember the ref particle if the lattice is crated from sim.lattice

@ax3l ax3l requested review from RemiLehe and cemitch99 July 11, 2025 05:33
@ax3l ax3l added the component: python Python bindings label Jul 11, 2025
@ax3l ax3l force-pushed the topic-plot-lattice branch 2 times, most recently from ee5ab6d to b9bde5e Compare July 11, 2025 05:46
@ax3l ax3l force-pushed the topic-plot-lattice branch from b9bde5e to 46b7f50 Compare July 13, 2025 22:58
@ax3l ax3l requested a review from proy30 July 13, 2025 23:00
@ax3l ax3l force-pushed the topic-plot-lattice branch from 46b7f50 to 91b509b Compare July 14, 2025 21:28
@ax3l ax3l force-pushed the topic-plot-lattice branch from 91b509b to d9e0396 Compare July 21, 2025 19:20
@ax3l ax3l changed the title MPL: KnownElementsList.plot() MPL: KnownElementsList.plot_survey() Jul 21, 2025
@ax3l ax3l force-pushed the topic-plot-lattice branch 3 times, most recently from 3c83b75 to 524fd84 Compare July 21, 2025 21:37
Comment on lines +89 to +94
# if el_type == "Kicker":
# height = copysign(0.8, el_dict["xkick"])

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Comment on lines +17 to +31
"Quad": "tab:blue",
"Multipole": "tab:orange",
"Sbend": "tab:green",
"CFbend": "tab:olive", # TODO: improve and plot as two on top of each other
"ConstF": "tab:red",
"ChrPlasmaLens": "tab:red",
"SoftSolenoid": "tab:red",
"TaperedPL": "tab:red",
"RFCavity": "tab:brown",
"ShortRF": "tab:brown",
"Buncher": "tab:purple",
"Aperture": "black",
"Kicker": "tab:pink",
# 'tab:cyan'
"other": "tab:gray",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To double check, I asked again about the colors according to ChatGPT:

  • sbend (main dipole) – blue
  • quadrupole – silver-grey stainless steel (white for the IR triplets)
  • multipole corrector (sextupole, octupole, …) – blue
  • final-focus / triplet quadrupole (generic “focusing element”) – white
  • RF accelerating cavity (400 MHz) – white
  • RF buncher cavity (800 MHz) – white
  • aperture / collimator – beige-ivory (sometimes bare stainless steel)
  • kicker – black

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slac-lcls2:

(visual appearance in the LCLS-II tunnel / gallery)

  • sbend (dipole) – teal-green
  • quadrupole – teal-green
  • multipole (sextupole, octupole, corrector) – teal-green
  • other focusing magnets (doublets, triplets) – teal-green
  • 1.3 GHz SRF cryomodule – light-grey / metallic stainless-steel
  • 3.9 GHz harmonic (bunch-length control) cryomodule – light-grey / metallic stainless-steel
  • warm 2.856 GHz copper buncher cavity – copper-orange
  • aperture / collimator / slit – bare stainless-steel (silver-grey)
  • kicker (fast deflector) – teal-green

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lbnl-als (ALS-U)

  • sbend (dipole) – turquoise / teal-green
  • quadrupole – turquoise / teal-green
  • multipole (sextupole, octupole, corrector) – turquoise / teal-green
  • other focusing elements (doublets, triplets) – turquoise / teal-green
  • 500 MHz RF accelerating cavity – bare copper (reddish-orange)
  • higher-harmonic / bunching cavity – bare copper (reddish-orange)
  • aperture / collimator / absorber – bare stainless-steel (silver-grey)
  • kicker (injection / extraction) – turquoise / teal-green

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cornell-cesr:

  • sbend (dipole) – blue
  • quadrupole – green
  • multipole (sextupole / octupole / corrector) – red
  • other focusing elements (doublets / triplets) – green
  • RF accelerating cavity – bare copper (reddish-orange)
  • RF buncher / harmonic cavity – bare copper (reddish-orange)
  • aperture / collimator / absorber – bare stainless-steel (silver-grey)
  • kicker (injection / extraction) – yellow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnal-pip-ii (PIP-II linac / transfer line):

  • sbend (dipole) – teal-green
  • quadrupole – teal-green
  • multipole / corrector (sextupole, dipole corrector, etc.) – teal-green
  • other warm focusing elements (doublets, triplets) – teal-green
  • superconducting RF cryomodules (HWR, SSR1/2, LB650, HB650) – light-grey brushed stainless-steel
  • 162.5 MHz RFQ – light-grey brushed stainless-steel
  • 325 MHz room-temperature buncher cavity – copper-orange
  • aperture / collimator / absorber – bare stainless-steel (silver-grey)
  • kicker / chopper – teal-green

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add such palettes in a follow-up PR where we can do a careful review and detailed docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some checks on the SPS/LHC complex and there are def some hallucinations in the above responses :)

Example:
```py
import matplotlib.pyplot as plt

sim.lattice.plot_survey(ref)
plt.show()
```
Copy link
Member

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I tried this and it worked for me. I just left a suggestion regarding the documentation.

Co-authored-by: Chad Mitchell <[email protected]>
@ax3l ax3l merged commit 70691f4 into BLAST-ImpactX:development Jul 22, 2025
16 checks passed
@ax3l ax3l deleted the topic-plot-lattice branch July 22, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: python Python bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants