BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSFieldESinusoid.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSFieldESinusoid.hh"
20#include "BDSMagnetStrength.hh"
21#include "BDSUtilities.hh"
22
23#include "globals.hh"
24#include "G4ThreeVector.hh"
25
26#include "CLHEP/Units/SystemOfUnits.h"
27
28#include <cmath>
29
31 G4double brho):
32 BDSFieldESinusoid((*strength)["efield"],
33 (*strength)["frequency"],
34 (*strength)["phase"])
35{
36 G4int sign = BDS::Sign(brho);
37 eField *= sign;
38}
39
40BDSFieldESinusoid::BDSFieldESinusoid(G4double eFieldAmplitudeIn,
41 G4double frequencyIn,
42 G4double phaseOffsetIn):
43 eField(eFieldAmplitudeIn),
44 angularFrequency(CLHEP::twopi*frequencyIn),
45 phase(phaseOffsetIn)
46{
48}
49
50G4ThreeVector BDSFieldESinusoid::GetField(const G4ThreeVector& /*position*/,
51 const G4double t) const
52{
53 G4double eZ = eField*std::cos(angularFrequency*t + phase);
54 G4ThreeVector field = G4ThreeVector(0, 0, eZ);
55 return field;
56}
A sinusoidal electric (only) field that doesn't vary with position. Uses cosine.
G4double angularFrequency
Angular frequency of field.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t) const
Accessor for field value.
G4double eField
Amplitude of electric field in V/m.
G4double phase
Phase in radians.
BDSFieldESinusoid()=delete
Private default constructor to force use of supplied one.
G4bool finiteStrength
Flag to cache whether finite nor not.
Definition: BDSFieldE.hh:74
Efficient storage of magnet strengths.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())