Question
We have a single straight pipe with 7 nodes and 6 elements. (The nodes are at each end and between the elements). The following code
We have a single straight pipe with 7 nodes and 6 elements. (The nodes are at each end and between the elements). The following code is Newton's Method applied to this problem. Some statements have been removed. Fix the code and then solve for the paramenters shown. This is a MatLab Code
Element 1 | Element 2 | Element 3 | Element 4 | Element 5 | Element 6 |
clear all;
close all;
pbar=3.0; % characteristic pressure
kio=1.0; % Initial flow conductance
nel = 6; %number of elements
nnode = 7; % number of nodes
p=zeros(nnode,1); % Initialize pressure vector
p(1)=1; % boundary condition
rhs=[0 kio 0 0 0 0 0]'; %Initialize RHS vector
residual=ones(7,1); % Initialize residual
toler_r = 0.001;
maxiter=100;
iter=0;
while iter < maxiter && norm(residual)/norm(rhs) > toler_r
iter=iter+1;
amat=zeros(nnode,nnode); % Initialize the matrix.
jacob=zeros(nnode,nnode); % Initialize the Jacobian matrix.
for i = 1:nel % construct the matrix element-by-element
p_el=(p(i)+p(i+1))/2.0;
k_el = kio*(1+p_el/pbar)^4;
dkdp= 4*kio*(1+p_el/pbar)^3/(2*pbar);
amat(i,i)=;
amat(i,i+1)=;
amat(i+1,i)=
amat(i+1,i+1)=;
jacob(i,i)= ;
jacob(i,i+1)= ;
jacob(i+1,i)= ;
jacob(i+1,i+1)= ;
if i==1
rhs(i+1)=k_el;
end
end
jacob
residual=rhs(2:6)-amat(2:6,2:6)*p(2:6)
p_s= amat(2:6, 2:6) \ rhs(2:6);
p(2:6)=p(2:6)+p_s
pause;
end
iter
plot(p);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started