StrainRateCompute

PURPOSE ^

STRAINRATECOMPUTE - compute the strain rate

SYNOPSIS ^

function strainrate=StrainRateCompute(m,inputs,type);

DESCRIPTION ^

STRAINRATECOMPUTE - compute the strain rate

   return a vector of size (numberofelements,1), holding the strain rate for 
   every element

   Usage:
      strainrate=StrainRateCompute(m,inputs,type)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function strainrate=StrainRateCompute(m,inputs,type);
0002 %STRAINRATECOMPUTE - compute the strain rate
0003 %
0004 %   return a vector of size (numberofelements,1), holding the strain rate for
0005 %   every element
0006 %
0007 %   Usage:
0008 %      strainrate=StrainRateCompute(m,inputs,type)
0009 
0010 %global variables
0011 global cluster gridset
0012 
0013 %recover fem model fields
0014 elements=m.elements;
0015 grids=m.grids;
0016 materials=m.materials;
0017 loads=m.loads;
0018 gridset=m.gridset;
0019 
0020 %figure out active elements that will take part in the stiffness and load generation
0021 [n1,n2]=GetNumberOfActiveElements(elements);
0022 
0023 if strcmpi(type,'2d')
0024     %initialize vectors
0025     strainrate=struct('xx',[],'yy',[],'xy',[],'principalvalue1',[],'principalaxis1',[],'principalvalue2',[],'principalaxis2',[]);
0026     strainrate1=zeros((n2-n1)+1,3);
0027     A1=zeros((n2-n1)+1,1); Vx1=zeros((n2-n1)+1,1); Vy1=zeros((n2-n1)+1,1);
0028     A2=zeros((n2-n1)+1,1); Vx2=zeros((n2-n1)+1,1); Vy2=zeros((n2-n1)+1,1);
0029 
0030     %Go through all elements and call the strainrate routine, then compute eigen values and vector
0031     for n=n1:n2,
0032         if ~isempty(elements(n).element),
0033             strainratevector=StrainRate(elements(n).element,grids,materials,inputs)';
0034 
0035             strainratematrix=[strainratevector(1) strainratevector(3) 
0036                       strainratevector(3)  strainratevector(2)];
0037 
0038             %eigen values and vectors
0039             [directions,value]=eig(strainratematrix);
0040 
0041             %Plug into global vectors
0042             strainrate1(n,:)=strainratevector;
0043                         A1(n,1)=value(1,1); A2(n,1)=value(2,2);
0044                         Vx1(n,1)=directions(1,1); Vx2(n,1)=directions(1,2);
0045                         Vy1(n,1)=directions(2,1); Vy2(n,1)=directions(2,2);
0046         end
0047     end
0048 
0049     %plug results into outputs
0050     %NB: Matlab sorts the eigen value in increasing order, we want the reverse
0051     %Components
0052     strainrate.xx=strainrate1(:,1)*(365.25*24*3600);  %strain rate in 1/a instead of 1/s
0053     strainrate.yy=strainrate1(:,2)*(365.25*24*3600);
0054     strainrate.xy=strainrate1(:,3)*(365.25*24*3600);
0055     %principal axis and values
0056     strainrate.principalvalue2=A1;
0057     strainrate.principalaxis2=[Vx1 Vy1];
0058     strainrate.principalvalue1=A2;
0059     strainrate.principalaxis1=[Vx2 Vy2];
0060     %Norm or effective value
0061     straintare.effectivevalue=1/sqrt(2)*sqrt(strainrate.xx.^2+strainrate.yy.^2+2*strainrate.xy.^2);
0062 else
0063     %initialize vectors
0064     strainrate=struct('xx',[],'yy',[],'zz',[],'xy',[],'xz',[],'yz',[],'principalvalue1',[],'principalaxis1',[],'principalvalue2',[],'principalaxis2',[],'principalvalue3',[],'principalaxis3',[]);
0065     strainrate1=zeros((n2-n1)+1,6);
0066     A1=zeros((n2-n1)+1,1); Vx1=zeros((n2-n1)+1,1); Vy1=zeros((n2-n1)+1,1); Vz1=zeros((n2-n1)+1,1);
0067     A2=zeros((n2-n1)+1,1); Vx2=zeros((n2-n1)+1,1); Vy2=zeros((n2-n1)+1,1); Vz2=zeros((n2-n1)+1,1);
0068     A3=zeros((n2-n1)+1,1); Vx3=zeros((n2-n1)+1,1); Vy3=zeros((n2-n1)+1,1); Vz3=zeros((n2-n1)+1,1);
0069 
0070     %Go through all elements and call the strainrate routine, then compute eigen values and vector
0071     for n=n1:n2,
0072         if ~isempty(elements(n).element),
0073             strainratevector=StrainRate(elements(n).element,grids,materials,inputs)';
0074 
0075             strainratematrix=[strainratevector(1) strainratevector(4) strainratevector(5)
0076                       strainratevector(4)  strainratevector(2)  strainratevector(6)
0077                       strainratevector(5)  strainratevector(6)  strainratevector(3)];
0078 
0079             %eigen values and vectors
0080             [directions,value]=eig(strainratematrix);
0081 
0082                         %Plug into global vectors
0083             strainrate1(n,:)=strainratevector;
0084                         A1(n,1)=value(1,1); A2(n,1)=value(2,2); A3(n,1)=value(3,3);
0085                         Vx1(n,1)=directions(1,1); Vx2(n,1)=directions(1,2); Vx3(n,1)=directions(1,3);
0086                         Vy1(n,1)=directions(2,1); Vy2(n,1)=directions(2,2); Vy3(n,1)=directions(2,3);
0087                         Vz1(n,1)=directions(3,1); Vz2(n,1)=directions(3,2); Vz3(n,1)=directions(3,3);
0088         end
0089     end
0090 
0091     %plug results into outputs
0092     %NB: Matlab sorts the eigen value in increasing order, we want the reverse
0093     %Components
0094     strainrate.xx=strainrate1(:,1)*(365.25*24*3600);  %strain rate in 1/a instead of 1/s
0095     strainrate.yy=strainrate1(:,2)*(365.25*24*3600);
0096     strainrate.zz=strainrate1(:,3)*(365.25*24*3600);
0097     strainrate.xy=strainrate1(:,4)*(365.25*24*3600);
0098     strainrate.xz=strainrate1(:,5)*(365.25*24*3600);
0099     strainrate.yz=strainrate1(:,6)*(365.25*24*3600);
0100     %principal axis and values
0101     strainrate.principalvalue3=A1;
0102     strainrate.principalaxis3=[Vx1 Vy1 Vz1];
0103     strainrate.principalvalue2=A2;
0104     strainrate.principalaxis2=[Vx2 Vy2 Vz2];
0105     strainrate.principalvalue1=A3;
0106     strainrate.principalaxis1=[Vx3 Vy3 Vz3];
0107     %Norm or effective value
0108     straintare.effectivevalue=1/sqrt(2)*sqrt(strainrate.xx.^2+strainrate.yy.^2+strainrate.zz.^2+2*strainrate.xy.^2+2*strainrate.xz.^2+2*strainrate.yz.^2);
0109 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003