Skip to content

Commit

Permalink
Add more defaults and rename default variables
Browse files Browse the repository at this point in the history
  • Loading branch information
proy30 committed Dec 17, 2024
1 parent 28e2eaf commit 0314f1c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 18 deletions.
19 changes: 16 additions & 3 deletions src/python/impactx/dashboard/Input/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@ class DashboardDefaults:
Defaults for input parameters in the ImpactX dashboard.
"""

PARAMETER_VALUES = {
DEFAULTS = {
"distribution": "Waterbag",
"distribution_type": "Twiss",
"lattice": None,
"kin_energy_unit_list": ["meV", "eV", "keV", "MeV", "GeV", "TeV"],
"distribution_type_list": ["Twiss", "Quadratic"],
"poisson_solver_list": ["fft", "multigrid"],
"particle_shape_list": [1, 2, 3],
"max_level_list": [0, 1, 2, 3, 4],
}

VALUES = {
# Input Parameters
"charge_qe": -1,
"mass_MeV": 0.51099895,
Expand All @@ -12,6 +23,7 @@ class DashboardDefaults:
"bunch_charge_C": 1e-9,
"particle_shape": 2,
# Space Charge
"dynamic_size": False,
"poisson_solver": "fft",
"max_level": 0,
"n_cell": 32,
Expand All @@ -27,7 +39,7 @@ class DashboardDefaults:
}

# If parameter is not included in the dictionary, default step amount is 1.
PARAMETER_STEPS = {
STEPS = {
# Single input
"mass_MeV": 0.1,
"bunch_charge_C": 1e-11,
Expand All @@ -40,10 +52,11 @@ class DashboardDefaults:
"alpha": 0.1,
}

PARAMETER_UNITS = {
UNITS = {
# Single input
"charge_qe": "qe",
"mass_MeV": "MeV",
"kin_energy": "MeV",
"bunch_charge_C": "C",
"mlmg_absolute_tolerance": "V/m",
# Shared inputs (x,y,z)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
# Defaults
# -----------------------------------------------------------------------------

state.selectedDistribution = "Waterbag"
state.selectedDistributionType = "Twiss"
state.selectedDistribution = generalFunctions.get_default("distribution", "defaults")
state.selectedDistributionType = generalFunctions.get_default(
"distribution_type", "defaults"
)
state.selectedDistributionParameters = []
state.distributionTypeDisabled = False

Expand Down Expand Up @@ -208,7 +210,11 @@ def card():
vuetify.VSelect(
v_model=("selectedDistributionType",),
label="Type",
items=(["Twiss", "Quadratic Form"],),
items=(
generalFunctions.get_default(
"distribution_type_list", "defaults"
),
),
dense=True,
disabled=("distributionTypeDisabled",),
)
Expand Down
4 changes: 1 addition & 3 deletions src/python/impactx/dashboard/Input/generalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def documentation(section_name):

@staticmethod
def get_default(parameter, type):
parameter_type_dictionary = getattr(
DashboardDefaults, f"PARAMETER_{type.upper()}", None
)
parameter_type_dictionary = getattr(DashboardDefaults, f"{type.upper()}", None)
parameter_default = parameter_type_dictionary.get(parameter)

if parameter_default is not None:
Expand Down
10 changes: 7 additions & 3 deletions src/python/impactx/dashboard/Input/inputParameters/inputMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(self):
state.kin_energy = generalFunctions.get_default("kin_energy", "values")
state.kin_energy_MeV = state.kin_energy
state.bunch_charge_C = generalFunctions.get_default("bunch_charge_C", "values")
state.kin_energy_unit = "MeV"
state.old_kin_energy_unit = "MeV"
state.kin_energy_unit = generalFunctions.get_default("kin_energy", "units")
state.old_kin_energy_unit = generalFunctions.get_default("kin_energy", "units")
state.charge_qe = generalFunctions.get_default("charge_qe", "values")
state.mass_MeV = generalFunctions.get_default("mass_MeV", "values")

Expand Down Expand Up @@ -175,7 +175,11 @@ def card(self):
vuetify.VSelect(
v_model=("kin_energy_unit",),
label="Unit",
items=(["meV", "eV", "keV", "MeV", "GeV", "TeV"],),
items=(
generalFunctions.get_default(
"kin_energy_unit_list", "defaults"
),
),
change=(ctrl.kin_energy_unit_change, "[$event]"),
dense=True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
# Default
# -----------------------------------------------------------------------------

state.selectedLattice = None
state.selectedLattice = generalFunctions.get_default("lattice", "defaults")
state.selectedLatticeList = []
state.nsliceDefaultValue = None
state.nsliceDefaultValue = generalFunctions.get_default("n_slice", "values")

# -----------------------------------------------------------------------------
# Main Functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Default
# -----------------------------------------------------------------------------

state.dynamic_size = False
state.dynamic_size = generalFunctions.get_default("dynamic_size", "values")
state.max_level = generalFunctions.get_default("max_level", "values")
state.particle_shape = generalFunctions.get_default("particle_shape", "values")
state.poisson_solver = generalFunctions.get_default("poisson_solver", "values")
Expand Down Expand Up @@ -213,22 +213,34 @@ def card():
vuetify.VSelect(
label="Poisson Solver",
v_model=("poisson_solver",),
items=(["multigrid", "fft"],),
items=(
generalFunctions.get_default(
"poisson_solver_list", "defaults"
),
),
dense=True,
hide_details=True,
)
with vuetify.VCol(cols=4, classes="py-0"):
vuetify.VSelect(
label="Particle Shape",
v_model=("particle_shape",),
items=([1, 2, 3],),
items=(
generalFunctions.get_default(
"particle_shape_list", "defaults"
),
),
dense=True,
)
with vuetify.VCol(cols=3, classes="py-0"):
vuetify.VSelect(
label="Max Level",
v_model=("max_level",),
items=([0, 1, 2, 3, 4],),
items=(
generalFunctions.get_default(
"max_level_list", "defaults"
),
),
dense=True,
)
with vuetify.VCol(classes="pa-0"):
Expand Down

0 comments on commit 0314f1c

Please sign in to comment.