Skip to content

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

Open
egstern wants to merge 26 commits intoBLAST-ImpactX:developmentfrom
egstern:parse_madx_lattice
Open

routine to instantiate an impactx lattice based on a synergia lattice#1271
egstern wants to merge 26 commits intoBLAST-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 (d762bdc) with development (909ea97)

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.

if __name__ == "__main__":
main()
pass

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.

# clean shutdown
sim.finalize()
pass

Check warning

Code scanning / CodeQL

Unnecessary pass Warning

Unnecessary 'pass' statement.
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.
beta_y = lf.beta.ver
alpha_y = lf.alpha.ver
psi_x = lf.psi.hor
psi_y = lf.psi.ver

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable psi_y is not used.
alpha_x = lf.alpha.hor
beta_y = lf.beta.ver
alpha_y = lf.alpha.ver
psi_x = lf.psi.hor

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable psi_x is not used.
lattice_raw.set_all_string_attribute("extractor_type", "libff")

if enable_rf:
lattice_with_rf = set_rf(

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable lattice_with_rf is not used.
@ax3l ax3l mentioned this pull request Apr 10, 2026
17 tasks
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