[petsc-users] TSAdjoint not working correctly when using TSThetaSetEndpoint(true)

Miguel Angel Salazar de Troya salazardetroya at gmail.com
Wed Jun 3 09:26:03 CDT 2020


Thanks!

On Tue, Jun 2, 2020, 20:51 Zhang, Hong via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> I checked the results again and can confirm that it is a bug on our side.
> A merge request has been created to fix it:
> https://gitlab.com/petsc/petsc/-/merge_requests/2830
>
> Thanks,
> Hong (Mr.)
>
> On Jun 2, 2020, at 6:26 PM, Salazar De Troya, Miguel <
> salazardetro1 at llnl.gov> wrote:
>
> Hong,
>
> That is not the correct result, however, we can obtain the correct result
> if we comment ts.setThetaEndpoint(True). Why is it so?
>
> Thanks
> Miguel
>
> *From: *"Zhang, Hong" <hongzhang at anl.gov>
> *Date: *Tuesday, June 2, 2020 at 3:31 PM
> *To: *"Salazar De Troya, Miguel" <salazardetro1 at llnl.gov>
> *Cc: *"petsc-users at mcs.anl.gov" <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] TSAdjoint not working correctly when using
> TSThetaSetEndpoint(true)
>
> Miguel,
>
> After I uncommented ts.setThetaEndpoint(True) and
> removed ts.setProblemType(False.ProblemType.LINEAR) in your code, I got the
> following result:
>
> hongzhang at Hongs-MacBook-Pro$ python3 petsc_question_2.py
> Cost function
> Vec Object: 1 MPI processes
>   type: seq
> 127.781
> Exact value: 127.78112
>
> Numerical sensitivity w.r.t. a
> 12.778122049945212
> Real sensitivity w.r.t a
> 12.7781121978613
>
> Numerical sensitivity w.r.t. b
> 83.8907580310942
> Real sensitivity w.r.t b
> 211.67168296791954
>
> -ts_type cn gives the same result. What was the problem you encountered?
>
> Thanks,
> Hong (Mr.)
>
>
> On Jun 2, 2020, at 2:36 PM, Salazar De Troya, Miguel via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
> Hello,
>
> I am attaching a simple example that uses TSAdjoint to calculate the
> sensitivity of a 1 degree of freedom ODE. When using theta methods, it
> returns the right sensitivity as given by the analytical solution. When I
> set `ts.setThetaEndpoint(True)`, it does not work. Is there a theoretical
> reason why? I was using this option because using the options
>
> ts.setType(ts.Type.THETA)
> ts.setTheta(0.5)
> ts.setThetaEndpoint(True)
>
> is equivalent to using ts.Type.CN
>
> Thanks
> Miguel
>
> Miguel A. Salazar de Troya
> Postdoctoral Researcher, Lawrence Livermore National Laboratory
> B141
> Rm: 1085-5
> Ph: 1(925) 422-6411
> <petsc_question_2.py>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200603/f6a1ffba/attachment.html>


More information about the petsc-users mailing list