disp('  ');
disp(' ring.m  ver 1.1  March 1, 2012 ');
disp(' ');
disp(' by Tom Irvine '); 
disp(' Email: tomirvine@aol.com ');
disp('  ');
disp(' This script calculates the natural frequencies of a thin ring ');
disp(' with a rectangular cross-section. ');
disp(' ');
%
close all hidden;
%
disp(' Select units:  1=English 2=metric ');
iu=input(' ');
%
if(iu==1)
  LD='in';
else
  LD='m';      
end
%
%  Material
%
[E,rho,v]=materials(iu);
%
c=sqrt(E/rho);
%
out1=sprintf(' Enter diameter (%s)',LD);
disp(out1);
diam=input(' ');
%
%
disp(' ');
disp(' The speed of sound in the material is: ');
if(iu==1)
   out1=sprintf(' c=%9.4g in/sec  ',c);
else
   out1=sprintf(' c=%9.4g m/sec  ',c);    
end
disp(out1);
%
fr=c/(pi*diam);
%
disp(' ');
disp(' The ring frequency is: ');
out1=sprintf(' fr=%9.4g Hz ',fr);
disp(out1);
%
disp(' ')
disp(' Calculate in-plane modes?  1=yes  2=no ');
ipm=input(' ');
%
iflag=0;
if(ipm==1)
%    
    out1=sprintf(' Enter thickness (%s)',LD);
    disp(out1);
    t=input(' ');
%
    A=sqrt(E*t^2/(3*rho));
    B=A/(pi*diam^2);
%
    disp(' ');
    disp(' in-plane modes ');
    disp(' n    fn(Hz) ');
%
    for(n=1:6)
        num=n*(n^2-1);
        den=sqrt(n^2+1);
        fn_in(n)=(num/den)*B;
        out1=sprintf(' %d  %8.4g',n,fn_in(n));
        disp(out1);
    end
    iflag=1;
end    
%
disp(' ')
disp(' Calculate out-of-plane modes?  1=yes  2=no ');
opm=input(' ');
%
if(opm==1)
%    
    if(iflag==0)
        out1=sprintf(' Enter thickness (%s)',LD);
        disp(out1);
        t=input(' ');
    end
%
    out1=sprintf(' Enter height (%s)',LD);
    disp(out1);
    h=input(' ');
%
    disp(' ');
    disp(' out-of-plane modes ');
    disp(' n    fn(Hz) ');
%
    for(n=1:6)
        A=2*n*(n^2-1)*h/(pi*diam^2);
        B=rho*(12*n^2 + 6.667*( 1+ (h/t)^2 )*(1+v));
        fn_out(n)=A*sqrt(E/B);
        out1=sprintf(' %d  %8.4g',n,fn_out(n));
        disp(out1);
    end
%
end    
%
if(iflag==1)
%
    B=1;
    N=1000;
    delta=2*pi/N;
    theta=0:delta:2*pi;
%
    for(n=2:4)
        figure(n);    
        clear V;
        clear Wa;
        clear Wb;
        clear Ra;
        clear und;
        V(1:length(theta))=0.;   
        Wa(1:length(theta))=0.;
        arg=n*theta;
%
        V=-B*sin(arg);
        R=4*n;
        Wa=R+n*cos(arg);
%    
        Ra=sqrt(V.^2+Wa.^2)/R;   
%
        alpha=theta+atan2(V,Wa);
%
        und(1:length(theta))=1;
%
        scale=1;
        Ra=Ra*scale;
        polar(alpha,Ra);
%         
        out5 = sprintf(' In-Plane Mode  n=%d  fn= %9.4g Hz',n,fn_in(n));
        title(out5);
        hold on;
        polar(theta,und,'-.');
        disp(' ')
        hold off;
    end
%
end