13 votes
Accepted

Why do I get an oscillatory solution when applying the implicit trapezoidal method to the linear diffusion equation?

I think you might have mixed up some terminology. An exponential integrator would use some type of eigensolver or related approach to exactly calculate $$f^{n + 1} = e^{\delta t\cdot \mathcal A}f^n$$ ...
Daniel Shapero's user avatar
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

Computation of diffusion time

It's easy to derive that equation from Fick's law. You have this diffusion equation as: $$\frac{\partial C}{\partial t} = D \nabla^{2} C$$ The mean square displacement weighted by the concentration ...
Mithridates the Great's user avatar
6 votes

Is this system of diffusion equations well-posed?

I think it might be ill-posed, since the time-dependent parts are linearly dependent. If you add your two time-dependent equations together, you get a time-independent equation: $(\alpha(x)u_x)_x + (...
David Ketcheson's user avatar
5 votes
Accepted

Numerically solving a non-linear PDE

First off, the PDE can be rewritten instead as $$\frac{\partial C}{\partial t} = \frac{\partial}{\partial x}C\frac{\partial C}{\partial x}$$ or, by applying the product rule in reverse again, as $$\...
Daniel Shapero's user avatar
5 votes

Mean-squared displacement in Monte Carlo studies

It is in some cases possible to map the dynamics obtained in MC simulations to other (more realistic) dynamics, especially for the case of dense colloidal suspensions. The following two papers talk ...
lr1985's user avatar
  • 677
5 votes
Accepted

Mean-squared displacement in Monte Carlo studies

This is possible (see [1]) but uncommon, as it requires Monte Carlo moves that alter the current conformations by a very small perturbation. In that setting of "small" Metropolis MC moves, it is ...
Juan M. Bello-Rivas's user avatar
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

Solving the heat diffusion equation with source term

You are starting from a uniform temperature and you have insulated boundary conditions; so there is no heat conduction occurring. Likewise, your initial mole fraction is also constant in $x$ so that ...
Bill Greene's user avatar
  • 5,984
4 votes

Should reaction be taken into account in the CFL condition when solving advection-diffusion-reaction equations numerically?

CFL is a necessary requirement for stability in transport-dominated systems, but in practice, is an intuitive way to interpret linear stability. A 1D advection-diffusion (or somewhat upwinded ...
Jed Brown's user avatar
  • 25.6k
3 votes

What is the right way to set up two random tensor fields which have an identical average diffusivity

There is no reason to believe that two random fields with the same arithmetic mean would yield solutions that have anything to do with each other. In fact, for the case you consider, one might imagine ...
Wolfgang Bangerth's user avatar
3 votes

Conservation violation in axisymmetric Diffusion Equation

You may want a method that works right down to the coordinate singularity at $r=0$. I will do the spherical case, but the cylindrical case is similar. We want to avoid ever dividing by $r$. To think ...
Philip Roe's user avatar
  • 1,154
3 votes
Accepted

How to simulate 3D diffusion in python?

You just add the diffusion along the other dimensions. This superposition from orthogonal directions makes some sense, as they are independent. So, going by wikipedia for Fick's second law of ...
hyperpallium's user avatar
3 votes

Transforming a 1D cartesian variable-coefficient diffusion code into a 1D adially symmetric one

More generally, the equation you are solving is \begin{equation} \frac{\partial u}{\partial t} = \nabla \cdot \left( D(x) \nabla u \right) \quad , \end{equation} where the first nabla operator ...
Hans Yu's user avatar
  • 51
3 votes
Accepted

Block-Tridiagonal Matrices with tridiagonal blocks

From my quick experiments in python, I find that a LU decomposition with the permutation strategy MMD_AT_PLUS_A¹ yields to an $\mathcal{O}(12n^{2.268})$ number of ...
Miguel's user avatar
  • 146
3 votes

Crank Nicolson Method with closed boundary conditions

I tried to run your code and I guess there might be a small mistake in your derivation, When you impose $u_{-1}^{j+1} = u_1^{j+1}$ into the equations at the ends, you have to equate $u_{-1}^{j+1} = ...
RandomElasticity's user avatar
2 votes
Accepted

Problem with Richardson extrapolation method for weak convergence in SDE

You are applying Richardson extrapolation to increasingly-accurate independent sample paths of an OU process. How would this work even for independent identically normally distributed random ...
Kirill's user avatar
  • 11.4k
2 votes

Numerical methods for non-linear diffusion

In fact, your equation is a non-linear advection-diffusion. Due to the fact that your problem is time-dependent, it could be easily solved by finite-difference: $$\frac{\partial z}{\partial t} = -C (\...
Mithridates the Great's user avatar
2 votes

Stable implicit method to solve convection-heat diffusion in 3D

It's a standard advection-diffusion equation. As long as your coefficients are bounded away from zero, there is really no difficulty associated with this equation with the possible exception of the ...
Wolfgang Bangerth's user avatar
2 votes

Simulating 1D diffusion

It seems still you don't specify your boundary conditions explicitly despite the suggestion given in one of your previous questions. As far as I understand from your MATLAB code, your boundary ...
Mithridates the Great's user avatar
2 votes

For implicit schemes, is there any general result that says numerical diffusion increases with smaller timesteps (for CFL<1) as in explicit schemes?

Short Answer: There is no general result that would hold for all implicit schemes. The reason is that how your method behaves with respect to numerical diffusion depends on the specific combination of ...
Daniel's user avatar
  • 1,238
2 votes

Should reaction be taken into account in the CFL condition when solving advection-diffusion-reaction equations numerically?

The CFL condition refers strictly to purely hyperbolic problems where there is a well-defined domain of dependence for the analytical solution. It state that a necessary condition for stability is ...
Philip Roe's user avatar
  • 1,154
2 votes
Accepted

Objective function for PDE-constrained boundary control problem in cylindrical coordinates

There are a couple of questions here, some of which pertain specifically to the geometry and input data for your problem and some have more to do with PDE-constrained optimization in general. Some of ...
Daniel Shapero's user avatar
2 votes
Accepted

Courant condition for diffusion

I think it is correct but it might be important to use the maximum value of the functions $A(x)$ and $D(x)$ in the domain of interest
RandomElasticity's user avatar
2 votes

Numerical artefacts in solution of spherical heat equation using FDM

You may simply change ...
ConvexHull's user avatar
  • 1,290
1 vote
Accepted

FEM diffusion: inaccurate results small time steps

What you find is indeed correct. It is known that positivity is lost if very small time steps are chosen, see https://doi.org/10.1515/cmam-2015-0018 This loss of positivity happens even for semi-...
cfdlab's user avatar
  • 3,028
1 vote
Accepted

Crank-Nicholson for diffusion-advection vs diffusion equation

Take the first expression and start to reduce the $x$ values to $x_i$, \begin{align} \frac{u_{i+1}^n - u_i^n}{x_{i+\frac{1}{2}}} - \frac{u_i^n - u_{i-1}^n}{x_{i-\frac{1}{2}}} &= \frac{(x_i-\...
Lutz Lehmann's user avatar
  • 5,984
1 vote

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

Problem well posed Your problem is well posed. On the discretization with Crank-Nicholson I am not familiar with MMS, and I wonder how you got that ungeneralised form of the diffusion equation. ...
mfnx's user avatar
  • 172
1 vote

Stability of PDEs

This comes from von Neumann stability analysis. You discretize the partial differential equation and look at the error equation, which is the difference between the exact solution to the finite ...
EMP's user avatar
  • 2,079
1 vote
Accepted

Minimizing the used memory in diffusion simulation using Python

It seems that you are going from one extreme to the other: you probably want to generate all $N$ particles at once without the for-loop; however, you don't want to generate all the ...
Anton Menshov's user avatar
  • 8,652

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