Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4RK547FEq2.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 // 2/13 | 2/13
30 // 2/13 | 3/52 9/52
31 // 5/9 | 12955/26244 -15925/8748 12350/6561
32 // 3/4 | -10383/52480 13923/10496 -176553/199424 505197/997120
33 // 1 | 1403/7236 -429/268 733330/309339 -7884/8911 104960/113967
34 // 1 | 181/2700 0 656903/1846800 19683/106400 34112/110565 67/800
35 //----------------------------------------------------------------------------------------------------------------------
36 // 181/2700 0 656903/1846800 19683/106400 34112/110565 67/800 0
37 // 11377/154575 0 35378291/105729300 343359/1522850 535952/1947645 134/17175 1/12
38 
39 #include "G4RK547FEq2.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 G4RK547FEq2::G4RK547FEq2(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 = 2./13.,
80  b31 = 3./52., b32 = 9./52.,
81  b41 = 12955./26244., b42 = -15925./8748., b43 = 12350./6561.,
82  b51 = -10383./52480., b52 = 13923./10496., b53 = -176553./199424.,
83  b54 = 505197./997120.,
84  b61 = 1403./7236., b62 = -429./268., b63 = 733330./309339.,
85  b64 = -7884./8911., b65 = 104960./113967.,
86  b71 = 181./2700., b72 = 0., b73 = 656903./1846800.,
87  b74 = 19683./106400., b75 = 34112./110565., b76 = 67./800.;
88 
89  const G4double
90  dc1 = b71 - 11377./154575.,
91  dc2 = b72 - 0.,
92  dc3 = b73 - 35378291./105729300.,
93  dc4 = b74 - 343359./1522850.,
94  dc5 = b75 - 535952./1947645.,
95  dc6 = b76 - 134./17175.,
96  dc7 = 0. - 1./12.;
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 }
virtual G4double DistChord() const override
Definition: G4RK547FEq2.cc:171
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4ThreeVector makeVector(const ArrayType &array, Value3D value)
G4RK547FEq2(G4EquationOfMotion *EqRhs, G4int integrationVariables=6)
Definition: G4RK547FEq2.cc:54
void makeStep(const G4double yInput[], const G4double dydx[], const G4double hstep, G4double yOutput[], G4double *dydxOutput=nullptr, G4double *yError=nullptr) const
Definition: G4RK547FEq2.cc:59
G4double fyIn[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq2.hh:80
G4double fdydx[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq2.hh:80
double G4double
Definition: G4Types.hh:76
G4int GetNumberOfStateVariables() const
void RightHandSide(const double y[], double dydx[]) const
int G4int
Definition: G4Types.hh:78
static const G4double ak2
G4double fyOut[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq2.hh:80
virtual void Stepper(const G4double yInput[], const G4double dydx[], G4double hstep, G4double yOutput[], G4double yError[]) override
Definition: G4RK547FEq2.cc:137
G4double fdydxOut[G4FieldTrack::ncompSVEC]
Definition: G4RK547FEq2.hh:80
G4int GetNumberOfVariables() const
G4double fhstep
Definition: G4RK547FEq2.hh:84