Main Content

求解PDE并计算部分衍生物

This example shows how to solve a transistor partial differential equation (PDE) and use the results to obtain partial derivatives that are part of solving a larger problem.

考虑PDE

t = d 2 X 2 - d η l X

这个方程式在晶体管理论[1]中产生,并且 (( X ,,,, t is a function describing the concentration of excess charge carriers (or)在PNP晶体管的底部。 d 一个nd η 一个re physical constants. The equation holds on the interval 0 X l 时间 t 0

The initial condition includes a constant k 并给出

(( X ,,,, 0 = k l d (( 1 - e - η (( 1 - X / l η

该问题具有给出的边界条件

(( 0 ,,,, t = (( l ,,,, t = 0

For fixed X ,方程的解决方案 (( X ,,,, t desCribes the collapse of excess charge as t 。This collapse produces a current, called the发射器排放电流,还有另一个常数 p

(( t = [[ p d k X (( X ,,,, t 这是给予的 X = 0

该方程对 t > 0 d你eto the inconsistency in the boundary values at X = 0 为了 t = 0 一个nd t > 0 。自从the PDE has a closed-form series solution for (( X ,,,, t ,您可以通过分析和数值计算发射器放电电流,并比较结果。

要在MATLAB中解决此问题,您需要编码PDE方程,初始条件和边界条件,然后在调用求解器之前选择合适的解决方案网格pdepe。您要么可以将所需的函数作为文件末尾的本地函数包含(如在此处完成),要么将其保存为单独的命名文件,在MATLAB路径上的目录中命名文件。

deFine Physical Constants

To keep track of the physical constants, create a structure array with fields for each one. When you later define functions for the equations, the initial condition, and the boundary conditions, you can pass in this structure as an extra argument so that the functions have access to the constants.

c.l = 1;C.D = 0.1;c.eta = 10;C.K = 1;c.ip = 1;

Code Equation

在可以编码方程式之前,您需要确保其处于形式pdepesolver expects:

C (( X ,,,, t ,,,, ,,,, X t = X - m X (( X m F (( X ,,,, t ,,,, ,,,, X + s (( X ,,,, t ,,,, ,,,, X

以这种形式,PDE是

t = X 0 X (( X 0 d X - d η l X

因此,方程中系数的值是

  • m = 0 ((C一个rtesian coordinates with no angular symmetry)

  • C (( X ,,,, t ,,,, ,,,, X = 1

  • F (( X ,,,, t ,,,, ,,,, X = d X

  • s (( X ,,,, t ,,,, ,,,, X = - d η l X

Now you can create a function to code the equation. The function should have the signature[[C,,,,F,,,,s这是给予的=transistorPDE(x,t,u,dudx,C)

  • Xis the independent spatial variable.

  • t是独立时间变量。

  • is the dependent variable being differentiated with respect toX一个ndt

  • dudxis the partial spatial derivative / X

  • Cis an extra input containing the physical constants.

  • 输出C,,,,F,,,,一个nds对应于标准PDE方程式中的系数,预期pdepe

As a result, the equation in this example can be represented by the function:

F你nCtion[c,f,s] =晶体管(x,t,u,dudx,c)d = c.d;eta = c.eta;l = c.l;C = 1;f = d*dudx;s =  - (d*eta/l)*dudx;结尾

(注意:在示例末尾,所有功能都包含为本地功能。)

代码初始条件

Next, write a function that returns the initial condition. The initial condition is applied at the first time value, and provides the value of (( X ,,,, t 0 为了一个ny value of X 。使用功能签名u0 =晶体管(x,c)to write the function.

The initial condition is

(( X ,,,, 0 = k l d (( 1 - e - η (( 1 - X / l η

相应的功能是

F你nCtionu0 =晶体管(x,c)k = c.k;l = c.l;d = c.d;eta = c.eta;u0 =(k*l/d)*(1- exp(-eta*(1- x/l)))/eta;结尾

Code Boundary Conditions

Now, write a function that evaluates the boundary conditions (( 0 ,,,, t = (( 1 ,,,, t = 0 。For problems posed on the interval 一个 X b ,,,,the boundary conditions apply for all t 一个ndeither X = 一个 or X = b 。求解器预期的边界条件的标准形式为

p (( X ,,,, t ,,,, + (( X ,,,, t F (( X ,,,, t ,,,, ,,,, X = 0

Written in this form, the boundary conditions for this problem are

- 为了 X = 0 ,,,,the equation is + 0 Å d X = 0 系数是:

  • p l (( X ,,,, t ,,,, = ,,,,

  • l (( X ,,,, t = 0

-likewise for X = 1 ,,,,the equation is + 0 Å d X = 0 系数是:

  • p r (( X ,,,, t ,,,, = ,,,,

  • r (( X ,,,, t = 0

边界功能应使用功能签名[PL,QL,PR,QR] =晶体管(XL,UL,XR,UR,T)

  • 输入xl一个nd你lCorrespond to X 一个nd 对于左边界。

  • The inputsxr一个ndurCorrespond to X 一个nd 对于正确的边界。

  • t是独立时间变量。

  • 输出pl一个ndQLCorrespond to p l (( X ,,,, t ,,,, 一个nd l (( X ,,,, t 为了the left boundary ( X = 0 对于这个问题)。

  • 输出PR一个ndQRCorrespond to p r (( X ,,,, t ,,,, 一个nd r (( X ,,,, t 为了the right boundary ( X = 1 对于这个问题)。

The boundary conditions in this example are represented by the function:

F你nCtion[PL,QL,PR,QR] =晶体管(XL,UL,XR,UR,T)pl=你l; ql = 0; pr = ur; qr = 0;结尾

SeleCtSolution Mesh

The solution mesh defines the values of X 一个nd t where the solution is evaluated by the solver. Since the solution to this problem changes rapidly, use a relatively fine mesh of 50 spatial points in the interval 0 X l 一个nd50 time points in the interval 0 t 1

X=linspace(0,C.L,50); t = linspace(0,1,50);

求解方程

最后,使用对称性求解方程 m ,,,,the PDE equation, the initial condition, the boundary conditions, and the meshes for X 一个nd t 。自从pdepe期望PDE函数使用四个输入,而初始条件函数将使用一个输入,创建函数句柄将物理常数的结构传递为额外的输入。

m=0; eqn = @(x,t,u,dudx) transistorPDE(x,t,u,dudx,C); ic = @(x) transistorIC(x,C); sol = pdepe(m,eqn,ic,@transistorBC,x,t);

pdepe返回3-D阵列中的解决方案sol,,,,whereSOL(I,J,K)一个pPRoximates thek溶液的分量 k evaluated att(i)一个ndX((j)。对于这个问题has only one component, but in general you can extract thekth solution component with the command你=sol(:,:,k)

u = sol(:,:,1);

图解决方案

Create a surface plot of the solution 在选定的网格点绘制 X 一个nd t

s你rf(x,t,u) title(“数值解决方案(50个网格点)”)Xl一个bel(('距离x')ylabel('时间t')zlabel(“解决方案u(x,t)”

图包含一个轴对象。The axes object with title Numerical Solution (50 mesh points) contains an object of type surface.

现在,只是绘制 X 一个nd to get a side view of the contours in the surface plot.

plot(x,u) xlabel('距离x')ylabel(“解决方案u(x,t)”)title('Solution profiles at several times'

图包含一个轴对象。带有标题解决方案配置文件的轴对象几次包含50个类型行的对象。

Compute Emitter Discharge Current

Using a series solution for (( X ,,,, t ,发射器排放电流可以表示为无限序列[1]:

(( t = 2 π 2 p (( 1 - e - η η n = 1 n 2 n 2 π 2 + η 2 / 4 e - DT l 2 (( n 2 π 2 + η 2 / 4

编写一个函数来计算分析解决方案 (( t 在本系列中使用40项。唯一的变量time, but specify a second input to the function for the structure of constants.

F你nCtion我t=serex3(t,C)% Approximate I(t) by series expansion.我p=C。我p; eta = C.eta; D = C.D; L = C.L; It = 0;为了n=1:40%使用40项m =(n*pi)^2 + 0.25*eta^2;it = it +((n*pi)^2 / m)*exp( - (d / l^2)*m*t);结尾我t=2*Ip*((1 - exp(-eta))/eta)*It;结尾

使用数字解决方案 (( X ,,,, t 一个sComputed bypdepe,,,,you can also calculate the numeric approximation for (( t X = 0

(( t = [[ p d k X (( X ,,,, t 这是给予的 X = 0

C一个lC你l在ethe analytic and numeric solutions for (( t 一个ndplot the results. UsePdeval计算价值 / X X = 0

nt=length(t); I = zeros(1,nt); seriesI = zeros(1,nt); iok = 2:nt;为了j = iok%在时间t(j),计算x = 0时的du/dx。[[~,I(j)] = pdeval(m,x,u(j,:),0); seriesI(j) = serex3(t(j),C);结尾% Numeric solution has form I(t) = (I_p*D/K)*du(0,t)/dx我=((C。我p*C.D/C.K)*I; plot(t(iok),I(iok),'o',,,,t((iok),seriesI(iok)) legend('来自pdepe + pdeval',,,,“来自系列”)title(“发射器排放电流i(t)”)Xl一个bel(('时间t'

图包含一个轴对象。带有标题发射器放电电流i(t)的轴对象包含2个类型线的对象。这些对象代表pdepe + pdeval,来自系列。

结果匹配得很好。您可以进一步改善数字结果pdepeby using a finer solution mesh.

本地功能

这里列出的是PDE求解器的本地辅助功能pdepeC一个llsto calculate the solution. Alternatively, you can save these functions as their own files in a directory on the MATLAB path.

F你nCtion[[C,,,,F,,,,s这是给予的=transistorPDE(x,t,u,dudx,C)% Equation to solved = c.d;eta = c.eta;l = c.l;C = 1;f = d*dudx;s =  - (d*eta/l)*dudx;结尾%------------------------------------------------------------------------------F你nCtionu0 =晶体管(x,c)% Initial conditionk=C。k; L = C.L; D = C.D; eta = C.eta; u0 = (K*L/D)*(1 - exp(-eta*(1 - x/L)))/eta;结尾%------------------------------------------------------------------------------F你nCtion[PL,QL,PR,QR] =晶体管(XL,UL,XR,UR,T)% Boundary conditionspl=你l; ql = 0; pr = ur; qr = 0;结尾%------------------------------------------------------------------------------F你nCtion我t=serex3(t,C)% Approximate I(t) by series expansion.我p=C。我p; eta = C.eta; D = C.D; L = C.L; It = 0;为了n=1:40%使用40项m =(n*pi)^2 + 0.25*eta^2;it = it +((n*pi)^2 / m)*exp( - (d / l^2)*m*t);结尾我t=2*Ip*((1 - exp(-eta))/eta)*It;结尾%------------------------------------------------------------------------------

reFerences

[1] Zachmanoglou,E.C。和D.L.thoe。与应用程序的部分微分方程简介。纽约多佛,1986年。

也可以看看

rel在edTopics