Code covered by the BSD License  

Highlights from
Rotor Dynamics toolbox (RotFE)

image thumbnail

Rotor Dynamics toolbox (RotFE)

by

Izhak Bucher (view profile)

 

Toolbox models rotating, elastic shafts with disks

modeplot2f(FILE,arg1,arg2)
function modeplot2f(FILE,arg1,arg2)  
% [phi,lambda,fb]=modeplot2f(FILE,W1,W2,N,P5) 
%   
%
% INPUTS:
%	FILE:   input file, can be template.m (Script) or template.mtx (*.mat)
%	W:	speed of rotation [Rad/s] (default is W=0)
%	TYPE:	type of eigenproblem to be solved
%		TYPE=0,  undamped (default)
%		TYPE=1,  external (non-rotating) damping
%		TYPE=2,  general (rotating hysteretic + non-rotating viscous) damping
% EXAMPLES:
%	 [phi,lambda,fb]=rotmodes('template');  % runs rotfe('template'), 
%						% assumes W=0

% By  I. Bucher  8-9-1998  Rev. 2.0
%                29-7-99   Rev. 2.1  now treats reduced models too
%						1-6-2000  plots solid model in 3D,
%						  also uses a fix for an bug in Matlab's view     T=view;   T(3,1:3) = -T(3,1:3);
    
CMDs={'go' 'display' 'Scale' 'modeplus' 'modeminus' 'save' 'keepT'};

    if nargin<1, FILE='simple1s'; end
    tool=mfilename;
    
        if isa(FILE,'struct'), 
            for q={'M' 'K' 'G' 'KH' 'Kst' 'D'} % those are too big and unecessary
                try, FILE=rmfield(FILE,q); end
            end
            rot2templ(FILE,'temporary1.m')
            FILE='temporary1';
        end
        
        if strcmp(FILE,'go'),
            fig=findobj('tag',[tool 'fig']);
            hfile=findobj('tag',[tool  'file']);  file=get(hfile,'string');
            Rot=rotfe(file);
            hed=findobj('tag',[tool  'modeN']); 
            set(hed,'visible','on');
            hN=findobj('tag',[tool  'N']);  set(hN,'visible','on');
            hcomp=findobj('tag',[tool  'compute']); 
            CoL=get(hcomp,'value');
            hW=findobj('tag',[tool  'W']);  
            cmd=['W=2*pi/60*' get(hW,'string') ';']; FAIL='W=0;';
            eval(cmd,FAIL);
            critspeed=get(  findobj('tag',   [tool 'critspd']), 'value')>1;
            Rot.W=max([eps W]);
            if  critspeed, 
                [phi lambda]=roteig(Rot,1);
            else,
                [phi lambda]=roteig(Rot); 
            end
            
            Rot.eigenvector=phi; Rot.eigenvalue=abs(lambda);  
           % Rot.eigenvector(10:13,25)=randn(4,1)*max(Rot.eigenvector(:,25))*2;
            set(fig,'userdata',Rot);
            Nm=length(lambda);
            S=sprintf('1: %g [Hz] ',100\round((abs(lambda(1)))/2/pi*100));
            for q=2:Nm, S=str2mat(S,sprintf('%d: %g [Hz]',q,100\round((abs(lambda(q)))/2/pi*100))); end
            set(hed,'string',S,'value',1);
            
            modeplot2f('display')
            
        elseif strcmp(FILE,'Scale') 
            disp(arg1)
        elseif strcmp(FILE,'modeplus') 
            hed=findobj('tag',[tool  'modeN']); 
            V=get(hed,'string');
            N=size(V,1);
            n=min(get(hed,'value')+1,N);
            set(hed,'value',n);   modeplot2f('display')
            %>>>>>>>>>>>>>>>>>>>>>>>
        elseif strcmp(FILE,'modeminus') 
            hed=findobj('tag',[tool  'modeN']); 
            V=get(hed,'string');
            N=size(V,1);
            n=max(get(hed,'value')-1,1);
            set(hed,'value',n);  modeplot2f('display')
            
            %<><><>??<><><>??<>
        elseif strcmp(FILE,'keepT')   
            h=findobj('tag',[tool  'keepT']);  
            trans=get(h,'userdata');
            
            trans.toggle=~trans.toggle;
            
            if trans.toggle
                T=view;   T(3,1:3) = -T(3,1:3);
                trans.T=T;       
                set(h,'string','view kept')
            else
                set(h,'string','auto view')
            end
            set(h,'userdata',trans);
            % <><><><><><><><><><><><>
        elseif  strcmp(FILE,'display'),
            hed=findobj('tag',[tool  'modeN']);  n=get(hed,'value');
            hN=findobj('tag',[tool  'N']);   p3D=get(hN,'value')==1;
            hS = findobj('tag',[tool 'solid']); pS=get(hS,'value')==1;
            hX = findobj('tag',[tool 'section']); pX=get(hX,'value')==1;
            
            hp=findobj('tag',[tool 'plane']); hc=findobj('tag',[tool 'Circ']);    
            pQ=get(hp,'value'); cQ=get(hc,'value');
            fig=findobj('tag',[tool 'fig']);
            Rot=get(fig,'userdata');
            if ~isa(Rot,'struct'), return, end
            ax=findobj('tag',[tool 'ax']);  % get the right axis
            [Wu,Wv,x,v2]=rotmshape(Rot.eigenvector(:,n),Rot);
            if all(real(Wu)==0) & all(real(Wv)==0)
                Wu=i*Wu; Wv=i*Wv;
            end
            
            [ws whatwhirl]  =   whirldir(v2);
            lambda=abs(Rot.eigenvalue);
            if p3D,
                NP=18-4*(size(Rot.ELEMENTS,1)>8)+4*(size(Rot.ELEMENTS,1)<5);
                if pS, 
                    if pX, drawrot3d_sec(Rot,'    ',1); 
                    else,drawrot3d_spring2(Rot,'    ',1); end
                    hold on, 
                end
                axis off
                rotmshape3a(Rot.eigenvector(:,n),Rot,NP,pQ,cQ);
                zoom off, rotate3d on,
                hT=findobj('tag',[tool  'keepT']);  
                trans=get(hT,'userdata');
                if trans.toggle,view(trans.T); end
                set(gcf,'renderer','zbuffer')
                drawnow
            else,
                drawrot(Rot.File,'xxx','xxx'); hold on, 
                axis normal,
                ax=axis;
                x1=min(min(Rot.NODES(Rot.ELEMENTS(:,[1 2]))));
                x2= max(max(Rot.NODES(Rot.ELEMENTS(:,[1 2]))));
                
                Lt=norm(Rot.NODES)/length(Rot.NODES);			% typical length
                dx=ax(2)-ax(1);  dy=ax(4)-ax(3); 
                set(gca,'xlim',[x1-Lt/15 x2+Lt/15 ]);
                s=20;
                mx=max(ax(3:4)); %axis([ax(1)-dx/s ax(2)+dx/s ax(3)-dy/s ax(4)+dy/s]);      
                scl=.8*mx/max(abs([eps;real(Wu(:)); real(Wv(:))]));
                h=plot(x,real(Wu)*scl*2.5,'r-',x, real(Wv)*scl/1.5,'m-'	,[min(x)-dx/s max(x)+dx/s],[0 0],'k-.');
                set(h , 'linewidth',2 ); set(h(end),'linewidth',.6 );
                ylabel('X and Y deflections'); 
                rotate3d off, view(2),zoom on; hold off, axis equal
            end
            fr=100\round((lambda(n))/2/pi*100);  
            critspeed=get(  findobj('tag',   [tool 'critspd']), 'value')>1;
            if critspeed
                title(sprintf('mode-%d  f=%6.2f Hz %s Speed=%.0f RPM',n,fr,whatwhirl,fr*60));
            else 
                title(sprintf('mode-%d  f=%6.2f Hz %s Speed=%.0f RPM',n,fr,whatwhirl,Rot.W*60/2/pi));
            end
            % <><><><>
        elseif  strcmp(FILE,'save'),
            fig=findobj('tag',[tool 'fig']);
            Rot=get(fig,'userdata');
            if (~isa(Rot,'struct')) , 
                warndlg('unable to save in file','Saving failed')
                return, 
            end
            
            switch arg1
            case 1,   [fname,pname] = uiputfile('*.mat','Choose file name');
                if (fname(1)==0), warndlg('unable to save in file','Saving failed'), return,end
                cmd=['save ' pname fname ' Rot' ];
                err=0; eval(cmd,'err=1;');
            case 2, 
                [fname,pname] = uiputfile('*.*','Choose file name') ;
                if (fname(1)==0), warndlg('unable to save in file','Saving failed'), return,end
                modes=Rot.eigenvector; modesRE=real(modes);  modesIM=imag(modes); 
                frequencies=abs(Rot.eigenvalue);
                cmd=['save ' pname fname '.mod modesRE modesIM -ascii ' ];
                err=0; eval(cmd,'err=1;');  
                cmd=['save ' pname fname '.frq frequencies  -ascii ' ];
                eval(cmd,'err=1;');  
            end
            if err, warndlg('unable to save in file','Saving failed'), return,end
            msgbox([' Saved in ' fname ' sucessfully'])
            
            %<><><><><><>   
        elseif strcmp(FILE,'newfile')
            h = findobj(gcf,'tag',[tool 'file']);
            FILE=get( h, 'string');
            try
                drawrot(FILE); axis auto
            catch
                title('Use existing Template File')
            end
            
            
            %<><><><><><>   
        else, % init
            
            fig=findobj('tag',[tool 'fig']);
            if length(fig)==0, 
                fig=figure('unit','normal','pos',...
                    [0.0100    0.1    0.6000    0.8],...
                    'tag',[tool 'fig'],'menubar','none',...
                    'name','mode shapes',...
                    'numbertitle','off'); 
                  set(gcf,'renderer','zbuffer')
            else, figure(gcf), clf reset,  set(gcf,'renderer','zbuffer')
                %      return
            end
            ax=axes; set(ax,'tag',[tool 'ax'])
            set(gca,'unit','normal','pos',[.1 .45 .8 .5]); axis off
            feval('drawrot',FILE);
            % ----------------------------------------------------------------------
            f=uimenu(gcf,'label','Save Modes/Frequencies');
            uimenu(f,'Label','Save in .Mat file','callback',[tool '(''save'',1)']);
            uimenu(f,'Label','Save in ascii format','callback',[tool '(''save'',2)']);
            f1=uimenu(gcf,'label','PlotScale');
            uimenu(f1,'Label','Scale Mode in 2D','callback',[tool '(''Scale'',1)']);
            uimenu(f1,'Label','Scale Mode in 3D','callback',[tool '(''Scale'',2)']);
            uimenu(f1,'Label','Scale Springs','callback',[tool '(''Scale'',3)']);
            
            goahead=[tool '(''go'');'];
            uicontrol('style','frame',...
                'foregroundcolor','w',...
                'unit','normal','pos',[.01 .01 .89 .39],...
                'backgroundcolor','b');
            uicontrol('style','text',...
                'string','  Template file (model)',...
                'unit','normal','pos',[.03 .19 .5 .08],'units','normalized',...
                'backgroundcolor','y');
            
            cb=['modeplot2f(''newfile'')'];
            uicontrol('style','edit',...
                'string',FILE,'units','normalized',...
                'pos',[.55 .19 .15 .08],...
                'tag',[tool 'file'],...
                'callback',setstr(cb)  ,...
                'backgroundcolor','w'); 
            uicontrol('style','text',...
                'string','  Speed of rotation (RPM)',...
                'units','normalized','pos',[.03 .19+.094 .5 .08],...
                'backgroundcolor','y');
            uicontrol('style','edit',...
                'string','0.0','units','normalized',...
                'pos',[.55 .19+.094 .15 .08],...
                'tag',[tool 'W'],...
                'backgroundcolor','w'); 
            uicontrol('style','text',...
                'string',' show mode number',...
                'units','normalized','pos',[.03 .09 .5 .08],...
                'backgroundcolor','y');
            h1= uicontrol('style','popup',...
                'string','0','units','normalized',...
                'pos',[.55 .1 .18 .08],...
                'tag',[tool 'modeN'],...
                'callback',[tool '(''display'');'],...
                'backgroundcolor','w');
            h1m= uicontrol('style','push',...
                'string','--','units','normalized',...
                'pos',[.55 .1-0.02 .05 .05],...
                'tag',[tool 'modeminus'],...
                'callback',[tool '(''modeminus'');'],...
                'backgroundcolor','w');
            h1p= uicontrol('style','push',...
                'string','-|-','units','normalized',...
                'pos',[.55+.07 .1-0.02 .05 .05],...
                'tag',[tool 'modeplus'],...
                'callback',[tool '(''modeplus'');'],...
                'backgroundcolor','w');
            h2=uicontrol('style','check',...
                'string','3D','units','normalized',...
                'pos',[.55 .03 .15 .045],...
                'tag',[tool 'N'],...
                'callback',[tool '(''display'');'],...
                'backgroundcolor','w');
            uicontrol('style','push',...
                'string','GO','units','normalized',...
                'pos',[.72 .03 .16 .1],...
                'callback',goahead);
            uicontrol('style','pop',...
                'string','compute|load','units','normalized',...
                'pos',[.72 .26 .16 .1],...
                'tag',[tool 'compute'],...
                'callback',[tool '(''display'');'] );
            uicontrol('style','pop',...
                'string','modes|crit. speed','units','normalized',...
                'pos',[.72 .16 .16 .1],...
                'tag',[tool 'critspd'] );
            
            uicontrol('Value',1, ...
                'Units','points', ...
                'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
                'Position',[10 14.25 60.75 15], ...
                'String','Circles plot', ...
                'Style','radiobutton',...
                'callback',[tool '(''display'');'] ,...
                'tag',[tool 'Circ']);  
            uicontrol( 'Value',1, ...
                'Units','points', ...
                'Position',[73.25 14.25 56 15], ...
                'String','Show plane', ...
                'Style','radiobutton', ...
                'callback',[tool '(''display'');'] ,...
                'tag',[tool 'plane']);  
            
            uicontrol( 'Value',0, ...
                'Units','points', ...
                'Position',[134 14.25 56 15], ...
                'String','Solid', ...
                'Style','radiobutton', ...
                'callback',[tool '(''display'');'] ,...
                'tag',[tool 'solid']);  
            uicontrol( 'Value',0, ...
                'Units','points', ...
                'Position',[191 14.25 56 15], ...
                'String','Section', ...
                'Style','radiobutton', ...
                'callback',[tool '(''display'');'] ,...
                'tag',[tool 'section']);  
            
            trans.T=eye(4); trans.toggle=0;
            uicontrol( 'Value',1, ...
                'Units','points', ...
                'unit','normal',...
                'Position',[.9 .94 .1 .05], ...
                'String','Keep view', ...
                'Style','push', ...
                'userdata',trans,...
                'callback',[tool '(''keepT'');'] ,...
                'tag',[tool 'keepT']);  
            
            set([h1 h2],'visible','off');
            % ---------------------------------------------------------------------------------
            
        end
        
        

Contact us