[petsc-users] Matlab gets a different solution to Petsc
Andrew Cramer
andrewdalecramer at gmail.com
Tue Jul 8 18:34:32 CDT 2014
I get *significantly *different results from backslash and petsc using
the *same
matrix*.
Deflection |Au-b|/|b|
Euler-Bernoulli: 4000
Petsc: 4386 0.3
Matlab: 4013 1.6e-10
I'm exporting to 6 significant figures. Condition number is rather poor
(~2e7) but I get similar or worse results with problems having lower
conditions numbers (~1e3).
On 8 July 2014 18:44, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, Jul 8, 2014 at 8:28 AM, Andrew Cramer <andrewdalecramer at gmail.com>
> wrote:
>
>> 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%).
>>
>
> As Karl says, this is probably truncation error, but more to the point
> this is accidental. You would not expect
> a solution that is more accurate than the discretization error. If you are
> comparing a discrete solution to a
> continuous solution, you want to look at "mesh convergence" meaning that
> you run on a series of refined
> meshes, calculate the error, and usually plot log(error) against mesh size
> h.
>
> Matt
>
>
>> 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.
>>
>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140709/b1393091/attachment.html>
More information about the petsc-users
mailing list