G4Molecule.cc

Go to the documentation of this file.
00001 // ********************************************************************
00002 // * License and Disclaimer                                           *
00003 // *                                                                  *
00004 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00005 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00006 // * conditions of the Geant4 Software License,  included in the file *
00007 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00008 // * include a list of copyright holders.                             *
00009 // *                                                                  *
00010 // * Neither the authors of this software system, nor their employing *
00011 // * institutes,nor the agencies providing financial support for this *
00012 // * work  make  any representation or  warranty, express or implied, *
00013 // * regarding  this  software system or assume any liability for its *
00014 // * use.  Please see the license in the file  LICENSE  and URL above *
00015 // * for the full disclaimer and the limitation of liability.         *
00016 // *                                                                  *
00017 // * This  code  implementation is the result of  the  scientific and *
00018 // * technical work of the GEANT4 collaboration.                      *
00019 // * By using,  copying,  modifying or  distributing the software (or *
00020 // * any work based  on the software)  you  agree  to acknowledge its *
00021 // * use  in  resulting  scientific  publications,  and indicate your *
00022 // * acceptance of all terms of the Geant4 Software license.          *
00023 // ********************************************************************
00024 //
00025 // $Id: G4Molecule.cc 64057 2012-10-30 15:04:49Z gcosmo $
00026 //
00027 // ---------------------------------------------------------------------
00028 //      GEANT 4 class header file
00029 //
00030 //      History: first implementation, based on G4DynamicParticle
00031 //           New dependency : G4VUserTrackInformation
00032 //
00033 //      ---------------- G4Molecule  ----------------
00034 //      first design&implementation by Alfonso Mantero, 7 Apr 2009
00035 //      New developments Alfonso Mantero & Mathieu Karamitros
00036 //      Oct/Nov 2009 Class Name changed to G4Molecule
00037 //                   Removed dependency from G4DynamicParticle
00038 //                   New constructors :
00039 //                    copy constructor
00040 //                    direct ionized/excited molecule
00041 //                   New methods :
00042 //                    Get : name,atoms' number,nb electrons,decayChannel
00043 //                    PrintState //To get the electronic level and the
00044 //                                 corresponding name of the excitation
00045 //                    Kinematic :
00046 //                    BuildTrack,GetKineticEnergy,GetDiffusionVelocity
00047 //                    Change the way dynCharge and eNb is calculated
00048 // ---------------------------------------------------------------------
00049 
00050 #include "G4Molecule.hh"
00051 #include "G4MolecularConfiguration.hh"
00052 #include "Randomize.hh"
00053 #include "G4PhysicalConstants.hh"
00054 #include "G4SystemOfUnits.hh"
00055 #include "G4Track.hh"
00056 #include "G4MoleculeCounter.hh"
00057 
00058 using namespace std;
00059 
00060 double G4Molecule::fgTemperature = 310*kelvin;
00061 // 37°C, used to shoot an energy
00062 
00063 ITImp(G4Molecule)
00064 
00065 G4Allocator<G4Molecule> aMoleculeAllocator;
00066 
00067 G4Molecule* GetMolecule(const G4Track& track)
00068 {
00069     return (G4Molecule*)(GetIT(track));
00070 }
00071 
00072 G4Molecule* GetMolecule(const G4Track* track)
00073 {
00074     return (G4Molecule*)(GetIT(track));
00075 }
00076 
00077 void G4Molecule::Print() const
00078 {
00079     G4cout<<"The user track information is a molecule"<<G4endl;
00080 }
00081 
00082 G4Molecule::G4Molecule(const G4Molecule& right) :
00083     G4VUserTrackInformation("G4Molecule"), G4IT(right)
00084 {
00085     Init();
00086     fMolecularConfiguration = right . fMolecularConfiguration;
00087 }
00088 
00089 G4Molecule& G4Molecule::operator=(const G4Molecule& right)
00090 {
00091     if (&right==this) return *this;
00092     Init();
00093     fMolecularConfiguration = right . fMolecularConfiguration;
00094     return *this;
00095 }
00096 
00097 G4bool G4Molecule::operator==(const G4Molecule& right) const
00098 {
00099     if(fMolecularConfiguration==right.fMolecularConfiguration)
00100     {
00101         return true;
00102     }
00103     return false;
00104 }
00105 
00106 G4bool G4Molecule::operator!=(const G4Molecule& right) const
00107 {
00108     return !(*this == right);
00109 }
00110 
00115 
00116 G4bool G4Molecule::operator<(const G4Molecule& right) const
00117 {
00118     return fMolecularConfiguration < right.fMolecularConfiguration ;
00119 }
00121 void G4Molecule::Init()
00122 {
00123     fMolecularConfiguration = 0 ;
00124     fDynamicParticle = 0;
00125 }
00126 
00128 
00130 
00131 G4Molecule::G4Molecule() : G4VUserTrackInformation("G4Molecule"), G4IT()
00133 {
00134     Init();
00135 }
00136 
00138 G4Molecule::~G4Molecule()
00140 {
00141     if(fpTrack!=NULL)
00142     {
00143         if(G4MoleculeCounter::GetMoleculeCounter()->InUse())
00144         {
00145             G4MoleculeCounter::GetMoleculeCounter()->RemoveAMoleculeAtTime(*this,
00146                                                                            fpTrack->GetGlobalTime());
00147         }
00148         fpTrack = 0;
00149     }
00150     fMolecularConfiguration = 0;
00151     fDynamicParticle = 0;
00152     // DEBUG
00153     // G4cout<<"Molecule killed"<<G4endl;
00154 }
00155 
00159 
00160 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
00161     G4VUserTrackInformation("G4Molecule"), G4IT()
00163 {
00164     Init();
00165     fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition);
00166 }
00167 
00172 
00173 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int OrbitalToFree, G4int OrbitalToFill):
00174     G4VUserTrackInformation("G4Molecule"), G4IT()
00176 {
00177     Init();
00178 
00179     G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
00180 
00181     if (OrbitalToFill != 0)
00182     {
00183         dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
00184         dynElectronOccupancy.AddElectron(OrbitalToFill-1,1);
00185         // dynElectronOccupancy.DumpInfo(); // DEBUG
00186     }
00187 
00188     if (OrbitalToFill == 0)
00189     {
00190         dynElectronOccupancy.RemoveElectron(OrbitalToFree-1,1);
00191         // dynElectronOccupancy.DumpInfo(); // DEBUG
00192     }
00193 
00194     fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
00195 }
00196 
00202 G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition, G4int Level, G4bool Excitation):
00203     G4VUserTrackInformation("G4Molecule"), G4IT()
00204 {
00205     Init();
00206 
00207     G4ElectronOccupancy dynElectronOccupancy (*moleculeDefinition->GetGroundStateElectronOccupancy());
00208 
00209     if (Excitation == true)
00210     {
00211         dynElectronOccupancy.RemoveElectron(Level,1);
00212         dynElectronOccupancy.AddElectron(5,1);
00213         // dynElectronOccupancy.DumpInfo(); // DEBUG
00214     }
00215 
00216     if (Excitation == false)
00217     {
00218         dynElectronOccupancy.RemoveElectron(Level,1);
00219         // dynElectronOccupancy.DumpInfo(); // DEBUG
00220     }
00221 
00222     fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(moleculeDefinition, dynElectronOccupancy);
00223 }
00224 
00225 void G4Molecule::SetElectronOccupancy(const G4ElectronOccupancy* occ)
00226 {
00227     fMolecularConfiguration = G4MolecularConfiguration::GetMolecularConfiguration(fMolecularConfiguration->GetDefinition(), *occ);
00228 }
00229 
00232 void G4Molecule::ExciteMolecule(G4int ExcitedLevel)
00233 {
00234     fMolecularConfiguration = fMolecularConfiguration->ExciteMolecule(ExcitedLevel);
00235 }
00236 
00239 void G4Molecule::IonizeMolecule(G4int IonizedLevel)
00240 {
00241     fMolecularConfiguration = fMolecularConfiguration->IonizeMolecule(IonizedLevel);
00242 }
00243 
00244 void G4Molecule::AddElectron(G4int orbit, G4int number)
00245 {
00246     fMolecularConfiguration = fMolecularConfiguration->AddElectron(orbit,number);
00247 }
00248 
00249 void G4Molecule::RemoveElectron(G4int orbit,G4int number)
00250 {
00251     fMolecularConfiguration = fMolecularConfiguration->RemoveElectron(orbit,number);
00252 }
00253 
00254 void G4Molecule::MoveOneElectron(G4int orbitToFree,G4int orbitToFill)
00255 {
00256     fMolecularConfiguration = fMolecularConfiguration->MoveOneElectron(orbitToFree,orbitToFill);
00257 }
00258 
00259 const G4String& G4Molecule::GetName() const
00260 {
00261     return fMolecularConfiguration->GetName();
00262 }
00263 
00264 G4int G4Molecule::GetAtomsNumber() const
00265 {
00266     return fMolecularConfiguration->GetAtomsNumber();
00267 }
00268 
00269 G4double G4Molecule::GetNbElectrons() const
00270 {
00271     return fMolecularConfiguration->GetNbElectrons();
00272 }
00273 
00274 void G4Molecule::PrintState() const
00275 {
00276     fMolecularConfiguration->PrintState();
00277 }
00278 
00279 G4Track * G4Molecule::BuildTrack(G4double globalTime, const G4ThreeVector& Position)
00280 {
00281     if(fpTrack != 0)
00282     {
00283         G4Exception("G4Molecule::BuildTrack","Molecule001",
00284                     FatalErrorInArgument,"A track was already assigned to this molecule");
00285     }
00286 
00287     // Kinetic Values
00288     // Set a random direction to the molecule
00289     G4double costheta = (2*G4UniformRand()-1);
00290     G4double theta = acos (costheta);
00291     G4double phi = 2*pi*G4UniformRand();
00292 
00293     G4double xMomentum = cos(phi)* sin(theta);
00294     G4double yMomentum = sin(theta)*sin(phi);
00295     G4double zMomentum = costheta;
00296 
00297     G4ThreeVector MomentumDirection(xMomentum, yMomentum, zMomentum);
00298     G4double KineticEnergy = GetKineticEnergy();
00299     // G4cout << " **** KineticEnergy : " << KineticEnergy << G4endl;
00300     fDynamicParticle = new G4DynamicParticle(fMolecularConfiguration->GetDefinition(),
00301                                              MomentumDirection,
00302                                              KineticEnergy);
00303 
00304     if(G4MoleculeCounter::GetMoleculeCounter()->InUse())
00305         G4MoleculeCounter::GetMoleculeCounter()->AddAMoleculeAtTime(*this,globalTime);
00306 
00307     //Set the Track
00308     fpTrack = new G4Track(fDynamicParticle, globalTime, Position);
00309     fpTrack -> SetUserInformation (this);
00310 
00311     return fpTrack;
00312 }
00313 
00314 G4double G4Molecule::GetKineticEnergy() const
00315 {
00317     // Ideal Gaz case
00318     double v = GetDiffusionVelocity();
00319     double E = (fMolecularConfiguration->GetMass()/(c_squared))*(v*v)/2.;
00321     return E;
00322 }
00323 
00324 G4double G4Molecule::GetDiffusionVelocity() const
00325 {
00326     double moleculeMass = fMolecularConfiguration->GetMass()/(c_squared);
00327 
00329     // Different possibilities
00331     // Ideal Gaz case : Maxwell Boltzmann Distribution
00332     //    double sigma = k_Boltzmann * fgTemperature / mass;
00333     //    return G4RandGauss::shoot( 0, sigma );
00335     // Ideal Gaz case : mean velocity from equipartition theorem
00336     return sqrt(3*k_Boltzmann*fgTemperature/moleculeMass);
00338     // Using this approximation for liquid is wrong
00339     // However the brownian process avoid taking
00340     // care of energy consideration and plays only
00341     // with positions
00342 }
00343 
00344 // added - to be transformed in a "Decay method"
00345 const vector <const G4MolecularDecayChannel*>* G4Molecule::GetDecayChannel() const
00346 {
00347     return fMolecularConfiguration->GetDecayChannel();
00348 }
00349 
00350 G4int G4Molecule::GetMoleculeID() const
00351 {
00352     return fMolecularConfiguration->GetMoleculeID();
00353 }
00354 
00355 void G4Molecule::SetDecayTime(G4double dynDecayTime)
00356 {
00357     fMolecularConfiguration->SetDecayTime(dynDecayTime);
00358 }
00359 
00360 G4double G4Molecule::GetDecayTime() const
00361 {
00362     return fMolecularConfiguration->GetDecayTime();
00363 }
00364 
00365 void G4Molecule::SetVanDerVaalsRadius(G4double dynVanDerVaalsRadius)
00366 {
00367     fMolecularConfiguration->SetVanDerVaalsRadius(dynVanDerVaalsRadius);
00368 }
00369 
00370 G4double G4Molecule::GetVanDerVaalsRadius() const
00371 {
00372     return fMolecularConfiguration->GetVanDerVaalsRadius();
00373 }
00374 
00375 G4int G4Molecule::GetCharge() const
00376 {
00377     return fMolecularConfiguration->GetCharge() ;
00378 }
00379 
00380 void G4Molecule::SetMass(G4double aMass)
00381 {
00382     fMolecularConfiguration->SetMass(aMass);
00383 }
00384 
00385 G4double G4Molecule::GetMass() const
00386 {
00387     return fMolecularConfiguration->GetMass();
00388 }
00389 
00390 const G4ElectronOccupancy* G4Molecule::GetElectronOccupancy() const
00391 {
00392     return fMolecularConfiguration->GetElectronOccupancy();
00393 }
00394 
00395 const G4MoleculeDefinition* G4Molecule::GetDefinition() const
00396 {
00397     return fMolecularConfiguration->GetDefinition();
00398 }
00399 
00400 void G4Molecule::SetDiffusionCoefficient(G4double dynDiffusionCoefficient)
00401 {
00402     fMolecularConfiguration->SetDiffusionCoefficient(dynDiffusionCoefficient);
00403 }
00404 
00405 G4double G4Molecule::GetDiffusionCoefficient() const
00406 {
00407     return fMolecularConfiguration->GetDiffusionCoefficient();
00408 }

Generated on Mon May 27 17:48:53 2013 for Geant4 by  doxygen 1.4.7