Pals-cpp is a parser library for PALS accelerator lattice files.
It uses rapidyaml https://github.com/biojppm/rapidyaml to read lattices into memory and provides
additional capabilities like printing to console, writing to files, and searching for elements.
One major component is performing lattice expansion following the PALS specifications.
The lattice to be expanded can be specified by the user as an argument to the parse_and_expand_PALS
function. If none is specified, the lattice is chosen using the prescription given by PALS.
First, to build, run the following in the root directory:
cmake -S . -B build
cmake --build buildThis builds libyaml_c_wrapper.dylib, a shared object library that can interface with other languages. Make sure to rebuild after making any changes to files, and before running tests. All lattice files should go in lattice_files/.
examples/example_rw.cpp contains examples for how to use the library API to read lattice files, perform basic manipulations (adding and removing elements, renaming, etc.), print to console, and write the lattice back to a file. The example uses ex.pals.yaml and writes to expand.pals.yaml. To see the consle output, navigate to the build directory and run
./example_rwThe program examples/print_lattices performs lattice expansion on a user-specified lattice. The first argument is the file name where the lattice is defined. It also takes an option argument using -lat root_lattice to specify a specific lattice to expand, otherwise it will choose a default (the lattice in the last use statement, or the last lattice in the file if none is present). The program will create and print a struct containing the lattice views:
originalis a map containing the base lattice as well as any file it reaches byincludeorload.combinedis the base lattice but with all included files substituted in and all loaded files merged in.expandedis the base lattice after lattice expansion has been performed, holding the parameters the author wrote and nothing derived from them. Values are the finished ones, so a parameter in both trees has the same value in both.full_expandedis the same lattice with every dependent parameter computed: reference parameters, floor placement, s-positions, and the derived members of each parameter family. To see the console output, in the build directory, run
./print_lattices ex.pals.yaml -lat lat2The PALSJulia.jl package is an extension of pals-cpp to:
- Provide a Julia interface for
pals-cppC++ functions. - Provide a translator from
PALSfiles toBmadlattice files. - Provide a translator from
PALSfiles toSciBmadlattice files.
The full documentation — the user guide, the five-tree model, the expression evaluation rules, and the generated C API reference — is at https://pals-project.github.io/pals-cpp/.
Notes for working on the library itself (source layout, memory model, running the tests, building the docs) are on the Working on pals-cpp page.