Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes
Accepted

How do I simulate an open end?

The problem you describe, how to prescribe non-reflecting or absorbing boundary conditions when solving partial differential equations (PDE) has been extensively studied. For complex (e.g. nonlinear) ...
Bill Greene's user avatar
  • 6,074
10 votes

How to solve a second order differential equation (diffusion) with boundary conditions using Python

I have found that I must keep the value of dt near dx or the results become unstable This behavior you have noticed is known as the Courant–Friedrichs–Lewy (CFL) condition. Indeed, there are ...
Steven Roberts's user avatar
8 votes
Accepted

Symmetric boundary condition

For the sake of simplicity let me slightly change your notation. Let $u, v, w$ be the components in the $x, y, z$ directions of a true (polar) vector, and $y=0$ the symmetry plane. For a true vector, ...
Stefano M's user avatar
  • 3,829
8 votes
Accepted

Solving Poisson equation with current BC using FEM

It is standard procedure for general case like that. You can enforce condition for electrode by Lagrange multipliers, $$ L(u,\lambda) = \int_\Omega \sigma u_{,i} u_{,i} \, \textrm{d}V - \int_{\...
likask's user avatar
  • 906
7 votes

How can an engineering student become a computational scinece expert in a short time

There is no shortcut. Just like there is no shortcut to becoming an "engineering expert in a short time". The thing is that to be an expert in civil engineering, you need to understand load analysis, ...
Wolfgang Bangerth's user avatar
6 votes

How do I program periodic boundary conditions?

Typically, you would add "guard cells", that is (for u) u(-1) and u(n+1) with your notation. Before each integration step: u(n+1) = u(0) u(-1) = u(n) and ...
Pierre de Buyl's user avatar
6 votes
Accepted

Boundary condition for Pressure in Navier-Stokes equation

When we say that the pressure is only defined "up to a constant", what we mean is this: If $u,p$ is a solution to the Navier-Stokes equations, then $u,p+c$ for any constant $c$ is also a solution. In ...
Wolfgang Bangerth's user avatar
6 votes

Computing accurate fluxes with FEM

If $\nabla u$ is of more interest than $u$ itself, it is reasonable to set $\mathbb v := -\sigma \, \nabla u$ and convert your Poisson problem $$ -\nabla \cdot (\sigma \, \nabla u) = f \quad \text{in }...
56th's user avatar
  • 901
6 votes
Accepted

How to apply non zero Dirichlet boundary condition in finite elements?

Consider the fact that your linear system can be broken up into two parts: the equations that correspond to the known Dirichlet dofs, and the equations that correspond to the unknown dofs. For the ...
Tyler Olsen's user avatar
  • 1,512
6 votes
Accepted

FEM current toy problem

The formulation of this problem is tricky. Here is what you have in your original post: Find $h \in L^2(\partial D)$ such that for any $w \in H^{\frac 1 2}(\partial D)$, $$ \int_{\partial D} hw \,...
Wolfgang Bangerth's user avatar
6 votes
Accepted

Traction -> stress; stress->displacement gradient

In short, no. Neumann boundary conditions should be specified in terms of traction. This is clear when you move from a strong-form statement of the boundary value problem to a weak-form. Strong form: ...
Tyler Olsen's user avatar
  • 1,512
6 votes

Modelling question: example of a physical phenomenon with this jump condition at an interface?

$\vec\Phi = K_i \nabla u_i$ is the flux across the interface. For example, if $u$ is the thermal energy density and $K$ the thermal conductivity, then $\vec\Phi$ is the thermal energy flux. Energy ...
Wolfgang Bangerth's user avatar
6 votes

Starting configuration for Molecular Dynamics

Usually one needs to employ periodic boundary conditions (at least in the horizontal directions). Any atoms which fly outside of the box will be mapped to the opposite side. This also has to be ...
MPIchael's user avatar
  • 2,935
5 votes

Poisson equation finite-difference with pure Neumann boundary conditions

I know this question is old but I found an error that I wanted to clear up in @DrHansGruber 's answer. It took me a few hours to spot the issue and I wanted to post the solution to save anyone else ...
user31765's user avatar
  • 101
5 votes
Accepted

Impose Neumann Boundary Condition in advection-diffusion equation 1D

First, write out the semi-discrete equation for $u_0$, assuming it's an interior node: $ \frac{d}{dt}(u_0) = - c \frac{\left( u_1 - u_{-1} \right)}{2h} + \alpha \frac{\left(u_1 - 2u_0 + u_{-1}\right)}...
Savithru's user avatar
  • 343
5 votes
Accepted

Is the diffusion equation with Neumann and Dirichlet BCs well-posed?

Yes, the problem with mixed boundary conditions is well posed. What's not clear to me is this: Why do you approximate the derivative via the two-sides approximation? Shouldn't it be enough to just ...
Wolfgang Bangerth's user avatar
5 votes
Accepted

Imposing no flux boundary conditions on variants of the Cahn-Hilliard equation using Finite Differences in Python

The short answer is that you need $$\phi_{-1} = \phi_0$$ $$\phi_N = \phi_{N-1}$$ to impose $\nabla\phi=0$. A quick check by making the following change ...
Chaitanya Joshi's user avatar
4 votes

How to incorporate the boundary conditions with the Galerkin method?

Here is a method known as basis recombination, which has not been mentioned in the present thread. I'm citing from the book of J.P. Boyd, "Chebyshev and Fourier Spectral Methods", 2nd Ed., Chapter 6.5....
davidhigh's user avatar
  • 3,127
4 votes

Solving a linear equation system with pure Neumann condition

Including even one Dirichelt condition changes the problem you are trying to solve and will not give you the correct solution! You must fulfil the Discrete Compatibility Criteria, see e.g. first and ...
DrHansGruber's user avatar
4 votes
Accepted

$O(h^2)$ convergence for Elliptic PDE

You appear (and correct me if I am wrong, i do not wish to presume) to be confused on the notion of what is an order of convergence. The order of convergence is the order at which your approximate ...
BlaB's user avatar
  • 1,157
4 votes

Solving the Poisson equation with Neumann Boundary Conditions - Finite Difference, BiCGSTAB

One of the standard ways to handle singular problems like Poisson with Neumann boundary conditions which lead to a sinuglar problem $Ax=b$ is to make the obtained solution orthogonal to the kernel (...
VorKir's user avatar
  • 254
4 votes
Accepted

Initial Condition in a Numerical Problem

That depends on the equation you have, and on the situation you want to model. Imagine, for example, that you are considering the advection equation $$ \partial_t u + c \partial_x u = 0, $$ i.e., ...
Wolfgang Bangerth's user avatar
4 votes
Accepted

Computing accurate fluxes with FEM

If averaging the element fluxes, as suggested by @Bill Greene, does not produce accurate enough fluxes, there are ways to improve the accuracy of the fluxes by post-processing. A standard and quite ...
DanielRch's user avatar
  • 482
4 votes

Solving Poisson equation with current BC using FEM

Like @likask points out in the other answer, using Lagrange multipliers is one way to do this. The other is to recognize that if you have constraints of the form $\sum_i a_i U_i=0$, then you can ...
Wolfgang Bangerth's user avatar
4 votes
Accepted

Line integral along the edge of an isoparametrically mapped triangle

Interestingly enough, you are using quadrature rule for a master triangle in order to integrate over a segment. You should use quadrature rule for a master segment (e.g. $[-1, 1]$) instead. You should ...
56th's user avatar
  • 901
4 votes

How do you apply boundary conditions in a time-stepping problem?

As HBR mentioned, the boundary conditions can often be immediately incorporated into $A$ and $b$. For example, suppose we wish to solve the 1D heat equation with Dirchilet boundary conditions $$ u_t =...
eepperly16's user avatar
4 votes
Accepted

Structural mechanics - traction free = Zero displacement gradient?

The traction is defined as $$ \mathbf{t} = \mathbf{n} \cdot \boldsymbol{\sigma} $$ In terms of components, the zero-traction condition is $$ t_j = \sum_i n_i \sigma_{ij} = 0 $$ From the above ...
Biswajit Banerjee's user avatar
4 votes
Accepted

Radiation boundary condition (heat transfer)

This is not particularly difficult once you realize that the nonlinear boundary condition simply yields a nonlinear term in the weak formulation. Let's assume that you want to solve the steady state ...
Wolfgang Bangerth's user avatar
4 votes

Why naively chopped finite difference matrix works for different ODE boundary conditions

If you convert the first line of your matrix operator back into a difference equation you get $$2y(x)-y(x+h)=h^2b,$$ where $b$ is whatever is on the right hand side. This is consistent with a non-...
origimbo's user avatar
  • 2,249
4 votes

Applying Neumann boundaries to Crank-Nicolson solution in python

Boundary conditions are often an annoyance, and can frequently take up a surprisingly large percentage of a numerical code. How to implement them depends on your choice of numerical method. Finite ...
origimbo's user avatar
  • 2,249

Only top scored, non community-wiki answers of a minimum length are eligible