:mod:`ocelot.cpbd.match` ======================== .. py:module:: ocelot.cpbd.match Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: ocelot.cpbd.match.weights_default ocelot.cpbd.match.match ocelot.cpbd.match.weights_default ocelot.cpbd.match.match_beam ocelot.cpbd.match.match_matrix ocelot.cpbd.match.match_tunes ocelot.cpbd.match.closed_orbit .. function:: weights_default(val) .. function:: 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 :param lat: MagneticLattice :param 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]}} :param 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']] :param tw: initial Twiss :param verbose: allow print output of minimization procedure :param max_iter: :param method: string, available 'simplex', 'cg', 'bfgs' :param 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 :param vary_bend_angle: False, allow to vary "angle" of the dipoles instead of the focusing strength "k1" :param min_i5: minimization of the radiation integral I5. Can be useful for storage rings. :return: result .. function:: weights_default(val) .. function:: 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 :param lat: MagneticLattice :param 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. :param vars: lsit of elements e.g. vars = [QF, QD] :param p_array: initial ParticleArray :param navi: Navigator with added PhysProcess if needed :param verbose: allow print output of minimization procedure :param max_iter: :param method: string, available 'simplex', 'cg', 'bfgs' :param 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 :param vary_bend_angle: False, allow to vary "angle" of the dipoles instead of the focusing strength "k1" :param min_i5: minimization of the radiation integral I5. Can be useful for storage rings. :return: result .. function:: match_matrix(lat, beam, varz, target_matrix) .. function:: match_tunes(lat, tw0, quads, nu_x, nu_y, ncells=1, print_proc=0) .. function:: closed_orbit(lattice, eps_xy=1e-07, eps_angle=1e-07, energy=0)