Miguel,

After I uncommented ts.setThetaEndpoint(True) and removed 
ts.setProblemType(False.ProblemType.LINEAR) in your code, I got the following 
result:

hongzhang@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 
<[email protected]<mailto:[email protected]>> 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>

Reply via email to