Nonuniform finite element method

Click For Summary

Discussion Overview

The discussion revolves around the implementation of the finite element method for solving second-order differential equations, specifically focusing on the challenges and considerations when using a nonuniform mesh. Participants explore various formulations and approaches to accurately represent derivatives and construct matrices for eigenvalue problems in a nonuniform context.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes their approach to solving second-order differential equations using a finite element method and expresses difficulties when introducing a nonuniform mesh.
  • Another participant points out that the assumption of uniform spacing in the derivative formula leads to inaccuracies and suggests an alternative formula that accounts for varying mesh sizes.
  • A different participant notes that the matrix constructed from the proposed formula still exhibits divergence at points of discontinuity in the mesh.
  • One participant requests additional context about the problem being solved and the results obtained, indicating a need for clarity in the discussion.
  • Another participant shares MATLAB code for simulating a metal coupled to a heterostructure, detailing the grid definition and kinetic energy operator construction.
  • Concerns are raised about the accuracy of the matrix formulation, with suggestions for corrections to ensure proper representation of the second derivative.
  • A participant clarifies that the eigenvectors obtained from the matrix correspond to the wavefunction in the context of the Schrödinger equation.
  • Further discussion includes a proposed modification to account for position-dependent effective mass in the kinetic energy operator, raising questions about the appropriate discretization of this term.

Areas of Agreement / Disagreement

Participants express differing views on the appropriate formulations for the second derivative in a nonuniform mesh context, and there is no consensus on the best approach. Several corrections and suggestions are made, but the discussion remains unresolved regarding the optimal method for implementation.

Contextual Notes

Participants highlight limitations related to the assumptions made in the derivative approximations and the potential impact of mesh discontinuities on the accuracy of the results. There are also unresolved questions regarding the implementation of position-dependent effective mass in the kinetic energy operator.

aaaa202
Messages
1,144
Reaction score
2
I am solving some 2nd order differential equations using the finite element method. Doing so I represent the second order derivative at a given point as:

2ψi/∂x2 = 1/(Δx)2i-1i+1-2ψi)

And solve the differential equation by setting up a matrix of N entries and solving for the eigenvectors. I guess you are all familiar with this approach. Now what I want to do is use a nonuniform mesh. To do so I have tried to simply let Δx = Δxi, i.e. such that it may vary depending on the site i. But doing so I get some solutions that don't make sense, which I assume is because of the "discontinuity" in the mesh size.

How can I approach the problem of a nonuniform mesh size?
 
Physics news on Phys.org
The trouble is that using the factor ##(\Delta x)^2## assumes that ##x_{j+1}-x_j=x_j-x_{j-1}##, where that is not in fact the case.

An appropriate formula that avoids that would be

$$\frac{\partial^2\psi}{\partial x^2}(x_j)=\frac{\frac{\psi_{j+1}-\psi_j}{x_{j+1}-x_{j}}-
\frac{\psi_{j}-\psi_{j-1}}{x_j-x_{j-1}}}
{(x_{j+1}-x_{j-1})/2}$$
 
hmm when I construct the matrix for the formula above I still get something whose eigenvectors diverge at the point where x_j changes discontinuely.
 
Post the problem you are trying to solve, and the results you've obtained so far.
If you have code representing your calculations - eg if it's in MATLAB or R - post that too.

I don't know if this is relevant, because it should be a minor issue unless the mesh is very coarse, but the formula above is not exactly an approximation for the second derivative at ##x_j##. It is an approximation for the second derivative at ##\frac{x_{j+1}-x_{j-1}}{2}##.
 
Okay I have the code here. Basically I am simulating a metal coupled to a heterostructure. Since the fermi wavelength is much shorter in the metal I want to make a grid, which has a higher density of points here. To do so I write:

%%%%% Defining the grid
N=2000; %Number of grid points
N0=2; %Parameter that defines how long outside the actual well the grid should extend N0=1 only contains the well.
N_Al=200;
N_Semi=N-N_Al;
dx=N0*L/N_Semi;
dx_Al=L_Al/N_Al;
x=[dx_Al*(1:N_Al),dx*((N_Al+1):(N_Semi+N_Al))];

I then calculate the kinetic energy operator, which is the second derivative (times some factor, which we for now will take as constant). That means it is proportional to the follow matrix:

for i=2:N-1
K(i,i)=-2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i))+1/(x(i)-x(i-1)));
K(i+1,i)=2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i)));
K(i,i+1)=2/(x(i+1)-x(i-1))*(1/(x(i)-x(i-1)));
end
K(N,N)=K(N-1,N-1);
K(1,1)=K(2,2);
K(1,2)=K(2,3);
K(2,1)=K(2,3);

I think this should be the correct expression from the one you gave. The reason for the last four lines is to make it the correct matrix while keeping it of size NxN.
Now I add to this the potential V, which is a diagonal matrix defined by (j labels different iteration cycles, but that is a longer store):

V(x<L,j)=-aff_GaAs;
V(x<L_InAs+L_GaAs,j)=-aff_InAs;
V(x<L_GaAs)=-aff_GaAs;
V(x<L_Al)=mu-Ef_Al;

And finally solve the eigenvalue problem:

H=K+diag(V(:,j),0);
[psi,E0] = eig(H); % Psi is a matrix with eigenvectors and E is a matrix with eigenenergies in diagonal.
E=diag(E0); % Vector of Eigenvalues
groundstate(:,j)=psi(:,1);
firstexcited(:,j)=psi(:,2);
 
aaaa202 said:
I then calculate the kinetic energy operator, which is the second derivative (times some factor, which we for now will take as constant). That means it is proportional to the follow matrix:

for i=2:N-1
K(i,i)=-2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i))+1/(x(i)-x(i-1)));
K(i+1,i)=2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i)));
K(i,i+1)=2/(x(i+1)-x(i-1))*(1/(x(i)-x(i-1)));
end
K(N,N)=K(N-1,N-1);
K(1,1)=K(2,2);
K(1,2)=K(2,3);
K(2,1)=K(2,3);

I think this should be the correct expression from the one you gave.
My knowledge of MATLAB is only very basic, so perhaps I'm missing something.
But I can't see how this relates to what I wrote. The only input it appears to have is a vector of ##x_i## values. There is no sign of any function ##\psi## of which the second derivative is being taken.
 
Well that would be the eigenvector of the matrix I solve for. When the Schrödinger equation is discretized finding the eigenstates amounts to finding the eigenvectors of the matrix operator. In other words ψ is a vector of n entries with the ith entry being ψi.
 
OK. That makes more sense out of it.
Looking at the code again in the light of that, I think there's an error in the following lines:
aaaa202 said:
K(i+1,i)=2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i)));
K(i,i+1)=2/(x(i+1)-x(i-1))*(1/(x(i)-x(i-1)));
I think they should be

K(i,i-1)=2/(x(i+1)-x(i-1))*(1/(x(i)-x(i-1)));
K(i,i+1)=2/(x(i+1)-x(i-1))*(1/(x(i+1)-x(i)));

You'd need to consequently change your last line to

K(N,N-1)=K(N-1,N-2);

Try that and see how you go.
 
I think I figured out my problem. I had forgotten some constants that made the problems dimensions wrong. Now suppose I want to add the fact that the effective mass in the kinetic energy operator should also be position dependent. Then my differential operator would be:
d/dx(1/m*(x) d/dx)

In discretized form how would this look when I compare to your expression for the second derivative. Would I just have 1/m*(i+1) and 1/m*(i-1) in front of the two terms?
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K