Skip to content

Num beta osc stage length#175

Open
ben-c-2013 wants to merge 112 commits into
mainfrom
num_beta_osc_stage_length
Open

Num beta osc stage length#175
ben-c-2013 wants to merge 112 commits into
mainfrom
num_beta_osc_stage_length

Conversation

@ben-c-2013

@ben-c-2013 ben-c-2013 commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

Adds the capability to tailor the length of Stage according to desired number of betatron oscillations. Also includes tests, but these require PR #174.

In addition, also includes functions for estimating the orbit of the drive beam when driver guiding with an external azimuthal magnetic field is applied to a drive beam with an anglar offset.

…gives a given number of main beam betatron oscillations.
…c() to calculate the number of betatron oscillations a particle can undergo in the stage.
… betatron oscillations that should be performed in the main flattop by subtracting the contributions from the ramps.
…d Stage.flattop_length2num_beta_osc() for calculating the number of betatron oscillations when the gradient is small (usually the case for ramps).
…fying Stage.flattop_length2num_beta_osc() and Stage.calc_flattop_num_beta_osc().
…ength_num_beta_osc() and removed unnecessary comments and imports in some of the beatron oscillation length and phase advance class methods.
… flattop lengths to match the number of betatron oscillations.
@ben-c-2013 ben-c-2013 added the enhancement New feature or request label Dec 1, 2025
@ben-c-2013 ben-c-2013 requested a review from kyrsjo December 1, 2025 16:42
…ield used for driver guiding in abel/classes/stage/impl/stage_hipace.py.
….driver_guiding_trajectory() for array initialisation.
…lving self.external_focusing_gradient may cause an infinite loop.
…tory() and StageHipace.estimate_beam_trajectory(). Also removed a commented out version of StageHipace.calc_length_num_beta_osc().
…to include correction for driver trajectory.
@kyrsjo

kyrsjo commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Merge from master before today's meeting?

Comment thread src/abel/classes/stage/stage.py Outdated

@ben-c-2013 ben-c-2013 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changes to be done...

Comment thread src/abel/classes/stage/stage.py


# ==================================================
def match_length_2_num_beta_osc(self, num_beta_osc, q=SI.e):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should add logic to autimiatically find closest num_beta_osc for current stage length. Can perhaps do this in separate PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Make an issue about it?

Comment thread src/abel/classes/stage/stage.py
Comment thread src/abel/classes/stage/stage.py Outdated
Comment thread src/abel/classes/stage/impl/stage_hipace.py Outdated
Comment thread src/abel/classes/stage/impl/stage_hipace.py Outdated
Comment thread src/abel/classes/stage/impl/stage_hipace.py Outdated
Comment thread src/abel/utilities/beam_physics.py
Comment thread src/abel/utilities/beam_physics.py Outdated
Comment thread src/abel/utilities/beam_physics.py Outdated
@ben-c-2013 ben-c-2013 marked this pull request as ready for review May 30, 2026 00:06
ramp_length = beta_matched(self.plasma_density, ramp.nom_energy)*np.pi/(2*np.sqrt(1/ramp_beta_mag))

g = SI.e*self.plasma_density/(2*SI.epsilon_0*SI.c) # [T/m], ion background focusing gradient
#if self.external_focusing_gradient is not None: # Add contribution from external field

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove unused comments?

``True``. Otherwise, will match the beta function to the downramp.
Default set to ``True``.

q : [C] float, optional

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some comment about the sign of this? I see you later use abs(q)

the stage (excluding ramps).

Will take into account the contribution from an external linear magnetic
field B=[gy,-gx,0] if :attr:`self.external_focusing_gradient <abel.Stage.external_focusing>`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

self.?

@kyrsjo

kyrsjo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

I had a very very quick look, @carlandreaslindstrom should probably see more for the architechture stuff.

@kyrsjo

kyrsjo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Hmm, looking at the output here https://app.readthedocs.org/projects/abel/builds/32906630/ (expand the final command python -m sphinx -T -b html -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html ) we should definitively have another PR focused on cleaning up the RTD/Sphinx stuff.

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 this pull request may close these issues.

3 participants