# Materials Algorithms ProjectProgram Library

This page explains the standard format in which MAP documentation is presented. The crystallography subroutine MAP_CRYSTAL_ANGLEE is used as an illustrative example.

## Subroutine MAP_CRYSTAL_ANGLEE

### Provenance of Source Code

The name of, and contact information for, the person or persons who provided the source code and who should be approached if further information is required.

Phase Transformations Group,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge CB2 3QZ, U.K.

E-mail: name@comp.system

Give the date (to the nearest month) when the code was added to the MAP Website.

Top | Next

### Purpose

A brief statement outlining the broad purpose of the code.

To find the angle between two vectors.

Top | Next | Prev

### Specification

Details of the software (language of source code) or, if provided as a compiled program, details of the hardware required to run the executable file:

 Language: FORTRAN Product form: Source code.

A clear statement of the input and output arguments used by the routine, the order in which they must be passed and their type, eg:

```SUBROUTINE MAP_CRYSTAL_ANGLEE(F, G, H, K, L, JR1, HH, KK, LL, JR2, ANG, ADEG, PI)

REAL F(9), G(9), H, K, L, HH, KK, LL, ANG, ADEG, PI
INTEGER JR1, JR2
```

Top | Next | Prev

### Description

A more detailed explanation of the purpose and operation of the code, perhaps including some background theory and any limitations on values of input arguments:-

The vectors may be defined by components in real or reciprocal space. The metric tensor F converts components from reciprocal to real space. The metric tensor G converts components from real to reciprocal space.

In order to calculate the angle, it is necessary for one vector to be defined in real space, and the other in reciprocal space. The magnitude of each vector is calculated, and the scalar product of the two vectors is used to compute the angle.

Top | Next | Prev

### References

A list of references where more detailed background information can be found. These need not be published works.

1. H.K.D.H. Bhadeshia, 1987, Worked Examples in the Geometry of Crystals, Institute of Materials, London.

Top | Next | Prev

### Parameters

#### Input parameters

A statement of the type and purpose of all the arguments supplied to and returned from the routine.

F - real array of dimension 9
F is a metric tensor used to convert components from reciprocal to real space.

G - real array of dimension 9
G is a metric tensor used to convert the components from real to reciprocal space.

H, K, L - reals
H, K, L are the components of the first vector [H,K,L].

JR1 - integer
JR1 is 0 if the vector [H,K,L] is in real space coordinates, 1 if it is in reciprocal space.

HH, KK, LL - reals
HH, KK, LL are the components on the second vector [HH,KK,LL].

JR2 - integer
JR2 is 0 if the vector [HH,KK,LL] is in real space coordinates, 1 if it is in reciprocal space.

PI - real
PI is pi.

#### Output parameters

ANG - real
ANG is the angle in radians.

ADEG is the angle in degrees.

Top | Next | Prev

### Error Indicators

Describes any error-trapping procedures that may be implemented in the code, eg input arguments outside specified limits.

None.

Top | Next | Prev

### Accuracy

A statement of known limits to the accuracy of the results generated by the code, and/or a description of the circumstances within which a specified accuracy is maintained.

Works for any crystal system.

Top | Next | Prev

Any additional information which does not fit into another category.

None.

Top | Next | Prev

### Example

#### 1. Program text

A simple program illustrating the use of the routine and the output which will be generated.

```       REAL F(9), G(9), H, K, L, HH, KK, LL, ANG, ADEG, AP, CP, PI
INTEGER JR1, JR2
INCLUDE 'map_constants_pi.f'
CALL MAP_CRYSTAL_TENSOR2(F, G, AP, CP)
READ (5,*) H, K, L, JR1
READ (5,*) HH, KK, LL, JR2
CALL MAP_CRYSTAL_ANGLEE(F, G, H, K, L, JR1, HH, KK, LL, JR2, ANG, ADEG, PI)
STOP
END

```

#### 2. Program data

```1.0   1.0
0.0   1.0   1.0   0
1.0   0.0   1.0   1

```

#### 3. Program results

```0.500000   120.000

```

Top | Next | Prev

### Auxiliary Routines

Any other MAP routines called from within this code.

Top | Next | Prev

### Keywords

A list of keywords which describe the use of this code.

angle

Top | Next | Prev