From 2b9521cb5f0e86ff032635cc1e4553e89f69d417 Mon Sep 17 00:00:00 2001 From: Parthib Roy Date: Sat, 8 Feb 2025 20:19:54 -0800 Subject: [PATCH 1/5] Add trcking modes to dashboard ui and setup initial connection to sim --- src/python/impactx/dashboard/Input/defaults.py | 6 ++++++ .../impactx/dashboard/Input/inputParameters/inputMain.py | 4 ++++ src/python/impactx/dashboard/simulation.py | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/python/impactx/dashboard/Input/defaults.py b/src/python/impactx/dashboard/Input/defaults.py index 3bdb3f29b..2f8bdfdb1 100644 --- a/src/python/impactx/dashboard/Input/defaults.py +++ b/src/python/impactx/dashboard/Input/defaults.py @@ -36,6 +36,7 @@ class DashboardDefaults: } INPUT_PARAMETERS = { + "tracking_mode": "Particle Tracking", "charge_qe": -1, "mass_MeV": 0.51099895, "npart": 1000, @@ -85,6 +86,11 @@ class DashboardDefaults: "poisson_solver_list": ["fft", "multigrid"], "particle_shape_list": [1, 2, 3], "max_level_list": [0, 1, 2, 3, 4], + "tracking_mode_list": [ + "Particle Tracking", + "Envelope Tracking", + "Reference Tracking", + ], } # ------------------------------------------------------------------------- diff --git a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py index 2bd23e080..495a17032 100644 --- a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py +++ b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py @@ -33,6 +33,10 @@ def card_content(self): CardComponents.input_header(self.HEADER_NAME) with vuetify.VCardText(**self.CARD_TEXT_OVERFLOW): with vuetify.VRow(**self.ROW_STYLE): + with vuetify.VCol(cols=5.5): + InputComponents.select( + label="Tracking Mode", + ) with vuetify.VCol(cols="auto"): vuetify.VCheckbox( label="Space Charge", diff --git a/src/python/impactx/dashboard/simulation.py b/src/python/impactx/dashboard/simulation.py index d375a714f..3ac87722e 100644 --- a/src/python/impactx/dashboard/simulation.py +++ b/src/python/impactx/dashboard/simulation.py @@ -71,11 +71,16 @@ def run_simulation(): sim.add_particles(bunch_charge_C, distribution, npart) lattice_configuration = lattice_elements() - sim.lattice.extend(lattice_configuration) + tracking_modes = { + "Particle Tracking": sim.track_particles, + "Envelope Tracking": sim.track_envelope, + "Reference Tracking": sim.track_reference, + } + # simulate - sim.evolve() + tracking_modes[state.tracking_mode]() generate_phase_space(pc) From a1f1c64d1069f70f74bfcb2ca9ae0826cb640208 Mon Sep 17 00:00:00 2001 From: Parthib Roy Date: Thu, 20 Feb 2025 18:35:13 -0800 Subject: [PATCH 2/5] fix functionality --- src/python/impactx/dashboard/simulation.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/python/impactx/dashboard/simulation.py b/src/python/impactx/dashboard/simulation.py index 3ac87722e..8be286d45 100644 --- a/src/python/impactx/dashboard/simulation.py +++ b/src/python/impactx/dashboard/simulation.py @@ -68,20 +68,26 @@ def run_simulation(): ) distribution = distribution_parameters() - sim.add_particles(bunch_charge_C, distribution, npart) lattice_configuration = lattice_elements() sim.lattice.extend(lattice_configuration) tracking_modes = { - "Particle Tracking": sim.track_particles, - "Envelope Tracking": sim.track_envelope, + "Particle Tracking": lambda: ( + sim.add_particles(bunch_charge_C, distribution, npart), + sim.track_particles(), + ), + "Envelope Tracking": lambda: ( + sim.init_envelope(ref, distribution), + sim.track_envelope(), + ), "Reference Tracking": sim.track_reference, } # simulate tracking_modes[state.tracking_mode]() - generate_phase_space(pc) + if state.tracking_mode == "Particle Tracking": + generate_phase_space(pc) sim.finalize() From 1a1bc7e9cbea1cc1a202c5474f3e473fc293877e Mon Sep 17 00:00:00 2001 From: Parthib Roy Date: Thu, 20 Feb 2025 19:13:36 -0800 Subject: [PATCH 3/5] Handle selection of collective effects based on tracking_mode selection --- .../dashboard/Input/inputParameters/inputMain.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py index 495a17032..fc0bcdbc1 100644 --- a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py +++ b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py @@ -28,6 +28,18 @@ def on_kin_energy_unit_change(**kwargs) -> None: if state.kin_energy_on_ui != 0: InputFunctions.update_kin_energy_sim_value() + @state.change("tracking_mode") + def on_tracking_mode_change(tracking_mode, **kwargs) -> None: + if tracking_mode in ("Envelope Tracking", "Reference Tracking"): + state.space_charge = False + state.csr = False + + state.disable_space_charge = True + state.disable_csr = True + else: + state.disable_space_charge = False + state.disable_csr = False + def card_content(self): with vuetify.VCard(style=self.collapsable): CardComponents.input_header(self.HEADER_NAME) @@ -42,12 +54,14 @@ def card_content(self): label="Space Charge", v_model=("space_charge", False), dense=True, + disabled=("disable_space_charge",), ) with vuetify.VCol(cols="auto"): vuetify.VCheckbox( label="CSR", v_model=("csr", False), dense=True, + disabled=("disable_csr",), ) with vuetify.VRow(**self.ROW_STYLE): with vuetify.VCol(cols=6): From b6378f93d6bda69b90db2d176407d729b8c7b79a Mon Sep 17 00:00:00 2001 From: Parthib Roy Date: Mon, 24 Feb 2025 17:14:13 -0800 Subject: [PATCH 4/5] add ref argument in track_reference --- src/python/impactx/dashboard/simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/impactx/dashboard/simulation.py b/src/python/impactx/dashboard/simulation.py index 8be286d45..4368983b3 100644 --- a/src/python/impactx/dashboard/simulation.py +++ b/src/python/impactx/dashboard/simulation.py @@ -81,7 +81,7 @@ def run_simulation(): sim.init_envelope(ref, distribution), sim.track_envelope(), ), - "Reference Tracking": sim.track_reference, + "Reference Tracking": lambda: sim.track_reference(ref), } # simulate From 1b632ed8a6d99bdbabab92fc86318ee944e8afcd Mon Sep 17 00:00:00 2001 From: Parthib Roy Date: Mon, 24 Feb 2025 17:27:44 -0800 Subject: [PATCH 5/5] fix --- .../impactx/dashboard/Input/inputParameters/inputMain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py index fc0bcdbc1..0cabe19d1 100644 --- a/src/python/impactx/dashboard/Input/inputParameters/inputMain.py +++ b/src/python/impactx/dashboard/Input/inputParameters/inputMain.py @@ -29,8 +29,8 @@ def on_kin_energy_unit_change(**kwargs) -> None: InputFunctions.update_kin_energy_sim_value() @state.change("tracking_mode") - def on_tracking_mode_change(tracking_mode, **kwargs) -> None: - if tracking_mode in ("Envelope Tracking", "Reference Tracking"): + def on_tracking_mode_change(**kwargs) -> None: + if state.tracking_mode in ("Envelope Tracking", "Reference Tracking"): state.space_charge = False state.csr = False