diff --git a/README.md b/README.md index 73ced6b..c88c1e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Part A ### Problem Statement -Create a function that uses the central finite difference approximation to solve for the displacements of a membrane with 3 x 3 interior nodes. The function should take the pressure and tension as inputs and output a column vector, w. +Create a function called membrane_solution3 that uses the central finite difference approximation to solve for the displacements of a membrane with 3 x 3 interior nodes. The function should take the pressure (P) and tension (T) as inputs and output a column vector, w. ``` matlab function [w] = membrane_solution3(T,P) % Set up initial matrix @@ -26,7 +26,7 @@ end ## Part B ### Problem Statement -Using the function from part A as well as a given tension of 0.006 and a given pressure of 0.001, solve for w and plot the result in 3 dimensions +Using the function from part A as well as a given tension of 0.006 uN/um and a given pressure of 0.001 MPa, solve for w and plot the result in 3 dimensions ``` matlab [w] = membrane_solution3(0.006,0.001); @@ -34,7 +34,10 @@ Using the function from part A as well as a given tension of 0.006 and a given p ![3x3 Interior Nodes](./figures/figure1.png) -### Part C +## Part C +### Problem Statement +Create a function called membrane_solution that uses the central finite difference approximation to solve for the displacements of a membrane with n x n interior nodes. The function should take the pressure (P), tension (T), and number of interior nodes (n) as inputs and output the column vector, w. + ```matlab function [w] = membrane_solution(T,P,n)% Set up initial matrix % T = given tension (microNewton/micrometer) @@ -56,7 +59,8 @@ function [w] = membrane_solution(T,P,n)% Set up initial matrix end ``` -### Part D +## Part D +### Problem Statement ``` matlab [w] = membrane_solution(0.006,0.001,10) ``` diff --git a/SE_diff.m b/SE_diff.m index ac11607..d294e06 100644 --- a/SE_diff.m +++ b/SE_diff.m @@ -8,21 +8,36 @@ 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) + 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 + + left_side(i) = P * h^2*w_bar(i); + end + % 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 - +disp(dw_dx) % Compute dw_dy dy = zeros(n+1,n+2); for i = 2:n+2 @@ -35,7 +50,7 @@ dw_dy(i,j) = (dy(i,j)+dy(i,j+1))/2; end end - + disp(dw_dy) pw_se = zeros(n+1,n+1); for i = 1:(n+1)^2