ocelot
ocelot copied to clipboard
Import Lattice from other simulator? (ex: elegant)
Hi, I was working with the elegant
simulator and I heard about ocelot
from ICFA ML meeting.
I was accustomed to python, so I want to migrate some lattice from elegant
. But, lattice file of elegant
, which is format of *.LTE
is about ~4000 line and it is almost impossible to move this by hand.
Is there any support function for converting lattice from elegant
to ocelot
?
Hi, yes. Ocelot
has possibilities to convert elegant
*.lte file to ocelot lattice file or to python variable with lattice directly.
Here is a small example how to do it.
from ocelot import *
from ocelot.adaptors.elegant_lattice_converter import *
SC = ElegantLatticeConverter()
read_cell = SC.elegant2ocelot('elegant_lattice.lte')
lattice = MagneticLattice(read_cell)
write_lattice(lattice, remove_rep_drifts=False)
After launching this script, you in will have ocelot lattice file.
Note that not all elegant's elements conversion is yet implemented. If you will need any assistance let me know. Also if you will need, I can extend conversion possibilities.
I run the script and get these kinds of result
WARNING! Unknown element CHARGE with type CHARGE was skiped
WARNING! Unknown element MALIN with type MALIGN was skiped
WARNING! Unknown element INJEND with type WATCH was skiped
WARNING! Unknown element L0_END with type WATCH was skiped
WARNING! Unknown element D_QEND0 with type CSRDRIFT was changed by Drift
....
And I summarize the issue like below.
-
Issue
-
define
charge
-
define
malign
: actually, orgianl lattice doesn't give any value for this -
WATCH
andMARKER
- From the module
ocelot.adaptors.elegant2ocelot.py
,WATCH
is corresponds toMARK
. -
ocelot.adaptors.elegant_lattice_convertor
doesn't defineWATCH
. - Is there any difference?
- From the module
-
define beam
-
In the elegant
ele
file, I load beam -
&sdds_beam input = 200G_3p_10m_02460_004_1260.sdds, input_type = "elegant", n_particles_per_ring = 1, reuse_bunch = 1, one_random_bunch = 0, &end
-
beam sdds have below properties
-
SDDS1 &description text="200G_3p_10m_02460_004.sdds", &end &column name=ID, description="particle index", format_string=%6ld, type=long, &end &column name=x, symbol=x, units=m, description="horizontal position", format_string=%14.7e, type=double, &end &column name=xp, symbol=x', description="horizontal slope", format_string=%14.7e, type=double, &end &column name=y, symbol=y, units=m, description="vertical position", format_string=%14.7e, type=double, &end &column name=yp, symbol=y', description="vertical slope", format_string=%14.7e, type=double, &end &column name=t, symbol=t, units=s, description="time", format_string=%14.7e, type=double, &end &column name=p, symbol=p, units=m$be$nc, description="momentum", format_string=%14.7e, type=double, &end
-
Do I have to make particle array, like the case of
astraBeam2particleArray
?
-
-
Cavity properties
-
origianl lattice for cavity contain these properties
LL_BAND2_3_9 : RFCW, FREQ= 2.856000000E+09,L= 3.003304E+00, & VOLT=" 57062776 1.00 /", & PHASE="-21.90 90 +", & CHANGE_P0=1,END1_FOCUS=1,END2_FOCUS=1,CELL_LENGTH=0.03500, & ZWAKEFILE="Sz_5um_10mm.sdds", & TRWAKEFILE="Sx_5um_10mm.sdds", & TCOLUMN="t",WXCOLUMN="W",WYCOLUMN="W",WZCOLUMN="W", & DX=0.000000, DY=0.000000, & INTERPOLATE=1,N_KICKS=20, SMOOTHING=1
-
For adjusting wake, do I have to make
WakeTable
from my wakefile, which is written like below?SDDS1 &column name=z, units=m, type=double, &end &column name=W, units=V/C/m, type=double, &end &column name=t, units=s, type=double, &end
-
How can I apply Kick for RFCW?
-
-
CSRDRIFT
- In ocelot,
CSRDRIFT
are converted intoDRIFT
- Then, for applying CSR effect, do I have to follow step of Tutorial N5?
- In ocelot,
-
Since I am relatively new to accelerator, I would be grateful if I can get some help on this issue. Thank you.
Hi,
- ocelot.adaptors.elegant2ocelot.py is an old solution to convert elegant to ocelot lattice file. Now we maintain and develop ocelot.adaptors.elegant_lattice_convertor as the main adapter (@yefomin Evgeniy develops it).
- Watch element was added today to the adaptor to the dev branch.
- CSRDRIFT
- yes, tutorial N5 should help you with CSR
- Beam file
- we have also some possibility to convert elegant beam file to ocelot format and an example will be posted later.
- regarding wakefields, it is a bit more complicated. We did not work with wakefields in elegant format so we have to investigate it.
Warning messages look OK. They tell you what elements are not converted one to one.
I added WATCH
to MARK
conversion possibility. Updated module ocelot.adaptors.elegant_lattice_convertor
will be available in the dev
branch in a few days.
According to the difference between modules ocelot.adaptors.elegant_lattice_convertor
and ocelot.adaptors.elegant2ocelot.py
the first one is a new version and allows you to convert lattice from Elegant to Ocelot and vice versa.
Note that after automatic lattice conversion you have to manually check the conversion results that all features of the lattice are correctly converted. Because of the lattice definition for Elegant and Ocelot is completely different.
charge
, malign
and beam distribution
you should define separately in Ocelot format in your python script.
To automatic convert the beam sdds file to Ocelot format you can convert sdds file to Astra format using the following Elegant command elegant2astra [inputFile] [outputFile]
and after that read Astra file in Ocelot using Ocelot module astraBeam2particleArray
.
How to take into account CSR and Wakes you can find into Tutorials 4 and 5. For additional assistance let us know. We will try to help you.