atcollab / at

Accelerator Toolbox
Apache License 2.0
48 stars 31 forks source link

New test of the average optics values #794

Closed lfarv closed 2 months ago

lfarv commented 3 months ago

This PR restores the comparative tests between python and Matlab in the pyat/test_matlab directory, which was failing for the average beta and dispersion checks.

Unfortunately, this test cannot be run in GitHub actions because a problem of Matlab license, so the problem was not immediately spotted. We introduce here a new test in the "Matlab tests" script, which is run on GitHub, to prevent any further problem.

The introduction of this new test revealed a number of residual errors in the computation of average values. Among others:

However all these ended up in relatively small errors. But the making it completely correct implied rather large modifications: mainly because we cannot assume that we have either focusing in both planes, or no focusing at all. Planes must now be dissociated.

The main improvement here is that the average values will be automatically checked on each commit.

@ZeusMarti: in your 1st version, you showed a validation, mainly focused on quadrupoles (which were right). Maybe you could you check that this is still ok ?

ZeusMarti commented 3 months ago

Results look OK for me,

matlab_atavedata_test_errors_alba2

ZeusMarti commented 3 months ago

I compared the result with a numerical average slicing the elements, it gives errors at the 0.05% with up to 800 slices for each element. I haven't tried slicing further bit it seems to monotonically improve. matlab_atavedata_test_diff

lfarv commented 3 months ago

Hi @ZeusMarti: this looks nice. It it's OK for you, can you approve the PR? Hoping it's the end of a long story! By the way, you plots are very nice.