I used src/ksp/ksp/tutorials/ex10. c and saved the A and b into a PETSc binary file from Matlab with PetscBinaryWrite() in PETSC_DIR/share/petsc/matlab On Jun 7, 2024, at 10: 53 PM, neil liu <liufield@ gmail. com> wrote: Thanks a lot for your
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd

   I used src/ksp/ksp/tutorials/ex10.c and saved the A and b into a PETSc binary file from Matlab with PetscBinaryWrite() in PETSC_DIR/share/petsc/matlab


On Jun 7, 2024, at 10:53 PM, neil liu <liufield@gmail.com> wrote:

Thanks  a  lot for your explanation. 
Could you please share your petsc code to test this ?

Thanks,

Xiaodong 

On Fri, Jun 7, 2024 at 10:12 PM Barry Smith <bsmith@petsc.dev> wrote:

  If I run with -pc_type lu it solves the system

  If I run with the default (ILU) -ksp_monitor_true_residual -ksp_converged_reason it does not converge. In fact, it makes no real progress to the solution.

  It is always important to use KSPGetConvergedReason() or -ksp_converged_reason or -ksp_error_if_not_converged to check that the solver has actually converged.

  If I run with -ksp_gmres_restart 100 it converges in 75 iterations.

 Barry




On Jun 7, 2024, at 8:03 PM, neil liu <liufield@gmail.com> wrote:

This Message Is From an External Sender
This message came from outside your organization.
Dear Petsc developers, 

I am using Petsc to solve a complex system ,AX=B.

A is complex and B is real. 

And the petsc was configured with 
Configure options --download-mpich --download-fblaslapack=1 --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-triangle --with-scalar-type=complex

A and B were also imported to matlab and the same system was solved.
The direct and iterative solver in matlab give the same result, which are quite different from the result from Petsc. 
A and B are attached. x from petsc is also attached. I am using only one processor. 

It is weird. 

Thanks a lot.

Xiaodong 
<A.m><xPetsc.m><B.m>