Geant4  10.03
G4CrystalExtension.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4CrystalExtension.hh 94016 2015-11-05 10:14:49Z gcosmo $
28 //
29 
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
32 // 21-04-16, created by E.Bagli
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "G4CrystalExtension.hh"
37 #include "G4AtomicFormFactor.hh"
38 
39 
42 fMaterial(mat),
43 theUnitCell(0){;}
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
52 ComputeStructureFactor(G4double kScatteringVector,
53  G4int h,
54  G4int k,
55  G4int l){
56  //SF == Structure Factor
57  //AFF == Atomic Form Factor
58  //GFS == Geometrical Structure Factor
59  G4complex SF = G4complex(0.,0.);
60 
61  for(auto anElement: *(fMaterial->GetElementVector())){
62  G4double AFF = G4AtomicFormFactor::GetManager()->Get(kScatteringVector,anElement->GetZ());
63 
64  G4complex GFS = G4complex(0.,0.);
65 
66  for(auto anAtomPos: GetAtomBase(anElement)->GetPos())
67  {
68  G4double aDouble = h * anAtomPos.x()
69  + k * anAtomPos.y()
70  + l * anAtomPos.z();
71  GFS += G4complex(std::cos(2 * CLHEP::pi * aDouble),
72  std::sin(2 * CLHEP::pi * aDouble));
73  }
74 
75 
76  SF += G4complex(AFF * GFS.real(),AFF * GFS.imag());
77  }
78  return SF;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
82 
85  G4int k,
86  G4int l){
87  //GFS == Geometrical Structure Form Factor
88  G4complex GFS = G4complex(0.,0.);
89 
90  for(auto anElement: *(fMaterial->GetElementVector())){
91  for(auto anAtomPos: GetAtomBase(anElement)->GetPos())
92  {
93  G4double aDouble = h * anAtomPos.x()
94  + k * anAtomPos.y()
95  + l * anAtomPos.z();
96  GFS += G4complex(std::cos(2 * CLHEP::pi * aDouble),
97  std::sin(2 * CLHEP::pi * aDouble));
98  }
99  }
100  return GFS;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
104 
105 void G4CrystalExtension::SetElReduced(const ReducedElasticity& mat) {
106  for (size_t i=0; i<6; i++) {
107  for (size_t j=0; j<6; j++) {
108  fElReduced[i][j] = mat[i][j];
109  }
110  }
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
114 
116  if (p>0 && p<7 && q>0 && q<7) fElReduced[p-1][q-1] = value;
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
120 
122  if((theCrystalAtomBaseMap.count(anElement)<1)){
123  G4String astring = "Atom base for element " + anElement->GetName()
124  + " is not registered." ;
125  G4Exception ("G4CrystalExtension::GetAtomBase()", "cry001", JustWarning,astring);
126 
127  AddAtomBase(anElement, new G4CrystalAtomBase());
128  }
129  return theCrystalAtomBaseMap[anElement];
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 
134 G4bool G4CrystalExtension::GetAtomPos(const G4Element* anEl, std::vector<G4ThreeVector>& vecout){
135  std::vector<G4ThreeVector> pos;
136  for(auto asinglepos: GetAtomBase(anEl)->GetPos()){
137  pos.clear();
138  theUnitCell->FillAtomicPos(asinglepos,pos);
139  vecout.insert(std::end(vecout), std::begin(pos), std::end(pos));
140  }
141  return true;
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145 
146 G4bool G4CrystalExtension::GetAtomPos(std::vector<G4ThreeVector>& vecout){
147  std::vector<G4ThreeVector> pos;
148  vecout.clear();
149  for(auto anElement: *(fMaterial->GetElementVector())){
150  pos.clear();
151  GetAtomPos(anElement,pos);
152  vecout.insert(std::end(vecout), std::begin(pos), std::end(pos));
153  }
154  return true;
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158 
G4bool GetAtomPos(const G4Element *anEl, std::vector< G4ThreeVector > &vecout)
void AddAtomBase(const G4Element *anElement, G4CrystalAtomBase *aBase)
void SetCpq(G4int p, G4int q, G4double value)
static G4AtomicFormFactor * GetManager()
G4complex ComputeStructureFactor(G4double kScatteringVector, G4int h, G4int k, G4int l)
G4CrystalUnitCell * theUnitCell
G4double Get(G4double kScatteringVector, G4int Z, G4int charge=0)
const char * name(G4int ptype)
G4CrystalExtension(G4Material *, const G4String &name="crystal")
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
std::vector< G4ThreeVector > GetPos()
std::complex< G4double > G4complex
Definition: G4Types.hh:81
G4complex ComputeStructureFactorGeometrical(G4int h, G4int k, G4int l)
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::map< const G4Element *, G4CrystalAtomBase * > theCrystalAtomBaseMap
G4bool FillAtomicPos(G4ThreeVector &pos, std::vector< G4ThreeVector > &vecout)
void SetElReduced(const ReducedElasticity &mat)
G4CrystalAtomBase * GetAtomBase(const G4Element *anElement)
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Element.hh:127
ReducedElasticity fElReduced
static const G4double pos