Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TExplicitEuler.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4TExplicitEuler
27//
28// Class description:
29//
30// Templated version of G4ExplicitEuler
31//
32//
33// Created: Josh Xie, June 2014 (supported by Google Summer of Code 2014 )
34//
35// Supervisors: Sandro Wenzel, John Apostolakis (CERN)
36// Adapted from G4G4TExplicitEuler class
37// -------------------------------------------------------------------
38//
39// Information from G4Explicit Euler:
40// ----------------------------------
41// Explicit Euler stepper for magnetic field: x_1 = x_0 + h * dx_0.
42// The simplistic approach to solving linear differential equations.
43// Take the current derivative and add it to the current position.
44//
45// Created: W.Wander <[email protected]>, 12.09.1997
46// -------------------------------------------------------------------
47
48// --------------------------------------------------------------------
49#ifndef G4TExplicitEuler_HH
50#define G4TExplicitEuler_HH
51
52#include "G4TMagErrorStepper.hh"
53#include "G4ThreeVector.hh"
54
55template <class T_Equation, int N>
57 : public G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N>
58{
59 public: // with description
60 static constexpr double IntegratorCorrection = 1.;
61
62 G4TExplicitEuler(T_Equation* EqRhs, G4int numberOfVariables = N)
63 : G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N>(
64 EqRhs, numberOfVariables)
65 , fEquation_Rhs(EqRhs)
66 {
67 if( numberOfVariables != N ){
69 msg << "Equation has an incompatible number of variables." ;
70 msg << " template N = " << N << " equation-Nvar= "
71 << numberOfVariables;
72 G4Exception("G4TExplicitEuler: constructor", "GeomField0003",
74 }
75 }
76
78
79 inline void DumbStepper(const G4double yIn[],
80 const G4double dydx[],
81 G4double h, G4double yOut[]) // override final
82 {
83 // Initialise time to t0, needed when it is not updated by the integration.
84 // yOut[7] = yIn[7]; // Better to set it to NaN; // TODO
85
86 for(G4int i = 0; i < N; ++i)
87 {
88 yOut[i] = yIn[i] + h * dydx[i]; // 1st and only Step
89 }
90
91 return;
92 }
93
94 public: // without description
95 G4int IntegratorOrder() const { return 1; }
96
97 private:
98 T_Equation* fEquation_Rhs;
99};
100
101#endif /* G4TExplicitEuler_HH */
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
static constexpr double IntegratorCorrection
void DumbStepper(const G4double yIn[], const G4double dydx[], G4double h, G4double yOut[])
G4int IntegratorOrder() const
G4TExplicitEuler(T_Equation *EqRhs, G4int numberOfVariables=N)
#define N
Definition crc32.c:57