Core

The main module for Pynac.

Pynac.Core.DynacFromEle(ele)[source]
Pynac.Core.EleFromPynac(pynacRepr)[source]
class Pynac.Core.PhaseSpace(dataStrMatrix)[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]
getNumPlots()[source]

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

getPlotInds()[source]

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

getXinds(*X)[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.

setNewRDBEAMfile(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.buildABeam()[source]
Pynac.Core.doSingleDynacProcess(num, filelist, pynacFunc)[source]

Execute pynacFunc in the pynacInSubDirectory 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 multiProcessPynac function.

Pynac.Core.getNumberOfParticles()[source]

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

Pynac.Core.makePhaseSpaceList()[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.multiProcessPynac(filelist, pynacFunc, numIters=100, max_workers=8)[source]

Use a ProcessPool from the concurrent.futures module to execute numIters number of instances of pynacFunc. This function takes advantage of doSingleDynacProcess and pynacInSubDirectory.

Pynac.Core.pynacInSubDirectory(num, filelist)[source]

A context manager to create a new directory, move the files listed in filelist 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 multiProcessPynac function.