From f1746506958a8025cf0d5d0e2ba750de3f4786c6 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 11 Oct 2024 16:25:38 -0700 Subject: [PATCH] Introduce `sim.track_particles()` We will have multiple ways to evolve the sim soon (particles, only ref particle, only linear push of covariance matrix), so it is time to rename our central loop. For now, `sim.evolve()` just calls the `sim.track_particles()` logic. --- docs/source/usage/python.rst | 6 +++++- examples/achromatic_spectrometer/run_spectrometer.py | 2 +- examples/alignment/run_alignment.py | 2 +- examples/aperture/run_aperture.py | 2 +- examples/apochromatic/run_apochromatic.py | 2 +- examples/apochromatic/run_apochromatic_pl.py | 2 +- examples/cfbend/run_cfbend.py | 2 +- examples/cfbend/run_cfbend_madx.py | 2 +- examples/cfchannel/run_cfchannel.py | 2 +- examples/cfchannel/run_cfchannel_10nC_fft.py | 2 +- examples/cfchannel/run_cfchannel_10nC_mlmg.py | 2 +- examples/chicane/run_chicane.py | 2 +- examples/chicane/run_chicane_csr.py | 2 +- examples/chicane/run_chicane_madx.py | 2 +- examples/compression/run_compression.py | 2 +- examples/coupled_optics/run_coupled_optics.py | 2 +- examples/cyclotron/run_cyclotron.py | 2 +- examples/distgen/run_gaussian_twiss.py | 2 +- examples/distgen/run_kurth4d.py | 2 +- examples/distgen/run_kvdist_twiss.py | 2 +- examples/distgen/run_semigaussian.py | 2 +- examples/dogleg/run_dogleg.py | 2 +- examples/epac2004_benchmarks/run_bithermal.py | 2 +- examples/epac2004_benchmarks/run_fodo_rf_SC.py | 2 +- examples/epac2004_benchmarks/run_thermal.py | 2 +- examples/expanding_beam/run_expanding_fft.py | 2 +- examples/expanding_beam/run_expanding_mlmg.py | 2 +- examples/fodo/run_fodo.py | 2 +- examples/fodo/run_fodo_madx.py | 2 +- examples/fodo/run_fodo_twiss.py | 2 +- examples/fodo_channel/run_fodo.py | 2 +- examples/fodo_chromatic/run_fodo_chr.py | 2 +- examples/fodo_programmable/run_fodo_programmable.py | 2 +- examples/fodo_rf/run_fodo_rf.py | 2 +- examples/fodo_tune/run_fodo_tune.py | 2 +- examples/initialize_from_array/run_from_array.py | 2 +- examples/iota_lattice/run_iotalattice.py | 2 +- examples/iota_lattice/run_iotalattice_sdep.py | 2 +- examples/iota_lens/run_iotalens.py | 2 +- examples/iota_lens/run_iotalens_sdep.py | 2 +- examples/kicker/run_hvkicker_madx.py | 2 +- examples/kicker/run_kicker.py | 2 +- examples/kicker/run_kicker_madx.py | 2 +- examples/kurth/run_kurth_10nC_periodic.py | 2 +- examples/kurth/run_kurth_periodic.py | 2 +- examples/multipole/run_multipole.py | 2 +- examples/optimize_triplet/run_triplet.py | 2 +- examples/positron_channel/run_positron.py | 2 +- .../run_ml_surrogate_15_stage.py | 2 +- .../quadrupole_softedge/run_quadrupole_softedge.py | 2 +- examples/rfcavity/run_rfcavity.py | 2 +- examples/rotation/run_rotation.py | 2 +- examples/solenoid/run_solenoid.py | 2 +- examples/solenoid/run_solenoid_madx.py | 2 +- examples/solenoid_softedge/run_solenoid_softedge.py | 2 +- examples/thin_dipole/run_thin_dipole.py | 2 +- src/ImpactX.H | 6 +++++- src/ImpactX.cpp | 7 +++++++ src/python/ImpactX.cpp | 7 +++++-- src/python/impactx/dashboard/Toolbar/exportTemplate.py | 2 +- src/python/impactx/dashboard/simulation.py | 2 +- tests/python/test_charge_deposition.py | 2 +- tests/python/test_dataframe.py | 2 +- tests/python/test_impactx.py | 10 +++++----- tests/python/test_particle_tiles.py | 2 +- tests/python/test_push.py | 2 +- tests/python/test_wake.py | 2 +- tests/python/test_xopt.py | 2 +- 68 files changed, 90 insertions(+), 72 deletions(-) diff --git a/docs/source/usage/python.rst b/docs/source/usage/python.rst index 73e9c0329..55e34d5f8 100644 --- a/docs/source/usage/python.rst +++ b/docs/source/usage/python.rst @@ -215,7 +215,11 @@ Collective Effects & Overall Simulation Parameters .. py:method:: evolve() - Run the main simulation loop for a number of steps. + Run the main simulation loop (deprecated, use ``track_particles``) + + .. py:method:: track_particles() + + Run the particle tracking simulation loop. .. py:method:: resize_mesh() diff --git a/examples/achromatic_spectrometer/run_spectrometer.py b/examples/achromatic_spectrometer/run_spectrometer.py index 3ea598645..043ad229d 100755 --- a/examples/achromatic_spectrometer/run_spectrometer.py +++ b/examples/achromatic_spectrometer/run_spectrometer.py @@ -78,7 +78,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/alignment/run_alignment.py b/examples/alignment/run_alignment.py index ccba11a3e..f384a749f 100755 --- a/examples/alignment/run_alignment.py +++ b/examples/alignment/run_alignment.py @@ -55,7 +55,7 @@ sim.lattice.extend(lattice) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/aperture/run_aperture.py b/examples/aperture/run_aperture.py index 39ff1e6fa..b8b783edb 100755 --- a/examples/aperture/run_aperture.py +++ b/examples/aperture/run_aperture.py @@ -63,7 +63,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/apochromatic/run_apochromatic.py b/examples/apochromatic/run_apochromatic.py index c25802ae3..bda95f1c0 100644 --- a/examples/apochromatic/run_apochromatic.py +++ b/examples/apochromatic/run_apochromatic.py @@ -69,7 +69,7 @@ sim.lattice.extend(lattice_line) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/apochromatic/run_apochromatic_pl.py b/examples/apochromatic/run_apochromatic_pl.py index af78089df..391af1999 100644 --- a/examples/apochromatic/run_apochromatic_pl.py +++ b/examples/apochromatic/run_apochromatic_pl.py @@ -108,7 +108,7 @@ sim.lattice.extend(lattice_line) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cfbend/run_cfbend.py b/examples/cfbend/run_cfbend.py index 22acc5834..2b3de256f 100644 --- a/examples/cfbend/run_cfbend.py +++ b/examples/cfbend/run_cfbend.py @@ -59,7 +59,7 @@ sim.lattice.extend(bend) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cfbend/run_cfbend_madx.py b/examples/cfbend/run_cfbend_madx.py index 9b40785f9..3667277b1 100755 --- a/examples/cfbend/run_cfbend_madx.py +++ b/examples/cfbend/run_cfbend_madx.py @@ -46,7 +46,7 @@ sim.lattice.load_file("chicane.madx", nslice=25) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cfchannel/run_cfchannel.py b/examples/cfchannel/run_cfchannel.py index d46428dc0..b817d3d38 100755 --- a/examples/cfchannel/run_cfchannel.py +++ b/examples/cfchannel/run_cfchannel.py @@ -53,7 +53,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cfchannel/run_cfchannel_10nC_fft.py b/examples/cfchannel/run_cfchannel_10nC_fft.py index 9b6467929..6349438b4 100755 --- a/examples/cfchannel/run_cfchannel_10nC_fft.py +++ b/examples/cfchannel/run_cfchannel_10nC_fft.py @@ -59,7 +59,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cfchannel/run_cfchannel_10nC_mlmg.py b/examples/cfchannel/run_cfchannel_10nC_mlmg.py index c8c46d18a..45f057edc 100755 --- a/examples/cfchannel/run_cfchannel_10nC_mlmg.py +++ b/examples/cfchannel/run_cfchannel_10nC_mlmg.py @@ -58,7 +58,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/chicane/run_chicane.py b/examples/chicane/run_chicane.py index 7065246ca..b7ad6efc1 100644 --- a/examples/chicane/run_chicane.py +++ b/examples/chicane/run_chicane.py @@ -77,7 +77,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/chicane/run_chicane_csr.py b/examples/chicane/run_chicane_csr.py index 9661d256d..0ebbfa510 100644 --- a/examples/chicane/run_chicane_csr.py +++ b/examples/chicane/run_chicane_csr.py @@ -79,7 +79,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/chicane/run_chicane_madx.py b/examples/chicane/run_chicane_madx.py index 33f22e899..e9ffb3558 100755 --- a/examples/chicane/run_chicane_madx.py +++ b/examples/chicane/run_chicane_madx.py @@ -46,7 +46,7 @@ sim.lattice.load_file("chicane.madx", nslice=25) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/compression/run_compression.py b/examples/compression/run_compression.py index 0552af292..5ffda5521 100644 --- a/examples/compression/run_compression.py +++ b/examples/compression/run_compression.py @@ -56,7 +56,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/coupled_optics/run_coupled_optics.py b/examples/coupled_optics/run_coupled_optics.py index c6e6632d1..5c14a6461 100644 --- a/examples/coupled_optics/run_coupled_optics.py +++ b/examples/coupled_optics/run_coupled_optics.py @@ -75,7 +75,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/cyclotron/run_cyclotron.py b/examples/cyclotron/run_cyclotron.py index 63ec87e1b..ea5af473d 100755 --- a/examples/cyclotron/run_cyclotron.py +++ b/examples/cyclotron/run_cyclotron.py @@ -62,7 +62,7 @@ sim.periods = 150 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/distgen/run_gaussian_twiss.py b/examples/distgen/run_gaussian_twiss.py index dbd4c1ce7..9e3a897c6 100755 --- a/examples/distgen/run_gaussian_twiss.py +++ b/examples/distgen/run_gaussian_twiss.py @@ -67,7 +67,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/distgen/run_kurth4d.py b/examples/distgen/run_kurth4d.py index 94194dcdb..6731a92ef 100755 --- a/examples/distgen/run_kurth4d.py +++ b/examples/distgen/run_kurth4d.py @@ -58,7 +58,7 @@ sim.lattice.extend(constf) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/distgen/run_kvdist_twiss.py b/examples/distgen/run_kvdist_twiss.py index 7d67987e5..da77dc26e 100755 --- a/examples/distgen/run_kvdist_twiss.py +++ b/examples/distgen/run_kvdist_twiss.py @@ -67,7 +67,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/distgen/run_semigaussian.py b/examples/distgen/run_semigaussian.py index b737246f4..8b43612db 100755 --- a/examples/distgen/run_semigaussian.py +++ b/examples/distgen/run_semigaussian.py @@ -65,7 +65,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/dogleg/run_dogleg.py b/examples/dogleg/run_dogleg.py index f731c76ca..9fc1e857d 100644 --- a/examples/dogleg/run_dogleg.py +++ b/examples/dogleg/run_dogleg.py @@ -71,7 +71,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/epac2004_benchmarks/run_bithermal.py b/examples/epac2004_benchmarks/run_bithermal.py index 5463cf9e8..008a3a7bd 100755 --- a/examples/epac2004_benchmarks/run_bithermal.py +++ b/examples/epac2004_benchmarks/run_bithermal.py @@ -65,7 +65,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/epac2004_benchmarks/run_fodo_rf_SC.py b/examples/epac2004_benchmarks/run_fodo_rf_SC.py index a86cd7d06..07c25eedb 100755 --- a/examples/epac2004_benchmarks/run_fodo_rf_SC.py +++ b/examples/epac2004_benchmarks/run_fodo_rf_SC.py @@ -197,7 +197,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/epac2004_benchmarks/run_thermal.py b/examples/epac2004_benchmarks/run_thermal.py index c2495a6d1..c20dc1b8d 100755 --- a/examples/epac2004_benchmarks/run_thermal.py +++ b/examples/epac2004_benchmarks/run_thermal.py @@ -62,7 +62,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/expanding_beam/run_expanding_fft.py b/examples/expanding_beam/run_expanding_fft.py index c6b9ac53b..92fa1269c 100755 --- a/examples/expanding_beam/run_expanding_fft.py +++ b/examples/expanding_beam/run_expanding_fft.py @@ -58,7 +58,7 @@ sim.lattice.extend([monitor, elements.Drift(name="d1", ds=6.0, nslice=40), monitor]) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/expanding_beam/run_expanding_mlmg.py b/examples/expanding_beam/run_expanding_mlmg.py index 42b97904b..6485d95eb 100755 --- a/examples/expanding_beam/run_expanding_mlmg.py +++ b/examples/expanding_beam/run_expanding_mlmg.py @@ -57,7 +57,7 @@ sim.lattice.extend([monitor, elements.Drift(name="d1", ds=6.0, nslice=40), monitor]) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo/run_fodo.py b/examples/fodo/run_fodo.py index 6a6418eca..1eee1baee 100755 --- a/examples/fodo/run_fodo.py +++ b/examples/fodo/run_fodo.py @@ -65,7 +65,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo/run_fodo_madx.py b/examples/fodo/run_fodo_madx.py index ed44dca0f..6e1265d36 100755 --- a/examples/fodo/run_fodo_madx.py +++ b/examples/fodo/run_fodo_madx.py @@ -47,7 +47,7 @@ sim.lattice.load_file("fodo.madx", nslice=25) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo/run_fodo_twiss.py b/examples/fodo/run_fodo_twiss.py index 700fdd767..156c22ea8 100755 --- a/examples/fodo/run_fodo_twiss.py +++ b/examples/fodo/run_fodo_twiss.py @@ -67,7 +67,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo_channel/run_fodo.py b/examples/fodo_channel/run_fodo.py index 9eaf171f5..ecc64125a 100755 --- a/examples/fodo_channel/run_fodo.py +++ b/examples/fodo_channel/run_fodo.py @@ -65,7 +65,7 @@ sim.periods = 101 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo_chromatic/run_fodo_chr.py b/examples/fodo_chromatic/run_fodo_chr.py index 1c25ff7c4..27f83a487 100755 --- a/examples/fodo_chromatic/run_fodo_chr.py +++ b/examples/fodo_chromatic/run_fodo_chr.py @@ -65,7 +65,7 @@ sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo_programmable/run_fodo_programmable.py b/examples/fodo_programmable/run_fodo_programmable.py index b74e697f3..8899c7ea3 100755 --- a/examples/fodo_programmable/run_fodo_programmable.py +++ b/examples/fodo_programmable/run_fodo_programmable.py @@ -149,7 +149,7 @@ def my_ref_drift(pge, refpart): sim.lattice.extend(fodo) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo_rf/run_fodo_rf.py b/examples/fodo_rf/run_fodo_rf.py index 397e46212..45bbca142 100644 --- a/examples/fodo_rf/run_fodo_rf.py +++ b/examples/fodo_rf/run_fodo_rf.py @@ -64,7 +64,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/fodo_tune/run_fodo_tune.py b/examples/fodo_tune/run_fodo_tune.py index 864a799d7..61f9f9d68 100755 --- a/examples/fodo_tune/run_fodo_tune.py +++ b/examples/fodo_tune/run_fodo_tune.py @@ -64,7 +64,7 @@ sim.periods = 100 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown del sim diff --git a/examples/initialize_from_array/run_from_array.py b/examples/initialize_from_array/run_from_array.py index 351ff95ab..d72cc02bf 100644 --- a/examples/initialize_from_array/run_from_array.py +++ b/examples/initialize_from_array/run_from_array.py @@ -103,7 +103,7 @@ ] ) -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/iota_lattice/run_iotalattice.py b/examples/iota_lattice/run_iotalattice.py index 5488cf1c7..61b77a27c 100644 --- a/examples/iota_lattice/run_iotalattice.py +++ b/examples/iota_lattice/run_iotalattice.py @@ -120,7 +120,7 @@ sim.periods = 5 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/iota_lattice/run_iotalattice_sdep.py b/examples/iota_lattice/run_iotalattice_sdep.py index 70f50d101..ca3f5a0cb 100644 --- a/examples/iota_lattice/run_iotalattice_sdep.py +++ b/examples/iota_lattice/run_iotalattice_sdep.py @@ -216,7 +216,7 @@ sim.periods = 5 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/iota_lens/run_iotalens.py b/examples/iota_lens/run_iotalens.py index 3efcd826f..1f8c448ad 100644 --- a/examples/iota_lens/run_iotalens.py +++ b/examples/iota_lens/run_iotalens.py @@ -63,7 +63,7 @@ sim.lattice.extend(nllens_lattice) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/iota_lens/run_iotalens_sdep.py b/examples/iota_lens/run_iotalens_sdep.py index 40f147062..efc153928 100644 --- a/examples/iota_lens/run_iotalens_sdep.py +++ b/examples/iota_lens/run_iotalens_sdep.py @@ -96,7 +96,7 @@ sim.periods = 1 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/kicker/run_hvkicker_madx.py b/examples/kicker/run_hvkicker_madx.py index 85b1ca658..d1030fd9b 100644 --- a/examples/kicker/run_hvkicker_madx.py +++ b/examples/kicker/run_hvkicker_madx.py @@ -46,7 +46,7 @@ sim.lattice.load_file("hvkicker.madx", nslice=1) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/kicker/run_kicker.py b/examples/kicker/run_kicker.py index c21a00f6c..d6f4dd9a9 100644 --- a/examples/kicker/run_kicker.py +++ b/examples/kicker/run_kicker.py @@ -54,7 +54,7 @@ sim.lattice.extend(kicklattice) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/kicker/run_kicker_madx.py b/examples/kicker/run_kicker_madx.py index b98d66b5e..9c1b958f2 100644 --- a/examples/kicker/run_kicker_madx.py +++ b/examples/kicker/run_kicker_madx.py @@ -46,7 +46,7 @@ sim.lattice.load_file("kicker.madx", nslice=1) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/kurth/run_kurth_10nC_periodic.py b/examples/kurth/run_kurth_10nC_periodic.py index 62b3be319..8c94035e3 100755 --- a/examples/kurth/run_kurth_10nC_periodic.py +++ b/examples/kurth/run_kurth_10nC_periodic.py @@ -52,7 +52,7 @@ sim.lattice.extend([monitor, drift1, constf1, drift1, monitor]) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/kurth/run_kurth_periodic.py b/examples/kurth/run_kurth_periodic.py index 6b6f60f0d..4b19d7887 100755 --- a/examples/kurth/run_kurth_periodic.py +++ b/examples/kurth/run_kurth_periodic.py @@ -50,7 +50,7 @@ sim.lattice.extend([monitor, drift1, constf1, drift1, monitor]) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/multipole/run_multipole.py b/examples/multipole/run_multipole.py index a8a065351..0780f53dc 100644 --- a/examples/multipole/run_multipole.py +++ b/examples/multipole/run_multipole.py @@ -57,7 +57,7 @@ sim.lattice.extend(multipole) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/optimize_triplet/run_triplet.py b/examples/optimize_triplet/run_triplet.py index dc7466d15..90ede91c7 100755 --- a/examples/optimize_triplet/run_triplet.py +++ b/examples/optimize_triplet/run_triplet.py @@ -125,7 +125,7 @@ def run(parameters: tuple, write_particles=False, write_reduced=False) -> dict: sim.lattice.extend(build_lattice(parameters, write_particles=write_particles)) # run simulation - sim.evolve() + sim.track_particles() # in situ calculate the reduced beam characteristics beam = sim.particle_container() diff --git a/examples/positron_channel/run_positron.py b/examples/positron_channel/run_positron.py index 0f98ae161..e6b432946 100755 --- a/examples/positron_channel/run_positron.py +++ b/examples/positron_channel/run_positron.py @@ -69,7 +69,7 @@ sim.periods = 250 # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py index 004f79bdb..a49a024e3 100644 --- a/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py +++ b/examples/pytorch_surrogate_model/run_ml_surrogate_15_stage.py @@ -355,6 +355,6 @@ def set_lens(self, pc, step, period): ) sim.lattice.extend([monitor]) -sim.evolve() +sim.track_particles() sim.finalize() del sim diff --git a/examples/quadrupole_softedge/run_quadrupole_softedge.py b/examples/quadrupole_softedge/run_quadrupole_softedge.py index 8f74a3241..4b2b96de6 100755 --- a/examples/quadrupole_softedge/run_quadrupole_softedge.py +++ b/examples/quadrupole_softedge/run_quadrupole_softedge.py @@ -76,7 +76,7 @@ sim.lattice.extend([monitor, drift1, quad1, drift2, quad2, drift1, monitor]) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/rfcavity/run_rfcavity.py b/examples/rfcavity/run_rfcavity.py index af73ed12c..69911fd26 100755 --- a/examples/rfcavity/run_rfcavity.py +++ b/examples/rfcavity/run_rfcavity.py @@ -138,7 +138,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/rotation/run_rotation.py b/examples/rotation/run_rotation.py index 0f1f187d1..11a3336dd 100644 --- a/examples/rotation/run_rotation.py +++ b/examples/rotation/run_rotation.py @@ -55,7 +55,7 @@ sim.lattice.extend(rotated_drift) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/solenoid/run_solenoid.py b/examples/solenoid/run_solenoid.py index fc0c517b4..c142a629e 100755 --- a/examples/solenoid/run_solenoid.py +++ b/examples/solenoid/run_solenoid.py @@ -54,7 +54,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/solenoid/run_solenoid_madx.py b/examples/solenoid/run_solenoid_madx.py index 7eea6cbc2..109688c48 100755 --- a/examples/solenoid/run_solenoid_madx.py +++ b/examples/solenoid/run_solenoid_madx.py @@ -43,7 +43,7 @@ sim.lattice.load_file("solenoid.madx", nslice=1) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/solenoid_softedge/run_solenoid_softedge.py b/examples/solenoid_softedge/run_solenoid_softedge.py index c56aa236c..e824b5f00 100755 --- a/examples/solenoid_softedge/run_solenoid_softedge.py +++ b/examples/solenoid_softedge/run_solenoid_softedge.py @@ -136,7 +136,7 @@ ) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/examples/thin_dipole/run_thin_dipole.py b/examples/thin_dipole/run_thin_dipole.py index 4df695f9a..afb21f344 100755 --- a/examples/thin_dipole/run_thin_dipole.py +++ b/examples/thin_dipole/run_thin_dipole.py @@ -64,7 +64,7 @@ sim.lattice.append(monitor) # run simulation -sim.evolve() +sim.track_particles() # clean shutdown sim.finalize() diff --git a/src/ImpactX.H b/src/ImpactX.H index 0b7264710..83b0e268c 100644 --- a/src/ImpactX.H +++ b/src/ImpactX.H @@ -96,10 +96,14 @@ namespace impactx */ bool early_param_check (); - /** Run the main simulation loop for a number of steps + /** Run the main simulation loop */ void evolve (); + /** Run the particle tracking simulation loop + */ + void track_particles (); + /** Query input for warning logger variables and set up warning logger accordingly * * Input variables are: ``always_warn_immediately`` and ``abort_on_warning_threshold``. diff --git a/src/ImpactX.cpp b/src/ImpactX.cpp index ed08201f3..2b356cb72 100644 --- a/src/ImpactX.cpp +++ b/src/ImpactX.cpp @@ -128,6 +128,13 @@ namespace impactx { { BL_PROFILE("ImpactX::evolve"); + track_particles(); + } + + void ImpactX::track_particles () + { + BL_PROFILE("ImpactX::track_particles"); + validate(); // verbosity diff --git a/src/python/ImpactX.cpp b/src/python/ImpactX.cpp index b67ab141b..d1c99f99e 100644 --- a/src/python/ImpactX.cpp +++ b/src/python/ImpactX.cpp @@ -436,9 +436,12 @@ void init_ImpactX (py::module& m) ) .def("evolve", &ImpactX::evolve, - "Run the main simulation loop for a number of steps." + "Run the main simulation loop." ) - // TODO: step + .def("track_particles", &ImpactX::track_particles, + "Run the particle tracking simulation loop." + ) + .def("resize_mesh", &ImpactX::ResizeMesh, "Resize the mesh :py:attr:`~domain` based on the :py:attr:`~dynamic_size` and related parameters." ) diff --git a/src/python/impactx/dashboard/Toolbar/exportTemplate.py b/src/python/impactx/dashboard/Toolbar/exportTemplate.py index e58e6e02a..157c019e2 100644 --- a/src/python/impactx/dashboard/Toolbar/exportTemplate.py +++ b/src/python/impactx/dashboard/Toolbar/exportTemplate.py @@ -83,7 +83,7 @@ def input_file(): sim.lattice.extend(lattice_configuration) # Simulate -sim.evolve() +sim.track_particles() sim.finalize() """ diff --git a/src/python/impactx/dashboard/simulation.py b/src/python/impactx/dashboard/simulation.py index 057304ab1..fbf696518 100644 --- a/src/python/impactx/dashboard/simulation.py +++ b/src/python/impactx/dashboard/simulation.py @@ -67,7 +67,7 @@ def run_simulation(): sim.lattice.extend(lattice_configuration) # simulate - sim.evolve() + sim.track_particles() fig = adjusted_settings_plot(pc) fig_original = pc.plot_phasespace() diff --git a/tests/python/test_charge_deposition.py b/tests/python/test_charge_deposition.py index 3f74b00b3..4baaf79df 100755 --- a/tests/python/test_charge_deposition.py +++ b/tests/python/test_charge_deposition.py @@ -37,7 +37,7 @@ def test_charge_deposition(save_png=True): sim.init_beam_distribution_from_inputs() sim.init_lattice_elements_from_inputs() - sim.evolve() + sim.track_particles() sim.deposit_charge() diff --git a/tests/python/test_dataframe.py b/tests/python/test_dataframe.py index db73ab530..263f735d5 100644 --- a/tests/python/test_dataframe.py +++ b/tests/python/test_dataframe.py @@ -66,7 +66,7 @@ def test_df_pandas(save_png=True): sim.lattice.extend(fodo) # simulate - sim.evolve() + sim.track_particles() # check local particles df = pc.to_df(local=True) diff --git a/tests/python/test_impactx.py b/tests/python/test_impactx.py index 871746770..e2bf24959 100755 --- a/tests/python/test_impactx.py +++ b/tests/python/test_impactx.py @@ -34,7 +34,7 @@ def test_impactx_fodo_file(): sim.init_beam_distribution_from_inputs() sim.init_lattice_elements_from_inputs() - sim.evolve() + sim.track_particles() # validate the results beam = sim.particle_container() @@ -133,7 +133,7 @@ def test_impactx_nofile(): print(len(sim.lattice)) assert len(sim.lattice) > 5 - sim.evolve() + sim.track_particles() # finalize simulation sim.finalize() @@ -163,7 +163,7 @@ def test_impactx_noparticles(): with pytest.raises( RuntimeError, match="No particles found. Cannot run evolve without a beam." ): - sim.evolve() + sim.track_particles() # finalize simulation sim.finalize() @@ -231,7 +231,7 @@ def test_impactx_resting_refparticle(): RuntimeError, match="The reference particle energy is zero. Not yet initialized?", ): - sim.evolve() + sim.track_particles() # finalize simulation sim.finalize() @@ -254,7 +254,7 @@ def test_impactx_no_elements(): RuntimeError, match="Beamline lattice has zero elements. Not yet initialized?", ): - sim.evolve() + sim.track_particles() # finalize simulation sim.finalize() diff --git a/tests/python/test_particle_tiles.py b/tests/python/test_particle_tiles.py index 4460530e8..27e5e2f47 100644 --- a/tests/python/test_particle_tiles.py +++ b/tests/python/test_particle_tiles.py @@ -59,7 +59,7 @@ def test_particle_tiles(): sim.lattice.extend(fodo) # simulate - sim.evolve() + sim.track_particles() # access local particles for lvl in range(pc.finest_level + 1): diff --git a/tests/python/test_push.py b/tests/python/test_push.py index 04fde43bd..1a87ddfd7 100644 --- a/tests/python/test_push.py +++ b/tests/python/test_push.py @@ -58,7 +58,7 @@ def test_element_push(): ] sim.lattice.extend(fodo) - sim.evolve() + sim.track_particles() # Push manually through a few (unnamed) elements elements.Quad(ds=1.0, k=1.0).push(pc) diff --git a/tests/python/test_wake.py b/tests/python/test_wake.py index 658023f4f..a30827a9a 100755 --- a/tests/python/test_wake.py +++ b/tests/python/test_wake.py @@ -27,7 +27,7 @@ def test_wake(save_png=True): sim.init_grids() sim.init_beam_distribution_from_inputs() sim.init_lattice_elements_from_inputs() - sim.evolve() + sim.track_particles() sim.deposit_charge() diff --git a/tests/python/test_xopt.py b/tests/python/test_xopt.py index 2862d6bf9..f39f05042 100644 --- a/tests/python/test_xopt.py +++ b/tests/python/test_xopt.py @@ -126,7 +126,7 @@ def run(parameters: dict, write_particles=False, write_reduced=False) -> dict: sim.lattice.extend(build_lattice(parameters, write_particles=write_particles)) # run simulation - sim.evolve() + sim.track_particles() # in situ calculate the reduced beam characteristics beam = sim.particle_container()