From ed836265bf5eeebec4b958de8a59ee12cdb424d1 Mon Sep 17 00:00:00 2001 From: Ayush Rathore Date: Thu, 14 Dec 2017 22:55:41 -0500 Subject: [PATCH] Part A update --- README.md | 121 ++++++++++++++++++++++++++----------------- SE_diff.m | 2 +- membrane_solution3.m | 12 +++-- 3 files changed, 81 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index cd28060..519854c 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,38 @@ ## Part A #### Problem Statement Create a central finite difference approximation of the gradient with 3-by-3 interior nodes of w -for the given membrane solution in terms of P and T. `[w]=membrane_solution3(T,P);` The -output `w` should be a vector, but the solution represents a 2D data set w(x,y). +for the given membrane solution in terms of P and T. `[w]=membrane_solution3(T,P);` + #### Approach -Central finite difference approximation for gradient of 3x3 interior nodes of w. ```matlab -[w] = membrane_solution3(T,P); +function [w] = membrane_solution3(T,P) + % Central finite difference approximation of gradient + % with 3x3 (um^2) interior nodes in terms of P & T. + % Input: + % T = tension per unit length (uN/um) + % P = pressure (MPa) + % Output: + % w = displacement vector for interior nodes + + od = ones(8,1); + od(3:3:end) = 0; + k = -4 * diag(ones((3^2),1)) + diag(ones((3^2)-3,1),3) + diag(ones((3^2)-3,1),-3) + diag(od,1) + diag(od,-1); + + y = -(10/4)^2*(P/T)*ones(9,1); + w = k\y; + + % Find displacement vector w + % which represents 2D data set w(x,y) + [x,y] = meshgrid(0:10/4:10,0:10/4:10); + z = zeros(size(x)); + z(2:end-1,2:end-1) = reshape(w,[3 3]); + + % Plot gradient of membrane displacement + surf(x,y,z) + title('Gradient of Membrane Displacement') + zlabel('Displacement [um] (micrometers)') +end + ``` ## Part B @@ -67,50 +93,50 @@ elements to calculate work done and strain energy. #### Approach ```matlab function [pw_se,w] = SE_diff(T,P,n) -% function that calculates the difference between -% strain energy and work done by pressure on the membrane. -% Input: -% T = tension per unit length (uN/um) -% P = pressure (MPa) -% n = # of interior nodes -% Output: -% pw_se = Absolute value of difference between strain energy and work done by pressure -% w = displacement vector for interior nodes - -E = 1e6; % 1 TPa ~= 10^6 MPa -t = 3*10^-4; % thickness [um] -h = 10/(n+1); % height [um] -v = 0.31; % Poisson's Ratio - -% Displacement vector w found using Part C -w = membrane_solution(T,P,n); -z = zeros(n + 2); -z(2:end-1,2:end-1) = reshape(w,[n n]); - -% Calculate average displacement, wavg, for each element by taking the displacement at each -% corner and then average the found values. -num = n + 1; -wavg = zeros(num); -for i = 1:num - for j = 1:num - wavg(i,j) = mean([z(i,j),z(i+1,j),z(i,j+1),z(i+1,j+1)]); - end -end - -% final work done by pressure -pw = sum(sum(wavg.*h^2.*P)) - -% to find= change in displacement, find the change in displacement on -% the x-axis, dwdx, and the change in displacement on the y-axis, dwdy, and -% average the found values. -dwdx = zeros(num); -dwdy = zeros(num); -for i = 1:num + % function that calculates the difference between + % strain energy and work done by pressure on the membrane. + % Input: + % T = tension per unit length (uN/um) + % P = pressure (MPa) + % n = # of interior node rows/columns + % Output: + % pw_se = Absolute value of difference between strain energy and work done by pressure + % w = displacement vector for interior nodes + + E = 1e6; % 1 TPa ~= 10^6 MPa + t = 3*10^-4; % thickness [um] + h = 10/(n+1); % height [um] + v = 0.31; % Poisson's Ratio + + % Displacement vector w found using Part C + w = membrane_solution(T,P,n); + z = zeros(n + 2); + z(2:end-1,2:end-1) = reshape(w,[n n]); + + % Calculate average displacement, wavg, for each element by taking the displacement at each + % corner and then average the found values. + num = n + 1; + wavg = zeros(num); + for i = 1:num for j = 1:num - dwdx(i,j) = mean([z(i+1,j)-z(i,j),z(i+1,j+1)-z(i,j+1)]); - dwdy(i,j) = mean([z(i,j+1)-z(i,j),z(i+1,j+1)-z(i+1,j)]); + wavg(i,j) = mean([z(i,j),z(i+1,j),z(i,j+1),z(i+1,j+1)]); end -end + end + + % final work done by pressure + pw = sum(sum(wavg.*h^2.*P)) + + % to find= change in displacement, find the change in displacement on + % the x-axis, dwdx, and the change in displacement on the y-axis, dwdy, and + % average the found values. + dwdx = zeros(num); + dwdy = zeros(num); + for i = 1:num + for j = 1:num + dwdx(i,j) = mean([z(i+1,j)-z(i,j),z(i+1,j+1)-z(i,j+1)]); + dwdy(i,j) = mean([z(i,j+1)-z(i,j),z(i+1,j+1)-z(i+1,j)]); + end + end % Using dwdx and dwdy, calculate the strain energy, se. se = (E*t*h^2)/(2*(1-v^2)) * sum(sum((1/4).*dwdx.^4+(1/4).*dwdy.^4+(1/4).*(dwdx.*dwdy).^2)); @@ -121,8 +147,7 @@ pw_se = pw - se; ## Part F #### Problem Statement -Use a root-finding method to calculate the tension in the membrane given a -pressure, P=0.001 MPa, and n=[20:5:40] interior nodes. +Use a root-finding method to calculate the tension in the membrane given a pressure, P=0.001 MPa, and n=[20:5:40] interior nodes. Show that the error in tension is decreasing with a table: #### Approach diff --git a/SE_diff.m b/SE_diff.m index dcb9ae7..c97e063 100644 --- a/SE_diff.m +++ b/SE_diff.m @@ -4,7 +4,7 @@ % Input: % T = tension per unit length (uN/um) % P = pressure (MPa) -% n = # of interior nodes +% n = # of interior node rows/columns % Output: % pw_se = Absolute value of difference between strain energy and work done by pressure % w = displacement vector for interior nodes diff --git a/membrane_solution3.m b/membrane_solution3.m index 792c208..e0783ca 100644 --- a/membrane_solution3.m +++ b/membrane_solution3.m @@ -1,25 +1,27 @@ function [w] = membrane_solution3(T,P) % Central finite difference approximation of gradient % with 3x3 (um^2) interior nodes in terms of P & T. + % Input: % T = tension per unit length (uN/um) % P = pressure (MPa) + % Output: + % w = displacement vector for interior nodes od = ones(8,1); od(3:3:end) = 0; k = -4 * diag(ones((3^2),1)) + diag(ones((3^2)-3,1),3) + diag(ones((3^2)-3,1),-3) + diag(od,1) + diag(od,-1); - % y = -(10/4)^2*(P/T)*ones(9,1); - % w = k\y; - % + % Find displacement vector w + % which represents 2D data set w(x,y) [x,y] = meshgrid(0:10/4:10,0:10/4:10); z = zeros(size(x)); - % z(2:end-1,2:end-1) = reshape(w,[3 3]); - surf(x,y,z) + % Plot gradient of membrane displacement + surf(x,y,z) title('Gradient of Membrane Displacement') zlabel('Displacement [um] (micrometers)') end