-
Notifications
You must be signed in to change notification settings - Fork 1
Num beta osc stage length #175
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
Open
ben-c-2013
wants to merge
112
commits into
main
Choose a base branch
from
num_beta_osc_stage_length
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
290c774
Added Stage.length_num_beta_osc() to calculate the stage length that …
ben-c-2013 3535df0
Edited Stage.length_num_beta_osc() and added Stage.length2num_beta_os…
ben-c-2013 f02f154
Added Stage.calc_flattop_num_beta_osc() for calculating the number of…
ben-c-2013 6e86c7a
Edited the docstrings of Stage.calc_flattop_num_beta_osc(), and edite…
ben-c-2013 c72de2b
Added default parameters to Stage.match_length2num_beta_osc() and edi…
ben-c-2013 ed670be
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 85b48c3
Added the function phase_advance() to abel/utilities/beam_physics.py.
ben-c-2013 5171f30
Added controls for stage parameters that may not be set in Stage.flat…
ben-c-2013 7120593
Added control to Stage.calc_flattop_num_beta_osc() to ensure that the…
ben-c-2013 618d342
Merge branch 'StageReducedModels_modify_ramp_time_step_mod' into num_…
ben-c-2013 e0fff13
Added Stage.phase_advance_beta_evolution() and in the process of modi…
ben-c-2013 938add4
Cleaned up in various betatron phase matching functions in abel/class…
ben-c-2013 e22e742
Reduced the number of time steps used in ramp tracking in StageReduce…
ben-c-2013 ee98ccb
Correction in Stage.match_length2num_beta_osc().
ben-c-2013 0d194cd
Changed the name of Stage.match_length2num_beta_osc() to Stage.calc_l…
ben-c-2013 138f90b
Added tests for checking the ramp phase advance and setting the stage…
ben-c-2013 aee6e2a
Merge remote-tracking branch 'mainline/main' into num_beta_osc_stage_…
ax3l 37249a4
Added a class method to StageHipace for estimating the orbit that a d…
ben-c-2013 285df8b
Removed commented out code in abel/classes/stage/impl/stage_hipace.py.
ben-c-2013 d3718d5
Added another dimension to the driver orbit tracking in StageHipace.d…
ben-c-2013 7c42513
Minor edit in abel/classes/stage/impl/stage_hipace.py.
ben-c-2013 e854afb
Changed the name StageHipace.driver_guiding_orbit() to StageHipace.dr…
ben-c-2013 ee8dcb0
Edited a hyperlink in the docstring of StageHipace.driver_guiding_tra…
ben-c-2013 ca9d97a
Added arc_lengths() for calculating trajectory length to abel/utiliti…
ben-c-2013 f60e0e5
Edited StageHipace.driver_guiding_trajectory() to raise an error if t…
ben-c-2013 9f20dbe
Correction in StageHipace.driver_guiding_trajectory() for the cases w…
ben-c-2013 704e77a
Bugfix for setting a transverse gradient for the azimuthal magnetic f…
ben-c-2013 12c6291
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 6a5adba
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 adc578a
Added controls to Stage.calc_length_num_beta_osc() and Stage.length_f…
ben-c-2013 0e79de1
Added _external_focusing_gradient as a Stage class attribute and modi…
ben-c-2013 0941c88
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 78ffa69
Edited Stage.calc_length_num_beta_osc() in such a way that a child cl…
ben-c-2013 da5644a
Edited StageHipace.calc_length_num_beta_osc() to include the contribu…
ben-c-2013 e2538f6
Decoupled Stage.calc_length_num_beta_osc() and StageHipace.calc_lengt…
ben-c-2013 d5663c8
Added more docstrings to StageHipace.calc_length_num_beta_osc() and e…
ben-c-2013 3cd19ff
Created the file tests/test_StageHipace.py and added tests for StageH…
ben-c-2013 3fc0d16
Added the tag StageHipace in pyproject.toml.
ben-c-2013 6273ede
Minor edit of Stage.length_flattop2num_beta_osc().
ben-c-2013 871b3c0
Corrected docstring in Stage.matched_beta_function().
ben-c-2013 c497708
Added StageHipace.Stage.matched_beta_function() to account for the co…
ben-c-2013 9ac14f1
Edited class methods of StageHipace to use the class attribute driver…
ben-c-2013 23d0d09
Minor docstring correction in tests/test_StageHipace.py.
ben-c-2013 2f8b1e3
Added Stage.get_ramp_length().
ben-c-2013 d92000c
Edited class methods in StageHipace for taking into account the lengt…
ben-c-2013 e98e361
Changed the class attribute StageHipace._external_focusing_gradient d…
ben-c-2013 74acd7c
Made corrections in tests/test_StageHipace.py::test_external_focusing…
ben-c-2013 f3d3f25
Edited StageHipace.driver_guiding_trajectory() to use the stage total…
ben-c-2013 92c5cc3
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 4ef5b5e
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 3e5eac0
Moved StageHipace.driver_guiding_trajectory() further down the file.
ben-c-2013 77e2592
Edited StageHipace.calc_length_num_beta_osc() to only use the nominal…
ben-c-2013 821f4b5
Edited tests/test_StageHipace.py::test_external_focusing to be compat…
ben-c-2013 754789b
Edited Stage.calc_length_num_beta_osc() to only use the nominal accel…
ben-c-2013 2d9d280
Added StageHipace.match_length_guiding_2_num_beta_osc().
ben-c-2013 d0e6b36
Changed the order of the input parameters in StageHipace.match_length…
ben-c-2013 d13968f
Made correction in StageHipace.match_length_guiding_2_num_beta_osc() …
ben-c-2013 578744b
Edited tests/test_StageHipace.py::test_external_focusing to be compat…
ben-c-2013 12f9269
Edited tests/test_StageReducedModels_beamline.py::test_ramped_linac()…
ben-c-2013 05301e8
Removed main source from setup_StageReducedModels() in tests/test_Sta…
ben-c-2013 03745f8
Renamed StageHipace.match_length_guiding_2_num_beta_osc() to StageHip…
ben-c-2013 d272cd4
Edited tests/test_StageHipace.py::test_match_length_2_num_beta_osc du…
ben-c-2013 dfafa9b
Renamed StageHipace.match_length_guiding_2_num_beta_osc() to StageHip…
ben-c-2013 051c61f
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 1c06ad9
Correction in tests/test_StageReducedModels_beamline.py due to the re…
ben-c-2013 cfa0d1c
Patched StageHipace.external_focusing setter to only calculate StageH…
ben-c-2013 796303e
Added external_focusing_gradient as a property with setter and getter…
ben-c-2013 e1f0474
Adited tests/test_StageHipace.py to be compatible with the new StageH…
ben-c-2013 4846013
Edited docstrings in tests/test_StageHipace.py.
ben-c-2013 cc1c158
Edited docstrings in abel/classes/stage/impl/stage_hipace.py.
ben-c-2013 0ce4510
Edited abel/classes/stage/stage.py to return Stage.external_focusing_…
ben-c-2013 88a8d86
Correction in StageHipace.driver_guiding_trajectory().
ben-c-2013 da77605
Edited abel/wrappers/hipace/hipace_wrapper.py::hipace_write_inputs to…
ben-c-2013 ab725dd
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 f57194c
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 3e3dba0
Added StageHipace.estimate_beam_trajectory() for estimating main beam…
ben-c-2013 8a5658b
Simplified StageHipace.driver_guiding_trajectory().
ben-c-2013 fffe736
Corrected a bug in StageHipace.estimate_beam_trajectory().
ben-c-2013 6da1154
Made corrections in StageHipace.estimate_beam_trajectory() to get the…
ben-c-2013 240e2d7
Major changes in StageHipace.estimate_beam_trajectory() for adding su…
ben-c-2013 74d9f48
Correction in StageHipace._estimate_beam_trajectory for calculating t…
ben-c-2013 3317278
Deleted most of the printing diagnostics in StageHipace._estimate_bea…
ben-c-2013 17f30a6
Removed the rest of the printing diagnostics in StageHipace._estimate…
ben-c-2013 6a500f6
Edited Stage.phase_advance_beta_evolution() to take into the account …
ben-c-2013 56313e8
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 c195ccd
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 a6b41f7
Added class methods for calculating the external focusing gradient an…
ben-c-2013 951bc38
Added getter for external focusing gradient to Stage.
ben-c-2013 fe31038
Edited src/abel/wrappers/hipace/hipace_wrapper.py for setting the ext…
ben-c-2013 356f3d3
Merge branch 'StageHipace_beam_trajectory_estimate' into num_beta_osc…
ben-c-2013 0d8ee16
Removed extra entry of Stage.external_focusing_gradient after mergein…
ben-c-2013 2639c05
Correction in StageHipace._estimate_beam_trajectory() and StageHipace…
ben-c-2013 7b6b08c
Merge branch 'StageHipace_beam_trajectory_estimate' into num_beta_osc…
ben-c-2013 9b50bc7
Made a correction in Stage._calc_ramp_length() that takes into accoun…
ben-c-2013 a05098d
Correction for Stage._calc_ramp_length(), as the previous update invo…
ben-c-2013 f8ebfd7
Minor correction in StageHIpace.calc_length_num_beta_osc() and StageH…
ben-c-2013 d8b297d
Major corrections and expansions in StageHipace._estimate_beam_trajec…
ben-c-2013 b53e431
Added phase_advance_traj_data() to src/abel/utilities/beam_physics.py.
ben-c-2013 5bc8b01
Edited phase_advance_traj_data in src/abel/utilities/beam_physics.py …
ben-c-2013 bf21d35
Merge branch 'main' into num_beta_osc_stage_length
ben-c-2013 77964ad
Remove src/abel/classes/stage/stage.py::calc_flattop_num_beta_osc.
ben-c-2013 645076c
Moved most of the logic in Stage.length_flattop2num_beta_osc() to src…
ben-c-2013 a971200
Removed Stage.phase_advance_beta_evolution().
ben-c-2013 ed98787
Updated tests/test_StageReducedModels_beamline.py after removing Stag…
ben-c-2013 efa2046
Changed name from StageHipace.driver_half_oscillations to StageHipace…
ben-c-2013 12eed77
Moved and replaced StageHipace.matched_beta_function() to Stage.match…
ben-c-2013 417b006
Moved functions for estimating guided beam trajectories from StageHip…
ben-c-2013 e6649bd
Removed src/abel/utilities/beam_physics.py::arc_lengths
ben-c-2013 130dd05
Renamed src/abel/utilities/beam_physics.py::phase_advance to phase_ad…
ben-c-2013 8fefb08
Edited the docstring in src/abel/utilities/beam_physics.py::phase_adv…
ben-c-2013 324f71a
Minor correction in docstring in src/abel/classes/stage/impl/stage_hi…
ben-c-2013 60251bb
Added Stage.external_focusing_gradient setter, added Stage.external_f…
ben-c-2013 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| # License: GPL-3.0-or-later | ||
|
|
||
| import numpy as np | ||
| import scipy.constants as SI | ||
|
|
||
|
|
||
| # ============================================= | ||
|
|
@@ -1152,3 +1153,113 @@ def evolve_chromatic_amplitude(ls, inv_rhos, ks, ms, taus, beta0, alpha0=0, Dx0= | |
|
|
||
| return W, evolution | ||
|
|
||
|
|
||
| # ============================================= | ||
| def phase_advance_integrate_betas(ss, betas): | ||
| """ | ||
| Calculate the phase advance in one dimesion by using the composite Simpson’s | ||
| rule (:func:`scipy.integrate.simpson() <scipy.integrate.simpson>`) to | ||
| integrate two arrays containing the location and the beta function. | ||
| """ | ||
|
|
||
| from scipy import integrate | ||
| inv_betas = 1/betas | ||
| return integrate.simpson(y=inv_betas, x=ss) | ||
|
|
||
|
|
||
| # ============================================= | ||
| def phase_advance_traj_data(pos, angles, orbit_pos=None, orbit_angles=None): | ||
| """ | ||
| Compute the unwrapped betatron phase advance from transverse position and | ||
| angle data by mapping the phase-space trajectory onto a normalised unit | ||
| circle and evaluating the continuous phase angle evolution. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| pos : [m] 1D float ndarray | ||
| Transverse position along the beamline. | ||
|
|
||
| angles : 1D float ndarray | ||
| Transverse angle dpos/ds. | ||
|
|
||
| orbit_pos : [m] 1D float ndarray, optional | ||
| Reference orbit transverse position (e.g., driver trajectory). If | ||
| provided, these are subtracted before phase calculation. Defaults to | ||
| `None`. | ||
|
|
||
| orbit_angles : 1D float ndarray, optional | ||
| Reference orbit transverse angles (e.g., driver trajectory angles). If | ||
| provided, these are subtracted before phase calculation. Defaults to | ||
| `None`. | ||
|
|
||
| Returns | ||
| ------- | ||
| phase_advance : float | ||
| Unwrapped phase angle in radians, representing the continuous betatron | ||
| phase advance at the end of the beamline | ||
| """ | ||
|
|
||
| if orbit_pos is not None: | ||
| pos = pos - orbit_pos | ||
| if orbit_angles is not None: | ||
| angles = angles - orbit_angles | ||
|
|
||
| # Compute the phase space angle by normalising coordinates to a unit circle | ||
| # and taking the arctangent before unwrapping | ||
| phase = np.unwrap(np.arctan2(angles / np.max(np.abs(angles)), | ||
| pos / np.max(np.abs(pos)))) | ||
|
|
||
| return np.abs(phase[-1] - phase[0]) | ||
|
|
||
|
|
||
| # ============================================= | ||
| def length2num_beta_osc(length, initial_energy, accel_gradient, foc_gradient, q=SI.e): | ||
| """ | ||
| Calculate the number of betatron oscillations a particle can undergo in | ||
| 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>` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| is not ``None``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| length : [m] float | ||
| Length of a plasma stage excluding ramps that the particle can | ||
| perform betatron oscillations in. | ||
|
|
||
| initial_energy : [eV] float | ||
| The initial energy of the particle at the start of the plasma stage. | ||
|
|
||
| accel_gradient : [V/m] float | ||
| Nominal accelerating gradient of the plasma stage exclusing ramps. | ||
|
|
||
| foc_gradient : [T/m] float | ||
| The gradient of the total transverse focusing field. | ||
|
|
||
| q : [C] float, optional | ||
| Particle charge. q * accel_gradient must be positive. | ||
| Defaults to elementary charge. | ||
|
|
||
|
|
||
| Returns | ||
| ------- | ||
| num_beta_osc : float | ||
| Total number of betatron oscillations that the particle will perform | ||
| across the plasma stage. | ||
| """ | ||
|
|
||
| if q * accel_gradient < 0: | ||
| raise ValueError('q * accel_gradient must be positive.') | ||
|
|
||
| if accel_gradient < 1e-15: # Need to treat very small gradients separately. Often the case for plasma density ramps. | ||
| return np.sqrt(np.abs(q)*SI.c*foc_gradient/(initial_energy*SI.e)) * length/(2*np.pi) | ||
| else: | ||
|
|
||
| prefactor = 2*np.sqrt(np.abs(q)*foc_gradient*SI.c) / (q*accel_gradient) | ||
| energy_scaling = np.sqrt(initial_energy*SI.e + q*accel_gradient*length) - np.sqrt(initial_energy*SI.e) | ||
|
|
||
| num_beta_osc = prefactor * energy_scaling / (2*np.pi) | ||
|
|
||
| return num_beta_osc | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.