File: TRAN_Add_ADensity_Lead.c

package info (click to toggle)
openmx 3.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 325,856 kB
  • ctags: 3,575
  • sloc: ansic: 152,655; f90: 2,080; python: 876; makefile: 675; sh: 25; perl: 18
file content (84 lines) | stat: -rw-r--r-- 2,081 bytes parent folder | download | duplicates (2)
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
/**********************************************************************
  TRAN_Add_ADensity_Lead.c:

  TRAN_Add_ADensity_Lead.c is a subroutine to correct atomic charge
  density near the boundary region of the extended system
  The super position of atomic charge density from that of electrodes 
  is added to the regions [0:TRAN_grid_bound[0]] and 
  [TRAN_grid_bound[1]:Ngrid1-1].

  Log of TRAN_Add_ADensity_Lead.c:

     24/July/2008  Released by T.Ozaki
     24/Apr/2012   Modified by T.Ozaki

***********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>
#include "tran_variables.h"
#include "tran_prototypes.h"


void TRAN_Add_ADensity_Lead(
            MPI_Comm comm1,
            int SpinP_switch,
            int Ngrid1,
            int Ngrid2,
            int Ngrid3,
            int My_NumGridB_AB,
            double *ADensity_Grid_B)

#define grid_e_ref(i,j,k)  ( ((i)-l1[0]) *Ngrid2*Ngrid3+(j)*Ngrid3+(k) )

{
  int side,l1[2],N2D,GNs;
  int i,j,k,spin,GN,BN_AB;
  int myid,numprocs;

  MPI_Comm_size(comm1,&numprocs);
  MPI_Comm_rank(comm1,&myid);

  if (myid==Host_ID){
    printf("<TRAN_Add_ADensity_Lead>\n");
  }

  /* set N2D and GNs */

  N2D = Ngrid1*Ngrid2;
  GNs = ((myid*N2D+numprocs-1)/numprocs)*Ngrid3;

  /***********************************************************
    add contribution to atomic charge density from electrodes

    side=0 -> left lead
    side=1 -> right lead
  ***********************************************************/

  for (side=0; side<=1; side++){

    if (side==0){
      l1[0] = 0;
      l1[1] = TRAN_grid_bound[0]; 
    }
    else{
      l1[0] = TRAN_grid_bound[1];
      l1[1] = Ngrid1-1;
    }

    for (BN_AB=0; BN_AB<My_NumGridB_AB; BN_AB++){

      GN = BN_AB + GNs;     
      i = GN/(Ngrid2*Ngrid3);    
      j = (GN - i*Ngrid2*Ngrid3)/Ngrid3;
      k = GN - i*Ngrid2*Ngrid3 - j*Ngrid3; 

      if ( l1[0]<=i && i<=l1[1] ) {

	ADensity_Grid_B[BN_AB] += ElectrodeADensity_Grid[side][ grid_e_ref(i,j,k) ];
      }
    }
  }
}