On Sun, 11 Mar 2007, alex wrote:
> *** Discussion title: Fields: Magnetic and Otherwise
> Email replies to PublicHyperNews@slac.stanford.edu must include:
> In-Reply-To: <"/emfields/118"@geant4-hn.slac.stanford.edu>
> Subject: ...change this to be about your reply.
>
> Hello,
>
> I am trying to add a local magnetic field into a box, and I encounter
> several compiler errors that I can`t fix. I managed to add a global
> uniform magnetic field but it is not what I need, so after searching the
> forum and studying some .ppt I found at some workshops I managed to add
> the code, but I get the following errors:
>
> --------------- root@ubuntu :~/GeantProjects/teste/N01# make
>
> Making dependency for file src/ExN01DetectorConstruction.cc ...
>
> Compiling ExN01DetectorConstruction.cc ...
>
> src/ExN01DetectorConstruction.cc: In member function virtual
> G4VPhysicalVolume* ExN01DetectorConstruction::Construct():
>
> src/ExN01DetectorConstruction.cc:72: error: expected type-specifier
> before G4ClassicalRK4
>
> src/ExN01DetectorConstruction.cc:72: error: cannot convert int* to
> G4MagIntegratorStepper* in initialization
>
> src/ExN01DetectorConstruction.cc:72: error: expected , or ; before
> G4ClassicalRK4
>
> src/ExN01DetectorConstruction.cc:70: warning: unused variable myEquation
>
> make: *** [/home/oem/GeantProjects/tmp/Linux-g++/testN01/ExN01DetectorConstruction.o] Error 1
>
> ------------------
>
> Can you help me figure out what am I doing wrong? I have the following
> detectorconstruction source:
>
> -------------------- #include "ExN01DetectorConstruction.hh"
>
> #include "G4Material.hh"
> #include "G4Box.hh"
> #include "G4Tubs.hh"
> #include "G4LogicalVolume.hh"
> #include "G4ThreeVector.hh"
> #include "G4PVPlacement.hh"
> #include "globals.hh"
> #include "G4NistManager.hh"
>
> #include <G4UniformMagField.hh>
> #include <G4FieldManager.hh>
> #include <G4TransportationManager.hh>
>
> #include <G4Mag_UsualEqRhs.hh>
> #include <G4MagIntegratorStepper.hh>
> #include <G4ChordFinder.hh>
>
> ExN01DetectorConstruction::ExN01DetectorConstruction()
> : experimentalHall_log(0), tracker_log(0),
> calorimeterBlock_log(0), calorimeterLayer_log(0),
> experimentalHall_phys(0), calorimeterLayer_phys(0),
> calorimeterBlock_phys(0), tracker_phys(0)
> {;}
>
> ExN01DetectorConstruction::~ExN01DetectorConstruction() { }
>
> G4VPhysicalVolume* ExN01DetectorConstruction::Construct() {
>
> //------------------------------------------------------ materiale - definire materiale
>
> G4double a;
> G4double z;
> G4double density;
>
> G4Material* Pb = new G4Material("Lead", z= 82., a= 207.19*g/mole, density= 11.35*g/cm3); // Plumb sau Fier
>
> G4NistManager* man = G4NistManager::Instance();
> G4Material* Air = man->FindOrBuildMaterial("G4_AIR"); // Aer
> G4cout <<Air<<"\r";
> G4cout << *(G4Material::GetMaterialTable()); // lista materiale
>
> //------------------------------------------------------ volumes
>
> //------------------------------ experimental hall (world volume)
> //------------------------------ beam line along x axis
>
> G4double expHall_x = 6.0*m;
> G4double expHall_y = 3.0*m;
> G4double expHall_z = 3.0*m;
> G4Box* experimentalHall_box = new G4Box("World_Box_Shape",expHall_x,expHall_y,expHall_z); // dedinesc shape pt World Volume
> experimentalHall_log = new G4LogicalVolume(experimentalHall_box, Air,"World_Box__Logical",0,0,0); // definesc proprietati pentru World Volume
> experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), experimentalHall_log,"World_Box",0,false,0); //pozitionez in scena World Volume
>
> G4double block_x = 1.0*m;
> G4double block_y = 50.0*cm;
> G4double block_z = 50.0*cm;
>
> G4double fieldValue = 10.0*tesla;
> G4UniformMagField* myField =new G4UniformMagField(G4ThreeVector(0.0,fieldValue,0.0));
>
> G4Mag_UsualEqRhs* myEquation = new G4Mag_UsualEqRhs(myField);
>
> G4MagIntegratorStepper* myStepper = new G4ClassicalRK4(myEquation);
>
> G4ChordFinder* myChordFinder = new G4ChordFinder(myField,0.01*mm,myStepper);
>
> G4FieldManager* fieldMgr = new G4FieldManager(myField,myChordFinder);
>
> G4Box* calorimeterBlock_box = new G4Box("calorimetru_box", block_x, block_y, block_z);
> calorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box,Pb,"calorimetru_log", fieldMgr,0,0); //camp mg
>
> G4double blockPos_x = 1.0*m;
> G4double blockPos_y = 0.0*m;
> G4double blockPos_z = 0.0*m;
>
> calorimeterBlock_phys = new G4PVPlacement(0,G4ThreeVector(blockPos_x,blockPos_y,blockPos_z),calorimeterBlock_log,"calorimetru",experimentalHall_log,false,0);
>
> return experimentalHall_phys; }
>
> ------------------------
>
> Thank you for you time.
>
Hello,
There are extended examples showing how to implement magnetic field.
Please, have a look:
$G4INSTALL/examples/extended/field
VI
|