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

Trying to "solve" an integer CellVariable should raise an error #128

Closed
guyer opened this issue Sep 19, 2014 · 4 comments
Closed

Trying to "solve" an integer CellVariable should raise an error #128

guyer opened this issue Sep 19, 2014 · 4 comments

Comments

@guyer
Copy link
Member

@guyer guyer commented Sep 19, 2014

Declaring

var = CellVariable(..., value=0)
 :
eq.solve(var)

produces confusing error messages deep in PySparse that result from var holding integers ("value=0" instead of "value=0.").

One option is to chance the default type for CellVariable, since integer arrays are probably only useful for FiPy's internal purposes.

Perhaps better to leave the semantics of "0" vs. "0." to Python and NumPy to sort out and simply raise an error (or warning?) if an attempt is made to "solve" an integer CellVariable, since that is not meaningful.

Imported from trac ticket #143, created by guyer on 05-27-2008 at 12:53, last modified: 06-12-2013 at 14:14

@guyer
Copy link
Member Author

@guyer guyer commented Sep 19, 2014

Previously reported as #133

Trac comment by guyer on 06-26-2008 at 16:32

@guyer
Copy link
Member Author

@guyer guyer commented Sep 19, 2014

Warning raised in r2829

Trac comment by guyer on 11-20-2008 at 15:57

@guyer
Copy link
Member Author

@guyer guyer commented Sep 19, 2014

As reported in http://thread.gmane.org/gmane.comp.python.fipy/2826/focus=2838, coupled equations produce weird results if the solution variables hold integers. This should have been addressed by this ticket, and is for single equations, but coupled equations don't raise a warning, e.g.,

import fipy as fp

mesh = fp.Grid1D(nx=10)

v1 = fp.CellVariable(mesh=mesh, value=1, hasOld=True)
v2 = fp.CellVariable(mesh=mesh, value=1., hasOld=True)

eq1 = fp.TransientTerm(var=v1) h2. fp.DiffusionTerm(var=v1)
eq2 = fp.TransientTerm(var=v2) fp.DiffusionTerm(var=v2)

(eq1 & eq2).solve(dt=1.)

Trac comment by guyer on 12-12-2012 at 15:05

@fipymigrate
Copy link

@fipymigrate fipymigrate commented Sep 19, 2014

In 5441732:

#CommitTicketReference repository="fipy" revision="5441732192e13c4f95dd891c5458fff10f6287a2"
Raise a warning when trying to "solve" an integer `CellVariable`.
Fixes issue #128


git-svn-id: svn+ssh://code.matforge.org/fipy/trunk@2829 d80e17d7-ff13-0410-a124-85740d801063

Trac comment by Jonathan E. Guyer guyer@nist.gov on 06-12-2013 at 14:14

@guyer guyer closed this Sep 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants