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

This class for launching calculation module. More...

#include "TBMS_Solver.h"

Collaboration diagram for CTBMS_Solver:
Collaboration graph

Public Member Functions

 CTBMS_Solver ()
 
 ~CTBMS_Solver ()
 

Static Public Member Functions

static unsigned int Launching_TBMS_Solver (char *pszInputCommnadFileName, bool bMPI, bool bShowMsg, bool bRemovePrevResult=true)
 Launching Geomentric construction and Lancsoz method. More...
 

Static Private Member Functions

static void getCurrentTime (char *pszBuffer)
 Get Current time from system. More...
 
static void FinalEvn (CMatrixOperation::CCSR *lpResult, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3], NEIGHBOR_MAP_INFO *lpMapInfo, CGeometricShape *pGeometricShape, bool bMPI)
 Finalization of enviroment and variables. More...
 
static CMatrixOperation::CCSRAllocateCSR (unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, CGeometricShape *pGeometricShape, bool bMPI, int &nLBIndex)
 Allocating CSR memory sapce. More...
 
static void ApplyPhPotential (double *impurity_position, CMatrixOperation::CCSR *matrix, NEIGHBOR_MAP_INFO mapInfo, bool bUseSplitVector, int nBandSize)
 Applying impurity potential. More...
 

Detailed Description

This class for launching calculation module.

Date
10/Jan/2015

Definition at line 18 of file TBMS_Solver.h.

Constructor & Destructor Documentation

CTBMS_Solver::CTBMS_Solver ( )
CTBMS_Solver::~CTBMS_Solver ( )

Member Function Documentation

CMatrixOperation::CCSR * CTBMS_Solver::AllocateCSR ( unsigned int &  nRtn,
NEIGHBOR_MAP_INFO lpMapInfo,
CCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
CGeometricShape pGeometricShape,
bool  bMPI,
int &  nLBIndex 
)
staticprivate

Allocating CSR memory sapce.

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 68 of file TBMS_Solver.cpp.

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

Referenced by Launching_TBMS_Solver().

69 {
70  unsigned int nRowCount, nColumnCount;
71  CMatrixOperation::CCSR *pResult = NULL;
72 
73  pResult = new CMatrixOperation::CCSR();
74  if (NULL == pResult)
75  throw ERROR_MALLOC;
76 
77  nRowCount = (unsigned int)lpMapInfo->fItemCount * lpParam->nBandSize;
78  nColumnCount = (unsigned int)lpMapInfo->fItemCount * lpParam->nBandSize;
79 
80  if (bMPI)
81  {
82  nColumnCount = (unsigned int)pGeometricShape->GetTotalAtomCount() * lpParam->nBandSize;
83  CMPIManager::LoadBlancing(nRowCount);
85  }
86 
87  lpParam->nMatrixDemension = nColumnCount;
88 
89  pResult->SetRowCount(nRowCount);
90  pResult->SetColumnCount(nColumnCount);
91  pResult->BuildDataBuffer();
92  pResult->SetFirstRowIndex(pGeometricShape->GetAtomStartID()*lpParam->nBandSize);
93 
94  return pResult;
95 }
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.
unsigned int nBandSize
Band basis size.
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 CTBMS_Solver::ApplyPhPotential ( double *  impurity_position,
CMatrixOperation::CCSR matrix,
NEIGHBOR_MAP_INFO  mapInfo,
bool  bUseSplitVector,
int  nBandSize 
)
staticprivate

Applying impurity potential.

Parameters
impurity_positionImpurity position with double buffer
matrixTarget matrix
mapInfoAtom map information
nBandSizeBand size
bUseSplitVectorOperation in MPI environment or not

Definition at line 394 of file TBMS_Solver.cpp.

References CMatrixOperation::CCSR::DiagonalOperation(), NEIGHBOR_MAP_INFO::fItemCount, CMPIManager::IsRootRank(), NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, NEIGHBOR_MAP_INFO::pfZ_Coordination, CMatrixOperation::CCSR::PLUS, CMatrixOperation::CVector::SetAt(), CComplex::SetRealNumber(), CMatrixOperation::CVector::SetSize(), and CUtility::ShowMsg().

395 {
396  CMatrixOperation::CVector potential;
397  CComplex curval;
398  potential.SetSize((unsigned int)mapInfo.fItemCount);
399  double inveps = 1.0 / 11.9;
400  double esqr = 1.4399766;
401  double myx, myy, myz, distance;
402 
403  for (unsigned int i = 0; i < (unsigned int)mapInfo.fItemCount; i++)
404  {
405  myx = (mapInfo.pfX_Coordination[i] - impurity_position[0]);
406  myy = (mapInfo.pfY_Coordination[i] - impurity_position[1]);
407  myz = (mapInfo.pfZ_Coordination[i] - impurity_position[2]);
408 
409  distance = sqrt(myx*myx + myy*myy + myz*myz);
410 
411  if (distance < 1.0e-5)
412  curval.SetRealNumber(-3.782);
413  else
414  curval.SetRealNumber(-inveps*esqr / distance);
415  potential.SetAt(i, curval);
416  }
417 
418  matrix->DiagonalOperation(&potential, CMatrixOperation::CCSR::PLUS, bUseSplitVector, nBandSize);
419 
421  CUtility::ShowMsg("-Phospher potential plungged\n");
422 }
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
void SetRealNumber(double fRealNumber)
Set real part.
Definition: Complex.h:29
bool DiagonalOperation(CVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector, int nBandSize)
To diagonal element do operation.
double * pfY_Coordination
An array of Y coordination.
Definition: AtomMapInfo.h:23
double fItemCount
Item count at atom map.
Definition: AtomMapInfo.h:16
This class for describing vector for Lanczos method.
This class for complex operation and saving value.
Definition: Complex.h:16
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.
void SetSize(unsigned int nSize)
Set Vector elements size.

Here is the call graph for this function:

void CTBMS_Solver::FinalEvn ( CMatrixOperation::CCSR lpResult,
CCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
double *  pKValue[3],
NEIGHBOR_MAP_INFO lpMapInfo,
CGeometricShape pGeometricShape,
bool  bMPI 
)
staticprivate

Finalization of enviroment and variables.

Parameters
lpResultCSR class that include Hamiltonian:
lpParamStrcuture that include options parameter for program launching
pKValueK values
lpMapInfoStructure that include atom map
pGeometricShapeClass that include shape information
bMPIRunning with MPI enviroment or not

Definition at line 42 of file TBMS_Solver.cpp.

References CMPIManager::FinalizeManager(), FREE_MEM, CMatrixOperation::FreeCSR(), and CGeometricShape::FreeMapInfo().

Referenced by Launching_TBMS_Solver().

43 {
44  int i;
45 
46  if (NULL != lpResult)
47  CMatrixOperation::FreeCSR(lpResult);
48 
50  FREE_MEM(lpParam);
51  for (i = 0; i < 3; ++i)
52  FREE_MEM(pKValue[i]);
53 
54  if (bMPI)
55  {
57  MPI_Finalize();
58  }
59 }
static void FreeCSR(CMatrixOperation::CCSR *pCSR)
Deallocating CSR memory.
static void FreeMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo)
Release mapinfo data.
static void FinalizeManager()
Get Root rank.
Definition: MPIManager.cpp:617
#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:

static void CTBMS_Solver::getCurrentTime ( char *  pszBuffer)
staticprivate

Get Current time from system.

unsigned int CTBMS_Solver::Launching_TBMS_Solver ( char *  pszInputCommnadFileName,
bool  bMPI,
bool  bShowMsg,
bool  bRemovePrevResult = true 
)
static

Launching Geomentric construction and Lancsoz method.

Parameters
pszInputCommnadFileNameInput file that include program parameters
bMPIRunning with MPI enviroment or not
bShowMsgShowing message on console or not
bRemovePrevResultRemove previous calculating results or not

< Parsing command file

< Initialization of MPI environment

< Remove output directory first

< Setting shape parameters

< Setting unitcell parameters

< Arranging unitcell

< Numbering unitcell in periodic bonding layer

< Exchanging front and back side layer information between node

< Numbering unitcell in periodic bonding layer for exchanging layer

< Find Neighbor of each atom

< Make mapinfo runtime strcuture and writting into file

< Creating CSR class obeject

< Building Hamiltonian matrix

< Calculating k points

< Calculating phase

< Launching lanczos method

< Release memery for lanczos result

Definition at line 103 of file TBMS_Solver.cpp.

References AllocateCSR(), CMPIManager::AllReduceDouble(), CCommandFileParser::INPUT_CMD_PARAM::bCalculateEigenVectors, CCommandFileParser::INPUT_CMD_PARAM::bCalculateWaveFunction, CCommandFileParser::INPUT_CMD_PARAM::bConsiderBoundaryCondition, CCommandFileParser::INPUT_CMD_PARAM::bDoSelectiveReorthogonalization, CCommandFileParser::INPUT_CMD_PARAM::bSaveHamiltonian, CHamiltonianBuilder::BuildHamiltonian(), CGeometricShape::BuildNeighborInformation(), CALCULATION_SUCCESS, CAN_NOT_ALLOC_RANK, CAN_NOT_FIND_COMMAND_FILE, CAN_NOT_LOAD_METERIAL_PARAM, CLanczosMethod::CheckingCalculationCondition(), CGeometricShape::ConstructMapInfo(), CUBIC, CLanczosMethod::DoLanczosMethod(), CUtility::DumpCSR(), CGeometricShape::ExchangeAtomInfoBetweenNode(), CCommandFileParser::INPUT_CMD_PARAM::fConvergeceCriteria, CCommandFileParser::INPUT_CMD_PARAM::fevMax, CCommandFileParser::INPUT_CMD_PARAM::fevMin, CGeometricShape::FillUnitcell(), FinalEvn(), CHamiltonianBuilder::FinalizeMatrixBuffer(), CGeometricShape::FinalShape(), CCommandFileParser::INPUT_CMD_PARAM::fKPoints, FREE_MEM, CCommandFileParser::INPUT_CMD_PARAM::fShapeLength, CCommandFileParser::INPUT_CMD_PARAM::fUnitcellLength, CGeometricShape::GetAtomStartID(), CMPIManager::GetCurrentRank(), CUtility::GetKValues(), CMatrixOperation::CCSR::GetNoneZeroCount(), CGeometricShape::GetSurfaceAtomList(), CMPIManager::GetTotalNodeCount(), CMPIManager::InitMPIEnv(), CMPIManager::IsDeflationRoot(), CMPIManager::IsMultiLevelMPI(), CMPIManager::IsRootRank(), CCommandFileParser::INPUT_CMD_PARAM::load_in_MIC, CGeometricShape::m_nAtomFirstLayer, CGeometricShape::m_nAtomLastLayer, CMatrixOperation::CCSR::m_vectColumn, CMatrixOperation::CCSR::m_vectRow, CMatrixOperation::CCSR::m_vectValueImaginaryBuffer, CMatrixOperation::CCSR::m_vectValueRealBuffer, CLanczosMethod::MergeDegeneratedEigenvalues(), CCommandFileParser::INPUT_CMD_PARAM::nBandSize, CCommandFileParser::INPUT_CMD_PARAM::nCheckEigenvalueInterval, CMatrixOperation::CCSR::nComponentsFirstUnitCell, CMatrixOperation::CCSR::nComponentsLastUnitCell, CCommandFileParser::INPUT_CMD_PARAM::nDirectionSingle, NEED_TO_ADJUST_MPI_CONFIG, CCommandFileParser::INPUT_CMD_PARAM::nFindingDegeneratedEVCount, CCommandFileParser::INPUT_CMD_PARAM::nFindingEigenValueCount, CCommandFileParser::INPUT_CMD_PARAM::nLanczosIterationCount, CCommandFileParser::ParsingInputCommand(), CGeometricShape::PeriodicUnitCellNumbering(), phi_tid, CLanczosMethod::RecalcuWaveFunction(), CGeometricShape::RefillPeriodicBinding(), CLanczosMethod::ReleaseResult(), CLanczosMethod::SaveLanczosResult(), CGeometricShape::SetAtomAndNeighborInformation(), CLanczosMethod::SetLBIndex(), CGeometricShape::SetShapeInformation(), CUtility::SetShow(), SHOW_SIMPLE_MSG, CLanczosMethod::ShowLanczosResult(), CLanczosMethod::ShowLanczosWorkingTime(), CUtility::ShowMsg(), CLanczosMethod::SortSolution(), CCommandFileParser::INPUT_CMD_PARAM::szStructureType, CTimeMeasurement::TotalMeasurementEnd(), and CTimeMeasurement::TotalMeasurementStart().

Referenced by main().

104 {
105 
106  CGeometricShape GeometricShape;
107  CMatrixOperation::CCSR *pHamiltonian = NULL;
108  CMatrixOperation::CCSR *plocalH = NULL;
109  CMatrixOperation::CCSR *plocalHm1 = NULL;
110  CMatrixOperation::CCSR *plocalHp1 = NULL;
112  NEIGHBOR_MAP_INFO mapInfo;
113  unsigned int nRtnCode = CALCULATION_SUCCESS;
114  unsigned int i, nRepeatCount = 1;
115  CLanczosMethod::LPEIGENVALUE_RESULT lpResult = NULL;
116  CLanczosMethod lanczos;
117  char szMsg[1024];
118  double *pKValue[3] = {NULL, NULL, NULL};
119  int nLBIndex = 0;
120 
121  if (bShowMsg)
122  CUtility::SetShow(true);
123 
124  lpParam = CCommandFileParser::ParsingInputCommand(pszInputCommnadFileName);
125  if (NULL == lpParam)
126  {
128  {
129  sprintf(szMsg, "Terminated program. '%s' file doesn't existed\n", pszInputCommnadFileName);
130  CUtility::ShowMsg(szMsg);
131  }
133  }
135  {
136  SHOW_SIMPLE_MSG("Adjusting input parameter first!\n");
138  }
139 
140  if( !CMPIManager::InitMPIEnv(bMPI, lpParam))
141  {
142  SHOW_SIMPLE_MSG("Adjusting MPI level and node count first!\n");
144  }
145 
147  {
148  if (bRemovePrevResult)
149 #ifdef _WIN32
150  system("rmdir /s /q result");
151 #else //WIN32
152  system("rm -rf result");
153 #endif //WIN32
154 
155 #pragma omp parallel
156  {
157  if(omp_get_num_threads() > 1)
158  {
159  if(omp_get_thread_num() == 0)
160  {
161  sprintf(szMsg, "-Run with MPI (%d cores) and OpenMP (%d threads)\n", CMPIManager::GetTotalNodeCount(), omp_get_num_threads());
162  CUtility::ShowMsg(szMsg);
163  }
164  }
165  else
166  {
167  sprintf(szMsg, "-Run with MPI only (%d cores)\n", CMPIManager::GetTotalNodeCount());
168  CUtility::ShowMsg(szMsg);
169  }
170  }
171 
172  sprintf(szMsg, "-Command file: %s\n-Direction: [%03d], Periodic condition [%d %d %d]\n", pszInputCommnadFileName, lpParam->nDirectionSingle, lpParam->bConsiderBoundaryCondition[0] ? 1 : 0, lpParam->bConsiderBoundaryCondition[1] ? 1 : 0, lpParam->bConsiderBoundaryCondition[2] ? 1 : 0);
173  CUtility::ShowMsg(szMsg);
174  CUtility::ShowMsg("-Start Building Geometric construction\n");
175  }
176 
177  GeometricShape.SetShapeInformation(lpParam);
179  {
180  SHOW_SIMPLE_MSG("Terminated program. Direction information doesn't existed.\n");
181  nRtnCode = CAN_NOT_ALLOC_RANK;
182  FREE_MEM(lpParam);
183  return nRtnCode;
184  }
185  if(!GeometricShape.FillUnitcell(lpParam))
186  {
187  SHOW_SIMPLE_MSG("Terminated program. Node counts should be smaller than assigend unitcell count with X axis.\n");
188  nRtnCode = CAN_NOT_ALLOC_RANK;
189  FREE_MEM(lpParam);
190  return nRtnCode;
191  }
192 
193  GeometricShape.PeriodicUnitCellNumbering();
194  if (bMPI)
195  {
196  GeometricShape.ExchangeAtomInfoBetweenNode();
197  GeometricShape.PeriodicUnitCellNumbering(true);
198  }
199  GeometricShape.BuildNeighborInformation();
200  GeometricShape.ConstructMapInfo(&mapInfo, lpParam);
201 
202  double fSurfaceCount = (double)GeometricShape.GetSurfaceAtomList()->size();
203  double fTotalSurfaceCount = CMPIManager::AllReduceDouble(fSurfaceCount);
204 
206  {
207  sprintf(szMsg, "-Surface atom counts: %d\n", (int)fTotalSurfaceCount);
208  CUtility::ShowMsg(szMsg);
209  }
210 
211  if (!strcmp(lpParam->szStructureType, CUBIC))
212  {
213  SHOW_SIMPLE_MSG("\n-Geometry construction completed!\n\n");
214 
215  GeometricShape.FinalShape();
216  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
217 
218  return nRtnCode;
219  }
220 
221  pHamiltonian = AllocateCSR(nRtnCode, &mapInfo, lpParam, &GeometricShape, bMPI, nLBIndex);
222  lanczos.SetLBIndex(nLBIndex);
223 
224 
225  SHOW_SIMPLE_MSG("-Building Hamiltonian Matrix\n");
226  if (!CHamiltonianBuilder::BuildHamiltonian(lpParam, &mapInfo, pHamiltonian, GeometricShape.GetAtomStartID()))
227  {
228  SHOW_SIMPLE_MSG("Terminated program. Can't load meterial param information.\n");
229  nRtnCode = CAN_NOT_LOAD_METERIAL_PARAM;
230  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
231  return nRtnCode;
232  }
233 
234  pHamiltonian->nComponentsFirstUnitCell = GeometricShape.m_nAtomFirstLayer*lpParam->nBandSize;
235  pHamiltonian->nComponentsLastUnitCell = GeometricShape.m_nAtomLastLayer*lpParam->nBandSize;
236 
237 
238  if( lpParam->bSaveHamiltonian )
239  {
240  SHOW_SIMPLE_MSG("-Save Hamiltonian matrix to file\n");
241  CUtility::DumpCSR(pHamiltonian, "Hamiltonian.dat", GeometricShape.GetAtomStartID());
242  }
243 
244 #ifndef DISABLE_MPI_ROUTINE
246 // FIXME test code
247 #ifndef _WIN32
248  char host_name[256];
249  gethostname(host_name, 256);
250  printf("-[Host:%s] (MPI:%03d) mapped to (MIC:%03d)\n", host_name, CMPIManager::GetCurrentRank(), phi_tid);
251 #endif //_WIN32
252 #else
253  phi_tid = 0;
254 #endif
255 
256 
257 #ifdef USE_XEONPHI
258 
259  double *local_real = NULL;
260  double *local_imaginary = NULL;
261  unsigned int *local_row = NULL;
262  unsigned int *local_col = NULL;
263  unsigned int local_size = 0;
264  unsigned int local_row_size = 0;
265  unsigned int local_col_size = 0;
266 
267  local_real = pHamiltonian->m_vectValueRealBuffer.data();
268  local_imaginary = pHamiltonian->m_vectValueImaginaryBuffer.data();
269  local_row = pHamiltonian->m_vectRow.data();
270  local_col = pHamiltonian->m_vectColumn.data();
271  local_size = pHamiltonian->GetNoneZeroCount();
272  local_row_size = pHamiltonian->m_vectRow.size();
273  local_col_size = pHamiltonian->m_vectColumn.size();
274 #pragma offload_transfer target(mic:phi_tid) \
275  nocopy(local_real[0:local_size] : ALLOC) \
276  nocopy(local_imaginary[0:local_size] : ALLOC) \
277  nocopy(local_row[0:local_row_size] : ALLOC) \
278  nocopy(local_col[0:local_col_size] : ALLOC)
279 
280 #endif // USE_XEONPHI
281 
282  double impurity_position[3];
283  int tempnCell;
284  tempnCell = floor(lpParam->fShapeLength[0][0] / lpParam->fUnitcellLength[0]);
285  impurity_position[0] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[0];
286  tempnCell = floor(lpParam->fShapeLength[0][1] / lpParam->fUnitcellLength[1]);
287  impurity_position[1] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[1];
288  tempnCell = floor(lpParam->fShapeLength[0][2] / lpParam->fUnitcellLength[2]);
289  impurity_position[2] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[2];
290  //ApplyPhPotential(impurity_position, pHamiltonian, mapInfo, true, lpParam->nBandSize);
291 
292 
293  CUtility::GetKValues(lpParam, pKValue);
294  for (i = 0; i < (unsigned int)lpParam->fKPoints ; i++)
295  {
296  double fKValue[3] = { 0., 0., 0. };
297 
298  fKValue[0] = pKValue[0][i]; fKValue[1] = pKValue[1][i]; fKValue[2] = pKValue[2][i];
300  {
301  sprintf(szMsg, "-Start Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n", fKValue[0], fKValue[1], fKValue[2]);
302  CUtility::ShowMsg(szMsg);
303  }
304 
305  if (false == GeometricShape.RefillPeriodicBinding(pHamiltonian, lpParam, &mapInfo, i, fKValue, lpParam->nBandSize, false))
306  continue;
307 
308 #ifdef USE_XEONPHI
309 
310 #pragma offload_transfer target(mic:phi_tid) \
311  in(local_real[0:local_size] : REUSE) \
312  in(local_imaginary[0:local_size] : REUSE) \
313  in(local_row[0:local_row_size] : REUSE) \
314  in(local_col[0:local_col_size] : REUSE)
315 
316 #endif // USE_XEONPHI
317 
320  lpResult = lanczos.DoLanczosMethod(pHamiltonian,
321  lpParam->nLanczosIterationCount,
322  lpParam->nCheckEigenvalueInterval,
323  lpParam->nFindingEigenValueCount,
324  lpParam->fevMin,
325  lpParam->fevMax,
326  lpParam->fConvergeceCriteria,
328  lpParam->bCalculateEigenVectors,
329  lpParam->bCalculateWaveFunction,
330  lpParam->load_in_MIC,
331  plocalH, // ADDED
332  plocalHm1, // ADDED
333  plocalHp1);// ADDED
334 
336  {
338  CUtility::ShowMsg("-Calculating degenerated eigenvalues\n");
339  lanczos.MergeDegeneratedEigenvalues(lpResult, lpParam->nFindingDegeneratedEVCount, pHamiltonian, plocalH, plocalHm1, plocalHp1);
340  if( lpParam->bCalculateWaveFunction )
341  lanczos.RecalcuWaveFunction(lpResult);
342  }
343 
345  lanczos.SortSolution(lpResult);
346 
348  CUtility::ShowMsg("\n-Save result into file\n");
349 
350  CLanczosMethod::SaveLanczosResult(lpResult, lpParam->bCalculateEigenVectors, lpParam->bCalculateWaveFunction, fKValue, i);
352 
353  CLanczosMethod::ShowLanczosResult(lpResult, lpParam->bCalculateEigenVectors, lpParam->bCalculateWaveFunction, fKValue, i);
355 
356 
358  {
359  sprintf(szMsg, "\n-Finished Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n\n", fKValue[0], fKValue[1], fKValue[2]);
360  CUtility::ShowMsg(szMsg);
361  }
362 
363  CLanczosMethod::ReleaseResult(lpResult, true);
364  //CHamiltonianBuilder::ResetPeriodicBinding(pHamiltonian, &mapInfo); ///< Reset hamlitonian before calculating phase
365  if (false == GeometricShape.RefillPeriodicBinding(pHamiltonian, lpParam, &mapInfo, i, fKValue, lpParam->nBandSize, true))
366  continue;
367  }
369 
370  SHOW_SIMPLE_MSG("- TBMS Solver completed!\n\n");
371 
372 #ifdef USE_XEONPHI
373 
374 #pragma offload_transfer target(mic:phi_tid) \
375  nocopy(local_real : FREE) \
376  nocopy(local_imaginary : FREE) \
377  nocopy(local_row : FREE) \
378  nocopy(local_col : FREE)
379 
380 #endif // USE_XEONPHI
381 
382  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
383 
384  return nRtnCode;
385 }
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
unsigned int m_nAtomFirstLayer
="">
static bool IsRootRank()
Get Total node count.
Definition: MPIManager.cpp:182
#define CAN_NOT_FIND_COMMAND_FILE
Return code at main loop, there is no command file for option.
Definition: Global.h:74
static CMatrixOperation::CCSR * AllocateCSR(unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, CGeometricShape *pGeometricShape, bool bMPI, int &nLBIndex)
Allocating CSR memory sapce.
Definition: TBMS_Solver.cpp:68
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.
static void FinalizeMatrixBuffer()
Release all temporary buffer.
int phi_tid
Definition: TBMS_Solver.cpp:30
unsigned int nComponentsLastUnitCell
Atom counts for interoperaton with next node.
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.
static double AllReduceDouble(double fNumber)
Do all reduce function with CKNComplex.
Definition: MPIManager.cpp:593
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
std::vector< CGeometricAtom * > * GetSurfaceAtomList()
double fShapeLength[NMAXDOMAIN][3]
Shap length x, y, z, direction.
int nLanczosIterationCount
A counts of lanczos interation.
bool bConsiderBoundaryCondition[3]
Considering bondary condition or not x, y, z direction.
static void TotalMeasurementStart()
Measurement start for total taken time.
bool FillUnitcell(CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set bondary condition of shape.
static void DumpCSR(CMatrixOperation::CCSR *pCSR, char *pszFileName, double fAtomIDStartIndex)
Definition: Utility.cpp:296
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
#define CALCULATION_SUCCESS
Return code at main loop, every steps completed.
Definition: Global.h:70
double fevMax
Eigen value maximun value boundary.
void BuildNeighborInformation()
Find neighbor of each atom.
static bool SetAtomAndNeighborInformation(CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set neighbor information to AtomFactory.
static void SaveLanczosResult(CLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalcuEigenvalue, bool bWaveFunction, double *pKValue, int nRepeatCount)
Saving Lanczos computation result into file.
static int GetTotalNodeCount()
Definition: MPIManager.h:42
bool ConstructMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo, CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Extract atom information from runtime objects.
static void TotalMeasurementEnd()
Measurement end for total taken time.
Structure for save input command file parsing result.
int nCheckEigenvalueInterval
A interval for checking T matrix eigenvlaue.
double GetAtomStartID()
Set total valid atom count in shape.
double fConvergeceCriteria
Eigen value convergence criteria.
unsigned int nBandSize
Band basis size.
#define CAN_NOT_ALLOC_RANK
Return code at main loop, there is fail assign unit cell to MPI ranks.
Definition: Global.h:71
static LPINPUT_CMD_PARAM ParsingInputCommand(char *pszInputCommnadFileName)
Parsing Commaind file.
static void ReleaseResult(LPEIGENVALUE_RESULT lpResult, bool bReleaseStruct)
Release memory for lanczos method result.
void SetShapeInformation(CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set shape information(Length, material, bondary condition and so on)
static bool IsDeflationRoot()
Checking is root rank of Lanczos computation.
Definition: MPIManager.h:69
static int GetCurrentRank()
Definition: MPIManager.h:40
void FinalShape()
Finalize Shape variable.
static bool BuildHamiltonian(CCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, CMatrixOperation::CCSR *pCSRResult, unsigned int fAtomStartID)
Build Hamiltonian matrxi from mapinfo data.
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.
void ExchangeAtomInfoBetweenNode()
Get start index of atom in shape, using in MPI running enviroment.
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.
static void FinalEvn(CMatrixOperation::CCSR *lpResult, CCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3], NEIGHBOR_MAP_INFO *lpMapInfo, CGeometricShape *pGeometricShape, bool bMPI)
Finalization of enviroment and variables.
Definition: TBMS_Solver.cpp:42
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.
double fUnitcellLength[3]
Unitcell length x, y, z direction.
static bool CheckingCalculationCondition(bool bCalcuEigenValue, bool bCalcuWaveFunction, unsigned int nDeflationGroup)
Checking pre conditions for Lanczos method operation.
#define NEED_TO_ADJUST_MPI_CONFIG
Return code at main loop, there is need to adjusting mpi level and mpi node count.
Definition: Global.h:75
void SortSolution(LPEIGENVALUE_RESULT lpResult)
Sorting computing eigenvalue.
unsigned int m_nAtomLastLayer
Last layer information for sending to next node.
Structure for engienvalue computing.
Definition: LanczosMethod.h:28
unsigned int nComponentsFirstUnitCell
Atom counts for interoperaton with previous node.
static void SetShow(bool bShow)
Definition: Utility.h:29
char szStructureType[1024]
Structure type.
Data and operation representation of CSR(Compressed Sparse Row)
void SetLBIndex(int nLBIndex)
Definition: LanczosMethod.h:55
Class for Geometric shape.
#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
static bool InitMPIEnv(bool &bMPI, CCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Getting Lanczos group index.
Definition: MPIManager.cpp:875
This class for doing Lanczos method.
Definition: LanczosMethod.h:18
void PeriodicUnitCellNumbering(bool bXAxis=false)
Numbering to periodic unitcell.
uint_vector_t m_vectColumn
A member variable for saving column information.
static void ShowLanczosWorkingTime()
Showing operation time into screen.
#define FREE_MEM(pointer)
Macro for memory allocation and assign null value.
Definition: Global.h:19
bool bDoSelectiveReorthogonalization
Option for doing selective reorthogonalization or not.
Structure for neighbor information.
Definition: AtomMapInfo.h:15
uint_vector_t m_vectRow
A member variable for saving row information.
#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:


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