Message: Re: Need help implementing a radial electric field Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Ok Re: Need help implementing a radial electric field 

Keywords: radial electric field
Forum: Fields: Magnetic and Otherwise
Re: Question Need help implementing a radial electric field (Andrew Dummer)
Date: 22 Mar, 2004
From: John Apostolakis <John Apostolakis>

Dear Andrew, 

To use this or another type of field, you will need to create a new
class for this case, which can be similar to the Uniform Electric Field. 

http://www-geant4.kek.jp/lxr/source/geometry/magneticfield/include/G4UniformElectricField.hh
and
http://www-geant4.kek.jp/lxr/source/geometry/magneticfield/src/G4UniformElectricField.cc

The class can eg take V, b, a and an Axis as parameters.

In addition to the same include files etc, the core of an 
include file RadialElectricField.hh can be something like:

class RadialElectricField : public G4ElectricField
{
  public: 
   RadialElectricField( G4double Voltage, G4double b, G4double a);

   virtual void GetFieldValue(const    G4double pos[4], 
                              G4double *field) const;
  private: 
   G4double fVoltage;
   G4double fLogBAratio;
   G4ThreeVector  fAxis; 
}

and the core of the source file can be:

RadialElectricField::
RadialElectricField(G4double Voltage, G4double b, 
                      G4double a,       G4ThreeVector Axis)
)
{ 
  fVoltage=    Voltage;   
  fLogBAratio= std::log(b/a); 
  fAxis=       Axis; 
}

RadialElectricField::GetFieldValue(const    G4double pos[4], 
                              G4double *field) const
{
  G4ThreeVector  position(pos[0], pos[1], pos[2]); 

  G4double radius = ... calculation of radius using Axis ...
 
  G4double fieldMag= Voltage / ( radius * fLogBAratio )  

  // Calculate direction here
  G4ThreeVector  unitDir = ....

  G4ThreeVector  Efield= fieldMag * unitDir; 

  // Return the field value
  field[0]= field[1]= field[2]= 0.0;   // Magnetic field
  field[3]= Efield.x(); 
  field[4]= Efield.y();
  field[5]= Efield.z();

}

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Re: Need help implementing a radial electric field"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]