usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
512 stars 149 forks source link

Grid2D doesn't work well with integer dx #672

Open guyer opened 5 years ago

guyer commented 5 years ago
import fipy as fp

nx = 20
ny = nx
dx = 1
dy = dx
mesh = fp.Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

phi = fp.CellVariable(mesh=mesh, value=0.)
eq = fp.TransientTerm() == fp.DiffusionTerm(coeff=1)

eq.solve(var=phi, dt=1.)

raises

depending on solver.

dx = 1. fixes this.

raviapatel commented 4 years ago

In general i find this also problem when initializing cell variables with an integer it raises warning and solutions are not right. just doing "1." fixes this problem. This is issue even with python3!

guyer commented 4 years ago

@raviapatel: That's true and unlikely to change. There are internal reasons why cell variables need to be able to hold integers, but integers are not suitable for solving PDEs.