# [petsc-users] FW: EXTERNAL: Re: EXTERNAL: Re: F90 to petsc 3.4.3 interface - loss of accuracy

Matthew Knepley knepley at gmail.com
Thu Jan 29 12:10:52 CST 2015

On Thu, Jan 29, 2015 at 12:03 PM, <Carol.Brickley at awe.co.uk> wrote:

>
> All,
>
> I am still having problems with data inconsistencies. We think it is loss
> of accuracy but am not sure. I have tried using 1 tolerance of 1e-12 for
> the ksp tolerance (ksp_rtol) but that doesn't seem to change matters.
>

I am not sure I understand what you want. What you seemed to report in the
first email was a difference in output of size 1e-21. This is
smaller than the machine epsilon for double precision by several order of
magnitude:

http://en.wikipedia.org/wiki/Machine_epsilon

This means that if you reverse the sum of just two numbers, you can have a
difference this large since floating point operations are not
commutative. In general, you can only expect an answer accurate to

\kappa(A) \epsilon

where \kappa(A) is the condition number of your operator, and this applies
to both direct and iterative methods. So, there is a loss of
accuracy compared to exact arithmetic, but this is inherent in the
definition floating point.

Thanks,

Matt

> Carol
>
>
> Dr Carol Brickley
> BSc,PhD,ARCS,DIC,MBCS
>
> Senior Software Engineer
> Applied Computer Science
> DS+T,
> AWE
> Aldermaston
> Berkshire
> RG7 4PR
>
> Direct: 0118 9855035
>
> -----Original Message-----
> From: Brickley Carol AWE
> Sent: 29 January 2015 17:12
> To: 'Barry Smith'
> Subject: RE: EXTERNAL: Re: EXTERNAL: Re: [petsc-users] F90 to petsc 3.4.3
> interface - loss of accuracy
>
> Hi,
>
> The data change is in material temperature and pressure. It is different
> from the unstructured case.
>
> I tried using 1e-12 but this made no difference. I also thought it may be
> the way the 2d structured matrix is read in compared to the 1d unstructured
> matrix but as its symmetrical apparently this would not matter (ie, inner
> index before outer or vice versa).
>
> Any other ideas would be gratefully appreciated.
>
> Carol
>
> Dr Carol Brickley
> BSc,PhD,ARCS,DIC,MBCS
>
> Senior Software Engineer
> Applied Computer Science
> DS+T,
> AWE
> Aldermaston
> Berkshire
> RG7 4PR
>
> Direct: 0118 9855035
>
> -----Original Message-----
> From: Barry Smith [mailto:bsmith at mcs.anl.gov]
> Sent: 28 January 2015 18:59
> To: Brickley Carol AWE; PETSc users list
> Subject: EXTERNAL: Re: EXTERNAL: Re: [petsc-users] F90 to petsc 3.4.3
> interface - loss of accuracy
>
>
> > On Jan 28, 2015, at 12:54 PM, <Carol.Brickley at awe.co.uk> <
> Carol.Brickley at awe.co.uk> wrote:
> >
> > Hi,
> >
> > I have a F90 suite that uses the petsc and runs for structured and
> unstructured matrices. For the unstructured we do not see the change at
> tiny decimal places but in the structured we do.
>
>    What data is the change in? A solution? Some derived quantity of the
> solution? Or in a residual?  Depending on what the difference is in
> generally that seems a very small difference to me.
>
> > The same solver is being used - GMRES. The tolerance should be 1e-10 in
> both cases but I can check in case there is a mistake.
>
>    You can try using KSP and SNES tolerances of 1e-12 to see if you get
> closer match -ksp_rtol 1.e-12 -snes_rtol 1.e-12
> >
> > Carol
> >
> > Dr Carol Brickley
> > BSc,PhD,ARCS,DIC,MBCS
> >
> > Senior Software Engineer
> > Applied Computer Science
> > DS+T,
> > AWE
> > Aldermaston
> > Berkshire
> > RG7 4PR
> >
> > Direct: 0118 9855035
> >
> > -----Original Message-----
> > From: Barry Smith [mailto:bsmith at mcs.anl.gov]
> > Sent: 28 January 2015 18:52
> > To: Brickley Carol AWE
> > Cc: petsc-users at mcs.anl.gov
> > Subject: EXTERNAL: Re: [petsc-users] F90 to petsc 3.4.3 interface - loss
> of accuracy
> >
> >
> >> On Jan 28, 2015, at 12:39 PM, <Carol.Brickley at awe.co.uk> <
> Carol.Brickley at awe.co.uk> wrote:
> >>
> >> Hi,
> >>
> >> Does anyone find loss of accuracy between F90 code and Petsc 3.4.3 C
> codes? I am noticing that some of my data is returning 9.99999997e-13
> instead of 1.00000000e-12 for example.
> >
> >  I am not sure exactly what your question is. Do you have two codes a
> F90 code without PETSc and a PETSc based C code? What is the data that is
> different? Is it solutions, residual values, ...?  This kind of small
> difference can often be caused by different tolerances used during the
> iterative solvers. We'll need more information in order to make any
> suggestions.
> >
> >   Barry
> >
> >>
> >> Carol
> >>
> >> Dr Carol Brickley
> >> BSc,PhD,ARCS,DIC,MBCS
> >>
> >> Senior Software Engineer
> >> Applied Computer Science
> >> DS+T,
> >> AWE
> >> Aldermaston
> >> Berkshire
> >> RG7 4PR
> >>
> >> Direct: 0118 9855035
> >>
> >> ___________________________________________________
> ____________________________ The information in this email and in any
> attachment(s) is commercial in confidence. If you are not the named
> addressee(s) or if you receive this email in error then any distribution,
> copying or use of this communication or the information in it is strictly
> awe.co.uk, and then delete this message from your computer. While
> attachments are virus checked, AWE plc does not accept any liability in
> respect of any virus which is not detected. AWE Plc Registered in England
> and Wales Registration No 02763902 AWE, Aldermaston, Reading, RG7 4PR
> >>
> >
> >
> > ___________________________________________________
> > ____________________________
> >
> > The information in this email and in any attachment(s) is
> > commercial in confidence. If you are not the named addressee(s)
> > or
> > if you receive this email in error then any distribution, copying or
> > use of this communication or the information in it is strictly
> > prohibited. Please notify us immediately by email at
> > admin.internet(at)awe.co.uk, and then delete this message from
> > your computer. While attachments are virus checked, AWE plc
> > does not accept any liability in respect of any virus which is not
> > detected.
> >
> > AWE Plc
> > Registered in England and Wales
> > Registration No 02763902
> > AWE, Aldermaston, Reading, RG7 4PR
>
>
> ___________________________________________________
> ____________________________
>
> The information in this email and in any attachment(s) is
> commercial in confidence. If you are not the named addressee(s)
> or
> if you receive this email in error then any distribution, copying or
> use of this communication or the information in it is strictly
> prohibited. Please notify us immediately by email at
> admin.internet(at)awe.co.uk, and then delete this message from
> your computer. While attachments are virus checked, AWE plc
> does not accept any liability in respect of any virus which is not
> detected.
>
> AWE Plc
> Registered in England and Wales
> Registration No 02763902
> AWE, Aldermaston, Reading, RG7 4PR
>

--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their