![]() |
|
|||
File indexing completed on 2025-02-23 09:21:12
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file exoticphysics/monopole/src/G4MonopoleFieldSetup.cc 0027 /// \brief Implementation of the G4MonopoleFieldSetup class 0028 // 0029 // 0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0032 // 0033 // 0034 // G4MonopoleFieldSetup is responsible for setting up a magnetic field 0035 // and the ability to use it with two different equation of motions, 0036 // one for monopoles and another for the rest of the particles. 0037 // 0038 // 0039 0040 // ======================================================================= 0041 // Created: 13 May 2010, B. Bozsogi 0042 // ======================================================================= 0043 0044 #include "G4MonopoleFieldSetup.hh" 0045 0046 #include "G4ChordFinder.hh" 0047 #include "G4FieldManager.hh" 0048 #include "G4MagIntegratorStepper.hh" 0049 #include "G4Mag_UsualEqRhs.hh" 0050 #include "G4MagneticField.hh" 0051 #include "G4MonopoleEquation.hh" 0052 #include "G4MonopoleFieldMessenger.hh" 0053 #include "G4TransportationManager.hh" 0054 #include "G4UniformMagField.hh" 0055 0056 // #include "G4ExplicitEuler.hh" 0057 // #include "G4ImplicitEuler.hh" 0058 // #include "G4SimpleRunge.hh" 0059 // #include "G4SimpleHeum.hh" 0060 #include "G4ClassicalRK4.hh" 0061 // #include "G4HelixExplicitEuler.hh" 0062 // #include "G4HelixImplicitEuler.hh" 0063 // #include "G4HelixSimpleRunge.hh" 0064 // #include "G4CashKarpRKF45.hh" 0065 // #include "G4RKG3_Stepper.hh" 0066 0067 #include "G4SystemOfUnits.hh" 0068 0069 // G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0; 0070 0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0072 0073 G4MonopoleFieldSetup::G4MonopoleFieldSetup() 0074 : fFieldManager(0), 0075 fChordFinder(0), 0076 fUsualChordFinder(0), 0077 fMonopoleChordFinder(0), 0078 fEquation(0), 0079 fMonopoleEquation(0), 0080 fMagneticField(0), 0081 fStepper(0), 0082 fMonopoleStepper(0), 0083 fMinStep(0.0), 0084 fZmagFieldValue(0.2 * tesla), 0085 fMonopoleFieldMessenger(0) 0086 { 0087 fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this); 0088 fFieldManager = GetGlobalFieldManager(); 0089 } 0090 0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0092 0093 // G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup() 0094 // { 0095 // if (0 == fMonopoleFieldSetup) 0096 // { 0097 // static G4ThreadLocal G4MonopoleFieldSetup theInstance; 0098 // fMonopoleFieldSetup = &theInstance; 0099 // } 0100 0101 // return fMonopoleFieldSetup; 0102 // } 0103 0104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0105 0106 G4MonopoleFieldSetup::~G4MonopoleFieldSetup() 0107 { 0108 delete fMonopoleFieldMessenger; 0109 if (fMagneticField) delete fMagneticField; 0110 // if(fChordFinder) delete fChordFinder; 0111 if (fUsualChordFinder) delete fUsualChordFinder; 0112 if (fMonopoleChordFinder) delete fMonopoleChordFinder; 0113 if (fStepper) delete fStepper; 0114 if (fMonopoleStepper) delete fMonopoleStepper; 0115 } 0116 0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0118 0119 void G4MonopoleFieldSetup::SetZMagFieldValue(G4double val) 0120 { 0121 // set new magnetic field value and rebuild the field 0122 fZmagFieldValue = val; 0123 0124 ConstructMagField(); 0125 } 0126 0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0128 0129 void G4MonopoleFieldSetup::ConstructMagField() 0130 { 0131 // apply a global uniform magnetic field along Z axis 0132 if (fMagneticField) { 0133 delete fMagneticField; 0134 } // delete the existing magn field 0135 0136 if (fZmagFieldValue != 0.) // create a new one if non nul 0137 { 0138 // G4cout << "Go to create new field ..." << G4endl; 0139 fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., fZmagFieldValue)); 0140 InitialiseAll(); 0141 } 0142 else { 0143 // G4cout << "Set field = 0 ..." << G4endl; 0144 fMagneticField = 0; 0145 } 0146 0147 fFieldManager->SetDetectorField(fMagneticField); 0148 } 0149 0150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0151 0152 void G4MonopoleFieldSetup::InitialiseAll() 0153 { 0154 fEquation = new G4Mag_UsualEqRhs(fMagneticField); 0155 fMonopoleEquation = new G4MonopoleEquation(fMagneticField); 0156 0157 fMinStep = 0.01 * mm; // minimal step of 1 mm is default 0158 0159 fMonopoleStepper = new G4ClassicalRK4(fMonopoleEquation, 8); 0160 fStepper = new G4ClassicalRK4(fEquation); 0161 0162 fUsualChordFinder = new G4ChordFinder(fMagneticField, fMinStep, fStepper); 0163 fMonopoleChordFinder = new G4ChordFinder(fMagneticField, fMinStep, fMonopoleStepper); 0164 0165 SetStepperAndChordFinder(0); 0166 } 0167 0168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0169 0170 void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val) 0171 { 0172 if (fMagneticField) { 0173 fFieldManager->SetDetectorField(fMagneticField); 0174 // if(fChordFinder) delete fChordFinder; 0175 0176 switch (val) { 0177 // case 0: 0178 // fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper); 0179 // break; 0180 // case 1: 0181 // fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, 0182 // fMonopoleStepper); 0183 // break; 0184 case 0: 0185 fChordFinder = fUsualChordFinder; 0186 break; 0187 case 1: 0188 fChordFinder = fMonopoleChordFinder; 0189 break; 0190 } 0191 0192 fFieldManager->SetChordFinder(fChordFinder); 0193 } 0194 } 0195 0196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0197 0198 G4FieldManager* G4MonopoleFieldSetup::GetGlobalFieldManager() 0199 { 0200 return G4TransportationManager::GetTransportationManager()->GetFieldManager(); 0201 } 0202 0203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |