CS计算机代考程序代写 scheme matlab [Content_Types].xml

[Content_Types].xml

_rels/.rels

matlab/document.xml

matlab/output.xml

metadata/coreProperties.xml

metadata/mwcoreProperties.xml

metadata/mwcorePropertiesExtension.xml

metadata/mwcorePropertiesReleaseInfo.xml

Types of Boundary Conditions for Finite Difference Methods In this livescript, you will learn how To implement varying types of boundary conditions. Boundary value problems are differential equations of the form \frac{d^{2}y}{dx^{2}}+p(x)\frac{dy}{dx}+q(x)y=r(x) coupled with some constraints at the boundary, called boundary conditions, which can be specified as Dirichlet Neumann Periodic Dirichlet boundary conditions are simplest in form, as it just specifies the function value at the boundaries. For example, specifying the temperature at the boundaries. y(0)=\alpha\\
y(L)=\beta which gives the equations y_{1}=\alpha\\
y_{N}=\beta which may be implemented in matrix form by excluding the boundary nodes from the differentiation matrix and substracting the dependence from the right-hand-side. Neumann boundary conditions on the other hand specify the derivative at the boundaries. Physically, this corresponds to some sort of flux entering the domain, such as heat. y'(0)=\alpha\\
y'(L)=\beta Since we can’t exactly evaluate the derivative at the boundaries, we have to use a finite difference approximation to rewrite the derivative in terms of the end nodes. For example, for \Big(\frac{dy}{dx} \Big)_{x=0}=\alpha we could use a forward difference method \frac{y_{2}-y_{1}}{\Delta}=\alpha Rearranging for y_{1} gives the following equation for the end node. y_{1}=y_{2}-\alpha\Delta More complicated implementations that use higher order schemes and involve imaginary nodes outside the domain do exist, but for simplicity, we’ll just stick with this. If we consider steady-state heat diffusion again \frac{d^{2}T}{dx^{2}}=0 with the boundary conditions T'(0)=1 and T(1)=1 , modifying the code from last week gives N = 10;
xmesh = linspace(0,1,N+1);
dx = 1/N;

C = zeros(N+1,N+1);
b = zeros(N+1,1);

for k = 2:N
C(k,k-1:k+1) = [1,-2,1];
b(k) = 0;
end

C(1,1:2) = [1,-1];
C(end:end) = 1;
b(1) = -1*dx;
b(end) = 1;

T = C\b
plot(xmesh,T)
xlabel(‘x’)
ylabel(‘Temperature’) Periodic boundary conditions essentially loop the domain back on itself, like in Pac-Man. They’re useful when considering infinite systems that have very similar behaviour no matter where you look, since exiting one cell and entering the next looks pretty much the same as entering that first cell. To describe this, the boundary conditions are given by y(0)=y(L) For example, the derivative at the first node using a backward difference scheme is given by \Big(\frac{dy}{dx}\Big)_{x=0}=\frac{y_{1}-y_{0}}{\Delta} But since y_{0} lies outside of our domain, periodicity means that we can set it as the end node y_{0}=y_{N} , giving \Big(\frac{dy}{dx}\Big)_{x=0}=\frac{y_{1}-y_{N}}{\Delta} which would give a [C] matrix of [C]
=
\pmatrix{
1&0 & \cdots & 0 &-1\cr
\vdots & & \ddots & & \vdots
} To see what this would look like, a function that solves the convection equation \frac{\partial\phi}{\partial t}+U\frac{\partial\phi}{\partial x} using a backward difference scheme is given below. linear_convection_example()

manual code ready 0.4 true false 0 29 29 false false 1 30 30 false false 2 31 31 false false 3 33 33 false false 4 34 34 false false 5 36 39 false false 6 41 41 false false 7 42 42 false false 8 43 43 false false 9 44 44 false false 10 46 46 false false 11 47 47 false false 12 48 48 false true 13 49 49 true true 14 63 63

2020-05-10T15:33:16Z 2020-09-27T02:56:37Z

application/vnd.mathworks.matlab.code MATLAB Code R2020b

9.9.0.1444674 2486e74a-a549-4251-837b-4aa0b73c44ec

9.9.0.1467703
R2020b

Aug 26 2020
2314982500