Skip to content

PTC Improvements and BugFixes#1200

Merged
rdemaria merged 118 commits into
MethodicalAcceleratorDesign:masterfrom
jgray-19:testing_ptc
Oct 19, 2023
Merged

PTC Improvements and BugFixes#1200
rdemaria merged 118 commits into
MethodicalAcceleratorDesign:masterfrom
jgray-19:testing_ptc

Conversation

@jgray-19

@jgray-19 jgray-19 commented Aug 16, 2023

Copy link
Copy Markdown
Contributor

Please see presentation for the list of changes to the code.

Changes to note:

  • A flag has been added to ptc_setswitch called nocharge. If you set this value to false, PTC receives the true value of the charge from your beam rather than 1. This has a significant effect on the tests, where it used to tell the user that the charge that had been "set" was the charge from the beam, not the actual charge that was set. Furthermore, in debug mode, if nocharge is set is output, therefore the tests have been changed to accommodate this.
  • ptcrbend and truerbend has been removed. Now we use true_rbend, therefore the diamond sequence has been changed accordingly.
  • Setting n_wedge to 0 is more stable (due to no 0 rotations), however this means that the test fails at on the final digit of the test-ptc-twiss-56Dt-ini_map_man and test-ptc-align tests. These tests have therefore been changed.
  • Solenoids are never converted to markers now, as they can have knl and ksl values, therefore they are changed to multipoles when l=0 and (lrad=0 or ksi=0). The tests have now been changed accordingly.
  • The inconsistency in sector_nmul_max, reported by Laurent here, has been corrected. The tests have been changed accordingly
  • The solenoid problem described in the presentation has also been fixed (trsol of trrun.f90). This is the only changed to the physics of MAD-X, everything else is changes to MAD-X-PTC, including documentation.

--EDIT--
I have now removed the changes to the solenoid equation. After running the tests, I found that both versions converged to the thick lens in the solenoid, but the previous implementation converged fastest in MAD-X, this is not the case in PTC or MAD-NG.

Closes issues:
#1160, #1135 and #1165 (was never completed)

jgray-19 and others added 30 commits April 13, 2023 18:35
…o use fint and fintx (fint2) separately. Comment out return so that rbend can have the rest of the attributes set
…on to rbend, sbend, quadrupole, sextupole and octupole. Stop solenoid being set to a marker in case of knl and ksl
…e, add k0 and k0s to octupole. Improve solenoid to act like multipole when l=0 and thick with l~=0
Comment thread src/trrun.f90 Outdated
track(5,i) = (sigf + (xf*pyf - yf*pxf)*Z) * beti
! JG: 25.07.2023 - Fix for T variable to match PTC,
! see http://cds.cern.ch/record/290467/files/arXiv:acc-phys_9510005.pdf
track(5,i) = (sigf + (xf*track(4,i) - yf*track(2,i))*Z) * beti

@rdemaria rdemaria Aug 16, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

matter of taste but I would write (sigf + (xf*pyf_- yf*pxf_)*Z) * beti

@jgray-19 jgray-19 Aug 16, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The variables pxf_ and pyf_ are currently being used by this function, could potentially have new variables called pxi and pyi :

Line from 3550

           !     Ripken formulae p.28 (3.35 and 3.36)
           xf    = track(1,i)
           pxi   = track(2,i)
           yf    = track(3,i)
           pyi   = track(4,i)
           psigf = track(6,i) * beti

Then it becomes

Suggested change
track(5,i) = (sigf + (xf*track(4,i) - yf*track(2,i))*Z) * beti
track(5,i) = (sigf + (xf*pyi - yf*pxi)*Z) * beti

@rdemaria

Copy link
Copy Markdown
Contributor

Are the additional ptc attributes needed for all the elements in madx_dict.c? They have a memory impact.

@jgray-19

Copy link
Copy Markdown
Contributor Author

Are the additional ptc attributes needed for all the elements in madx_dict.c? They have a memory impact.

For the elements, quadrupole, sextupole, octupole, rbend and sbend, they all go through the fringe maps, so for activation of fringes, yes. However, if you are concerned about memory, there are some elements that do not have fringe maps, such as the electrostatic separator, in which you could remove current arguments, such as kill_e(nt|xi)_fringe or fringe (of course, unless this is needed for MAD-X).

@ldeniau

ldeniau commented Aug 23, 2023

Copy link
Copy Markdown
Contributor

About memory impact, the fringe field attributes use about 8 numbers (let's round it to 10). So for example for the LHC, loading LHCB1 and LHCB2 in memory will use 500 MB (1GB after a matching), while the attribute will use 8 bytes x 10 attributes x 10000 elements ~ 0.5 MB. If all elements get those attributes (not the case) rounding up all numbers leads to a 0,1% memory increase. Just running PTC once will put this memory increase in the shadow...

@rdemaria

Copy link
Copy Markdown
Contributor

I see you are still adding important stuff. How much time do you need to complete it?

@jgray-19

jgray-19 commented Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

It should now be complete, all the tests pass, the final check that fails is unlikely to be due to this pull request, I suspect that the failure can be fixed with a sudo apt update, before the sudo apt-get ... that fails.

@jgray-19

Copy link
Copy Markdown
Contributor Author

Please see pull request #1203. With this fix, we can rerun the failing check, allowing it to pass. If you would like to see that the master fails, you can rerun this test, as I did for https://github.com/jgray-19/MAD-X/tree/master.

@rdemaria

Copy link
Copy Markdown
Contributor

ok I merge!

@rdemaria rdemaria merged commit 20475e4 into MethodicalAcceleratorDesign:master Oct 19, 2023
@rdemaria

Copy link
Copy Markdown
Contributor

@jgray-19

Copy link
Copy Markdown
Contributor Author

Yes, of course! Will look at this tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants