Core¶
The primary module for Pynac.
-
class
Pynac.Core.PhaseSpace(data_str_matrix)[source]¶ Bases:
objectA representation of the phase space of the simulated bunch read from the
dynac.shortfile. Each of the phase space parameters is represented as aelements.Parameternamedtuple.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:
objectThe 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.
-
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.
-
-
Pynac.Core.do_single_dynac_process(num, filelist, pynac_func)[source]¶ Execute
pynac_funcin thepynac_in_sub_directorycontext manager. See the docstring for that context manager to understand the meaning of thenumandfilelistinputs.The primary purpose of this function is to enable multiprocess use of Pynac via the
multi_process_pynacfunction.
-
Pynac.Core.get_number_of_particles()[source]¶ Queries the
dynac.shortfile for the number of particles used in the simulation.
-
Pynac.Core.make_phase_space_list()[source]¶ Extract all the phase space information (due to
EMITcommands 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.futuresmodule to executenum_itersnumber of instances ofpynac_func. This function takes advantage ofdo_single_dynac_processandpynac_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_listto 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
numinput, 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_pynacfunction.