-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collective Effects Config in Dashboard (#690)
* Added initial space charge UI with basic compatibility with simulation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Connected max_level and poisson_solver to simulation * prob_relative simulation functionality added * Update code structuring * rename variables * Moved input cards * code structure adjustment * Added space charge documentation * Added CSR configuration * Rename 'CSR Configuration' to 'CSR' for UI and code folder name is still called 'csrConfiguration' * Connect csr_bins to simulation * Updated UI look and minor code structure * Add initial validation for Space Charge * update simulation code & change Vcombobox to vSelect * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated default values * Format update * Minor updates * Added initial space charge UI with basic compatibility with simulation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * prob_relative simulation functionality added * Update code structuring * rename variables * Moved input cards * Added space charge documentation * Add initial validation for Space Charge * update simulation code & change Vcombobox to vSelect * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert "Added IDs to UI components" This reverts commit 4456665. * Removed duiplicated UI cards * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Formatting change and remove duplicate code * Update default n_cell * particle_shape placed in CSR * Added blocking_factor to UI, no functionality * Added blocking_factor defaults * Added blocking_factor functionality last step is to connect to simulation * Update default values for space charge * Updated prob_relative validation prob_relative values are required to decrease with increasing index * Connected blocking_factor to simulation * Add multigrid-specific numerical options No validation yet and not yet connected to simulation * Adjust UI formatting * Update export_template for space charge and csr * Updated default for blocking_factor xyz * Fixed simulation.py after merge Space charge/csr simulation content did not merge in correctly originally, this fixes it. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update validation for n_cell and blocking_factor * Updated ui format * Add csr validation csr_bins int and positive number * Update simulation station function to ensure that users cannot run a simulation when inputs have errors * connect multigrid advanced settings to simulation * add space * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7e28c8b
commit 1c3861f
Showing
8 changed files
with
682 additions
and
103 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/python/impactx/dashboard/Input/csrConfiguration/csrMain.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from trame.widgets import vuetify | ||
|
||
from ...trame_setup import setup_server | ||
from ..generalFunctions import generalFunctions | ||
|
||
server, state, ctrl = setup_server() | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Default State Variables | ||
# ----------------------------------------------------------------------------- | ||
|
||
state.csr_bins = 150 | ||
state.csr_bins_error_message = "" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
@state.change("csr_bins") | ||
def on_csr_bins_change(csr_bins, **kwargs): | ||
error_message = generalFunctions.validate_against(csr_bins, "int", ["positive"]) | ||
state.csr_bins_error_message = error_message | ||
generalFunctions.update_simulation_validation_status() | ||
|
||
|
||
# ----------------------------------------------------------------------------- | ||
# UI | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
class csrConfiguration: | ||
@staticmethod | ||
def card(): | ||
""" | ||
Creates UI content for CSR. | ||
""" | ||
|
||
with vuetify.VCard(v_show="csr", style="width: 170px;"): | ||
with vuetify.VCardTitle("CSR"): | ||
vuetify.VSpacer() | ||
vuetify.VIcon( | ||
"mdi-information", | ||
classes="ml-2", | ||
click=lambda: generalFunctions.documentation("CSR"), | ||
style="color: #00313C;", | ||
) | ||
vuetify.VDivider() | ||
with vuetify.VCardText(): | ||
with vuetify.VRow(classes="my-0"): | ||
with vuetify.VCol(classes="py-0"): | ||
vuetify.VSelect( | ||
label="Particle Shape", | ||
v_model=("particle_shape",), | ||
items=([1, 2, 3],), | ||
dense=True, | ||
) | ||
with vuetify.VRow(classes="my-0"): | ||
with vuetify.VCol(classes="py-0"): | ||
vuetify.VTextField( | ||
label="CSR Bins", | ||
v_model=("csr_bins",), | ||
error_messages=("csr_bins_error_message",), | ||
type="number", | ||
dense=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/python/impactx/dashboard/Input/space_charge_configuration/spaceChargeFunctions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from ...trame_setup import setup_server | ||
from ..generalFunctions import generalFunctions | ||
|
||
server, state, ctrl = setup_server() | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Functions | ||
# ----------------------------------------------------------------------------- | ||
|
||
|
||
class SpaceChargeFunctions: | ||
@staticmethod | ||
def validate_prob_relative_fields(index, prob_relative_value): | ||
""" | ||
This function checks specific validation requirements | ||
for prob_relative_fields. | ||
:param index: The index of the prob_relative_field modified. | ||
:param prob_relative_value: The numerical value entered by the user. | ||
:return: An error message. An empty string if there is no error. | ||
""" | ||
error_message = "" | ||
|
||
try: | ||
prob_relative_value = float(prob_relative_value) | ||
poisson_solver = state.poisson_solver | ||
|
||
if index == 0: | ||
if poisson_solver == "multigrid": | ||
if prob_relative_value < 3: | ||
error_message = "Must be greater than 3." | ||
elif poisson_solver == "fft": | ||
if prob_relative_value <= 1: | ||
error_message = "Must be greater than 1." | ||
else: | ||
previous_value = float(state.prob_relative[index - 1]) | ||
if prob_relative_value >= previous_value: | ||
error_message = ( | ||
f"Must be less than previous value ({previous_value})." | ||
) | ||
else: | ||
if prob_relative_value <= 1: | ||
error_message = "Must be greater than 1." | ||
except ValueError: | ||
error_message = "Must be a float." | ||
|
||
return error_message | ||
|
||
@staticmethod | ||
def validate_n_cell_and_blocking_factor(direction): | ||
""" | ||
Validation function for n_cell and blocking_factor parameters. | ||
""" | ||
n_cell_value = getattr(state, f"n_cell_{direction}", None) | ||
blocking_factor_value = getattr(state, f"blocking_factor_{direction}", None) | ||
|
||
n_cell_errors = generalFunctions.validate_against(n_cell_value, "int") | ||
blocking_factor_errors = generalFunctions.validate_against( | ||
blocking_factor_value, "int", ["non_zero", "positive"] | ||
) | ||
|
||
setattr(state, f"error_message_n_cell_{direction}", "; ".join(n_cell_errors)) | ||
setattr( | ||
state, | ||
f"error_message_blocking_factor_{direction}", | ||
"; ".join(blocking_factor_errors), | ||
) | ||
|
||
if not n_cell_errors and not blocking_factor_errors: | ||
n_cell_value = int(n_cell_value) | ||
blocking_factor_value = int(blocking_factor_value) | ||
if n_cell_value % blocking_factor_value != 0: | ||
setattr( | ||
state, | ||
f"error_message_n_cell_{direction}", | ||
"Must be a multiple of blocking factor.", | ||
) |
Oops, something went wrong.