# Presentation: 511264

## Minimization and Preconditioning

- John C. Derber
- NOAA/NWS/NCEP/EMC

## Basic structure

- Outer iteration
- Most of outer iteration in routine glbsoi
- Accounts for small nonlinearities which are complex to include and changes in quality control (especially for radiances)
- If linear and no changes in QC should be same as doing more inner iterations
- Inner iteration
- Solves partially linearized version of objective function
- Mostly in routine pcgsoi

## Outer iteration

- Currently background error cannot change in outer iteration (due to preconditioning in inner interation)
- For the current problem, we find that 2 outer iterations appears to work reasonably well except for precip.
- Often we run three outer iterations so that we can see the fit to the obs. at the end of the second outer iteration

## Outer iteration

- Major operations within outer iteration
- Read current solution (read_wrf_..., read_guess)
- Read in statistics (prewgt, first outer iteration only)
- Call setup routines (setuprhsall)
- Call pcgsoi (solve inner iteration)
- Write solution
- Difference from background kept in xhatsave and yhatsave (= B-1xhatsave).

## Inner iteration

- Solves partially linearized sub-problem
- Uses preconditioned conjugate gradient
- Stepsize calculation exact for linear terms and approximate for nonlinear term
- Current nonlinear terms (if not using variational QC)
- SSM/I wind speeds
- Precipitation
- Penalizing q for supersaturation and negative values

## Inner iteration - algorithm

- J = xTB-1x + (Hx-o)TO-1(Hx-o) (assume linear)
- define y = B-1x
- J = xTy + (Hx-o)TO-1(Hx-o)
- Grad Jx = B-1x +HTO-1(Hx-o) = y + HTO-1(Hx-o)
- Grad Jy = x + BHTO-1(Hx-o) = B Grad Jx
- Solve for both x and y using preconditioned conjugate gradient (where the x solution is preconditioned by B and the solution for y is preconditioned by B-1)

## Inner iteration - algorithm

- Specific algorithm
- x0=y0=0
- Iterate over n
- 	Grad xn = yn-1 + HTO-1(Hxn-1-o)
- 	Grad yn = B Grad xn
- 	Dir xn = Grad yn + β Dir xn-1
- 	Dir yn = Grad xn + β Dir yn-1
- 	xn = xn-1 + α Dir xn                (Update xhatsave as well)
- 	 yn = yn-1 + α Dir yn               (Update yhatsave as well)
- Until max iteration or gradient sufficiently minimized

## Inner iteration - algorithm

- intall routine calculate HTO-1(Hx-o)
- bkerror multiplies by B
- dprod x calculates β and magnitude of gradient
- stpcalc calculates stepsize
- Note that consistency between x and y allows this algorithm to work properly

## Inner iteration – algorithm Estimation of β

- β = (Grad xn-Gradxn-1)T Grad yn/
-        (Grad xn-Gradxn-1)T Dir xn
- Calculation performed in dprodx
- Also produces (Grad xn)T Grad yn

## Inner iteration – algorithm Estimation of α (the stepsize)

- The stepsize is estimated through estimating the ratio of contributions for each term
- 		α = ∑a ∕ ∑b
- The a’s and b’s can be estimated exactly for the linear terms.
- For nonlinear terms, the a’s and b’s are estimated by fitting a quadratic using 3 points around an estimate of the stepsize
- The estimate for the nonlinear terms is reestimated using the stepsize for the first estimate

## Inner iteration – u,v

- Analysis variables are streamfunction and velocity potential
- u,v needed for int routines
- u,v updated along with other variables by calculating derivatives of streamfunction and velocity potential components of dir x and creating a dir x (u,v)