43 t = localtime(&timer);
45 sprintf(pszBuffer,
"%d:%d:%d", t->tm_hour, t->tm_min, t->tm_sec);
57 for( i = 0; i < 3; ++i)
59 double *pfKValueUnit = NULL;
60 pKValue[i] = (
double*)malloc(
sizeof(
double)*(
unsigned int)lpParam->
fKPoints);
61 pfKValueUnit = pKValue[i];
66 for( j = 1; j < (
unsigned int)lpParam->
fKPoints-1 ; ++j )
67 pfKValueUnit[j] = pfKValueUnit[j-1] + fInterval[i];
85 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
86 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
106 if (NULL != lpResult)
111 for (i = 0; i < 3; ++i)
130 unsigned int nRowCount, nColumnCount;
137 nRowCount = (
unsigned int)lpMapInfo->
fItemCount * 10;
138 nColumnCount = (
unsigned int)lpMapInfo->
fItemCount * 10;
174 unsigned int i, nRepeatCount = 1;
178 double *pKValue[3] = {NULL, NULL, NULL};
188 sprintf(szMsg,
"Terminated program. '%s' file doesn't existed\n", pszInputCommnadFileName);
207 if (bRemovePrevResult)
209 system("rmdir /s /q result");
211 system(
"rm -rf result");
216 if(omp_get_num_threads() > 1)
218 if(omp_get_thread_num() == 0)
239 SHOW_SIMPLE_MSG(
"Terminated program. Direction information doesn't existed.\n");
246 SHOW_SIMPLE_MSG(
"Terminated program. Node counts should be smaller than assigend unitcell count with X axis.\n");
266 sprintf(szMsg,
"-Surface atom counts: %d\n", (
int)fTotalSurfaceCount);
275 FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
280 pHamiltonian =
AllocateCSR(nRtnCode, &mapInfo, lpParam, &GeometricShape, bMPI);
286 SHOW_SIMPLE_MSG(
"Terminated program. Can't load meterial param information.\n");
288 FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
302 #ifndef DISABLE_MPI_ROUTINE
307 gethostname(host_name, 256);
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;
324 local_row = pHamiltonian->
m_vectRow.data();
327 local_row_size = pHamiltonian->
m_vectRow.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)
335 double impurity_position[3];
338 impurity_position[0] = (double)tempnCell / 2.0 * lpParam->
fUnitcellLength[0];
340 impurity_position[1] = (double)tempnCell / 2.0 * lpParam->
fUnitcellLength[1];
342 impurity_position[2] = (double)tempnCell / 2.0 * lpParam->
fUnitcellLength[2];
347 for (i = 0; i < (
unsigned int)lpParam->
fKPoints ; i++)
349 double fKValue[3] = { 0., 0., 0. };
351 fKValue[0] = pKValue[0][i]; fKValue[1] = pKValue[1][i]; fKValue[2] = pKValue[2][i];
354 sprintf(szMsg,
"[%d] -Start Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n", i, fKValue[0], fKValue[1], fKValue[2]);
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)
408 sprintf(szMsg,
"\n[%d] -Finished Lanczos eigenvalue solver for Hamiltonian. (k = %f, %f, %f)\n\n", i, fKValue[0], fKValue[1], fKValue[2]);
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)
426 FinalEvn(pHamiltonian, lpParam, pKValue, &mapInfo, &GeometricShape, bMPI);
442 double inveps = 1.0 / 11.9;
443 double esqr = 1.4399766;
444 double myx, myy, myz, distance;
446 for (
unsigned int i = 0; i < (
unsigned int)mapInfo.
fItemCount; i++)
452 distance = sqrt(myx*myx + myy*myy + myz*myz);
454 if (distance < 1.0e-5)
458 potential.
SetAt(i, curval);
double * pfZ_Coordination
An array of Z coordination.
unsigned int nMPILevel
MPI Grouping level.
#define CAN_NOT_ALLOC_RANK
Return code at main loop, there is fail assign unit cell to MPI ranks.
void SetSize(unsigned int nSize)
Set Vector elements size.
static void InitCommunicationBufferMetric()
Initializing MPI Communication buffer for MVMul.
static void FinalizeManager()
Get Root rank.
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 void SetMPIEnviroment(int nRank, int nTotalNode)
Set MPI Enviroment.
static bool SetAtomAndNeighborInformation(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set neighbor information to AtomFactory.
Factory class for create CKNGeometricAtom instance.
unsigned int nComponentsFirstUnitCell
Atom counts for interoperaton with previous node.
void BuildNeighborInformation()
Find neighbor of each atom.
This class includes functions for Hamiltonian building.
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.
static void FreeCSR(CKNMatrixOperation::CKNCSR *pCSR)
Deallocating CSR memory.
static bool InitLevel(int nMPILevel, int nFindingDegeneratedEVCount)
Init MPI Level, most low level is for multi node cacluation for Lanczos.
unsigned int GetNoneZeroCount()
Getting numbers of none zero elements.
double_vector_t m_vectValueRealBuffer
A member variable for saving none zero elements.
Show message and debugging variable.
double * pfX_Coordination
An array of X coordination.
bool RefillPeriodicBinding(CKNMatrixOperation::CKNCSR *pResult, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, unsigned int nRepeatIndex, double fKValue[3])
Applying phase to Hamiltonian.
static void FreeMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo)
Release mapinfo data.
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.
This class for parsing input command file.
double fKValueInit[3]
Init k point value.
double fKValueFinal[3]
Final k point value.
Lanczos method result audit class.
void SetFirstRowIndex(double fFirstIndex)
double_vector_t m_vectValueImaginaryBuffer
A member variable for saving none zero elements.
static int GetTotalNodeCount()
bool bDoSelectiveReorthogonalization
Option for doing selective reorthogonalization or not.
#define CALCULATION_SUCCESS
Return code at main loop, every steps completed.
#define SHOW_SIMPLE_MSG(message)
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.
void BuildDataBuffer()
Allocating memory for class member variable.
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.
static void LoadBlancing(int nElementCount)
Load blancing for MPI, This function for lanczos solving with geometric constrcution.
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)
Common definition for Solver.
bool DiagonalOperation(CKNVector *pOperand, OPERATION_TYPE type, bool bUseSplitVector)
To diagonal element do operation.
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.
double * pfY_Coordination
An array of Y coordination.
#define NEED_TO_ADJUST_MPI_CONFIG
Return code at main loop, there is need to adjusting mpi level and mpi node count.
double fItemCount
Item count at atom map.
#define CAN_NOT_FIND_COMMAND_FILE
Return code at main loop, there is no command file for option.
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.
This class includes functions for matrix debugging.
static void SortSolution(LPEIGENVALUE_RESULT lpResult)
Sorting computing eigenvalue.
char szStructureType[1024]
Structure type.
static int GetCurrentRank()
static void getCurrentTime(char *pszBuffer)
Get Current time from system.
static void GetKValues(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, double *pKValue[3])
Calculate K value with K points.
static unsigned int Launching_TBMS_Solver(char *pszInputCommnadFileName, bool bMPI, bool bShowMsg, bool bRemovePrevResult=true)
Launching Geomentric construction and Lancsoz method.
double GetTotalAtomCount()
static void TotalMeasurementEnd()
Measurement end for total taken time.
double fConvergeceCriteria
Eigen value convergence criteria.
#define CAN_NOT_LOAD_METERIAL_PARAM
Return code at main loop, there is no material param information file.
void SetAt(unsigned int nIndex, CKNComplex value)
Set element value in specific index, Call by value.
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.
void PeriodicUnitCellNumbering(bool bXAxis=false)
Numbering to periodic unitcell.
static void TotalMeasurementStart()
Measurement start for total taken time.
void SetRealNumber(double fRealNumber)
Set real part.
const unsigned long ERROR_MALLOC
Error code that means error occur during memory allocation.
static void ApplyPhPotential(double *impurity_position, CKNMatrixOperation::CKNCSR *matrix, NEIGHBOR_MAP_INFO mapInfo, bool bUseSplitVector)
Applying impurity potential.
This class for complex operation and saving value.
double fKPoints
K point count.
void SetRowCount(unsigned int nRow)
Settting row size of matrix.
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.
void SetColumnCount(unsigned int nColumn)
Settting column size of matrix.
static bool IsRootRank()
Get Total node count.
#define ORBITALS
At Hamiltonian matrix one atom inserted 10 * 10.
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 nMatrixDemension
Hamiltonian matrix demension.
int nCheckEigenvalueInterval
A interval for checking T matrix eigenvlaue.
static bool IsMultiLevelMPI()
Get MPI_Comm.
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.
This class for describing vector for Lanczos method.
int nDirectionSingle
Direction xyz.
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.
unsigned int m_nAtomFirstLayer
Get Surface atom list.