dedalus icon indicating copy to clipboard operation
dedalus copied to clipboard

Pencil () has 2 constant equations for 0 constant variables plus 1 differential equations / tau terms

Open navdeeprana opened this issue 3 years ago • 2 comments

Consider the following dedalus code snippet

import numpy as np
import matplotlib.pyplot as plt
import dedalus.public as de

r_basis = de.Chebyshev("r", 32, interval=(0.0, 1.0))
domain = de.Domain([r_basis], grid_dtype=np.float64)
system = de.IVP(domain, variables=["ur", "drur"], ncc_cutoff=1.e-8)

system.add_equation("dt(ur) = dr(drur)")
system.add_equation("drur - dr(ur) = 0")
system.add_bc("left(ur) = 0")
system.add_bc("right(ur) = 0")
IVP = system.build_solver(de.timesteppers.RK222)

I get the following error when I try to setup the above system

ValueError: Pencil () has 2 constant equations for 0 constant variables plus 1 differential equations / tau terms.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_229442/259235025.py in <module>
     11 system.add_bc("left(ur) = 0")
     12 system.add_bc("right(ur) = 0")
---> 13 IVP = system.build_solver(de.timesteppers.RK222)

But when I change the line

system.add_equation("dt(ur) = dr(drur)")

to

system.add_equation("dt(ur) - dr(drur) = 0")

it goes through. I am confused by the error. The kind of terms allowed on the left and right sides of the equation are described in the documentation here : https://dedalus-project.readthedocs.io/en/latest/notebooks/dedalus_tutorial_problems_solvers.html#Problem-formulations, but it doesn't clarify the situation. Are terms like $\mathcal{L}\cdot\mathcal{X}$ exclusive to the right hand side only? Perhaps an expanded documentation with examples can clear up the confusion.

navdeeprana avatar Sep 06 '21 10:09 navdeeprana

Dedalus requires a first-order formulation of the linear terms in the Chebyshev direction of your equations. Your original formulation has only one derivative on the left hand side but two boundary conditions. This cannot be solved. It is not a matter of what kind of terms can be on either side--in this case, you are right that the term in question could be on either the right or left hand side. However, the number of derivatives and the number of boundary conditions must agree.

Your correction puts two derivatives on the left hand side (one in each equation). This leads to a solvable system, and thus it works.

jsoishi avatar Nov 01 '21 13:11 jsoishi

Okay, I understand it now. With the original equation, if I remove one of the boundary conditions, it does not give the error.

navdeeprana avatar Nov 02 '21 05:11 navdeeprana