IPCC  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
KNGeometricShape.cpp
Go to the documentation of this file.
1 
7 #include "stdafx.h"
8 #include "CKNGlobal.h"
9 #include "KNGeometricShape.h"
10 #include "KNGeometricAtom.h"
11 #include "KNIPCCUtility.h"
12 #include "KNMPIManager.h"
13 #include "KNGeometricAtomFactory.h"
14 #include <math.h>
15 #include "KNMaterialParam.h"
16 #include "KNZincblendeParam.h"
17 #include "CKNGeometricParameter.h"
18 #include "KNTwoCenterl.h"
19 #include <algorithm>
20 
21 #ifdef _WIN32
22 #include <direct.h>
23 #else
24 #include <sys/stat.h>
25 #include <sys/types.h>
26 #endif
27 
32 
34 {
35  InitShape();
36 }
37 
39 {
40  FinalShape();
41 }
42 
48 void CKNGeometricShape::SetOriginCoordination(double x, double y, double z)
49 {
51 }
52 
58 void CKNGeometricShape::SetDirection(double x_axis, double y_axis, double z_axis)
59 {
60  m_shapDirection.SetDirection(x_axis, y_axis, z_axis);
61 }
62 
68 void CKNGeometricShape::SetLength(double lx, double ly, double lz)
69 {
70  m_fLength[_X] = lx;
71  m_fLength[_Y] = ly;
72  m_fLength[_Z] = lz;
73 }
74 
79 {
80  if (!strcmp(pszType, "Si"))
82  else if (!strcmp(pszType, "GaAs"))
84  else if (!strcmp(pszType, "InAs"))
86 }
87 
92 {
93  if (!strcmp(pszForm, "Box"))
95  else if (!strcmp(pszForm, "Cylinder"))
97 }
98 
104 {
105  bool bRtn;
106 
107  bRtn = CalculateUnitcellCount();
108  if( !bRtn )
109  return bRtn;
110 
111  ArrangeUnitCell(lpParam);
113 
114  return bRtn;
115 }
116 
118 {
119  int i, nSize = m_vectUnitCell.size();
120 
121  for (i = 0; i < nSize; ++i)
122  {
123  if( !m_vectUnitCell[i].IsPeriodicUnitCell() )
124  m_vectUnitCell[i].BuildNeighborInformation(m_fAssignedCount, GetSurfaceAtomList());
125  }
126 }
127 
136 int CKNGeometricShape::GetPeriodicDirection(int x, int y, int z, int maxX, int maxY, int maxZ)
137 {
138  int nRtn = CKNGeometricAtom::NONE;
139 
140  if (0 == x && true == m_bConsiderBoundaryCondition[_X])
141 #ifndef DISABLE_MPI_ROUTINE
144 #else //DISABLE_MPI_ROUTINE
146 #endif //DISABLE_MPI_ROUTINE
147 
148  if (0 == y && true == m_bConsiderBoundaryCondition[_Y])
150 
151  if (0 == z && true == m_bConsiderBoundaryCondition[_Z])
153 
154  if (maxX - 1 == x && true == m_bConsiderBoundaryCondition[_X])
155 #ifndef DISABLE_MPI_ROUTINE
158 #else //DISABLE_MPI_ROUTINE
160 #endif //DISABLE_MPI_ROUTINE
161 
162  if (maxY - 1 == y && true == m_bConsiderBoundaryCondition[_Y])
164 
165  if (maxZ - 1 == z && true == m_bConsiderBoundaryCondition[_Z])
167 
168  return nRtn;
169 }
170 
180 bool CKNGeometricShape::IsInBoundaryCondition(int x, int y, int z, int maxX, int maxY, int maxZ)
181 {
182  bool bRtn = false;
183 
184  if (0 == x && true == m_bConsiderBoundaryCondition[_X])
185 #ifndef DISABLE_MPI_ROUTINE
186  {
188  return bRtn;
189  }
190 #else //DISABLE_MPI_ROUTINE
191  return bRtn;
192 #endif //DISABLE_MPI_ROUTINE
193 
194  if (0 == y && true == m_bConsiderBoundaryCondition[_Y])
195  return bRtn;
196 
197  if (0 == z && true == m_bConsiderBoundaryCondition[_Z])
198  return bRtn;
199 
200  if (maxX - 1 == x && true == m_bConsiderBoundaryCondition[_X])
201 #ifndef DISABLE_MPI_ROUTINE
202  {
204  return bRtn;
205  }
206 #else //DISABLE_MPI_ROUTINE
207  return bRtn;
208 #endif //DISABLE_MPI_ROUTINE
209 
210  if (maxY - 1 == y && true == m_bConsiderBoundaryCondition[_Y])
211  return bRtn;
212 
213  if (maxZ - 1 == z && true == m_bConsiderBoundaryCondition[_Z])
214  return bRtn;
215 
216  bRtn = true;
217  return bRtn;
218 }
219 
221 {
222  m_vectUnitCell.clear();
223  m_vectPrevUnitCell.clear();
224  m_vectNextUnitCell.clear();
225  m_vectSurfaceAtom.clear();
226 }
227 
229 {
230  m_originCoordination.SetCoordination(0.0, 0.0, 0.0);
231  m_shapDirection.SetDirection(1, 0, 0);
232  m_fLength[_X] = 0;
233  m_fLength[_Y] = 0;
234  m_fLength[_Z] = 0;
235  m_MaterialType = Si;
240  m_bFrontFace = false;
241  m_bBackendFace = false;
244  m_pUnitCellInfo = NULL;
245  m_nAtomFirstLayer = 0;
246  m_nAtomLastLayer = 0;
247 }
248 
250 {
252 }
253 
255 {
256  double fXTotalCount;
257  double fXAssignCount, fYAssignCount, fZAssignCount;
258  double fUnitcellLength[3];
259  bool bRtn = false;
260  bool bPaddingUnitCell = false;
261  char szMsg[1024];
262 
263  fUnitcellLength[_X] = CKNGeometricUnitCell::GetLength(_X);
264  fUnitcellLength[_Y] = CKNGeometricUnitCell::GetLength(_Y);
265  fUnitcellLength[_Z] = CKNGeometricUnitCell::GetLength(_Z);
266 
267  fXTotalCount = floor(m_fLength[_X] / fUnitcellLength[_X]);
269  bPaddingUnitCell = true;
270 
272  fYAssignCount = floor(m_fLength[_Y] / fUnitcellLength[_Y]) + 2;
273  else
274  fYAssignCount = ceil(m_fLength[_Y] / fUnitcellLength[_Y]);
275 
277  fZAssignCount = floor(m_fLength[_Z] / fUnitcellLength[_Z]) + 2;
278  else
279  fZAssignCount = ceil(m_fLength[_Z] / fUnitcellLength[_Z]);
280 
281 #ifdef DISABLE_MPI_ROUTINE
282  fXAssignCount = fXTotalCount;
283 
284  if (bPaddingUnitCell)
285  {
286  fXAssignCount++;
287  fXTotalCount++;
288  }
289 
290 #else
292  {
293  fXAssignCount = fXTotalCount;
294  if (bPaddingUnitCell)
295  {
296  fXAssignCount++;
297  fXTotalCount++;
298  }
299  }
300  else
301  {
302  int nNodeCount = CKNMPIManager::GetTotalNodeCount();
303  unsigned int nRank = (unsigned int)CKNMPIManager::GetCurrentRank();
304 
305  if( 1 > fXTotalCount / nNodeCount )
306  return bRtn;
307 
308  unsigned int nBaseCount, nRestCount;
309 
310  nBaseCount = (unsigned int)floor(fXTotalCount / nNodeCount);
311  nRestCount = (unsigned int)floor(fXTotalCount) - nBaseCount * nNodeCount;
312 
313  fXAssignCount = nBaseCount;
314  if( nRank < nRestCount )
315  fXAssignCount += 1;
316 
317  if( true == bPaddingUnitCell && CKNMPIManager::GetCurrentRank() == CKNMPIManager::GetTotalNodeCount() - 1 )
318  fXAssignCount += 1;
319 
320  //m_fLength[LX] = fXAssignCount * fUnitcellLength[LX];
321 
322  unsigned int nExtraAdding = 0;
323 #ifdef _WIN32
324  nExtraAdding = min(nRestCount, nRank);
325 #else
326  nExtraAdding = std::min(nRestCount, nRank);
327 #endif
328 
329  if (nRank > 0)
330  {
331  double cx;
332 
333  cx = (nBaseCount * nRank + nExtraAdding) * fUnitcellLength[_X];
335  }
336 
337  if( fXAssignCount * fUnitcellLength[_X] + m_originCoordination.GetCoordination(_X) > m_fLength[_X] )
339  else
340  m_fLength[_X] = fXAssignCount * fUnitcellLength[_X];
341 
342 #ifdef SHOW_DEBUG_STRING
343 
345  {
346  sprintf(szMsg, "TotalAssignCount: %7f\n", fXTotalCount);
348  }
349 
350  sprintf(szMsg, "%d rank: Xoffset: %7f, LX: %7f, Assign Count: %7f\n", CKNMPIManager::GetCurrentRank(), m_originCoordination.GetCoordination(_X), m_fLength[_X], fXAssignCount);
352 
353 #endif //SHOW_DEBUG_STRING
354  }
355 #endif //DISABLE_MPI_ROUTINE
356 
358  {
359  if (m_bFrontFace)
360  fXAssignCount++;
361 
362  if (true == m_bBackendFace)
363  fXAssignCount++;
364  }
365 
366  m_fAssignedCount[_X] = fXAssignCount;
367  m_fAssignedCount[_Y] = fYAssignCount;
368  m_fAssignedCount[_Z] = fZAssignCount;
369 
370 
371 
372 
373 #ifndef _WIN32
375  {
376  fXAssignCount = CKNMPIManager::AllReduceDouble(fXAssignCount);
377 #endif //_WIN32
378  sprintf(szMsg, "-Unitcell counts: X-axis[%2.1f], Y-axis[%2.1f], Z-axis[%2.1f]\n", fXAssignCount, fYAssignCount, fZAssignCount);
380 #ifndef _WIN32
381  }
382  else
383  fXAssignCount = CKNMPIManager::AllReduceDouble(fXAssignCount);
384 #endif //_WIN32
385 
386  bRtn = true;
387  return bRtn;
388 }
389 
394 {
395  int x, y, z, maxX, maxY, maxZ;
396  CKNGeometricCoordination currentPos, refPos;
397  double fUnitcellLength[3];
398  double fUnitcellID = 0;
399 
400  fUnitcellLength[_X] = CKNGeometricUnitCell::GetLength(_X);
401  fUnitcellLength[_Y] = CKNGeometricUnitCell::GetLength(_Y);
402  fUnitcellLength[_Z] = CKNGeometricUnitCell::GetLength(_Z);
403 
405 
406  double fOffset[3] = { 0, };
407 
409  {
410  if (m_bFrontFace)
411  fOffset[_X] = -fUnitcellLength[_X];
412  }
413 
415  fOffset[_Y] = -fUnitcellLength[_Y];
416 
418  fOffset[_Z] = -fUnitcellLength[_Z];
419 
420  currentPos.SetOffset(fOffset[_X], fOffset[_Y], fOffset[_Z]);
421  refPos.SetCoordination(currentPos.GetCoordinationAll());
422 
423  maxX = (int)floor(m_fAssignedCount[_X]);
424  maxY = (int)floor(m_fAssignedCount[_Y]);
425  maxZ = (int)floor(m_fAssignedCount[_Z]);
426 
428  for (x = 0; x < maxX; ++x)
429  {
430  currentPos.SetCoordination(currentPos.GetCoordination(_X), refPos.GetCoordination(_Y), refPos.GetCoordination(_Z));
431  for (y = 0; y < maxY; ++y)
432  {
433  currentPos.SetCoordination(currentPos.GetCoordination(_X), currentPos.GetCoordination(_Y), refPos.GetCoordination(_Z));
434  for (z = 0; z < maxZ; ++z)
435  {
436  CKNGeometricUnitCell UnitCell;
437 
438  UnitCell.SetCoordination(currentPos);
439  UnitCell.SetID(fUnitcellID++);
440  UnitCell.ArrangeAtom(lpParam);
441 
442  if (IsInBoundaryCondition(x, y, z, maxX, maxY, maxZ))
443  {
444  //printf("[%03d] %10.10f, %10.10f, %10.10f\n", (int)(fUnitcellID - 1), currentPos.GetCoordination(CKNGeometricCoordination::X), currentPos.GetCoordination(CKNGeometricCoordination::Y), currentPos.GetCoordination(CKNGeometricCoordination::Z));
445  unsigned int nAtom = UnitCell.NumberingSubElement(m_originCoordination, m_fLength, lpParam->nShape[0], lpParam->szDomainMat[0]);
446  if (x == 0)
447  m_nAtomFirstLayer += nAtom;
448  if (x == 1 && m_bConsiderBoundaryCondition[_X])
449  m_nAtomFirstLayer += nAtom;
451  {
452  if (x == maxX - 2)
453  m_nAtomLastLayer += nAtom;
454  }
455  else
456  {
457  if (x == maxX - 1)
458  m_nAtomLastLayer += nAtom;
459  }
460  }
461  else
462  {
463  int periodicDirection = CKNGeometricAtom::NONE;
464 
465  periodicDirection = GetPeriodicDirection(x, y, z, maxX, maxY, maxZ);
466  UnitCell.SetPeriodic(true, periodicDirection);
467  }
468 
469  UnitCell.SetSubDomainMaterial(lpParam);
470  UnitCell.SetAssignIndex(x, y, z);
472  m_vectUnitCell.push_back(UnitCell);
473 
474  currentPos.SetOffset(0, 0, fUnitcellLength[_Z]);
475  }
476  currentPos.SetOffset(0, fUnitcellLength[_Y], 0);
477  }
478  currentPos.SetOffset(fUnitcellLength[_X], 0, 0);
479  }
480 }
481 
482 #define FIND_TARGET_INDEX(targetC, AssignIndex, AssigneCount, direction)\
483 if (m_bConsiderBoundaryCondition[direction]) \
484 {\
485  if (0 == AssignIndex[direction])\
486  {\
487  targetC = AssigneCount[direction] - 2; \
488  }\
489  else if (AssigneCount[direction] - 1 == AssignIndex[direction])\
490  {\
491  targetC = 1;\
492  }\
493 }\
494 
495 
499 {
500  int i, nSize = m_vectUnitCell.size();
501  int maxX, maxY, maxZ;
502  double targetCx, targetCy, targetCz;
503  double *pfAssignIndex = NULL;
504  double fCopyIndex = -1;
505 
507  return;
508 
509  maxX = (int)floor(m_fAssignedCount[_X]);
510  maxY = (int)floor(m_fAssignedCount[_Y]);
511  maxZ = (int)floor(m_fAssignedCount[_Z]);
512 
513  for (i = 0; i < nSize; ++i)
514  {
515  if (m_vectUnitCell[i].IsPeriodicUnitCell())
516  {
517  pfAssignIndex = m_vectUnitCell[i].GetAssignedIndex();
518  targetCx = pfAssignIndex[_X];
519  targetCy = pfAssignIndex[_Y];
520  targetCz = pfAssignIndex[_Z];
521 
522  FIND_TARGET_INDEX(targetCy, pfAssignIndex, m_fAssignedCount, _Y);
523  FIND_TARGET_INDEX(targetCz, pfAssignIndex, m_fAssignedCount, _Z);
524 
526  {
527 #ifdef DISABLE_MPI_ROUTINE
528  FIND_TARGET_INDEX(targetCx, pfAssignIndex, m_fAssignedCount, _X);
529 #else //DISABLE_MPI_ROUTINE
531  {
532  FIND_TARGET_INDEX(targetCx, pfAssignIndex, m_fAssignedCount, _X);
533  }
534  else
535  {
536  if( 0 == pfAssignIndex[_X] && CKNMPIManager::IsRootRank())
537  {
538  targetCx = -1;
539  if( false == bXAxis)
540  continue;
541  }
542  else if (m_fAssignedCount[_X] - 1 == pfAssignIndex[_X]
544  {
545  targetCx = pfAssignIndex[_X]+1;
546  if( false == bXAxis)
547  continue;
548  }
549  }
550 #endif //DISABLE_MPI_ROUTINE
551  }
552 
553  fCopyIndex = CKNGeometricUnitCell::CalculatingIndex(targetCx, targetCy, targetCz, m_fAssignedCount);
554 #ifndef DISABLE_MPI_ROUTINE
556  {
557  if( false == bXAxis )
558  m_vectUnitCell[i].CopyInnerAtomIndex(m_vectUnitCell[(unsigned int)fCopyIndex]);
559  }
560  else
561  {
562  if (fCopyIndex < 0 && m_vectPrevUnitCell.size() > 0)
563  {
564  m_vectUnitCell[i].CopyInnerAtomIndex(m_vectPrevUnitCell[(unsigned int)(fCopyIndex + m_fAssignedCount[_Y] * m_fAssignedCount[_Z])]);
565  }
566  else if (fCopyIndex >= maxX * maxY * maxZ && m_vectNextUnitCell.size() > 0)
567  {
568  m_vectUnitCell[i].CopyInnerAtomIndex(m_vectNextUnitCell[(unsigned int)(fCopyIndex - m_fAssignedCount[_X] * m_fAssignedCount[_Y] * m_fAssignedCount[_Z])]);
569  }
570  else
571  {
572  if( false == bXAxis )
573  m_vectUnitCell[i].CopyInnerAtomIndex(m_vectUnitCell[(unsigned int)fCopyIndex]);
574  }
575  }
576 #else //DISABLE_MPI_ROUTINE
577  {
578  if( false == bXAxis )
579  m_vectUnitCell[i].CopyInnerAtomIndex(m_vectUnitCell[(unsigned int)fCopyIndex]);
580  }
581 #endif //DISABLE_MPI_ROUTINE
582  }
583  }
584 }
585 
586 
587 
596 bool CKNGeometricShape::RefillPeriodicBinding(CKNMatrixOperation::CKNCSR *pResult, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam, LPNEIGHBOR_MAP_INFO lpMapInfo, unsigned int nRepeatIndex, double fKValue[3])
597 {
598  unsigned int i, j, k;
599  double *pDirection = m_shapDirection.GetDirectionAll();
600  double kTotal = 0;
601  CKNComplex calcuResult;
602  double fNeighborIndex[4];
603  bool bRtn = false;
604 
605  if( 0 == fKValue[0] && 0 == fKValue[1] && 0 == fKValue[2] )
606  {
607  bRtn = true;
608  return bRtn;
609  }
610 
611  for (i = 0; i < lpMapInfo->fItemCount; ++i)
612  {
613  int nMatrixIndex = 0;
614  double kkTotal = kTotal;
615  CKNGeometricAtom* pCurrentAtom = GetAtomByIndex(lpMapInfo->pfID[i]);
616 
617  for (j = 0; j < 4; ++j)
618  fNeighborIndex[j] = lpMapInfo->pfNeighbor[j][i];
619  //fNeighborIndex[0] = lpMapInfo->pfNeighbor_1[i]; fNeighborIndex[1] = lpMapInfo->pfNeighbor_2[i]; fNeighborIndex[2] = lpMapInfo->pfNeighbor_3[i]; fNeighborIndex[3] = lpMapInfo->pfNeighbor_4[i];
620 
621  /* if (CKNGeometricAtom::C == lpMapInfo->pAtomType[i])
622  nMatrixIndex = 4;*/
623 
624  for (j = 0; j < 4; j++)
625  {
626  double kTotal = 0;
627 
628  if (ATOM_DEFAULT_INDEX != fNeighborIndex[j] && true == pCurrentAtom->IsPeriodicCoupling(j))
629  {
630  CKNGeometricCoordination coupleCoordination = pCurrentAtom->GetNeighborCoordination(j);
631  int periodicDirection = pCurrentAtom->GetNeighborPeriodicDirection(j);
632 
633  if (coupleCoordination == pCurrentAtom->GetCoordination())
634  continue;
635 
636  for (k = 0; k < 3; k++)
637  {
638  int nPeriodic = periodicDirection & (int)pow((double)2, (int)k);
639 
640  if (0 != nPeriodic)
641  {
642  double fPhase = GetKPhaseSign(pCurrentAtom->GetCoordination().GetCoordination((AXIS_DEFINE)k),
643  coupleCoordination.GetCoordination((AXIS_DEFINE)k));
644  kTotal += (fPhase * fKValue[k] * PI_VALUE);
645  }
646  }
647  calcuResult.SetComplexNumber(cos(kTotal), sin(kTotal));
648 
649  pResult->AreaScalarMultiple(i * ORBITALS, ORBITALS, (unsigned int)fNeighborIndex[j] * ORBITALS, ORBITALS, calcuResult);
650  }
651  }
652  }
653 
654  bRtn = true;
655  return bRtn;
656 }
657 
663 double CKNGeometricShape::GetKPhaseSign(double fAtomPos, double fPeriodicAtomPos)
664 {
665  double fRtn = 1.;
666 
667  if( fPeriodicAtomPos - fAtomPos > 0 )
668  fRtn = -1.;
669 
670  return fRtn;
671 }
672 
678 {
679  CKNGeometricAtom *pRtn = NULL;
680  int nSize, i;
681 
682  nSize = m_vectUnitCell.size();
683  for( i = 0; i < nSize ; ++ i)
684  {
685  pRtn = m_vectUnitCell[i].GetSubElementByID(fID);
686  if( NULL != pRtn && false == pRtn->IsPeriodicAtom())
687  return pRtn;
688  }
689 
690  return pRtn;
691 }
692 
697 {
698  /*TODO: changing input parameter sqrtf -> sqrt(from all source code)*/
699  double fR = sqrt(lpParam->fDirection[0] * lpParam->fDirection[0] + lpParam->fDirection[1] * lpParam->fDirection[1] + lpParam->fDirection[2] * lpParam->fDirection[2]);
700 
701  lpParam->fDegree[PHI_DEGREE] = PI_VALUE/2 - acos(lpParam->fDirection[2] / fR);
702  lpParam->fDegree[THETA_DEGREE] = atan(lpParam->fDirection[1] / lpParam->fDirection[0]);
703 }
704 
711 {
712  CKNMatrixOperation::CKNDMatrix matrixRotate;
713 
714  matrixRotate.BuildMatrixFirst(3, 3);
715 
716  matrixRotate.SetElement(0, 0, cos(fDegree[THETA_DEGREE]) * cos(fDegree[PHI_DEGREE]), 0);
717  matrixRotate.SetElement(0, 1, -sin(fDegree[THETA_DEGREE]), 0);
718  matrixRotate.SetElement(0, 2, -cos(fDegree[THETA_DEGREE])*sin(fDegree[PHI_DEGREE]), 0);
719 
720  matrixRotate.SetElement(1, 0, sin(fDegree[THETA_DEGREE]) * cos(fDegree[PHI_DEGREE]), 0);
721  matrixRotate.SetElement(1, 1, cos(fDegree[THETA_DEGREE]), 0);
722  matrixRotate.SetElement(1, 2, -sin(fDegree[THETA_DEGREE])*sin(fDegree[PHI_DEGREE]), 0);
723 
724  matrixRotate.SetElement(2, 0, sin(fDegree[PHI_DEGREE]), 0);
725  matrixRotate.SetElement(2, 1, 0, 0);
726  matrixRotate.SetElement(2, 2, cos(fDegree[PHI_DEGREE]), 0);
727 
728  matrixRotate.TrnasPos();
729 
730  pMatrixNbr->TrnasPos();
731  CKNMatrixOperation::MMMul(&matrixRotate, pMatrixNbr, pMatrixResult);
732  pMatrixResult->TrnasPos();
733 }
734 
736 {
737  int i, nSize = m_vectUnitCell.size();
738 
739  for (i = 0; i < nSize; ++i)
740  {
741  m_vectUnitCell[i].CheckingNeighborCandiate(m_fAssignedCount, m_bFrontFace, m_bBackendFace);
742  }
743 }
744 
751 {
752  bool bRtn = false;
753  char szMsg[1024], szAdditional[1024];
754  unsigned int i, j, k, nSize, nAtomSize, nNeighborSize, nMapIndex = 0;;
755  FILE *out = NULL;
756  char szFileName[1024];
757  double fNeighborAtomID = ATOM_DEFAULT_INDEX;
758  bool bPeriodic = false;
759  char szTemp[1024], szMaterial[1024], szTemp2[1024];
760 #ifndef DISABLE_MPI_ROUTINE
761  MPI_Request req;
762  double fTemp = 1;
763 #endif //DISABLE_MPI_ROUTINE
764 
765  BuildGeoFileName(szTemp, lpParam);
766 
767  InitMapInfo(lpMapInfo);
768  if (true == lpParam->bSaveMapFile)
769  {
770 #ifdef _WIN32
771  _mkdir("result");
772  sprintf(szFileName, "result\\%s", szTemp);
773 #else
774  mkdir("result", 0777);
775  sprintf(szFileName, "result/%s", szTemp);
776 #endif
777 
778 
779 #ifdef DISABLE_MPI_ROUTINE
780  out = fopen(szFileName, "wt");
781 #else //DISABLE_MPI_ROUTINE
782 
784  {
785  CKNIPCCUtility::ShowMsg("-Save atom map to file.\n");
786  out = fopen(szFileName, "wt");
787  }
788  else
789  {
791  out = fopen(szFileName, "at");
792  }
793 #endif //DISABLE_MPI_ROUTINE
794  }
795 
796  nSize = m_vectUnitCell.size();
797 
799  {
800  if (NULL != out)
801  fclose(out);
803  return bRtn;
804  }
805 
806 #ifdef SHOW_ATOM_MAP_RESULT_ON_SCREEN
808  CKNIPCCUtility::ShowMsg("Atom list--------------------------------------\n");
809 #endif //SHOW_ATOM_MAP_RESULT_ON_SCREEN
810  for (i = 0; i < nSize; ++i)
811  {
812  double fIDForDebug;
813  nAtomSize = m_vectUnitCell[i].GetSubElementSize();
814 
815  for (j = 0; j < nAtomSize; ++j)
816  {
817  CKNGeometricAtom *pAtom = m_vectUnitCell[i].GetSubElementAt(j);
818  if (ATOM_DEFAULT_INDEX == pAtom->GetID() || true == pAtom->IsPeriodicAtom())
819  continue;
820 
821  CKNGeometricCoordination coord = pAtom->GetCoordination();
822  fIDForDebug = pAtom->GetID();
823 
824  sprintf(szAdditional, "");
825  sprintf(szMaterial, "");
826  nNeighborSize = pAtom->GetNeighborCount();
827  for (k = 0; k < nNeighborSize; ++k)
828  {
829  fNeighborAtomID = pAtom->GetNeighborAtomID(k);
830 
831  if (ATOM_DEFAULT_INDEX == fNeighborAtomID)
832  bPeriodic = false;
833  else
834  bPeriodic = pAtom->IsPeriodicCoupling(k);
835 
836 #ifdef NOSHOW_MINORS_ONE
837  if (ATOM_DEFAULT_INDEX == pAtom->GetNeighborAtom(k))
838  {
839  sprintf(szTemp, "\t");
840  sprintf(szTemp2, "\t", (int)pAtom->GetMaterialMaterialNumber(k));
841  }
842  else
843 #endif //NOSHOW_MINORS_ONE
844  {
845  sprintf(szTemp, "\t%7.0f", fNeighborAtomID);
846  if (-1 == fNeighborAtomID)
847  sprintf(szTemp2, "\t%7.0d", -1);
848  else
849  sprintf(szTemp2, "\t%7.0d", (int)pAtom->GetMaterialMaterialNumber(k));
850  }
851  strcat(szAdditional, szTemp);
852  strcat(szMaterial, szTemp2);
853 
854  lpMapInfo->pfNeighbor[k][nMapIndex] = fNeighborAtomID;
855  lpMapInfo->pbPeriodicCondition[k][nMapIndex] = bPeriodic;
856  lpMapInfo->pNeighborMaterial[k][nMapIndex] = pAtom->GetMaterialMaterialNumber(k);
857  }
858 
859  sprintf(szMsg, "%-7.0f\t%d\t%d\t%15.6f\t%15.6f\t%15.6f%s%s\n", pAtom->GetID(), (int)pAtom->GetType(), (int)pAtom->GetMaterialNumber(),
860  coord.GetCoordination(_X),
861  coord.GetCoordination(_Y),
862  coord.GetCoordination(_Z),
863  szAdditional, szMaterial);
864 
865  lpMapInfo->fItemCount++;
866  lpMapInfo->pAtomType[nMapIndex] = pAtom->GetType();
867  lpMapInfo->pMaterialNumber[nMapIndex] = pAtom->GetMaterialNumber();
868  lpMapInfo->pDomainMaterialNumber[nMapIndex] = pAtom->GetDomainMaterialNumber();
869  lpMapInfo->pfID[nMapIndex] = pAtom->GetID();
870  lpMapInfo->pfX_Coordination[nMapIndex] = coord.GetCoordination(_X);
871  lpMapInfo->pfY_Coordination[nMapIndex] = coord.GetCoordination(_Y);
872  lpMapInfo->pfZ_Coordination[nMapIndex] = coord.GetCoordination(_Z);
873  nMapIndex++;
874 
875  if (true == lpParam->bSaveMapFile && NULL != out)
876  fputs(szMsg, out);
877 #ifdef SHOW_ATOM_MAP_RESULT_ON_SCREEN
879 #endif //SHOW_ATOM_MAP_RESULT_ON_SCREEN
880 
881  }
882  }
883 
884  if (true == lpParam->bSaveMapFile && NULL != out)
885  {
886  fclose(out);
887 #ifndef DISABLE_MPI_ROUTINE
890 #endif //DISABLE_MPI_ROUTINE
891  }
892 
893  bRtn = true;
894  return bRtn;
895 }
896 
902 {
903 
904  shape.SetDirection(1, 0, 0);
905  shape.SetLength(lpParam->fShapeLength[0][_X], lpParam->fShapeLength[0][_Y], lpParam->fShapeLength[0][_Z]);
906  shape.SetOriginCoordination(lpParam->fOrigin[0][_X], lpParam->fOrigin[0][_Y], lpParam->fOrigin[0][_Z]);
907  shape.SetMaterialType(lpParam->szDomainMat[0]);
908  shape.SetShapeForm(lpParam->szShape[0]);
912 #ifdef DISABLE_MPI_ROUTINE
913  shape.SetFrontFace(true);
914  shape.SetBackendFace(true);
915 #else //DISABLE_MPI_ROUTINE
917  shape.SetFrontFace(true);
919  shape.SetBackendFace(true);
920 #endif //DISABLE_MPI_ROUTINE
921 }
922 
928 {
929  unsigned int i;
930  CKNGeometricCoordination coordination;
931 
934 
935 
936  if (!strcmp(lpParam->szStructureType, CUBIC))
937  {
940  lpParam->bNeedRotate = false;
941  }
942  else if (!strcmp(lpParam->szStructureType, ZB))
943  {
944  lpParam->bNeedRotate = true;
948 
949  if (100 == lpParam->nDirectionSingle)
950  lpParam->bNeedRotate = false;
951  }
952 
953  if (NULL != m_pUnitCellInfo)
954  {
959 
960  if (lpParam->bNeedRotate)
961  {
962  CalculateDegree(lpParam);
963  BuildRotationMatrix(lpParam->fDegree);
964  m_pUnitCellInfo->RotateNeighbor(&CKNGeometricShape::m_rotationMatrix);
965  }
966  }
967  else
968  return false;
969 
970  for (i = 0; i < m_pUnitCellInfo->GetAnionCount(); ++i)
971  {
974  coordination.GetCoordination(_X),
975  coordination.GetCoordination(_Y),
976  coordination.GetCoordination(_Z));
977  }
978 
979  for (i = 0; i < m_pUnitCellInfo->GetCationCount(); ++i)
980  {
983  coordination.GetCoordination(_X),
984  coordination.GetCoordination(_Y),
985  coordination.GetCoordination(_Z));
986  }
987 
988  for (i = 0; i < (unsigned int)m_pUnitCellInfo->GetA2CNeighborCount(); ++i)
989  {
992  coordination.GetCoordination(_X),
993  coordination.GetCoordination(_Y),
994  coordination.GetCoordination(_Z));
995 
996  }
997 
998  for (i = 0; i < (unsigned int)m_pUnitCellInfo->GetC2ANeighborCount(); i++)
999  {
1002  coordination.GetCoordination(_X),
1003  coordination.GetCoordination(_Y),
1004  coordination.GetCoordination(_Z));
1005  }
1006 
1008 
1009  return true;
1010 }
1011 
1017 {
1018  bool bRtn = false;
1019  unsigned int i;
1020 
1021  ALLOC_WITH_NULL_INIT(lpMapInfo->pfID, double, (size_t)fSize);
1022  ALLOC_WITH_NULL_INIT(lpMapInfo->pAtomType, CKNGeometricAtom::ATOM_TYPE, (size_t)fSize);
1023  ALLOC_WITH_NULL_INIT(lpMapInfo->pMaterialNumber, MATERIAL_INDEX, (size_t)fSize);
1024  ALLOC_WITH_NULL_INIT(lpMapInfo->pDomainMaterialNumber, MATERIAL_INDEX, (size_t)fSize);
1025  ALLOC_WITH_NULL_INIT(lpMapInfo->pfX_Coordination, double, (size_t)fSize);
1026  ALLOC_WITH_NULL_INIT(lpMapInfo->pfY_Coordination, double, (size_t)fSize);
1027  ALLOC_WITH_NULL_INIT(lpMapInfo->pfZ_Coordination, double, (size_t)fSize);
1028 
1029  for (i = 0; i < MAX_NEIGHBOR; ++i)
1030  {
1031  ALLOC_WITH_NULL_INIT(lpMapInfo->pfNeighbor[i], double, (size_t)fSize);
1032  ALLOC_WITH_NULL_INIT(lpMapInfo->pbPeriodicCondition[i], bool, (size_t)fSize);
1033  ALLOC_WITH_NULL_INIT(lpMapInfo->pNeighborMaterial[i], MATERIAL_INDEX, (size_t)fSize);
1034  }
1035 
1036  bRtn = true;
1037  return bRtn;
1038 }
1039 
1044 {
1045  unsigned int i;
1046 
1047  FREE_MEM(lpMapInfo->pfID);
1048  FREE_MEM(lpMapInfo->pAtomType);
1049  FREE_MEM(lpMapInfo->pMaterialNumber);
1050  FREE_MEM(lpMapInfo->pDomainMaterialNumber);
1051  FREE_MEM(lpMapInfo->pfX_Coordination);
1052  FREE_MEM(lpMapInfo->pfY_Coordination);
1053  FREE_MEM(lpMapInfo->pfZ_Coordination);
1054 
1055  for (i = 0; i < MAX_NEIGHBOR; ++i)
1056  {
1057  FREE_MEM(lpMapInfo->pfNeighbor[i]);
1058  FREE_MEM(lpMapInfo->pbPeriodicCondition[i]);
1059  FREE_MEM(lpMapInfo->pNeighborMaterial[i]);
1060  }
1061 }
1062 
1067 {
1068  unsigned int i;
1069 
1070  lpMapInfo->pfID = NULL;
1071  lpMapInfo->pAtomType = NULL;
1072  lpMapInfo->pfX_Coordination = NULL;
1073  lpMapInfo->pfY_Coordination = NULL;
1074  lpMapInfo->pfZ_Coordination = NULL;
1075  lpMapInfo->fItemCount = 0;
1076 
1077  for (i = 0; i < MAX_NEIGHBOR; ++i)
1078  {
1079  lpMapInfo->pfNeighbor[i] = NULL;
1080  lpMapInfo->pbPeriodicCondition[i] = NULL;
1081  lpMapInfo->pNeighborMaterial[i] = NULL;
1082  }
1083 }
1084 
1089 {
1090  int i, nSize = m_vectUnitCell.size();
1091 
1092  for (i = 0; i < nSize; ++i)
1093  m_vectUnitCell[i].ShiftAtomID(fShift);
1094 }
1095 
1097 {
1098  double fShift = CKNMPIManager::GetCurrentRank() * floor(m_fAssignedCount[0]) * floor(m_fAssignedCount[1]) * floor(m_fAssignedCount[2]);
1099  int i, nSize = m_vectUnitCell.size();
1100  double fSendingCount = floor(m_fAssignedCount[_Y]) * floor(m_fAssignedCount[_Z]);
1101  double *pSendBuffer = NULL;
1102  int nAtomCountInCell = CKNGeometricAtomFactory::GetAtomCountInUnitcell();
1103  double *pReceiveBuffer = (double*)malloc(sizeof(double)*(fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell));
1104  MPI_Request req[2];
1105  double fAtomID = 0;
1106 
1108  {
1110  FREE_MEM(pReceiveBuffer);
1111  return;
1112  }
1113 
1114 
1117  {
1119  CKNMPIManager::SendDoubleBufferSync(1, &fAtomID, 1, &req[0]);
1120  }
1121  else
1122  {
1124  m_fAtomIDStartIndex = fAtomID;
1125  for (i = 0; i < nSize; ++i)
1126  m_vectUnitCell[i].ShiftAtomID(fAtomID);
1127 
1129  {
1132  }
1134  {
1136  m_fTotalAtomCountinMPI = fAtomID;
1137  }
1138  }
1139 
1142 
1143 
1146  {
1147  pSendBuffer = Serialize(floor(m_fAssignedCount[_X])-1);
1148  CKNMPIManager::SendDoubleBufferSync(CKNMPIManager::GetCurrentRank() + 1, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1149  }
1150  else
1151  {
1152  CKNMPIManager::ReceiveDoubleBufferSync(CKNMPIManager::GetCurrentRank() -1, pReceiveBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[0]);
1153  Deserialize(&m_vectPrevUnitCell, pReceiveBuffer, true);
1154 
1156  {
1157  pSendBuffer = Serialize(floor(m_fAssignedCount[_X])-1);
1158  CKNMPIManager::SendDoubleBufferSync(CKNMPIManager::GetCurrentRank() + 1, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1159  }
1160  else
1161  {
1163  {
1164  pSendBuffer = Serialize(floor(m_fAssignedCount[_X])-2);
1165  CKNMPIManager::SendDoubleBufferSync(0, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1166  }
1167  }
1168  }
1169 
1171  {
1172  CKNMPIManager::ReceiveDoubleBufferSync(CKNMPIManager::GetTotalNodeCount() - 1, pReceiveBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[0]);
1173  Deserialize(&m_vectPrevUnitCell, pReceiveBuffer, true);
1174  }
1175  FREE_MEM(pSendBuffer);
1176 
1179  {
1180  pSendBuffer = Serialize(0);
1181  CKNMPIManager::SendDoubleBufferSync(CKNMPIManager::GetCurrentRank() - 1, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1182  }
1183  else
1184  {
1185  CKNMPIManager::ReceiveDoubleBufferSync(CKNMPIManager::GetCurrentRank() + 1, pReceiveBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[0]);
1186  Deserialize(&m_vectNextUnitCell, pReceiveBuffer, false);
1187 
1189  {
1190  pSendBuffer = Serialize(0);
1191  CKNMPIManager::SendDoubleBufferSync(CKNMPIManager::GetCurrentRank() - 1, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1192  }
1193  else
1194  {
1196  {
1197  pSendBuffer = Serialize(1);
1198  CKNMPIManager::SendDoubleBufferSync(CKNMPIManager::GetTotalNodeCount() - 1, pSendBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[1]);
1199  }
1200  }
1201  }
1202 
1204  {
1205  CKNMPIManager::ReceiveDoubleBufferSync(0, pReceiveBuffer, (int)fSendingCount*UNITCELL_WRITING_BLOCK_SIZE*nAtomCountInCell, &req[0]);
1206  Deserialize(&m_vectNextUnitCell, pReceiveBuffer, false);
1207  }
1208 
1209  FREE_MEM(pSendBuffer);
1210  FREE_MEM(pReceiveBuffer);
1211 }
1212 
1216 double* CKNGeometricShape::Serialize(double fXLayer)
1217 {
1218  double *pBuffer = NULL;
1219  double fSendingCount = floor(m_fAssignedCount[_Y]) * floor(m_fAssignedCount[_Z]);
1220  int i, nSize = m_vectUnitCell.size();
1221  int fPos = 0;
1222  int nAtomCountInCell = CKNGeometricAtomFactory::GetAtomCountInUnitcell();
1223 
1224  pBuffer = (double*)malloc(sizeof(double)*(fSendingCount*nAtomCountInCell*UNITCELL_WRITING_BLOCK_SIZE));
1225 
1226  for (i = (int)(fXLayer * floor(fSendingCount)); i < fXLayer * fSendingCount + floor(fSendingCount); ++i)
1227  {
1228 
1229  m_vectUnitCell[i].Serialize(pBuffer + fPos);
1230  fPos += nAtomCountInCell*UNITCELL_WRITING_BLOCK_SIZE;
1231  }
1232 
1233  return pBuffer;
1234 }
1235 
1241 void CKNGeometricShape::Deserialize(std::vector<CKNGeometricUnitCell> *pVectUnitCell, double *pBuffer, bool bFrontSide)
1242 {
1243  double fReceivingCount = floor(m_fAssignedCount[_Y]) * floor(m_fAssignedCount[_Z]);
1244  int i, nSize = m_vectUnitCell.size();
1245  int fPos = 0;
1246  int nAtomCountInCell = CKNGeometricAtomFactory::GetAtomCountInUnitcell();
1247  double fID;
1248 
1249  if( bFrontSide )
1250  fID = -fReceivingCount;
1251  else
1252  fID = m_vectUnitCell[m_vectUnitCell.size()-1].GetID() + 1;
1253 
1254  for (i = 0 ; i < floor(fReceivingCount); ++i)
1255  {
1256  CKNGeometricUnitCell unitcell;
1257 
1258  unitcell.SetID(fID++);
1259  unitcell.Deserialize(pBuffer + fPos);
1260  pVectUnitCell->push_back(unitcell);
1261  fPos += nAtomCountInCell*UNITCELL_WRITING_BLOCK_SIZE;
1262  }
1263 }
1264 
1269 {
1271 
1272  m_rotationMatrix.SetElement(0, 0, cos(fDegree[THETA_DEGREE]) * cos(fDegree[PHI_DEGREE]), 0);
1273  m_rotationMatrix.SetElement(0, 1, -sin(fDegree[THETA_DEGREE]), 0);
1274  m_rotationMatrix.SetElement(0, 2, -cos(fDegree[THETA_DEGREE])*sin(fDegree[PHI_DEGREE]), 0);
1275 
1276  m_rotationMatrix.SetElement(1, 0, sin(fDegree[THETA_DEGREE]) * cos(fDegree[PHI_DEGREE]), 0);
1277  m_rotationMatrix.SetElement(1, 1, cos(fDegree[THETA_DEGREE]), 0);
1278  m_rotationMatrix.SetElement(1, 2, -sin(fDegree[THETA_DEGREE])*sin(fDegree[PHI_DEGREE]), 0);
1279 
1280  m_rotationMatrix.SetElement(2, 0, sin(fDegree[PHI_DEGREE]), 0);
1281  m_rotationMatrix.SetElement(2, 1, 0, 0);
1282  m_rotationMatrix.SetElement(2, 2, cos(fDegree[PHI_DEGREE]), 0);
1283 
1285 }
1286 
1292 {
1293  char szTemp[1024];
1294  unsigned int i;
1295 
1296 
1297  sprintf(pszFileName, "Geo_%d_%d%d%d_", lpParam->nDirectionSingle, lpParam->bConsiderBoundaryCondition[0] ? 1 : 0, lpParam->bConsiderBoundaryCondition[1] ? 1 : 0, lpParam->bConsiderBoundaryCondition[2] ? 1 : 0);
1298 
1299  if (!strcmp(lpParam->szShape[0], "Box"))
1300  strcpy(szTemp, "B");
1301  else if (!strcmp(lpParam->szShape[0], "Cylinder"))
1302  strcpy(szTemp, "C");
1303 
1304  strcat(pszFileName, szTemp);
1305 
1306  for (i = 0; i < (unsigned int)lpParam->nSubDomainNumber; ++i)
1307  {
1308  if (!strcmp(lpParam->szShape[i + 1], "Box"))
1309  strcpy(szTemp, "B");
1310  else if (!strcmp(lpParam->szShape[i + 1], "Cylinder"))
1311  strcpy(szTemp, "C");
1312 
1313  strcat(pszFileName, szTemp);
1314  }
1315 }
double * pfZ_Coordination
An array of Z coordination.
unsigned int m_ShapeForm
Shape form.
std::vector< CKNGeometricUnitCell > m_vectNextUnitCell
Back end edge unit cell that copy from next side node.
MATERIAL_INDEX
Definition: CKNGlobal.h:106
#define CYLINDER_SHAPE
Definition: CKNGlobal.h:89
MATERIAL_INDEX m_MaterialType
Material type of shape.
Meterial parameter definition.
#define PHI_DEGREE
Definition: CKNGlobal.h:80
static CKNGeometricUnitCellInfo_cubic m_UnitCellInfo_cubic
bool SetMapInfoSize(LPNEIGHBOR_MAP_INFO lpMapInfo, double fSize)
Building Hamiltonian part.
void SetDirection(double *fDirection)
Set direciton information.
Class for calculating zincblend parameter.
static void ShowMsg(char *pszBuffer)
Show message.
bool * pbPeriodicCondition[MAX_NEIGHBOR]
An array of Neighbor no 1 bondary condition.
static void SetNeighborCoordination(CKNGeometricAtom::NEIGHOR_RELATION type, double x, double y, double z)
Setting neighbor coordination.
void ExchangeAtomInfoBetweenNode()
Get start index of atom in shape, using in MPI running enviroment.
void SetMaterialType(MATERIAL_INDEX type)
Get maetrial typpe of shap.
void SetConsideringBoundaryCondition(bool bConsider, AXIS_DEFINE direction)
Get bondary condition of shape.
CKNGeometricDirection m_shapDirection
Direction of shape.
MATERIAL_INDEX GetDomainMaterialNumber()
Get atom material type.
static bool SetAtomAndNeighborInformation(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set neighbor information to AtomFactory.
Factory class for create CKNGeometricAtom instance.
void BuildNeighborInformation()
Find neighbor of each atom.
ATOM_TYPE GetType()
Data and operation representation of Matrix.
int GetNeighborPeriodicDirection(int nIndex)
Get neighbor coupling periodic direction if has coupling with periodic atom.
Class for coordination.
unsigned int GetNeighborCount()
std::vector< CKNGeometricAtom * > m_vectSurfaceAtom
Class for Geometric unit cell.
static void BroadcastDouble(double *pValue, unsigned int nSize, int nRootRank=0, MPI_Comm comm=MPI_COMM_NULL)
Broadcst boolean value.
double * pfX_Coordination
An array of X coordination.
Definition: CKNGlobal.h:105
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.
static void BuildRotationMatrix(double fDegree[2])
Build rotation matrix for given direction.
static void ResetSubElementID()
Get unit cell length.
void SetOriginCoordination(double x, double y, double z)
Building Geometric part.
void Deserialize(std::vector< CKNGeometricUnitCell > *pVectUnitCell, double *pBuffer, bool bFrontSide)
Deerialize unitcells from double array.
Data and operation representation of CSR(Compressed Sparse Row)
MATERIAL_INDEX GetMaterialMaterialNumber(unsigned int nIndex)
Get Neighbor material type.
static void SetShapeInformation(CKNGeometricShape &shape, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set shape information(Length, material, bondary condition and so on)
void SetDirection(double x_axis, double y_axis, double z_axis)
Set direciton of shape.
std::vector< CKNGeometricUnitCell > m_vectPrevUnitCell
Front edge unit cell that copy from previous side node.
#define THETA_DEGREE
Definition: CKNGlobal.h:79
void SetLength(double lx, double ly, double lz)
Set length of shape.
bool m_bConsiderBoundaryCondition[3]
Bondary condition for each driection.
static IKNGeometricUnitCellInfo * m_pUnitCellInfo
Unitcell information pointer for using in class internal.
int nShape[NMAXDOMAIN]
Geometric Shape.
void SetDireciton(int nDirectionSingle)
Set direction information.
static int GetTotalNodeCount()
Definition: KNMPIManager.h:44
virtual void SetAtomCoordination()=0
Atom coordination setting.
double * GetDirectionAll()
Get direction information all.
MATERIAL_INDEX * pNeighborMaterial[MAX_NEIGHBOR]
An array of Neighbor material Number.
bool CalculateUnitcellCount()
Calculating unitcell count in shape.
void ArrangeAtom(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set atoms information(coordination, type) in unit cell.
void SetOffset(CKNGeometricCoordination coord)
To offset coordination.
static void SetAtomCoordination(CKNGeometricAtom::ATOM_TYPE type, double x, double y, double z)
Setting atom coordination.
Class for Atom.
void CheckingNeighborCandiate()
Checking neighbor unitcell by calculating index.
Definition: CKNGlobal.h:105
static double AllReduceDouble(double fNumber)
Do all reduce function with CKNComplex.
bool IsInBoundaryCondition(int x, int y, int z, int maxX, int maxY, int maxZ)
Check unitcell is in the bondary area or not.
virtual void SetNeighborCoordination()=0
Neighbor atom coordiantion setting.
double m_fAssignedCount[3]
Unitcell assigend count in shape for each direction.
Class for calculating parameter.
std::vector< CKNGeometricUnitCell > m_vectUnitCell
Array of unitcell in shape.
#define MAX_NEIGHBOR
Definition: CKNGlobal.h:86
Class for Geometric shape.
static void MMMul(CKNDMatrix *pMatrix, CKNDMatrix *pMatrixOperand, CKNDMatrix *pResult)
Matrix and matrix multiple operation.
bool AreaScalarMultiple(unsigned int nRowStart, unsigned int nRowCount, unsigned int nColumnStart, unsigned int nColumnCount, CKNComplex Scalar)
Scalar multiple operation to specific area.
void SetAssignIndex(double fXAssignIndex, double fYAssignIndex, double fZAssignIndex)
Get Assign index.
std::vector< CKNGeometricAtom * > * GetSurfaceAtomList()
double * Serialize(double fXLayer)
Serialize unitcells with specific later index to double array.
bool bNeedRotate
Calculation parameter that need to apply rotation matrix.
CKNGeometricCoordination m_originCoordination
Orign coordination of shape.
void FinalShape()
Finalize Shape variable.
void InitCoordination()
Initial Coordination information.
bool m_bBackendFace
Flag of back end face or not.
Definition: CKNGlobal.h:105
Common definition for Solver.
void SetPeriodic(bool bPeriodic, int periodicDirection)
To mark unit cell is periodic condition.
Class for Geometric unit cell for cubic.
Structure for save input command file parsing result.
double GetKPhaseSign(double fAtomPos, double fPeriodicAtomPos)
Calculating Phase sign.
double fShapeLength[NMAXDOMAIN][3]
Shap length x, y, z, direction.
double * pfY_Coordination
An array of Y coordination.
bool TrnasPos()
Transpos matrix.
AXIS_DEFINE
Definition: CKNGlobal.h:105
virtual void SetUnitCellSize(double fUnitcellSize[3])=0
Unitcell size setting.
double fItemCount
Item count at atom map.
double fDegree[2]
Rotation degree, this variable isn't input by command file. It is calculated by module.
CKNGeometricCoordination GetNeighborCoordination(int nIndex)
Get neighbor coordination.
static double GetSubElementID()
Reset SubElement ID to Zero.
Iterface for Unitcell information.
bool ConstructMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Extract atom information from runtime objects.
bool SetElement(unsigned int nRow, unsigned int nColumn, CKNComplex element)
Set matrix elements value.
#define ATOM_DEFAULT_INDEX
Atom index default value that empty atom instance.
Definition: CKNGlobal.h:53
double fDirection[3]
Direction x, y, z.
Definition: CKNGlobal.h:106
double m_fLength[3]
Building Geometric part.
double * pfNeighbor[MAX_NEIGHBOR]
An array of Neighbor no 1 index.
Class for Geometric shape.
unsigned int NumberingSubElement(CKNGeometricCoordination ShapeCoordination, double fLength[3], int nShapeType, char *pszDomainMatName)
Assign atom ID to sub element(atoms in unit cell)
bool bSaveMapFile
Save atom map or not.
char szDomainMat[NMAXDOMAIN][1024]
Material type.
int nSubDomainNumber
Numbers of Subdomain, except main domain.
#define BOX_SHAPE
Definition: CKNGlobal.h:88
#define UNITCELL_WRITING_BLOCK_SIZE
When serialize or deserialize how many data block converting.
Definition: CKNGlobal.h:66
void SetID(double fID)
bool FillUnitcell(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set bondary condition of shape.
void InitShape()
Initialize Shape variable.
int GetPeriodicDirection(int x, int y, int z, int maxX, int maxY, int maxZ)
Get periodic direction information.
double fUnitcellLength[3]
Unitcell length x, y, z direction.
void SetBackendFace(bool bBackendFace)
Check is this back end face side in MPI running enviroment.
static void SetLength(double fLength[3], double fOriginLength[3])
Set unit cell length.
double GetCoordination(AXIS_DEFINE coord)
Get coordination specific axis.
bool IsPeriodicAtom()
Set atom is periodic.
This class includes functions for matrix debugging.
char szStructureType[1024]
Structure type.
void SetShapeForm(unsigned int form)
Get form type of shape.
void SetFrontFace(bool bFrontFace)
Check is this front face side in MPI running enviroment.
static int GetCurrentRank()
Definition: KNMPIManager.h:42
Class for Geometric unit cell for cubic.
#define FIND_TARGET_INDEX(targetC, AssignIndex, AssigneCount, direction)
void SetSubDomainMaterial(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Set atoms information(coordination, type) in unit cell.
CKNGeometricAtom * GetAtomByIndex(double fID)
Get atom instance by ID.
Class for Atom.
double m_fTotalAtomCountinMPI
Total valid atom count in shape.
double * pfID
An array of atom ID.
#define ALLOC_WITH_NULL_INIT(pointer, data_type, data_size)
Definition: CKNGlobal.h:35
#define PI_VALUE
Pi definition.
Definition: CKNGlobal.h:77
static double CalculatingIndex(double fXAssignedIndex, double fYAssignedIndex, double fZAssignedIndex, double fAssignedCount[3])
Calulating unit cell index.
bool IsPeriodicCoupling(int nIndex)
Check is this periodic atom.
MATERIAL_INDEX GetMaterialNumber()
Get atom typpe.
unsigned int GetCationCount()
Get anion count in Unitcell.
int GetC2ANeighborCount()
Get neigbhor relation count.
void RotateNeighbor(CKNMatrixOperation::CKNDMatrix *pRotationMatrix)
Rotating neighbor coordination.
#define CUBIC
Definition: CKNGlobal.h:83
#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.
bool m_bFrontFace
Flag of front face or not.
double m_fAtomIDStartIndex
Start atom index in current Shape.
void RotateMatrix(CKNMatrixOperation::CKNDMatrix *pMatrixNbr, CKNMatrixOperation::CKNDMatrix *pMatrixResult, double fDegree[2])
Rotate matrix with calculated degree.
This class for complex operation and saving value.
Definition: KNComplex.h:18
MATERIAL_INDEX * pMaterialNumber
An array of Atom number.
void FreeUnitCellList()
Relase unitcell list.
MPI Mangement class.
static double GetLength(AXIS_DEFINE index)
CKNGeometricAtom::ATOM_TYPE * pAtomType
An array of atom type 0:A, 1:C.
CKNGeometricCoordination GetCoordination()
Get Domain atom material type.
void SetCoordination(CKNGeometricCoordination coordination)
Get coordination of unit cell.
void SetCoordination(CKNGeometricCoordination coordination)
Get coordination with double buffer.
void ArrangeUnitCell(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Arranging unitcell into shape.
static void CalculateDegree(CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Calculating degree from direction information.
static bool IsRootRank()
Get Total node count.
char szShape[NMAXDOMAIN][1024]
Geometric Shape.
#define ORBITALS
At Hamiltonian matrix one atom inserted 10 * 10.
Definition: CKNGlobal.h:54
#define ZB
Definition: CKNGlobal.h:82
unsigned int m_nAtomLastLayer
Last layer information for sending to next node.
CKNGeometricCoordination GetNeighborCoordination(CKNGeometricAtom::NEIGHOR_RELATION neighborType, unsigned int nIndex)
Get neigbhor atom coordination from Unitcell.
Class for Material Parameter.
void Deserialize(double *pBuffer)
Convert double buffer to unit cell data.
void SetUnitcellList(std::vector< CKNGeometricUnitCell > *pVect, std::vector< CKNGeometricUnitCell > *pVectPrev, std::vector< CKNGeometricUnitCell > *pVectNext)
Set unit cell list of shape to each unit cell.
void BuildGeoFileName(char *pszFileName, CKNCommandFileParser::LPINPUT_CMD_PARAM lpParam)
Make atom map naming.
static void SendDoubleBufferSync(int nTargetRank, double *pBuffer, int nSize, MPI_Request *req, MPI_Comm commWorld=MPI_COMM_NULL)
Sending buffer for double data array with sync.
void ShiftAtomID(double fShift)
Shift atom id in MPI running enviroment.
void SetComplexNumber(double fReal, double fImaginaray)
Set Complex number using real part and imaginary part.
Definition: KNComplex.cpp:59
MATERIAL_INDEX * pDomainMaterialNumber
An array of Domain Atom number.
int GetA2CNeighborCount()
Get neigbhor relation count.
bool BuildMatrixFirst(unsigned int nRow, unsigned int nColumn)
Building matrix elements.
CKNGeometricCoordination GetAtomCoordination(CKNGeometricAtom::ATOM_TYPE atomType, unsigned int nIndex)
Get Unitcell size x, y, z direction axis.
Structure for neighbor information.
bool bConsiderBoundaryCondition[3]
Considering bondary condition or not x, y, z direction.
double * GetUnitcCellSize()
Get cation count in Unitcell.
static CKNMatrixOperation::CKNDMatrix m_rotationMatrix
Rotation matrix for given direction.
double GetNeighborAtomID(unsigned int nIndex)
Get neighbor atom count.
static void SetNeighborNumber(unsigned int nNeighborNumber)
Get periodic direction information.
static CKNGeometricUnitCellInfo_zincblende m_UnitCellInfo_zincblende
void InitMapInfo(LPNEIGHBOR_MAP_INFO lpMapInfo)
Intilize map info data.
double fOrigin[NMAXDOMAIN][3]
Coordinator original coordinate.
static bool IsDeflationRoot()
Checking is root rank of Lanczos computation.
Definition: KNMPIManager.h:72
static void ReceiveDoubleBufferSync(int nSourceRank, double *pBuffer, int nSize, MPI_Request *req, MPI_Comm commWorld=MPI_COMM_NULL)
Receivinging buffer for double data array with sync.
unsigned int m_nAtomFirstLayer
Get Surface atom list.