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

Dashboard: Add track_envelop and track_reference #856

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/python/impactx/dashboard/Input/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DashboardDefaults:
}

INPUT_PARAMETERS = {
"tracking_mode": "Particle Tracking",
"charge_qe": -1,
"mass_MeV": 0.51099895,
"npart": 1000,
Expand Down Expand Up @@ -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",
],
}

# -------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions src/python/impactx/dashboard/Input/inputParameters/inputMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,40 @@ 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(**kwargs) -> None:
if state.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)
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",
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):
Expand Down
19 changes: 15 additions & 4 deletions src/python/impactx/dashboard/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +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": 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": lambda: sim.track_reference(ref),
}

# simulate
sim.evolve()
tracking_modes[state.tracking_mode]()

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

sim.finalize()
Loading