Skip to content

Commit

Permalink
fix functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
proy30 committed Feb 21, 2025
1 parent c3f91ce commit 597789f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/python/impactx/dashboard/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ 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,
}

Expand All @@ -100,11 +105,12 @@ def run_simulation():
fig = adjusted_settings_plot(pc)
ctrl.matplotlib_figure_update(fig)

fig_original = pc.plot_phasespace()
if state.tracking_mode == "Particle Tracking":
fig_original = pc.plot_phasespace()

if fig_original is not None:
image_base64 = fig_to_base64(fig_original)
state.phase_space_png = f"data:image/png;base64, {image_base64}"
if fig_original is not None:
image_base64 = fig_to_base64(fig_original)
state.phase_space_png = f"data:image/png;base64, {image_base64}"

sim.finalize()

Expand Down

0 comments on commit 597789f

Please sign in to comment.