






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Finite Element Analysis; Subject: Aerospace Engineering; University: University of Illinois - Urbana-Champaign; Term: Spring 2009;
Typology: Assignments
1 / 11
This page cannot be seen from the preview
Don't miss anything!







num(i)=(eta(i)(1-eta(i)))/10;%Num soln end plot(eta,exact); hold; plot(eta,num); plot(eta,exact,'b-',eta,num,'go','linewidth',2) % plot 2 solutions xlabel 'eta-x/L' ylabel 'EAu(x)/(PoL^2)' title 'Rayleigh-Ritz method' legend('exact','numerical')
% The bar stiffness is E % The BC are w(0)=0, w'(0)=0, EIw''(L)=0 and EIw'''(L)=0. % The basis functions are of the form: fi(x)=x^(i+1) % u(x)={f} % The code builds the linear system % Kq=R % where % Kij=integral_from_0_to_L(EAf''if''j)dx % q is the vector with the unknown qi coefficients % Ri=-Pointegral_from_L/2_to_L(fi dx) format long e; % increase the precision of numbers clc % clears the command window of matlab clear % clears the defined variables in the workspace % First initialize the geometrical and material parameters E=1; % bar stiffness (in Pa) - can be set to 1 as we need to plot the dimensionless values L=1; % bar length (in m) - can be set to 1 as we need to plot the dimensionless values Po=1; % distributed load (in N/m) - can be set to 1 as we need to plot the dimensionless values I=1; % moment of inertia (in m^4) - can be set to 1 as we need to plot the dimensionless values N=input(' enter the number of polynomial basis functions') % initialize the solution matrix and vectors K=zeros(N,N); R=zeros(N,1); q=zeros(N,1); % Build the matrix K and RHS vector R for i=1:N % loop over rows for j=1:N % loop over columns K(i,j)=EIij(i+1)(j+1)((L^(i+j-1))/(i+j-1)); end R(i)=(-Po/(i+2))((L^(i+2))-((L/2)^(i+2))); end % Solve linear system q=inv(K)R; % Post-processing qaux=zeros(N+1,1); % create auxiliary vector with polynomial % coefficients to use command 'polyval' below for j=1:N qaux(j)=q(N+1-j); end x=linspace(0,1,100); % create x/L vector for plotting for i=1:1: yex(i)=(((-1/24)((x(i)-0.5)^4)heaviside(x(i)-0.5))+((1/12)(x(i)^3))- ((3/16)(x(i)^2)))((PoL^4)/(EI)); % exact solution E=I=Po=L= ynum(i)=(polyval(qaux,((x(i)L)))(x(i)))((PoL^4)/EI); % numerical soln end plot(x,yex,'b-',x,ynum,'go','linewidth',2) % plot 2 solutions xlabel 'x/L' ylabel 'EIu(x)/(Po*L^4)' title 'Rayleigh-Ritz method' legend('exact','numerical')
% Solve linear system q=inv(K)R; % Post-processing qaux=zeros(N+1,1); % create auxiliary vector with polynomial % coefficients to use command 'polyval' below for j=1:N qaux(j)=q(N+1-j); end x=linspace(0,1,100); % create x/L vector for plotting %eta=P/(qoL); % non-dimensional parameter for i=1:1: yex(i)=(((-1/24)((x(i)-0.5)^4)heaviside(x(i)-0.5))+((1/12)(x(i)^3))- ((3/16)(x(i)^2)))((PoL^4)/(EI)); % exact solution E=I=Po=L= ynum(i)=(polyval(qaux,((x(i)L)))(x(i)))((PoL^4)/EI); % numerical soln end beam_tip_ex(N)=yex(100); beam_tip_num(N)=ynum(100); error(N)=abs(beam_tip_ex(N)-beam_tip_num(N)); Ni(N)=N;%variable just used for plotting purposes end semilogy(Ni,error) %Plot the semilog error plot xlabel 'N(1 to 10)' ylabel 'Abs Error (Exact-Num)' title 'Error in defl. at x=L' figure; % new figure plot(Ni,beam_tip_num) % plot beam defl. at x=L as a fn of N xlabel 'N(1 to 10)' ylabel 'Num Defl. at x=L' title 'Num Defl. at x=L'