-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.uconn.edu/cpl11001/07_final_p…
- Loading branch information
Showing
3 changed files
with
74 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,63 @@ | ||
function [pw_se,w]=SE_diff(T,P,n) | ||
w = membrane_solution31(T,P,n); | ||
A = zeros(n,n); | ||
h = zeros(n,1); | ||
m = n+1; %Represents the number of nodes | ||
|
||
%Top Left Corner Interior Node | ||
for i = 2+m | ||
A(i,i)=1; | ||
A(i,i-1)=0; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=0; | ||
h(i) = 10; | ||
end | ||
%Top Right Corner Interior Node | ||
for i = m*2-1 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=1; | ||
h(i) = 10; | ||
end | ||
%Bottom Left Corner Interior Node | ||
for i = m*m-(2*m)+1 | ||
A(i,i)=1; | ||
A(i,i-1)=0; | ||
A(i,i+m)=0; | ||
A(i,i+m-1)=0; | ||
h(i) = 10; | ||
end | ||
%Bottom Right Corner Interior Node | ||
for i = (m*m)-m-1 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=0; | ||
A(i,i+m-1)=0; | ||
h(i) = 10; | ||
end | ||
|
||
%The following represent the values for the interior nodes | ||
|
||
%Top Interior Row | ||
for i = 3+m:m*2-2 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=1; | ||
h(i) = 10; | ||
end | ||
%Bottom Interior Row | ||
for i = m*m-(2*m)+2:(m*m)-m-2 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=0; | ||
A(i,i+m-1)=0; | ||
h(i) = 10; | ||
end | ||
%Left Interior Column | ||
for i = (2*m)+2,(2*m)+2:(m*m)-(2*m)+2 | ||
A(i,i)=1; | ||
A(i,i-1)=0; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=0; | ||
h(i) = 10; | ||
end | ||
%Right Interior Column | ||
for i = (3*m)-1,(2*m)+2:(m*m)-(2*m)+2 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=1; | ||
h(i) = 10; | ||
end | ||
%Inerior Nodes | ||
for i = (2*m)+3:(3*m)-2,(2*m)+3:(m*m)-(3*m)+3 | ||
A(i,i)=1; | ||
A(i,i-1)=1; | ||
A(i,i+m)=1; | ||
A(i,i+m-1)=1; | ||
h(i) = 10; | ||
end | ||
|
||
|
||
dw_dx = (A(i,i)-A(i-1)+A(i,i+m)-A(i,i+m-1))/(2.*h); | ||
dw_dx' | ||
function [pw_se,w] = SE_diff(T,P,n) | ||
|
||
% Call function from part c to obtain vector w | ||
w = membrane_solution(T,P,n); | ||
% Create All Nodes Matrix (Interior & Exterior) | ||
m = zeros(n+2); | ||
c = vec2mat(w,n); % Vector w rearranged to n x n matrix. | ||
m(2:n+1,2:n+1) = c; % insert matrix c into middle of m matrix | ||
% m = symmetric matrix | ||
|
||
h = 10/(n+1); % h = delta_x = delta_y (micron) | ||
|
||
% Compute w bar | ||
w_bar = zeros(n+1,n+1); | ||
for i = 1:n+1 | ||
for j = 1:n+1 | ||
w_bar(i,j) = (m(i,j)+m(i,j+1)+m(i+1,j)+m(i+1,j+1))/4; | ||
end | ||
end | ||
|
||
% Left side of the equation | ||
left_side = zeros(n+1,n+1); | ||
for i = 1:(n+1)^2 | ||
left_side(i) = P * h^2*w_bar(i); | ||
end | ||
L = sum(sum(left_side)); | ||
|
||
% Compute dw_dx | ||
dx = zeros(n+2,n+1); | ||
for i = 2:n+2 | ||
dx(:,i-1)= (m(:,i)-m(:,i-1))/(h); | ||
end | ||
|
||
dw_dx = zeros(n+1,n+1); | ||
for i = 1:n+1 % rows | ||
for j = 1:n+1 % columns | ||
dw_dx(i,j) = (dx(i,j)+dx(i+1,j))/2; | ||
end | ||
end | ||
|
||
end | ||
% Compute dw_dy | ||
dy = zeros(n+1,n+2); | ||
for i = 2:n+2 | ||
dy(i-1,:)= (m(i-1,:)-m(i,:))/(h); | ||
end | ||
|
||
dw_dy = zeros(n+1,n+1); | ||
for i = 1:n+1 % rows | ||
for j = 1:n+1 % columns | ||
dw_dy(i,j) = (dy(i,j)+dy(i,j+1))/2; | ||
end | ||
end | ||
|
||
right_side = zeros(n+1,n+1); | ||
|
||
for i = 1:(n+1)^2 | ||
right_side(i) = (0.25*(dw_dx(i))^4+0.25*(dw_dy(i))^4+0.5*(dw_dx(i)*dw_dy(i))^2); | ||
end | ||
R = sum(sum(right_side)); | ||
R = (1000*10^3*0.3*10^-3*h^2)/(2*(1-0.31^2))*R; | ||
|
||
|
||
pw_se = R - L; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters