Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Help
- Loading branch information
mattmaliniak
committed
Dec 15, 2017
1 parent
4bcd4b4
commit f9e32f6
Showing
13 changed files
with
230 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
function [w] = membrane_solution3(T,P) | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
|
||
od = ones(8,1); | ||
od(3:3:end) = 0; | ||
k = -4*diag(ones(9,1))+diag(ones(9-3,1),3)+diag(ones(9-3,1),-3)+diag(od,1)+diag(od,-1); | ||
|
||
|
||
y = -(10/4)^2*(P/T)*ones(9,1); | ||
w = k\y; | ||
% Solves for displacement (micrometers) | ||
% Solution represents a 2D data set w(x,y) | ||
% membrane_solution3: dispalacement of node for membrane with 3x3 interior | ||
% nodes | ||
% [w] = membrane_solution3(T,P) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% output: | ||
% w = vector of displacement of interior nodes | ||
|
||
[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) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
|
||
end | ||
od = ones(8,1); | ||
od(3:3:end) = 0; | ||
k = -4*diag(ones(9,1))+diag(ones(9-3,1),3)+diag(ones(9-3,1),-3)+diag(od,1)+diag(od,-1); | ||
|
||
|
||
y = -(10/4)^2*(P/T)*ones(9,1); | ||
w = k\y; | ||
|
||
% Solves for displacement (micrometers) | ||
% Solution represents a 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) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
|
||
% Membrane displacement is shown on chart | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function [w] = membrane_solution(T,P,n) | ||
% membrane_solution: dispalacement of node for membrane with nxn interior nodes | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% output: | ||
% w = vector of displacement of 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; | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,28 @@ | ||
function [w] = membrane_solution(T,P,n) | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = # of interior nodes | ||
% membrane_solution: dispalacement of node for membrane with nxn interior nodes | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% w = vector of displacement of 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); | ||
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; | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 2D data set w(x,y) | ||
y = -(10/(n+1))^2*(P/T)*ones(n^2,1); | ||
w = k\y; | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
[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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
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
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,23 +1,28 @@ | ||
function [w] = membrane_solution(T,P,n) | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = # of interior nodes | ||
% membrane_solution: dispalacement of node for membrane with nxn interior nodes | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% w = vector of displacement of 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); | ||
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; | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 2D data set w(x,y) | ||
y = -(10/(n+1))^2*(P/T)*ones(n^2,1); | ||
w = k\y; | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
[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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
% Membrane displacement is shown on chart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function re = Rel_error (T) | ||
% Rel_error: calculates relative error of a vector | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% w = vector of displacement of interior nodes | ||
|
||
re = zeros(1,length(T)-1); | ||
for i = 2:length(T) | ||
re(i-1)= abs(T(i)-T(i-1))/T(i-1); | ||
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
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,25 +1,31 @@ | ||
function [w] = membrane_solution(T,P,n) | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = # of interior nodes | ||
% membrane_solution: dispalacement of node for membrane with nxn interior nodes | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% w = vector of displacement of 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; | ||
|
||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 2D data set w(x,y) | ||
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); | ||
|
||
[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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
|
||
% Membrane displacement is shown on chart | ||
y = -(10/(n+1))^2*(P/T)*ones(n^2,1); | ||
w = k\y; | ||
|
||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
|
||
% Membrane displacement is shown on chart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
function [T,ea] = tension_sol(P,n) | ||
% tension_sol: outputs tension of a membrane given the pressure and number | ||
% of nodes | ||
% [T,ea] = tension_sol(P,n) | ||
% input: | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% T = Tension (microNewton/micrometer) | ||
% ea = approximate relative error (%) | ||
|
||
y =@(T) SE_diff(T,P,n); | ||
[T,fx,ea,iter]=bisect(y,.01,1); |
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,25 +1,30 @@ | ||
function [w] = membrane_solution(T,P,n) | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = # of interior nodes | ||
% membrane_solution: dispalacement of node for membrane with nxn interior nodes | ||
% [w] = membrane_solution(T,P,n) | ||
% input: | ||
% T = Tension (microNewton/micrometer) | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% w = vector of displacement of 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); | ||
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; | ||
|
||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 2D data set w(x,y) | ||
y = -(10/(n+1))^2*(P/T)*ones(n^2,1); | ||
w = k\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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
|
||
% Membrane displacement is shown on chart | ||
% Solves for displacement (micrometers) | ||
% Output w is a vector | ||
% Solution represents a 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]); | ||
surf(x,y,z) | ||
title('Membrane Displacement') | ||
zlabel('Displacement (micrometer)') | ||
|
||
% Membrane displacement is shown on chart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
function [T,ea] = tension_sol(P,n) | ||
% tension_sol: outputs tension of a membrane given the pressure and number | ||
% of nodes | ||
% [T,ea] = tension_sol(P,n) | ||
% input: | ||
% P = Pressure (MPa) | ||
% n = number of rows and columns of interior nodes | ||
% output: | ||
% T = Tension (microNewton/micrometer) | ||
% ea = approximate relative error (%) | ||
|
||
y =@(T) SE_diff(T,P,n); | ||
[T,fx,ea,iter]=bisect(y,.01,1); |