BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLaserIonExcitation.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSAuxiliaryNavigator.hh"
20#include "BDSElectronQuantumLevel.hh"
21#include "BDSGlobalConstants.hh"
22#include "BDSIonExcitationEngine.hh"
23#include "BDSLaserIonExcitation.hh"
24#include "BDSLogicalVolumeLaser.hh"
25#include "BDSLaser.hh"
26#include "BDSStep.hh"
27#include "BDSUserTrackInformation.hh"
28
29#include "globals.hh"
30#include "G4AffineTransform.hh"
31#include "G4Electron.hh"
32#include "G4DecayProducts.hh"
33#include "G4Hydrogen.hh"
34#include "G4LogicalVolume.hh"
35#include "G4ParticleTable.hh"
36#include "G4ProcessType.hh"
37#include "G4Proton.hh"
38#include "G4Step.hh"
39#include "G4StepPoint.hh"
40#include "G4ThreeVector.hh"
41#include "G4Track.hh"
42#include "G4VTouchable.hh"
43#include "Randomize.hh"
44#include "G4TransportationManager.hh"
45#include "G4VPhysicalVolume.hh"
46#include "BDSElectronOccupancy.hh"
47
48#include "CLHEP/Units/PhysicalConstants.h"
49#include "CLHEP/Units/SystemOfUnits.h"
50
51#include <cmath>
52#include <limits>
53
54BDSLaserIonExcitation::BDSLaserIonExcitation(const G4String& processName):
55 G4VDiscreteProcess(processName, G4ProcessType::fUserDefined),
56 auxNavigator(new BDSAuxiliaryNavigator())
57{;}
58
59BDSLaserIonExcitation::~BDSLaserIonExcitation()
60{
61 delete auxNavigator;
62}
63
64G4double BDSLaserIonExcitation::GetMeanFreePath(const G4Track& track,
65 G4double /*previousStepSize*/,
66 G4ForceCondition* forceCondition)
67{
68 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
69 BDSUserTrackInformation* trackInfo = dynamic_cast<BDSUserTrackInformation*>(track.GetUserInformation());
70
71 if (!lv->IsExtended())
72 {// not extended so can't be a laser logical volume
73 return std::numeric_limits<double>::max();
74 }
75 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser*>(lv);
76 if (!lvv)
77 {// it's an extended volume but not ours (could be a crystal)
78 return std::numeric_limits<double>::max();
79 }
80 G4bool excited = trackInfo->GetElectronOccupancy()->StatePopulated(2,1,0.5);
81 if(excited)
82 {// its already in the excited state cannot be excited again
83 return std::numeric_limits<double>::max();
84 }
85
86 const BDSLaser* laser = lvv->Laser();
87 aParticleChange.Initialize(track);
88
89 *forceCondition = Forced;
90 return laser->Sigma0()/10;
91}
92
93G4VParticleChange* BDSLaserIonExcitation::PostStepDoIt(const G4Track& track,
94 const G4Step& step)
95{
96 // get coordinates for photon desity calculations
97 aParticleChange.Initialize(track);
98 //copied from mfp to access laser instance is clearly incorrect!
99
100 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
101 if (!lv->IsExtended())// not extended so can't be a laser logical volume
102 {return pParticleChange;}
103
104 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser *>(lv);
105 if (!lvv) // it's an extended volume but not ours (could be a crystal)
106 {return pParticleChange;}
107 // else proceed
108
109 const BDSLaser* laser = lvv->Laser();
110 G4double stepLength = step.GetStepLength();
111 G4DynamicParticle* ion = const_cast<G4DynamicParticle*>(track.GetDynamicParticle());
112
113 G4ThreeVector particlePositionGlobal = track.GetPosition();
114 G4ThreeVector particleDirectionMomentumGlobal = track.GetMomentumDirection();
115 const G4RotationMatrix* rot = track.GetTouchable()->GetRotation();
116 const G4AffineTransform transform = track.GetTouchable()->GetHistory()->GetTopTransform();
117 G4ThreeVector particlePositionLocal = transform.TransformPoint(particlePositionGlobal);
118 G4ThreeVector particleDirectionMomentumLocal = transform.TransformPoint(particleDirectionMomentumGlobal).unit();
119
120 BDSIonExcitationEngine* ionExcitationEngine = new BDSIonExcitationEngine();
121 // create photon
122 // photon vector in laser frame coordinates
123 G4ThreeVector photonUnit(0, 0, 1);
124 //translate into lab frame coordinates
125 G4double photonE = (CLHEP::h_Planck * CLHEP::c_light) / laser->Wavelength();
126 G4ThreeVector photonVector = photonUnit * photonE;
127 photonVector.transform(*rot);
128 G4LorentzVector photonLorentz = G4LorentzVector(photonVector, photonE);
129
130 G4double ionEnergy = ion->GetTotalEnergy();
131 G4ThreeVector ionMomentum = ion->GetMomentum();
132 G4ThreeVector ionBeta = ionMomentum / ionEnergy;
133 G4double ionVelocity = ionBeta.mag() * CLHEP::c_light;
134 photonLorentz.boost(-ionBeta);
135 G4double photonEnergy = photonLorentz.e();
136 G4double crossSection = ionExcitationEngine->CrossSection(photonEnergy);
137 G4double particleGlobalTime = track.GetGlobalTime();
138 G4double photonFlux = (laser->Intensity(particlePositionLocal)*laser->TemporalProfileGaussian(particleGlobalTime,particlePositionLocal.z()))/photonEnergy;
139 G4LorentzVector ion4Vector = ion->Get4Momentum();
140 ion4Vector.boost(-ionBeta);
141
142 G4double ionTime = (stepLength / ionVelocity);
143 G4double excitationProbability = 1.0 - std::exp(-crossSection * photonFlux * ionTime);
145 G4double scaleFactor = g->ScaleFactorLaser();
146 G4double randomNumber = G4UniformRand();
147
148 if ((excitationProbability * scaleFactor) > randomNumber)
149 {
150 BDSUserTrackInformation* userInfo = dynamic_cast<BDSUserTrackInformation*>(track.GetUserInformation());
151 userInfo->GetElectronOccupancy()->RemoveElectrons(2,0,0.5,1);
152 userInfo->GetElectronOccupancy()->AddElectrons(2,1,0.5,1);
153 userInfo->GetElectronOccupancy()->SetTimeOfExciation(ion->GetProperTime(),2,1,(1/2));
154 // Kinematics
155 ionExcitationEngine->setIncomingGamma(photonLorentz);
156 ionExcitationEngine->setIncomingIon(ion4Vector);
157 ionExcitationEngine->PhotonAbsorption(ionBeta);
158 G4LorentzVector scatteredIon = ionExcitationEngine->GetScatteredIonAbsorption();
159
160 G4LorentzVector IonLorentz = G4LorentzVector(scatteredIon.vect().unit(),scatteredIon.e());
161
162 aParticleChange.ProposeEnergy(scatteredIon.e());
163 aParticleChange.ProposeMomentumDirection(IonLorentz.getX(),IonLorentz.getY(),IonLorentz.getZ());
164 aParticleChange.ProposeWeight(scaleFactor);
165 }
166
167 delete ionExcitationEngine;
168
169 return G4VDiscreteProcess::PostStepDoIt(track,step);
170}
Extra G4Navigator to get coordinate transforms.
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
Class to provide laser intensity at any point.
Definition BDSLaser.hh:36
G4double Wavelength() const
Accessor.
Definition BDSLaser.hh:64
G4double Sigma0() const
Accessor.
Definition BDSLaser.hh:68
Extended logical volume with laser definition.
const BDSLaser * Laser() const
Access the laser.