<!DOCTYPE html> 2 Tides in a Two-layer Fluid: Solving a System of Equations‣ Notes on the Finite Element Method
Notes on the Finite Element Method

Chapter 2 Tides in a Two-layer Fluid: Solving a System of Equations

It is often the case that the partial differential equations that govern flows are stated in term of multiple dependent variables. A two-layer hydrostatic fluid, where displacements of both the free surface and the inteface are sought, provides an example of how the FEM procedure can be adapted to determine the solutions.

2.1 The Problem

The one-dimesional basin described in the previous chapter is now filled with two fluids of different density: the top layer, of constant thickness , sits on top of a heavier layer of variable height (figure 2.1). The maximum depth beneath the surface is taken to be one.

Model Basin

Figure 2.1: Model Basin

As before the free surface displacement from the mean sea level is η(x,t); the displacement of the interface from z=- is ζ. The velocity in the upper layer is u1(x,t). In the lower layer the velocity is u2(x,t). the density anomaly between the two layers is ρ=2(ρ2-ρ1)/(ρ1+ρ2).

2.1.1 Equations and BC

After suitable non-dimensionalization, conserving mass in each layer gives the two equations:

(η-ζ)t+u1x=0,ζt+(1-)u2x=0, (2.1)

and the momentum equations for each layer are:

u1t+ηx=η¯x,u2t+(η-η¯)x+ρζx=0 (2.2)

Look for periodic solutions of the form:

η(x,y,t)=N(x,y)e-it,ζ(x,y,t)=I(x,y)e-it (2.3)
u1(x,y,t)=U1(x,y)e-it,u2(x,y,t)=U2(x,y)e-it. (2.4)

Momentum conservation in each layer determines the transport in terms of pressure gradient:

U1=-iκ2dNdx;U2=-i(h-)κ2d(N+ρI)dx; (2.5)

where N=N-N¯ is the departure of the sea level from the forcing, taken to be an equilibrium tide. The mass conservation relations in each layer are:

dU1dx-i(N-I)=0;dU2dx-iI=0. (2.6)

Substituting relations 2.5 into equations 2.6 yields a system of nonhomogeneous ordinary differential equations for the dependent variables N and I:

d2Ndx2+κ2(N-I)=-κ2N¯, (2.7)
ddx[(h-)d(N+ρI)dx]+κ2I=0.

The boundary conditions require that the transports (U1 and (1-)U2) be zero at each extremity:

dNdx=0;dIdx=0atx=±1. (2.8)

2.1.2 Analytic Solution

Solve the first of equations 2.7 for I:

I=N+N¯+κ2d2Ndx2 (2.9)

Introduce this expression into the second of equations 2.7:

ddx{(h-)ddx[N+ρ(N+N¯+κ2d2Ndx2)]}+κ2(N+N¯+κ2d2Ndx2)=0. (2.10)

or, after gathering terms:

ρddx[(h-)d3Ndx3]+κ2ddx{[h+ρ(h-)]dNdx}+κ4N=-κ2{κ2N¯+ρddx[(h-)dN¯dx]} (2.11)

The boundary conditions are:

dNdx=0;d3Ndx3=-κ2dN¯dxatx=±1; (2.12)

and the forcing is taken as a wave travelling from right to left:

N¯=e(-ikx) (2.13)

The solution to equation 2.11 can be written as the sum of a particular solution and a homogeneous solution:

N=Np+Nh (2.14)

The equation governing the particular solution Np is:

ρ(h-)d4Npdx4+κ2(h+ρ(h-))d2Npdx2+κ4Np=κ2(ρ(h-)k2-κ2)e-ikx (2.15)

For the particular solution, try Np=Ae(-ikx), plug into 2.15:

A(ρ(h-)k4-κ2(h+ρ(h-))k2+κ4)=κ2(ρ(h-)k2-κ2) (2.16)

This can be solved for A:

A=κ2(ρ(h-)k2-κ2)ρ(h-)k4-κ2k2(h+ρ(h-))+κ4 (2.17)

Note that if ρ(h-)1, A=κ2/(k2-κ2), usually less than one (since k<κ).

For the homogeneous part, Nh is the solution of:

ρ(h-)d4Nhdx4+κ2(h+ρ(h-))d2Nhdx2+κ4Nh=0 (2.18)

If solutions are sought with wavenumber k, equation 2.18 gives a fourth order algebraic equation for k:

ρ(h-)k4-κ2(h+ρ(h-))k2+κ4=0 (2.19)

with solutions:

k2=κ2h+ρ(h-)-h2+2ρ(h-)(1-2)+ρ2(h-)22ρ(h-),k2=κ2h+ρ(h-)+h2+2ρ(h-)(1-2)+ρ2(h-)22ρ(h-); (2.20)

A general solution to equation 2.18 is:

Nh=Ssinkx+Ccoskx+Ssinkx+Ccoskx (2.21)

where the four constants S, C, S, C are evaluated by enforcing the boundary conditions on equation 2.18:

dNhdx=-dNpdx,d3Nhdx3=-κ2dN¯dx-d3Npdx3atx=0,1; (2.22)

The constants are found to be:

S=-ikcosk[A(k2-k2)-κ2]kcosk(k2-k2),C=ksink[A(k2-k2)-κ2]ksink(k2-k2),S=ikcosk[A(k2-k2)-κ2]kcosk(k2-k2),C=-ksink[A(k2-k2)-κ2]ksink(k2-k2). (2.23)

Any Computer Algebra System (CAS) can really help solving systems of equations such as above. I use Maxima, but Mathematica and Maple are quite popular. The solutions are resonant if either k or k are equal to nπ for n=1,2,. Otherwise the constants S and C are usually small, as they depend on k-3. The solution is:

N=Ae-ikx+Ssinkx+Ccoskx+Ssinkx+Ccoskx+N¯,I=N+κ2d2Ndx2 (2.24)

with A given by equation 2.17.

Analytic solution 

Figure 2.2: Analytic solution 2.24 for η and ζ as functions of x and t.The parameter values are: κ=2, k=1;, ρ=0.03, =0.165

The solution for the surface, η, and the interface, ζ, displacements are illustrated in figure 2.2. The sea level behaves consistently with the single layer solution (figure 1.2), exceptd for a high wavenumber modulation that is the surface signature of the interfacial motion. Conversely, the high wavenumber oscillation of the interface carry the signature of the surface displacement. The two modes are coupled.

2.2 FEM solution

2.2.1 System of 2 Second Order Equations

Weak Form

The weak form of the system 2.7 is:

ϕmd2Ndx2𝑑x + κ2ϕm(N-I)𝑑x=-κ2ϕmN¯𝑑x, (2.25)
ddxϕm[(h-)d(N+ρI)dx]𝑑x + κ2ϕmI𝑑x=0.

If it is assumed that the depth varies little over an element, this becomes:

ϕmd2Ndx2𝑑x + κ2ϕm(N-I)𝑑x=-κ2ϕmN¯𝑑x, (2.26)
(h-)ϕmddx[d(N+ρI)dx]𝑑x + κ2ϕmI𝑑x=0.

Following chapter 1, the integrals that involve second derivatives can be integrated by parts. Combining the result with the divergence theorem gives:

dϕmdxdNdx𝑑x-κ2ϕm(N-I)𝑑x-κ2ϕmN¯𝑑x = [ϕmdNdx]-11, (2.27)
(h-)dϕmdxd(N+ρI)dx𝑑x-κ2ϕmI𝑑x = (h-)[ϕmd(N+ρI)dx]-11.

The boundary condition 2.8 forces the terms on the right side of equation 2.27 to zero, so the sytem can be written:

dϕmdxdNdx𝑑x-κ2ϕmN𝑑x+κ2ϕmI𝑑x = κ2ϕmN¯𝑑x, (2.28)
(h-)dϕmdxd(N+ρI)dx𝑑x-κ2ϕmI𝑑x = 0.

Assembly

Following equation 1.17, both dependent variables N and I are expanded in terms of the trial functions ϕm:

N(x)=n=1nxNnϕn(x)I(x)=n=1nxInϕn(x),whereϕn(x)=m=1MCm,nxm-1. (2.29)

where Nn and In represent the solution at each node, and nx is the total number of grid points.

With (equation 1.21) and 𝒦 the system 2.28 is:

[𝒦-κ2κ2(h-)𝒦-κ2+ρ(h-)𝒦]𝒔=[𝑭0]where𝒔=[NI] (2.30)

is the solution vector 𝒔 consists of nx values of N followed by nx values of I. The matrix on the left of equation 2.30 is 2nx on side. Just as only the first of equations 2.7 is forced, there is only a load associated with the first set of equations. The load elements are given by

Fm=κ2-11e-ikxϕm𝑑x (2.31)

Note the similarity between equation 1.22 and the system 2.30. In each case, 𝑭, 𝑵 and 𝑰 are complex.

Experience shows that when this problem is soleved as a system of two equations in two unknowns, quadratic TF are sufficient high polynomials to obtain an accurate solution. Once the global matrices and the load vector have been assembled, the solution is obtained by solving the usual linear system. The FEM solution is compared with the analytic solution 2.24 in figure 2.3.

Solutions to the forced two layer wave problem. The black
line represents the analytic solution, the blue line represents the
FEM solution with quadratic TF and the red line is the FEM
solution with cubic TF (described in the following section). The
cubic TF solution is a better match with the analytical solution.

Figure 2.3: Solutions to the forced two layer wave problem. The black line represents the analytic solution, the blue line represents the FEM solution with quadratic TF and the red line is the FEM solution with cubic TF (described in the following section). The cubic TF solution is a better match with the analytical solution.

Figure 2.3 is drawn with script C2S2figure3.m.

2.2.2 Single Fourth Order Equation

Weak Form

The starting point is equation 2.11 subject to conditions 2.12. With the exception of the fourth order derivative, each term has been considere in chapter 1. For a constant depth basin, with α=ρ(1-), the extra term can be dealt with as follows:

αϕmd4Ndx𝑑x=αddx(ϕd3Ndx3)𝑑x-αdϕdxd3Ndx3𝑑x=-αdϕdxd3Ndx3𝑑x+(ϕdNdx)-11 (2.32)

after an integration by parts followed by application of the Divergence theorem (see section 1.2.1). The Divergence theorem can be used since ϕ is continuous. The second term on the right is zero because of the boundary condition. This process can be repeated a second time:

αϕmd4Ndx𝑑x=-αddx(dϕdrd2Ndr)𝑑x+αd2ϕdx2d2Ndx2𝑑x (2.33)

In order to use the Divergence theorem, the derivative of ϕ needs to be continuous, so test functions other that the linear and quadratic polynomials described in chapter 1 are required. These will be one-dimensional Hermite cubics, described in the following section. With the dependent variable N expressed as an expansion over these functions, the weak form of equation 2.11 is:

n(α-11d2ϕmdx2d2ϕndx2𝑑x-β-11dϕmdxdϕndx𝑑x+κ4-11ϕmϕn𝑑x)Nn=-11Fϕm𝑑x-iακ2k(δnx,me-ik-δ1,meik) (2.34)

where β=κ2[1+ρ(1-)]. The last term on the right side of equation 2.34 represents the contribution from the boundary condition on d3N/dx3. See lines 54 and 55 of NI2by2vs4.m

Cubic Test Functions

The test functions encountered in chapter 1 have all been continuous functions, but their derivatives (figure 1.4) are discontinuous. With hermite polynomial two (or more) functions test functions are defined at each node. In the case of Hermite cubic functions these are defined as:

ϕH=(|x|-1)2(2|x|+1),ϕS=x(|x|-1)2 (2.35)

These are illustrated in figure 2.4. One function ϕkH represent the height of the test function (equal to one at xk) and the other accounts for the slope, and has a slope equal to one at xk.

The functions

Figure 2.4: The functions ϕkH and ϕkS. The amplitude of ϕkH and the slope of ϕkS is one at xk

In this way both the function and its derivative are continuous. If there are nx nodes, then there are 2nx test functions, and the global matrices are 2nx on side.

Assembly

For these cubic elements, the element mass matrix is:

e=δx420(15622δx54-13δx22δx4(δx)213δx-3(δx)25413δx156-22δx-13δx-3(δx)2-22δx4(δx)2) (2.36)

The stiffness is

𝒦e=130δx(363δx-363δx3δx4(δx)2-3δx-(δx)2-36-3δx36-3δx3δx-(δx)2-3δx4(δx)2) (2.37)

and the fourth order stiffness matrix, defined as

𝒦iv=-11d2ϕmdx2d2ϕndx2𝑑x (2.38)

The elements of 𝒦eiv are:

Kemniv=2(δx)3[63δx-63δx3δx2(δx)2-3δx(δx)2-6-3δx6-3δx3δx(δx)2-3δx2(δx)2] (2.39)

Assembly proceeds as in the previous chapter, on an element by element basis. The matrix equation to be solved for a single fourth order equation is:

(α𝒦iv-β𝒦+κ4)𝒔iv=𝑭iv (2.40)

wher the solution vector is made up of pairs NH,NS at each node. The load vector is evaluated following equation 2.31, with additional contributions for the first and last nodes, corresponding to the last term on the right side of equation 2.34:

𝑭iv=κ2[-11Fϕ1𝑑x+iακ2keik-11Fϕm𝑑x-11Fϕ2nx𝑑x-iακ2ke-ik] (2.41)

The Solution

Solutions to the forced two layer wave problem. The black
line represents the analytic solution, the green line represents
the FEM solution to a

Figure 2.5: Solutions to the forced two layer wave problem. The black line represents the analytic solution, the green line represents the FEM solution to a 2×2 system with cubic TF and the blue line is the FEM solution to a 1×4 system with cubic TF. For this case nx=1001,

FEM solutions obtained with the system of two second order equations and with the single fourth order equation are compared with the analytic solution if figure 2.5. The upper two panels show the real and imaginar parts of the three solutions. Because they are nearly indistiguishable, the lower two panels illustrates differences between the analytic solution and the system of two second order equations solution (in green) and the single fourth order equation solution (blue line). These results suggest the system of two second order equations is preferable.

Exercises

  1. 1.

    Write a script to reproduce figure 2.2 based on a FEM solution. Avoid looking at my scripts in this chapter.

  2. 2.

    Modify script 2 to compute the forcing by quadrature. Under what conditions is this useful?

Scripts

Octave: Periodic Two Layer System: Quadratic vs Cubic Test Functions

%%ID C2S2: Two layer resposnse to equilibrium forcing
%%ID compare quadratic and cubic TF solutions to system of 2x2 equations
clear;
%% Problem parameters
rho=0.03;kappa=2;hbar=0.165;k=1;
nx=201;x=linspace(-1,1,nx);x=transpose(x);
%% Quad TF
tq=[(1:2:nx-2)’,(3:2:nx)’];ne=size(tq,1);dx=diff(x(1:2:3));
M=K=sparse(nx,nx);F=zeros(nx,1);
Me=dx*[4,2,-1;2,16,2;,-1,2,4]/30;
Ke=[7,-8,1;-8,16,-8;1,-8,7]/3/dx;
Fe=dx/6*[1;4;1];
%% F and K   by quadrature
QuadWeights = [5/18,4/9,5/18];
QuadPoints = [0.5*(1-sqrt(0.6)),0.5,0.5*(1+sqrt(0.6))];
%% FEM Quadratic TF
for ke=1:ne
  nodes=tq(ke,1):tq(ke,2);
  M(nodes,nodes)=M(nodes,nodes)+Me;
  K(nodes,nodes)=K(nodes,nodes)+Ke;
  F(nodes,1)=F(nodes,1)+kappa^2*Fe*exp(-i*k*mean(x(nodes)));
endfor
L=[hbar*K-kappa^2*M,kappa^2*M;(1-hbar)*K,rho*(1-hbar)*K-kappa^2*M];
s = L\[F;zeros(nx,1)];
Nquad = s (1:nx)+exp(-i*k*x);
Iquad = s (nx+1:2*nx);
%%%  FEM cubic trial fn
tc=[(1:nx-1)’,(2:nx)’];dx=diff(x(1:2));%samedxaslinearTFhalfofquadTF
M=K=sparse(2*nx,2*nx);F=zeros(2*nx,1);
Ke=[36,3*dx,-36,3*dx;
␣␣␣␣3*dx,4*dx^2,-3*dx,-dx^2;
␣␣␣␣-36,-3*dx,36,-3*dx;
␣␣␣␣3*dx,-dx^2,-3*dx,4*dx^2]/30/dx;
Me=dx*[156,22*dx,54,-13*dx;
␣␣␣␣␣␣␣22*dx,4*dx^2,13*dx,-3*dx^2;
␣␣␣␣␣␣␣54,13*dx,156,-22*dx;
␣␣␣␣␣␣␣-13*dx,-3*dx^2,-22*dx,4*dx^2]/420;
fore=1:nx-1
␣␣nodes=tc(e,:);ind=2*(tc(e,1)-1)+[1:4];
␣␣Fe(1:2,1)=kappa^2*dx/12*[6;dx]*exp(-i*k*x(nodes(1)));
␣␣Fe(3:4,1)=kappa^2*dx/12*[6;-dx]*exp(-i*k*x(nodes(2)));
␣␣K(ind,ind)=K(ind,ind)+Ke;
␣␣M(ind,ind)=M(ind,ind)+Me;
␣␣F(ind,1)=F(ind,1)+Fe;
end
L=[hbar*K-kappa^2*M,kappa^2*M;(1-hbar)*K,rho*(1-hbar)*K-kappa^2*M];
s=L\[F;zeros(2*nx,1)];
Ncub=s(1:2:2*nx)+exp(-i*k*x);
Icub=s(2*nx+1:2:4*nx);
%%Exactsolution
[N,I]=NIexacthcons(nx,kappa,k,rho,hbar);N=transpose(N);I=transpose(I);
%%Plots
set(gcf,”position”,[500,10,1400,1400]);clf
axes(’position’,[0.05,0.55,0.4,0.4]);plot(x,real(N),’k’,’linewidth’,2);
holdon;plot(x,real(Nquad),’b’,’linewidth’,1);%axis([-1,1,-.4,.4]);
plot(x,real(Ncub),’color’,[0,0.6,0.2],’linewidth’,1/2);
xlabel(’x’,’fontsize’,18);ylabel(’real(N)’,’fontsize’,18);
title(strcat(’\kappa=’,num2str(kappa,’%3.1f’),{’␣␣␣k=’},num2str(k,’%3.1f’),{’␣␣␣\rho=’},num2str(rho,’%3.2f’),{’␣␣␣\hbar=’},num2str(hbar,’%4.3f’)),’fontsize’,18);
axes(’position’,[0.55,0.55,0.4,0.4]);plot(x,imag(N),’k’,’linewidth’,2);
holdon;plot(x,imag(Nquad),’b’,’linewidth’,1);
plot(x,imag(Ncub),’color’,[0,0.6,0.2],’linewidth’,1/2);ylabel(’imag(N)’,’fontsize’,18);
legend(’Analytic’,’FEM2by2quad’,’FEM2by2cub’,’location’,’southeast’)
axes(’position’,[0.05,0.1,0.4,0.4]);plot(x,real(I),’k’,’linewidth’,2);
holdon;plot(x,real(Iquad),’b’,’linewidth’,1);axis([-1,1,-.4,.4]);
plot(x,real(Icub),’color’,[0,0.6,0.2],’linewidth’,1/2);axis([-1,1,-2,2]);
xlabel(’x’,’fontsize’,18);ylabel(’real(I)’,’fontsize’,18);
axes(’position’,[0.55,0.1,0.4,0.4]);plot(x,imag(I),’k’,’linewidth’,2);
holdon;plot(x,imag(Iquad),’b’,’linewidth’,1);
plot(x,imag(Icub),’color’,[0,0.6,0.2],’linewidth’,1/2);ylabel(’imag(I)’,’fontsize’,18);
set(gcf,’paperpositionmode’,’manual’,’paperposition’,[0.250.251414])
print-dpng../../words/figs/C2/C2S2figure3.png

Octave: Periodic Two Layer System: Fourth Order vs System of Second Order

%%ID C2S2: Two layer resposnse to equilibrium forcing
%%ID compare cubic TF solutions in a 2by2 vs 1by4 formulation
clear
%% Problem parameters
rho=0.03;kappa=2;hbar=0.165;k=1;
%% F(orcing)
nx=201;x=linspace(-1,1,nx);x=transpose(x);dx=diff(x(1:2));
%%  FEM 2x2 cubic trial fn
tc=[(1:nx-1)’,(2:nx)’];dx=diff(x(1:2));%samedxaslinearTFhalfofquadTF
M=K=sparse(2*nx,2*nx);F=zeros(2*nx,1);
Ke=[36,3*dx,-36,3*dx;
␣␣␣␣3*dx,4*dx^2,-3*dx,-dx^2;
␣␣␣␣-36,-3*dx,36,-3*dx;
␣␣␣␣3*dx,-dx^2,-3*dx,4*dx^2]/30/dx;
Me=dx*[156,22*dx,54,-13*dx;
␣␣␣␣␣␣␣22*dx,4*dx^2,13*dx,-3*dx^2;
␣␣␣␣␣␣␣54,13*dx,156,-22*dx;
␣␣␣␣␣␣␣-13*dx,-3*dx^2,-22*dx,4*dx^2]/420;
fore=1:nx-1
␣␣nodes=tc(e,:);ind=2*(tc(e,1)-1)+[1:4];
␣␣Fe(1:2,1)=kappa^2*dx/12*[6;dx]*exp(-i*k*x(nodes(1)));
␣␣Fe(3:4,1)=kappa^2*dx/12*[6;-dx]*exp(-i*k*x(nodes(2)));
␣␣K(ind,ind)=K(ind,ind)+Ke;
␣␣M(ind,ind)=M(ind,ind)+Me;
␣␣F(ind,1)=F(ind,1)+Fe;
end
L=[hbar*K-kappa^2*M,kappa^2*M;(1-hbar)*K,rho*(1-hbar)*K-kappa^2*M];
s=L\[F;zeros(2*nx,1)];
N2by2=s(1:2:2*nx)+exp(-i*k*x);
I2by2=s(2*nx+1:2:4*nx);%notusedhere
%%␣␣FEM1x4cubictrialfn
alpha=rho*hbar*(1-hbar);beta=kappa^2*(1+rho*(1-hbar));
gamma=g=kappa^2*(rho*(1-hbar)*k^2-kappa^2);
K4=sparse(2*nx,2*nx);F=zeros(2*nx,1);
K4e=2*[6,3*dx,-6,3*dx;
␣␣␣␣␣␣␣3*dx,2*dx^2,-3*dx,dx^2;
␣␣␣␣␣␣␣-6,-3*dx,6,-3*dx;
␣␣␣␣␣␣␣3*dx,dx^2,-3*dx,2*dx^2]/dx^3;
%%MandKareidenticaltovaluesgivenabove
fore=1:nx-1
␣␣nodes=tc(e,:);ind=2*(tc(e,1)-1)+[1:4];
␣␣K4(ind,ind)=K4(ind,ind)+K4e;
␣␣Fe(1:2,1)=gamma*dx/12*[6;dx]*exp(-i*k*x(nodes(1)));
␣␣Fe(3:4,1)=gamma*dx/12*[6;-dx]*exp(-i*k*x(nodes(2)));
␣␣F(ind)=F(ind)+Fe;
end
%%Adjustrhs(F^iv)forbcond^3N’/dx^3
F(1,1)=F(1,1)+i*alpha*kappa^2*k*exp(i*k)/hbar;
F(2*nx-1,1)=F(2*nx-1,1)-i*alpha*kappa^2*k*exp(-i*k)/hbar;
%%becausetheBCondN’/dxishomogeneous,weonlyinclude
%%equationsforN’^Hatextremities(-1<=x<=1)
K4=[K4(1,1),K4(1,3:2*nx-1);K4(3:2*nx-1,1),K4(3:2*nx-1,3:2*nx-1)];
K=[K(1,1),K(1,3:2*nx-1);K(3:2*nx-1,1),K(3:2*nx-1,3:2*nx-1)];
M=[M(1,1),M(1,3:2*nx-1);M(3:2*nx-1,1),M(3:2*nx-1,3:2*nx-1)];
F=[F(1,1);F(3:2*nx-1,1)];
%%Solvelinearsystem
s=(alpha*K4-beta*K+kappa^4*M)\F;
%%sortoutsintoN’^HandN’^S(unusedhere)
NpH=[s(1);s(2:2:2*(nx-1))];NpS=[s(2:2*nx-2)];
N1by4=NpH+exp(-i*k*x);%addNbartpNprimetogetN
%%ifIwasneededgetitfromequation2.9
%%getexactsolution
[Nx,Ix]=NIexacthcons(nx,kappa,k,rho,hbar);Nx=transpose(Nx);Ix=transpose(Ix);
set(gcf,”position”,[100,1000,1400,1400]);clf
axes(’position’,[0.05,0.55,0.4,0.4]);plot(x,real(Nx),’k’,’linewidth’,2);
holdon;plot(x,real(N1by4),’b’,’linewidth’,1);axis([-1,1,-.4,.4]);
plot(x,real(N2by2),’color’,[0,0.6,0.2],’linewidth’,1/2);axis([-1,1,-.4,.4]);
xlabel(’x’,’fontsize’,18);ylabel(’real(N)’,’fontsize’,18);
title(strcat(’\kappa=’,num2str(kappa,’%3.1f’),{’␣␣␣k=’},num2str(k,’%3.1f’),{’␣␣␣\rho=’},num2str(rho,’%3.2f’),{’␣␣␣\hbar=’},num2str(hbar,’%4.3f’)),’fontsize’,18);
axes(’position’,[0.55,0.55,0.4,0.4]);plot(x,imag(Nx),’k’,’linewidth’,2);
holdon;plot(x,imag(N1by4),’b’,’linewidth’,1);
plot(x,imag(N2by2),’color’,[0,0.6,0.2],’linewidth’,1/2);ylabel(’imag(N)’,’fontsize’,18);
legend(’Analytic’,’FEM1by4’,’FEM2by22by2’,’location’,’southeast’)
axes(’position’,[0.05,0.1,0.4,0.4]);
holdon;plot(x,real(Nx-N1by4),’b’,’linewidth’,1);
plot(x,real(Nx-N2by2),’color’,[0,0.6,0.2],’linewidth’,1/2);
xlabel(’x’,’fontsize’,18);ylabel(’real(Nx-Nfem)’,’fontsize’,18);
axes(’position’,[0.55,0.1,0.4,0.4]);
holdon;plot(x,imag(Nx-N1by4),’b’,’linewidth’,1);
plot(x,imag(Nx-N2by2),’color’,[0,0.6,0.2],’linewidth’,1/2);ylabel(’imag(Nx-Nfem)’,’fontsize’,18);
set(gcf,’paperpositionmode’,’manual’,’paperposition’,[0.250.251414])
print-dpng../../words/figs/C2/C2S2figure5.png