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'), |
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
dbc.Row([ | |
dbc.Col([ | |
html.Progress(id=f'{APP_ID}_progress_bar', value='0', max='10', style={'visibility':"hidden"}), | |
]) | |
]), | |
dbc.Row([ | |
dbc.Col([ | |
html.Div( | |
style={"width": "100%", "height": "60vh"}, | |
children=[ |
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.layout = dbc.Container([ | |
html.H1('PyAnsys MAPDL in a Dash App', className="mt-3"), | |
html.P('Design your solar array! (not really, dont use these assumed properties)'), | |
dbc.Row([ | |
dbc.Col([ | |
dbc.Form([ | |
dbc.Label('Number of Panels', html_for=f'{APP_ID}_n_panels_input'), | |
dbc.Input(id=f'{APP_ID}_n_panels_input', type="number", min=0, max=10, step=1, value=2) | |
]) | |
]), |
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
def make_pv_array(panel_w, panel_h, n_panels=2, nsm_pv = 0.002, tc=0.25, tfs=0.03, k_hinge=10e3, dx_panel=2.): | |
mapdl = launch_mapdl(override=True, license_type="ansys", cleanup_on_exit=True) | |
mapdl.clear() | |
mapdl.prep7() | |
mapdl.units("BIN") | |
mapdl.csys(kcn=0) | |
# material property definitions ommitted, See github repo for full file. | |
# create geometry (areas) |
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
# %% | |
import pandas as pd | |
from ansys.mapdl.core import launch_mapdl | |
mapdl = launch_mapdl(override=True, license_type="ansys", cleanup_on_exit=True) | |
mapdl.clear() | |
mapdl.prep7() | |
mapdl.units("BIN") | |
mapdl.csys(kcn=0) |
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.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}_results_min_max_dt', 'data'), | |
Input(f'{APP_ID}_plot_button', 'n_clicks'), | |
State(f'{APP_ID}_example_dropdown', 'value'), | |
State(f'{APP_ID}_example_result_dropdown','value'), | |
State(f'{APP_ID}_example_comp_dropdown', 'value'), | |
State(f'{APP_ID}_example_tf_dropdown', 'value') |
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.callback( | |
Output(f'{APP_ID}_example_tf_dropdown', 'options'), | |
Output(f'{APP_ID}_example_tf_dropdown', 'value'), | |
Output(f'{APP_ID}_example_result_dropdown','options'), | |
Output(f'{APP_ID}_example_result_dropdown','value'), | |
Input(f'{APP_ID}_example_dropdown', 'value') | |
) | |
def dash_vtk_update_result_options(example_name): | |
ctx = dash.callback_context | |
if not ctx.triggered: |
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
dbc.Row([ | |
dbc.Col([ | |
dbc.Label('Select Example', html_for="dropdown"), | |
dcc.Dropdown( | |
id=f'{APP_ID}_example_dropdown', | |
options=[ | |
{'label': 'simple_bar', 'value': 'simple_bar'}, | |
{'label': 'msup_transient', 'value': 'msup_transient'}, | |
{'label': 'static', 'value': 'static'}, | |
], |
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
def get_grid_with_field(meshed_region, field): | |
name = '_'.join(field.name.split("_")[:-1]) | |
location = field.location | |
if location == dpf.locations.nodal: | |
mesh_location = meshed_region.nodes | |
elif location == dpf.locations.elemental: | |
mesh_location = meshed_region.elements | |
else: | |
raise ValueError( | |
"Only elemental or nodal location are supported for plotting." |
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
# %% | |
# 1st result in results set | |
res_idx = 0 | |
# last available 'time' index | |
tf_idx = len(tfs) - 1 | |
# first component (if more than 1) | |
comp_idx = 0 | |
result_info = model.metadata.result_info | |
res = result_info.available_results[res_idx] |
NewerOlder