Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters: Use AMReX Parser #792

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Parameters: Inputs File

This documents how to use ImpactX with an input file (``impactx input_file.in``).

.. note::

Input files use the AMReX `ParmParse <https://amrex-codes.github.io/amrex/docs_html/Basics.html#parmparse>`__ syntax.
A `parser <https://amrex-codes.github.io/amrex/docs_html/Basics.html#parser>`__) is used for the right-hand-side of all input parameters that consist of one or more integers or floats, so expressions like ``beam.kin_energy = "2.+1."``, ``beam.lambdaY = beam.lambdaX`` and/or using user-defined constants are accepted.


.. _running-cpp-parameters-particle:

Expand Down
4 changes: 2 additions & 2 deletions examples/achromatic_spectrometer/input_spectrometer.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag
beam.lambdaX = 3.162277660e-6
beam.lambdaY = 3.162277660e-6
beam.lambdaY = beam.lambdaX
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to change all of the existing examples? Couldn't this cause some confusion to users? It might be better to have just one example to illustrate this feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added it whenever it made sense so people come definitely across it. I hope I did not add it in confusing places, can revert a few where it is complicating the logic ofc.

beam.lambdaT = 1.0e-3
beam.lambdaPx = 3.16227766017e-4
beam.lambdaPy = 3.16227766017e-4
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-2
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/alignment/input_alignment.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = proton
beam.distribution = waterbag
beam.lambdaX = 1.16098260008648811e-3
beam.lambdaY = 1.16098260008648811e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-3
beam.lambdaPx = 0.580491300043e-3
beam.lambdaPy = 0.580491300043e-3
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-3
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
6 changes: 3 additions & 3 deletions examples/apochromatic/input_apochromatic.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = gaussian
beam.lambdaX = 1.288697604e-6
beam.lambdaY = 1.288697604e-6
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-6
beam.lambdaPx = 3.965223396e-6
beam.lambdaPy = 3.965223396e-6
beam.lambdaPt = 0.01 #1% energy spread
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 0.01 # 1% energy spread
beam.muxpx = 0.0
beam.muypy = 0.0
beam.mutpt = 0.0
Expand Down
6 changes: 3 additions & 3 deletions examples/apochromatic/input_apochromatic_pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = gaussian
beam.lambdaX = 1.288697604e-6
beam.lambdaY = 1.288697604e-6
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-6
beam.lambdaPx = 3.965223396e-6
beam.lambdaPy = 3.965223396e-6
beam.lambdaPt = 0.01 #1% energy spread
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 0.01 # 1% energy spread
beam.muxpx = 0.0
beam.muypy = 0.0
beam.mutpt = 0.0
Expand Down
12 changes: 6 additions & 6 deletions examples/cfbend/input_cfbend.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ beam.kin_energy = 2.0e3 #2 GeV
beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag
beam.lambdaX = 5.0e-6 #5 um
beam.lambdaY = 8.0e-6 #8 um
beam.lambdaT = 0.0599584916 #200 ps
beam.lambdaPx = 2.5543422003e-9 #exn = 50 pm-rad
beam.lambdaPy = 1.5964638752e-9 #eyn = 50 pm-rad
beam.lambdaPt = 9.0e-4 #approximately dE/E
beam.lambdaX = 5.0e-6 # 5 um
beam.lambdaY = 8.0e-6 # 8 um
beam.lambdaT = 0.0599584916 # 200 ps
beam.lambdaPx = 2.5543422003e-9 # exn = 50 pm-rad
beam.lambdaPy = 1.5964638752e-9 # eyn = 50 pm-rad
beam.lambdaPt = 9.0e-4 # approximately dE/E
beam.muxpx = 0.0
beam.muypy = 0.0
beam.mutpt = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/cfchannel/input_cfchannel.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = proton
beam.distribution = waterbag
beam.lambdaX = 1.0e-3
beam.lambdaY = 1.0e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 3.369701494258956e-4
beam.lambdaPx = 1.0e-3
beam.lambdaPy = 1.0e-3
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.9676219145931020e-3
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/cfchannel/input_cfchannel_10nC_fft.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ beam.charge = 1.0e-8
beam.particle = proton
beam.distribution = waterbag
beam.lambdaX = 1.2154443728379865788e-3
beam.lambdaY = 1.2154443728379865788e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 4.0956844276541331005e-4
beam.lambdaPx = 8.2274435782286157175e-4
beam.lambdaPy = 8.2274435782286157175e-4
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.4415943602685364584e-3


Expand Down
4 changes: 2 additions & 2 deletions examples/cfchannel/input_cfchannel_10nC_mlmg.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ beam.charge = 1.0e-8
beam.particle = proton
beam.distribution = waterbag
beam.lambdaX = 1.2154443728379865788e-3
beam.lambdaY = 1.2154443728379865788e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 4.0956844276541331005e-4
beam.lambdaPx = 8.2274435782286157175e-4
beam.lambdaPy = 8.2274435782286157175e-4
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.4415943602685364584e-3


Expand Down
2 changes: 1 addition & 1 deletion examples/chicane/input_chicane.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ beam.lambdaPx = 1.598353425e-6
beam.lambdaPy = 2.803697378e-6
beam.lambdaPt = 2.000000000e-6
beam.muxpx = 0.933345606203060
beam.muypy = 0.933345606203060
beam.muypy = beam.muxpx
beam.mutpt = 0.999999961419755


Expand Down
2 changes: 1 addition & 1 deletion examples/chicane/input_chicane_csr.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ beam.lambdaPx = 1.598353425e-6
beam.lambdaPy = 2.803697378e-6
beam.lambdaPt = 2.000000000e-6
beam.muxpx = 0.933345606203060
beam.muypy = 0.933345606203060
beam.muypy = beam.muxpx
beam.mutpt = 0.999999961419755


Expand Down
4 changes: 2 additions & 2 deletions examples/compression/input_compression.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag
beam.lambdaX = 0.5e-3
beam.lambdaY = 0.5e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 5.0e-3
beam.lambdaPx = 1.0e-5
beam.lambdaPy = 1.0e-5
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 4.0e-6
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
2 changes: 1 addition & 1 deletion examples/coupled_optics/input_coupled_optics.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ beam.lambdaPx = 1.598353425e-6
beam.lambdaPy = 2.803697378e-6
beam.lambdaPt = 2.000000000e-6
beam.muxpx = 0.933345606203060
beam.muypy = 0.933345606203060
beam.muypy = beam.muxpx
beam.mutpt = 0.999999961419755


Expand Down
4 changes: 2 additions & 2 deletions examples/cyclotron/input_cyclotron.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = proton
beam.distribution = waterbag
beam.lambdaX = 1.0e-3
beam.lambdaY = 1.0e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 0.3
beam.lambdaPx = 2.0e-4
beam.lambdaPy = 2.0e-4
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-5
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/distgen/input_gaussian_twiss.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ beam.alphaX = -1.5905003499999992
beam.alphaY = 1.5905003499999992
beam.alphaT = 0.0
beam.betaX = 2.8216194100262637
beam.betaY = 2.8216194100262637
beam.betaY = beam.betaX
beam.betaT = 0.5
beam.emittX = 2e-09
beam.emittY = 2e-09
beam.emittY = beam.emittX
beam.emittT = 2e-06


Expand Down
4 changes: 2 additions & 2 deletions examples/distgen/input_kurth4d.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ beam.charge = 1.0e-9
beam.particle = proton
beam.distribution = kurth4d
beam.lambdaX = 1.0e-3
beam.lambdaY = 1.0e-3
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-3
beam.lambdaPx = 1.0e-3
beam.lambdaPy = 1.0e-3
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-3
beam.muxpx = 0.0
beam.muypy = 0.0
Expand Down
6 changes: 3 additions & 3 deletions examples/distgen/input_kvdist_twiss.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = kvdist_from_twiss
beam.alphaX = -1.5905003499999992
beam.alphaY = 1.5905003499999992
beam.alphaY = -beam.alphaX
beam.alphaT = 0.0
beam.betaX = 2.8216194100262637
beam.betaY = 2.8216194100262637
beam.betaY = beam.betaX
beam.betaT = 0.5
beam.emittX = 2e-09
beam.emittY = 2e-09
beam.emittY = beam.emittX
beam.emittT = 2e-06


Expand Down
6 changes: 3 additions & 3 deletions examples/distgen/input_semigaussian.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = gaussian
beam.lambdaX = 3.9984884770e-5
beam.lambdaY = 3.9984884770e-5
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-3
beam.lambdaPx = 2.6623538760e-5
beam.lambdaPy = 2.6623538760e-5
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-3
beam.muxpx = -0.846574929020762
beam.muypy = 0.846574929020762
beam.muypy = -beam.muxpx
beam.mutpt = 0.0


Expand Down
12 changes: 6 additions & 6 deletions examples/dogleg/input_dogleg.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ beam.lambdaPx = 1.598353425e-6
beam.lambdaPy = 2.803697378e-6
beam.lambdaPt = 2.000000000e-6
beam.muxpx = 0.933345606203060
beam.muypy = 0.933345606203060
beam.muypy = beam.muxpx
beam.mutpt = 0.999999961419755


Expand All @@ -29,11 +29,11 @@ sbend1.ds = 0.500194828041958 # projected length 0.5 m, angle 2.77 deg
sbend1.rc = -10.3462283686195526

drift1.type = drift
drift1.ds = 5.0058489435 # projected length 5 m
drift1.ds = 5.0058489435 # projected length 5 m

sbend2.type = sbend
sbend2.ds = 0.500194828041958 # projected length 0.5 m, angle 2.77 deg
sbend2.rc = 10.3462283686195526
sbend2.ds = sbend1.ds # projected length 0.5 m, angle 2.77 deg
sbend2.rc = -sbend1.rc

drift2.type = drift
drift2.ds = 0.5
Expand All @@ -45,8 +45,8 @@ dipedge1.g = 0.0
dipedge1.K2 = 0.0

dipedge2.type = dipedge
dipedge2.psi = 0.048345620280243
dipedge2.rc = 10.3462283686195526
dipedge2.psi = -dipedge1.psi
dipedge2.rc = -dipedge1.rc
dipedge2.g = 0.0
dipedge2.K2 = 0.0

Expand Down
4 changes: 2 additions & 2 deletions examples/epac2004_benchmarks/input_bithermal.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ monitor.backend = h5
constf1.type = constf
constf1.ds = 10.0
constf1.kx = 6.283185307179586
constf1.ky = 6.283185307179586
constf1.kt = 6.283185307179586
constf1.ky = constf1.kx
constf1.kt = constf1.kx
#constf1.nslice = 400 #full resolution
constf1.nslice = 50

Expand Down
2 changes: 1 addition & 1 deletion examples/epac2004_benchmarks/input_fodo_rf_SC.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fquad.nslice = 6

dquad.type = quad
dquad.ds = 0.3
dquad.k = -2.4669749766168163
dquad.k = -fquad.k
dquad.nslice = 12

gapa1.type = rfcavity
Expand Down
4 changes: 2 additions & 2 deletions examples/epac2004_benchmarks/input_thermal.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ monitor.backend = h5
constf1.type = constf
constf1.ds = 10.0
constf1.kx = 6.283185307179586
constf1.ky = 6.283185307179586
constf1.kt = 6.283185307179586
constf1.ky = constf1.kx
constf1.kt = constf1.kx
constf1.nslice = 400 #full resolution
#constf1.nslice = 50

Expand Down
2 changes: 1 addition & 1 deletion examples/expanding_beam/input_expanding_fft.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = kurth6d
beam.lambdaX = 4.472135955e-4
beam.lambdaY = 4.472135955e-4
beam.lambdaY = beam.lambdaX
beam.lambdaT = 9.12241869e-7
beam.lambdaPx = 0.0
beam.lambdaPy = 0.0
Expand Down
2 changes: 1 addition & 1 deletion examples/expanding_beam/input_expanding_mlmg.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = kurth6d
beam.lambdaX = 4.472135955e-4
beam.lambdaY = 4.472135955e-4
beam.lambdaY = beam.lambdaX
beam.lambdaT = 9.12241869e-7
beam.lambdaPx = 0.0
beam.lambdaPy = 0.0
Expand Down
6 changes: 3 additions & 3 deletions examples/fodo/input_fodo.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag
beam.lambdaX = 3.9984884770e-5
beam.lambdaY = 3.9984884770e-5
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-3
beam.lambdaPx = 2.6623538760e-5
beam.lambdaPy = 2.6623538760e-5
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-3
beam.muxpx = -0.846574929020762
beam.muypy = 0.846574929020762
beam.muypy = -beam.muxpx
beam.mutpt = 0.0


Expand Down
6 changes: 3 additions & 3 deletions examples/fodo/input_fodo_twiss.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag_from_twiss
beam.alphaX = -1.5905003499999992
beam.alphaY = 1.5905003499999992
beam.alphaY = -beam.alphaX
beam.alphaT = 0.0
beam.betaX = 2.8216194100262637
beam.betaY = 2.8216194100262637
beam.betaY = beam.betaX
beam.betaT = 0.5
beam.emittX = 2e-09
beam.emittY = 2e-09
beam.emittY = beam.emittX
beam.emittT = 2e-06


Expand Down
6 changes: 3 additions & 3 deletions examples/fodo_channel/input_fodo.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag_from_twiss
beam.alphaX = -1.5905003499999992
beam.alphaY = 1.5905003499999992
beam.alphaY = -beam.alphaX
beam.alphaT = 0.0
beam.betaX = 2.8216194100262637
beam.betaY = 2.8216194100262637
beam.betaY = beam.betaX
beam.betaT = 0.5
beam.emittX = 2e-09
beam.emittY = 2e-09
beam.emittY = beam.emittX
beam.emittT = 2e-06


Expand Down
6 changes: 3 additions & 3 deletions examples/fodo_chromatic/input_fodo_chr.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ beam.charge = 1.0e-9
beam.particle = electron
beam.distribution = waterbag
beam.lambdaX = 3.9984884770e-5
beam.lambdaY = 3.9984884770e-5
beam.lambdaY = beam.lambdaX
beam.lambdaT = 1.0e-3
beam.lambdaPx = 2.6623538760e-5
beam.lambdaPy = 2.6623538760e-5
beam.lambdaPy = beam.lambdaPx
beam.lambdaPt = 2.0e-3
beam.muxpx = -0.846574929020762
beam.muypy = 0.846574929020762
beam.muypy = -beam.muxpx
beam.mutpt = 0.0


Expand Down
Loading
Loading