Conversion from Centered Diff Scheme to Ax = b

  • Thread starter AIR&SPACE
  • Start date
In summary, the individual has been working with an in-house code and is now exploring the use of the conjugate gradient method to solve a PDE. They have correctly rearranged the equation to the form Ax = b and have set up the matrix A and vectors x and b. One potential typo was identified in the equation for \Psi_{i,j}, and the suggestion was made to consider using a preconditioner to improve convergence. Overall, the individual has a good understanding of the conjugate gradient method and may benefit from a second opinion on their work.
  • #1
AIR&SPACE
101
0
Hey all, I've been working with an in-house code for a while and have decided to pursue a different method of solving the pde inside. Currently a spatial centered difference scheme is used to give us our equation to solve with the Jacobi iterative method. I want to investigate the conjugate gradient method as it pertains to the problem, but have been struggling. I need a new set of eyes.
So first off, here is the equation inside the Jacobi: (Let i denote x direction, j the y direction)

[itex]\Psi_{i,j} = \kappa_A \left(\left(\Delta x\right)^2 * \left(x_{i,j}^2 + y_{i,j}^2\right) * \omega_{i,j} + \Psi_{i+1,j} + \Psi_{i-1,j} + \kappa_2*\left(\Psi_{i,j+1} + \Psi_{i,j-1}\right)\right)[/itex]

Where [itex]\Delta x[/itex], [itex]\kappa_A[/itex], and [itex]\kappa_2[/itex] are scalar constants.
[itex]\Psi[/itex] is what I'm solving for, [itex]\omega[/itex] is the RHS.

So for conjugate gradient method (CGM) we need to rearrange this to the form Ax = b, where A is an NxN symmetric positive definite matrix. So this is where I need someone to double check my work. I started with the above equation and rearranged it to:

[itex]\Psi_{i,j}/\kappa_A - \Psi_{i+1,j} - \Psi_{i-1,j} - \kappa_2*\left(\Psi_{i,j+1} + \Psi_{i,j-1}\right) = \left(\Delta x\right)^2\left(x_{i,j}^2 + y_{i,j}^2\right)*\omega_{i,j}[/itex]

Assuming that is correct, then the matrix A should consist of [itex]1/\kappa_A[/itex] along the diagonal, -1's on both sides of the diagonal and then [itex]-\kappa_2[/itex] at each side spaced out from the diagonal based on the size of [itex]\Psi[/itex].
Might look something like this:
1hay40.jpg


The vector, x, would then be [itex] \left[ \Psi_{1:end,1};\Psi_{1:end,2};... \Psi_{1:end,end}\right] [/itex]

And vector, b, would be [itex]\left(\Delta x\right)^2 * \left[\left(x_{1:end,1}^2 + y_{1:end,1}^2\right)*\omega_{1:end,1};... \left(x_{1:end,end}^2 + y_{1:end,end}^2\right)*\omega_{1:end,end}\right] [/itex]


So how have I done? Am I good up to here?
 
Physics news on Phys.org
  • #2


Hello,

Thanks for reaching out for a second opinion on your work. It looks like you are on the right track with rearranging the equation to the form Ax = b for the conjugate gradient method. Your matrix A and vectors x and b seem to be set up correctly, assuming that your boundary conditions and grid spacing are properly accounted for.

One suggestion I have is to double check your equation for \Psi_{i,j}. It looks like there may be a typo in the first term, as it currently reads as \kappa_A multiplied by a product of \Delta x squared and the sum of x_{i,j} squared and y_{i,j} squared. Perhaps it should be \kappa_A multiplied by the sum of \Delta x squared and the product of x_{i,j} squared and y_{i,j} squared.

Additionally, when using the conjugate gradient method, it may be helpful to consider using a preconditioner to improve the convergence of the iterative process. This can be done by multiplying both sides of the equation by a matrix M, where M is a good approximation of the inverse of A. This can help reduce the number of iterations needed to reach a solution.

Overall, it seems like you have a good understanding of the conjugate gradient method and its application to your problem. Keep up the good work and don't hesitate to reach out for further assistance if needed. Best of luck with your research!
 

FAQ: Conversion from Centered Diff Scheme to Ax = b

What is the purpose of converting a centered difference scheme to Ax = b?

The purpose of converting a centered difference scheme to Ax = b is to solve a system of linear equations. This is useful in many scientific applications, such as solving for unknowns in a physical system or for modeling and predicting phenomena.

How does the conversion from centered difference scheme to Ax = b work?

The conversion from centered difference scheme to Ax = b involves rearranging the equations in the centered difference scheme into a matrix form, where the coefficients of the unknown variables are represented in the matrix A and the constants are represented in the vector b. This allows for the use of matrix operations to solve for the unknown variables.

What are the advantages of using Ax = b over a centered difference scheme?

Using Ax = b allows for a more efficient and accurate way to solve a system of linear equations, as matrix operations can be performed quickly using computer algorithms. Additionally, this method can easily be extended to larger systems with more unknown variables, whereas a centered difference scheme would become increasingly complex and difficult to solve.

Are there any limitations to converting a centered difference scheme to Ax = b?

One limitation of converting a centered difference scheme to Ax = b is that it assumes linearity, meaning that the equations must be able to be represented as a linear combination of unknown variables. Additionally, this method may not be suitable for non-linear systems or systems with complex boundary conditions.

Can the conversion from centered difference scheme to Ax = b be applied to any type of equation?

No, the conversion from centered difference scheme to Ax = b is only applicable to systems of linear equations. It cannot be used to solve non-linear equations or equations with higher order derivatives.

Similar threads

Replies
3
Views
2K
Replies
5
Views
886
Replies
3
Views
1K
Replies
1
Views
2K
Replies
9
Views
1K
Replies
6
Views
1K
Replies
8
Views
4K
Back
Top