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

New Matlab function atsimplering #657

Merged
merged 7 commits into from
Oct 5, 2023
Merged

New Matlab function atsimplering #657

merged 7 commits into from
Oct 5, 2023

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Sep 17, 2023

The new function atsimplering creates a simple lattice according to a set of ring properties. A "simple ring" consists of:

  • A RF cavity
  • a 6x6 linear transfer map
  • a detuning and chromaticity element
  • a simplified quantum diffusion element which provides the equilibrium emittance, radiation damping and energy loss

It is defined by:

  • the nominal energy [eV],
  • the ring circumference [m],
  • the harmonic number,
  • the horizontal tune,
  • the vertical tune,
  • the RF voltage [V],
  • the momentum compaction factor.

plus optional parameters:

  • either vertical and horizontal alpha, beta, emittance, or sigma matrix,
  • horizontal, vertical and longitudinal damping times,
  • energy loss per turn,
  • particle,
  • lattice name.

It is similar to the python simplering introduced in #643

@lfarv lfarv added enhancement Matlab For Matlab/Octave AT code labels Sep 17, 2023
@simoneliuzzo
Copy link
Contributor

Dear @lfarv @lcarver and @swhite2401 ,

what is the difference with atfastring? The imputs are parameters rather than an AT lattice?

I will try to test it

thank you,

best regards
Simone

@lcarver
Copy link
Contributor

lcarver commented Sep 18, 2023 via email

@simoneliuzzo
Copy link
Contributor

Dear @lcarver @lfarv and @swhite2401,

if the output is ought to be the same, why having two functions rather than simply adding inputs to atfastring?

For example:
if you give a lattice it will use the lattice. (atfastring)
if you give the parameters it will use the parameters. (atsimplering)
if you give a partial amount of parameters it will use the lattice to get the defaults for the others. (atfastsimplering)

best regards
Simone

@simoneliuzzo
Copy link
Contributor

Dear @lfarv @lcarver and @swhite2401,

do you have a test function checking that the output elements are strictly the same for atfastring(ring) and atsimplering(parameters_of_ring) ?

@lfarv
Copy link
Contributor Author

lfarv commented Sep 18, 2023

if the output is ought to be the same, why having two functions rather than simply adding inputs to atfastring?

@simoneliuzzo
What you propose could be done, though I have doubts on the interest of the "mixed" input. But I'm not pushing for that because:

  • generally speaking, I prefer having different functions for different tasks, rather than trying to mix things with ambiguous inputs. Parsing the different possible ways of giving the simplering parameters is already tricky,
  • here, the purpose of the two functions is really different: modelling an existing lattice for fastring, creating a new lattice from scratch for simplering,
  • if you look in detail, you'll see that the generated lattices are somewhat different: in fastring the damping is included in the linear 6x6 matrix, in simplering it's in the quantdiff element, the quantum diffusion is also treated differently. It's not the ideal solution, it could be possible for fastring to generate the same elements than simplering but not the other way round. So unifying the output needs a modification of fastring. Possible, but it's another topic.

The test you propose is a good idea. But the comparison is not easy because the generated lattice are different, though they should behave the same…

atmat/lattice/atsimplering.m Show resolved Hide resolved
atmat/lattice/atsimplering.m Show resolved Hide resolved
@lcarver
Copy link
Contributor

lcarver commented Sep 21, 2023

Looks good to me. Thanks a lot

@lcarver lcarver self-requested a review September 21, 2023 12:11
@lfarv
Copy link
Contributor Author

lfarv commented Sep 22, 2023

@lcarver : I had to solve a conflict with the updated master. Could you approve again? Thanks

@simoneliuzzo : any more comments on this function?

@lfarv lfarv requested a review from lcarver September 22, 2023 13:22
@lfarv
Copy link
Contributor Author

lfarv commented Oct 5, 2023

After solving a conflict with the master branch (Matlab version number), I need another review.
Can @lcarver or @simoneliuzzo approve again?

@lfarv lfarv merged commit 62a668e into master Oct 5, 2023
31 checks passed
@lfarv lfarv deleted the matlab_simplering branch October 5, 2023 09:43
lnadolski added a commit that referenced this pull request Oct 25, 2023
# By Laurent Farvacque (14) and others
# Via GitHub
* master: (28 commits)
  Add passive beamloading cavity (#586)
  Create BndStrMPoleSymplectic4RadPass (#665)
  Documentation fixes (#669)
  Update of the build process (#659)
  New Matlab function atsimplering (#657)
  Collective bugfix (#664)
  Correct the attribute name of solenoids in Matlab (#663)
  Error parsing args for twiss_in and r_4d (#662)
  Fix atmaincavities (#656)
  Fix attribute names in Simple Ring (#655)
  Remove collective passes from internal lattice_pass (#650)
  The DPStep keyword in linopt6 raises an error for 4D lattices (#651)
  Bug fix in atdisable_6d: keep the Energy field in cavities. (#654)
  fix: ring phase advances in computeRDT.m (#652)
  Correct the axis definition in plot_sigma (#648)
  Don't automatically cache the location of RF cavities (#640)
  Simple ring model (#643)
  Correct Dipole tapering (#623)
  Chromatic functions extended (#644)
  Repair the Matlab tests (#645)
  ...

# Conflicts:
#	atmat/Contents.m
#	atmat/atphysics/Radiation/atdisable_6d.m
#	atmat/atphysics/Radiation/atenable_6d.m
#	atmat/lattice/at2str.m
#	atmat/pubtools/create_elems/atidtable_dat.m
#	pyat/at/lattice/elements.py
#	pyat/at/lattice/lattice_object.py
#	pyat/at/physics/matrix.py
#	pyat/at/physics/radiation.py
#	pyat/examples/CollectiveEffects/RobinsonInstability.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Matlab For Matlab/Octave AT code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants