Tangent Linear and Adjoint Models Correctness Test

Discussion about tangent linear and adjoint models, variational data assimilation, and other related issues.

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Tangent Linear and Adjoint Models Correctness Test

#1 Unread post by arango »

One of bigest problems in developing the tangent linear and adjoint models for ROMS/TOMS is that bugs can be introduced very easily. Four CPP switches are now available to check for the correctness of these algorithms: INNER_PRODUCT, SANITY_CHECK, GRADIENT_CHECK and TLM_CHECK. There are also several drivers (pert_roms.F, grad_roms.F, tlcheck_roms.F) to carry out these tasks. They can be used to check whether or not both tangent linear and adjoint models are correct.

Inner Product and Sanity Check:

The driver pert_roms.F can be used to perform inner product and sanity check. It is a measure of consistency between tangent linear and adjoint algorithms. It can be executed in two different modes:

(1) Multiple perturbation mode: The tangent linear and adjoint models are executed for each perturbed interior point, one point at the time. The standard input parameters ERstr and ERend are used to achive multiple executions of both model kernels. The value for ERend is re-writen internally to its appropriate value. The resulting tangent linear (T) and adjoint (A) N-by-N matrices yield a symmetric matrix, such that T - tanspose(A), is zero within round off. This is known as the inner product test and is activated with switch INNER_PRODUCT. This is a highly idealized test that can be run in 2D and 3D congurations using input scripts roms2d_inner.in and roms3d_inner.in. The results are analyzed using Matlab scripts adjoint2d.m and adjoint3d.m, respectively.

(2) Single perturbation mode: The tangent linear and adjoint models are excuted once for a single specified interior point. This option can be activated with switch SANITY_CHECK and can be done in any application. The only file needed is the nonlinear forward tracjectory NetCDF file. This test is more practical and inexpensive. It also test the algorithm selected by the application CPP options. The point to perturb can be specified at random in the standard input model script. Please specify interior point to pertub in the vector user as follows:

Code: Select all

     user(1) => State variable ID to perturb:
                [1] free-surface
                [2] 2D u-momentum
                [3] 2D v-momentum
                [4] 3D u-momentum
                [5] 3D v-momentum
                [6] temperature
                [7] salinity
     user(2) => I-index to perturb
     user(3) => J-index to perturb
     user(4) => K-index to perturb (3D state fields)
The driver will report to standard ouput the tangent linear and adjoint solutions at the specified point. It also reports its difference. To see these value just type:

grep "Sanity Check" MyLogFile

Gradient Check:

The driver grad_roms.F can be used to check the gradient (adjoint model) by using the same structure as that for variational data assimilation. It is a measure of the correctness of the tangent linear and adjoint models. It can be run with any application with the same set-up (nonlinear and tangent linear initial NetCDF files, observation NetCDF file) for incremental 4DVAR, but with GRADIENT_CHECK activated and IS4DVAR undefined.

Let's denote the state vector as s. The cost function is the given by J(s). Suppose we perturb s by pds where p is a scalar. Then, using Taylor expansion to first-order we have:

Code: Select all

        J(s+pds) = J(s) + Transpose[grad(J)](pds)
Now, consider the functions:

Code: Select all

         g(p) = [J(s+pds) - J(s)] / Transpose[grad(J)](pds)
and
         h(p) = [g(p) - 1] / p
As p goes to zero, we require g(p) to go to unity and h(p) to go to a constant. These conditions will be satisfied if we have the correct tangent linear and adjoint models. Practically, we define ds to be a steepest descent direction given by grad(J). We get J(s) from the nonlinear model, grad(J) from the adjoint and J(s+pds) from the tangent linear model.

In the algorithm, the outer loop is used to perturb a particular tangent linear model state variable and the inner loop as the pertubation amplitude p, such that,

Code: Select all

        p = 10 ** FLOAT(-inner)
If outer=1, all the state variables are pertubed at once. In 2D configurations the state variables to perturb are free-surface (tl_zeta), and vertically integrated momentum (tl_ubar, tl_vbar). In 3D configurations, when SOLVE3D is defined, the state variables to perturb are free-surface (tl_zeta), total horizontal momentum (tl_u, tl_v), and tracers (tl_t). Then, if outer>1, each state variable is perturbed at the time. Notice that in 3D configurations that tl_ubar and tl_vbar are not perturbed (see tl_ini_perturb). They are computed by vertically integarting tl_u and tl_v.

The driver will report to standard output file. To see these values just type

grep "Gradient" MyLogFile

Tangent Linear Model Linearization Check

The tlcheck_roms.F driver can be used to check the linearization of the tangent linear model. It can be run with any application with the same set-up (nonlinear and tangent linear initial NetCDF files, observation NetCDF file) for incremental 4DVAR, but with TLM_CHECK activated and IS4DVAR undefined. This driver is similar to the gradient check, except that now both nonlinear and tangent linear initial conditions are pertubed.

Good Luck, H

Post Reply