Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementing our backward order final equation

Similar presentations


Presentation on theme: "Implementing our backward order final equation"— Presentation transcript:

1 Implementing our backward order final equation
Jennifer Tanyer March 27, 2002

2 Goals: Balance the discretized equation from Bob’s presentation
Develop a system of linear equations from the given equation Modify previous code to solve the implicit function and get values for our unknown concentration at time t+1

3 Our backward order discretized equation:
From Bob’s presentation:

4 Problems with this equation:
The system is not balanced i.e.(# of variables on the LHS  # of variables on the RHS) LHS accounts for interior nodes only RHS accounts for interior and boundary nodes # of Unknowns > #of Equations because of this. The difference in the number is due to the lack of representation for the boundary points

5 Solutions: Add the boundary condition for each boundary node onto the LHS of the equation: c(x,y,t) = 0. Since we can’t solve this system explicitly, we must generate a system of linear equations that establish an algorithm for solving for our unknowns Our unknown : concentration at time t + 1

6 Step 1: Developing the new linear system
Place all of our unknowns: t + 1 onto the LHS of our equation The RHS will be equal to our concentration at time t

7 Step 1:

8 Step 2: Replace equations with their proper node labels

9 Step 3: Combine like terms
Refer to poisson.m These new combined equations will represent w(k,k), w(k,E), w(k,W), w(k,N), and w(k,S) respectively.

10 Step 4: Implement the new equation into ‘concentrate.m’
%Modified concentrate.m deltat=0.5; D=0.1; rho=1; time=10; ntimes=round(time/deltat); NRPOINTS=max(size(a10)); for k=1:NRPOINTS Position=a10(k,1:2); Concentration(k,1)=g(Position); end

11 Modified concentration.m continued…
for m=1:ntimes m w = zeros(1528, 1528); rhs = zeros(1528,1); deltaXsq = 1/deltaX^2; deltaYsq = 1/deltaY^2; for k = 1:1528 N = nb(k,find((nbor(k,:) == 1))); W = nb(k,find((nbor(k,:) == 3))); S = nb(k,find((nbor(k,:) == 5))); E = nb(k,fgind((nbor(k,:) == 7)));

12 gAnd finally… uy = scaledvelocity(k,2); ux = scaledvelocity(k,1);
if(~g(N) & ~isempty(W) & ~isempty(S) & ~isempty(E)) ux = scaledvelocity(k,1); uy = scaledvelocity(k,2); w(k,N) = ((D/rho) * (1/deltaYsq) – uy * (1/(deltaY)*2)); w(k,S) = ((D/rho) * (1/deltaYsq) + uy * (1/(deltaY)*2)); w(k,E) = ((D/rho) * (1/deltaXsq) - ux * (1/(deltaX)*2)); w(k,W) = ((D/rho) * (1/deltaXsq) + ux * (1/(deltaX)*2)); w(k,k) = (-1/deltat – (D/rho)*(2/(deltaXsq)) – (D/rho) *(2/(deltaYsq)); rhs(k,1) = concentration(k,m)/deltat; else w(k,k) = 1; rhs(k,1) = 0; end xjen=w\rhs; concentration(:,m+1)=xjen;

13 In the End… You now have an algorithm of linear equations that you can solve to get a 1532 x 1532 matrix of concentrations at each node. You can use MATLAB to solve Ax = b (w * x) = rhs by using either The inverse of A >>x=inv(A)*b OR Row Reduction >>x1=A\b We no longer have approximate values for our concentrations…we now have actual values


Download ppt "Implementing our backward order final equation"

Similar presentations


Ads by Google