Skip to content
Snippets Groups Projects

Turn off quantum excitation

Merged Teresia Olsson requested to merge turn-off-qexec into develop

Add option to turn off the quantum excitation. For example useful when want to run with a single particle per bunch.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Teresia Olsson requested review from @GAMELIN

    requested review from @GAMELIN

  • Teresia Olsson added 3 commits

    added 3 commits

    • 4c53c299 - Fix of bin length calculation with 1 slice for MPI and init_phasor.
    • fb7f3fc2 - Merge branch 'use-one-bin' into turn-off-qexec
    • 2fc549f0 - Add way to handle if bin_min == bin_max.

    Compare with previous version

  • Teresia Olsson marked this merge request as draft

    marked this merge request as draft

  • Are we sure that, in this case, everything will work as it should? The amplitude of the particle will decay exponentially forever. This is not the physical reality. What I think should be done instead is to provide an option to specify necessary sigmas if the bunch object cannot compute them. What do you two think?

    Update: I've even checked that the class does not use the Bunch object to compute the sigmas; only the ring object is used, which should work for a single macroparticle, too. So, in my view, there's no need to make any modifications.

    Edited by GUBAIDULIN
  • @GUBAIDULIN I'm not entirely sure I understood what you meant? The user case for this is if you want to run a simulation where you only have a single particle per bunch. In this case I think no sigma should be calculated because the result wouldn't make sense. And the centroids will eventually damp to the equilibrium orbit. At least that's how it worked in the old mbtrack where I tried this before. If I remember correctly that code just didn't output any sigma results when you had a single particle. It doesn't give the correct result for very non-gaussian bunches, but I found it quite useful for studying things like the RF feedback where you might want to run quick simulations trying different parameters and don't care about the sigmas.

    One problem I ran into is that init_beam automatically generates a Gaussian beam so the particle started with some random values. I however avoided that by using the feature where you can build a beam from a list of Bunch objects. Then I could specify that every particle should start at zero. That worked nicely :)

  • I just commented on your use case of turning quantum excitation. My point was that the quantum excitation effect still exists for a single particle. So, there's no need to turn it off when a beam consists of a single particle. SynchrotronRadiation() works for a single particle in a bunch in the current implementation (I've just tried it now, and I think it works correctly). The mbtrack2 SynchrotronRadiation() class only uses equilibrium std parameters defined in the ring object. It never computes std values of a single bunch. Of course, the option to switch off quantum excitation or synchrotron radiation can still be useful. But physically, I think both effects are always present.

    For example, with the code below (if you replace v2366 by your own mbtrack2 Synchrotron() object) you should be able to have radiation effects with a single particle in a bunch.

    def run_mbtrack2(
        n_turns=100_000,
        n_macroparticles=2000,
        bunch_current=1.2e-3,
    ):
        ring = v2366(IDs="open")
        # ring.emit[1] = ring.emit[0]*0.3
        particle = Electron()
        mybunch = Bunch(
            ring, mp_number=n_macroparticles, current=bunch_current, track_alive=False
        )
        np.random.seed(42)
        mybunch.init_gaussian()
        mybunch['tau'][:] = 7e-10
        mybunch['delta'][:] = ring.sigma_delta
        long_map = LongitudinalMap(ring)
        sr = SynchrotronRadiation(ring, switch=[1, 1, 1])
        trans_map = TransverseMap(ring)
        V_rf  = 1.7e6
        rf = RFCavity(ring, m=1, Vc=V_rf, theta=np.arccos(ring.U0 / V_rf))
        bunch_monitor = PhaseSpaceMonitor(0, sample_number=1, save_every=1, buffer_size=n_turns, total_size=n_turns, file_name='test_monitor')
        tracking_elements = [trans_map, long_map, rf, bunch_monitor, sr]
        white_noise = 2e-8
        try:
            for i in tqdm(range(n_turns)):
                for el in tracking_elements:
                    el.track(mybunch)
        finally:
            bunch_monitor.close()
        return None

    This code still worked with a single particle, and I can see the damping, for example, in the picture below, where a "tau" of a single particle is shown.

    image

    Edited by GUBAIDULIN
  • Ah, okay. I understand. You are referring to the part where the SynchrotronRadiation object is created and which values it gets. That I also thinks works correctly independently of the number of particles. The reason why I want to turn the quantum excitation off is to explicitly be able to exclude that effect when tracking. Similar to the SREFFECTS element in Elegant where you in addition to the quantum excitation can turn off the damping and average energy loss if you want by just changing a flag.

    https://ops.aps.anl.gov/manuals/elegant_latest/elegantsu217.html#x228-23300010.107

    If I turn the quantum excitation off, I can use a single particle per bunch to represent the centroid of the bunch. The results will be approximate since the simulation doesn't correctly include the effect of the bunch profile, but it's useful for example to quickly be able to study transient beam loading. If I include the quantum excitation, the particles will still damp down but the final transient will look very noisy since it's like the "centroid" gets a small kick every turn.

  • All clear!

  • Alexis GAMELIN mentioned in merge request !19 (closed)

    mentioned in merge request !19 (closed)

  • Hi @TeresiaOlsson,

    This can be considered again now that !21 (merged) has been completed.

    I've closed !19 (closed) as these changes have already been included in !21 (merged).

    I think you should rebase the change on the current (merged) develop branch so only the QE stuff is in this MR.

  • Alexis GAMELIN added 11 commits

    added 11 commits

    Compare with previous version

  • added 1 commit

    • 8e885d2f - Revert changes to rf.py and parallel.py

    Compare with previous version

  • added 1 commit

    • 02eb28a5 - Small changes to SynchrotronRadiation

    Compare with previous version

  • Alexis GAMELIN marked this merge request as ready

    marked this merge request as ready

  • Alexis GAMELIN enabled an automatic merge when all merge checks for 02eb28a5 pass

    enabled an automatic merge when all merge checks for 02eb28a5 pass

  • Alexis GAMELIN approved this merge request

    approved this merge request

  • Alexis GAMELIN mentioned in commit bb41cdf8

    mentioned in commit bb41cdf8

Please register or sign in to reply
Loading