Advanced Mathematics and Mechanics Applications Using MATLAB phần 9 pps

67 363 0
Advanced Mathematics and Mechanics Applications Using MATLAB phần 9 pps

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

86: print(’Input data are incorrect. The ’); 87: print(’following r values lie outside the ’); 88: print(’unit circle:’); disp(rvec(kout)’); 89: return 90: end 91: 92: if bvtyp==1 % Solve a Dirichlet problem 93: % Check for points on the boundary where 94: % function values are known. Interpolate 95: % these directly 96: konbd=find(r==1); onbndry=length(konbd); 97: if onbndry > 0 98: u(konbd)=lintrp(thbv,fbv,th(konbd)); 99: end 100: 101: % Evaluate the series solution 102: kinsid=find(r<1); inside=length(kinsid); 103: 104: if inside > 0 105: a=fft(lintrp(thbv,fbv,thfft)); 106: a=a(1:nsum)/(nft/2); 107: a(1)=a(1)/2; Z=r(kinsid).*exp(i*th(kinsid)); 108: u(kinsid)=real(polyval(flipud(a(:)),Z)); 109: end 110: 111: titl= 112: ’Dirichlet Problem Inside the Unit Circle’; 113: 114: else % Solve a Neumann problem 115: gbv=lintrp(thbv,fbv,thfft); 116: a=fft(gbv)/(nft/2); 117: erchek=abs(a(1))/sum(abs(gbv)); 118: if erchek>1e-3 119: disp(’ ’); 120: disp(’ERROR DUE TO NONZERO AVERAGE VALUE’); 121: disp(’OF NORMAL GRADIENT ON THE BOUNDARY.’); 122: disp(’CORRECT THE INPUT DATA AND RERUN.’); 123: disp(’ ’); u=[]; r=[]; th=[]; return; 124: end 125: a=a(2:nsum)./(1:nsum-1)’; z=r.*exp(i*th); 126: u=real(polyval(flipud([0;a(:)]),z)); 127: titl=’Neumann Problem Inside the Unit Circle’; 128: end 129: 130: u=reshape(u,nth,nr); r=R; th=Th; © 2003 by CRC Press LLC 131: surf(r.*cos(th),r.*sin(th),u); 132: xlabel(’x axis’); ylabel(’y axis’); 133: zlabel(’function u’); title(titl); 134: colormap(’default’); 135: grid on; figure(gcf); 136: % print -deps dirich 137: 138: %============================================= 139: 140: % function y=lintrp(xd,yd,x) 141: % See Appendix B Function cauchtst 1: function u=cauchtst(z,nquad) 2: % 3: % u=cauchtst(z,nquad) 4: % ~~~~~~~~~~~~~~~~~~~ 5: % 6: % This function solves a mixed boundary 7: % value problem for the interior of a circle 8: % by numerically evaluating a Cauchy integral. 9: % 10: % z - matrix of complex coordinates where 11: % function values are computed 12: % nquad - order of Gauss quadrature used to 13: % perform numerical integration 14: % 15: % u - computed values of the approximate 16: % solution 17: % 18: % User m functions called: cauchint, mbvtest, 19: % gcquad, splined 20: 21: if nargin<2, nquad=50; end; nbdat=61; 22: if nargin==0 23: z=linspace(0,.99,10)’* 24: exp(i*linspace(0,2*pi,91)); 25: end 26: th=linspace(-pi/2,pi/2,nbdat); zb=exp(i*th); 27: fb=sqrt(zb-i).*sqrt(zb+i); fb(1)=1; fb(nbdat)=1; © 2003 by CRC Press LLC 28: fb=cos(th)./fb; fb(1)=0; fb(end)=0; 29: F=cauchint(fb,zb,z,nquad); 30: F=F.*sqrt(z-i).*sqrt(z+i); u=2*real(F); 31: 32: surf(real(z),imag(z),u); xlabel(’x axis’); 33: ylabel(’y axis’); zlabel(’Solution Value’) 34: title([’Approximate Solution to ’, 35: ’a Mixed Boundary Value Problem’]); 36: grid on; figure(gcf); %gra(.4); 37: fprintf(’\nPress [Enter] to solution error\n’); 38: pause 39: %print -deps caucher1 40: uexact=mbvtest(z,1); udif=u-uexact; 41: clf; surf(real(z),imag(z),udif); 42: title([’Difference Between Exact and ’, 43: ’Approximate Solutions’]); 44: xlabel(’x axis’); ylabel(’y axis’); 45: zlabel(’Solution Error’) 46: grid on; figure(gcf); %gra(.4) 47: %print -deps caucher2 48: 49: %============================================= 50: 51: function u=mbvtest(z,noplot) 52: % 53: % u=mbvtest(z,noplot) 54: % ~~~~~~~~~~~~~~~~~~~ 55: % 56: % This function determines a function which is 57: % harmonic for abs(z)<1 and satisfies at r=1, 58: % u=cos(theta), -pi/2<theta<pi/2 59: % du/dr=0, pi/2<theta<3*pi/2 60: % The solution only applies for points inside 61: % or on the unit circle. 62: % 63: % z - matrix of complex values where the 64: % solution is computed. 65: % noplot - option set to one if no plot is 66: % requested, otherwise option is not 67: % required. 68: % 69: % u - values of the harmonic function 70: % defined inside the unit circle 71: % 72: % User m functions called: none © 2003 by CRC Press LLC 73: % 74: 75: if nargin==0 76: noplot=0; 77: z=linspace(0,1,10)’* 78: exp(i*linspace(0,2*pi,81)); 79: end 80: [n,m]=size(z); z=z(:); u=1/2*ones(size(z)); 81: k=find(abs(z)>0); Z=z(k); 82: U=(Z+1./Z+(1-1./Z).*sqrt(Z-i).*sqrt(Z+i))/2; 83: u(k)=real(U); u=reshape(u,n,m); 84: if nargin==1 | noplot==0 85: z=reshape(z,n,m); 86: surf(real(z),imag(z),u); xlabel(’x axis’); 87: ylabel(’y axis’); 88: title([’Mixed Boundary Value Problem ’, 89: ’for a Circular Disk’]); 90: grid; figure(gcf); %gra(.4), pause 91: %print -deps mbvtest 92: end 93: 94: %============================================= 95: 96: function F=cauchint(fb,zb,z,nquad) 97: % 98: % F=cauchint(fb,zb,z,nquad) 99: % ~~~~~~~~~~~~~~~~~~~~~~~~~ 100: % 101: % This function numerically evaluates a Cauchy 102: % integral of the form: 103: % 104: % F(z)=1/(2*pi*i)*Integral(f(t)/(t-z)*dt) 105: % 106: % where t denotes points on a curve in the 107: % complex plane. The boundary curve is defined 108: % by spline interpolation through data points 109: % zb lying on the curve. The values of f(t) 110: % are also specified by spline interpolation 111: % through values fb corresponding to the 112: % points zb. Numerical evaluation of the 113: % integral is performed using a composite 114: % Gauss formula of arbitrary order. 115: % 116: % fb - values of density function f 117: % at point on the curve © 2003 by CRC Press LLC 118: % zb - points where fb is given. The 119: % number of values of zb must be 120: % adequate to define the curve 121: % accurately. 122: % z - a matrix of values at which the 123: % Cauchy integral is to be evaluated. 124: % If any of the z-values lie on path 125: % of integration or too close to the 126: % path of integration, incorrect 127: % results will be obtained. 128: % nquad - the order of Gauss quadrature 129: % formula used to perform numerical 130: % integration 131: % 132: % F - The value of the Cauchy integral 133: % corresponding to matrix argument z 134: % 135: % User m functions called: gcquad splined 136: % 137: 138: n=length(fb); [nr,nc]=size(z); z=z(:).’; 139: nz=length(z); t=1:n; 140: [dummy,bp,wf]=gcquad(’’,1,n,nquad,n-1); 141: fq=spline(t,fb,bp); zq=spline(t,zb,bp); 142: zqd=splined(t,zb,bp); nq=length(fq); 143: fq=fq(:).*zqd(:); 144: 145: bdrylen=sum(abs(zq(2:nq)-zq(1:nq-1))); 146: 147: closnes=1e100; bigz=max(abs(z)); 148: for j=1:nq 149: closnes=min([closnes,abs(zq(j)-z)]); 150: end 151: if closnes/bdrylen<.01 | closnes/bigz<.01 152: disp(’ ’) 153: disp([’WARNING! SOME DATA VALUES ARE ’, 154: ’EITHER NEAR OR ON’]); 155: disp([’THE BOUNDARY. COMPUTED RESULTS ’, 156: ’MAY BE INACCURATE’]); disp(’ ’) 157: end 158: F=wf(:)’*(fq(:,ones(1,nz))./(zq(:,ones(1,nz)) 159: -z(ones(nq,1),:))); 160: F=reshape(F,nr,nc)/(2*pi*i); 161: 162: %============================================= © 2003 by CRC Press LLC 163: 164: % function [val,bp,wf]=gcquad(func,xlow, 165: % xhigh,nquad,mparts,varargin) 166: % See Appendix B 167: 168: %============================================= 169: 170: % function val=splined(xd,yd,x,if2) 171: % See Appendix B 12.12 Inviscid Fluid Flow around an Elliptic Cylinder This section analyzes inviscid ßow around an elliptic cylinder in an inÞnite Þeld. Flow around a circular cylinder is treated Þrst. Then the function conformally map- ping the exterior of a circle onto the exterior of an ellipse is used in conjunction with the invariance of harmonic functions under a conformal transformation. Results de- scribing the elliptic cylinder ßow Þeld for uniform velocity components at inÞnity are presented. Let us solve for the ßow around a circular cylinder in the region |ζ|≥1, ζ = ξ+iη with the requirement that the velocity components at inÞnity have constant values u = U,v= V where (u, v) are the horizontal and vertical components of velocity. These compo- nents are derivable from a potential function φ such that u = ∂φ ∂ξ ,v= ∂φ ∂η where φ is a harmonic function. The velocity normal to the cylinder boundary must be zero. This requires that the function ψ, the harmonic conjugate of φ, must be con- stant on the boundary. The constant can be taken as zero without loss of generality. In terms of the complex velocity potential f(ζ)=φ + iψ we need f(ζ) − f(ζ)=0 on |ζ| =1 The velocity Þeld is related to the complex velocity potential by u −iv = f  (ζ) so the ßow condition at inÞnity is satisÞed by f(ζ)=pζ + O(1) where p = U − iV © 2003 by CRC Press LLC A Laurent series can be used to represent f (ζ) in the form f(ζ)=pζ + a 0 + ∞  n=1 a n ζ −n Imposition of the boundary condition on the cylinder surface requiring f(σ) − f(σ)=0 where σ = e ıθ leads to pσ + a 0 + ∞  n=1 a n σ −n − ¯pσ −1 − a 0 − ∞  n=1 a n σ n =0 Taking a 0 =0, a 1 =¯p, and a n =0,n≥ 2 satisÞes all conditions of the problem and yields f(ζ)=pζ +¯pζ −1 as the desired complex potential function giving the velocity Þeld as u −iv = f  (ζ)=p − ¯pζ −2 , |ζ|≥1 Now consider ßow about an elliptic cylinder lying in the z-plane. If the velocity at inÞnity has components (U, V ) then we need a velocity potential F (z) such that F  (∞)=U −iV and F (z) − F (z)=0 for  x a  2 +  y b  2 =1 This is nearly the same problem as was already solved in the ζ-plane except that dF dz = dζ dz dF dζ = 1 ω  (ζ) dF dζ where ω(ζ) is the mapping function z = ω(ζ)=R(ζ + mζ −1 ) ,R= a + b 2 ,m= a −b a + b In terms of ζ we would need dF dζ = ω  (∞)[U − iV ]=R(U − iV ) at ζ = ∞ Consequently, the velocity potential for the elliptic cylinder problem expressed in terms of ζ is F = pζ +¯pζ −1 ,p= R(U − ıV ) and the velocity components in the z-plane are given by u −iv = 1 ω  (ζ)  p − ¯pζ −2  = (U − iV ) − (U − iV )ζ −2 1 −mζ −2 . © 2003 by CRC Press LLC To get values for a particular choice of z we can use the inverse mapping function ζ = z + √ z 2 − 4mR 2 2R to eliminate ζ or we can compute results in terms of ζ. To complete our discussion of this ßow problem we will graph the lines charac- terizing the directions of ßow. The velocity potential F = φ + iψ satisÞes u = ∂φ ∂x = ∂ψ ∂y ,v= ∂φ ∂y = − ∂ψ ∂x so a curve tangent to the velocity Þeld obeys dy dx = v u = − ∂ψ/∂x ∂ψ/∂y or ∂ψ ∂x dx + ∂ψ ∂y dy =0 ,ψ= constant Consequently, the ßow lines are the contours of function ψ, which is called the stream function. The function we want to contour does not exist inside the ellipse, but we can circumvent this problem by computing ψ in the ellipse exterior and then setting ψ to zero inside the ellipse. The function elipcyl analyzes the cylinder ßow and produces the accompanying contour plot shown in Figure 12.9. © 2003 by CRC Press LLC −5 −4 −3 −2 −1 0 1 2 3 4 5 −5 −4 −3 −2 −1 0 1 2 3 4 5 x axis y axis Elliptic Cylinder Flow Field for Angle = 30 Degrees Figure 12.9: Elliptic Cylinder Flow Field for Angle = 30 ◦ 12.12.1 Program Output and Code Function elipcyl 1: function [x,y,F]=elipcyl(a,n,rx,ry,ang) 2: % 3: % [x,y,F]=elipcyl(a,n,rx,ry,ang) 4: % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5: % 6: % This function computes the flow field around 7: % an elliptic cylinder. The velocity direction 8: % at infinity is arbitrary. 9: % 10: % a - defines the region -a<x<a, -a<y<a 11: % within which the flow field is 12: % computed 13: % n - this determines the grid size which 14: % uses n by n points 15: % rx,ry - major and minor semi-diameters af the 16: % ellipse lying on the x and y axes, © 2003 by CRC Press LLC 17: % respectively 18: % ang - the angle in degrees which the 19: % velocity at infinity makes with the 20: % x axis 21: % 22: % x,y - matrices of points where the velocity 23: % potential is computed 24: % F - matrix of complex velocity potential 25: % values. This function is set to zero 26: % inside the ellipse, where the 27: % potential is actually not defined 28: % 29: % User m functions called: none 30: 31: % default data for a 2 by 1 ellipse 32: if nargin==0 33: a=5; n=81; rx=2; ry=1; ang=30; 34: end 35: 36: % Compute a square grid in the z plane. 37: ar=pi/180*ang; p=(rx+ry)/2*exp(-i*ar); 38: cp=conj(p); d=linspace(-a,a,n); 39: [x,y]=meshgrid(d,d); m=sqrt(rx^2-ry^2); 40: 41: % Obtain points in the zeta plane outside 42: % the ellipse 43: z=x(:)+i*y(:); k=find((x/rx).^2+(y/ry).^2>=1); 44: Z=z(k); zeta=(Z+sqrt(Z-m).*sqrt(Z+m))/(rx+ry); 45: F=zeros(n*n,1); 46: 47: % Evaluate the potential for a circular 48: % cylinder 49: F(k)=p*zeta+cp./zeta; F=reshape(F,n,n); 50: 51: % Contour the stream function to show the 52: % direction of flow 53: 54: clf; contourf(x(1,:),y(:,1),abs(imag(F)),30); 55: axis(’square’); zb=exp(i*linspace(0,2*pi,101)); 56: xb=rx*real(zb); yb=ry*imag(zb); 57: xb(end)=xb(1); yb(end)=yb(1); 58: hold on; fill(xb,yb,[127/255 1 212/255]); 59: xlabel(’x axis’); ylabel(’y axis’); 60: title([’Elliptic Cylinder Flow Field for ’, 61: ’Angle = ’,num2str(ang),’ Degrees’]); © 2003 by CRC Press LLC [...]... fprintf(’All Done\n’); © 2003 by CRC Press LLC 86: 87: %============================================= 88: 89: 90 : 91 : 92 : 93 : 94 : 95 : 96 : 97 : 98 : 99 : 100: 101: 102: 103: 104: 105: 106: 107: 108: 1 09: 110: 111: 112: 113: 114: 115: 116: 117: 118: 1 19: 120: 121: 122: 123: 124: 125: 126: 127: 128: 1 29: 130: function [a,b,c]=platecrc(N,T,ti,kapa,np) % % [a,b,c]=platecrc(N,T,ti,kapa,np) % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~... %============================================= 186: 187: 188: 1 89: 190 : 191 : 192 : 193 : 194 : 195 : 196 : 197 : 198 : 199 : 200: 201: 202: 203: 204: 205: 206: 207: 208: function [Phi,Psi,Phip]=strfun(a,b,z) % % [Phi,Psi,Phip]=strfun(a,b,z) % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % % This function evaluates the complex % stress functions Phi(z) and Psi(z) % as well as the derivative function Phi’(z) % using series coefficients determined from... of the complex stress % function % % trho - torsional stresses in directions % normal to the lines into which % abs(zeta)=const map These values © 2003 by CRC Press LLC 86: 87: 88: 89: 90 : 91 : 92 : 93 : 94 : 95 : 96 : 97 : 98 : 99 : 100: 101: 102: 103: % should be zero at the boundary % corresponding to abs(zeta)=1 % talpha - torsional stresses in directions % tangent to the curves into which % abs(zeta)=const... % Psi(zeta)=psi’(zeta)/w’(zeta) % d(Phi)/dz=(w’(zeta)*phi’’(zeta)- % w’’(zeta)*phi’(zeta))/w’(zeta)^3 84: 85: r=(rx+ry)/2; m=(rx-ry)/(rx+ry); © 2003 by CRC Press LLC 86: 87: 88: 89: 90 : 91 : 92 : 93 : 94 : 95 : 96 : 97 : 98 : 99 : 100: 101: 102: 103: 104: 105: 106: z=r*(zeta+m./zeta); zeta2=zeta.^2; zeta3=zeta.^3; wp=r*(1-m./zeta2); wpp=2*r*m./zeta3; a=exp(2*i*pi/180*ang); b=p*r/4; c=b*(2*a-m); d=-p*r/2*conj(a);... the order of the elements reversed % % 287: 288: y=polyval(a(end:-1:1),x); 2 89: 290 : %============================================= 291 : 292 : 293 : % function y=lintrp(xd,yd,x) % See Appendix B 12.14.2 Stressed Plate with an Elliptic Hole This chapter is concluded with an example using conformal mapping in elasticity theory We discussed earlier the useful property that harmonic... expansions of functions Φ(z) and Ψ(z) can be generated in terms of the coefÞcients c n and the stress components at inÞnity The stresses can be evaluated by using the stress functions Displacements can also be obtained by integrating Φ and Ψ, but this straightforward calculation is not discussed here The program runplate was written to evaluate the above formulas by expanding N + iT using the FFT Truncating... % User m functions required: eliphole 10: 11: 12: 13: 14: rx=2; ry=1; p=1; ang =90 ; ifplot=1; zeta=linspace(1,2,11)’* exp(i*linspace(0,2*pi,121)); eliphole(rx,ry,p,ang,zeta,1); 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: r=linspace(1.001,10, 19) ; tamax=zeros(size(r)); for j=1: 19 [tr,tamax(j)]=eliphole(r(j),1,1 ,90 ,1); end plot(r,tamax,’-’,r,tamax,’o’); title([’Stress Concentration Around an... values of the mapping % function and its first derivative % % User m functions called: none % 160: 161: 162: 163: 164: 165: 166: a=[ 1.07835, 1.37751, -0.02642, -0. 091 29, 0.13460, -0.15763, 0.07430, 0.14858, 0.01878, -0.00354 ]’; b=[ 1.37743, 0.07157, -0.11085, 0.12778, -0.13750, 0.05313, 0.1 493 1, 0.02683, -0.00350, -0.000120 ]’; 167: 168: 1 69: 170: % Evaluate the mapping function... to deal with torsion problems © 2003 by CRC Press LLC 12.13.1 Program Output and Code Program runtors 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: function runtors(ntrms) % Example: runtors(ntrms) % ~~~~~~~~~~~~~~~~ % % Example showing torsional stress computation % for a beam of square cross section using % conformal mapping and a complex stress % function % % ntrms - number of series terms used to %... Φ(z) and Ψ(z), which exactly represent the solution corresponding to the boundary loading deÞned by the truncated Fourier series Using the same approach employed in Chapter 6 we can deÞne N and T as piecewise linear functions of the polar angle θ The program utilizes several routines described in the table below runplate deÞne N , T , stresses at inÞnity, z-points where results are requested, and the . disp(rvec(kout)’); 89: return 90 : end 91 : 92 : if bvtyp==1 % Solve a Dirichlet problem 93 : % Check for points on the boundary where 94 : % function values are known. Interpolate 95 : % these directly 96 : konbd=find(r==1);. Value Problem ’, 89: ’for a Circular Disk’]); 90 : grid; figure(gcf); %gra(.4), pause 91 : %print -deps mbvtest 92 : end 93 : 94 : %============================================= 95 : 96 : function F=cauchint(fb,zb,z,nquad) 97 :. directions 89: % tangent to the curves into which 90 : % abs(zeta)=const map. The maximum 91 : % value of shear stress always occurs 92 : % at some point on the boundary defined 93 : % by abs(zeta)=1. 94 :

Ngày đăng: 08/08/2014, 11:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan