Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -112,9 +112,16 @@ G4OpBoundaryProcess::G4OpBoundaryProcess(const G4String& processName,
prob_ss = 0.;
prob_bs = 0.;
PropertyPointer = NULL;
PropertyPointer1 = NULL;
PropertyPointer2 = NULL;
kCarTolerance = G4GeometryTolerance::GetInstance()
->GetSurfaceTolerance();
iTE = iTM = 0;
thePhotonMomentum = 0.;
Rindex1 = Rindex2 = cost1 = cost2 = sint1 = sint2 = 0.;
}
// G4OpBoundaryProcess::G4OpBoundaryProcess(const G4OpBoundaryProcess &right)
@@ -227,6 +234,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -237,6 +245,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -306,6 +315,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -370,6 +380,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else if (theFinish == polishedbackpainted ||
theFinish == groundbackpainted ) {
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -393,6 +404,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -417,26 +429,28 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else if (type == dielectric_dielectric) {
if ( theFinish == polishedfrontpainted ||
theFinish == groundfrontpainted ) {
if( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
}
else {
if ( theFinish == groundfrontpainted )
theStatus = LambertianReflection;
DoReflection();
}
}
if ( theFinish == polishedbackpainted ||
theFinish == groundbackpainted ) {
DielectricDielectric();
}
else {
if( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
}
else {
DielectricDielectric();
}
}
}
if ( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
}
else {
if ( theFinish == polishedfrontpainted ) {
DoReflection();
}
else if ( theFinish == groundfrontpainted ) {
theStatus = LambertianReflection;
DoReflection();
}
else {
DielectricDielectric();
}
}
}
}
else {
G4cerr << " Error: G4BoundaryProcess: illegal boundary type " << G4endl;
@@ -780,13 +794,13 @@ void G4OpBoundaryProcess::DielectricDielectric()
G4SwapPtr(Material1,Material2);
G4SwapObj(&Rindex1,&Rindex2);
}
if ( theFinish == ground || theFinish == groundbackpainted ) {
theFacetNormal =
GetFacetNormal(OldMomentum,theGlobalNormal);
if ( theFinish == polished ) {
theFacetNormal = theGlobalNormal;
}
else {
theFacetNormal = theGlobalNormal;
theFacetNormal =
GetFacetNormal(OldMomentum,theGlobalNormal);
}
G4double PdotN = OldMomentum * theFacetNormal;
+189
View File
@@ -0,0 +1,189 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
////////////////////////////////////////////////////////////////////////
//
// File G4OpMieHG.hh
// Description: Discrete Process -- Mie Scattering of Optical Photons
// Created: 2010-07-03
// Author: Xin Qian
// Based on work from Vlasios Vasileiou
//
// This subroutine will mimic the Mie scattering based on
// Henyey-Greenstein phase function
// Forward and backward angles are treated separately.
//
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
#include "G4OpProcessSubType.hh"
#include "G4OpMieHG.hh"
G4OpMieHG::G4OpMieHG(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
{
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created " << G4endl;
}
SetProcessSubType(fOpMieHG);
}
G4OpMieHG::~G4OpMieHG(){}
////////////
// Methods
////////////
// PostStepDoIt
// -------------
//
G4VParticleChange*
G4OpMieHG::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4Material* aMaterial = aTrack.GetMaterial();
G4MaterialPropertiesTable* aMaterialPropertyTable =
aMaterial->GetMaterialPropertiesTable();
G4double forward_g =
aMaterialPropertyTable->GetConstProperty("MIEHG_FORWARD");
G4double backward_g =
aMaterialPropertyTable->GetConstProperty("MIEHG_BACKWARD");
G4double ForwardRatio =
aMaterialPropertyTable->GetConstProperty("MIEHG_FORWARD_RATIO");
if (verboseLevel>0) {
G4cout << "MIE Scattering Photon!" << G4endl;
G4cout << "MIE Old Momentum Direction: "
<< aParticle->GetMomentumDirection() << G4endl;
G4cout << "MIE Old Polarization: "
<< aParticle->GetPolarization() << G4endl;
}
G4double g;
G4int direction;
if (G4UniformRand()<=ForwardRatio){
g = forward_g;
direction = 1;
} else {
g = backward_g;
direction = -1;
}
G4double r = G4UniformRand();
G4double Theta;
//sample the direction
if (g!=0) {
Theta = std::acos(2*r*(1+g)*(1+g)*(1-g+g*r)/((1-g+2*g*r)*(1-g+2*g*r)) -1);
} else {
Theta = std::acos(2*r-1.);
}
G4double Phi = G4UniformRand()*2*pi;
if (direction==-1) Theta = pi - Theta; //backward scattering
G4ThreeVector NewMomentumDirection, OldMomentumDirection;
G4ThreeVector OldPolarization, NewPolarization;
NewMomentumDirection.set
(std::sin(Theta)*std::cos(Phi), std::sin(Theta)*std::sin(Phi), std::cos(Theta));
OldMomentumDirection = aParticle->GetMomentumDirection();
NewMomentumDirection.rotateUz(OldMomentumDirection);
NewMomentumDirection = NewMomentumDirection.unit();
OldPolarization = aParticle->GetPolarization();
G4double constant = -1./NewMomentumDirection.dot(OldPolarization);
NewPolarization = NewMomentumDirection + constant*OldPolarization;
NewPolarization = NewPolarization.unit();
if (NewPolarization.mag()==0) {
r = G4UniformRand()*twopi;
NewPolarization.set(std::cos(r),std::sin(r),0.);
NewPolarization.rotateUz(NewMomentumDirection);
} else {
// There are two directions which perpendicular
// new momentum direction
if (G4UniformRand() < 0.5) NewPolarization = -NewPolarization;
}
aParticleChange.ProposePolarization(NewPolarization);
aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
if (verboseLevel>0) {
G4cout << "MIE New Polarization: "
<< NewPolarization << G4endl;
G4cout << "MIE Polarization Change: "
<< *(aParticleChange.GetPolarization()) << G4endl;
G4cout << "MIE New Momentum Direction: "
<< NewMomentumDirection << G4endl;
G4cout << "MIE Momentum Change: "
<< *(aParticleChange.GetMomentumDirection()) << G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
// GetMeanFreePath()
// -----------------
//
G4double G4OpMieHG::GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4ForceCondition* )
{
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4Material* aMaterial = aTrack.GetMaterial();
G4double thePhotonEnergy = aParticle->GetTotalEnergy();
G4double AttenuationLength = DBL_MAX;
G4MaterialPropertiesTable* aMaterialPropertyTable =
aMaterial->GetMaterialPropertiesTable();
if (aMaterialPropertyTable) {
G4MaterialPropertyVector* AttenuationLengthVector =
aMaterialPropertyTable->GetProperty("MIEHG");
if (AttenuationLengthVector) {
AttenuationLength = AttenuationLengthVector ->
GetProperty(thePhotonEnergy);
} else {
// G4cout << "No Mie scattering length specified" << G4endl;
}
} else {
// G4cout << "No Mie scattering length specified" << G4endl;
}
// G4cout << thePhotonEnergy/GeV << " \t" << AttenuationLength/m << G4endl;
return AttenuationLength;
}
+72 -57
View File
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4OpRayleigh.cc,v 1.17 2008/10/24 19:51:12 gum Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4OpRayleigh.cc,v 1.19 2010/10/29 23:18:35 gum Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
////////////////////////////////////////////////////////////////////////
@@ -38,7 +38,9 @@
// Version: 1.0
// Created: 1996-05-31
// Author: Juliet Armstrong
// Updated: 2005-07-28 - add G4ProcessType to constructor
// Updated: 2010-06-11 - Fix Bug 207; Thanks to Xin Qian
// (Kellogg Radiation Lab of Caltech)
// 2005-07-28 - add G4ProcessType to constructor
// 2001-10-18 by Peter Gumplinger
// eliminate unused variable warning on Linux (gcc-2.95.2)
// 2001-09-18 by mma
@@ -115,7 +117,7 @@ G4OpRayleigh::~G4OpRayleigh()
// PostStepDoIt
// -------------
//
G4VParticleChange*
G4VParticleChange*
G4OpRayleigh::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
@@ -123,68 +125,82 @@ G4OpRayleigh::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
if (verboseLevel>0) {
G4cout << "Scattering Photon!" << G4endl;
G4cout << "Old Momentum Direction: "
<< aParticle->GetMomentumDirection() << G4endl;
G4cout << "Old Polarization: "
<< aParticle->GetPolarization() << G4endl;
}
G4cout << "Scattering Photon!" << G4endl;
G4cout << "Old Momentum Direction: "
<< aParticle->GetMomentumDirection() << G4endl;
G4cout << "Old Polarization: "
<< aParticle->GetPolarization() << G4endl;
}
// find polar angle w.r.t. old polarization vector
G4double cosTheta;
G4ThreeVector OldMomentumDirection, NewMomentumDirection;
G4ThreeVector OldPolarization, NewPolarization;
G4double rand = G4UniformRand();
do {
// Try to simulate the scattered photon momentum direction
// w.r.t. the initial photon momentum direction
G4double CosTheta = std::pow(rand, 1./3.);
G4double SinTheta = std::sqrt(1.-CosTheta*CosTheta);
G4double CosTheta = G4UniformRand();
G4double SinTheta = std::sqrt(1.-CosTheta*CosTheta);
// consider for the angle 90-180 degrees
if (G4UniformRand() < 0.5) CosTheta = -CosTheta;
if(G4UniformRand() < 0.5)CosTheta = -CosTheta;
// simulate the phi angle
G4double rand = twopi*G4UniformRand();
G4double SinPhi = std::sin(rand);
G4double CosPhi = std::cos(rand);
// find azimuthal angle w.r.t old polarization vector
// start constructing the new momentum direction
G4double unit_x = SinTheta * CosPhi;
G4double unit_y = SinTheta * SinPhi;
G4double unit_z = CosTheta;
NewMomentumDirection.set (unit_x,unit_y,unit_z);
rand = G4UniformRand();
// Rotate the new momentum direction into global reference system
OldMomentumDirection = aParticle->GetMomentumDirection();
OldMomentumDirection = OldMomentumDirection.unit();
NewMomentumDirection.rotateUz(OldMomentumDirection);
NewMomentumDirection = NewMomentumDirection.unit();
G4double Phi = twopi*rand;
G4double SinPhi = std::sin(Phi);
G4double CosPhi = std::cos(Phi);
G4double unit_x = SinTheta * CosPhi;
G4double unit_y = SinTheta * SinPhi;
G4double unit_z = CosTheta;
G4ThreeVector NewPolarization (unit_x,unit_y,unit_z);
// calculate the new polarization direction
// The new polarization needs to be in the same plane as the new
// momentum direction and the old polarization direction
OldPolarization = aParticle->GetPolarization();
G4double constant = -1./NewMomentumDirection.dot(OldPolarization);
// Rotate new polarization direction into global reference system
NewPolarization = NewMomentumDirection + constant*OldPolarization;
NewPolarization = NewPolarization.unit();
G4ThreeVector OldPolarization = aParticle->GetPolarization();
OldPolarization = OldPolarization.unit();
// There is a corner case, where the Newmomentum direction
// is the same as oldpolariztion direction:
// random generate the azimuthal angle w.r.t. Newmomentum direction
if (NewPolarization.mag() == 0.) {
rand = G4UniformRand()*twopi;
NewPolarization.set(std::cos(rand),std::sin(rand),0.);
NewPolarization.rotateUz(NewMomentumDirection);
} else {
// There are two directions which are perpendicular
// to the new momentum direction
if (G4UniformRand() < 0.5) NewPolarization = -NewPolarization;
}
// simulate according to the distribution cos^2(theta)
cosTheta = NewPolarization.dot(OldPolarization);
} while (std::pow(cosTheta,2) < G4UniformRand());
NewPolarization.rotateUz(OldPolarization);
NewPolarization = NewPolarization.unit();
// -- new momentum direction is normal to the new
// polarization vector and in the same plane as the
// old and new polarization vectors --
G4ThreeVector NewMomentumDirection =
OldPolarization - NewPolarization * CosTheta;
if(G4UniformRand() < 0.5)NewMomentumDirection = -NewMomentumDirection;
NewMomentumDirection = NewMomentumDirection.unit();
aParticleChange.ProposePolarization(NewPolarization);
aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
aParticleChange.ProposePolarization(NewPolarization);
aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
if (verboseLevel>0) {
G4cout << "New Polarization: "
<< NewPolarization << G4endl;
G4cout << "Polarization Change: "
<< *(aParticleChange.GetPolarization()) << G4endl;
G4cout << "New Momentum Direction: "
<< NewMomentumDirection << G4endl;
G4cout << "Momentum Change: "
<< *(aParticleChange.GetMomentumDirection()) << G4endl;
}
G4cout << "New Polarization: "
<< NewPolarization << G4endl;
G4cout << "Polarization Change: "
<< *(aParticleChange.GetPolarization()) << G4endl;
G4cout << "New Momentum Direction: "
<< NewMomentumDirection << G4endl;
G4cout << "Momentum Change: "
<< *(aParticleChange.GetMomentumDirection()) << G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -210,8 +226,7 @@ void G4OpRayleigh::BuildThePhysicsTable()
for (G4int i=0 ; i < numOfMaterials; i++)
{
G4PhysicsOrderedFreeVector* ScatteringLengths =
new G4PhysicsOrderedFreeVector();
G4PhysicsOrderedFreeVector* ScatteringLengths = NULL;
G4MaterialPropertiesTable *aMaterialPropertiesTable =
(*theMaterialTable)[i]->GetMaterialPropertiesTable();
@@ -230,7 +245,7 @@ void G4OpRayleigh::BuildThePhysicsTable()
DefaultWater = true;
ScatteringLengths =
ScatteringLengths =
RayleighAttenuationLengthGenerator(aMaterialPropertiesTable);
}
}