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

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 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
)

fig.add_trace(
    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,
)

fig.add_trace(
    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,
)

fig.add_trace(
    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",
    range=min_max_factored(vvector, plotpadfactor),
	autorange=False
)

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

fig['layout']['yaxis3'].update(
    # title_text="Deflection",
    range=min_max_factored(mvector, plotpadfactor),
	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,
    margin=dict(l=40, r=40, b=60, t=120, pad=10),
    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)

Leave a Reply

Your email address will not be published. Required fields are marked *