Questions tagged [crank-nicolson]

For questions about the Crank-Nicolson method, an approach for discretizing and solving partial differential equations.

Filter by
Sorted by
Tagged with
0 votes
1 answer
117 views

Using Crank-Nicolson to solve Non-Linear Schrödinger equation in Python

I aim to solve the (non-linear) Schrodinger equation using the Crank-Nicolson method in Python. Here are my two functions. ...
FairyLiquid's user avatar
1 vote
1 answer
225 views

Why does scipy Conjugate Gradient solver fail to converge for non-steady heat equation using Crank-Nicolson method

Could someone please explain why my implementation of the Crank-Nicolson method applied to the non-steady heat equation won't converge? There shouldn't be any nonlinear aspects to my implementation ...
n1ck94's user avatar
  • 13
1 vote
1 answer
148 views

Crank Nicolson Method with closed boundary conditions

I want to simulate 1D diffusion with a constant diffusion coefficient using the Crank-Nicolson method. $$\frac{\partial u (x,t)}{\partial t} = D \frac{\partial^2 u(x,t)}{\partial x^2}.$$ I take an ...
Jbag1212's user avatar
  • 111
0 votes
0 answers
38 views

Crank Nicolson Simulation Not Preserving Probability?

I have written a Crank-Nicolson simulation based on this post and the code it links too. ...
cgbsu's user avatar
  • 33
0 votes
2 answers
299 views

Can the Crank-Nicolson Method Be used to Solve The Schrodinger Equation with a Time Varying Potential?

I have been following an excellent article about how to use the Crank-Nicolson method to solve the Schrodinger equation. In the article, it starts with a $V(x, y, t)$ but the potential seems to become ...
cgbsu's user avatar
  • 33
1 vote
0 answers
153 views

Solving PDE on a non-uniform grid with Crank-Nicolson scheme

I am solving a 1D diffusion-type equation with the finite-difference Crank-Nicolson (CN) scheme, and I need to densify the spatial grid around the central point. One could change the spatial variable ...
ottavio 's user avatar
1 vote
0 answers
92 views

Crank-Nicolson vs Spectral Methods for the TDSE

The time-dependent Schroedinger equation (TDSE) depends linearly on the system's initial state $\vert \psi(0) \rangle$, such that the solution can be generally written as $$ \vert \psi(t) \rangle = \...
QuantumBrick's user avatar
2 votes
0 answers
160 views

Error in implementation of Crank-Nicolson method applied to 1D TDSE?

Some context, I've posted this question on physics SE and stack overflow. The former had nothing to offer, the latter had a great commenter that agreed with the phase looking off being one of the ...
MinimalCodingIQ's user avatar
0 votes
0 answers
79 views

Transparent Boundary Conditions for Finite Difference ADI PR 2D TDSE solution

I want to put (non-dirichlet) boundary conditions inside the code I wrote to solve the 2dim TDSE using the alternating direction implicit Peaceman - Rachford method. $$ (1 + iB\Delta t/2 ) \psi^{n+1/2}...
velenos14's user avatar
  • 131
4 votes
1 answer
188 views

Method to linearize highly nonlinear partial differential equation

I have a set of coupled pdes which I want to solve using finite-difference, of which one is nonlinear. The three linear pdes for quantities $T_f$, $T_s$ and $c$ are convection-diffusion-reaction-like ...
DozerD's user avatar
  • 81
2 votes
1 answer
446 views

Solving Schrodinger Equation with finite element and Crank-Nicolson?

I have asked this in Mathematic section, but received no reply. Please let me ask here to see if threr is any difference. The Schrodinger equation without potential has the following form: $$\...
WhatsupAndThanks's user avatar
2 votes
0 answers
121 views

Advection diffusion equation using Crank-Nicolson with total flux and Diriclet BCs

I am trying to model the 1D advection-diffusion equation: $${\partial c \over \partial t} = D_c{\partial^2 c \over \partial x^2} -u{\partial c \over \partial x}.$$ With Robin boundary conditions that ...
DozerD's user avatar
  • 81
2 votes
1 answer
128 views

Derivation of a parabolic PDE using Alternating Direction Implicit method

I have a very simple question concerning Alternating Direction Implicit (ADI) Scheme. If I have an equation of the form: \begin{equation*} \frac{df(x,y,t)}{dt} = \nabla^2 f(x,y,t) + f(x,y,t) \end{...
Iddingsite's user avatar
5 votes
0 answers
377 views

Stability of Crank-Nicholson for advection diffusion equation for spatial discretization other than finite differences second-order centered

Crank Nicholson is a time discretization method (see 4th equation here). From what I see around, you can use different space discretization, such as Finite elements. But for the linear advection-...
Millemila's user avatar
  • 435
2 votes
0 answers
85 views

Linearising Nonlinear Coupled Partial Differential Equations - Alfvénic Diffusion

I am trying to solve the following coupled partial differential equations with a finite difference scheme: $$\partial_tf+v\partial_zf+\partial_z\frac{1}{W}\partial_zf=0$$ $$\partial_tW+v\partial_zW-\...
Hanno Jacobs's user avatar
3 votes
1 answer
111 views

Maintain unitary time evolution for a nonlinear ODE

I want to solve a nonlinear ODE of matrix $A(t)$ $$\mathrm{i}\dot A = A(t)M(t),\:\mathrm{with}\: M(t)=A^\dagger(t)H(t)A(t)$$ where $H(t)$ and hence $M(t)$ are Hermitian. Therefore, I presume the time ...
xiaohuamao's user avatar
0 votes
0 answers
93 views

Crank-Nicolson solution of parabolic PDE with Newumann boundary conditions

I am trying to solve the non-linear parabolic PDE in $c(t,r)$ $$c_t=\frac{1}{r}(rDc_r-\alpha r^2 c)_r$$ with initial condition $c(0,r)=f(r)$ and boundary conditions $c_r(t,r_1)=\alpha r_1c_1/D$ and $...
Woody20's user avatar
  • 171
0 votes
1 answer
180 views

FDM on nonlinear PDEs

I'm working with a 2D Navier Stokes PDE in the unstabilized version - the equation is a linear equation of the type $\frac{∂u}{∂t} = F(u,t)$. In order to perform time discretization with FDM (finite ...
Rubi C.g.'s user avatar
1 vote
0 answers
530 views

Time-dependent Schrodinger equation implementation in FEniCS

For our Bachelors thesis we're trying to solve the Schrodinger equation $i\partial_tu = -\nabla^2u+Vu$ in FEniCS. Given the domain $[-5, 5]^2$ with an initial value of $u_0(x, y)=e^{(-2(x^2+y^2))}$ ...
Anton Scotte's user avatar
1 vote
1 answer
286 views

Crank-Nicholson for diffusion-advection vs diffusion equation

Let's consider the following 1D diffusion equation: $\frac{\partial u}{\partial t} = xk \frac{\partial}{\partial x}(\frac{1}{x}\frac{\partial u}{\partial x})$ where we assume that the diffusion ...
mfnx's user avatar
  • 172
6 votes
2 answers
346 views

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

I am considering the following diffusion equation: $$\frac{\partial f}{\partial t} = \frac{\partial}{\partial x}[D(x,t)\frac{\partial f}{\partial x}]$$ over a grid ...
R Thompson's user avatar
1 vote
1 answer
122 views

Finite difference methods

I am currently applying the finite difference method to the solution of the diffusion equation. I think that a problem has occurred, and is as follows, my explicit method is the most accurate when ...
Peter's user avatar
  • 33
2 votes
2 answers
120 views

Stability of Crank-Nicolson for $u_t = iu_{xx}+2iu$

I want to use the Crank-Nicolson scheme to solve the equation $$u_t = iu_{xx}+2iu$$ Here's the analysis: Suppose we make a grid, with $k = dt$ and $h = dx$, the usual notation, and also $u_j^n = u(...
Rick Joker's user avatar
1 vote
0 answers
50 views

Boundary conditions for a Non-linear Schrödinger equation using an extended crank nicolson scheme

I try to solve numerically the following PDE for $E(r, z)$ with a cylindrical symmetrie (i. e. $E(r, z) = E(-r, z)$). $\frac{\partial E}{\partial z} = \frac{i}{2k} \Delta E + \mathcal{N}(E)$ Where $...
user30548's user avatar
3 votes
0 answers
80 views

Use of non-typical values of $\theta$ in theta-methods

The theta-method is a popular solution for solving time-transient PDEs (or ODEs), which consists of solving the general equation for each time step: $$ \frac{u^{n+1} - u^{n}}{\Delta t} + (\theta f(u^{...
gazoh's user avatar
  • 153
1 vote
1 answer
297 views

Finite difference - Explicit / Implicit / Crank Nicolson - Does the implicit method require the least memory?

Examine a dynamic 2D heat equation $\dot{u} = \Delta u$ with zero boundary temperature. A standard finite difference approach is used on a rectangle using a $n\times n$ grid. For the resulting linear ...
user29635's user avatar
5 votes
1 answer
716 views

Finite Differencing schemes for Convection-Diffusion equation

I'm using the Convection(/advection)-Diffusion(-Reaction) equation to calculate the temperature over time in different hydraulic parts like a pipe or a heat exchanger. The flow/convection is always 1D,...
JE_Muc's user avatar
  • 265
2 votes
1 answer
4k views

Applying Neumann boundaries to Crank-Nicolson solution in python

Consider the heat equation $$u_t = \kappa u_{xx}$$ with boundary conditions of $$u(x,0)=0\\ u(0,t)=100\\ u(l,t)=0$$ Numerical analysis by pyton can be done with ...
Googlebot's user avatar
  • 131
0 votes
1 answer
1k views

Crank–Nicolson method for nonlinear differential equation

I want to solve the following differential equation from a paper with the boundary condition: The paper used the Crank–Nicolson method for solving it. I think I understand the method after googling ...
Physicist's user avatar
  • 227
0 votes
1 answer
237 views

implicit method (crank-Nicolson) I not understand the procedure [closed]

I'm trying to understand the passage through this equation can be written for easily solved with the fortran alghorithm in particular i don't understood the meaning of L_x and L_xx ... what (-1,0,1) ...
Marco Ghiani's user avatar
1 vote
0 answers
337 views

Crank-Nicolson scheme in space for advection equation

Consider the equation $$\frac{\partial}{\partial t}v(t,x)=\frac{\partial}{\partial x}v(t,x)$$, for $t,x\in\mathbb{R}$. I'd like to solve this equation forward in space and backward in time, ...
Jason Born's user avatar
2 votes
1 answer
745 views

Crank-Nicolson algorithm for coupled PDEs

Assumed I have the following two coupled equations $$\begin{split} \partial_tA&=a_0AB\\ \partial_tB&=b_0AB \end{split} $$ but I am not sure how to calculate them. One approach is a crank-...
arc_lupus's user avatar
  • 543
1 vote
0 answers
313 views

Why can I not solve the negative advection equation (backwards in time)?

Suppose we have the negative, inhomogeneous advection equation: $$\left(\frac{\partial}{\partial x}-\frac{1}{c}\frac{\partial}{\partial t}\right)v(t,x)=u(t,x)\qquad(t\in\mathbb{R}_{+},x\in\mathbb{R})$$...
Jason Born's user avatar
1 vote
1 answer
875 views

Crank-Nicolson method for inhomogeneous advection equation

Suppose we have the inhomogeneous advection equation $$\left(\frac{\partial}{\partial x}+\frac{1}{c}\frac{\partial}{\partial t}\right)u(t,x)=v(t,x)$$ for $u,v:\mathbb{R}\times\mathbb{R}\to\mathbb{R}$ (...
Jason Born's user avatar
0 votes
1 answer
576 views

Solving an equation in space and time using the Crank-Nicolson approach

Assume I have the following equation (light propagating in $z$-direction through the matter): $$id_zu+d^2_ru=0$$ with $u(z, r)$ being a complex wave. The time scale in this equation is $$t\equiv t_\...
arc_lupus's user avatar
  • 543
7 votes
1 answer
2k views

What is the origin of the spurious oscillations in the Crank-Nicolson scheme?

I was reading about the Crank-Nicolson method, and it is often said that it can produce "spurious oscillations" or that this method is prone to "ringing", especially for large time step and stiff ...
Matthieu's user avatar
1 vote
1 answer
550 views

How can I numericaly solve a convection-diffusion equation with a large diffusion term?

I want to numerically solve the advection-diffusion equation: \begin{equation} u_t(x,t) + cu_x(x,t) = v u_{xx}(x,t) \end{equation} for $x \in [0,1]$ and $t \geq 0$ subject to the boundary conditions ...
fabian's user avatar
  • 113
1 vote
1 answer
383 views

Numerical solution of non-linear heat-diffusion PDE using the Crank-Nicolson Method

I am trying to solve numerically the following 1D EBM: $C\frac{\partial T[x,t] }{\partial t} - \frac{\partial }{\partial x}\left ( D(1-x^2)\frac{\partial T[x,t] }{\partial x} \right ) + I[T] = S[x,t](...
Student48's user avatar
4 votes
2 answers
3k views

How to handle boundary conditions in Crank-Nicolson solution of IVP-BVP?

I'm trying to solve the PDE for $c(r,t)$ $$c_t=(1/r)(rJ)_r$$ using Crank-Nicolson, and I'm having difficulty with the boundary conditions. $J$ is the flux, the initial condition is $c(0,r)=c_{init}$, ...
Woody20's user avatar
  • 171
0 votes
0 answers
38 views

Useful Quantity for Heat Equation? [duplicate]

I'm interested in testing some algorithms on the heat equation, and I'd like to assess their accuracy. When evolving a Hamiltonian system, one has the energy to check the validity/correctness of the ...
Arturo don Juan's user avatar
1 vote
2 answers
2k views

Numerical solution of burgers equation with finite volume method and crank-nicolson

I'm having difficulty with numerically solving the inviscid burgers equation.Godunov's scheme is used in most of what I've found in literature . Now my question is if using a crank nicolson shceme is ...
mojijoon's user avatar
6 votes
2 answers
236 views

Is this system of diffusion equations well-posed?

I’m using a standard Crank-Nicholson algorithm to solve this system of two coupled diffusion equations: $$\dot{u} - \dot{v} = \frac{\partial}{\partial x} \left( \alpha(x) \frac{\partial u}{\partial x}...
user avatar
5 votes
2 answers
2k views

Why is Crank-Nicolson considered implicit in time?

From Wikipedia: Explicit methods calculate the state of a system at a later time from the state of the system at the current time, while implicit methods find a solution by solving an equation ...
Sparkler's user avatar
  • 153
1 vote
1 answer
391 views

Numerical Solution of non-linear diffusion equation using Finite Differencing

I'm trying to solve the following non-linear diffusion equation: $$ \frac{\partial}{\partial t} u(x,t)= \frac{\partial^{2}}{\partial x^{2}}u(x,t)^{3}$$ $$ -1\leq x \leq1, t \geq 0 $$ with the boundary ...
brokenseas's user avatar
3 votes
1 answer
2k views

How to solve the advection equation in 2 dimension using the Crank-Nicolson method?

I've an equation like this to solve with the crank-nicolson method $$U_t -\frac{y}{2} U_x + \frac{x}{2}U_y = 0,$$ where $x$ and $y$ are: [-2,5:2,5] and the time $T$ ...
Ysmael's user avatar
  • 31
4 votes
1 answer
624 views

My algorithm for the heat equation is unstable

I have implemented the 2D heat equation with what I thought was the Crank-Nicolson algorithm in the following way: ...
Daniel's user avatar
  • 85
1 vote
0 answers
1k views

Crank-Nicolson for 2nd- and 4th-order finite differences

I modeled the heat equation, $$ u_t = au_{xx} $$ using the common 2nd-order Crank-Nicolson scheme, $$ \frac{u^{n+1}_i-u^{n}_i}{dt} = \frac{a}{2\,dx}\left(u_{i-1}^{n+1}+u_{i+1}^{n+1}-2u_i^{n+1} + u_{i-...
Kyle Kanos's user avatar
5 votes
0 answers
84 views

Order of convergence of Scrodinger eq. with CN scheme

I'm trying to solve numerically the 1-dim time dependent Schrodinger equation using the Crank Nicolson scheme and the Thomas algorithm to solve the tridiagonal matrix. The physical system consists of ...
the_elder's user avatar
  • 151
8 votes
2 answers
15k views

How to discretize the advection equation using the Crank-Nicolson method?

The advection equation needs to be discretized in order to be used for the Crank-Nicolson method. Can someone show me how to do that?
pandoragami's user avatar
10 votes
2 answers
1k views

Is the maximum/minimum principle of the heat equation maintained by the Crank-Nicolson discretization?

I'm using the Crank-Nicolson finite difference scheme to solve a 1D heat equation. I'm wondering if the maximum/minimum principle of the heat equation (i.e. that the maximum/minimum occurs at the ...
foobarbaz's user avatar
  • 105