Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiplying equation by "x" changes the solution #343

Closed
wd15 opened this issue Sep 19, 2014 · 1 comment
Closed

multiplying equation by "x" changes the solution #343

wd15 opened this issue Sep 19, 2014 · 1 comment

Comments

@wd15
Copy link
Contributor

wd15 commented Sep 19, 2014

The solution to the following changes when the equation is multiplied through by "x"

from fipy import Grid1D, CellVariable
from scipy import exp
from fipy import TransientTerm, ConvectionTerm, ImplicitSourceTerm, Viewer

xmax = 5.
dx = 0.05
nx = xmax/dx
mesh = Grid1D(dx=dx, Lx=xmax)

x = mesh.getCellCenters()[0]
X = mesh.getFaceCenters()[0]

numerical = CellVariable(name="numerical", mesh=mesh)

numerical.constrain(1, mesh.facesLeft)
numerical.constrain(0, mesh.facesRight)
numerical.faceGrad.constrain([0], mesh.facesLeft)

analytical = CellVariable(name="analytical value", mesh=mesh)
analytical.setValue(exp(-x**2/2.))

eqn = TransientTerm(coeff=1 / x) == \
  - ConvectionTerm(coeff=[[1]]) \
  - ImplicitSourceTerm(coeff=x)

numerical.setValue(exp(-x**2/2.))

vi = Viewer(vars=(numerical,analytical),datamin=0,datamax=2)

for i in range(10000):
eqn.solve(var=numerical,dt=1.)
vi.plot()
raw_input('stopped')

Imported from trac ticket #466, created by wd15 on 09-20-2012 at 12:27, last modified: 09-21-2012 at 17:43

@wd15
Copy link
Contributor Author

wd15 commented Sep 19, 2014

The reason why this doesn't work is due to the pathological nature of
the equation rather than any numerical issues. Obviously, the boundary
condition on the LHS of the domain can have no influence as the
equation is simply $\phi_t=0$ at $x=0$. Assuming we start with
$\phi=1$ as the initial condition, any drift away from $1$ can't be
prevented. There are no boundary conditions on the LHS of the domain,
only the initial condition and, hence, the only thing preventing the
drift away from $1$ on the LHS of the domain is the small value on the
RHS of the equation. Unless the cell is exactly at $x=0$ then drift
will occur. The drift reduces like the size of the grid. Technically
an infinitely fine grid would solve this problem.

Trac comment by wd15 on 09-21-2012 at 17:43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants