CHANGELOG
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[0.16.2] – 2026-04-13
Fixed
Bad conflict resolution in
AcceleratorFactory.
[0.16.1] – 2026-04-13
Added
New
OptimisationAlgorithm:PredefinedSolution. It is automatically created when theAcceleratoris unpickled and uses the storedSimulationOutputto fake the optimization process.New
OptimisationAlgorithm: NSGA-III, adapted to high-dimensionality problems.New
ObjectivesFactory:RemainBelow. Sets an upper limit for a variable.Refactored creation of
DesignSpaceFactory. Opens way to manual definition of variables/constraints inTOML, rather than usingdesign_space_preset = abs_phase_amplitudeordesign_space_preset = RelPhaseAmplitudeWithConstrainedSyncPhase.[x] Choose
design_space_preset = UserDefined[x] Set
variable_names = ['k_e', 'phi_0_abs] (for example)[x] Set
constraint_names = ['phi_s'](for example)[ ] Ensure that order of variables is not hard-coded somewhere.
[ ] Find an intuitive way to set limits for the different variables and constraints.
Fixed
Synchronous phases can be used as constraints again.
Synchronous phases in constraints calculations was taken from
SimulationOutput.elts(nominal settings) instead ofSimulationOutput.set_of_cavity_settings. This bug was nasty. Fixing it dramatically improved constrained optimization.
Information message when creating
ListOfElementssubset printed wrong end of linac subset.
[0.16.0] – 2026-03-04
Added
The key
pickle_pathsin the[files]section of theTOMLconfiguration file allows you to control pickling ofAccelerators.If a given
PKLfile exists, it is unpickled and associated calculations are skipped.If it does not exist, corresponding
Acceleratoris pickled at the end of the simulation.Configuration file example:
[files.pickle_paths] Reference = "reference.pkl" # Scenario 1: pre-computed solution (skips optimization if file exists) [files.pickle_paths.000001] Solution = "solution-000001.pkl" # Scenario 2: alternatives with custom names (optimization still runs, the # pickled Accelerators will be appended) [files.pickle_paths.000002] "Conservative approach" = "design-conservative.pkl" "Aggressive tuning" = "design-aggressive.pkl" # Scenario 3: solution + alternatives [files.pickle_paths.000003] Solution = "solution-000003.pkl" "Tweaked design" = "tweaked.pkl" "Experimental config" = "experimental.pkl"
Changed
AcceleratorFactoryproduces adict[int, list[Accelerator]instead of a plainlist[Accelerator]. Keys areFaultScenarioindex, values correspondingAccelerators – including unpickledAccelerators for comparison. Nothing should change for you if you use the functions from theui.workflow_setupmodule.plot.factoryis more robust, and allows plotting any number ofAccelerators. Use theonly_solver_idkey to filter byBeamCalculator.
[0.15.2] – 2026-03-04
Added
Build on Python 3.14.
Fixed
Build on
manylinux.
[0.15.1] – 2026-03-03
Changed
AcceleratorFactoryproduces adict[int, list[Accelerator]instead of a plainlist[Accelerator]. Keys areFaultScenarioindex, values correspondingAccelerators – including unpickledAccelerators for comparison. Nothing should change for you if you use the functions from theui.workflow_setupmodule.plot.factoryis more robust, and allows plotting any number ofAccelerators. Use theonly_solver_idkey to filter byBeamCalculator.
0.15.1 – unreleased
Added
New
Objective:MinimizeVariationto minimize std of a quantity.Check the new
ObjectivesFactory:RegularEnvelopefor an example of usage.New
Accelerator.plotmethod for rapid plotting of stored data.
Changed
Accelerator.eltsmust now be called without the().
[0.15.0] – 2025-12-11
Added
In the
[wtf]section of theTOMLconfiguration file:id_naturecan be set to"lattice"or"section". The indexes listed infailedwill then be lattice or section index.index_offset = 1optional configuration key makes indexes infailedandcompensating_manualstart at1instead of0. With this option,failed = [[50]]means the 50th cavity/element, not the 51st.New entry
automatic_study. Two values allowed for now:"single cavity failures"and"cryomodule failures". All the cavities/cryomodules indicated infailedwill be failed one after another. Typical usage; this will run a systematic study of all single cavity failures in the second section.
automatic_study = "single cavity failures"
failed = [1]
id_nature = "section"
[!IMPORTANT] This new feature introduced a new dependency between
AcceleratorFactoryandFaultScenarioFactory. If you created yourAcceleratorandFaultScenarioyourself instead of using utility functions from theuimodule,automatic_studywill not be supported.
[0.14.1] – 2025-12-10
Changed
Deprecated numpy API in Cython is no longer used.
The
AcceleratorfactoriesNoFaultandWithFaultare deprecated. Prefer the general purposeAcceleratorFactory.
Fixed
The
k_bparameter ofFIELD_MAPwas not updated.We always keep it equal to
k_efor now.
[0.14.0] – 2025-12-04
Added
Explicit Cython optional dependency in
pyproject.toml.
Changed
Refactored the
RfFieldclass, which is now calledField.Opens up the way for DC and 3D fields support.
FIELD_MAP 7700is partially supported: motion is integrated on axis.
Massive speed-up w.r.t 0.13.5:
Envelope1Dis ~40% faster.CyEnvelope1Dis ~50% faster.Envelope3Dis ~25% faster. Note that it is not fully optimized.
[!IMPORTANT] If you encounter a “wrong number of attributes” error using
CyEnvelope1D, it means that Cython modules were not recompiled. Recompile the Cython modules following the classic instructions.
[0.13.5] – 2025-11-27
Changed
Modernized the
experimentalmodule:Plotter,SimulationOutputEvaluator. Write some tutorial before official functionality release.
Fixed
Cython solver was not used even if configuration asked for it.
[0.13.4] – 2025-11-26
Fixed
Release workflow on macos os 13 was not supported anymore.
[0.13.3] – 2025-11-25
Fixed
Removed
pymoodependencies andNSGAalgorithm to avoid build errors.
[0.13.2] – 2025-11-25
Fixed
Bad output path resolution due to a merge conflict.
[0.13.1] – 2025-11-25
Changed
export_phaseis now a mandatory configuration entry for beam calculators. Former default behavior is preserved: if this entry is not given, we set it to"as_in_cavity_settings".
Fixed
Field map phase is correctly exported in the
DATfiles.Ensured that the
default_valueof configuration entries are used.TraceWin compensation works again.
[0.13.0] – 2025-11-05
Added
SNS-like compensation method:
Activate it with
reference_phase_policy = "phi_s",strategy = "corrector at exit"and"objective_preset = "CorrectorAtExit".n_compensatingcavities around each failure are used to keep energy longitudinal shape “reasonable”.n_compensating = 0is currently not supported.
All downstream cavities are rephased to preserve longitudinal acceptance.
Final
n_correctorscavities accelerate the beam to retrieve nominal energy.
Deprecated
All the
Objectivesubclasses are now in thelightwin.optimisation.objective .objectivemodule. Old import paths still work but raise a warning when used. TheObjectivesubclasses are:MinimizeDifferenceWithRefMinimizeMismatchQuantityIsBetween
[0.12.1] – 2025-08-26
Changed
More consistent documentation of parameters type.
Fixed
cythontransfer matrices were not used
[0.12.0] – 2025-08-25
Added
The cavities reference phase is now determined by
reference_phase_policy.This is more permissive than
flag_phi_abs, that could only beTrueorFalse.Now, reference phase can be
phi_0_abs,phi_0_rel,phi_soras_in_dat_file!
Changed
The
CavitySettingsobject, and in particular its handling of phases and reference phases, is more robust.This update introduced significant changes: do not hesitate to file an issue if you encounter
MissingAttributeError, or any phase-related error.
Deprecated
Do not use the
TOMLflag_phi_absconfiguration entry anymore, preferreference_phase_policy.If
flag_phi_absis found, a deprecation warning is raised.For now,
flag_phi_absas precedence overreference_phase_policyto keep backward compatibility.
[0.11.4] – 2025-08-21
Added
New Sphinx directive to nicely display dictionaries.
Check example
Support for Bayesian Optimization
kwargs.
Fixed
Selection of
simulated_annealingwas in fact not possible.
[0.11.3] – 2025-08-20
Added
New optimization algorithms:
Simulated Annealing.
Bayesian Optimization.
[0.11.2] – 2025-08-20
Fixed
Dummy import error in test suite.
[0.11.1] – 2025-08-20
Changed
Tables listing configuration options are more consistent in the html documentation.
[0.11.0] – 2025-08-19
Added
Calculation of energy and phase acceptances (#5).
New
physicspackage holding helper physical functions (#6).New plot preset:
acceptance.Explicit error message when trying to plot some bugged quantities:
Transfer matrix components (TraceWin)
Phase acceptance (TraceWin)
Fixed
Objective position was plotted at the wrong place when the x-axis of plot was index of elements.
r_zdeltacomponents can begetand plotted usingtransfer_matrixplot preset.Symmetric plot (
envelope,acceptance) work as expected.
[0.10.6] – 2025-07-04
Added
Documentation for
setuptools_scmissues when downloading LightWin as an archive.
[0.10.5] – 2025-07-01
Fixed
Missing dependencies in linux Github Actions wheel builder.
[0.10.4] – 2025-07-01
Added
Introduced
BeamKwargstyping. Easier to know the values stored in this object.
[0.10.3] – 2025-06-30
Fixed
Bug introduced in the beam parameters test by 0.10.2.
[0.10.2] – 2025-06-30
Fixed
MinimizeDifferenceWithRefresiduals func now returns an always positive value.Does not make any difference with
OptimisationAlgorithmsuch asLeastSquareswhich take the squared residuals. May be a game changer for other algorithms.
Flag to handle
SimulationOutput.get(..., elt=elt)whenelt: Elementis not inSimulationOutput.elts.Fixed some errors at
Objectivecreation.
[0.10.1] – 2025-06-06
Fixed
Update of
CITATION.cff,CHANGELOG.md
[0.10.0] – 2025-06-06
Added
release.pyscript,CONTRIBUTING.mdto ease collaboration.
Changed
Accelerator.get,SimulationOutput.get,ListOfElements.getnow accept arguments found inFieldMap.e.g.:
ListOfElements.get("freq_cavity_mhz")is now valid.
[0.10.0rc0] – 2025-05-12
Changed
Refactored the
getmethods.It may introduce some bugs, do not hesitate to reach me out in case of problem.
Fixed
getrefactoring fixed several bugs:Some
getmethods such asSimulationOutput.getdid not consider thephase_space_namekeyword argument.getmethods behavior are more consistent.
[0.9.4] – 2025-05-06
Added
Wrote the documentation for the magic
getmethods.Added
getexamples in the example notebook.
[0.9.3] – 2025-04-09
Fixed
The
lightwin.config_managersymlink pointing tolightwin.config.config_managerdid not resolve on Windows. It was deleted and allimport lightwin.config_managerwere replaced byimport lightwin.config.config_manager.
Changed
import lightwin.config_managerno longer works! Replace all occurrences byimport lightwin.config.config_manager.
[0.9.2] – 2025-04-07
Added
Type hints for the
.getmethods.Notebook example to showcase how LightWin can be used.
You can give
matplotlib.axes.Axes.plotkwargs in theplotsTOML section.
[0.9.1] – 2025-01-30
Added
When tagging a version:
The package is built and tested on several platforms, before being released to PyPI.
CITATION.cffis automatically updated accordingly.
Package on
pip(simpler installation withpip install lightwin).
Changed
Data used for examples was moved from
data/example/tosrc/lightwin/data/ads/.It can now be imported for testing purposes.
See also: Including data files
[0.9.0] – 2025-01-21
Added
CI/CD tasks:
Automatic linting with
pre-commit.ci.Automatic checking of common mistakes with
pre-commit.ci.Run automatic tests using
pytestand GitHub workflows.
Badges to quickly see if something went wrong.
Changed
Introduced optional dependencies.
Install them with
pip install -e .[docs]orpip install -e .[test].It is recommended to install LightWin with the test optional dependencies.
[0.8.4] 2025-01-15
Changed
Tests now rely on the
pytest.approxfunctions, much cleaner than previous approach.
[0.8.3] 2025-01-13
Added
Version number and commit number are written in the log file.
Fixed
Properly handle opening/closing log files.
Display of some objective values.
[0.8.2] 2024-11-11
Added
Possibility to save optimization history. Check
[save_wtf]table indata/example/lightwin.toml.
[0.8.1] 2024-11-11
Added
Utility scripts in
ui/workflow_setup.pydefining generic LightWin workflows.User can provide
fault_scenario_factorywith aObjectivesFactoryto define objectives without altering the source code.The
add_objectivein the [plots] TOML table to show position of objective.
[0.8.0b4] 2024-11-08
Added
SimulationOutput.plot()method, that calls.getunder the hood and takes in the same arguments.Non-normalized emittance is stored under
non_norm_eps. Ex:SimulationOutput.get("non_norm_eps_phiw").
Changed
Normalized emittances are explicitly marked as normalized in the output.
[0.8.0b3] 2024-11-07
Added
SET_SYNC_PHASEcommands are now handled for export in DAT file.It is now possible to use the
export_phasein the[beam_calculator]table to choose the type of phase to put in the output DAT file.
Changed
Display of cavity parameters in
cav.png, so that 2nd solver does not hide 1st.
Fixed
Calculating
phi_0_absof a cavity when the reference wasphi_sraised error.path_calnot existing inTraceWinraised error instead of just creating the folder.Interpolation of Twiss to compute mismatch factor was bugged.
[0.8.0b2] 2024-11-05
Fixed
Fixed several bugs that were outside the scope of my pytests.
beam_calc_postconfiguration key was no longer recognized.Not providing the
project_folderkey in the[files]TOML table led to bug.Some elements created bugs in
CyEnvelope1D.
[0.8.0b1] 2024-11-04
Fixed
Dot characters in field map file names do not throw an error anymore.
When several
Elementobjects have the same_personalized_name, a fallback name and a warning is raised instead of raising anAssertionError.
Changed
Creation of
DatLineobject, holding a line of the.datfile. Solves several bugs, e.g. with hyphens in personalized names.Makefile for docs is up-to-date. Instructions in README.
Changed location of
RfFieldobject, now incore/em_field/rf_field.The solver
Envelope1Dis nowCyEnvelope1Dwhen user wants Cython.
[0.8.0b0] 2024-10-22
Changed
The configuration manager was refactored.
NewRfFieldobject officially replacesRfField.The configurations for the different objects are now in the
specs.pyfiles, in the same folder as the object they instantiate.
Deleted
Constants were removed from the config module to fix circular dependency and bad design issues.
BeamCalculatorobjects now need to be given thebeamconfiguration dict. Easiest is to instantiateBeamCalculatorFactorywith**config.Acceleratorwill also use data frombeam. InstantiateAcceleratorFactorywith**config.SimulationOutputFactoryinstantiated with_beam_kwargs.
[0.7.0] 2024-10-22
Added
Better display of units in documentation with the new
:unit:role.
[0.7.0b3] 2024-10-09
Added
Documentation has links to documentation from other libraries (numpy etc).
Changed
Documentation is nitpicky.
Fixed
Loading function of
evaluations.csvinlw-combine-solutionsto handle trailing whitespaces.Documentation generation does not raise warnings anymore (except for pymoo).
[0.7.0b2] 2024-10-01
Fixed
Updated path to scripts in
pyproject.toml; they should work again!
Changed
Table of Contents does not show the full path to every module/package anymore. The API section should be much clearer now!
Better display of the constants in the doc
[0.7.0b1] 2024-09-30
Fixed
Scripts moved to the
lightwinmodule so that they can actually be imported.outfolderargument incombine-solutionsscript is automatically created if it does not exist.Documentation includes the API reference again.
Most of the errors raised during documentation compilation were fixed.
[0.7.0b0] 2024-09-26
Fixed
Released constraints on the versions of installed packages.
[0.7.0b] 2024-08-07
Changed
The code is packaged.
Installation instructions were updated.
It is not necessary to add LightWin to your
PATH.Imports of LightWin modules and functions must be imported from
lightwin:from lightwin.<foo> import <fee>.Cython compilation is automatic.
[0.6.21] 2024-06-07
Added
Support for
REPEAT_ELEcommand.Basic support for
SET_SYNC_PHASE. This command can be kept in the input.dat, but output.datwill hold relative or absolute phase (determined by theBeamCalculator.reference_phase).
Changed
When creating the
BeamCalculator, prefermethod="RK4"overmethod="RK"for 4th order Runge-Kutta method.
[0.6.20] 2024-05-31
Added
Basic support for
ADJUSTcommandsNew functionality: pass beauty.
After a
FaultScenariois fixed, useinsert_beauty_pass_instructionsfromutil.beauty_passto add diagnostics and adjust and let TraceWin refine the settings.Prefer providing
TraceWinwithcancel_matchingP = true(would be too long).Do NOT provide
cancel_matching = truenorcancel_matching = false. Just drop this argument out (FIXME).Compensating, rephased and failed cavities will be incorrectly displayed as nominal (green) cavities in the output figures (FIXME).
Fixed
Personalized name of field maps 1100, 100 and of quadrupoles are now exported in output dat file.
Note that this is a temporary patch, a more robust solution will be implemented in future updates.
[0.6.19] 2024-05-27
Added
Support for the TraceWin command line arguments:
algo,cancel_matchingandcancel_matchingPYou can provide a
shiftkey inwtfto shift the window of compensating cavities.Example with 4 compensating lattices:
shift=0-> 2 upstream and 2 downstream compensating latticesshift=+1-> 1 upstream and 3 downstream compensating latticesshift=-1-> 3 upstream and 1 downstream compensating lattices
Variable/Constraintlimits can be changed after creation with thechange_limitsmethod.You can override the default kwargs in the
OptimisationAlgorithmactual algo.Support for pickling/unpickling objects.
In other words: some objects such as
AcceleratororSimulationOutputcan be saved in binary format, so they can be reloaded and reused in a later Python instance without the hassle of recreating and recomputing everything.
Changed
A configuration file is mandatory to select the TraceWin executables.
Fixed
SimulationOutput created by TraceWin have a
is_multiparticleattribute that matches reality.Position envelopes are now plotted in deg instead of degdeg (1degdeg = 180 / pi deg).
[0.6.18] 2024-04-23
Added
You can forbid a cavity from being retuned (ex: a rebuncher which is here to rebunch, not to try funny beamy things). Just set
my_cavity.can_be_retuned = False.By default, a lattice without any retunable cavity is skipped when selecting the compensating cavities; this behavior can be modified by setting a
min_number_of_cavities_in_latticewithl neighboring latticesmethod in the configuration.
Changed
New typing features impose the use of Python 3.12.
The
idxkey in thewtfdictionary is now calledid_nature, which can be one of the following:cavity: we consider thatfailed = [[10]]means “the 10th cavity is down”.element: we consider thatfailed = [[10]]means “the 10th element is down”. If the 10th element is not a cavity, an error is raised.name: we consider thatfailed = [["FM10"]]means “the first element which name is ‘FM10’ is down”.
With the
l neighboring latticesstrategy,lcan now be odd.You can provide
tie_strategy = "downstream first"ortie_strategy = "upstream first"to favour up/downstream cavities when there is a tie in distance between compensating cavities/lattices and failed.
Fixed
Colors in Evaluator plots are now reset between executions
[0.6.17] 2024-04-19
Added
Switch between different phases at
.datsave.
Fixed
With the
"sync_phase_amplitude"design space, the synchronous phases were saved in the.datand labelled as relative phase (noSET_SYNC_PHASE).
[0.6.16] 2024-04-17
Added
New design space
"rel_phase_amplitude_with_constrained_sync_phase"Pytest for basic compensation with all
BeamCalculatorPytest for every
Design Space
Deprecated
Some design space names are not to be used.
"unconstrained"->"abs_phase_amplitude""unconstrained_rel"->"rel_phase_amplitude""constrained_sync_phase"->"abs_phase_amplitude_with_constrained_sync_phase""sync_phase_as_variable"->"sync_phase_amplitude"
Removed
Support for
.iniconfiguration files."phi_s_fit"entry in configuration (use the proper design space config entry instead)
Fixed
Lattices and their indexes correctly set.
Synchronous phases correctly calculated and updated; can be used as a variable again.
Future updates
[0.?.??] 2024-??-?? – branch under development
Changed
evaluatorobjects are more robust and can be configured from the.toml.Plotting is now performed thanks to the
plotterlibrary.
Added
FIELD_MAP 70does not raise error (warning issued withEnvelope3D: no transverse tracking).SUPERPOSE_MAPwill be implemented for 1D maps (warning issued withEnvelope3D: no transverse tracking).