In this post, we will look at a way of approximating deflection function of beams using Rayleigh Ritz method. I had been recently watching this (click here for youtube link) lecture series by Clayton Pettit which had been a very useful introduction to finite element methods. This is one of the assignment problems provided in that series.
Regarding the choice of language here, it is Julia but also python (through PyCall, but for sympy thatβs taken care by the SymPy package). The reason for this acrobatics is that python had issues converting singularity functions which tend to rise when analytically solving the system using Singularity method (if that sounds like gibberish, I would suggest βMachine Design, an Integrated Approach by Nortonβ for a quick brush up). I did initially intend to use Julia but the symbolics library doesnβt have all the calculus functionalities yet. Now, letβs get started!
1
2
3
usingSymPyusingPlotsusingLaTeXStrings
1
2
@varsx1x2;@varsa0a1a2a3a4a5a6;
Problem Statement
Consider the following cantilever beam.
The value for various parameters in the problem are defined as following:
1
2
3
4
5
6
7
8
E=20e6# Young's Modulus, KPaL=6# Length, mq=-45# Uniformly Distributed Load, KNmP=-100# Point Load, KNd=4# Position of UDL, mb=0.3# Width of beam, mh=0.5# Height of the beam, mIg=b*h^3/12# Moment of Inertia, m^4
0.0031249999999999997
Consider an Euler-Bernoulli beam (with the assumptions). The deflection of the beam can be obtained by solving the loading equation,
q=EI(dx12βd2yβ)
with the boundary conditions,
y(x1β=0)=0dxdyβ(x1β=0)=0
Further, there are the implicit boundary conditions, V(0β)=0,M(0β)=0,V(l+)=0,M(l+)=0 which are utilised to solve the equation analytically.
If the above equation is solved, the shear force V and bending moment M can be obtained through,
M=EI(dx12βd2yβ)V=EI(dx13βd3yβ)
Rayleigh Ritz Method
Solving the above equation becomes tedious as the complexity of the loading increases. Hence, one might often resort to approximations. Rayleigh-Ritz method is one such method of approximating the deflection equation. This can be broken down into the following steps.
Approximate the function to be solved for as a polynomial
Apply boundary conditions
Find the potential energy with this equation and minimize it by taking variations with respect to the parameters.
Solve the arising equations to find the constants. Substitute them back to get the approximate function.
Approximation function
Letβs start with the approximation of the deflection as a polynomial. Note that, the loading equation is a 4th order equation which means that our polynomial should have a minimum degree of 4. Here, we will take a polynomial of order 6 and see how it turns out.
1
2
y_approx=a0+a1*x1+a2*x1^2+a3*x1^3+a4*x1^4+a5*x1^5+a6*x1^6# polynomial of degree 6
The next step is to apply the boundary conditions on the yapproxβ. This is done below and the following values for the first two coefficients are obtained.
Note that, β(y(x1β)) is a functional which means that it takes a function yapproxβ(x1β) as input and gives a scalar as output. Our aim is to find the yapproxβ which gives the minimum value of the potential energy. In order to find that, we differentiate β with respect to each of the remaining coefficients (a2β,a3β,a4β,a5β,a6β). We solve the resulting system of equations algebraically to get the corresponding values. Note that, if we had not applied the boundary conditions initially, the coefficients a0β,a1β can also be solved this way but that wonβt gaurantee that the resulting equation will satisfy the boundary conditions.
Substituting these values back in the equation, we obtain the approximated equation for the deflection. Further, we substitute this equation in the equations for M and V to get the Mapproxβ and Vapproxβ respectively.
where, <β > indicate the singularity functions, R1β and M1β are the reaction load and moment on the fixed end. The values are substituted and the yactβ is derived below.
The corresponding Mactβ and Vactβ are also calculated.
In the plot below, we are plotting the actual and approximated y values. It can be seen that approximation conforms very well to the original function.
1
2
3
4
5
6
plot(x->y_approx.evalf(subs=Dict(x1=>x)),0,L,label="y approximate",lw=2,lc="black",title="Deflection",xlabel=L"x_1",ylabel="y in m",size=(600,200),ylim=(-0.2,0.2),axes_style=:origin)plot!(x->y_act.evalf(subs=Dict(x1=>x)),0,L,label="y actual",lw=3,ls=:dash)
Bending Moment Diagram
In the bending diagram, the approximation still seems to hold good though there seems to be a something peculiar at x1β=4 but not enough to judge without careful examination.
1
2
3
4
5
plot(x->M_approx.evalf(subs=Dict(x1=>x)),0,L,label="M approximate",lw=2,lc="black",title="Bending Moment",xlabel=L"x_1",ylabel="M in KNm",size=(600,200),ylim=(-1500,1000),axes_style=:origin)plot!(x->M_act.evalf(subs=Dict(x1=>x)),0,L,label="M actual",lw=3,ls=:dash)
Shear Force Diagram
Now, while drawing the Shear force diagram, the caveats of approximation is seen. The area under the curve remains the same (aka the bending moment) but the actual curve traced is different. The analytical solution has the discontinuity at x1β=4 mark which is smoothed out. Also, the maximum shear force predicted is slightly lower than the analytical solution.
1
2
3
4
5
plot(x->V_approx.evalf(subs=Dict(x1=>x)),0,L,label="V approximate",lw=2,lc="black",title="Shear Force",xlabel=L"x_1",ylabel="V in KN",size=(600,200),ylim=(-100,500))plot!(x->V_act.evalf(subs=Dict(x1=>x)),0,L,label="V actual",lw=3,ls=:dash)
Stress Calculations
Next, we shall take a look at the bending and shear stresses. For an Euler-Bernoulli beam, only Ο11β and Ο12β exists which are given by,
Ο11β=IMx2ββ
Ο12β=IbVQβ
where Q=b(2tββx2β)(4tβ+2x2ββ) for a rectangular cross sectioned beam.
In the following cells, the Ο11β and Ο12β actual and approximate values are plotted. Note that, if you run this in your system, the following plots may take a lot of time. This is due to sympy. A purely Julia based symbolic library would have meant lesser hassle.
Based on the comparison above, it can be seen that the stress distributions for both yactβ and yapproxβ remain the same. Hence, this can be considered as a viable approximation for the deflection function.
The entire blog post is a Jupter Notebook which can be downloaded from below. Please note that this is generated as a part of my learning experience and hence should be treated appropriately.