A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
5

You can't. Nonlinear systems of equations are in general not solvable exactly. What you need to do is to use a method to solve nonlinear systems, of which there are of course quite a lot: A simple approach would be to use $D(U)\approx D(U^{n-1})$, where $D^{n-1}$ is the solution of the previous time step. A possibly smarter approach would be to use $D(U)\...


3

If you use diffeqpy you can use the commands adaptive=false,dt=... to specify fixed time stepping. The following is for using the Dormand-Prince RK45 method with fixed time stepping on the Lorenz equation: from diffeqpy import de import matplotlib.pyplot as plt def f(u,p,t): x, y, z = u sigma, rho, beta = p return [sigma * (y - x), x * (rho - z)...


2

It is true that $C$ depends on $x$ and $h$. This implies that if your function has a very poorly behaved second derivative at $x$, this method will be inaccurate. The dependance on $h$ is also to be expected, since finite differences are based on Taylor series, which converge locally, so our error estimate essentially depends on how well a Taylor series ...


2

The formula you show is not a general formula for the Neumann Boundary Condition, it is already projected onto $\mathbf{n}$. To see this, note that the gradient in finite difference approximation (with central differences) is given by: $$\boldsymbol{\nabla}f=\left(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}\right)\approx\left(\frac{f_{i+1,j}...


2

What you want is the convolution between two functions $f = |\Psi|^2$ and $g = g_{\sigma_x}(x)$, $h = (f * g)(x)$. You can compute the Fourier transform of $h$, to get $$\mathcal{F}\{h\} = \mathcal{F}\lbrace f\rbrace \mathcal{F}\lbrace g\rbrace\, ,$$ and then, just compute the inverse Fourier transform to obtain what you want $$ h = \mathcal{F}^{-1}\...


1

Not strictly no. They will reconstruct only linear functions on simple meshes exactly. You can get a better approximation (for non stretched meshes) using weighted least squares gradient reconstruction, but that still wont be exactly second order accurate. You can find more information on the gradient reconstruction techniques and their pitfalls here: https:...


1

It is quite straightforward to demonstrate this for implicit Euler (aka backward Euler) on a scalar example. Consider the initial value problem $\dot{y}(t) = i \alpha y(t), \ y(0) = 1$ with solution $y(t) = \exp(i \alpha t) = \cos(\alpha t) + i \sin(\alpha t)$. The solution is a harmonic oscillation with amplitude 1 and this amplitude does not change ...


1

Because the problem is linear, you don't need to deal with the complicated theory referenced in the answer from @spencerbryngelson. There is a very nice discussion of problems of this kind in LeVeque's Finite Volume Methods for Hyperbolic Problems, Chapter 9. Specifically, your system is very similar to the variable-coefficient acoustics equations (when ...


1

There is some literature on this. Such methods are generally associated with a property called "path-conservative". The main player in this area, as far as I know, is Carlos Pares. He has several nice papers, though the math is somewhat involved. Check this one out, for example. An additional point is that the product rule trick doesn't entirely get you ...


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