From a4b43a8ade6acefc32543428b5a585c4f1a18d06 Mon Sep 17 00:00:00 2001 From: Ayush Rathore Date: Thu, 14 Dec 2017 22:59:03 -0500 Subject: [PATCH] Part C update --- README.md | 44 +++++++++++++++++++++++++++++++++----------- membrane_solution.m | 18 +++++++++--------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 519854c..0976c82 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ Solve for w given a pressure, P=0.001 MPa and tension, T=0.006 uN/um. Plot the r `surf(X,Y,W)` where X, Y, and W are the x-, y-, and z-coordinates of each point on the membrane from 0-10um. #### Approach - T = 0.006 uN/um P = 0.001 MPa ```matlab @@ -56,23 +55,46 @@ P = 0.001 MPa #### Problem Statement Create a general central finite difference approximation of the gradient with n-by-n interior nodes of w -for the given membrane solution in terms of P and T. `[w]=membrane_solution(T,P,n);` The -output `w` should be a vector, but the solution represents a 2D data set w(x,y). -#### Approach +for the given membrane solution in terms of P and T. `[w]=membrane_solution(T,P,n);` -General central finite difference approximation for gradient -of nxn interior nodes of w. +#### Approach ```matlab -[w] = membrane_solution(T,P,n) +function [w] = membrane_solution(T,P,n) + % General Central finite difference approximation of + % gradient with n-by-n interior nodes in terms of P & T. + % Input: + % T = tension per unit length (uN/um) + % P = pressure (MPa) + % n = # of interior node rows/columns + % Output: + % w = displacement vector for interior nodes + + od = ones(n^2-1,1); + od(n:n:end) = 0; + k = -4 * diag(ones(n^2,1)) + diag(ones((n^2)-n,1),n) + diag(ones((n^2)-n,1),-n) + diag(od,1) + diag(od,-1); + + y = -(10/(n+1))^2*(P/T)*ones(n^2,1); + w = k\y; + + % Find displacement vector w + % which represents 2D data set w(x,y) + [x,y] = meshgrid(0:10/(n+1):10,0:10/(n+1):10); + z = zeros(size(x)); + z(2:end-1,2:end-1) = reshape(w,[n n]); + + % Plot gradient of membrane displacement + surf(x,y,z) + title('Gradient of Membrane Displacement') + zlabel('Displacement [um] (micrometers)') +end + ``` ## Part D #### Problem Statement -Solve for w given a pressure, P=0.001 MPa and tension, T=0.006 uN/um with 10 interior -nodes. Plot the result with `surf(X,Y,W)` where X, Y, and W are the x-, y-, and -z-coordinates of each point on the membrane from 0-10um. -#### Approach +Solve for w given a pressure, P=0.001 MPa and tension, T=0.006 uN/um with 10 interior nodes. Plot the result with `surf(X,Y,W)` where X, Y, and W are the x-, y-, and z-coordinates of each point on the membrane from 0-10um. +#### Approach - T = 0.006 uN/um - P = 0.001 MPa - n = 10 nodes diff --git a/membrane_solution.m b/membrane_solution.m index 0f68771..4e12254 100644 --- a/membrane_solution.m +++ b/membrane_solution.m @@ -1,28 +1,28 @@ function [w] = membrane_solution(T,P,n) - % + % General Central finite difference approximation of + % gradient with n-by-n interior nodes in terms of P & T. + % Input: % T = tension per unit length (uN/um) % P = pressure (MPa) - % n = # of interior nodes + % n = # of interior node rows/columns + % Output: + % w = displacement vector for interior nodes od = ones(n^2-1,1); od(n:n:end) = 0; k = -4 * diag(ones(n^2,1)) + diag(ones((n^2)-n,1),n) + diag(ones((n^2)-n,1),-n) + diag(od,1) + diag(od,-1); - % y = -(10/(n+1))^2*(P/T)*ones(n^2,1); - - % w = k\y; - % + % Find displacement vector w + % which represents 2D data set w(x,y) [x,y] = meshgrid(0:10/(n+1):10,0:10/(n+1):10); - % z = zeros(size(x)); - z(2:end-1,2:end-1) = reshape(w,[n n]); + % Plot gradient of membrane displacement surf(x,y,z) - title('Gradient of Membrane Displacement') zlabel('Displacement [um] (micrometers)') end