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 ...
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 ...
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 + (...
user avatar
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 ...
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 ...
user avatar
  • 657
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 $$\...
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 ...
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 ...
user avatar
  • 5,754
4 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 ...
user avatar
  • 61
4 votes

Diffusion coefficient when simulating in 2D

That's a modelling problem, not a CS one. This will depend on what is diffusing and on the reasons why 2D is relevant. You may want to give physical details and ask this on physics.SE. Alternatively ...
user avatar
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 ...
user avatar
  • 25.3k
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 ...
user avatar
3 votes

Determining if samples fit a 3D Gaussian distribution

In statistics the widely used test for checking if the distribution is gaussian is the Jarque-Bera test. Koizumi [1] presents an equivalent test for the multivariate case. I don't know if there ...
user avatar
3 votes
Accepted

Numerical Solution of non-linear diffusion equation using Finite Differencing

You should rearrange the terms so that all of the $n+1$ terms are together on one side of the equals sign and all of the $n$ terms are on them other. Then you will have a system of non-linear ...
user avatar
  • 10.8k
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 ...
user avatar
2 votes

Molecular Dynamics: Diffusion with PBC

You need to unfold the positions after the simulation is done. I use the following subroutine: ...
user avatar
2 votes
Accepted

Determining if samples fit a 3D Gaussian distribution

Your first test should be to compute the mean value and covariance matrix of your point sample. If these converge to the correct values as you increase the number of samples, you are, from a practical ...
user avatar
2 votes
Accepted

Reaction-Diffusion problem A->B, solving for B

I would do it exactly how you describe, with the two following remarks. I would solve the two evolutions simultaneously. In the way you describe, you will need to store and retrieve all the time ...
user avatar
  • 1,246
2 votes
Accepted

Modified diffusion equation and unstabilities

At first glance, it looks like you are using the method of lines with forward Euler time steps. What WolfgangBangerth is getting at with his example is that even for a simple heat equation, the ...
user avatar
2 votes

9-point stencil finite difference Laplacian with variable diffusion coefficients

Interesting question. I too would like to know if this is mentioned anywhere explicitly. My guess is maybe this is a little too hard and not too useful to be used/taught. Perhaps someone can give a ...
user avatar
  • 11.4k
2 votes

Not getting correct numerical solution for Advection-Diffusion-Reaction eqn

One of the best ways to test a PDE solver is to use the method of manufactured solutions. Essentially, you modify the PDE (and discretization) by adding a source term that yields an exact solution ...
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 ...
user avatar
  • 11.4k
2 votes

Diffusion coefficient when simulating in 2D

If you want to obtain the diffusion coefficient for 2D from 3D you have to take a look how the 2D diffusion equation is derived from 3D equation. It will be integrated with respect to one of the ...
user avatar
  • 475
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 ...
user avatar
2 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 ...
user avatar
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 (\...
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 ...
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 ...
user avatar
  • 1,208
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 ...
user avatar
1 vote

Neumann boundary conditions diffusion equations methods of lines

It is easy to see that the function \begin{equation} P(t) := \int \limits_0^1 p(x,t) \, \mathrm{d}x, \quad t \geq 0, \end{equation} is constant over time (i. e. $P(t) = P(0)$, $\forall \, t \geq 0$), ...
user avatar
  • 176

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