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

This class for launching calculation module. More...

#include "KNTBMS_Solver.h"

Collaboration diagram for CKNTBMS_Solver:
Collaboration graph

Public Member Functions

 CKNTBMS_Solver ()
 
 ~CKNTBMS_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 bool InitMPIEnv (bool &bMPI, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
 Initialization of MPI environment. More...
 
static void FinalEvn (CKNMatrixOperation::CKNCSR *lpResult, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3], NEIGHBOR_MAP_INFO *lpMapInfo, CKNGeometricShape *pGeometricShape, bool bMPI)
 Finalization of enviroment and variables. More...
 
static void GetKValues (CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3])
 Calculate K value with K points. More...
 
static CKNMatrixOperation::CKNCSRAllocateCSR (unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, CKNGeometricShape *pGeometricShape, bool bMPI)
 Allocating CSR memory sapce. More...
 
static void ApplyPhPotential (double *impurity_position, CKNMatrixOperation::CKNCSR *matrix, NEIGHBOR_MAP_INFO mapInfo, bool bUseSplitVector)
 Applying impurity potential. More...
 

Detailed Description

This class for launching calculation module.

Date
10/Jan/2015
Author
Kyu Nam Cho(mysto.nosp@m.us@k.nosp@m.orea..nosp@m.ac.k.nosp@m.r), Hoon Ryu(elec1.nosp@m.020@.nosp@m.gmail.nosp@m..com)

Definition at line 20 of file KNTBMS_Solver.h.

Constructor & Destructor Documentation

CKNTBMS_Solver::CKNTBMS_Solver ( )
CKNTBMS_Solver::~CKNTBMS_Solver ( )

Member Function Documentation

CKNMatrixOperation::CKNCSR * CKNTBMS_Solver::AllocateCSR ( unsigned int &  nRtn,
NEIGHBOR_MAP_INFO lpMapInfo,
CKNCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
CKNGeometricShape pGeometricShape,
bool  bMPI 
)
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 128 of file KNTBMS_Solver.cpp.

References CKNMatrixOperation::CKNCSR::BuildDataBuffer(), ERROR_MALLOC, NEIGHBOR_MAP_INFO::fItemCount, CKNGeometricShape::GetAtomStartID(), CKNGeometricShape::GetTotalAtomCount(), CKNMPIManager::InitCommunicationBufferMetric(), CKNMPIManager::LoadBlancing(), CKNCommandFileParser::INPUT_CMD_PARAM::nMatrixDemension, CKNMatrixOperation::CKNCSR::SetColumnCount(), CKNMatrixOperation::CKNCSR::SetFirstRowIndex(), and CKNMatrixOperation::CKNCSR::SetRowCount().

Referenced by Launching_TBMS_Solver().

129 {
130  unsigned int nRowCount, nColumnCount;
131  CKNMatrixOperation::CKNCSR *pResult = NULL;
132 
133  pResult = new CKNMatrixOperation::CKNCSR();
134  if (NULL == pResult)
135  throw ERROR_MALLOC;
136 
137  nRowCount = (unsigned int)lpMapInfo->fItemCount * 10;
138  nColumnCount = (unsigned int)lpMapInfo->fItemCount * 10;
139 
140  if (bMPI)
141  {
142  nColumnCount = (unsigned int)pGeometricShape->GetTotalAtomCount() * 10;
143  CKNMPIManager::LoadBlancing(nRowCount);
145  }
146 
147  lpParam->nMatrixDemension = nColumnCount;
148 
149  pResult->SetRowCount(nRowCount);
150  pResult->SetColumnCount(nColumnCount);
151  pResult->BuildDataBuffer();
152  pResult->SetFirstRowIndex(pGeometricShape->GetAtomStartID()*10);
153 
154  return pResult;
155 }
static void InitCommunicationBufferMetric()
Initializing MPI Communication buffer for MVMul.
Data and operation representation of CSR(Compressed Sparse Row)
void SetFirstRowIndex(double fFirstIndex)
void BuildDataBuffer()
Allocating memory for class member variable.
double GetAtomStartID()
Set total valid atom count in shape.
static void LoadBlancing(int nElementCount)
Load blancing for MPI, This function for lanczos solving with geometric constrcution.
double fItemCount
Item count at atom map.
double GetTotalAtomCount()
const unsigned long ERROR_MALLOC
Error code that means error occur during memory allocation.
Definition: CKNGlobal.h:62
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
int nMatrixDemension
Hamiltonian matrix demension.

Here is the call graph for this function:

Here is the caller graph for this function:

void CKNTBMS_Solver::ApplyPhPotential ( double *  impurity_position,
CKNMatrixOperation::CKNCSR matrix,
NEIGHBOR_MAP_INFO  mapInfo,
bool  bUseSplitVector 
)
staticprivate

Applying impurity potential.

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

Definition at line 437 of file KNTBMS_Solver.cpp.

References CKNMatrixOperation::CKNCSR::DiagonalOperation(), NEIGHBOR_MAP_INFO::fItemCount, CKNMPIManager::IsRootRank(), NEIGHBOR_MAP_INFO::pfX_Coordination, NEIGHBOR_MAP_INFO::pfY_Coordination, NEIGHBOR_MAP_INFO::pfZ_Coordination, CKNMatrixOperation::CKNCSR::PLUS, CKNMatrixOperation::CKNVector::SetAt(), CKNComplex::SetRealNumber(), CKNMatrixOperation::CKNVector::SetSize(), and CKNIPCCUtility::ShowMsg().

438 {
440  CKNComplex curval;
441  potential.SetSize((unsigned int)mapInfo.fItemCount);
442  double inveps = 1.0 / 11.9;
443  double esqr = 1.4399766;
444  double myx, myy, myz, distance;
445 
446  for (unsigned int i = 0; i < (unsigned int)mapInfo.fItemCount; i++)
447  {
448  myx = (mapInfo.pfX_Coordination[i] - impurity_position[0]);
449  myy = (mapInfo.pfY_Coordination[i] - impurity_position[1]);
450  myz = (mapInfo.pfZ_Coordination[i] - impurity_position[2]);
451 
452  distance = sqrt(myx*myx + myy*myy + myz*myz);
453 
454  if (distance < 1.0e-5)
455  curval.SetRealNumber(-3.782);
456  else
457  curval.SetRealNumber(-inveps*esqr / distance);
458  potential.SetAt(i, curval);
459  }
460 
461  matrix->DiagonalOperation(&potential, CKNMatrixOperation::CKNCSR::PLUS, bUseSplitVector);
462 
464  CKNIPCCUtility::ShowMsg("-Phospher potential plungged\n");
465 }
double * pfZ_Coordination
An array of Z coordination.
void SetSize(unsigned int nSize)
Set Vector elements size.
static void ShowMsg(char *pszBuffer)
Show message.
double * pfX_Coordination
An array of X coordination.
bool DiagonalOperation(CKNVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector)
To diagonal element do operation.
double * pfY_Coordination
An array of Y coordination.
double fItemCount
Item count at atom map.
void SetAt(unsigned int nIndex, CKNComplex value)
Set element value in specific index, Call by value.
void SetRealNumber(double fRealNumber)
Set real part.
Definition: KNComplex.h:31
This class for complex operation and saving value.
Definition: KNComplex.h:18
static bool IsRootRank()
Get Total node count.
This class for describing vector for Lanczos method.

Here is the call graph for this function:

void CKNTBMS_Solver::FinalEvn ( CKNMatrixOperation::CKNCSR lpResult,
CKNCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
double *  pKValue[3],
NEIGHBOR_MAP_INFO lpMapInfo,
CKNGeometricShape 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 102 of file KNTBMS_Solver.cpp.

References CKNMPIManager::FinalizeManager(), FREE_MEM, CKNMatrixOperation::FreeCSR(), and CKNGeometricShape::FreeMapInfo().

Referenced by Launching_TBMS_Solver().

103 {
104  int i;
105 
106  if (NULL != lpResult)
107  CKNMatrixOperation::FreeCSR(lpResult);
108 
110  FREE_MEM(lpParam);
111  for (i = 0; i < 3; ++i)
112  FREE_MEM(pKValue[i]);
113 
114  if (bMPI)
115  {
117  MPI_Finalize();
118  }
119 }
static void FinalizeManager()
Get Root rank.
static void FreeCSR(CKNMatrixOperation::CKNCSR *pCSR)
Deallocating CSR memory.
static void FreeMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo)
Release mapinfo data.
#define FREE_MEM(pointer)
Macro for memory allocation and assign null value.
Definition: CKNGlobal.h:20

Here is the call graph for this function:

Here is the caller graph for this function:

void CKNTBMS_Solver::getCurrentTime ( char *  pszBuffer)
staticprivate

Get Current time from system.

Parameters
pszBuffer[out]Charater buffer that want to save string that include time information

Definition at line 37 of file KNTBMS_Solver.cpp.

38 {
39  time_t timer;
40  struct tm *t;
41 
42  timer = time(NULL);
43  t = localtime(&timer);
44 
45  sprintf(pszBuffer, "%d:%d:%d", t->tm_hour, t->tm_min, t->tm_sec);
46 }
void CKNTBMS_Solver::GetKValues ( CKNCommandFileParser::LPINPUT_CMD_PARAM  lpParam,
double *  pKValue[3] 
)
staticprivate

Calculate K value with K points.

Parameters
lpParamOption parameters for program launching
pKValue[out]Buffer for saving k values

Definition at line 52 of file KNTBMS_Solver.cpp.

References CKNCommandFileParser::INPUT_CMD_PARAM::fKPoints, CKNCommandFileParser::INPUT_CMD_PARAM::fKValueFinal, and CKNCommandFileParser::INPUT_CMD_PARAM::fKValueInit.

Referenced by Launching_TBMS_Solver().

53 {
54  double fInterval[3];
55  unsigned int i, j;
56 
57  for( i = 0; i < 3; ++i)
58  {
59  double *pfKValueUnit = NULL;
60  pKValue[i] = (double*)malloc(sizeof(double)*(unsigned int)lpParam->fKPoints);
61  pfKValueUnit = pKValue[i];
62  fInterval[i] = (lpParam->fKValueFinal[i] - lpParam->fKValueInit[i]) / (lpParam->fKPoints - 1);
63  pfKValueUnit[0] = lpParam->fKValueInit[i];
64  if (lpParam->fKPoints > 1 )
65  pfKValueUnit[(int)lpParam->fKPoints-1] = lpParam->fKValueFinal[i];
66  for( j = 1; j < (unsigned int)lpParam->fKPoints-1 ; ++j )
67  pfKValueUnit[j] = pfKValueUnit[j-1] + fInterval[i];
68  }
69 }
double fKValueInit[3]
Init k point value.
double fKValueFinal[3]
Final k point value.

Here is the caller graph for this function:

bool CKNTBMS_Solver::InitMPIEnv ( bool &  bMPI,
CKNCommandFileParser::LPINPUT_CMD_PARAM  lpParam 
)
staticprivate

Initialization of MPI environment.

Parameters
bMPIRunning with MPI enviroment or not
lpParamOption parameters for program launching

Definition at line 75 of file KNTBMS_Solver.cpp.

References CKNMPIManager::InitLevel(), CKNCommandFileParser::INPUT_CMD_PARAM::nFindingDegeneratedEVCount, CKNCommandFileParser::INPUT_CMD_PARAM::nMPILevel, and CKNMPIManager::SetMPIEnviroment().

Referenced by Launching_TBMS_Solver().

76 {
77  int rank;
78  int world_size;
79  bool bRtn = true;
80 
81  if (!bMPI)
82  return bRtn;
83 
84  MPI_Init(NULL, NULL);
85  MPI_Comm_size(MPI_COMM_WORLD, &world_size);
86  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
87 
88  CKNMPIManager::SetMPIEnviroment(rank, world_size);
90 
91  return bRtn;
92 }
unsigned int nMPILevel
MPI Grouping level.
static void SetMPIEnviroment(int nRank, int nTotalNode)
Set MPI Enviroment.
static bool InitLevel(int nMPILevel, int nFindingDegeneratedEVCount)
Init MPI Level, most low level is for multi node cacluation for Lanczos.
unsigned int nFindingDegeneratedEVCount
Degenerated eigenvalue count for want to find.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int CKNTBMS_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

< Reset hamlitonian before calculating phase

Definition at line 163 of file KNTBMS_Solver.cpp.

References AllocateCSR(), CKNMPIManager::AllReduceDouble(), CKNCommandFileParser::INPUT_CMD_PARAM::bCalculateEigenVectors, CKNCommandFileParser::INPUT_CMD_PARAM::bCalculateWaveFunction, CKNCommandFileParser::INPUT_CMD_PARAM::bConsiderBoundaryCondition, CKNCommandFileParser::INPUT_CMD_PARAM::bDoSelectiveReorthogonalization, CKNCommandFileParser::INPUT_CMD_PARAM::bSaveHamiltonian, CKNHamiltonianBuilder::BuildHamiltonian(), CKNGeometricShape::BuildNeighborInformation(), CALCULATION_SUCCESS, CAN_NOT_ALLOC_RANK, CAN_NOT_FIND_COMMAND_FILE, CAN_NOT_LOAD_METERIAL_PARAM, CKNLanczosMethod::CheckingCalculationCondition(), CKNGeometricShape::ConstructMapInfo(), CUBIC, CKNLanczosMethod::DoLanczosMethod(), CKNIPCCUtility::DumpCSR(), CKNGeometricShape::ExchangeAtomInfoBetweenNode(), CKNCommandFileParser::INPUT_CMD_PARAM::fConvergeceCriteria, CKNCommandFileParser::INPUT_CMD_PARAM::fevMax, CKNCommandFileParser::INPUT_CMD_PARAM::fevMin, CKNGeometricShape::FillUnitcell(), FinalEvn(), CKNHamiltonianBuilder::FinalizeMatrixBuffer(), CKNGeometricShape::FinalShape(), CKNCommandFileParser::INPUT_CMD_PARAM::fKPoints, FREE_MEM, CKNCommandFileParser::INPUT_CMD_PARAM::fShapeLength, CKNCommandFileParser::INPUT_CMD_PARAM::fUnitcellLength, CKNGeometricShape::GetAtomStartID(), CKNMPIManager::GetCurrentRank(), GetKValues(), CKNMatrixOperation::CKNCSR::GetNoneZeroCount(), CKNGeometricShape::GetSurfaceAtomList(), CKNMPIManager::GetTotalNodeCount(), InitMPIEnv(), CKNTimeMeasurement::InitTimer(), CKNMPIManager::IsDeflationRoot(), CKNMPIManager::IsMultiLevelMPI(), CKNMPIManager::IsRootRank(), CKNCommandFileParser::INPUT_CMD_PARAM::load_in_MIC, CKNGeometricShape::m_nAtomFirstLayer, CKNGeometricShape::m_nAtomLastLayer, CKNMatrixOperation::CKNCSR::m_vectColumn, CKNMatrixOperation::CKNCSR::m_vectRow, CKNMatrixOperation::CKNCSR::m_vectValueImaginaryBuffer, CKNMatrixOperation::CKNCSR::m_vectValueRealBuffer, CKNLanczosMethod::MergeDegeneratedEigenvalues(), CKNCommandFileParser::INPUT_CMD_PARAM::nCheckEigenvalueInterval, CKNMatrixOperation::CKNCSR::nComponentsFirstUnitCell, CKNMatrixOperation::CKNCSR::nComponentsLastUnitCell, CKNCommandFileParser::INPUT_CMD_PARAM::nDirectionSingle, NEED_TO_ADJUST_MPI_CONFIG, CKNCommandFileParser::INPUT_CMD_PARAM::nFindingDegeneratedEVCount, CKNCommandFileParser::INPUT_CMD_PARAM::nFindingEigenValueCount, CKNCommandFileParser::INPUT_CMD_PARAM::nLanczosIterationCount, ORBITALS, CKNCommandFileParser::ParsingInputCommand(), CKNGeometricShape::PeriodicUnitCellNumbering(), phi_tid, CKNLanczosMethod::RecalcuWaveFunction(), CKNGeometricShape::RefillPeriodicBinding(), CKNLanczosMethod::ReleaseResult(), CKNHamiltonianBuilder::ResetPeriodicBinding(), CKNLanczosMethod::SaveLanczosResult(), CKNGeometricShape::SetAtomAndNeighborInformation(), CKNGeometricShape::SetShapeInformation(), CKNIPCCUtility::SetShow(), SHOW_SIMPLE_MSG, CKNLanczosMethod::ShowLanczosResult(), CKNIPCCUtility::ShowMsg(), CKNLanczosMethod::SortSolution(), CKNCommandFileParser::INPUT_CMD_PARAM::szStructureType, CKNTimeMeasurement::TotalMeasurementEnd(), and CKNTimeMeasurement::TotalMeasurementStart().

164 {
165 
166  CKNGeometricShape GeometricShape;
167  CKNMatrixOperation::CKNCSR *pHamiltonian = NULL;
168  CKNMatrixOperation::CKNCSR *plocalH = NULL;
169  CKNMatrixOperation::CKNCSR *plocalHm1 = NULL;
170  CKNMatrixOperation::CKNCSR *plocalHp1 = NULL;
172  NEIGHBOR_MAP_INFO mapInfo;
173  unsigned int nRtnCode = CALCULATION_SUCCESS;
174  unsigned int i, nRepeatCount = 1;
176  CKNLanczosMethod lanczos;
177  char szMsg[1024];
178  double *pKValue[3] = {NULL, NULL, NULL};
179 
180  if (bShowMsg)
182 
183  lpParam = CKNCommandFileParser::ParsingInputCommand(pszInputCommnadFileName);
184  if (NULL == lpParam)
185  {
187  {
188  sprintf(szMsg, "Terminated program. '%s' file doesn't existed\n", pszInputCommnadFileName);
190  }
192  }
194  {
195  SHOW_SIMPLE_MSG("Adjusting input parameter first!\n");
197  }
198 
199  if( !InitMPIEnv(bMPI, lpParam))
200  {
201  SHOW_SIMPLE_MSG("Adjusting MPI level and node count first!\n");
203  }
204 
206  {
207  if (bRemovePrevResult)
208 #ifdef _WIN32
209  system("rmdir /s /q result");
210 #else //WIN32
211  system("rm -rf result");
212 #endif //WIN32
213 
214 #pragma omp parallel
215 {
216  if(omp_get_num_threads() > 1)
217  {
218  if(omp_get_thread_num() == 0)
219  {
220  sprintf(szMsg, "-Run with MPI (%d cores) and OpenMP (%d threads)\n", CKNMPIManager::GetTotalNodeCount(), omp_get_num_threads());
222  }
223  }
224  else
225  {
226  sprintf(szMsg, "-Run with MPI only (%d cores)\n", CKNMPIManager::GetTotalNodeCount());
228  }
229 }
230 
231  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);
233  CKNIPCCUtility::ShowMsg("-Start Building Geometric construction\n");
234  }
235 
236  CKNGeometricShape::SetShapeInformation(GeometricShape, lpParam);
238  {
239  SHOW_SIMPLE_MSG("Terminated program. Direction information doesn't existed.\n");
240  nRtnCode = CAN_NOT_ALLOC_RANK;
241  FREE_MEM(lpParam);
242  return nRtnCode;
243  }
244  if(!GeometricShape.FillUnitcell(lpParam))
245  {
246  SHOW_SIMPLE_MSG("Terminated program. Node counts should be smaller than assigend unitcell count with X axis.\n");
247  nRtnCode = CAN_NOT_ALLOC_RANK;
248  FREE_MEM(lpParam);
249  return nRtnCode;
250  }
251 
252  GeometricShape.PeriodicUnitCellNumbering();
253  if (bMPI)
254  {
255  GeometricShape.ExchangeAtomInfoBetweenNode();
256  GeometricShape.PeriodicUnitCellNumbering(true);
257  }
258  GeometricShape.BuildNeighborInformation();
259  GeometricShape.ConstructMapInfo(&mapInfo, lpParam);
260 
261  double fSurfaceCount = (double)GeometricShape.GetSurfaceAtomList()->size();
262  double fTotalSurfaceCount = CKNMPIManager::AllReduceDouble(fSurfaceCount);
263 
265  {
266  sprintf(szMsg, "-Surface atom counts: %d\n", (int)fTotalSurfaceCount);
268  }
269 
270  if (!strcmp(lpParam->szStructureType, CUBIC))
271  {
272  SHOW_SIMPLE_MSG("\n-Geometry construction completed!\n\n");
273 
274  GeometricShape.FinalShape();
275  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
276 
277  return nRtnCode;
278  }
279 
280  pHamiltonian = AllocateCSR(nRtnCode, &mapInfo, lpParam, &GeometricShape, bMPI);
281 
282 
283  SHOW_SIMPLE_MSG("-Building Hamiltonian Matrix\n");
284  if (!CKNHamiltonianBuilder::BuildHamiltonian(lpParam, &mapInfo, pHamiltonian, GeometricShape.GetAtomStartID()))
285  {
286  SHOW_SIMPLE_MSG("Terminated program. Can't load meterial param information.\n");
287  nRtnCode = CAN_NOT_LOAD_METERIAL_PARAM;
288  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
289  return nRtnCode;
290  }
291 
292  pHamiltonian->nComponentsFirstUnitCell = GeometricShape.m_nAtomFirstLayer*ORBITALS;
293  pHamiltonian->nComponentsLastUnitCell = GeometricShape.m_nAtomLastLayer*ORBITALS;
294 
295 
296  if( lpParam->bSaveHamiltonian )
297  {
298  SHOW_SIMPLE_MSG("-Save Hamiltonian matrix to file\n");
299  CKNIPCCUtility::DumpCSR(pHamiltonian, "Hamiltonian.dat", GeometricShape.GetAtomStartID());
300  }
301 
302 #ifndef DISABLE_MPI_ROUTINE
304 // FIXME test code
305 #ifndef _WIN32
306  char host_name[256];
307  gethostname(host_name, 256);
308  printf("-[Host:%s] (MPI:%03d) mapped to (MIC:%03d)\n", host_name, CKNMPIManager::GetCurrentRank(), phi_tid);
309 #endif //_WIN32
310 #else
311  phi_tid = 0;
312 #endif
313 
314  double *local_real = NULL;
315  double *local_imaginary = NULL;
316  unsigned int *local_row = NULL;
317  unsigned int *local_col = NULL;
318  unsigned int local_size = 0;
319  unsigned int local_row_size = 0;
320  unsigned int local_col_size = 0;
321 
322  local_real = pHamiltonian->m_vectValueRealBuffer.data();
323  local_imaginary = pHamiltonian->m_vectValueImaginaryBuffer.data();
324  local_row = pHamiltonian->m_vectRow.data();
325  local_col = pHamiltonian->m_vectColumn.data();
326  local_size = pHamiltonian->GetNoneZeroCount();
327  local_row_size = pHamiltonian->m_vectRow.size();
328  local_col_size = pHamiltonian->m_vectColumn.size();
329 #pragma offload_transfer target(mic:phi_tid) \
330  nocopy(local_real[0:local_size] : ALLOC) \
331  nocopy(local_imaginary[0:local_size] : ALLOC) \
332  nocopy(local_row[0:local_row_size] : ALLOC) \
333  nocopy(local_col[0:local_col_size] : ALLOC)
334 
335  double impurity_position[3];
336  int tempnCell;
337  tempnCell = floor(lpParam->fShapeLength[0][0] / lpParam->fUnitcellLength[0]);
338  impurity_position[0] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[0];
339  tempnCell = floor(lpParam->fShapeLength[0][1] / lpParam->fUnitcellLength[1]);
340  impurity_position[1] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[1];
341  tempnCell = floor(lpParam->fShapeLength[0][2] / lpParam->fUnitcellLength[2]);
342  impurity_position[2] = (double)tempnCell / 2.0 * lpParam->fUnitcellLength[2];
343  //ApplyPhPotential(impurity_position, pHamiltonian, mapInfo, true);
344 
345 
346  GetKValues(lpParam, pKValue);
347  for (i = 0; i < (unsigned int)lpParam->fKPoints ; i++)
348  {
349  double fKValue[3] = { 0., 0., 0. };
350 
351  fKValue[0] = pKValue[0][i]; fKValue[1] = pKValue[1][i]; fKValue[2] = pKValue[2][i];
353  {
354  sprintf(szMsg, "[%d] -Start Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n", i, fKValue[0], fKValue[1], fKValue[2]);
356  }
357 
358  if (false == GeometricShape.RefillPeriodicBinding(pHamiltonian, lpParam, &mapInfo, i, fKValue))
359  continue;
360 
361 #pragma offload_transfer target(mic:phi_tid) \
362  in(local_real[0:local_size] : REUSE) \
363  in(local_imaginary[0:local_size] : REUSE) \
364  in(local_row[0:local_row_size] : REUSE) \
365  in(local_col[0:local_col_size] : REUSE)
366 
370  lpResult = lanczos.DoLanczosMethod(pHamiltonian,
371  lpParam->nLanczosIterationCount,
372  lpParam->nCheckEigenvalueInterval,
373  lpParam->nFindingEigenValueCount,
374  lpParam->fevMin,
375  lpParam->fevMax,
376  lpParam->fConvergeceCriteria,
378  lpParam->bCalculateEigenVectors,
379  lpParam->bCalculateWaveFunction,
380  lpParam->load_in_MIC,
381  plocalH, // ADDED
382  plocalHm1, // ADDED
383  plocalHp1);// ADDED
384 
386  {
388  CKNIPCCUtility::ShowMsg("-Calculating degenerated eigenvalues\n");
389  CKNLanczosMethod::MergeDegeneratedEigenvalues(lpResult, lpParam->nFindingDegeneratedEVCount, pHamiltonian, plocalH, plocalHm1, plocalHp1);
390  if( lpParam->bCalculateWaveFunction )
392  }
393 
396 
398  CKNIPCCUtility::ShowMsg("\n-Save result into file\n");
399 
402 
404 
405 
407  {
408  sprintf(szMsg, "\n[%d] -Finished Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n\n", i, fKValue[0], fKValue[1], fKValue[2]);
410  }
411 
412  CKNLanczosMethod::ReleaseResult(lpResult, true);
413  CKNHamiltonianBuilder::ResetPeriodicBinding(pHamiltonian, &mapInfo);
414  }
416 
417  SHOW_SIMPLE_MSG("- TBMS Solver completed!\n\n");
418 
419 
420 #pragma offload_transfer target(mic:phi_tid) \
421  nocopy(local_real : FREE) \
422  nocopy(local_imaginary : FREE) \
423  nocopy(local_row : FREE) \
424  nocopy(local_col : FREE)
425 
426  FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
427 
428  return nRtnCode;
429 }
#define CAN_NOT_ALLOC_RANK
Return code at main loop, there is fail assign unit cell to MPI ranks.
Definition: CKNGlobal.h:71
static void ShowMsg(char *pszBuffer)
Show message.
static bool BuildHamiltonian(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, CKNMatrixOperation::CKNCSR *pCSRResult, unsigned int fAtomStartID)
Build Hamiltonian matrxi from mapinfo data.
void ExchangeAtomInfoBetweenNode()
Get start index of atom in shape, using in MPI running enviroment.
static bool SetAtomAndNeighborInformation(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set neighbor information to AtomFactory.
unsigned int nComponentsFirstUnitCell
Atom counts for interoperaton with previous node.
void BuildNeighborInformation()
Find neighbor of each atom.
static void MergeDegeneratedEigenvalues(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, unsigned int nFindingDegeneratedEVCount, CKNMatrixOperation::CKNCSR *pA, CKNMatrixOperation::CKNCSR *pLocalBlock, CKNMatrixOperation::CKNCSR *pLeftBlock, CKNMatrixOperation::CKNCSR *pRightBlock)
Merging eigenvalue into mater group.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
bool RefillPeriodicBinding(CKNMatrixOperation::CKNCSR *pResult, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, unsigned int nRepeatIndex, double fKValue[3])
Applying phase to Hamiltonian.
Data and operation representation of CSR(Compressed Sparse Row)
static void SetShapeInformation(CKNGeometricShape &shape, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set shape information(Length, material, bondary condition and so on)
bool bSaveHamiltonian
Save Hamiltonian matrix or not.
This class for doing Lanczos method.
int phi_tid
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
static int GetTotalNodeCount()
Definition: KNMPIManager.h:44
bool bDoSelectiveReorthogonalization
Option for doing selective reorthogonalization or not.
#define CALCULATION_SUCCESS
Return code at main loop, every steps completed.
Definition: CKNGlobal.h:70
#define SHOW_SIMPLE_MSG(message)
Definition: CKNGlobal.h:41
static double AllReduceDouble(double fNumber)
Do all reduce function with CKNComplex.
uint_vector_t m_vectColumn
A member variable for saving column information.
bool bCalculateEigenVectors
Option for doing calculating eigen vectors or not.
static void RecalcuWaveFunction(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult)
Recalculating wavefunction after merging degenerated eigenvalues.
static LPINPUT_CMD_PARAM ParsingInputCommand(char *pszInputCommnadFileName)
Parsing Commaind file.
Class for Geometric shape.
std::vector< CKNGeometricAtom * > * GetSurfaceAtomList()
double fevMin
Eigen value minimun value boundary.
int nFindingEigenValueCount
Eigen value count for want to find.
double GetAtomStartID()
Set total valid atom count in shape.
bool bCalculateWaveFunction
Option for doing calculating wave function or not.
void FinalShape()
Finalize Shape variable.
int nLanczosIterationCount
A counts of lanczos interation.
static void SaveLanczosResult(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalcuEigenvalue, bool bWaveFunction, double *pKValue, int nRepeatCount)
Saving Lanczos computation result into file.
static void SetShow(bool bShow)
Definition: KNIPCCUtility.h:30
unsigned int nFindingDegeneratedEVCount
Degenerated eigenvalue count for want to find.
static bool CheckingCalculationCondition(bool bCalcuEigenValue, bool bCalcuWaveFunction, unsigned int nDeflationGroup)
Checking pre conditions for Lanczos method operation.
Structure for save input command file parsing result.
double fShapeLength[NMAXDOMAIN][3]
Shap length x, y, z, direction.
double fevMax
Eigen value maximun value boundary.
static void DumpCSR(CKNMatrixOperation::CKNCSR *pCSR, char *pszFileName, double fAtomIDStartIndex)
Dump CSR to text file.
#define NEED_TO_ADJUST_MPI_CONFIG
Return code at main loop, there is need to adjusting mpi level and mpi node count.
Definition: CKNGlobal.h:75
#define CAN_NOT_FIND_COMMAND_FILE
Return code at main loop, there is no command file for option.
Definition: CKNGlobal.h:74
Structure for engienvalue computing.
bool ConstructMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Extract atom information from runtime objects.
unsigned int nComponentsLastUnitCell
Atom counts for interoperaton with next node.
static CKNMatrixOperation::CKNCSR * AllocateCSR(unsigned int &nRtn, NEIGHBOR_MAP_INFO *lpMapInfo, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, CKNGeometricShape *pGeometricShape, bool bMPI)
Allocating CSR memory sapce.
bool FillUnitcell(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set bondary condition of shape.
double fUnitcellLength[3]
Unitcell length x, y, z direction.
LPEIGENVALUE_RESULT DoLanczosMethod(CKNMatrixOperation::CKNCSR *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, CKNMatrixOperation::CKNCSR *pmylocalblock=NULL, CKNMatrixOperation::CKNCSR *leftlocalblock=NULL, CKNMatrixOperation::CKNCSR *rightlocalblock=NULL)
Doing lanczos method.
static void SortSolution(LPEIGENVALUE_RESULT lpResult)
Sorting computing eigenvalue.
char szStructureType[1024]
Structure type.
static int GetCurrentRank()
Definition: KNMPIManager.h:42
static void GetKValues(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3])
Calculate K value with K points.
static void TotalMeasurementEnd()
Measurement end for total taken time.
double fConvergeceCriteria
Eigen value convergence criteria.
#define CUBIC
Definition: CKNGlobal.h:83
#define CAN_NOT_LOAD_METERIAL_PARAM
Return code at main loop, there is no material param information file.
Definition: CKNGlobal.h:72
static void ResetPeriodicBinding(CKNMatrixOperation::CKNCSR *pResult, LPNEIGHBOR_MAP_INFO lpMapInfo)
Reset Hamiltonian before applying phase.
#define FREE_MEM(pointer)
Macro for memory allocation and assign null value.
Definition: CKNGlobal.h:20
void PeriodicUnitCellNumbering(bool bXAxis=false)
Numbering to periodic unitcell.
static void TotalMeasurementStart()
Measurement start for total taken time.
static void ReleaseResult(LPEIGENVALUE_RESULT lpResult, bool bReleaseStruct)
Release memory for lanczos method result.
static bool InitMPIEnv(bool &bMPI, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Initialization of MPI environment.
static void FinalizeMatrixBuffer()
Release all temporary buffer.
static bool IsRootRank()
Get Total node count.
#define ORBITALS
At Hamiltonian matrix one atom inserted 10 * 10.
Definition: CKNGlobal.h:54
uint_vector_t m_vectRow
A member variable for saving row information.
unsigned int m_nAtomLastLayer
Last layer information for sending to next node.
int nCheckEigenvalueInterval
A interval for checking T matrix eigenvlaue.
static bool IsMultiLevelMPI()
Get MPI_Comm.
Definition: KNMPIManager.h:68
static void FinalEvn(CKNMatrixOperation::CKNCSR *lpResult, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3], NEIGHBOR_MAP_INFO *lpMapInfo, CKNGeometricShape *pGeometricShape, bool bMPI)
Finalization of enviroment and variables.
Structure for neighbor information.
bool bConsiderBoundaryCondition[3]
Considering bondary condition or not x, y, z direction.
static void InitTimer()
Init time related variable.
static void ShowLanczosResult(CKNLanczosMethod::LPEIGENVALUE_RESULT lpResult, bool bCalculateEigenVectors, bool bCalculateWaveFunction, double *pKValue, int nRepeatCount)
Save calculating result into file.
static bool IsDeflationRoot()
Checking is root rank of Lanczos computation.
Definition: KNMPIManager.h:72
unsigned int m_nAtomFirstLayer
Get Surface atom list.

Here is the call graph for this function:


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