Wrong modified equation in some cases
jcsutherland opened this issue · comments
James Sutherland commented
Synopsis
For some discretizations, the modified equation that is generated is wrong.
Instructions to duplicate:
Here is some code that will show the problem:
from sympy import symbols,latex
from src.pymodpde import DifferentialEquation, i, n # import the differential equation and the indicies we need to use
u= symbols('u')
D= symbols('D')
pde = DifferentialEquation( dependentVarName='y',
independentVarsNames=['x'])
t = n+1
advection = ( pde.y(time=t,x=i) - pde.y(time=t,x=i-1) ) / pde.dx
diffusion = (
pde.y(time=t,x=i-1)
- 2*pde.y(time=t,x=i)
+ pde.y(time=t,x=i+1)
) / pde.dx**2
pde.set_rhs( -u*advection + D*diffusion )
pde.generate_amp_factor()
# pde.display_amp_factor()
pde.generate_modified_equation(nterms=3)
pde.display_modified_equation()
Workaround
Changing
pde.display_modified_equation()
to
pde.symbolic_modified_equation()
results in a correct (I think) modified equation.
Mokbel Karam commented
I have addressed this issue in this commit 5e9631a