Skip to content

routine to instantiate an impactx lattice based on a synergia lattice#1271

Open
egstern wants to merge 39 commits into
BLAST-ImpactX:developmentfrom
egstern:parse_madx_lattice
Open

routine to instantiate an impactx lattice based on a synergia lattice#1271
egstern wants to merge 39 commits into
BLAST-ImpactX:developmentfrom
egstern:parse_madx_lattice

Conversation

@egstern
Copy link
Copy Markdown
Member

@egstern egstern commented Jan 21, 2026

This is the start of an example that demonstrates converting a lattice parsed in Synergia from a MAD-X into an ImpactX lattice.

Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@cemitch99
Copy link
Copy Markdown
Member

Great! Thanks for sharing!

@ax3l ax3l added component: documentation Docs, readme and manual component: third party Changes in ImpactX that reflect a change in a third-party library component: elements Elements/maps/external fields component: python Python bindings labels Jan 27, 2026
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
)

return ocelem

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
# only do linear bend
main_bend_elem = impactx.elements.CFbend(
ds, radius_of_curvature, k1, nslice=ns, name=nm
)

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
else:
# CF bend

if order == Order.linear:

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
)
else:
phi = bendangle * 180 / np.pi
main_bend_elem = impactx.elements.ExactSbend(ds, phi, nslice=ns, name=nm)

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
de_model = "linear"

if e1 != 0.0:
us_dipedge = impactx.elements.DipEdge(

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
@cemitch99 cemitch99 requested review from ax3l and cemitch99 February 3, 2026 00:33
Copy link
Copy Markdown
Member

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like one feature still needed for this PR is documentation in a README.

model="linear",
name=nm + "_usedge",
)
pass

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
Comment thread examples/parse_madx_lattice/syn2_to_impactx.py Fixed
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing egstern:parse_madx_lattice (eb9154d) with development (7ba9694)

Open in CodSpeed

2 * hgap,
K2=fint,
location="entry",
model=de_model,

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'de_model' may be used before it is initialized.
2 * hgap,
K2=fint,
location="exit",
model=de_model,

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'de_model' may be used before it is initialized.
radius_of_curvature,
2 * hgap,
K2=fint,
model=de_model,

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'de_model' may be used before it is initialized.
radius_of_curvature,
2 * hgap,
K2=fint,
model=de_model,

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'de_model' may be used before it is initialized.
egstern and others added 5 commits March 23, 2026 10:04
2) A script that parses the lattice with Synergia, converts to ImpactX
     format with syn2_to_impactx and runs a simulation.
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
Comment thread examples/parse_madx_lattice/parse_booster_lattice.py Fixed
@ax3l ax3l mentioned this pull request Apr 10, 2026
17 tasks
@ax3l ax3l force-pushed the development branch 2 times, most recently from 9a1e4af to fa61eba Compare April 20, 2026 04:08
egstern and others added 6 commits April 23, 2026 12:10
Add dependencies conditional on the fla ImpactX_synmadx
…a tree

Remove the following unused Synergia subdirectories that are not required
to build MadX_reader:
  - synergia/bunch/
  - synergia/collective/
  - synergia/libFF/
  - synergia/optics/
  - synergia/simulation/
  - synergia/tools/

(368 files total)

Decouple the remaining root synergia/ tree by vendoring bundled Boost
headers locally into src/synmadx/synergia/utils/boost/. Update synmadx
include path from ${CMAKE_SOURCE_DIR}/synergia/utils to
${CMAKE_CURRENT_SOURCE_DIR}/synergia/utils to use the local vendored copy.

Remove remaining root synergia/foundation/, synergia/lattice/,
synergia/utils/, and root management files (CMakeLists.txt, __init__.py,
version.py.in, .gitignore).

Verify synmadx builds and all 4 tests pass after decoupling:
  - synmadx.test_lattice
  - synmadx.test_dynamic_lattice
  - synmadx.test_madx_parser
  - synmadx.test_mx_expr

Synmadx is now fully standalone with all dependencies either bundled
or inherited from the ImpactX CMake layer (pybind11, C++ std lib).
ref.set_kin_energy_MeV(kin_energy)

# charge to mass ratio
qm_eev = 1.0 / (1.0e-9 * mp)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable qm_eev is not used.

if enable_rf:
lattice_with_rf = set_rf(
lattice_raw,

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable lattice_with_rf is not used.
@egstern
Copy link
Copy Markdown
Member Author

egstern commented May 11, 2026

@ax3l The first failure is because the name of the author in an included Boost header is European and has a non-ASCII character in their name which just appears in a comment. As a European, how do you feel about flagging this as an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: documentation Docs, readme and manual component: elements Elements/maps/external fields component: python Python bindings component: third party Changes in ImpactX that reflect a change in a third-party library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants