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

Vector equations are broken when sweep is used instead of solve. #401

Closed
wd15 opened this issue Sep 19, 2014 · 3 comments
Closed

Vector equations are broken when sweep is used instead of solve. #401

wd15 opened this issue Sep 19, 2014 · 3 comments

Comments

@wd15
Copy link
Contributor

wd15 commented Sep 19, 2014

Jon Alm Erikson noticed that vector equations are broken with sweep. His code

rom fipy import *

m = Grid1D(nx=100, Lx=1.)
v = CellVariable(mesh=m, hasOld=True, value=[[0.5], [0.5]], 
elementshape=(2,))

v.constrain([[0], [1]], m.facesLeft)
v.constrain([[1], [0]], m.facesRight)
eqn = TransientTerm([[1, 0], 
[0, 1]]) == DiffusionTerm([[[0.01, -1], 
[1, 0.01]]])
vi = Viewer((v[0], v[1]), datamax=1., datamin=0.)

for t in range(100): 
v.updateOld()
res = 1
while res > 1e-6:
res = eqn.sweep(var=v, dt=1e-3)

vi.plot()

gave a TypeError

Traceback (most recent call last):

...

  File "/home/wd15/git/fipy/fipy/solvers/solver.py", line 141, in _calcResidualVector
Lx = self.matrix * numerix.array(self.var)
  File "/home/wd15/git/fipy/fipy/matrices/pysparseMatrix.py", line 327, in __mul__
return _PysparseMatrixFromShape.__mul__(self, other)
  File "/home/wd15/git/fipy/fipy/matrices/pysparseMatrix.py", line 169, in __mul__
raise TypeError
TypeError

See http://thread.gmane.org/gmane.comp.python.fipy/3246/focus=3250.

Imported from trac ticket #658, created by wd15 on 10-25-2013 at 18:27, last modified: 01-17-2014 at 12:06

@fipymigrate
Copy link

In 2f015d7:

#CommitTicketReference repository="fipy" revision="2f015d7d9acd1953462a93a52e03c18303c8e2a6"
BUG: Fix issue with vector equations when sweeping.

The fix flattens variable arrays which can have the wrong shape when
calculating the residual. The variable arrays are 2D for vector
equations.

Addresses issue #401

Trac comment by Daniel Wheeler daniel.wheeler2@gmail.com on 10-25-2013 at 18:53

@wd15
Copy link
Contributor Author

wd15 commented Sep 19, 2014

Pull request:

The following changes since commit c668e0f16ba4477a354c3f298b56e0cac620404f:

  Merge branch 'develop' into ticket658-sweep_breaks_vector_equations (2013-10-25 18:51:39 -0400)

are available in the git repository at:


  ssh://git@code.matforge.org/nist/fipy.git ticket658-sweep_breaks_vector_equations

for you to fetch changes up to c668e0f16ba4477a354c3f298b56e0cac620404f:

  Merge branch 'develop' into ticket658-sweep_breaks_vector_equations (2013-10-25 18:51:39 -0400)

Trac comment by wd15 on 10-25-2013 at 19:06

@fipymigrate
Copy link

In 6dbc25d:

#CommitTicketReference repository="fipy" revision="6dbc25dde8bdbcb208009a4ee0eef79bb5e0ed31"
Merge remote-tracking branch 'origin/ticket658-sweep_breaks_vector_equations' into develop

Fixes issue #401

Trac comment by Jonathan Guyer guyer@nist.gov on 01-16-2014 at 18:56

@wd15 wd15 closed this as completed Sep 19, 2014
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