Core

The primary module for Pynac.

class Pynac.Core.Builder[source]

Bases: object

build_a_beam()[source]
run_simulation()[source]
class Pynac.Core.PhaseSpace(data_str_matrix)[source]

Bases: object

A representation of the phase space of the simulated bunch read from the dynac.short file. Each of the phase space parameters is represented as a elements.Parameter namedtuple.

This class is intended to be used in interactive explorations of the data produced during Pynac simulations.

class Pynac.Core.Pynac(filename=None)[source]

Bases: object

The primary entry point for performing simulations. Objects of this class contain all the necessary information to perform a Dynac simulation, as well as methods to manipulate the lattice, and to make the call to Dynac.

classmethod from_lattice(name, lattice)[source]
get_num_plots()[source]

Return the number of Dynac plots that will be output when Dynac is run.

get_plot_inds()[source]

Return the indices into the lattice list attribute of elements that result in Dynac plot output.

get_x_inds(*dynac_type)[source]

Return the indices into the lattice list attribute of elements whose Dynac type matches the input string. Multiple input strings can be given, either as a comma-separated list or as a genuine Python list.

get_x_objs(*dynac_type)[source]

Return the indices into the lattice list attribute of elements whose Dynac type matches the input string. Multiple input strings can be given, either as a comma-separated list or as a genuine Python list.

run()[source]

Run the simulation in the current directory.

set_new_rdbeam_file(filename)[source]

Change the current RDBEAM command to point at another Dynac input file. This will raise an IndexError if the lattice doesn’t contain an RDBEAM command.

Pynac.Core.do_single_dynac_process(num, filelist, pynac_func)[source]

Execute pynac_func in the pynac_in_sub_directory context manager. See the docstring for that context manager to understand the meaning of the num and filelist inputs.

The primary purpose of this function is to enable multiprocess use of Pynac via the multi_process_pynac function.

Pynac.Core.dynac_from_ele(ele)[source]
Pynac.Core.ele_from_pynac(pynac_repr)[source]
Pynac.Core.get_number_of_particles()[source]

Queries the dynac.short file for the number of particles used in the simulation.

Pynac.Core.make_phase_space_list()[source]

Extract all the phase space information (due to EMIT commands in the input file), and create a list of PhaseSpace objects. The primary purpose of this is for interactive explorations of the data produced during Pynac simulations.

Pynac.Core.multi_process_pynac(file_list, pynac_func, num_iters=100, max_workers=8)[source]

Use a ProcessPool from the concurrent.futures module to execute num_iters number of instances of pynac_func. This function takes advantage of do_single_dynac_process and pynac_in_sub_directory.

Pynac.Core.pynac_in_sub_directory(num, file_list)[source]

A context manager to create a new directory, move the files listed in file_list to that directory, and change to that directory before handing control back to context. The closing action is to change back to the original directory.

The directory name is based on the num input, and if it already exists, it will be deleted upon entering the context.

The primary purpose of this function is to enable multiprocess use of Pynac via the multi_process_pynac function.