Geant4  10.02.p02
XUnitCell.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 #include "XUnitCell.hh"
28 #include "G4PhysicalConstants.hh"
29 #include <cmath>
30 
33  0. * CLHEP::angstrom,
34  0. * CLHEP::angstrom);
36  0.5 * CLHEP::pi * CLHEP::radian,
37  0.5 * CLHEP::pi * CLHEP::radian);
38  fNumberOfBases = 0;
39 }
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
44 }
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
47 
49  return fSize;
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53 
55  return fAngle;
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
61  if(i<fNumberOfBases){
62  return fBase[i];
63  }
64  else{
65  G4cout << "XUnitCell::GetBase(G4int) Base "
66  << i << " does not exist" << std::endl;
67  return NULL;
68  }
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
72 
74  fSize = vSize;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78 
80  fAngle = vAngle;
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
84 
86  if(i<fNumberOfBases){
87  fBase[i] = base;
88  }
89  else{
90  G4cout << "XUnitCell::SetBase Base(G4int,G4XLogicalBase) "
91  << i << " does not exist" << std::endl;
92  }
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
96 
99  //the new added basis will be in the last of the [0,fNumberOfBases-1] bases
100  fBase[fNumberOfBases-1] = base;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
106  if(IsOrthogonal()){
107  return ( fSize.x()*fSize.y()*fSize.z() );
108  }
109  else{
110  return (fSize.x()*fSize.y()*fSize.z()*std::cos(fAngle.x())*std::sin(fAngle.z()));
111  }
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
115 
117  G4double vAtomVolumeDensity = 0.;
118  for(G4int i=0;i< fNumberOfBases;i++){
119  vAtomVolumeDensity += (fBase[i]->GetElement()->GetZ()
121  }
122  vAtomVolumeDensity /= ComputeVolume();
123  return vAtomVolumeDensity;
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129  return std::pow(h/fSize.x(),2.) + std::pow(k/fSize.y(),2.) + std::pow(l/fSize.z(),2.);
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 
135  return std::pow(h*fSize.x(),2.) + std::pow(k*fSize.y(),2.) + std::pow(l*fSize.z(),2.);
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141  G4double vReciprocalVectorSquared = 0.0;
142 
143  if(IsOrthogonal()){
144  vReciprocalVectorSquared = ComputeMillerOverSizeSquared(h,k,l);
145  }
146  else{
147  G4double vTemp[6];
148  G4double vVolume = ComputeVolume();
149 
150  vTemp[0] = fSize.y() * fSize.z() * std::sin(fAngle.y());
151  vTemp[0] = std::pow(vTemp[0] * h,2.) / vVolume;
152 
153  vTemp[1] = fSize.x() * fSize.z() * std::sin(fAngle.x());
154  vTemp[1] = std::pow(vTemp[1] * k,2.) / vVolume;
155 
156  vTemp[2] = fSize.x() * fSize.y() * std::sin(fAngle.z());
157  vTemp[2] = std::pow(vTemp[2] * l,2.) / vVolume;
158 
159  vTemp[3] = fSize.x() * fSize.y() * std::pow(fSize.z(),2.) *
160  (std::cos(fAngle.x()) * std::cos(fAngle.y()) - std::cos(fAngle.z()));
161  vTemp[3] *= (2. * h * k);
162 
163  vTemp[4] = fSize.x() * std::pow(fSize.y(),2.) * fSize.z() *
164  (std::cos(fAngle.z()) * std::cos(fAngle.x()) - std::cos(fAngle.y()));
165  vTemp[4] *= (2. * l * h);
166 
167  vTemp[5] = std::pow(fSize.x(),2.) * fSize.y() * fSize.z() *
168  (std::cos(fAngle.y()) * std::cos(fAngle.z()) - std::cos(fAngle.x()));
169  vTemp[5] *= (2. * k * l);
170 
171  vReciprocalVectorSquared = (vTemp[0]+vTemp[1]+vTemp[2]) / vVolume;
172  vReciprocalVectorSquared += (vTemp[3]+vTemp[4]+vTemp[5]);
173  vReciprocalVectorSquared /= vVolume;
174  }
175 
176  vReciprocalVectorSquared *= (4. * CLHEP::pi * CLHEP::pi);
177  return vReciprocalVectorSquared;
178 }
179 
180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181 
183  return std::sqrt(ComputeReciprocalVectorSquared(h,k,l));
184 }
185 
186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 
189  if(IsOrthogonal()){
190  return ComputeMillerPerSizeSquared(h,k,l);
191  }
192  else{
193  double vDirectVectorSquared = 0.0;
194  vDirectVectorSquared = ComputeMillerPerSizeSquared(h,k,l);
195  vDirectVectorSquared += 2. * h * k * fSize.y() *
196  fSize.z() * std::cos(fAngle.y()) ;
197  vDirectVectorSquared += 2. * l * h * fSize.x() *
198  fSize.z() * std::cos(fAngle.x()) ;
199  vDirectVectorSquared += 2. * l * l * fSize.x() *
200  fSize.y() * std::cos(fAngle.z()) ;
201  return vDirectVectorSquared;
202  }
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
208  return std::sqrt(ComputeDirectVectorSquared(h,k,l));
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
212 
214  return (1./ComputeMillerOverSizeSquared(h,k,l));
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
220  return std::sqrt(ComputeDirectPeriodSquared(h,k,l));
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
225 
227  if(fAngle.x() == CLHEP::pi / 2.)
228  if(fAngle.y() == CLHEP::pi / 2.)
229  if(fAngle.z() == CLHEP::pi / 2.)
230  return true;
231  return false;
232 }
233 
234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
235 
237  if(IsOrthogonal())
238  if(fSize.x() == fSize.y())
239  if(fSize.y() == fSize.z())
240  return true;
241  return false;
242 }
243 
244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreeVector GetAngle()
Definition: XUnitCell.cc:54
G4double ComputeDirectVectorSquared(G4int, G4int, G4int)
Definition: XUnitCell.cc:188
XLogicalBase * fBase[MAXBASENUMBER]
Definition: XUnitCell.hh:47
G4Element * GetElement()
Definition: XLogicalBase.cc:53
CLHEP::Hep3Vector G4ThreeVector
~XUnitCell()
Definition: XUnitCell.cc:43
void SetSize(G4ThreeVector)
Definition: XUnitCell.cc:73
G4bool IsCubic()
Definition: XUnitCell.cc:236
G4double GetZ() const
Definition: G4Element.hh:131
G4double ComputeMillerPerSizeSquared(G4int, G4int, G4int)
Definition: XUnitCell.cc:134
G4double ComputeReciprocalVectorSquared(G4int, G4int, G4int)
Definition: XUnitCell.cc:140
int G4int
Definition: G4Types.hh:78
G4double ComputeVolume()
Definition: XUnitCell.cc:105
G4double ComputeMillerOverSizeSquared(G4int, G4int, G4int)
Definition: XUnitCell.cc:128
XLogicalAtomicLattice * GetLattice()
Definition: XLogicalBase.cc:47
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector GetSize()
Definition: XUnitCell.cc:48
void AddBase(XLogicalBase *)
Definition: XUnitCell.cc:97
G4double ComputeAtomVolumeDensity()
Definition: XUnitCell.cc:116
G4bool IsOrthogonal()
Definition: XUnitCell.cc:226
static const double pi
Definition: G4SIunits.hh:74
G4ThreeVector fSize
Definition: XUnitCell.hh:49
G4double ComputeDirectPeriod(G4int, G4int, G4int)
Definition: XUnitCell.cc:219
XLogicalBase * GetBase(G4int)
Definition: XUnitCell.cc:60
static const double radian
Definition: G4SIunits.hh:141
void SetBase(G4int, XLogicalBase *)
Definition: XUnitCell.cc:85
G4double ComputeDirectPeriodSquared(G4int, G4int, G4int)
Definition: XUnitCell.cc:213
G4ThreeVector fAngle
Definition: XUnitCell.hh:50
double G4double
Definition: G4Types.hh:76
G4int fNumberOfBases
Definition: XUnitCell.hh:46
void SetAngle(G4ThreeVector)
Definition: XUnitCell.cc:79
G4double ComputeReciprocalVector(G4int, G4int, G4int)
Definition: XUnitCell.cc:182
G4double ComputeDirectVector(G4int, G4int, G4int)
Definition: XUnitCell.cc:207
static const double angstrom
Definition: G4SIunits.hh:101