[petsc-users] Matlab gets a different solution to Petsc
Karl Rupp
rupp at iue.tuwien.ac.at
Tue Jul 8 02:55:42 CDT 2014
Hi Andrew,
> Doing a basic cantilever bending problem to test my code which results
> in the linear system Au = b.
>
> - Using DMDA for the domain and KSPSetComputeOperators
> - Solving it using various methods in petsc gets similar (within 1%)
> solutions
> - Even using -pc_type lu
> - Using KSPGetOperators and KSPGetRhs to export to matlab
>
> Exporting the matrix and and the rhs, importing them into matlab and
> solving with backslash gives a solution which matches the
> Euler-Bernoulli beam model much closer (0.4% error vs 9.6%).
>
> Calculating the residual of petsc's solution using matlab
> (norm(A*u-b)/norm(b)) I get 0.3 having solved with -pc_type lu.
>
> Is there a way I could have accidentally made petsc solve a different
> problem to Ax=b? I've been looking at this code for a while now (days)
> and can't seem to figure out what is wrong.
one possible cause: How many digits to you export per floating point
value? If you only export a small number of significant digits (~4) and
your system doesn't have a very good condition number, then this is the
effect of truncation errors.
Best regards,
Karli
More information about the petsc-users
mailing list