Advertisement
PashaYa

Untitled

Jan 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 4.82 KB | None | 0 0
  1. clc
  2. clear
  3.  
  4. %Solving not linear task to destroy contact at using finite element method.
  5. %In program uses the rectangular multiplex element.
  6.  
  7. %
  8. %
  9. %Initial data (input data)
  10.    
  11.     %Parameters material contactive parts
  12.         %сталь 20л/ steel 430A
  13.         mu = 0.25;        %(0,24..0,28) Poisson's coeff.
  14.         sigma_critical = 216e4; %sigma_0.2
  15.         E = 200e9;        %Young's modulus (for this task elastic modulus)
  16.                
  17.     %Parameters contact
  18.         Cs = 0.01*E;
  19.         Cn = 0.01*E;
  20.  
  21.     %Body geometry
  22.         L = 1;    %length
  23.         H = 1/2;    %height parts body
  24.         t = 1/10;
  25.    
  26.     %Grid options
  27.         N = 11;   %points at length
  28.         M = 11;   %points at height part body
  29.  
  30.  
  31.        
  32.  
  33. %    
  34. %
  35. %Program body
  36.  
  37.     %Create the initial state and the grid
  38.        
  39.             [point_global_number ,point_coordinate_in_global_numbers] = create_grid(N ,M ,L ,H);
  40.        
  41.         %Create the vector of tension
  42.             tension = zeros(2*(N-1)*(M-1) ,3);
  43.        
  44.         %Create the indication overloaded elements        
  45.             overloaded_elements = zeros(2*(N-1)*(M-1) ,1);   %for control elements
  46.        
  47.         %Create the indication overloaded point on contact        
  48.             overloaded_contact_elements = zeros((N - 1) ,2);   %for overload check at basic elements
  49.    
  50.     %Parametrs finite element
  51.    
  52.         %Basis elements
  53.        
  54.         %Matrix elastic constants
  55.             D = [        1, mu/(1-mu),                  0;
  56.                  mu/(1-mu),         1,                  0;
  57.                          0,         0, (1-2*mu)/(2*(1-mu)) ] *E*(1-mu)/((1+mu)*(1-2*mu));
  58.                      
  59.     %Create the stress
  60.        
  61.         %local force
  62.        
  63.             point_stress = [203 220 201  232 221 202 240 241 233 234 237];      %the global number of the point
  64.             local_forse = [-5e6 ,0; -5e7 ,0; -5e7 ,0; 5e7 ,0; 5e7 ,0; 5e6 ,0; 0 ,-5e7; 0 ,-5e7; 0 ,-5e7; 0 ,-5e7;  0 ,5e5;];     %[f_x ,f_y]
  65.    
  66.            
  67.     %The task is solving at the initial data
  68.    
  69. %     [delta_U ,new_point_coordinate_in_global_numbers ,K] = FEM_for_linear_tasks(D ,N ,M ,t ,Cn ,Cs ,overloaded_elements ,overloaded_contact_elements ,point_global_number  ,point_coordinate_in_global_numbers ,point_stress ,local_forse);
  70.    
  71.     %Create parametrs for plots
  72.     FaceColor = zeros(size(point_global_number,1),3);
  73.     FaceColor(:,1) = 0.98824; FaceColor(:,2) = 0.74902; FaceColor(:,3) = 0.10588;
  74.     EdgeColor = zeros(size(point_coordinate_in_global_numbers,1),3);
  75.     EdgeColor(:,1) = 0.0; EdgeColor(:,2) = 0.0; EdgeColor(:,3) = 0.0;
  76.  
  77.     count = 1;
  78.  
  79.     if ~exist('plots/', 'dir')
  80.         mkdir('plots/');
  81.     end
  82.     if ~exist('plots/grid/', 'dir')
  83.         mkdir('plots/grid/');
  84.     end
  85.     if ~exist('plots/strains/', 'dir')
  86.         mkdir('plots/strains/');
  87.     end
  88.            
  89.     old_U = 0;
  90.     while (true)
  91.     if (count == 1)
  92.         fig = domainPlot( point_global_number, point_coordinate_in_global_numbers, FaceColor, EdgeColor,'Iteration 0', false );
  93.         saveas(fig, 'plots/grid/iteration0.png');
  94.        
  95.     end
  96.     [delta_U ,new_point_coordinate_in_global_numbers ,K] = FEM_for_linear_tasks(D ,N ,M ,t ,Cn ,Cs ,overloaded_elements ,overloaded_contact_elements ,point_global_number  ,point_coordinate_in_global_numbers ,point_stress ,local_forse);
  97.     [new_tension ,new_overloaded_elements ,new_overloaded_contact_elements ,virtual_tension,a ,b] = tension_in_element (M ,N ,Cs ,Cn ,sigma_critical ,D ,tension ,overloaded_elements ,point_global_number ,point_coordinate_in_global_numbers ,overloaded_contact_elements ,delta_U);
  98.    
  99.     if (new_overloaded_contact_elements == overloaded_contact_elements) | (new_overloaded_contact_elements == overloaded_contact_elements)
  100.         break;      
  101.     else
  102.         fig = domainPlot( point_global_number, new_point_coordinate_in_global_numbers, FaceColor, EdgeColor, strcat('Iteration',{' '},int2str(count)), false );
  103.         saveas(fig, sprintf('plots/grid/iteration%d.png',count));
  104.        
  105.         for i = 1:1:3
  106.             switch i
  107.                 case 1
  108.                     title = sprintf('\\sigma_x %d',count);
  109.                 case 2
  110.                     title = sprintf('\\sigma_y %d',count);
  111.                 otherwise
  112.                     title = sprintf('\\tau_{xy} %d',count);
  113.             end
  114.             fig = domainPlot( point_global_number, new_point_coordinate_in_global_numbers, abs(new_tension(:,i)), EdgeColor, title, true );
  115.             saveas(fig, sprintf('plots/strains/%s.png',regexprep(title,'[\\{}_ ]','')));
  116.            
  117.         end
  118.         overloaded_elements = new_overloaded_elements;
  119.         overloaded_contact_elements = new_overloaded_contact_elements;
  120.         old_U = delta_U;
  121.     end
  122.     count = count + 1;
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement