From e326fb8df7a374f079f19bf22e5dbc8ff281eaea Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 3 Feb 2024 15:16:13 -0800 Subject: [PATCH] Python Examples: Finalize Sim (#519) As in the Python tests, run explicitly `sim.finalize()` for a controlled and clean shutdown. This also stops and prints the tiny profiler table. --- examples/alignment/run_alignment.py | 3 +++ examples/aperture/run_aperture.py | 3 +++ examples/apochromatic/run_apochromatic.py | 3 +++ examples/apochromatic/run_apochromatic_pl.py | 3 +++ examples/cfbend/run_cfbend.py | 3 +++ examples/cfbend/run_cfbend_madx.py | 3 +++ examples/cfchannel/run_cfchannel.py | 3 +++ examples/cfchannel/run_cfchannel_10nC.py | 3 +++ examples/chicane/run_chicane.py | 3 +++ examples/chicane/run_chicane_madx.py | 3 +++ examples/compression/run_compression.py | 3 +++ examples/cyclotron/run_cyclotron.py | 3 +++ examples/epac2004_benchmarks/run_bithermal.py | 3 +++ examples/epac2004_benchmarks/run_fodo_rf_SC.py | 3 +++ examples/epac2004_benchmarks/run_thermal.py | 3 +++ examples/expanding_beam/run_expanding.py | 3 +++ examples/fodo/run_fodo.py | 3 +++ examples/fodo/run_fodo_madx.py | 3 +++ examples/fodo/run_fodo_programmable.py | 3 +++ examples/fodo_chromatic/run_fodo_chr.py | 3 +++ examples/fodo_rf/run_fodo_rf.py | 3 +++ examples/iota_lattice/run_iotalattice.py | 3 +++ examples/iota_lattice/run_iotalattice_sdep.py | 3 +++ examples/iota_lens/run_iotalens.py | 3 +++ examples/iota_lens/run_iotalens_sdep.py | 3 +++ examples/kicker/run_hvkicker_madx.py | 3 +++ examples/kicker/run_kicker.py | 3 +++ examples/kicker/run_kicker_madx.py | 3 +++ examples/kurth/run_kurth_10nC_periodic.py | 3 +++ examples/kurth/run_kurth_periodic.py | 3 +++ examples/multipole/run_multipole.py | 3 +++ examples/positron_channel/run_positron.py | 3 +++ examples/pytorch_surrogate_model/run_ml_surrogate.py | 3 +++ examples/quadrupole_softedge/run_quadrupole_softedge.py | 3 +++ examples/rfcavity/run_rfcavity.py | 3 +++ examples/rotation/run_rotation.py | 3 +++ examples/solenoid/run_solenoid.py | 3 +++ examples/solenoid/run_solenoid_madx.py | 3 +++ examples/solenoid_softedge/run_solenoid_softedge.py | 3 +++ examples/thin_dipole/run_thin_dipole.py | 3 +++ 40 files changed, 120 insertions(+) diff --git a/examples/alignment/run_alignment.py b/examples/alignment/run_alignment.py index 643743566..a4fb672cb 100755 --- a/examples/alignment/run_alignment.py +++ b/examples/alignment/run_alignment.py @@ -57,3 +57,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/aperture/run_aperture.py b/examples/aperture/run_aperture.py index 952e801aa..2cf30dc51 100755 --- a/examples/aperture/run_aperture.py +++ b/examples/aperture/run_aperture.py @@ -62,3 +62,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/apochromatic/run_apochromatic.py b/examples/apochromatic/run_apochromatic.py index 32e800144..7a80c1a7d 100644 --- a/examples/apochromatic/run_apochromatic.py +++ b/examples/apochromatic/run_apochromatic.py @@ -71,3 +71,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/apochromatic/run_apochromatic_pl.py b/examples/apochromatic/run_apochromatic_pl.py index 95b5ee011..0a564a9bd 100644 --- a/examples/apochromatic/run_apochromatic_pl.py +++ b/examples/apochromatic/run_apochromatic_pl.py @@ -109,3 +109,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/cfbend/run_cfbend.py b/examples/cfbend/run_cfbend.py index f28a11a1d..6871fda46 100644 --- a/examples/cfbend/run_cfbend.py +++ b/examples/cfbend/run_cfbend.py @@ -61,3 +61,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/cfbend/run_cfbend_madx.py b/examples/cfbend/run_cfbend_madx.py index 9be91c3c1..4cc2bb3ba 100755 --- a/examples/cfbend/run_cfbend_madx.py +++ b/examples/cfbend/run_cfbend_madx.py @@ -48,3 +48,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/cfchannel/run_cfchannel.py b/examples/cfchannel/run_cfchannel.py index 98b1ccc46..cfc4d480a 100755 --- a/examples/cfchannel/run_cfchannel.py +++ b/examples/cfchannel/run_cfchannel.py @@ -55,3 +55,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/cfchannel/run_cfchannel_10nC.py b/examples/cfchannel/run_cfchannel_10nC.py index 57cb1fde4..c782150ac 100755 --- a/examples/cfchannel/run_cfchannel_10nC.py +++ b/examples/cfchannel/run_cfchannel_10nC.py @@ -60,3 +60,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/chicane/run_chicane.py b/examples/chicane/run_chicane.py index 6163169e1..5bbb0431e 100644 --- a/examples/chicane/run_chicane.py +++ b/examples/chicane/run_chicane.py @@ -78,3 +78,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/chicane/run_chicane_madx.py b/examples/chicane/run_chicane_madx.py index fae2ead88..07e2b7b5c 100755 --- a/examples/chicane/run_chicane_madx.py +++ b/examples/chicane/run_chicane_madx.py @@ -48,3 +48,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/compression/run_compression.py b/examples/compression/run_compression.py index f2c19cf8b..d9cb32ff8 100644 --- a/examples/compression/run_compression.py +++ b/examples/compression/run_compression.py @@ -58,3 +58,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/cyclotron/run_cyclotron.py b/examples/cyclotron/run_cyclotron.py index 5b251b3f4..834e258ed 100755 --- a/examples/cyclotron/run_cyclotron.py +++ b/examples/cyclotron/run_cyclotron.py @@ -64,3 +64,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/epac2004_benchmarks/run_bithermal.py b/examples/epac2004_benchmarks/run_bithermal.py index 26dda7849..59e4f1b0d 100755 --- a/examples/epac2004_benchmarks/run_bithermal.py +++ b/examples/epac2004_benchmarks/run_bithermal.py @@ -66,3 +66,6 @@ # run simulation sim.evolve() + +# 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 9f15b8b1b..828539a17 100755 --- a/examples/epac2004_benchmarks/run_fodo_rf_SC.py +++ b/examples/epac2004_benchmarks/run_fodo_rf_SC.py @@ -197,3 +197,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/epac2004_benchmarks/run_thermal.py b/examples/epac2004_benchmarks/run_thermal.py index d713b5928..ff72cc7d3 100755 --- a/examples/epac2004_benchmarks/run_thermal.py +++ b/examples/epac2004_benchmarks/run_thermal.py @@ -64,3 +64,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/expanding_beam/run_expanding.py b/examples/expanding_beam/run_expanding.py index 2fb300968..4d5b72301 100755 --- a/examples/expanding_beam/run_expanding.py +++ b/examples/expanding_beam/run_expanding.py @@ -59,3 +59,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/fodo/run_fodo.py b/examples/fodo/run_fodo.py index 65d9a4b29..85762e909 100755 --- a/examples/fodo/run_fodo.py +++ b/examples/fodo/run_fodo.py @@ -67,3 +67,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/fodo/run_fodo_madx.py b/examples/fodo/run_fodo_madx.py index 52079c10d..0513d81f3 100755 --- a/examples/fodo/run_fodo_madx.py +++ b/examples/fodo/run_fodo_madx.py @@ -49,3 +49,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/fodo/run_fodo_programmable.py b/examples/fodo/run_fodo_programmable.py index 1af61bbdb..dc79dc23e 100755 --- a/examples/fodo/run_fodo_programmable.py +++ b/examples/fodo/run_fodo_programmable.py @@ -172,3 +172,6 @@ def my_ref_drift(pge, refpart): # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/fodo_chromatic/run_fodo_chr.py b/examples/fodo_chromatic/run_fodo_chr.py index 7d45152fc..e6be31c1e 100755 --- a/examples/fodo_chromatic/run_fodo_chr.py +++ b/examples/fodo_chromatic/run_fodo_chr.py @@ -67,3 +67,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/fodo_rf/run_fodo_rf.py b/examples/fodo_rf/run_fodo_rf.py index 125146d39..372551515 100644 --- a/examples/fodo_rf/run_fodo_rf.py +++ b/examples/fodo_rf/run_fodo_rf.py @@ -66,3 +66,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/iota_lattice/run_iotalattice.py b/examples/iota_lattice/run_iotalattice.py index 4cdbcc349..373943956 100644 --- a/examples/iota_lattice/run_iotalattice.py +++ b/examples/iota_lattice/run_iotalattice.py @@ -122,3 +122,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/iota_lattice/run_iotalattice_sdep.py b/examples/iota_lattice/run_iotalattice_sdep.py index 823ae5f1d..407b3dffc 100644 --- a/examples/iota_lattice/run_iotalattice_sdep.py +++ b/examples/iota_lattice/run_iotalattice_sdep.py @@ -218,3 +218,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/iota_lens/run_iotalens.py b/examples/iota_lens/run_iotalens.py index d47bbbf70..b91faa5d8 100644 --- a/examples/iota_lens/run_iotalens.py +++ b/examples/iota_lens/run_iotalens.py @@ -56,3 +56,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/iota_lens/run_iotalens_sdep.py b/examples/iota_lens/run_iotalens_sdep.py index ab6739150..65bb44785 100644 --- a/examples/iota_lens/run_iotalens_sdep.py +++ b/examples/iota_lens/run_iotalens_sdep.py @@ -92,3 +92,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/kicker/run_hvkicker_madx.py b/examples/kicker/run_hvkicker_madx.py index 01945d345..62175c285 100644 --- a/examples/kicker/run_hvkicker_madx.py +++ b/examples/kicker/run_hvkicker_madx.py @@ -48,3 +48,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/kicker/run_kicker.py b/examples/kicker/run_kicker.py index 6aa098547..7493df0f2 100644 --- a/examples/kicker/run_kicker.py +++ b/examples/kicker/run_kicker.py @@ -56,3 +56,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/kicker/run_kicker_madx.py b/examples/kicker/run_kicker_madx.py index 973e77625..bbbdc47c3 100644 --- a/examples/kicker/run_kicker_madx.py +++ b/examples/kicker/run_kicker_madx.py @@ -48,3 +48,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/kurth/run_kurth_10nC_periodic.py b/examples/kurth/run_kurth_10nC_periodic.py index e1b462479..7fe416847 100755 --- a/examples/kurth/run_kurth_10nC_periodic.py +++ b/examples/kurth/run_kurth_10nC_periodic.py @@ -54,3 +54,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/kurth/run_kurth_periodic.py b/examples/kurth/run_kurth_periodic.py index bb60c4d5a..b7fe64ae2 100755 --- a/examples/kurth/run_kurth_periodic.py +++ b/examples/kurth/run_kurth_periodic.py @@ -52,3 +52,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/multipole/run_multipole.py b/examples/multipole/run_multipole.py index 9c6e70abc..07e91166e 100644 --- a/examples/multipole/run_multipole.py +++ b/examples/multipole/run_multipole.py @@ -57,3 +57,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/positron_channel/run_positron.py b/examples/positron_channel/run_positron.py index 58c1f0beb..7a1f3b5fd 100755 --- a/examples/positron_channel/run_positron.py +++ b/examples/positron_channel/run_positron.py @@ -69,3 +69,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/pytorch_surrogate_model/run_ml_surrogate.py b/examples/pytorch_surrogate_model/run_ml_surrogate.py index 1de19c005..aa1a15cbd 100644 --- a/examples/pytorch_surrogate_model/run_ml_surrogate.py +++ b/examples/pytorch_surrogate_model/run_ml_surrogate.py @@ -265,3 +265,6 @@ def surrogate_push(self, pc, step): sim.lattice.extend([monitor]) sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/quadrupole_softedge/run_quadrupole_softedge.py b/examples/quadrupole_softedge/run_quadrupole_softedge.py index db2598cde..81753f104 100755 --- a/examples/quadrupole_softedge/run_quadrupole_softedge.py +++ b/examples/quadrupole_softedge/run_quadrupole_softedge.py @@ -76,3 +76,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/rfcavity/run_rfcavity.py b/examples/rfcavity/run_rfcavity.py index 5d9ec9b2b..87d66f800 100755 --- a/examples/rfcavity/run_rfcavity.py +++ b/examples/rfcavity/run_rfcavity.py @@ -139,3 +139,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/rotation/run_rotation.py b/examples/rotation/run_rotation.py index 5a3247a45..945a60d7a 100644 --- a/examples/rotation/run_rotation.py +++ b/examples/rotation/run_rotation.py @@ -57,3 +57,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/solenoid/run_solenoid.py b/examples/solenoid/run_solenoid.py index bd91a4f31..e1630569e 100755 --- a/examples/solenoid/run_solenoid.py +++ b/examples/solenoid/run_solenoid.py @@ -56,3 +56,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/solenoid/run_solenoid_madx.py b/examples/solenoid/run_solenoid_madx.py index da8af86a1..f241e79d0 100755 --- a/examples/solenoid/run_solenoid_madx.py +++ b/examples/solenoid/run_solenoid_madx.py @@ -45,3 +45,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/solenoid_softedge/run_solenoid_softedge.py b/examples/solenoid_softedge/run_solenoid_softedge.py index ff6877f20..27b3efb12 100755 --- a/examples/solenoid_softedge/run_solenoid_softedge.py +++ b/examples/solenoid_softedge/run_solenoid_softedge.py @@ -137,3 +137,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize() diff --git a/examples/thin_dipole/run_thin_dipole.py b/examples/thin_dipole/run_thin_dipole.py index 8bfa92153..446805f19 100755 --- a/examples/thin_dipole/run_thin_dipole.py +++ b/examples/thin_dipole/run_thin_dipole.py @@ -64,3 +64,6 @@ # run simulation sim.evolve() + +# clean shutdown +sim.finalize()