DALTON

## Localized orbitals

To transform to localized orbitals in first iteration, make a specialized DALTON: Find the section in (sirinp.F)
\*\*\*\*\*  PROCESS AND CHECK INPUT DATA \*\*\*\*\*

IF (DOSCF .OR. DOCI .OR. DOMC) THEN

         IF(MAXMAC.LE.0 .OR.MAXMAC.GT.200) CALL ERRINP( 5,INPERR)

         ! edh modification to get localized virtuals !

         IF(THRGRD.LT.D0.OR.THRGRD.GT.1000)  CALL ERRINP( 7,INPERR)

END IF

OBS: Do not use this DALTON for anything else than localized orbitals - the insert allows the gradient to be VERY large (because we do not want do any iterations!)

## generate dalton mol inputs from xyz files

This can be done with openbabel:

```
babel -i xyz input.xyz -o dalmol output.mol # Default basis: 6-31G*

```

Sometimes it is more flexible to employ a atom-specific basis set. This can be fixed by:

```
sed -i '/Charge/ s/$/ Basis=def2-svp/' input.mol

```

Remember to remove the default basis set and replace "BASIS" by "ATOMBASIS" in the mol file

## Convergence

* Estimate in change in the gradient: Look for

Residual norm when dim(red L) =  14

NEO root     CSF        orbital          total

integer /some value /some value /some value

## Debug

Tips and tricks

* In-build routine to track program calls:

call QTRACE(lupri)

### In MCSCF code

* Check convergence parameters (some hints for quadratic convergence).
* The optimization scheme in DALTON builds on a second order Taylor expansion, where the predicted energy change for a parameter step **L** is q(**L**) = **gL + LHL** (**g** = gradient and **H** = Hessian). The true energy change is E(**L**). q(**L**) and E(**L**) has a number of convergence parameters that can be used to check for quadratic convergence
	+ GRDNORM: Gradient norm. Should decrease quadratic (e.g. 0.1, 0.01, 0.0001 etc...). CI part calculated in routine CIGRAD, orbital part in routine ORBGRD
	+ RATIO: E(**L**) / q(**L**). Should go monot towards 1.0 (0.99...) in the optimization (note that in the last step it is usually set to 1.0000 and this therefore does not count). in DALTON this parameters is calculated as routine SIRSTP.
	+ STPLNG. Step length taken in

Memory bugs

* Trace the routine that gives the problem
* nasty: Inserting print statements makes code fail/run: boil down to exactly what print statement (and where in the code) it goes wrong
* If a routine is spotted, go to this and write debug prints (e.g. debug print 1, debug print 2 etc...) - continue with locate spot where it goes wrong:
	+ If inside a loop, is it first time it quits? If not, are there as many loop prints as expected?
* In first MACRO ITERATION (MACRO 1), check active energy and CIDIAG - the CI diagonal elements should have an absolute value that is lower than the active energy (otherwise the Hessian gets negative elements as CIDIAG is used in the Davidson preconditioning)
* If error is in gradient, locate the high element(s) giving rise to the problem
* Look at actual and predicted energy change. They should be similar (almost identical close to convergence!)
* STEP control (if strange steps are observed, there might be a problem here)
* Alternatively, us the NR solver (note that it cannot back-step and will stop if there are negative eigenvalues in the Hessian)
* With .NR ALWAYS solver: 2. order contribution should be exactly one half of 1. order contribution
* Things to be dumbed from file can be done with dmplab
* Check that reduced Hessian is symmetric (redH") can also be done with p6flag(51) in input

### MC-srDFT

* Compare single determinant with full CI and only exchange (possibly also full HF exchange) using very high mu - here exchange is shifted between lr and sr parts but total energy should be equilvalent. Check convergence