ocelot.cpbd.match

Module Contents

Functions

weights_default(val)

match(lat, constr, vars, tw, verbose=True, max_iter=1000, method='simplex', weights=weights_default, vary_bend_angle=False, min_i5=False)

Function to match twiss parameters

weights_default(val)

match_beam(lat, constr, vars, p_array, navi, verbose=True, max_iter=1000, method='simplex', weights=weights_default, vary_bend_angle=False, min_i5=False)

Function to match twiss paramters

match_matrix(lat, beam, varz, target_matrix)

match_tunes(lat, tw0, quads, nu_x, nu_y, ncells=1, print_proc=0)

closed_orbit(lattice, eps_xy=1e-07, eps_angle=1e-07, energy=0)

ocelot.cpbd.match.weights_default(val)
ocelot.cpbd.match.match(lat, constr, vars, tw, verbose=True, max_iter=1000, method='simplex', weights=weights_default, vary_bend_angle=False, min_i5=False)

Function to match twiss parameters

Parameters
  • lat – MagneticLattice

  • constr

    dictionary, constrains. Example: ‘periodic’:True - means the “match” function tries to find periodic solution at the ends of lattice:

    constr = {elem1:{‘beta_x’:15, ‘beta_y’:2}, ‘periodic’:True}

    ”hard” constrains on the end of elements (elem1, elem2):

    constr = {elem1:{‘alpha_x’:5, ‘beta_y’:5}, elem2:{‘Dx’:0 ‘Dyp’:0, ‘alpha_x’:5, ‘beta_y’:5}}

    or mixture of “soft” and hard constrains:

    constr = {elem1:{‘alpha_x’:[“>”, 5], ‘beta_y’:5}, elem2:{‘Dx’:0 ‘Dyp’:0, ‘alpha_x’:5, ‘beta_y’:[“>”, 5]}}

    in case one needs global control on beta function, the constrains can be written following way.

    constr = {elem1:{‘alpha_x’:5, ‘beta_y’:5}, ‘global’: {‘beta_x’: [‘>’, 10]}}

  • vars – list of elements e.g. vars = [QF, QD] or it can be initial twiss parameters: vars = [[tws0, ‘beta_x’], [tws0, ‘beta_y’], [tws0, ‘alpha_x’], [tws0, ‘alpha_y’]]

  • tw – initial Twiss

  • verbose – allow print output of minimization procedure

  • max_iter

  • method – string, available ‘simplex’, ‘cg’, ‘bfgs’

  • weights

    function returns weights, for example def weights_default(val):

    if val == ‘periodic’: return 10000001.0 if val == ‘total_len’: return 10000001.0 if val in [‘Dx’, ‘Dy’, ‘Dxp’, ‘Dyp’]: return 10000002.0 if val in [‘alpha_x’, ‘alpha_y’]: return 100007.0 if val in [‘mux’, ‘muy’]: return 10000006.0 if val in [‘beta_x’, ‘beta_y’]: return 100007.0 return 0.0001

  • vary_bend_angle – False, allow to vary “angle” of the dipoles instead of the focusing strength “k1”

  • min_i5 – minimization of the radiation integral I5. Can be useful for storage rings.

Returns

result

ocelot.cpbd.match.weights_default(val)
ocelot.cpbd.match.match_beam(lat, constr, vars, p_array, navi, verbose=True, max_iter=1000, method='simplex', weights=weights_default, vary_bend_angle=False, min_i5=False)

Function to match twiss paramters

Parameters
  • lat – MagneticLattice

  • constr – dict in format {elem1:{‘beta_x’:15, ‘beta_y’:2}, ‘periodic’:True} try to find periodic solution or constr = {elem1:{‘alpha_x’:5, ‘beta_y’:5}, elem2:{‘Dx’:0 ‘Dyp’:0, ‘alpha_x’:5, ‘beta_y’:5} and so on.

  • vars – lsit of elements e.g. vars = [QF, QD]

  • p_array – initial ParticleArray

  • navi – Navigator with added PhysProcess if needed

  • verbose – allow print output of minimization procedure

  • max_iter

  • method – string, available ‘simplex’, ‘cg’, ‘bfgs’

  • weights

    function returns weights, for example def weights_default(val):

    if val == ‘periodic’: return 10000001.0 if val == ‘total_len’: return 10000001.0 if val in [‘Dx’, ‘Dy’, ‘Dxp’, ‘Dyp’]: return 10000002.0 if val in [‘alpha_x’, ‘alpha_y’]: return 100007.0 if val in [‘mux’, ‘muy’]: return 10000006.0 if val in [‘beta_x’, ‘beta_y’]: return 100007.0 return 0.0001

  • vary_bend_angle – False, allow to vary “angle” of the dipoles instead of the focusing strength “k1”

  • min_i5 – minimization of the radiation integral I5. Can be useful for storage rings.

Returns

result

ocelot.cpbd.match.match_matrix(lat, beam, varz, target_matrix)
ocelot.cpbd.match.match_tunes(lat, tw0, quads, nu_x, nu_y, ncells=1, print_proc=0)
ocelot.cpbd.match.closed_orbit(lattice, eps_xy=1e-07, eps_angle=1e-07, energy=0)