- clear;
- Cref=22; %reference capacitor
- Aferro=6.25e-4; %capacitor areas
- Rref=100; %reference resistence
- G=1; %gradiet constant
- V0max=0.02; %V0 max value
- epsilond=260; %d layer
- epsilonf=260; %f layer
- sigma0=2.86e-7; %conductivity
- alphaf=-2.3618; %2 order constant in flayer
- beltaf=7.81e-4; %4 order constant in f layer
- alphad=-236.18; %2 order constant in d layer
- beltad=7.81e-2; %4 order constant in d layer
- nu=0.1; %width ratio
- L=800; %width
- Ld=L*nu; %d layer width 8e-6
- Lf=L*(1-nu); %f layer width
- N=800;
- k=L/N; %△x:
- epsilon=ones(N+1,1);
- epsilon(1:nu*N)=epsilond;
- epsilon(nu*N+1:end)=epsilonf;
- T=1;
- M=1e3;
- h=T/M; %△t:
- %-------------initial boundary condition----------%
- Vref=zeros(N+1,M+1);
- fVref_integrate=zeros(N+1,M+1);
- E=zeros(N+1,M+1);
- dV0=ones(N+1,M+1);
- P=zeros(N+1,M+1);
- fP=zeros(N+1,M+1);
- P(:,1)=0;
- P(:,2)=P(:,1);
- Eave=zeros(1,M+1);
- Pave=zeros(1,M+1);
- Vave=zeros(1,M+1);
- %------------forward eular method II-----------------%
- for j=1:M %time difference
- dV0(:,j)=repmat(cos(2*pi*j*h/1000),N+1,1);
- %fVref_integrate(:,j)=repmat(trapz([0:k:L],[(sigma0*E(:,j)+diff(P(:,j:j+1),1,2)/h)./epsilon]),N+1,1);
- fVref_integrate(:,2:end)=repmat(trapz([0:k:L],[(sigma0*E(:,1:end-1)+diff(P,1,2)/h)/epsilond]),N+1,1); %求积分
- Vref(:,j+1)=h*(V0max*2*pi*dV0(:,j)+fVref_integrate(:,j)-(Ld/epsilond+Lf/epsilonf)*Vref(:,j)/Rref/Aferro)/(1+Cref/Aferro*(Ld/epsilond+Lf/epsilonf))+Vref(:,j);
- E(:,j+1)=h*(Vref(:,j)/Rref/Aferro+Cref/Aferro*(Vref(:,j+1)-Vref(:,j))/h-sigma0*E(:,j)-(P(:,j+1)-P(:,j))/h)/epsilond+E(:,j);
- for i=2:N %spatial difference
- fP(i,j)=-alphaf*P(i,j)-beltaf*P(i,j)^3+E(i,j)+G*(P(i+1,j)+P(i-1,j)-2*P(i,j))/(k^2); %中心差分格式
- end
- P(:,j+1)=h*fP(:,j)+P(:,j);
- end
- Eave=mean(E);
- Pave=mean(P);
- Vave=mean(Vref);
- plot(Eave);
- ylabel('Eave');
- figure;
- plot(Pave);
- ylabel('Pave')
- figure;
- plot(Vave);
- ylabel('Vave')
- figure;
- plot(Eave,Pave);
- xlabel('Eave');ylabel('Pave');
- figure;
- plot(Eave,Vave);
- xlabel('Eave');ylabel('Vave');
复制代码
我试图用ode45等MATLAB中的语句来写一阶的常微分的方程组,但是因为方程的右边又有微分,又有积分,都不知道怎么写odefun函数了,所以就自己写了前向差分的欧拉法程序。
[ 本帖最后由 肉肉坨 于 2008-2-25 13:51 编辑 ] |