Extract data from countour and add two (or more) contours together.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
William White
le 7 Juil 2015
Modifié(e) : William White
le 7 Juil 2015
My problem is thus:
I have a mesh onto which I 'plot' a function.
That is, for every point x,y, I have a value Q
What I want to do is extract the value of Q for every x,y and ADD (superimpose) it to the value of Q for every x,y .
My code plots a stress field centered at at point (0,0) then it is moved a length dx and dy and an appropratiate step length. Then this is plotted.
If I have more than one point, I wish to superimpose the data.
i.e. I wish to set up a loop where the original position is kept, then another stress field is generated at different dx, dy, and then the two are added.
regards William
u = 80000; % Shear modulus, measure in Mpa nu = 0.3; % Poissions ratio of material b = .00025; % Burgers Vector measured in microns
[x,y]=meshgrid(-100:1:100,-100:1:100); % area of grid to which stress field is mapped
angle = 54.7; % angle of slip plane in degrees
theta = angle*pi/180; % angle converted to radians
steplength = 400;
interplanarspacing = 100*b; % spacing between slip planes is about 100 b
x2 = (x.*cos(theta) + y.*sin(theta));% rotates and displaces dislocation
y2 = (y.*cos(theta) - x.*sin(theta));%; rotates and displaces dislocation
QxxPRIME = -(u .* b / (2.*pi .* (1-nu))) .* ((y2 .* (3.*x2.^2 +y2.^2)) ./ ((x2.^2 + y2.^2).^2)); % Qyy stress PRIME
QyyPRIME = (u .* b / (2.*pi .* (1-nu))) .* ((y2 .* (x2.^2 -y2.^2)) ./ ((x2.^2 + y2.^2).^2)); % Qyy stress PRIME
QxyPRIME = (u .* b / (2.*pi .* (1-nu))) .* ((x2 .* (x2.^2 -y2.^2)) ./ ((x2.^2 + y2.^2).^2)); % Qxy stress PRIME
QxxPRIME(QxxPRIME<-.5) = -.5; % erase low value
QxxPRIME(QxxPRIME>.5) = .5; % erase high value
dx = steplength.*cos(theta);
dy = steplength.*sin(theta);
y = y+dy;
x = x+dx;
caxis([-0.5,0.5]); % set the legend limit
contourf(x(1,:),y(:,1)',QxxPRIME)
axis equal
0 commentaires
Réponse acceptée
Thorsten
le 7 Juil 2015
Modifié(e) : Thorsten
le 7 Juil 2015
The idea is to compute a new QxxPRIME for the different offsets and add them to QxxPRIME0 for zero offset:
u = 80000; % Shear modulus, measure in Mpa
nu = 0.3; % Poissions ratio of material
b = .00025; % Burgers Vector measured in microns
N = 500; % grid size
[x,y]=meshgrid(-N:1:N,-N:1:N); % area of grid to which stress field is mapped
angle = 54.7; % angle of slip plane in degrees
theta = angle*pi/180; % angle converted to radians
steplength = 400;
interplanarspacing = 100*b; % spacing between slip planes is about 100 b
Nsteps = 10;
c = -(u*b/(2*pi*(1 - nu))); % constants independent of loop variable sl
for sl = linspace(0, steplength, Nsteps)
dx = sl.*cos(theta);
dy = sl.*sin(theta);
x2 = x.*cos(theta) + y.*sin(theta) + dx;% rotates and displaces dislocation
y2 = y.*cos(theta) - x.*sin(theta) + dy;%; rotates and displaces dislocation
QxxPRIME = c*(y2.*(3*x2.^2 + y2.^2))./((x2.^2 + y2.^2).^2); % Qyy stress PRIME
QxxPRIME(QxxPRIME<-.5) = -.5; % erase low value
QxxPRIME(QxxPRIME>.5) = .5; % erase high value
subplot(1,2,1)
contourf(x,y,QxxPRIME)
caxis([-0.5,0.5])
axis square
title(['Contour at Steplength ' num2str(sl)])
if sl == 0
QxxPRIME0 = QxxPRIME;
else
QxxPRIME = QxxPRIME0 + QxxPRIME;
end
subplot(1,2,2)
contourf(x,y,QxxPRIME)
caxis([-0.5,0.5])
axis square
title(['Steplength 0 + ' num2str(sl)])
pause
end
6 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Stress and Strain dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!