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

GMRES solver fails when solving Ax=0 with default initial guess x0=0 #451

Open
spossann opened this issue Dec 4, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@spossann
Copy link
Collaborator

spossann commented Dec 4, 2024

The GMRES solver has a division by zero when computing the initial residual in this case.

Minimal example:

import numpy as np
from psydac.linalg.solvers import inverse
from psydac.linalg.tests.test_solvers import define_data, define_data_hermitian

n = 5
p = 2

# cg solve of Ax = 0 with default initial guess
V, A, xe = define_data_hermitian(n, p)
solver = 'cg'
solv = inverse(A, solver, tol=1e-13)
b = A.domain.zeros()
x = solv.dot(b)
assert np.max(np.abs(x.toarray())) == 0.

# gmres solve of Ax = 0 with default initial guess
diagonals = [-7,-1,-3]
V, A, xe = define_data(n, p, diagonals)
solver = 'gmres'
solv = inverse(A, solver, tol=1e-13)
b = A.domain.zeros()
x = solv.dot(b)  # fails here

Proposed solution:

Handle the case b=0 separately by immediately returning the solution x=0?

@spossann spossann added the bug Something isn't working label Dec 4, 2024
@spossann spossann changed the title GMRES solver fails when solving Ax=0 with default inital guess x0=0 GMRES solver fails when solving Ax=0 with default initial guess x0=0 Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants