# Analysis of difference charge density induced by the interaction

The redistribution of charge (spin) density induced by the interaction between two systems A and B can be analyzed by the following procedure:

(i) calculate the composite system consisting of A and B

Then, you will have a cube file for charge (spin) density. Let it be 'AB.cube'. Also, you will find 'Grid_Origin' in the standard output which gives x-, y-, and z-components of the origin of the regular grid as:

```  Grid_Origin  xxx  yyy  zzz
```
The values will be used in the following calculations (ii) and (iii).

(ii) calculate the system A

This calculation must be performed by the same calculation condition with the same unit cell as in the composite system consisting of A and B. Also, the coordinates of the system A must be the same as in the calculation (i). To use the same origin as in the calculation (i) rather than the use of an automatically determined origin, you have to include the following keyword in your input file:
```  scf.fixed.grid  xxx  yyy  zzz
```
where 'xxx yyy zzz' is the coordinate of the origin you got in the calculation (i). Then, you will have a cube file for charge (spin) density. Let it be 'A.cube'.

(iii) calculate the system B

As well as the calculation (ii), this calculation must be performed by the same calculation condition with the same unit cell as in the composite system consisting of A and B. Also, the coordinates of the system B must be the same as in the calculation (i). To use the same origin as in the calculation (i) rather than the use of an automatically determined origin, you have to include the following keyword in your input file:
```  scf.fixed.grid  xxx  yyy  zzz
```
where 'xxx yyy zzz' is the coordinate of the origin you got in the calculation (i). Then, you will have a cube file for charge (spin) density. Let it be 'B.cube'.

(iv) compile two codes

compile two codes as follows:
```  % gcc diff_gcube.c -lm -o diff_gcube
```  % ./add_gcube A.cube B.cube A_B.cube
```  % ./diff_gcube AB.cube A_B.cube dAB.cube