Last active
January 20, 2022 08:20
-
-
Save shkiefer/bc44c1e26b53396bcac7cdd8d498299a to your computer and use it in GitHub Desktop.
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
@app.long_callback( | |
Output(f'{APP_ID}_geom_rep_mesh', 'children'), | |
Output(f'{APP_ID}_geom_rep_mesh', 'colorDataRange'), | |
Output(f'{APP_ID}_results_colorbar_graph', 'figure'), | |
Output(f'{APP_ID}_mem_sene_dt_div', 'children'), | |
Input(f'{APP_ID}_solve_button', 'n_clicks'), | |
State(f'{APP_ID}_n_panels_input', 'value'), | |
State(f'{APP_ID}_w_panel_input','value'), | |
State(f'{APP_ID}_h_panel_input', 'value'), | |
State(f'{APP_ID}_nsm_input', 'value'), | |
State(f'{APP_ID}_tfs_input', 'value'), | |
State(f'{APP_ID}_k_hinge_input', 'value'), | |
State(f'{APP_ID}_dx_panel_input', 'value'), | |
State(f'{APP_ID}_tc_input', 'value'), | |
State(f'{APP_ID}_scale_input', 'value'), | |
prevent_initial_call=True, | |
running=[ | |
( | |
Output(f'{APP_ID}_solve_button', "disabled"), | |
True, | |
False | |
), | |
( | |
Output(f'{APP_ID}_progress_bar', "style"), | |
{"visibility": "visible"}, | |
{"visibility": "hidden"}, | |
), | |
], | |
progress=[ | |
Output(f'{APP_ID}_progress_bar', "value"), | |
Output(f'{APP_ID}_progress_bar', "max") | |
], | |
) | |
def dash_vtk_update_grid(set_progress, n_clicks, n_panels, panel_w, panel_h, nsm_pv, tfs, k_hinge, dx_panel, tc, scale): | |
if any([v is None for v in [n_clicks, n_panels, panel_w, panel_h, nsm_pv, tfs, k_hinge, dx_panel, tc, scale]]): | |
raise PreventUpdate | |
set_progress((str(1), str(10))) | |
res, ugrid, df_sene_mem = make_pv_array(panel_w, panel_h, n_panels=n_panels, nsm_pv=nsm_pv, tc=tc, tfs=tfs, k_hinge=k_hinge, dx_panel=dx_panel, prog=set_progress) | |
set_progress((str(8), str(10))) | |
f0 = df_sene_mem['freq'].iloc[0] | |
dof ='uZ' | |
ugrid = plot_nodal_disp(ugrid, res, scale=scale, dof=dof) | |
view_max = ugrid[dof].max() | |
view_min = ugrid[dof].min() | |
rng = [view_min, view_max] | |
fig_cb = make_colorbar(f'Z Displacement (in)<Br>Freq: {f0:0.3f}', rng) | |
mesh_state = to_mesh_state(ugrid, field_to_keep=dof) | |
set_progress((str(9), str(10))) | |
dt = dash_table.DataTable( | |
data=df_sene_mem.to_dict('records'), | |
sort_action='native', | |
columns=[ | |
{'name': 'Mode', 'id': 'mode', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.decimal_integer)}, | |
{'name': 'Frequency (Hz)', 'id': 'freq', 'type': 'numeric', 'format': Format(precision=3, scheme=Scheme.decimal)}, | |
{'name': 'TX', 'id': 'TX', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'TY', 'id': 'TY', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'TZ', 'id': 'TZ', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'RX', 'id': 'RX', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'RY', 'id': 'RY', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'RZ', 'id': 'RZ', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'SENE Hinges', 'id': 'joint', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
{'name': 'SENE Panels', 'id': 'shell', 'type': 'numeric', 'format': Format(precision=2, scheme=Scheme.percentage)}, | |
], | |
style_data_conditional=( | |
data_bars(df_sene_mem, 'TX', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'TY', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'TZ', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'RX', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'RY', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'RZ', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'joint', clr='rgb(11, 94, 215)') + | |
data_bars(df_sene_mem, 'shell', clr='rgb(11, 94, 215)') | |
), | |
) | |
set_progress((str(10), str(10))) | |
return dash_vtk.Mesh(state=mesh_state), rng, fig_cb, dt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment