Structural Analysis, Finite Difference Method, Pythonista, and Plotly Oct 2020

Structural Analysis with Plotly
I built a short presentation to demonstrate using the finite difference method to analyze a beam.

I used Pythonista and Plotly, both on an iPhone, to perform the analysis and to produce the graphs.

A special thank you to Dr. C. V. G. Vallabhan
The finite difference method used, and the example problem solved, are both taken from my class notes at Texas Tech University.

https://www.amazon.com/Finite-Element-Method-Engineers-Practice/dp/1842655531

Beam Problem β Hand Calculation

PDF LINK β beam analysis β hand calculations

The 5 page calculation in the PDF was done in 1983. The quidiagonal matrix solution was probably done with an HP-41 calculator program.

Beam Problem β Plotly Graph

LIVE LINK to HTML PAGE β using Plotly

The Plotly graph shows deflections, shears, and moments in the beam. Feel free to manipulate the graph elements.

This web page stands alone; once the web page is generated, it no longer needs Python or Plotly.

Click the βhomeβ icon to restore the graphs to the original settings.

Screenshot β Plotly Graph

DSM Screenshot

Plotly β Python code

```plotpadfactor = 0.25

# xvector β x positions
# vvector β deflections
# svector β shears
# mvector β moments

# convert these 2D arrays to vectors
xvector = x_array[1:14, 0]
vvector = v_array[1:14, 0]

svector = shear[1:14]
mvector = moment[1:14]

fig = make_subplots(
rows=3,
cols=1,
shared_xaxes=True,
subplot_titles=("Deflection", "Shear", "Moment"),
vertical_spacing=0.12
)

go.Scatter(
x=xvector,
y=vvector,
name="Deflection",
text=min_max_filter(vvector, 3),
# texttemplate="%{y:.3f}",
mode="lines+markers+text",
textposition="top center",
hovertemplate="Deflection: %{y:.3f}" + "
x: %{x}",
),
row=1,
col=1,
)

go.Scatter(
x=xvector,
y=svector,
name="Shear",
text="",
texttemplate="%{y:.1f}",
mode="lines+markers+text",
textposition="top center",
hovertemplate="Shear: %{y:.2f}" + "
x: %{x}",
),
row=2,
col=1,
)

go.Scatter(
x=xvector,
y=mvector,
name="Moment",
text="",
texttemplate="%{y:.1f}",
mode="lines+markers+text",
textposition="top center",
hovertemplate="Moment: %{y:.2f}" + "
x: %{x}",
),
row=3,
col=1,
)

fig['layout']['yaxis1'].update(
# title_text="Deflection",
autorange=False
)

fig['layout']['yaxis2'].update(
# title_text="Deflection",
autorange=False
)

fig['layout']['yaxis3'].update(
# title_text="Deflection",
autorange=False
)

fig['layout']['yaxis1'].update(
zeroline=True, zerolinewidth=2, zerolinecolor='sandybrown')

fig['layout']['yaxis2'].update(
zeroline=True, zerolinewidth=2, zerolinecolor='sandybrown')

fig['layout']['yaxis3'].update(
zeroline=True, zerolinewidth=2, zerolinecolor='sandybrown')

fig.update_layout(
autosize=False,
width=500,
height=700,
paper_bgcolor="linen",
hoverlabel=dict(bgcolor="lightyellow"),
title_text="Beam Analysis",
showlegend=False
)

fig['layout']['annotations'][0].update(x=0.10)
fig['layout']['annotations'][1].update(x=0.10)
fig['layout']['annotations'][2].update(x=0.10)

# fig['layout']['annotations'][2].update(x=0.15, y=0.05	)

# fig.update_layout(hovermode='x unified')

# fig.show()
fig.write_html("num_method.html", auto_open=True)
```