|
|
|||
File indexing completed on 2026-09-20 08:29:59
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 G4MonopoleFieldSetup.cc 0027 /// \brief Implementation of the G4MonopoleFieldSetup class 0028 0029 // G4MonopoleFieldSetup is responsible for setting up a magnetic field 0030 // and the ability to use it with two different equation of motions, 0031 // one for monopoles and another for the rest of the particles. 0032 // 0033 // 0034 0035 // ======================================================================= 0036 // Created: 13 May 2010, B. Bozsogi 0037 // ======================================================================= 0038 0039 #include "G4MonopoleFieldSetup.hh" 0040 0041 #include "G4ChordFinder.hh" 0042 #include "G4FieldManager.hh" 0043 #include "G4MagIntegratorStepper.hh" 0044 #include "G4Mag_UsualEqRhs.hh" 0045 #include "G4MagneticField.hh" 0046 #include "G4MonopoleEquation.hh" 0047 #include "G4MonopoleFieldMessenger.hh" 0048 #include "G4TransportationManager.hh" 0049 #include "G4UniformMagField.hh" 0050 0051 // #include "G4ExplicitEuler.hh" 0052 // #include "G4ImplicitEuler.hh" 0053 // #include "G4SimpleRunge.hh" 0054 // #include "G4SimpleHeum.hh" 0055 #include "G4ClassicalRK4.hh" 0056 // #include "G4HelixExplicitEuler.hh" 0057 // #include "G4HelixImplicitEuler.hh" 0058 // #include "G4HelixSimpleRunge.hh" 0059 // #include "G4CashKarpRKF45.hh" 0060 // #include "G4RKG3_Stepper.hh" 0061 0062 #include "G4SystemOfUnits.hh" 0063 0064 // G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0; 0065 0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0067 0068 G4MonopoleFieldSetup::G4MonopoleFieldSetup() 0069 : fFieldManager(0), 0070 fChordFinder(0), 0071 fUsualChordFinder(0), 0072 fMonopoleChordFinder(0), 0073 fEquation(0), 0074 fMonopoleEquation(0), 0075 fMagneticField(0), 0076 fStepper(0), 0077 fMonopoleStepper(0), 0078 fMinStep(0.0), 0079 fZmagFieldValue(0.2 * tesla), 0080 fMonopoleFieldMessenger(0) 0081 { 0082 fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this); 0083 fFieldManager = GetGlobalFieldManager(); 0084 } 0085 0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0087 0088 // G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup() 0089 // { 0090 // if (0 == fMonopoleFieldSetup) 0091 // { 0092 // static G4ThreadLocal G4MonopoleFieldSetup theInstance; 0093 // fMonopoleFieldSetup = &theInstance; 0094 // } 0095 0096 // return fMonopoleFieldSetup; 0097 // } 0098 0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0100 0101 G4MonopoleFieldSetup::~G4MonopoleFieldSetup() 0102 { 0103 delete fMonopoleFieldMessenger; 0104 if (fMagneticField) delete fMagneticField; 0105 // if(fChordFinder) delete fChordFinder; 0106 if (fUsualChordFinder) delete fUsualChordFinder; 0107 if (fMonopoleChordFinder) delete fMonopoleChordFinder; 0108 if (fStepper) delete fStepper; 0109 if (fMonopoleStepper) delete fMonopoleStepper; 0110 } 0111 0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0113 0114 void G4MonopoleFieldSetup::SetZMagFieldValue(G4double val) 0115 { 0116 // set new magnetic field value and rebuild the field 0117 fZmagFieldValue = val; 0118 0119 ConstructMagField(); 0120 } 0121 0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0123 0124 void G4MonopoleFieldSetup::ConstructMagField() 0125 { 0126 // apply a global uniform magnetic field along Z axis 0127 if (fMagneticField) { 0128 delete fMagneticField; 0129 } // delete the existing magn field 0130 0131 if (fZmagFieldValue != 0.) // create a new one if non nul 0132 { 0133 // G4cout << "Go to create new field ..." << G4endl; 0134 fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., fZmagFieldValue)); 0135 InitialiseAll(); 0136 } 0137 else { 0138 // G4cout << "Set field = 0 ..." << G4endl; 0139 fMagneticField = 0; 0140 } 0141 0142 fFieldManager->SetDetectorField(fMagneticField); 0143 } 0144 0145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0146 0147 void G4MonopoleFieldSetup::InitialiseAll() 0148 { 0149 fEquation = new G4Mag_UsualEqRhs(fMagneticField); 0150 fMonopoleEquation = new G4MonopoleEquation(fMagneticField); 0151 0152 fMinStep = 0.01 * mm; // minimal step of 1 mm is default 0153 0154 fMonopoleStepper = new G4ClassicalRK4(fMonopoleEquation, 8); 0155 fStepper = new G4ClassicalRK4(fEquation); 0156 0157 fUsualChordFinder = new G4ChordFinder(fMagneticField, fMinStep, fStepper); 0158 fMonopoleChordFinder = new G4ChordFinder(fMagneticField, fMinStep, fMonopoleStepper); 0159 0160 SetStepperAndChordFinder(0); 0161 } 0162 0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0164 0165 void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val) 0166 { 0167 if (fMagneticField) { 0168 fFieldManager->SetDetectorField(fMagneticField); 0169 // if(fChordFinder) delete fChordFinder; 0170 0171 switch (val) { 0172 // case 0: 0173 // fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper); 0174 // break; 0175 // case 1: 0176 // fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, 0177 // fMonopoleStepper); 0178 // break; 0179 case 0: 0180 fChordFinder = fUsualChordFinder; 0181 break; 0182 case 1: 0183 fChordFinder = fMonopoleChordFinder; 0184 break; 0185 } 0186 0187 fFieldManager->SetChordFinder(fChordFinder); 0188 } 0189 } 0190 0191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0192 0193 G4FieldManager* G4MonopoleFieldSetup::GetGlobalFieldManager() 0194 { 0195 return G4TransportationManager::GetTransportationManager()->GetFieldManager(); 0196 } 0197 0198 //....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 |
|