# Algorithms

In Octopus, many operations, such as time propagations, geometry optimization, etc. are implemented in terms of algorithms. An algorithm, in general, contains a set of instructions, which are performed in a well-defined order.

### Algorithm container

The algorithm_t class itself, is only an extention of the linked list.

Definition of algorithm_t

Algorithmic operations can be added with the function add_operation(). Examples are discussed in the section Propagators.

Placement in the class hierarchy

### Algorithm iterator

Definition of algorithm_iterator_t

### Algorithmic operations

Definition of algorithmic_operation_t

Some global algorithmic steps are defined in multisystem/propagator.F90:


! Known propagation operations
character(len=ALGO_LABEL_LEN), public, parameter ::   &
START_SCF_LOOP       = 'START_SCF_LOOP',            &
END_SCF_LOOP         = 'END_SCF_LOOP',              &
STORE_CURRENT_STATUS = 'STORE_CURRENT_STATUS'

type(algorithmic_operation_t), public, parameter :: &
OP_START_SCF_LOOP       = algorithmic_operation_t(START_SCF_LOOP,       'Starting SCF loop'),         &
OP_END_SCF_LOOP         = algorithmic_operation_t(END_SCF_LOOP,         'End of SCF iteration'),      &
OP_STORE_CURRENT_STATUS = algorithmic_operation_t(STORE_CURRENT_STATUS, 'Store current status')


Derived propagators can then add their own steps, such as e.g. in multisystem/propagator_verlet.F90:


! Specific verlet propagation operations identifiers
character(len=30), public, parameter ::      &
VERLET_START       = 'VERLET_START',       &
VERLET_FINISH      = 'VERLET_FINISH',      &
VERLET_UPDATE_POS  = 'VERLET_UPDATE_POS',  &
VERLET_COMPUTE_ACC = 'VERLET_COMPUTE_ACC', &
VERLET_COMPUTE_VEL = 'VERLET_COMPUTE_VEL'

! Specific verlet propagation operations
type(algorithmic_operation_t), public, parameter :: &
OP_VERLET_START       = algorithmic_operation_t(VERLET_START,       'Starting Verlet propagation'),               &
OP_VERLET_FINISH      = algorithmic_operation_t(VERLET_FINISH,      'Finishing Verlet propagation'),              &
OP_VERLET_UPDATE_POS  = algorithmic_operation_t(VERLET_UPDATE_POS,  'Propagation step - Updating positions'),     &
OP_VERLET_COMPUTE_ACC = algorithmic_operation_t(VERLET_COMPUTE_ACC, 'Propagation step - Computing acceleration'), &
OP_VERLET_COMPUTE_VEL = algorithmic_operation_t(VERLET_COMPUTE_VEL, 'Propagation step - Computing velocity')