IPCC  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CSPLoop Class Reference

Class for Schrodinger-Poisson solver. More...

#include "SPLoop.h"

Collaboration diagram for CSPLoop:
Collaboration graph

Public Member Functions

 CSPLoop (void)
 
 CSPLoop (bool bMPI)
 
 ~CSPLoop (void)
 
unsigned int ConstructionGeometric ()
 
unsigned int BuildHamiltonian ()
 
bool executeSPLoop ()
 
void SetParam (CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
 
void Prepare ()
 
void Finalize ()
 

Private Member Functions

void Initialize ()
 
bool MapZBandCB ()
 
bool IsSatisfyCriteria ()
 
void SolveSchroedinger (double *pVA, double *pEval, double **pWF)
 
void SolvePoisson (CMatrixOperation::CVector *pRHS, CMatrixOperation::CVector *pSolution)
 
void DumpSolution (double *pVsol, double *pQsol, NEIGHBOR_MAP_INFO *nbrmap)
 
void Fermi_Dirac (CMatrixOperation::CVector *pWF, CLanczosMethod::LPEIGENVALUE_RESULT lpResult)
 
void ApplyingPotential (CMatrixOperation::CVector *pVA)
 
void SetInitialPotential (double *potential, double *impurity_position, bool bUseSplitVector)
 
void GetChargeProfile (double *impurity_position, double **WF, CMatrixOperation::CVector *charge)
 
LP_CONTACT_GROUP_INFOAllocateContactGrp (unsigned int &nRtn)
 
CMatrixOperation::CCSRAllocateCSR (unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, CGeometricShape *pGeometricShape, bool bMPI, int &nLBIndex, int nMultipleSize)
 

Private Attributes

CMatrixOperation::CCSRm_pHamiltonian
 
CMatrixOperation::CCSRm_pFDMPoisson
 
CGeometricShape m_SchroedingerGeometric
 Geometric construction for Schroedinger. More...
 
CGeometricShape m_PossionGeometric
 Geometric construction for Poisson. More...
 
bool m_bMPI
 
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
 
double * m_pMap
 
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
 
NEIGHBOR_MAP_INFO m_PossionMapInfo
 
double m_fTotalSurfaceCount
 
CMatrixOperation::CVector m_BiasVector
 
ConjugateGradientMethod m_CG
 
CLanczosMethod m_Lanczos
 

Detailed Description

Class for Schrodinger-Poisson solver.

Date
05/Jan/2016

Definition at line 26 of file SPLoop.h.

Constructor & Destructor Documentation

CSPLoop::CSPLoop ( void  )

Definition at line 12 of file SPLoop.cpp.

References Initialize().

13 {
14  Initialize();
15 }
void Initialize()
Definition: SPLoop.cpp:30

Here is the call graph for this function:

CSPLoop::CSPLoop ( bool  bMPI)

Definition at line 18 of file SPLoop.cpp.

References Initialize(), and m_bMPI.

19 {
20  Initialize();
21  m_bMPI = bMPI;
22 }
void Initialize()
Definition: SPLoop.cpp:30
bool m_bMPI
Definition: SPLoop.h:57

Here is the call graph for this function:

CSPLoop::~CSPLoop ( void  )

Definition at line 25 of file SPLoop.cpp.

26 {
27 // Finalize();
28 }

Member Function Documentation

LP_CONTACT_GROUP_INFO * CSPLoop::AllocateContactGrp ( unsigned int &  nRtn)
private

Definition at line 666 of file SPLoop.cpp.

References ERROR_MALLOC, m_lpParam, and CCommandFileParser::INPUT_CMD_PARAM::nContactNumber.

Referenced by ConstructionGeometric().

667 {
668 
669  unsigned int i;
670  CONTACT_GROUP_INFO **pContactGroup = NULL;
671 
672  pContactGroup = new LP_CONTACT_GROUP_INFO[m_lpParam->nContactNumber];
673  if (NULL == pContactGroup)
674  throw ERROR_MALLOC;
675 
676  for (i = 0; i < m_lpParam->nContactNumber; i++)
677  {
678  pContactGroup[i] = new CONTACT_GROUP_INFO;
679  }
680 
681  return pContactGroup;
682 }
const unsigned long ERROR_MALLOC
Error code that means error occur during memory allocation.
Definition: Global.h:62
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
Structure for contact group information.

Here is the caller graph for this function:

CMatrixOperation::CCSR * CSPLoop::AllocateCSR ( unsigned int &  nRtn,
NEIGHBOR_MAP_INFO lpMapInfo,
CCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
CGeometricShape pGeometricShape,
bool  bMPI,
int &  nLBIndex,
int  nMultipleSize 
)
private
Parameters
nRtn[out]Operation result
lpMapInfoStructure that include atom map
lpParamStrcuture that include options parameter for program launching
pGeometricShapeClass that include shape information
bMPIRunning with MPI enviroment or not

Definition at line 474 of file SPLoop.cpp.

References CMatrixOperation::CCSR::BuildDataBuffer(), ERROR_MALLOC, NEIGHBOR_MAP_INFO::fItemCount, CGeometricShape::GetAtomStartID(), CGeometricShape::GetTotalAtomCount(), CMPIManager::InitCommunicationBufferMetric(), CMPIManager::LoadBlancing(), CCommandFileParser::INPUT_CMD_PARAM::nMatrixDemension, CMatrixOperation::CCSR::SetColumnCount(), CMatrixOperation::CCSR::SetFirstRowIndex(), and CMatrixOperation::CCSR::SetRowCount().

Referenced by BuildHamiltonian().

475 {
476  unsigned int nRowCount, nColumnCount;
477  CMatrixOperation::CCSR *pResult = NULL;
478 
479  pResult = new CMatrixOperation::CCSR();
480  if (NULL == pResult)
481  throw ERROR_MALLOC;
482 
483  nRowCount = (unsigned int)lpMapInfo->fItemCount * nMultipleSize;
484  nColumnCount = (unsigned int)lpMapInfo->fItemCount * nMultipleSize;
485 
486  if (bMPI)
487  {
488  nColumnCount = (unsigned int)pGeometricShape->GetTotalAtomCount() * nMultipleSize;
489  CMPIManager::LoadBlancing(nRowCount);
491  }
492 
493  lpParam->nMatrixDemension = nColumnCount;
494 
495  pResult->SetRowCount(nRowCount);
496  pResult->SetColumnCount(nColumnCount);
497  pResult->BuildDataBuffer();
498  pResult->SetFirstRowIndex(pGeometricShape->GetAtomStartID()*nMultipleSize);
499 
500  return pResult;
501 }
double GetTotalAtomCount()
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
const unsigned long ERROR_MALLOC
Error code that means error occur during memory allocation.
Definition: Global.h:62
void SetFirstRowIndex(double fFirstIndex)
static void LoadBlancing(int nElementCount)
Load blancing for MPI, This function for lanczos solving with geometric constrcution.
Definition: MPIManager.cpp:152
double GetAtomStartID()
Set total valid atom count in shape.
static int InitCommunicationBufferMetric()
Initializing MPI Communication buffer for MVMul.
Definition: MPIManager.cpp:655
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
void BuildDataBuffer()
Allocating memory for class member variable.
int nMatrixDemension
Hamiltonian matrix demension.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
Data and operation representation of CSR(Compressed Sparse Row)

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::ApplyingPotential ( CMatrixOperation::CVector pVA)
private
unsigned int CSPLoop::BuildHamiltonian ( )

< Building Schroedinger Hamiltonian

< Building Hamiltonian matrix

< Building Hamiltonian matrix

Definition at line 155 of file SPLoop.cpp.

References AllocateCSR(), CCommandFileParser::INPUT_CMD_PARAM::bSaveHamiltonian, CHamiltonianBuilder::BuildHamiltonian(), CGeometricShape::BuildPEHamiltonian(), CAN_NOT_LOAD_METERIAL_PARAM, CUtility::DumpCSR(), CGeometricShape::GetAtomStartID(), CMPIManager::IsRootRank(), m_bMPI, m_CG, m_Lanczos, m_lpParam, CGeometricShape::m_nAtomFirstLayer, CGeometricShape::m_nAtomLastLayer, m_pFDMPoisson, m_pHamiltonian, m_PossionGeometric, m_PossionMapInfo, m_SchroedingerGeometric, m_SchroedingerMapInfo, CCommandFileParser::INPUT_CMD_PARAM::nBandSize, CMatrixOperation::CCSR::nComponentsFirstUnitCell, CMatrixOperation::CCSR::nComponentsLastUnitCell, CLanczosMethod::SetLBIndex(), SHOW_SIMPLE_MSG, and CUtility::ShowMsg().

Referenced by SPLoopMain().

156 {
157  unsigned int nRtnCode;
158  int nLBIndex[2];
159 
162  m_Lanczos.SetLBIndex(nLBIndex[0]);
163 
164  SHOW_SIMPLE_MSG("-Building Hamiltonian Matrix\n");
166  {
167  SHOW_SIMPLE_MSG("Terminated program. Can't load meterial param information.\n");
168  nRtnCode = CAN_NOT_LOAD_METERIAL_PARAM;
169  //FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
170  return nRtnCode;
171  }
172 
175 
176 
178  {
179  SHOW_SIMPLE_MSG("-Save Hamiltonian matrix to file\n");
181  }
182 
183 
186  m_CG.SetLBIndex(nLBIndex[1]);
187 
189  CUtility::ShowMsg("-Building A-Matrix for PE\n");
191  {
193  CUtility::ShowMsg("-Terminated program. Can't load meterial param information.\n");
194  nRtnCode = CAN_NOT_LOAD_METERIAL_PARAM;
195  //FinalEvn(pHamiltonian, lpParam, pKValue, &PE_mapInfo, &PE_GeometricShape, bMPI);
196  return nRtnCode;
197  }
198 
200  {
202  CUtility::ShowMsg("-Save Poisson matrix to file\n");
204  }
205 
206 
207  return nRtnCode;
208 }
unsigned int m_nAtomFirstLayer
="">
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
unsigned int nComponentsLastUnitCell
Atom counts for interoperaton with next node.
bool BuildPEHamiltonian(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, CMatrixOperation::CCSR *pCSRResult)
Build PE Hamiltonian matrix from mapinfo data.
NEIGHBOR_MAP_INFO m_PossionMapInfo
Definition: SPLoop.h:61
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
static void DumpCSR(CMatrixOperation::CCSR *pCSR, char *pszFileName, double fAtomIDStartIndex)
Definition: Utility.cpp:296
CMatrixOperation::CCSR * AllocateCSR(unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, CGeometricShape *pGeometricShape, bool bMPI, int &nLBIndex, int nMultipleSize)
Definition: SPLoop.cpp:474
CLanczosMethod m_Lanczos
Definition: SPLoop.h:65
double GetAtomStartID()
Set total valid atom count in shape.
CGeometricShape m_SchroedingerGeometric
Geometric construction for Schroedinger.
Definition: SPLoop.h:55
unsigned int nBandSize
Band basis size.
CMatrixOperation::CCSR * m_pFDMPoisson
Definition: SPLoop.h:54
static bool BuildHamiltonian(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, CMatrixOperation::CCSR *pCSRResult, unsigned int fAtomStartID)
Build Hamiltonian matrxi from mapinfo data.
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
unsigned int m_nAtomLastLayer
Last layer information for sending to next node.
CMatrixOperation::CCSR * m_pHamiltonian
Definition: SPLoop.h:53
CGeometricShape m_PossionGeometric
Geometric construction for Poisson.
Definition: SPLoop.h:56
unsigned int nComponentsFirstUnitCell
Atom counts for interoperaton with previous node.
bool m_bMPI
Definition: SPLoop.h:57
void SetLBIndex(int nLBIndex)
Definition: LanczosMethod.h:55
#define CAN_NOT_LOAD_METERIAL_PARAM
Return code at main loop, there is no material param information file.
Definition: Global.h:72
bool bSaveHamiltonian
Save Hamiltonian matrix or not.
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
ConjugateGradientMethod m_CG
Definition: SPLoop.h:64
#define SHOW_SIMPLE_MSG(message)
Definition: Global.h:40

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int CSPLoop::ConstructionGeometric ( )

< Building Schroedinger Geometric - Start

< Building Poisson Geometric - Start

< Creating contact group object

< Building Poisson Geometric - End

Definition at line 41 of file SPLoop.cpp.

References AllocateContactGrp(), CMPIManager::AllReduceDouble(), CGeometricShape::BuildPEBiasVector(), CALCULATION_SUCCESS, CAN_MAPPING_ZB_TO_CB, CGeometricShape::ConstructBasicGeometric(), CGeometricShape::ConstructContactRegionOnPoissonGrid(), CUBIC, NEIGHBOR_MAP_INFO::fItemCount, CGeometricShape::GetSurfaceAtomList(), CMPIManager::IsRootRank(), m_BiasVector, m_bMPI, m_fTotalSurfaceCount, m_lpParam, m_pMap, m_PossionGeometric, m_PossionMapInfo, m_SchroedingerGeometric, m_SchroedingerMapInfo, MapZBandCB(), CCommandFileParser::INPUT_CMD_PARAM::nContactNumber, CCommandFileParser::INPUT_CMD_PARAM::nDirectionSingle, CGeometricShape::SetMatchingUnitcellCount(), CGeometricShape::SetupPEBoundaryCondition(), SHOW_SIMPLE_MSG, CUtility::ShowMsg(), and CCommandFileParser::INPUT_CMD_PARAM::szStructureType.

Referenced by SPLoopMain().

42 {
43  unsigned int nResultCode;
44  bool bRtn = false;
45  char szMsg[1024];
46  double fSurfaceCount;
47  char szStruct[1024];
48  CONTACT_GROUP_INFO **pContactGrp = NULL;
49 
52  if( CALCULATION_SUCCESS != nResultCode )
53  return false;
54  SHOW_SIMPLE_MSG("-Schroedinger geometry construction completed!\n");
55  m_pMap = (double*)malloc(sizeof(double)*m_SchroedingerMapInfo.fItemCount);
56 
57  fSurfaceCount = (double)m_SchroedingerGeometric.GetSurfaceAtomList()->size();
59 
61  {
62  sprintf(szMsg, "-Surface atom counts: %d\n", (int)m_fTotalSurfaceCount);
63  CUtility::ShowMsg(szMsg);
64  }
66 
68  strcpy(szStruct, m_lpParam->szStructureType);
71  {
72  case 100:
74  break;
75  case 110:
76  break;
77  case 111:
78  break;
79  }
81  if( CALCULATION_SUCCESS != nResultCode )
82  return false;
83 
84  SHOW_SIMPLE_MSG("-Poisson geometry construction completed!\n");
85 
86  strcpy(m_lpParam->szStructureType, szStruct);
87 
88  if(m_lpParam->nContactNumber > 0)
89  {
90  pContactGrp = AllocateContactGrp(nResultCode);
93 
94  SHOW_SIMPLE_MSG("-Contact and bias vector construction completed!\n");
95  }
96 
98 
99  if( NULL != pContactGrp )
100  delete[] pContactGrp;
102 
103  if( !MapZBandCB() )
104  {
105  SHOW_SIMPLE_MSG("-Terminated program. ZB grid doesn't map with CB grid.\n");
106  nResultCode = CAN_MAPPING_ZB_TO_CB;
107  }
108 
109  return nResultCode;
110 }
LP_CONTACT_GROUP_INFO * AllocateContactGrp(unsigned int &nRtn)
Definition: SPLoop.cpp:666
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
void BuildPEBiasVector(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, LP_CONTACT_GROUP_INFO *lpContactGroup, CMatrixOperation::CVector *pVecResult)
static double AllReduceDouble(double fNumber)
Do all reduce function with CKNComplex.
Definition: MPIManager.cpp:593
NEIGHBOR_MAP_INFO m_PossionMapInfo
Definition: SPLoop.h:61
#define CAN_MAPPING_ZB_TO_CB
Return code at main loop, there is no mapping between zb and cb.
Definition: Global.h:76
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
Structure for contact group information.
unsigned int ConstructBasicGeometric(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, bool bMPI)
Get Surface atom list.
std::vector< CGeometricAtom * > * GetSurfaceAtomList()
double * m_pMap
Definition: SPLoop.h:59
#define CALCULATION_SUCCESS
Return code at main loop, every steps completed.
Definition: Global.h:70
CMatrixOperation::CVector m_BiasVector
Definition: SPLoop.h:63
void SetMatchingUnitcellCount(int nCount)
CGeometricShape m_SchroedingerGeometric
Geometric construction for Schroedinger.
Definition: SPLoop.h:55
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
CGeometricShape m_PossionGeometric
Geometric construction for Poisson.
Definition: SPLoop.h:56
double m_fTotalSurfaceCount
Definition: SPLoop.h:62
char szStructureType[1024]
Structure type.
bool m_bMPI
Definition: SPLoop.h:57
void SetupPEBoundaryCondition(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LP_CONTACT_GROUP_INFO *lpContactGroup)
="">
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
void ConstructContactRegionOnPoissonGrid(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, LP_CONTACT_GROUP_INFO *lpContactGroup)
bool MapZBandCB()
Definition: SPLoop.cpp:112
#define SHOW_SIMPLE_MSG(message)
Definition: Global.h:40
#define CUBIC
Definition: Global.h:87

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::DumpSolution ( double *  pVsol,
double *  pQsol,
NEIGHBOR_MAP_INFO nbrmap 
)
private

Definition at line 375 of file SPLoop.cpp.

References CMPIManager::Barrier(), NEIGHBOR_MAP_INFO::fItemCount, CMPIManager::GetCurrentRank(), CMPIManager::GetTotalNodeCount(), CMPIManager::IsDeflationRoot(), CMPIManager::IsRootRank(), NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, and NEIGHBOR_MAP_INFO::pfZ_Coordination.

Referenced by executeSPLoop().

376 {
377  unsigned int nSize = (unsigned int)nbrmap->fItemCount;
378  char szOpt[1024], szFileName[1024];
379  int i, k;
380  FILE *out;
381 
382  if (false == CMPIManager::IsDeflationRoot())
383  return;
384 
386  {
387 #ifdef _WIN32
388  _mkdir("result");
389 #else
390  mkdir("result", 0777);
391 #endif
392  }
393 
395  strcpy(szOpt, "wt");
396  else
397  strcpy(szOpt, "at");
398 
399 #ifdef _WIN32
400  strcpy(szFileName, "result\\solution.dat");
401 #else
402  strcpy(szFileName, "result/solution.dat");
403 #endif //_WIN32
404 
405  for (k = 0; k < CMPIManager::GetTotalNodeCount(); ++k)
406  {
407  if (k == CMPIManager::GetCurrentRank())
408  {
409  if (NULL != (out = fopen(szFileName, szOpt)))
410  {
411  for (i = 0; i < nSize; i++)
412  fprintf(out,"%13.6e %13.6e %13.6e %13.6e %13.6e\n", nbrmap->pfX_Coordination[i], nbrmap->pfY_Coordination[i], nbrmap->pfZ_Coordination[i], pVsol[i], pQsol[i]);
413 
414  fclose(out);
415 
416  }
417 
418  }
419 
421 
422  }
423 }
double * pfZ_Coordination
An array of Z coordination.
Definition: AtomMapInfo.h:24
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
double * pfX_Coordination
An array of X coordination.
Definition: AtomMapInfo.h:22
static int GetTotalNodeCount()
Definition: MPIManager.h:42
static bool IsDeflationRoot()
Checking is root rank of Lanczos computation.
Definition: MPIManager.h:69
static int GetCurrentRank()
Definition: MPIManager.h:40
double * pfY_Coordination
An array of Y coordination.
Definition: AtomMapInfo.h:23
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
static void Barrier()
Definition: MPIManager.h:67

Here is the call graph for this function:

Here is the caller graph for this function:

bool CSPLoop::executeSPLoop ( )

Definition at line 210 of file SPLoop.cpp.

References DumpSolution(), CHamiltonianBuilder::FinalizeMatrixBuffer(), NEIGHBOR_MAP_INFO::fItemCount, CCommandFileParser::INPUT_CMD_PARAM::fKPoints, CCommandFileParser::INPUT_CMD_PARAM::fShapeLength, CCommandFileParser::INPUT_CMD_PARAM::fUnitcellLength, CMatrixOperation::CVector::GetAt(), GetChargeProfile(), CMPIManager::GetCurrentLoadBalanceCount(), CLanczosMethod::GetLBIndex(), CMatrixOperation::CCSR::GetNoneZeroCount(), CComplex::GetRealNumber(), CGeometricShape::GetUnitCellLength(), CMPIManager::IsRootRank(), m_BiasVector, m_Lanczos, m_lpParam, m_pHamiltonian, m_pMap, m_PossionGeometric, m_PossionMapInfo, m_SchroedingerMapInfo, CMatrixOperation::CCSR::m_vectColumn, CMatrixOperation::CCSR::m_vectRow, CMatrixOperation::CCSR::m_vectValueImaginaryBuffer, CMatrixOperation::CVector::m_vectValueRealBuffer, CMatrixOperation::CCSR::m_vectValueRealBuffer, CCommandFileParser::INPUT_CMD_PARAM::nContactNumber, CCommandFileParser::INPUT_CMD_PARAM::nFindingEigenValueCount, NM, phi_tid, CMatrixOperation::CVector::PlusVector(), Qo, CMatrixOperation::CVector::SetAt(), SetInitialPotential(), CMPIManager::SetPhiTid(), CMatrixOperation::CVector::SetSize(), CLanczosMethod::ShowLanczosWorkingTime(), CUtility::ShowMsg(), SolvePoisson(), SolveSchroedinger(), CTimeMeasurement::TotalMeasurementEnd(), and CTimeMeasurement::TotalMeasurementStart().

Referenced by SPLoopMain().

211 {
212 /*
213 #ifndef DISABLE_MPI_ROUTINE
214  phi_tid = CMPIManager::GetCurrentRank() % 2;
215 // FIXME test code
216 #ifndef _WIN32
217  char host_name[256];
218  gethostname(host_name, 256);
219  printf("-[Host:%s] (MPI:%03d) mapped to (MIC:%03d)\n", host_name, CMPIManager::GetCurrentRank(), phi_tid);
220 #endif //_WIN32
221 #else
222  phi_tid = 0;
223 #endif
224 */
225  double *pVnow = NULL, *pVold = NULL;
226  //CMatrixOperation::CVector WF;
227  double *pEV = NULL;
228  double **pWF = NULL;
229  double Efold, Efnow;
230  double *fPUnitLength = m_PossionGeometric.GetUnitCellLength();
231  double RHSscaler = Qo/fPUnitLength[0]/fPUnitLength[1]/fPUnitLength[2]/NM/NM/NM;
232  double spMSE = 0.0;
233  char szMsg[1024];
234 
235  CMatrixOperation::CVector charge, poissonRHS, poissonSolution;
236  unsigned int i, j;
237 
238 #ifdef USE_XEONPHI
239 
240  double *phi_local_real = NULL;
241  double *phi_local_imaginary = NULL;
242  unsigned int *phi_local_row = NULL;
243  unsigned int *phi_local_col = NULL;
244  unsigned int phi_local_size = 0;
245  unsigned int phi_local_row_size = 0;
246  unsigned int phi_local_col_size = 0;
247 
249 
250  phi_local_real = m_pHamiltonian->m_vectValueRealBuffer.data();
251  phi_local_imaginary = m_pHamiltonian->m_vectValueImaginaryBuffer.data();
252  phi_local_row = m_pHamiltonian->m_vectRow.data();
253  phi_local_col = m_pHamiltonian->m_vectColumn.data();
254  phi_local_size = m_pHamiltonian->GetNoneZeroCount();
255  phi_local_row_size = m_pHamiltonian->m_vectRow.size();
256  phi_local_col_size = m_pHamiltonian->m_vectColumn.size();
257 #pragma offload_transfer target(mic:phi_tid) \
258  nocopy(phi_local_real[0:phi_local_size] : ALLOC) \
259  nocopy(phi_local_imaginary[0:phi_local_size] : ALLOC) \
260  nocopy(phi_local_row[0:phi_local_row_size] : ALLOC) \
261  nocopy(phi_local_col[0:phi_local_col_size] : ALLOC)
262 
263 #endif // USE_XEONPHI
264 
265  pVnow = new double[(unsigned int)m_SchroedingerMapInfo.fItemCount];
266  pVold = new double[(unsigned int)m_SchroedingerMapInfo.fItemCount];
267  Efold = 0.0;
268  Efnow = 0.0;
269 
270  pEV = new double[m_lpParam->nFindingEigenValueCount*(unsigned int)m_lpParam->fKPoints];
271  pWF = new double*[m_lpParam->nFindingEigenValueCount];
272  for( i = 0 ; i < m_lpParam->nFindingEigenValueCount ; ++ i )
273  pWF[i] = new double[CMPIManager::GetCurrentLoadBalanceCount(m_Lanczos.GetLBIndex())];
274 
275  //VA.SetSize(m_PossionMapInfo.fItemCount);
276  //WF.SetSize(m_SchroedingerMapInfo.fItemCount);
277 
278  CTimeMeasurement::TotalMeasurementStart();
279 
280  double impurity_position[3];
281  int tempnCell;
282  tempnCell = floor(m_lpParam->fShapeLength[0][0] / m_lpParam->fUnitcellLength[0]);
283  impurity_position[0] = (double)tempnCell / 2.0 * m_lpParam->fUnitcellLength[0];
284  tempnCell = floor(m_lpParam->fShapeLength[0][1] / m_lpParam->fUnitcellLength[1]);
285  impurity_position[1] = (double)tempnCell / 2.0 * m_lpParam->fUnitcellLength[1];
286  tempnCell = floor(m_lpParam->fShapeLength[0][2] / m_lpParam->fUnitcellLength[2]);
287  impurity_position[2] = (double)tempnCell / 2.0 * m_lpParam->fUnitcellLength[2];
288 
289  SetInitialPotential(pVnow, impurity_position, true);
290  charge.SetSize((unsigned int)m_SchroedingerMapInfo.fItemCount);
291  poissonRHS.SetSize((unsigned int)m_PossionMapInfo.fItemCount);
292  poissonSolution.SetSize((unsigned int)m_PossionMapInfo.fItemCount);
293 
294  int nIteration = 0;
295 
296  while(1)
297  {
298  nIteration++;
299 
300  SolveSchroedinger(pVnow, pEV, pWF);
301  Efnow = pEV[0];
302  GetChargeProfile(impurity_position, pWF, &charge);
303 
304  for( i = 0 ; i < (unsigned int)m_SchroedingerMapInfo.fItemCount ; ++ i )
305  poissonRHS.SetAt(m_pMap[i], charge.GetAt(i).GetRealNumber() * RHSscaler, 0.0);
306 
307  if(m_lpParam->nContactNumber > 0)
308  poissonRHS.PlusVector(&m_BiasVector);
309 
310  SolvePoisson(&poissonRHS, &poissonSolution);
311 
312  spMSE = fabs(Efnow-Efold);
313 
314  Efold = Efnow;
315 
316  for( i = 0 ; i < (unsigned int)m_SchroedingerMapInfo.fItemCount ; ++ i )
317  {
318  pVold[i] = pVnow[i];
319  pVnow[i] = poissonSolution.GetAt(m_pMap[i]).GetRealNumber();
320  }
321 
322  if(spMSE < 1e-5 || nIteration > 500)
323  {
325  {
326  if(spMSE < 1e-5)
327  sprintf(szMsg, "-Met convergence criteria at iteration %d with MSE = %.6e. Dumping solution..\n", nIteration, spMSE);
328  else if(nIteration > 500)
329  sprintf(szMsg, "-No convergence within 500 iterations. Dumping solution..\n");
330  CUtility::ShowMsg(szMsg);
331  }
332 
333  for( i = 0 ; i < (unsigned int)m_SchroedingerMapInfo.fItemCount ; ++ i )
334  pVnow[i] = 0.5*pVnow[i] + 0.5*pVold[i];
335 
337  break;
338  }
339  else
340  {
342  {
343  sprintf(szMsg, "-MSE = %.6e at Iteration %d\n", spMSE, nIteration);
344  CUtility::ShowMsg(szMsg);
345  }
346 
347  for( i = 0 ; i < (unsigned int)m_SchroedingerMapInfo.fItemCount ; ++ i )
348  pVnow[i] = 0.5*pVnow[i] + 0.5*pVold[i];
349  }
350  }
351 
353 
356 
357 #ifdef USE_XEONPHI
358 
359 #pragma offload_transfer target(mic:phi_tid) \
360  nocopy(phi_local_real : FREE) \
361  nocopy(phi_local_imaginary : FREE) \
362  nocopy(phi_local_row : FREE) \
363  nocopy(phi_local_col : FREE)
364 
365 #endif // USE_XEONPHI
366 
367  delete [] pEV;
368  for( i = 0 ; i < m_lpParam->nFindingEigenValueCount ; ++ i )
369  delete [] pWF[i];
370  delete [] pWF;
371 
372  return true;
373 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
void SolveSchroedinger(double *pVA, double *pEval, double **pWF)
Definition: SPLoop.cpp:539
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
static void FinalizeMatrixBuffer()
Release all temporary buffer.
NEIGHBOR_MAP_INFO m_PossionMapInfo
Definition: SPLoop.h:61
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
void SolvePoisson(CMatrixOperation::CVector *pRHS, CMatrixOperation::CVector *pSolution)
Definition: SPLoop.cpp:511
double * m_pMap
Definition: SPLoop.h:59
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
CMatrixOperation::CVector m_BiasVector
Definition: SPLoop.h:63
CComplex GetAt(unsigned int nIndex)
Get element value from specific index.
MPI Mangement class.
Definition: MPIManager.h:19
void PlusVector(CVector *vector)
Do plus operation between vectors.
void SetInitialPotential(double *potential, double *impurity_position, bool bUseSplitVector)
Definition: SPLoop.cpp:445
static void TotalMeasurementEnd()
Measurement end for total taken time.
CLanczosMethod m_Lanczos
Definition: SPLoop.h:65
#define NM
Definition: Global.h:81
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
static void SetPhiTid(int *tid)
Definition: MPIManager.cpp:894
int nFindingEigenValueCount
Eigen value count for want to find.
Time measurement class.
This class for describing vector for Lanczos method.
void DumpSolution(double *pVsol, double *pQsol, NEIGHBOR_MAP_INFO *nbrmap)
Definition: SPLoop.cpp:375
CMatrixOperation::CCSR * m_pHamiltonian
Definition: SPLoop.h:53
CGeometricShape m_PossionGeometric
Geometric construction for Poisson.
Definition: SPLoop.h:56
double * GetUnitCellLength()
#define Qo
Definition: Global.h:79
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.
uint_vector_t m_vectColumn
A member variable for saving column information.
static void ShowLanczosWorkingTime()
Showing operation time into screen.
int phi_tid
Definition: TBMS_Solver.cpp:30
uint_vector_t m_vectRow
A member variable for saving row information.
void GetChargeProfile(double *impurity_position, double **WF, CMatrixOperation::CVector *charge)
Definition: SPLoop.cpp:425
double GetRealNumber() const
Get real part.
Definition: Complex.h:24

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::Fermi_Dirac ( CMatrixOperation::CVector pWF,
CLanczosMethod::LPEIGENVALUE_RESULT  lpResult 
)
private

Definition at line 534 of file SPLoop.cpp.

References CLanczosMethod::EIGENVALUE_RESULT::pWaveFunctions.

535 {
536  *pWF = lpResult->pWaveFunctions[0];
537 }
CMatrixOperation::CVector * pWaveFunctions
Definition: LanczosMethod.h:38
void CSPLoop::Finalize ( )

Definition at line 688 of file SPLoop.cpp.

References CMatrixOperation::CVector::Finalize(), FREE_MEM, CMatrixOperation::FreeCSR(), CGeometricShape::FreeMapInfo(), m_BiasVector, m_pFDMPoisson, m_pHamiltonian, m_pMap, m_PossionMapInfo, and m_SchroedingerMapInfo.

Referenced by SPLoopMain().

689 {
692 
693  FREE_MEM(m_pMap);
694 
698  //Initialize();
699 }
static void FreeCSR(CMatrixOperation::CCSR *pCSR)
Deallocating CSR memory.
NEIGHBOR_MAP_INFO m_PossionMapInfo
Definition: SPLoop.h:61
double * m_pMap
Definition: SPLoop.h:59
CMatrixOperation::CVector m_BiasVector
Definition: SPLoop.h:63
CMatrixOperation::CCSR * m_pFDMPoisson
Definition: SPLoop.h:54
static void FreeMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo)
Release mapinfo data.
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
CMatrixOperation::CCSR * m_pHamiltonian
Definition: SPLoop.h:53
#define FREE_MEM(pointer)
Macro for memory allocation and assign null value.
Definition: Global.h:19
void Finalize()
Free allocated memory for vector elements.

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::GetChargeProfile ( double *  impurity_position,
double **  WF,
CMatrixOperation::CVector charge 
)
private

Definition at line 425 of file SPLoop.cpp.

References NEIGHBOR_MAP_INFO::fItemCount, m_SchroedingerMapInfo, NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, NEIGHBOR_MAP_INFO::pfZ_Coordination, and CMatrixOperation::CVector::SetAt().

Referenced by executeSPLoop().

426 {
427  double myx, myy, myz, distance;
428 
429  for (unsigned int i = 0; i < (unsigned int)m_SchroedingerMapInfo.fItemCount; i++)
430  {
431  myx = (m_SchroedingerMapInfo.pfX_Coordination[i] - impurity_position[0]);
432  myy = (m_SchroedingerMapInfo.pfY_Coordination[i] - impurity_position[1]);
433  myz = (m_SchroedingerMapInfo.pfZ_Coordination[i] - impurity_position[2]);
434 
435  distance = sqrt(myx*myx + myy*myy + myz*myz);
436 
437  if (distance < 1.0e-5)
438  charge->SetAt(i, WF[0][i]-1.0, 0.0);
439  else
440  charge->SetAt(i, WF[0][i], 0.0);
441  }
442 
443 }
double * pfZ_Coordination
An array of Z coordination.
Definition: AtomMapInfo.h:24
double * pfX_Coordination
An array of X coordination.
Definition: AtomMapInfo.h:22
double * pfY_Coordination
An array of Y coordination.
Definition: AtomMapInfo.h:23
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
void SetAt(unsigned int nIndex, CComplex value)
Set element value in specific index, Call by value.

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::Initialize ( )
private

Definition at line 30 of file SPLoop.cpp.

References m_bMPI, m_fTotalSurfaceCount, m_lpParam, m_pFDMPoisson, m_pHamiltonian, and m_pMap.

Referenced by CSPLoop().

31 {
32  m_lpParam = NULL;
33  m_bMPI = true;
35  m_pHamiltonian = NULL;
36  m_pFDMPoisson = NULL;
37  m_pMap = NULL;
38 }
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
double * m_pMap
Definition: SPLoop.h:59
CMatrixOperation::CCSR * m_pFDMPoisson
Definition: SPLoop.h:54
CMatrixOperation::CCSR * m_pHamiltonian
Definition: SPLoop.h:53
double m_fTotalSurfaceCount
Definition: SPLoop.h:62
bool m_bMPI
Definition: SPLoop.h:57

Here is the caller graph for this function:

bool CSPLoop::IsSatisfyCriteria ( )
private

Definition at line 503 of file SPLoop.cpp.

504 {
505  bool bRtn = false;
506 
507  bRtn = true;
508  return bRtn;
509 }
bool CSPLoop::MapZBandCB ( )
private

Definition at line 112 of file SPLoop.cpp.

References NEIGHBOR_MAP_INFO::fItemCount, FREE_MEM, GENERAL_TOLERANCE, CMPIManager::IsRootRank(), CMatrixOperation::IsSame(), m_pMap, m_PossionMapInfo, m_SchroedingerMapInfo, NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, and NEIGHBOR_MAP_INFO::pfZ_Coordination.

Referenced by ConstructionGeometric().

113 {
114  unsigned int i, j;
115  unsigned int nMatchCase = 0;
116  bool *pChecked = (bool*)malloc(sizeof(bool)*(unsigned int)m_PossionMapInfo.fItemCount);
117  bool bRtn = false;
118 
119  memset(pChecked, false, sizeof(bool)*(unsigned int)m_PossionMapInfo.fItemCount);
120 
122  i = 0;
123 
124  for( i = 0 ; i < (unsigned int)m_SchroedingerMapInfo.fItemCount ; ++ i )
125  {
126  for( j = 0 ; j < (unsigned int)m_PossionMapInfo.fItemCount ; ++ j )
127  {
128  if( pChecked[j] )
129  continue;
130 
132  {
134  {
136  {
137  m_pMap[i] = j;
138  pChecked[j] = true;
139  nMatchCase++;
140  break;
141  }
142  }
143  }
144  }
145  }
146 
147  if( nMatchCase == (unsigned int)m_SchroedingerMapInfo.fItemCount )
148  bRtn = true;
149 
150  FREE_MEM(pChecked);
151 
152  return bRtn;
153 }
double * pfZ_Coordination
An array of Z coordination.
Definition: AtomMapInfo.h:24
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
#define GENERAL_TOLERANCE
General tolerance definition.
Definition: Global.h:47
NEIGHBOR_MAP_INFO m_PossionMapInfo
Definition: SPLoop.h:61
double * pfX_Coordination
An array of X coordination.
Definition: AtomMapInfo.h:22
double * m_pMap
Definition: SPLoop.h:59
double * pfY_Coordination
An array of Y coordination.
Definition: AtomMapInfo.h:23
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
static bool IsSame(double operand1, double operand2, double tol)
Compare two double variable.
#define FREE_MEM(pointer)
Macro for memory allocation and assign null value.
Definition: Global.h:19

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::Prepare ( )

Definition at line 684 of file SPLoop.cpp.

Referenced by SPLoopMain().

685 {
686 }

Here is the caller graph for this function:

void CSPLoop::SetInitialPotential ( double *  potential,
double *  impurity_position,
bool  bUseSplitVector 
)
private

Definition at line 445 of file SPLoop.cpp.

References NEIGHBOR_MAP_INFO::fItemCount, CMPIManager::IsRootRank(), m_SchroedingerMapInfo, NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, NEIGHBOR_MAP_INFO::pfZ_Coordination, and CUtility::ShowMsg().

Referenced by executeSPLoop().

446 {
447  double myx, myy, myz, distance;
448 
449  for (unsigned int i = 0; i < (unsigned int)m_SchroedingerMapInfo.fItemCount; i++)
450  {
451  myx = (m_SchroedingerMapInfo.pfX_Coordination[i] - impurity_position[0]);
452  myy = (m_SchroedingerMapInfo.pfY_Coordination[i] - impurity_position[1]);
453  myz = (m_SchroedingerMapInfo.pfZ_Coordination[i] - impurity_position[2]);
454 
455  distance = sqrt(myx*myx + myy*myy + myz*myz);
456 
457  if (distance < 1.0e-5)
458  potential[i] = -3.782;
459  else
460  potential[i] = 0.0;
461  }
462 
464  CUtility::ShowMsg("-Phospher potential plungged\n");
465 }
double * pfZ_Coordination
An array of Z coordination.
Definition: AtomMapInfo.h:24
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
double * pfX_Coordination
An array of X coordination.
Definition: AtomMapInfo.h:22
double * pfY_Coordination
An array of Y coordination.
Definition: AtomMapInfo.h:23
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::SetParam ( CCommandFileParser::LPINPUT_CMD_PARAM  lpParam)
inline

Definition at line 36 of file SPLoop.h.

References m_lpParam.

Referenced by SPLoopMain().

36 { m_lpParam = lpParam; };
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58

Here is the caller graph for this function:

void CSPLoop::SolvePoisson ( CMatrixOperation::CVector pRHS,
CMatrixOperation::CVector pSolution 
)
private

Definition at line 511 of file SPLoop.cpp.

References CMatrixOperation::CVector::GetNorm(), CMPIManager::IsRootRank(), m_bMPI, m_CG, m_lpParam, m_pFDMPoisson, and CUtility::ShowMsg().

Referenced by executeSPLoop().

512 {
513  ConjugateGradientMethod cg;
514 
515  double fErrorNorm, fNorm;
516 
517  cg.SetLBIndex(m_CG.GetLBIndex());
519  CUtility::ShowMsg("-Start conjugate gradient iteration\n\n");
520 
521  cg.DoCongugateGradientMethod(m_pFDMPoisson,pRHS,pSolution, m_lpParam,m_bMPI);
522 
524  CUtility::ShowMsg("\n-Finished conjugate gradient iteration\n\n");
525 
526  fErrorNorm = m_CG.TestCGSolution(m_pFDMPoisson, pSolution, pRHS);
527  fNorm = pRHS->GetNorm(m_bMPI);
528 
530  printf("-Error norm = %15.10e, Vector norm = %15.10e \n",fErrorNorm, fNorm);
531 }
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
CMatrixOperation::CCSR * m_pFDMPoisson
Definition: SPLoop.h:54
bool m_bMPI
Definition: SPLoop.h:57
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
double GetNorm(bool bMPI=false)
Getting norm of vector.
ConjugateGradientMethod m_CG
Definition: SPLoop.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

void CSPLoop::SolveSchroedinger ( double *  pVA,
double *  pEval,
double **  pWF 
)
private

< Calculating k points

< Calculating phase

< Launching lanczos method

< Release memery for lanczos result

< Calculating phase

Definition at line 539 of file SPLoop.cpp.

References CCommandFileParser::INPUT_CMD_PARAM::bCalculateEigenVectors, CCommandFileParser::INPUT_CMD_PARAM::bCalculateWaveFunction, CCommandFileParser::INPUT_CMD_PARAM::bDoSelectiveReorthogonalization, CMPIManager::BroadcastDouble(), CMatrixOperation::CCSR::DiagonalOperation(), CLanczosMethod::DoLanczosMethod(), CCommandFileParser::INPUT_CMD_PARAM::fConvergeceCriteria, CCommandFileParser::INPUT_CMD_PARAM::fevMax, CCommandFileParser::INPUT_CMD_PARAM::fevMin, NEIGHBOR_MAP_INFO::fItemCount, CCommandFileParser::INPUT_CMD_PARAM::fKPoints, CUtility::GetKValues(), CMatrixOperation::CCSR::GetNoneZeroCount(), CMatrixOperation::CVector::GetSize(), CMPIManager::IsDeflationRoot(), CMPIManager::IsMultiLevelMPI(), CMPIManager::IsRootRank(), CCommandFileParser::INPUT_CMD_PARAM::load_in_MIC, m_Lanczos, m_lpParam, m_pHamiltonian, m_SchroedingerGeometric, m_SchroedingerMapInfo, CMatrixOperation::CCSR::m_vectColumn, CMatrixOperation::CCSR::m_vectRow, CMatrixOperation::CCSR::m_vectValueImaginaryBuffer, CMatrixOperation::CVector::m_vectValueRealBuffer, CMatrixOperation::CCSR::m_vectValueRealBuffer, CLanczosMethod::MergeDegeneratedEigenvalues(), CMatrixOperation::CCSR::MINUS, CCommandFileParser::INPUT_CMD_PARAM::nBandSize, CCommandFileParser::INPUT_CMD_PARAM::nCheckEigenvalueInterval, CLanczosMethod::EIGENVALUE_RESULT::nEigenValueCount, CCommandFileParser::INPUT_CMD_PARAM::nFindingDegeneratedEVCount, CCommandFileParser::INPUT_CMD_PARAM::nFindingEigenValueCount, CCommandFileParser::INPUT_CMD_PARAM::nLanczosIterationCount, CLanczosMethod::EIGENVALUE_RESULT::pEigenValues, CMatrixOperation::CCSR::PLUS, CLanczosMethod::EIGENVALUE_RESULT::pWaveFunctions, CLanczosMethod::RecalcuWaveFunction(), CGeometricShape::RefillPeriodicBinding(), CLanczosMethod::ReleaseResult(), CLanczosMethod::ShowLanczosResult(), CUtility::ShowMsg(), and CLanczosMethod::SortSolution().

Referenced by executeSPLoop().

540 {
541  CMatrixOperation::CCSR *plocalH = NULL;
542  CMatrixOperation::CCSR *plocalHm1 = NULL;
543  CMatrixOperation::CCSR *plocalHp1 = NULL;
544  double *pKValue[3] = {NULL, NULL, NULL};
545  unsigned int i, j;
546  char szMsg[1024];
547  CLanczosMethod::LPEIGENVALUE_RESULT lpResult = NULL;
548  int NumK = 1;
549  int nSolIndex = 0;
550  int nLoopCount = 0;
551 
552 #ifdef USE_XEONPHI
553 
554  double *phi_local_real = NULL;
555  double *phi_local_imaginary = NULL;
556  unsigned int *phi_local_row = NULL;
557  unsigned int *phi_local_col = NULL;
558  unsigned int phi_local_size = 0;
559  unsigned int phi_local_row_size = 0;
560  unsigned int phi_local_col_size = 0;
561 
562  phi_local_real = m_pHamiltonian->m_vectValueRealBuffer.data();
563  phi_local_imaginary = m_pHamiltonian->m_vectValueImaginaryBuffer.data();
564  phi_local_row = m_pHamiltonian->m_vectRow.data();
565  phi_local_col = m_pHamiltonian->m_vectColumn.data();
566  phi_local_size = m_pHamiltonian->GetNoneZeroCount();
567  phi_local_row_size = m_pHamiltonian->m_vectRow.size();
568  phi_local_col_size = m_pHamiltonian->m_vectColumn.size();
569 
570 #endif
571 
573 
574  CUtility::GetKValues(m_lpParam, pKValue);
575  for (i = 0; i < (unsigned int)m_lpParam->fKPoints ; i++)
576  {
577  double fKValue[3] = { 0., 0., 0. };
578 
579  fKValue[0] = pKValue[0][i]; fKValue[1] = pKValue[1][i]; fKValue[2] = pKValue[2][i];
580 
582  {
583  sprintf(szMsg, "-Start Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n", fKValue[0], fKValue[1], fKValue[2]);
584  CUtility::ShowMsg(szMsg);
585  }
586 
588  continue;
589 
590 
591 #ifdef USE_XEONPHI
592 
593 #pragma offload_transfer target(mic:phi_tid) \
594  in(phi_local_real[0:phi_local_size] : REUSE) \
595  in(phi_local_imaginary[0:phi_local_size] : REUSE) \
596  in(phi_local_row[0:phi_local_row_size] : REUSE) \
597  in(phi_local_col[0:phi_local_col_size] : REUSE)
598 
599 #endif
605  m_lpParam->fevMin,
606  m_lpParam->fevMax,
612  plocalH, // ADDED
613  plocalHm1, // ADDED
614  plocalHp1);// ADDED
615 
617  {
619  CUtility::ShowMsg("-Calculating degenerated eigenvalues\n");
622  m_Lanczos.RecalcuWaveFunction(lpResult);
623  }
624 
626  m_Lanczos.SortSolution(lpResult);
627 
629 
631  {
632  sprintf(szMsg, "\n-Finished Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n\n", fKValue[0], fKValue[1], fKValue[2]);
633  CUtility::ShowMsg(szMsg);
634  }
635  else
636  lpResult->pEigenValues = (double*)malloc(sizeof(double)*lpResult->nEigenValueCount);
637 
639 
640 #ifdef _WIN32
641  nLoopCount = min((int)m_lpParam->nFindingEigenValueCount, (int)lpResult->nEigenValueCount);
642 #else
643  nLoopCount = std::min((int)m_lpParam->nFindingEigenValueCount, (int)lpResult->nEigenValueCount);
644 #endif
645 
646  for( j = 0 ; j < nLoopCount ; ++ j )
647  {
648  memcpy(pWF[nSolIndex], lpResult->pWaveFunctions[j].m_vectValueRealBuffer.data(), lpResult->pWaveFunctions[j].GetSize()*sizeof(double));
649  pEval[nSolIndex++] = lpResult->pEigenValues[j];
650  //pEval[nSolIndex++] = 0.1;
651  }
652 
653  CLanczosMethod::ReleaseResult(lpResult, true);
654 
655  //CHamiltonianBuilder::ResetPeriodicBinding(m_pHamiltonian, &m_SchroedingerMapInfo); ///< Reset hamlitonian before calculating phase
657  continue;
658  }
659 
661 
662 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
LPEIGENVALUE_RESULT DoLanczosMethod(CMatrixOperation::CCSR *pAMatrix, unsigned int nIterationCount, unsigned int nEigenValueCheckInterval, unsigned int nEigenValueCount, double fEigenvalueMin, double fEignevalueMax, double fConvergenceTolerance, bool bReorthogonalization, bool bCalcuEigVector, bool bWaveFunction, double load_in_MIC, CMatrixOperation::CCSR *pmylocalblock=NULL, CMatrixOperation::CCSR *leftlocalblock=NULL, CMatrixOperation::CCSR *rightlocalblock=NULL)
Doing lanczos method.
unsigned int GetSize()
Return Vector elements size.
static void GetKValues(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3])
Calculate K value with K points.
Definition: Utility.cpp:445
static void ShowLanczosResult(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalculateEigenVectors, bool bCalculateWaveFunction, double *pKValue, int nRepeatCount)
Showing calculating result into screen.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
CCommandFileParser::LPINPUT_CMD_PARAM m_lpParam
Definition: SPLoop.h:58
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
int nLanczosIterationCount
A counts of lanczos interation.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
double fevMax
Eigen value maximun value boundary.
bool DiagonalOperation(CVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector, int nBandSize)
To diagonal element do operation.
CLanczosMethod m_Lanczos
Definition: SPLoop.h:65
int nCheckEigenvalueInterval
A interval for checking T matrix eigenvlaue.
CGeometricShape m_SchroedingerGeometric
Geometric construction for Schroedinger.
Definition: SPLoop.h:55
double fConvergeceCriteria
Eigen value convergence criteria.
unsigned int nBandSize
Band basis size.
static void ReleaseResult(LPEIGENVALUE_RESULT lpResult, bool bReleaseStruct)
Release memory for lanczos method result.
static bool IsDeflationRoot()
Checking is root rank of Lanczos computation.
Definition: MPIManager.h:69
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
NEIGHBOR_MAP_INFO m_SchroedingerMapInfo
Definition: SPLoop.h:60
unsigned int nFindingDegeneratedEVCount
Added by jhkang>
int nFindingEigenValueCount
Eigen value count for want to find.
bool bCalculateWaveFunction
Option for doing calculating wave function or not.
static bool IsMultiLevelMPI()
Get MPI_Comm.
Definition: MPIManager.h:65
void RecalcuWaveFunction(CLanczosMethod::LPEIGENVALUE_RESULT lpResult)
Recalculating wavefunction after merging degenerated eigenvalues.
void MergeDegeneratedEigenvalues(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, unsigned int nFindingDegeneratedEVCount, CMatrixOperation::CCSR *pA, CMatrixOperation::CCSR *pLocalBlock, CMatrixOperation::CCSR *pLeftBlock, CMatrixOperation::CCSR *pRightBlock)
Merging eigenvalue into mater group.
double fevMin
Eigen value minimun value boundary.
bool RefillPeriodicBinding(CMatrixOperation::CCSR *pResult, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, unsigned int nRepeatIndex, double fKValue[3], unsigned int nBandSize, bool bRecover)
Applying phase to Hamiltonian.
bool bCalculateEigenVectors
Option for doing calculating eigen vectors or not.
CMatrixOperation::CVector * pWaveFunctions
Definition: LanczosMethod.h:38
void SortSolution(LPEIGENVALUE_RESULT lpResult)
Sorting computing eigenvalue.
Structure for engienvalue computing.
Definition: LanczosMethod.h:28
CMatrixOperation::CCSR * m_pHamiltonian
Definition: SPLoop.h:53
Data and operation representation of CSR(Compressed Sparse Row)
static void ShowMsg(char *pszBuffer)
Show message.
Definition: Utility.cpp:34
uint_vector_t m_vectColumn
A member variable for saving column information.
static void BroadcastDouble(double *pValue, unsigned int nSize, int nRootRank=0, MPI_Comm comm=MPI_COMM_NULL)
Broadcst boolean value.
Definition: MPIManager.cpp:486
bool bDoSelectiveReorthogonalization
Option for doing selective reorthogonalization or not.
uint_vector_t m_vectRow
A member variable for saving row information.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

CMatrixOperation::CVector CSPLoop::m_BiasVector
private

Definition at line 63 of file SPLoop.h.

Referenced by ConstructionGeometric(), executeSPLoop(), and Finalize().

bool CSPLoop::m_bMPI
private

Definition at line 57 of file SPLoop.h.

Referenced by BuildHamiltonian(), ConstructionGeometric(), CSPLoop(), Initialize(), and SolvePoisson().

ConjugateGradientMethod CSPLoop::m_CG
private

Definition at line 64 of file SPLoop.h.

Referenced by BuildHamiltonian(), and SolvePoisson().

double CSPLoop::m_fTotalSurfaceCount
private

Definition at line 62 of file SPLoop.h.

Referenced by ConstructionGeometric(), and Initialize().

CLanczosMethod CSPLoop::m_Lanczos
private

Definition at line 65 of file SPLoop.h.

Referenced by BuildHamiltonian(), executeSPLoop(), and SolveSchroedinger().

CMatrixOperation::CCSR* CSPLoop::m_pFDMPoisson
private

Definition at line 54 of file SPLoop.h.

Referenced by BuildHamiltonian(), Finalize(), Initialize(), and SolvePoisson().

CMatrixOperation::CCSR* CSPLoop::m_pHamiltonian
private

Definition at line 53 of file SPLoop.h.

Referenced by BuildHamiltonian(), executeSPLoop(), Finalize(), Initialize(), and SolveSchroedinger().

double* CSPLoop::m_pMap
private

Definition at line 59 of file SPLoop.h.

Referenced by ConstructionGeometric(), executeSPLoop(), Finalize(), Initialize(), and MapZBandCB().

CGeometricShape CSPLoop::m_PossionGeometric
private

Geometric construction for Poisson.

Definition at line 56 of file SPLoop.h.

Referenced by BuildHamiltonian(), ConstructionGeometric(), and executeSPLoop().

NEIGHBOR_MAP_INFO CSPLoop::m_PossionMapInfo
private

Definition at line 61 of file SPLoop.h.

Referenced by BuildHamiltonian(), ConstructionGeometric(), executeSPLoop(), Finalize(), and MapZBandCB().

CGeometricShape CSPLoop::m_SchroedingerGeometric
private

Geometric construction for Schroedinger.

Definition at line 55 of file SPLoop.h.

Referenced by BuildHamiltonian(), ConstructionGeometric(), and SolveSchroedinger().


The documentation for this class was generated from the following files: