1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
/**********************************************************************
analysis_example.c:
analysis_example.c provides examples for analyzing and
unitilizing Kohn-Sham Hamiltonian, overlap, and density
matrices which are stored in filename.scfout.
Log of analysis_example.c:
2/July/2003 Released by T.Ozaki
******************************************************************
You can utilize a filename.scfout which is generated by the SCF
calculation of OpenMX by the following procedure:
1. Define your main routine as follows:
int main(int argc, char *argv[])
2. Include a header file, "read_scfout.h", in your main routine
(if you want, also in other routines) as follows:
#include "read_scfout.h"
3. Call a function, read_scfout(), in the main routine as follows:
read_scfout(argv);
******************************************************************
***********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "read_scfout.h"
int main(int argc, char *argv[])
{
static int ct_AN,h_AN,Gh_AN,i,j,TNO1,TNO2;
static int spin,Rn;
static double *a;
static FILE *fp;
read_scfout(argv);
/**********************************************************************
Example 1:
Print the numbers of atoms
atomnum: the number of atoms in the total system
Catomnum: the number of atoms in the central region
Latomnum: the number of atoms in the left lead
Ratomnum: the number of atoms in the right lead
grobal index of atom runs
Catomnum -> Catomnum + Latomnum -> Catomnum + Latomnum + Ratomnum
***********************************************************************/
printf("atomnum=%i\n", atomnum);
printf("Catomnum=%i\n",Catomnum);
printf("Latomnum=%i\n",Latomnum);
printf("Ratomnum=%i\n",Ratomnum);
/**********************************************************************
Example 2:
Print Kohn-Sham Hamiltonian
Hks[spin][ct_AN][h_AN][i][j]
spin: spin=0, up
spin=1, down
ct_AN: global index of atoms
h_AN local index of neighbouring atoms for the atom ct_AN
i: orbital index in the atom ct_AN
j: orbital index in the atom h_AN
NOTE:
For instance, if the basis specification of the atom ct_AN is s2p2,
then the obital index runs in order of
s, s', px, py, pz, px', py', pz'
Transformation of the local index h_AN to the grobal index Gh_AN
is made as
Gh_AN = natn[ct_AN][h_AN];
Also, the cell index is given by
Rn = ncn[ct_AN][h_AN];
Each component l, m, or n (Rn = l*a + m*b + n*c) are given by
l = atv_ijk[Rn][1];
m = atv_ijk[Rn][2];
n = atv_ijk[Rn][3];
***********************************************************************/
for (spin=0; spin<=SpinP_switch; spin++){
printf("\n\nKohn-Sham Hamiltonian spin=%i\n",spin);
for (ct_AN=1; ct_AN<=atomnum; ct_AN++){
TNO1 = Total_NumOrbs[ct_AN];
for (h_AN=0; h_AN<=FNAN[ct_AN]; h_AN++){
Gh_AN = natn[ct_AN][h_AN];
Rn = ncn[ct_AN][h_AN];
TNO2 = Total_NumOrbs[Gh_AN];
printf("glbal index=%i local index=%i (grobal=%i, Rn=%i)\n",
ct_AN,h_AN,Gh_AN,Rn);
for (i=0; i<TNO1; i++){
for (j=0; j<TNO2; j++){
printf("%10.7f ",Hks[spin][ct_AN][h_AN][i][j]);
}
printf("\n");
}
}
}
}
/**********************************************************************
Example 3:
Print overlap matrix
OLP[ct_AN][h_AN][i][j]
ct_AN: global index of atoms
h_AN local index of neighbouring atoms for the atom ct_AN
i: orbital index in the atom ct_AN
j: orbital index in the atom h_AN
NOTE:
For instance, if the basis specification of the atom ct_AN is s2p2,
then the obital index runs in order of
s, s', px, py, pz, px', py', pz'
Transformation of the local index h_AN to the grobal index Gh_AN
is made as
Gh_AN = natn[ct_AN][h_AN];
Also, the cell index is given by
Rn = ncn[ct_AN][h_AN];
Each component l, m, or n (Rn = l*a + m*b + n*c) are given by
l = atv_ijk[Rn][1];
m = atv_ijk[Rn][2];
n = atv_ijk[Rn][3];
***********************************************************************/
printf("\n\nOverlap matrix\n");
for (ct_AN=1; ct_AN<=atomnum; ct_AN++){
TNO1 = Total_NumOrbs[ct_AN];
for (h_AN=0; h_AN<=FNAN[ct_AN]; h_AN++){
Gh_AN = natn[ct_AN][h_AN];
Rn = ncn[ct_AN][h_AN];
TNO2 = Total_NumOrbs[Gh_AN];
printf("glbal index=%i local index=%i (grobal=%i, Rn=%i)\n",
ct_AN,h_AN,Gh_AN,Rn);
for (i=0; i<TNO1; i++){
for (j=0; j<TNO2; j++){
printf("%10.7f ",OLP[ct_AN][h_AN][i][j]);
}
printf("\n");
}
}
}
/**********************************************************************
Example 4:
Print overlap matrix with position operator x
OLPpox[ct_AN][h_AN][i][j]
ct_AN: global index of atoms
h_AN local index of neighbouring atoms for the atom ct_AN
i: orbital index in the atom ct_AN
j: orbital index in the atom h_AN
NOTE:
For instance, if the basis specification of the atom ct_AN is s2p2,
then the obital index runs in order of
s, s', px, py, pz, px', py', pz'
Transformation of the local index h_AN to the grobal index Gh_AN
is made as
Gh_AN = natn[ct_AN][h_AN];
Also, the cell index is given by
Rn = ncn[ct_AN][h_AN];
Each component l, m, or n (Rn = l*a + m*b + n*c) are given by
l = atv_ijk[Rn][1];
m = atv_ijk[Rn][2];
n = atv_ijk[Rn][3];
***********************************************************************/
printf("\n\nOverlap matrix with position operator x\n");
for (ct_AN=1; ct_AN<=atomnum; ct_AN++){
TNO1 = Total_NumOrbs[ct_AN];
for (h_AN=0; h_AN<=FNAN[ct_AN]; h_AN++){
Gh_AN = natn[ct_AN][h_AN];
Rn = ncn[ct_AN][h_AN];
TNO2 = Total_NumOrbs[Gh_AN];
printf("glbal index=%i local index=%i (grobal=%i, Rn=%i)\n",
ct_AN,h_AN,Gh_AN,Rn);
for (i=0; i<TNO1; i++){
for (j=0; j<TNO2; j++){
printf("%10.7f ",OLPpox[ct_AN][h_AN][i][j]);
}
printf("\n");
}
}
}
/**********************************************************************
Example 5:
Print density matrix
DM[spin][ct_AN][h_AN][i][j]
spin: spin=0, up
spin=1, down
ct_AN: global index of atoms
h_AN local index of neighbouring atoms for the atom ct_AN
i: orbital index in the atom ct_AN
j: orbital index in the atom h_AN
NOTE:
For instance, if the basis specification of the atom ct_AN is s2p2,
then the obital index runs in order of
s, s', px, py, pz, px', py', pz'
Transformation of the local index h_AN to the grobal index Gh_AN
is made as
Gh_AN = natn[ct_AN][h_AN];
Also, the cell index is given by
Rn = ncn[ct_AN][h_AN];
Each component l, m, or n (Rn = l*a + m*b + n*c) are given by
l = atv_ijk[Rn][1];
m = atv_ijk[Rn][2];
n = atv_ijk[Rn][3];
***********************************************************************/
for (spin=0; spin<=SpinP_switch; spin++){
printf("\n\nDensity matrix spin=%i\n",spin);
for (ct_AN=1; ct_AN<=atomnum; ct_AN++){
TNO1 = Total_NumOrbs[ct_AN];
for (h_AN=0; h_AN<=FNAN[ct_AN]; h_AN++){
Gh_AN = natn[ct_AN][h_AN];
Rn = ncn[ct_AN][h_AN];
TNO2 = Total_NumOrbs[Gh_AN];
printf("glbal index=%i local index=%i (grobal=%i, Rn=%i)\n",
ct_AN,h_AN,Gh_AN,Rn);
for (i=0; i<TNO1; i++){
for (j=0; j<TNO2; j++){
printf("%10.7f ",DM[spin][ct_AN][h_AN][i][j]);
}
printf("\n");
}
}
}
}
}
|