Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4RK547FEq3.cc
이 파일의 문서화 페이지로 가기
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 // The Butcher table of the Higham & Hall 5(4)7 method is:
27 //
28 // 0 |
29 // 11/45 | 11/45
30 // 11/30 | 11/120 11/40
31 // 55/56 | 106865/87808 -408375/87808 193875/43904
32 // 9/10 | 79503/121000 -1053/440 147753/56870 27048/710875
33 // 1 | 89303/78045 -2025/473 994650/244541 -2547216/28122215 475/2967
34 // 1 | 1247/10890 0 57375/108053 -1229312/1962015 125/207 43/114
35 //---------------------------------------------------------------------------------------------------------------------
36 // 1247/10890 0 57375/108053 -1229312/1962015 125/207 43/114 0
37 // 21487/185130 0 963225/1836901 -39864832/33354255 2575/3519 4472/4845 -1/10
38 
39 #include "G4RK547FEq3.hh"
40 #include "G4LineSection.hh"
41 #include "G4FieldUtils.hh"
42 
43 using namespace field_utils;
44 
45 namespace {
46 
47 void copyArray(G4double dst[], const G4double src[])
48 {
49  memcpy(dst, src, sizeof(G4double) * G4FieldTrack::ncompSVEC);
50 }
51 
52 } // namespace
53 
54 G4RK547FEq3::G4RK547FEq3(G4EquationOfMotion* EqRhs, G4int integrationVariables)
55  : G4MagIntegratorStepper(EqRhs, integrationVariables)
56 {
57 }
58 
60  const G4double yInput[],
61  const G4double dydx[],
62  const G4double hstep,
63  G4double yOutput[],
64  G4double* dydxOutput,
65  G4double* yError) const
66 {
68  for (int i = GetNumberOfVariables(); i < GetNumberOfStateVariables(); ++i){
69  yOutput[i] = yTemp[i] = yInput[i];
70  }
71 
77 
78  const G4double
79  b21 = 11./45.,
80  b31 = 11./120., b32 = 11./40.,
81  b41 = 106865./87808., b42 = -408375./87808., b43 = 193875./43904.,
82  b51 = 79503./121000., b52 = -1053./440., b53 = 147753./56870.,
83  b54 = 27048./710875.,
84  b61 = 89303./78045., b62 = -2025./473., b63 = 994650./244541.,
85  b64 = -2547216./28122215., b65 = 475./2967.,
86  b71 = 1247./10890., b72 = 0., b73 = 57375./108053.,
87  b74 = -1229312./1962015., b75 = 125./207., b76 = 43./114.;
88 
89  const G4double
90  dc1 = b71 - 21487./185130.,
91  dc2 = b72 - 0.,
92  dc3 = b73 - 963225./1836901.,
93  dc4 = b74 + 39864832./33354255.,
94  dc5 = b75 - 2575./3519.,
95  dc6 = b76 - 4472./4845.,
96  dc7 = 0. + 1./10.;
97 
98  //RightHandSide(yInput, dydx);
99  for(int i = 0; i < GetNumberOfVariables(); ++i)
100  yTemp[i] = yInput[i] + hstep * b21 * dydx[i];
101 
102  RightHandSide(yTemp, ak2);
103  for(int i = 0; i < GetNumberOfVariables(); ++i)
104  yTemp[i] = yInput[i] + hstep * (b31 * dydx[i] + b32 * ak2[i]);
105 
106  RightHandSide(yTemp, ak3);
107  for(int i = 0;i < GetNumberOfVariables(); ++i)
108  yTemp[i] = yInput[i] + hstep * (b41 * dydx[i] + b42 * ak2[i] +
109  b43 * ak3[i]);
110 
111  RightHandSide(yTemp, ak4);
112  for(int i = 0; i < GetNumberOfVariables(); ++i)
113  yTemp[i] = yInput[i] + hstep * (b51 * dydx[i] + b52 * ak2[i] +
114  b53 * ak3[i] + b54 * ak4[i]);
115 
116  RightHandSide(yTemp, ak5);
117  for(int i = 0; i < GetNumberOfVariables(); ++i)
118  yTemp[i] = yInput[i] + hstep * (b61 * dydx[i] + b62 * ak2[i] +
119  b63 * ak3[i] + b64 * ak4[i] +
120  b65 * ak5[i]);
121 
122  RightHandSide(yTemp, ak6);
123  for(int i = 0; i < GetNumberOfVariables(); ++i)
124  yOutput[i] = yInput[i] + hstep * (b71 * dydx[i] + b72 * ak2[i] +
125  b73 * ak3[i] + b74 * ak4[i] +
126  b75 * ak5[i] + b76 * ak6[i]);
127 
128  if (dydxOutput && yError) {
129  RightHandSide(yOutput, dydxOutput);
130  for(int i = 0; i < GetNumberOfVariables(); ++i)
131  yError[i] = hstep * (dc1 * dydx[i] + dc2 * ak2[i] + dc3 * ak3[i] +
132  dc4 * ak4[i] + dc5 * ak5[i] + dc6 * ak6[i] +
133  dc7 * dydxOutput[i]);
134  }
135 }
136 
138  const G4double yInput[],
139  const G4double dydx[],
140  G4double hstep,
141  G4double yOutput[],
142  G4double yError[])
143 {
144  copyArray(fyIn, yInput);
145  copyArray(fdydx, dydx);
146  fhstep = hstep;
147 
148  makeStep(fyIn, fdydx, fhstep, fyOut, fdydxOut, yError);
149 
150  copyArray(yOutput, fyOut);
151 }
152 
154  const G4double yInput[],
155  const G4double dydx[],
156  G4double hstep,
157  G4double yOutput[],
158  G4double yError[],
159  G4double dydxOutput[])
160 {
161  copyArray(fyIn, yInput);
162  copyArray(fdydx, dydx);
163  fhstep = hstep;
164 
165  makeStep(fyIn, fdydx, fhstep, fyOut, fdydxOut, yError);
166 
167  copyArray(yOutput, fyOut);
168  copyArray(dydxOutput, fdydxOut);
169 }
170 
172 {
174  makeStep(fyIn, fdydx, fhstep / 2., yMid);
175 
176  const G4ThreeVector begin = makeVector(fyIn, Value3D::Position);
177  const G4ThreeVector mid = makeVector(yMid, Value3D::Position);
178  const G4ThreeVector end = makeVector(fyOut, Value3D::Position);
179 
180  return G4LineSection::Distline(mid, begin, end);
181 }
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4ThreeVector makeVector(const ArrayType &array, Value3D value)
G4RK547FEq3(G4EquationOfMotion *EqRhs, G4int integrationVariables=6)
Definition: G4RK547FEq3.cc:54
G4double fyIn[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq3.hh:80
double G4double
Definition: G4Types.hh:76
virtual G4double DistChord() const override
Definition: G4RK547FEq3.cc:171
G4int GetNumberOfStateVariables() const
G4double fyOut[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq3.hh:80
void makeStep(const G4double yInput[], const G4double dydx[], const G4double hstep, G4double yOutput[], G4double *dydxOutput=nullptr, G4double *yError=nullptr) const
Definition: G4RK547FEq3.cc:59
void RightHandSide(const double y[], double dydx[]) const
G4double fdydx[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq3.hh:80
G4double fhstep
Definition: G4RK547FEq3.hh:84
int G4int
Definition: G4Types.hh:78
G4double fdydxOut[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq3.hh:80
static const G4double ak2
G4int GetNumberOfVariables() const
virtual void Stepper(const G4double yInput[], const G4double dydx[], G4double hstep, G4double yOutput[], G4double yError[]) override
Definition: G4RK547FEq3.cc:137