This is http://matforge.org/fipy/ticket/447, which we haven't resolved yet.
At this point, either do: X, Y = mesh.cellCenters[0], mesh.cellCenters[1] or X, Y = mesh.cellCenters X = CellVariable(mesh=mesh, value=X) Y = CellVariable(mesh=mesh, value=Y) There is no reason to use the get..() methods, as they just call through to the properties. As to what's changed since FiPy 2.x, we used to tolerate NumPy arrays if they had the expected shape of a coefficient, but we stopped doing that because it made for hard-to-diagnose problems. Also, I think something about our interaction with NumPy caused a change in the behavior of automatic unpacking. We still need to sort that out. On Dec 5, 2012, at 12:40 PM, Adam Stone wrote: > I found the problem, although I don't quite understand it. If I do either > > X, Y = mesh.cellCenters > > or > > X, Y = mesh.getCellCenters() > > then type(X) gives a numpy array and results in this error. However, if > I do > > X, Y = mesh.cellCenters[0], mesh.cellCenters[1] > > or > > X, Y = mesh.getCellCenters()[0], mesh.getCellCenters()[1] > > then type(X) gives a fipy variable and the solver works properly. > Something about the automatic unpacking makes these not equivalent as I > had initially thought. > > Adam > > > > On 12/05/2012 12:07 PM, Adam Stone wrote: >> I am interested in modeling a heat equation problem with a Gaussian >> heat source, so I need a way to define a source as a function of X and >> Y. A search turned up a previous 1D case from the older version in >> which something like this was done: >> >> X = mesh.getCellCenters()[0] >> eq = (TransientTerm() == DiffusionTerm() + X) >> >> However, when I try to do this I get the following error: >> >> "TypeError: The coefficient must be rank 0 for a rank 0 solution >> variable." >> >> Did 3.0 change the way this works, or is the 2D case different, or >> there a problem somewhere else that I'm missing? >> >> Thanks, >> Adam >> > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
