Sensitivity Analysis for ODE and DAE — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# Sensitivity Analysis for ODE and DAE

The `TS` library provides discrete adjoint models (`TSAdjoint`) and tangent linear models (`TSForward`) for sensitivity analysis for ODEs and DAEs. Users guide section: Performing sensitivity analysis with the TS ODE Solvers.

The adjoint solvers support gradient calculation for multiple cost functions, and the tangent linear solvers support gradient calculation with respect to multiple parameters. Adjoint is particularly efficient when the number of cost functions is much less than the number of parameters. Note that the parameters can be initial states or system parameters as used in the calculation of ODE/DAE right-hand sides.

Typical cost functions of interest may depend on the final solution to the ODE/DAE or on the whole trajectory (taking an integral form). The integral can be evaluated together with the time integration.

Examples

## Beginner - Basic usage

TSAdjointReset TSForwardSetSensitivities | TSSetCostGradients | TSSetCostHessianProducts

## Intermediate - Setting options for algorithms and data structures

TSAdjointMonitorCancel TSAdjointMonitorDefault TSAdjointMonitorDrawSensi TSAdjointMonitorSensi TSAdjointMonitorSet TSAdjointResetForward TSAdjointSetForward TSAdjointSetSteps | TSAdjointSolve TSAdjointStep TSCreateQuadratureTS TSForwardGetSensitivities TSForwardSetInitialSensitivities TSGetCostGradients TSGetCostHessianProducts | TSGetCostIntegral TSGetQuadratureTS TSGetRHSJacobianP TSSetIHessianProduct TSSetIJacobianP TSSetRHSHessianProduct TSSetRHSJacobianP

## Advanced - Setting more advanced options and customization

TSAdjointCostIntegral TSAdjointSetUp TSForwardCostIntegral | TSForwardGetStages TSForwardReset | TSForwardSetUp TSForwardStep

## Developer - Interfaces rarely needed by applications programmers

TSAdjointMonitor TSAdjointMonitorSetFromOptions TSAdjointSetFromOptions TSComputeIHessianProductFunctionPP TSComputeIHessianProductFunctionPU | TSComputeIHessianProductFunctionUP TSComputeIHessianProductFunctionUU TSComputeIJacobianP TSComputeRHSHessianProductFunctionPP TSComputeRHSHessianProductFunctionPU | TSComputeRHSHessianProductFunctionUP TSComputeRHSHessianProductFunctionUU TSComputeRHSJacobianP TSComputeSNESJacobian

## Deprecated - Functionality scheduled for removal in the future

TSAdjointComputeDRDPFunction TSAdjointComputeDRDYFunction TSAdjointComputeRHSJacobian TSAdjointSetRHSJacobian | TSComputeCostIntegrand TSComputeDRDPFunction TSComputeDRDUFunction | TSForwardGetIntegralGradients TSForwardSetIntegralGradients TSSetCostIntegrand

## Single list of manual pages

TSAdjointComputeDRDPFunction TSAdjointComputeDRDYFunction TSAdjointComputeRHSJacobian TSAdjointCostIntegral TSAdjointMonitor TSAdjointMonitorCancel TSAdjointMonitorDefault TSAdjointMonitorDrawSensi TSAdjointMonitorSensi TSAdjointMonitorSet TSAdjointMonitorSetFromOptions TSAdjointReset TSAdjointResetForward TSAdjointSetForward TSAdjointSetFromOptions TSAdjointSetRHSJacobian TSAdjointSetSteps TSAdjointSetUp TSAdjointSolve | TSAdjointStep TSComputeCostIntegrand TSComputeDRDPFunction TSComputeDRDUFunction TSComputeIHessianProductFunctionPP TSComputeIHessianProductFunctionPU TSComputeIHessianProductFunctionUP TSComputeIHessianProductFunctionUU TSComputeIJacobianP TSComputeRHSHessianProductFunctionPP TSComputeRHSHessianProductFunctionPU TSComputeRHSHessianProductFunctionUP TSComputeRHSHessianProductFunctionUU TSComputeRHSJacobianP TSComputeSNESJacobian TSCreateQuadratureTS TSForwardCostIntegral TSForwardGetIntegralGradients TSForwardGetSensitivities | TSForwardGetStages TSForwardReset TSForwardSetInitialSensitivities TSForwardSetIntegralGradients TSForwardSetSensitivities TSForwardSetUp TSForwardStep TSGetCostGradients TSGetCostHessianProducts TSGetCostIntegral TSGetQuadratureTS TSGetRHSJacobianP TSSetCostGradients TSSetCostHessianProducts TSSetCostIntegrand TSSetIHessianProduct TSSetIJacobianP TSSetRHSHessianProduct TSSetRHSJacobianP