Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CrystalUnitCell Class Reference

#include <G4CrystalUnitCell.hh>

Public Member Functions

 G4CrystalUnitCell (G4double sizeA, G4double sizeB, G4double sizeC, G4double alpha, G4double beta, G4double gamma, G4int spacegroup)
 
virtual ~G4CrystalUnitCell ()=default
 
G4int GetSpaceGroup () const
 
void SetSpaceGroup (G4int aInt)
 
theLatticeSystemType GetLatticeSystem ()
 
theBravaisLatticeType GetBravaisLattice ()
 
const G4ThreeVectorGetBasis (G4int idx) const
 
const G4ThreeVectorGetUnitBasis (G4int idx) const
 
G4ThreeVector GetSize () const
 
G4ThreeVector GetAngle () const
 
G4ThreeVector GetUnitBasisTrigonal ()
 
const G4ThreeVectorGetRecBasis (G4int idx) const
 
const G4ThreeVectorGetRecUnitBasis (G4int idx) const
 
G4ThreeVector GetRecSize () const
 
G4ThreeVector GetRecAngle () const
 
G4bool FillAtomicUnitPos (G4ThreeVector &pos, std::vector< G4ThreeVector > &vecout)
 
G4bool FillAtomicPos (G4ThreeVector &pos, std::vector< G4ThreeVector > &vecout)
 
G4bool FillElReduced (G4double Cij[6][6])
 
G4double ComputeCellVolume ()
 
G4double GetVolume () const
 
G4double GetRecVolume () const
 
G4double GetIntSp2 (G4int h, G4int k, G4int l)
 
G4double GetRecIntSp2 (G4int h, G4int k, G4int l)
 
G4double GetIntCosAng (G4int h1, G4int k1, G4int l1, G4int h2, G4int k2, G4int l2)
 

Protected Attributes

G4ThreeVector nullVec
 
G4ThreeVector theSize
 
G4ThreeVector theAngle
 
G4ThreeVector theUnitBasis [3]
 
G4ThreeVector theBasis [3]
 
G4ThreeVector theRecSize
 
G4ThreeVector theRecAngle
 
G4ThreeVector theRecUnitBasis [3]
 
G4ThreeVector theRecBasis [3]
 

Detailed Description

Definition at line 44 of file G4CrystalUnitCell.hh.

Constructor & Destructor Documentation

◆ G4CrystalUnitCell()

G4CrystalUnitCell::G4CrystalUnitCell ( G4double sizeA,
G4double sizeB,
G4double sizeC,
G4double alpha,
G4double beta,
G4double gamma,
G4int spacegroup )

Definition at line 33 of file G4CrystalUnitCell.cc.

35 : theSize(G4ThreeVector(sizeA, sizeB, sizeC)),
36 theAngle(G4ThreeVector(alpha, beta, gamma)),
37 theSpaceGroup(spacegroup)
38{
39 nullVec = G4ThreeVector(0., 0., 0.);
43
47
48 cosa = std::cos(alpha), cosb = std::cos(beta), cosg = std::cos(gamma);
49 sina = std::sin(alpha), sinb = std::sin(beta), sing = std::sin(gamma);
50
51 cosar = (cosb * cosg - cosa) / (sinb * sing);
52 cosbr = (cosa * cosg - cosb) / (sina * sing);
53 cosgr = (cosa * cosb - cosg) / (sina * sinb);
54
55 theVolume = ComputeCellVolume();
56 theRecVolume = 1. / theVolume;
57
58 theRecSize[0] = sizeB * sizeC * sina / theVolume;
59 theRecSize[1] = sizeC * sizeA * sinb / theVolume;
60 theRecSize[2] = sizeA * sizeB * sing / theVolume;
61
62 theRecAngle[0] = std::acos(cosar);
63 theRecAngle[1] = std::acos(cosbr);
64 theRecAngle[2] = std::acos(cosgr);
65
66 G4double x3, y3, z3;
67
68 switch (GetLatticeSystem(theSpaceGroup)) {
69 case Amorphous:
70 break;
71 case Cubic: // Cubic, C44 set
72 break;
73 case Tetragonal:
74 break;
75 case Orthorhombic:
76 break;
77 case Rhombohedral:
78 theUnitBasis[1].rotateZ(gamma - CLHEP::halfpi); // X-Y opening angle
79 // Z' axis computed by hand to get both opening angles right
80 // X'.Z' = cos(alpha), Y'.Z' = cos(beta), solve for Z' components
81 x3 = cosa, y3 = (cosb - cosa * cosg) / sing, z3 = std::sqrt(1. - x3 * x3 - y3 * y3);
82 theUnitBasis[2] = G4ThreeVector(x3, y3, z3).unit();
83 break;
84 case Monoclinic:
85 theUnitBasis[2].rotateX(beta - CLHEP::halfpi); // Z-Y opening angle
86 break;
87 case Triclinic:
88 theUnitBasis[1].rotateZ(gamma - CLHEP::halfpi); // X-Y opening angle
89 // Z' axis computed by hand to get both opening angles right
90 // X'.Z' = cos(alpha), Y'.Z' = cos(beta), solve for Z' components
91 x3 = cosa, y3 = (cosb - cosa * cosg) / sing, z3 = std::sqrt(1. - x3 * x3 - y3 * y3);
92 theUnitBasis[2] = G4ThreeVector(x3, y3, z3).unit();
93 break;
94 case Hexagonal: // Tetragonal, C16=0
95 theUnitBasis[1].rotateZ(30. * CLHEP::deg); // X-Y opening angle
96 break;
97 default:
98 break;
99 }
100
101 for (auto i : {0, 1, 2}) {
102 theBasis[i] = theUnitBasis[i] * theSize[i];
104 }
105}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
Hep3Vector & rotateX(double)
Hep3Vector unit() const
Hep3Vector & rotateZ(double)
G4ThreeVector theBasis[3]
G4ThreeVector theRecUnitBasis[3]
G4ThreeVector theRecBasis[3]
G4ThreeVector theUnitBasis[3]
G4ThreeVector theRecAngle
theLatticeSystemType GetLatticeSystem()
DLL_API const Hep3Vector HepZHat
DLL_API const Hep3Vector HepXHat
DLL_API const Hep3Vector HepYHat

◆ ~G4CrystalUnitCell()

virtual G4CrystalUnitCell::~G4CrystalUnitCell ( )
virtualdefault

Member Function Documentation

◆ ComputeCellVolume()

G4double G4CrystalUnitCell::ComputeCellVolume ( )

Definition at line 378 of file G4CrystalUnitCell.cc.

379{
380 G4double a = theSize[0], b = theSize[1], c = theSize[2];
381
382 switch (GetLatticeSystem()) {
383 case Amorphous:
384 return 0.;
385 break;
386 case Cubic:
387 return a * a * a;
388 break;
389 case Tetragonal:
390 return a * a * c;
391 break;
392 case Orthorhombic:
393 return a * b * c;
394 break;
395 case Rhombohedral:
396 return a * a * a * std::sqrt(1. - 3. * cosa * cosa + 2. * cosa * cosa * cosa);
397 break;
398 case Monoclinic:
399 return a * b * c * sinb;
400 break;
401 case Triclinic:
402 return a * b * c *
403 std::sqrt(1. - cosa * cosa - cosb * cosb - cosg * cosg * 2. * cosa * cosb * cosg);
404 break;
405 case Hexagonal:
406 return std::sqrt(3.0) / 2. * a * a * c;
407 break;
408 default:
409 break;
410 }
411
412 return 0.;
413}

Referenced by G4CrystalUnitCell().

◆ FillAtomicPos()

G4bool G4CrystalUnitCell::FillAtomicPos ( G4ThreeVector & pos,
std::vector< G4ThreeVector > & vecout )

Definition at line 192 of file G4CrystalUnitCell.cc.

193{
194 FillAtomicUnitPos(posin, vecout);
195 for (auto& vec : vecout) {
196 vec.setX(vec.x() * theSize[0]);
197 vec.setY(vec.y() * theSize[1]);
198 vec.setZ(vec.z() * theSize[2]);
199 }
200 return true;
201}
G4bool FillAtomicUnitPos(G4ThreeVector &pos, std::vector< G4ThreeVector > &vecout)

Referenced by G4CrystalExtension::GetAtomPos().

◆ FillAtomicUnitPos()

G4bool G4CrystalUnitCell::FillAtomicUnitPos ( G4ThreeVector & pos,
std::vector< G4ThreeVector > & vecout )

Definition at line 181 of file G4CrystalUnitCell.cc.

182{
183 // Just for testing the infrastructure
184 G4ThreeVector aaa = pos;
185 vecout.push_back(aaa);
186 vecout.emplace_back(2., 5., 3.);
187 return true;
188}

Referenced by FillAtomicPos().

◆ FillElReduced()

G4bool G4CrystalUnitCell::FillElReduced ( G4double Cij[6][6])

Definition at line 205 of file G4CrystalUnitCell.cc.

206{
207 switch (GetLatticeSystem()) {
208 case Amorphous:
209 return FillAmorphous(Cij);
210 break;
211 case Cubic: // Cubic, C44 set
212 return FillCubic(Cij);
213 break;
214 case Tetragonal:
215 return FillTetragonal(Cij);
216 break;
217 case Orthorhombic:
218 return FillOrthorhombic(Cij);
219 break;
220 case Rhombohedral:
221 return FillRhombohedral(Cij);
222 break;
223 case Monoclinic:
224 return FillMonoclinic(Cij);
225 break;
226 case Triclinic:
227 return FillTriclinic(Cij);
228 break;
229 case Hexagonal: // Tetragonal, C16=0
230 return FillHexagonal(Cij);
231 break;
232 default:
233 break;
234 }
235
236 return false;
237}

◆ GetAngle()

G4ThreeVector G4CrystalUnitCell::GetAngle ( ) const
inline

Definition at line 61 of file G4CrystalUnitCell.hh.

61{ return theAngle; }

◆ GetBasis()

const G4ThreeVector & G4CrystalUnitCell::GetBasis ( G4int idx) const

Definition at line 150 of file G4CrystalUnitCell.cc.

151{
152 return (idx >= 0 && idx < 3 ? theBasis[idx] : nullVec);
153}

Referenced by G4LogicalCrystalVolume::GetBasis().

◆ GetBravaisLattice()

theBravaisLatticeType G4CrystalUnitCell::GetBravaisLattice ( )
inline

Definition at line 56 of file G4CrystalUnitCell.hh.

56{ return GetBravaisLattice(theSpaceGroup); }
theBravaisLatticeType GetBravaisLattice()

Referenced by GetBravaisLattice().

◆ GetIntCosAng()

G4double G4CrystalUnitCell::GetIntCosAng ( G4int h1,
G4int k1,
G4int l1,
G4int h2,
G4int k2,
G4int l2 )

Definition at line 540 of file G4CrystalUnitCell.cc.

541{
542 /* Reference:
543 Table 2.4, pag. 65
544
545 @Inbook{Kelly2012,
546 author="Anthony A. Kelly and Kevin M. Knowles",
547 title="Appendix 3 Interplanar Spacings and Interplanar Angles",
548 bookTitle="Crystallography and Crystal Defects, 2nd Edition",
549 year="2012",
550 publisher="John Wiley & Sons, Ltd.",
551 isbn="978-0-470-75014-8",
552 doi="10.1002/9781119961468",
553 url="http://onlinelibrary.wiley.com/book/10.1002/9781119961468"
554 }
555 */
556
557 G4double a = theRecSize[0], b = theRecSize[1], c = theRecSize[2];
558 G4double a2 = a * a, b2 = b * b, c2 = c * c;
559 G4double dsp1dsp2;
560 switch (GetLatticeSystem()) {
561 case Amorphous:
562 return 0.;
563 break;
564 case Cubic:
565 return (h1 * h2 + k1 * k2 + l1 + l2) /
566 (std::sqrt(h1 * h1 + k1 * k1 + l1 * l1) * std::sqrt(h2 * h2 + k2 * k2 + l2 * l2));
567 break;
568 case Tetragonal:
569 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
570 return 0.;
571 break;
572 case Orthorhombic:
573 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
574 return dsp1dsp2 * (h1 * h2 * a2 + k1 * k2 * a2 + l1 * l2 * c2);
575 break;
576 case Rhombohedral:
577 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
578 return dsp1dsp2 *
579 (h1 * h2 * a2 + k1 * k2 * b2 + l1 * l2 * c2 + (k1 * l2 + k2 * l1) * b * c * cosar +
580 (h1 * l2 + h2 * l1) * a * c * cosbr + (h1 * k2 + h2 * k1) * a * b * cosgr);
581 break;
582 case Monoclinic:
583 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
584 return dsp1dsp2 *
585 (h1 * h2 * a2 + k1 * k2 * b2 + l1 * l2 * c2 + (k1 * l2 + k2 * l1) * b * c * cosar +
586 (h1 * l2 + h2 * l1) * a * c * cosbr + (h1 * k2 + h2 * k1) * a * b * cosgr);
587 break;
588 case Triclinic:
589 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
590 return dsp1dsp2 *
591 (h1 * h2 * a2 + k1 * k2 * b2 + l1 * l2 * c2 + (k1 * l2 + k2 * l1) * b * c * cosar +
592 (h1 * l2 + h2 * l1) * a * c * cosbr + (h1 * k2 + h2 * k1) * a * b * cosgr);
593 break;
594 case Hexagonal:
595 dsp1dsp2 = std::sqrt(GetIntSp2(h1, k1, l1) * GetIntSp2(h2, k2, l2));
596 return dsp1dsp2 * ((h1 * h2 + k1 * k2 + 0.5 * (h1 * k2 + k1 * h2)) * a2 + l1 * l2 * c2);
597 break;
598 default:
599 break;
600 }
601
602 return 0.;
603}
G4double GetIntSp2(G4int h, G4int k, G4int l)

◆ GetIntSp2()

G4double G4CrystalUnitCell::GetIntSp2 ( G4int h,
G4int k,
G4int l )

Definition at line 417 of file G4CrystalUnitCell.cc.

418{
419 /* Reference:
420 Table 2.4, pag. 65
421
422 @Inbook{Ladd2003,
423 author="Ladd, Mark and Palmer, Rex",
424 title="Lattices and Space-Group Theory",
425 bookTitle="Structure Determination by X-ray Crystallography",
426 year="2003",
427 publisher="Springer US",
428 address="Boston, MA",
429 pages="51--116",
430 isbn="978-1-4615-0101-5",
431 doi="10.1007/978-1-4615-0101-5_2",
432 url="http://dx.doi.org/10.1007/978-1-4615-0101-5_2"
433 }
434 */
435
436 G4double a = theSize[0], b = theSize[1], c = theSize[2];
437 G4double a2 = a * a, b2 = b * b, c2 = c * c;
438 G4double h2 = h * h, k2 = k * k, l2 = l * l;
439
440 G4double cos2a, sin2a, sin2b;
441 G4double R, T;
442
443 switch (GetLatticeSystem()) {
444 case Amorphous:
445 return 0.;
446 break;
447 case Cubic:
448 return a2 / (h2 + k2 + l2);
449 break;
450 case Tetragonal:
451 return 1.0 / ((h2 + k2) / a2 + l2 / c2);
452 break;
453 case Orthorhombic:
454 return 1.0 / (h2 / a2 + k2 / b2 + l2 / c2);
455 break;
456 case Rhombohedral:
457 cos2a = cosa * cosa;
458 sin2a = sina * sina;
459 T = h2 + k2 + l2 + 2. * (h * k + k * l + h * l) * ((cos2a - cosa) / sin2a);
460 R = sin2a / (1. - 3 * cos2a + 2. * cos2a * cosa);
461 return a * a / (T * R);
462 break;
463 case Monoclinic:
464 sin2b = sinb * sinb;
465 return 1. / (1. / sin2b * (h2 / a2 + l2 / c2 - 2 * h * l * cosb / (a * c)) + k2 / b2);
466 break;
467 case Triclinic:
468 return 1. / GetRecIntSp2(h, k, l);
469 break;
470 case Hexagonal:
471 return 1. / ((4. * (h2 + k2 + h * k) / (3. * a2)) + l2 / c2);
472 break;
473 default:
474 break;
475 }
476
477 return 0.;
478}
G4double GetRecIntSp2(G4int h, G4int k, G4int l)

Referenced by GetIntCosAng().

◆ GetLatticeSystem()

theLatticeSystemType G4CrystalUnitCell::GetLatticeSystem ( )
inline

◆ GetRecAngle()

G4ThreeVector G4CrystalUnitCell::GetRecAngle ( ) const
inline

Definition at line 69 of file G4CrystalUnitCell.hh.

69{ return theRecAngle; }

◆ GetRecBasis()

const G4ThreeVector & G4CrystalUnitCell::GetRecBasis ( G4int idx) const

Definition at line 164 of file G4CrystalUnitCell.cc.

165{
166 return (idx >= 0 && idx < 3 ? theRecBasis[idx] : nullVec);
167}

◆ GetRecIntSp2()

G4double G4CrystalUnitCell::GetRecIntSp2 ( G4int h,
G4int k,
G4int l )

Definition at line 482 of file G4CrystalUnitCell.cc.

483{
484 /* Reference:
485 Table 2.4, pag. 65
486
487 @Inbook{Ladd2003,
488 author="Ladd, Mark and Palmer, Rex",
489 title="Lattices and Space-Group Theory",
490 bookTitle="Structure Determination by X-ray Crystallography",
491 year="2003",
492 publisher="Springer US",
493 address="Boston, MA",
494 pages="51--116",
495 isbn="978-1-4615-0101-5",
496 doi="10.1007/978-1-4615-0101-5_2",
497 url="http://dx.doi.org/10.1007/978-1-4615-0101-5_2"
498 }
499 */
500
501 G4double a = theRecSize[0], b = theRecSize[1], c = theRecSize[2];
502 G4double a2 = a * a, b2 = b * b, c2 = c * c;
503 G4double h2 = h * h, k2 = k * k, l2 = l * l;
504
505 switch (GetLatticeSystem()) {
506 case Amorphous:
507 return 0.;
508 break;
509 case Cubic:
510 return a2 * (h2 + k2 + l2);
511 break;
512 case Tetragonal:
513 return (h2 + k2) * a2 + l2 * c2;
514 break;
515 case Orthorhombic:
516 return h2 * a2 + k2 + b2 + h2 * c2;
517 break;
518 case Rhombohedral:
519 return (h2 + k2 + l2 + 2. * (h * k + k * l + h * l) * cosar) * a2;
520 break;
521 case Monoclinic:
522 return h2 * a2 + k2 * b2 + l2 * c2 + 2. * h * l * a * c * cosbr;
523 break;
524 case Triclinic:
525 return h2 * a2 + k2 * b2 + l2 * c2 + 2. * k * l * b * c * cosar + 2. * l * h * c * a * cosbr +
526 2. * h * k * a * b * cosgr;
527 break;
528 case Hexagonal:
529 return (h2 + k2 + h * k) * a2 + l2 * c2;
530 break;
531 default:
532 break;
533 }
534
535 return 0.;
536}

Referenced by GetIntSp2().

◆ GetRecSize()

G4ThreeVector G4CrystalUnitCell::GetRecSize ( ) const
inline

Definition at line 68 of file G4CrystalUnitCell.hh.

68{ return theRecSize; }

◆ GetRecUnitBasis()

const G4ThreeVector & G4CrystalUnitCell::GetRecUnitBasis ( G4int idx) const

Definition at line 157 of file G4CrystalUnitCell.cc.

158{
159 return (idx >= 0 && idx < 3 ? theRecUnitBasis[idx] : nullVec);
160}

◆ GetRecVolume()

G4double G4CrystalUnitCell::GetRecVolume ( ) const
inline

Definition at line 83 of file G4CrystalUnitCell.hh.

83{ return theRecVolume; } // get the stored volume

◆ GetSize()

G4ThreeVector G4CrystalUnitCell::GetSize ( ) const
inline

Definition at line 60 of file G4CrystalUnitCell.hh.

60{ return theSize; }

◆ GetSpaceGroup()

G4int G4CrystalUnitCell::GetSpaceGroup ( ) const
inline

Definition at line 52 of file G4CrystalUnitCell.hh.

52{ return theSpaceGroup; };

◆ GetUnitBasis()

const G4ThreeVector & G4CrystalUnitCell::GetUnitBasis ( G4int idx) const

Definition at line 143 of file G4CrystalUnitCell.cc.

144{
145 return (idx >= 0 && idx < 3 ? theUnitBasis[idx] : nullVec);
146}

◆ GetUnitBasisTrigonal()

G4ThreeVector G4CrystalUnitCell::GetUnitBasisTrigonal ( )

Definition at line 171 of file G4CrystalUnitCell.cc.

172{
173 // Z' axis computed by hand to get both opening angles right
174 // X'.Z' = cos(alpha), Y'.Z' = cos(beta), solve for Z' components
175 G4double x3 = cosa, y3 = (cosb - cosa * cosg) / sing, z3 = std::sqrt(1. - x3 * x3 - y3 * y3);
176 return G4ThreeVector(x3, y3, z3).unit();
177}

◆ GetVolume()

G4double G4CrystalUnitCell::GetVolume ( ) const
inline

Definition at line 82 of file G4CrystalUnitCell.hh.

82{ return theVolume; } // get the stored volume

◆ SetSpaceGroup()

void G4CrystalUnitCell::SetSpaceGroup ( G4int aInt)
inline

Definition at line 53 of file G4CrystalUnitCell.hh.

53{ theSpaceGroup = aInt; };

Member Data Documentation

◆ nullVec

G4ThreeVector G4CrystalUnitCell::nullVec
protected

◆ theAngle

G4ThreeVector G4CrystalUnitCell::theAngle
protected

Definition at line 99 of file G4CrystalUnitCell.hh.

Referenced by GetAngle().

◆ theBasis

G4ThreeVector G4CrystalUnitCell::theBasis[3]
protected

Definition at line 101 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), and GetBasis().

◆ theRecAngle

G4ThreeVector G4CrystalUnitCell::theRecAngle
protected

Definition at line 106 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), and GetRecAngle().

◆ theRecBasis

G4ThreeVector G4CrystalUnitCell::theRecBasis[3]
protected

Definition at line 108 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), and GetRecBasis().

◆ theRecSize

G4ThreeVector G4CrystalUnitCell::theRecSize
protected

Definition at line 105 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), GetIntCosAng(), GetRecIntSp2(), and GetRecSize().

◆ theRecUnitBasis

G4ThreeVector G4CrystalUnitCell::theRecUnitBasis[3]
protected

Definition at line 107 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), and GetRecUnitBasis().

◆ theSize

G4ThreeVector G4CrystalUnitCell::theSize
protected

◆ theUnitBasis

G4ThreeVector G4CrystalUnitCell::theUnitBasis[3]
protected

Definition at line 100 of file G4CrystalUnitCell.hh.

Referenced by G4CrystalUnitCell(), and GetUnitBasis().


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