File: TRAN_Check_Region.c

package info (click to toggle)
openmx 3.2.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 62,572 kB
  • ctags: 2,684
  • sloc: ansic: 130,666; python: 876; makefile: 560; xml: 63; perl: 18; sh: 4
file content (149 lines) | stat: -rw-r--r-- 3,691 bytes parent folder | download
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "tran_variables.h"


/*  output: none
    return value:  1 = OK
                   0 = NG

   purpose:
   to confirm that ...|L1|L|C|R|R1|...  has no overlapping PAO over the nearest neighboring region.

*/
int TRAN_Check_Region(
		      int atomnum,
		      int *WhatSpecies, 
		      double *Spe_Atom_Cut1,
		      double **Gxyz
		      )
{

  int ct_AN;
  int wanA;
  double rcutA;

  int ct_BN;
  int wanB;
  double rcutB;

  double rcutAB;

  int ix,iy,iz;
  int nz=3,ny=3;

  int iregion;

  double A[4], B[4], diff[4];
  double len;

  int i;

  char *regionstr[2]={"region L","region R"};

  int error;

  error=0;


  /* center <-> L1 or R1 */

  for (ct_AN=1; ct_AN<=atomnum; ct_AN++) {

    if ( TRAN_region[ct_AN]%10 ==1 ) { /* center */

      wanA = WhatSpecies[ct_AN];
      rcutA = Spe_Atom_Cut1[wanA];
      for (i=1; i<=3; i++) { A[i]= Gxyz[ct_AN][i]; }

      for (ct_BN=1; ct_BN<=atomnum; ct_BN++) {

	if ( TRAN_region[ct_BN]%10 == 2  || TRAN_region[ct_BN]%10 == 3 ) { /* left or right */

	  if ( TRAN_region[ct_BN]%10 == 2 ) {ix=-1; iregion=0;}/* left */
	  if ( TRAN_region[ct_BN]%10 == 3 ) {ix=+1; iregion=1;}/* right */

	  wanB = WhatSpecies[ct_BN];
	  rcutB = Spe_Atom_Cut1[wanB];
       
	  rcutAB = rcutA + rcutB;

	  for (iy=-ny;iy<=ny;iy++) {
	    for (iz=-nz;iz<=nz;iz++) {

	      for (i=1;i<=3;i++) {
		B[i] = Gxyz[ct_BN][i] + tv_e[iregion][1][i]*ix
             		              + tv_e[iregion][2][i]*iy
		                      + tv_e[iregion][3][i]*iz;
	      } 

	      for (i=1;i<=3;i++) { diff[i] = A[i]-B[i]; }
	      len = sqrt( diff[1]*diff[1]+diff[2]*diff[2]+diff[3]*diff[3] );
	      if ( len <= rcutAB ) { 
                printf("\n\nTRAN_Check_Region_Lead()\n");
                printf("\nThe length between atomA=%d(region C) and atomB=%d(%s) is too short for the transport calculation.\n",
		       ct_AN, ct_BN,regionstr[iregion]); 
                printf("distance=%lf rcutA=%lf rcutB=%lf\n",len,rcutA,rcutB);
                error=1;
		goto LRcheck;
              }
	     
	    } /* ix */
	  } /* iy */

	} /* left or right */
      } /* ct_BN */

    } /* center */
  } /* ct_AN */


 LRcheck: 

  /* L <-> R */
  for (ct_AN=1;ct_AN<=atomnum;ct_AN++) {
    if ( TRAN_region[ct_AN]%10 ==2 ) { /* left */
      wanA = WhatSpecies[ct_AN];
      rcutA = Spe_Atom_Cut1[wanA];
      for (i=1;i<=3;i++) { A[i]= Gxyz[ct_AN][i]; }

      for (ct_BN=1;ct_BN<=atomnum;ct_BN++) { 
        if ( TRAN_region[ct_AN]%10 ==3 ) { /* right */
          wanB = WhatSpecies[ct_BN];
          rcutB = Spe_Atom_Cut1[wanB];

          rcutAB = rcutA+rcutB;

          ix =0;
          for (iy=-ny;iy<=ny;iy++) {
            for (iz=-nz;iz<=nz;iz++) {
              for (i=1;i<=3;i++) {

                B[i] = Gxyz[ct_BN][i] + tv_e[iregion][1][i]*ix
                                      + tv_e[iregion][2][i]*iy
                                      + tv_e[iregion][3][i]*iz;
              }
              for (i=1;i<=3;i++) { diff[i] = A[i]-B[i]; }
              len = sqrt( diff[1]*diff[1]+diff[2]*diff[2]+diff[3]*diff[3] );
              if ( len <= rcutAB ) { 
                printf("\n\nTRAN_Check_Region_Lead()\n");
                printf("\nThe length between atomA=%d(region L) and atomB=%d(region R) is too short for the transport calculation.\n",ct_AN, ct_BN);
                printf("distance=%lf rcutA=%lf rcutB=%lf\n",len,rcutA,rcutB);
                error=1;
		goto lastproc;
              }

	    }/* iz */
	  } /* iy */
        } /* right */
      } /* ct_BN */
    } /* left */
  } /* ct_AN */

 lastproc:

  if (error) { return 0; }
  else { return 1; }
}