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) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSFieldESinusoid.hh"
19#include "BDSMagnetStrength.hh"
20#include "BDSUtilities.hh"
21
22#include "G4ThreeVector.hh"
23#include "G4Types.hh"
24
25#include "CLHEP/Units/SystemOfUnits.h"
26
27#include <cmath>
28
29BDSFieldESinusoid::BDSFieldESinusoid(BDSMagnetStrength const* strength):
30 BDSFieldESinusoid((*strength)["efield"],
31 G4ThreeVector( (*strength)["ex"], (*strength)["ey"], (*strength)["ez"]),
32 (*strength)["frequency"],
33 (*strength)["phase"],
34 (*strength)["synchronousT0"])
35{;}
36
37BDSFieldESinusoid::BDSFieldESinusoid(G4double eFieldAmplitudeIn,
38 const G4ThreeVector& unitDirectionIn,
39 G4double frequencyIn,
40 G4double phaseIn,
41 G4double synchronousTIn):
42 eField(eFieldAmplitudeIn),
43 unitDirection(unitDirectionIn.unit()),
44 angularFrequency(CLHEP::twopi*frequencyIn),
45 phase(phaseIn),
46 synchronousT(synchronousTIn)
47{
49}
50
51G4ThreeVector BDSFieldESinusoid::GetField(const G4ThreeVector& /*position*/,
52 const G4double t) const
53{
54 G4double ef = eField * std::cos(angularFrequency*(t - synchronousT) + phase);
55 G4ThreeVector field = unitDirection * ef;
56 return field;
57}
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:82
Efficient storage of magnet strengths.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())