BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldESinusoid.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
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 "G4ThreeVector.hh"
24#include "G4Types.hh"
25
26#include "CLHEP/Units/SystemOfUnits.h"
27
28#include <cmath>
29
30BDSFieldESinusoid::BDSFieldESinusoid(BDSMagnetStrength const* strength):
31 BDSFieldESinusoid((*strength)["efield"],
32 G4ThreeVector( (*strength)["ex"], (*strength)["ey"], (*strength)["ez"]),
33 (*strength)["frequency"],
34 (*strength)["phase"],
35 (*strength)["synchronousT0"])
36{;}
37
38BDSFieldESinusoid::BDSFieldESinusoid(G4double eFieldAmplitudeIn,
39 const G4ThreeVector& unitDirectionIn,
40 G4double frequencyIn,
41 G4double phaseIn,
42 G4double synchronousTIn):
43 eField(eFieldAmplitudeIn),
44 unitDirection(unitDirectionIn.unit()),
45 angularFrequency(CLHEP::twopi*frequencyIn),
46 phase(phaseIn),
47 synchronousT(synchronousTIn)
48{
50}
51
52G4ThreeVector BDSFieldESinusoid::GetField(const G4ThreeVector& /*position*/,
53 const G4double t) const
54{
55 G4double ef = eField * std::cos(angularFrequency*(t - synchronousT) + phase);
56 G4ThreeVector field = unitDirection * ef;
57 return field;
58}
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.
const G4ThreeVector unitDirection
Peak amplitude of electric field.
G4double synchronousT
Global T offset for 0 phase.
G4bool finiteStrength
Flag to cache whether finite nor not.
Definition BDSFieldE.hh:83
Efficient storage of magnet strengths.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())