ocelot-collab / ocelot

OCELOT is a multiphysics simulation toolkit designed for studying FEL and storage ring-based light sources.
GNU General Public License v3.0
84 stars 58 forks source link

Including space charge effect #190

Closed alexanatoly closed 10 months ago

alexanatoly commented 1 year ago

Hi, I would like to include space charge effect in the tracking simulation.

Please, could you help me to understand how I can do it ?

I followed the example give at : https://github.com/ocelot-collab/ocelot/blob/master/demos/ebeam/space_charge.py. but could not understand how the space charge effect is implemented.

I am using a small example file generated by ASTRA code and loading it in Ocelot.

Any help will be greatly appreciated.

Thanks. Alex

alexanatoly commented 1 year ago

Hi, I included the following lines for Space-Charge effect

sc1 = SpaceCharge() sc1.nmesh_xyz = [63, 63, 63] sc1.step = 1 navi = Navigator(lat) navi.add_physics_proc(sc1, lat.sequence[0], lat.sequency[-1])

Is the above is correct ?

Also, how to decided the mesh size ... why 63 ?

Thanks, Alex

sergey-tomin commented 11 months ago

Hi, if you want to apply Space Charge (SC) to the whole lattice, it looks okay. However, you need to determine how frequently you should apply SC to achieve the best accuracy. This is specified in the 'Navigator' class, where the default Navigator.unit_step is 1 m. If the beam energy is low (5-50 MeV), I would recommend using 0.01 m or even lower in some cases. Also, please remember that we can achieve good agreement with ASTRA for beam energies of 5 MeV and higher. If the beam has lower energy, I would recommend using ASTRA. If the beam is accelerated, you can use two or more SC objects. For example, for low energy, you can set sc1.step = 1 (SC will apply with step navi.unit_step * sc1.step m), and then for accelerator sections with high energy, you can set sc2.step = 5 or a similar value, and continue in this manner. It will speed up calculations without a lost of accuracy.

alexanatoly commented 10 months ago

Hi @sergey-tomin, thanks for explaining in detail. Somehow I missed your reply (sorry for it). My electron beam energy range is (10 MeV < energy < 1000 MeV). By the way, I must say that you have developed and made available to everyone a very nice beam dynamics code.