<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><span class="">Miguel,</span></div>
<div class=""><span class=""><br class="">
</span></div>
<span class="">After I uncommented ts.setThetaEndpoint(True) and removed ts.setProblemType(False.ProblemType.LINEAR) in your code, I got the following result:</span>
<div class=""><span class=""><br class="">
</span>
<div class="">hongzhang@Hongs-MacBook-Pro$ python3 petsc_question_2.py</div>
<div class="">Cost function</div>
<div class="">Vec Object: 1 MPI processes</div>
<div class=""> type: seq</div>
<div class="">127.781</div>
<div class="">Exact value: 127.78112</div>
<div class=""><br class="">
</div>
<div class="">Numerical sensitivity w.r.t. a</div>
<div class="">12.778122049945212</div>
<div class="">Real sensitivity w.r.t a</div>
<div class="">12.7781121978613</div>
<div class=""><br class="">
</div>
<div class="">Numerical sensitivity w.r.t. b</div>
<div class="">83.8907580310942</div>
<div class="">Real sensitivity w.r.t b</div>
<div class="">211.67168296791954</div>
<div class=""><br class="">
</div>
<div class="">-ts_type cn gives the same result. What was the problem you encountered?</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Hong (Mr.)</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jun 2, 2020, at 2:36 PM, Salazar De Troya, Miguel via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Hello,<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">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<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">ts.setType(ts.Type.THETA)<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">ts.setTheta(0.5) <span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">ts.setThetaEndpoint(True)<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">is equivalent to using ts.Type.CN<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Thanks<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Miguel<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span lang="ES" style="font-size: 9pt; font-family: Consolas;" class="">Miguel A. Salazar de Troya</span><span lang="ES" style="font-size: 10.5pt;" class=""><o:p class=""></o:p></span></div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 9pt; font-family: Consolas;" class="">Postdoctoral Researcher, Lawrence Livermore National Laboratory</span><span style="font-size: 10.5pt;" class=""><o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 9pt; font-family: Consolas;" class="">B141</span><span style="font-size: 10.5pt;" class=""><o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 9pt; font-family: Consolas;" class="">Rm: 1085-5</span><span style="font-size: 10.5pt;" class=""><o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 9pt; font-family: Consolas;" class="">Ph: 1(925) 422-6411</span><o:p class=""></o:p></div>
</div>
</div>
<span id="cid:9A3FB04DF3F7C24AA6E8C3BD2212ECAF@namprd09.prod.outlook.com"><petsc_question_2.py></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>