# Operator Details

## Basic Description

The purpose of the GENOPER modules are to generate the Hamiltonian operator in a form to be used by the MCTDH programs. The file operator.op (where operator stands for the name of the desired operator), specifies the Hamiltonian. This ASCII file defines the operator using basic mathematical expressions. The GENOPER routines in principle then translate this file, and generates the operator for the system, using the pre-defined primitive basis set.

For a full description of the operator file see Hamiltonian Documentation. In general, the operator is built from built-in symbols.

The operator file is read in `heingabe`, which is called directly after `einoper` in the `eingabe` routine. The main routine `runoper.F` is called from the `mctdh` main program, after `zeigoper.F` and `memoper.F` have calculated the pointers and memory structure, respectively.

The aim is to generate a digital representation of the operator which can be efficiently used in the programs. The problem is that the system itself may contain combined modes, or only a single mode, or many 1-dimensional modes, which need to be treated differently. Various operator types also need to be taken into account. Manipulations must also be performed to gain the greatest efficiency (e.g. by summing operator terms together, or multiplying out operators in a combined mode etc.)

The basic operator representation is contained in the integer array `hamilton(f,k)`. The index `k` runs over the terms in the operator, and `f` over the degrees of freedom. Thus the basic form is the MCTDH product form. Each integer points to a further integer array which represents the operators, `hterm(n,h)`, referred to as compound operators. These operators are in turn made up of simple operators, and the integer in `hterm(n,h)` points to the simple operators, which are represented by character strings in the array `hoplab(hl)` The index thus `n` runs over the components of the compound operator.

The arrays `hterm(n,h)` and `hoplab(hl)` have a number of associated arrays which store the information required to define and evaluate the operators. After describing these arrays, a `simple example` may help to illustrate the basic concept.

## Parameters

Parameters to be used in the program are stored using the following arrays:

Name Description
`apar(n)` Character array with name of n th parameter
`rpar(n)` Real array with value of n th parameter
`npar` Number of parameters
`maxpar` Maximum possible nunmber of parameters

## Hamiltonian

The Hamiltonian is specified using three levels of descriptors. The lowest level is a list of simple operators, the `hoplab(hl)` and associated arrays. These are then combined together to form the various combinations required, using sets of `hl` integers stored in the `hterm(n,h)` and associated arrays. Finally, the `hamilton(f,k)` array specifies how the combined operators are multiplied together to form the Hamiltonian.

### HOPLAB and associated arrays

Name Description
`hoplab(hl)` Character array with labels for the simple operators needed.
`hopilab(hl)` Integer array with number relating hoplab(hl) to the relevant function.
`hopfile(hl)` Integer array with a number defining the "file" containing hopilab(hl). See OPFUNCS Library below.
`hopipar(nhl,hl)` Integer parameters needed to define the operator.
`hoprpar(nhl,hl).` Real parameters needed to define the operator.
`maxhop`. Maximum possible number of labels, i.e. 1 < hl < maxhlab.

### HTERM and associated arrays

The `hterm(n,h)` array is a set of `n` integers representing the `h` the operator. The information required to represent and evaluate each operator is stored in various arrays, which are listed in the following table.

The `htmdof(h)`, `htmmode(h)`, and `htmmuld(h)` arrays are used to distinguish between the three basic types of operators: 1-D operators which operate only on a single degree of freedom; particle operators which operate on a single particle; multi-D operators which operate on a number of particles. If no combined modes are used, then 1-D and particle operators are synonymous.

Name Description
`hterm(nh,h)` Integer array in which operators are specified by a set of indices relating to hoplab(hl) array.
`htmfac(h)` Number of factors in hterm(nh,h), i.e. 1 < nh < htmfac(h).
`htmdim` Number of operators in hterm array, i.e. 1 < h < htmdim.
`htmdof(h)` Degree of freedom associated with hterm(nh,h). If the operator is a particle, or multi-dimensional operator, htmdof(h)=0.
`htmmode(h)` Particle associated with hterm(nh,h). If operator is not a a particle operator (i.e. it is a 1D or multi-D operator) htmmode(h)=0.
`htmmuld(h)` Multi-dimensional grid associated with hterm(nh,h). If operator is not a a multi-D operator (i.e. it is a 1D or particle operator) htmgrd(h)=0.
`htmtype(h)` Type of operator (see below).
`htmsym(h)` 1=hermitian; -1=anti-hermitian; 0=no symmetry
`minfac` Maximum value of hterm factors, i.e. minfac = max(htmfac(h)).
`maxfac` Maximum possible number of hterm factors, i.e. minfac < maxfac.
`maxhtm` Maximum possible number of hterm opertors, i.e. htmdim < maxhtm.

#### HTMTYPE: types of operators

These are the types of the operators. potential

Nos. Description
0 zero
1 unit
2 real vector (diagonal matrix)
3 imaginary vector (imaginary part stored as real)
4 complex vector
5 FFT, real vector
6 FFT, imaginary vector
7 FFT, complex vector
8 real matrix
9 imaginary matrix
10 complex matrix
11 npotk term, natpot fourier transformed
101 multi-dimensional diagonal analytic potential
2D combined-mode types
15 real 3D tensor (for dth1,dth2)
16 real 3D tensor (for jpm)
17 real 3D tensor (for jm^2)
18 real 3d tensor (for j_p)
19 real 3D tensor (for j_m)
20 real 3D tensor (for jp^2)
21 real 3D tensor (for jm^2)
coefficients
1 unit
2 real number
3 imaginary number
101 time-dependent

#### Initialisation

Initially the hterm array has the following values:

```htmfac(h) = 1   htmdof(h) = h   hterm(1,h) = 1   1 < h <ndof+1
```

i.e. hterm(1,f) is the unit operator for degree of freedom f.

### HAMILTON and associated arrays

Name Description
`hamilton(f,k)` Integer array specifying operators for degree of freedom f, for Hamiltonian term number k. NB the coefficients are stored in f=ndof+1.
`maxkoe` Maximum possible number of Hamiltonian terms.

## Simple example

For example, the operator term

```A | q | q*cos
```

results in

```hoplab(1) = 1
hoplab(2) = A
hoplab(3) = q
hoplab(4) = cos

htmfac(1) = 1   htmdof(1) = 1   hterm(1,1) = 1
htmfac(2) = 1   htmdof(2) = 2   hterm(1,2) = 1
htmfac(3) = 1   htmdof(3) = 3   hterm(1,3) = 1
htmfac(4) = 1   htmdof(4) = 1   hterm(1,4) = 3
htmfac(5) = 2   htmdof(5) = 2   hterm(1,5) = 3   hterm(2,5) = 4
htmfac(6) = 1   htmdof(6) = 3   hterm(1,6) = 2

hamilton(1,1) = 4   hamilton(2,1) = 5   hamilton(3,1) = 6

```

## The OPFUNCS Library

The OPFUNCS library is a set of functions that define the various possible operators. These are contained in a set of "files", that are categorized according to type. Each file has an associated number, which as the `hopfile` variable is used to find the operator defined by a label in the Hamiltonian. Each file has two sections (subroutines). In the first, the definition section, a label is connected to a number (`hopilab`). In the second, the function section, the functions (or subroutines) are set up.

There are four categories of operators, each of which are controlled by a callX.f file which enables the searching and use of operators of a particular category. The following table lists the four categories, with the file numbers reserved for each:

Nos. Controlling subroutine Description
1-100 callgrd Operators defined only on a grid (non-local operators, natural potentials etc.).
101-200 callanlz Complex analytic functions.
201-300 callsrf Multi-dimensional potential energy surfaces.
301-400 callanld Real analytic functions.

The following table lists the files presently in the library:

hopfile(hl) File name Description
1 diagonal grid potentials read from a file (see Files Containing Operators below)
2 non-diagonal grid potentials read from a file. (see Files Containing Operators below)
3 funcgrd 1D non-local operators
4 ch3igrd 1D non-local operators specific to the CH3I Hamiltonian
5 funckleg 2D non-local operators (j^2, j_p, j_m) specific to KLeg and PLeg primitive representations.
6 combined natural potentials.
7 4D operators for combined KLegs
8 funcwig 3D non-local operators
9 callmlop diagonal potentials from MLPF leaves
101 funcanlz 1D complex analytic functions
201 funcsrf multi-dimensional potential energy surfaces
202 functhph 2D trigonometric potential functions used in surfacs scattering
203 usersrf user defined multi-dimensional potential energy surfaces
301 real number
302 funcanld 1D real analytic functions
303 func1d 1D potential energy curves
304 user1d user defined 1D energy curves
305 ch3i 1D operators specific to the CH3I Hamiltonian

New functions can be included by editing one of the existing files. Each operator name must be unique. If a new file is to be created, the next file number in the appropriate category should be selected. The appropriate callX.f file also must be edited.

## Files Containing Operators

Certain operators, e.g. natural potentials, are stored on disc in a physical file. The following arrays store information on these files:

Name Description
nrdf Total number of files to be read.
rdfiles(nr) Character array with full names of files.

A label name,n,nr indicates that the operator name is the n th operator on the nr th file.

For these operators to be used in an equivalent manner to the operators in the library, these are read into the array `rdops`, which has the following associated information:

Name Description
zrdop(n) Pointer to n th operator.
rdopdim Dimension of rdops array.
rdtype(n) Type of n th operator. If rdtype(n) = 2, operator is real diagonal, stored as a vector. Otherwise it is stored as a matrix.