Skip to content

Simple Bmad lattice

David Sagan edited this page Aug 30, 2017 · 15 revisions

Setup

The following is a very simple Bmad lattice:

beginning[beta_a] = 10.   ! m  a-mode beta function
beginning[beta_b] = 10.   ! m  b-mode beta function
beginning[e_tot] = 10e6   ! eV   Or can set p0c

parameter[geometry] = open      ! or closed
parameter[particle] = electron  ! Default is positron

d: drift, L = 0.5
b: sbend, L = 0.5, g = 1    ! g = 1 / bending_radius
q: quadrupole, L = 0.6, k1 = 0.23

lat: line = (d, b, q)   ! List of lattice elements
use, lat                ! Line used to construct the lattice

Using the above as content, create a file 'lat.bmad' and run tao on the command line:

 > tao -lat lat.bmad

A plot window should be created looking like:

Notes:

  • Use the -no_plot option when starting Tao to avoid creating a plot window.
  • Use the -geometry option to get a smaller plot window. Example: -geom 400x500
  • Bmad lattice file syntax is generally case insensitive (file names are an exception).
  • Tao commands are case sensitive.
  • Multiple lines may be specified. And lines may contain sublines.
  • The line used to construct the lattice is determined by the use statement.

To get a list of Tao commands

Tao> help

Type 'help <command>' for help on an individual command
Available commands:
  alias                             read
  call                              restore
  change                            reinitialize
  clip                              run_optimizer
  continue                          scale
  derivative                        set
  end_file                          show
  exit                              single_mode
  flatten                           spawn
... etc...

For instance:

Tao> help set
The "set" command is used to set values for data,
variables, etc. Format:
  set beam_init {n@}<component> = <value>
  set beam_start {n@}<coordinate> = <value>
  set bmad_com <component> = <value>
  set csr_param <component> = <value>
  set curve <curve> <component> = <value>
  set data <data_name>|<component> = <value>
  set default <parameter> = <value>
  set element <element_list> <attribute> = <value>
  set floor_plan <component> = <value>
  set geodesic_lm <component> = <value>
  set global <component> = <value>
  set graph <graph> <component> = <value>
  set key <key> = <command>
  set lat_layout <component> = <value>
  set lattice {n@}<destination_lat> = <source_lat>
  set opti_de_param <component> = <value>
  set plot <plot> <parameter> = <value>
  set plot_page <parameter> = <value1> {<value2>}
  set ran_state = <random_number_generator_state>
  set universe <what_universe> <on/off>
  set universe <what_universe> recalculate
  set universe <what_universe> mat6_recalc <on/off>
  set universe <what_universe> track_recalc <on/off>
  set variable <var_name>|<component> = <value>
  set wave <component> = <value>

Also see the "change" command . The "change" command is specialized
for varying real parameters while the "set" command is more general.

... etc...

Use the command:
  help set <what>
to obtain more information on a particular set subtopic. Example:
  help set plot

To show a list of elements in the lattice

Tao> show lat
      Values at End of Element:
 Index  name      key                       s       l    beta     phi    eta  orbit     beta     phi    eta  orbit    Track_State
                                                            a       a      a  x [mm]       b       b      b  y [mm]
     0  BEGINNING Beginning_Ele         0.000     ---   10.00   0.000   0.00   0.000   10.00   0.000   0.00   0.000   Alive
     1  D         Drift                 0.500   0.500   10.03   0.050   0.00   0.000   10.03   0.050   0.00   0.000   Alive
     2  B         Sbend                 1.000   0.500    7.87   0.104   0.12   0.000   10.00   0.100   0.00   0.000   Alive
     3  Q         Quadrupole            1.600   0.600    3.50   0.217   0.40   0.000   10.64   0.159   0.00   0.000   Alive
     4  END       Marker                1.600   0.000    3.50   0.217   0.40   0.000   10.64   0.159   0.00   0.000   Alive
 Index  name      key                       s       l    beta     phi    eta  orbit     beta     phi    eta  orbit    Track_State
                                                            a       a      a  x [mm]       b       b      b  y [mm]
      Values at End of Element:

Bmad adds two extra elements to the lattice. A zero length beginning element called BEGINNING and a zero length marker element at the end called END.

Note: "show lat" (like many other commands) has lots of optional parameters to customize the table of information printed.

Tao> help show lat
Syntax:
  show lattice {-0undef} {-all} {-attribute <attrib>} {-base}
      {-blank_replacement <string>}  {-branch <name_or_index>}
      {-custom <file_name>} {-design} {-floor_coords} {-lords} {-middle}
      {-no_label_lines} {-no_tail_lines} {-no_slaves} {-orbit} {-radiation_integrals}
      {-remove_line_if_zero <column #>} {-s <s1>:<s2>} {-tracking_elements}
      {<element_list>}

Show a table of Twiss and orbit data, etc. at the specified element locations. The default
is to show the parameters at the exit end of the elements. To show the parameters in the
... etc...

To Show the Parameters of a Lattice Element

Tao> show ele b   ! or: show ele 2
 Element #                2
 Element Name: B
 Key: Sbend
 Sub Key: SBend
 S_start, S:    0.500000,    1.000000
 Ref_time:  3.340005E-09

 Attribute values [Only non-zero/non-default values shown]:
    1   L                            =  5.0000000E-01 m
    6   G                            =  1.0000000E+00 1/m
    8   RHO                          =  1.0000000E+00 m
   13   SPIN_FRINGE_ON               =  T (1)
   19   E1                           =  0.0000000E+00 rad
   20   E2                           =  0.0000000E+00 rad
   29   L_SAGITTA                    =  3.1087578E-02 m
		 ... etc...

Twiss at end of element:
                          A              B            Cbar                        C_mat
  Beta (m)         7.87064432     9.99974729  |   0.00000000   0.00000000      0.00000000   0.00000000
  Alpha            3.93634109     0.20027369  |   0.00000000   0.00000000      0.00000000   0.00000000
  Gamma (1/m)      2.09573455     0.10401358  |   Gamma_c =   1.00000000       Mode_Flip = F
  Phi (rad)        0.10395730     0.09991742            X              Y              Z
  Eta (m)          0.12241744     0.00000000     0.12241744     0.00000000    -0.01796326
  Etap             0.48187421     0.00000000     0.48187421     0.00000000     0.00000000

Orbit:  Positron   State: Alive
         Position[mm] Momentum[mrad]        Spin   |
  X:       0.00000000     0.00000000               | Particle [sec]:      3.34000451E-09  E_tot;  1.0000E+07
  Y:       0.00000000     0.00000000               | Part-Ref [sec]:      0.00000000E+00  PC:     9.9869E+06
  Z:       0.00000000     0.00000000               | (Ref-Part)*Vel [m]:  0.00000000E+00  Beta:    0.998694

Note: By default, only non-zero attributes are shown. Use the -all option to see all the attributes.


To Show a List of Elements Using Wild Cards

Show all elements whose name begins with "Q":

Tao> show ele q*
         1  Q                                                1.000
Number of Matches: 1

Show all sbend elements:

Tao> show ele sbend::*
         2  B                                                2.000
Number of Matches: 1

General syntax:

	show ele <element_type>::<name_with_wild_card_characters>

Wild card characters are

  • "*" -- Matches to any number of characters.
  • "%" -- Matches to any single character.