Search code examples
pythonnumpysparse-matrixpoisson

Solving Sparse Linear Problem With Some Known Boundary Values


I'm trying to solve a Poisson equation on a rectangular domain which ends up being a linear problem like Ax=b but since I know the boundary conditions, there are nodes where I have the solution values. I guess my question is... How can I solve the sparse system Ax=b if I know what some of the coordinates of x are and the undetermined values depend on these as well? It's the same as a normal solve except I know some of the solution to begin with.

Thanks!


Solution

  • If I understand correctly, some elements of x are known, and some are not, and you want to solve Ax = b for the unknown values of x, correct?

    Let Ax = [A1 A2][x1; x2] = b, where the vector x = [x1; x2], the vector x1 has the unknown values of x, and vector x2 have the known values of x. Then, A1x1 = b - A2x2. Therefore, solve for x1 using scipy.linalg.solve or any other desired solver.