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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/magneticfield/src/G4RK547FEq1.cc (Version 11.3.0) and /geometry/magneticfield/src/G4RK547FEq1.cc (Version 10.6)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4RK547FEq1 implementation                      26 // G4RK547FEq1 implementation
 27 //                                                 27 //
 28 // The Butcher table of the Higham & Hall 5(4)     28 // The Butcher table of the Higham & Hall 5(4)7 method is:
 29 //                                                 29 //
 30 //   0  |                                          30 //   0  |
 31 //  2/9 |      2/9                                 31 //  2/9 |      2/9
 32 //  1/3 |      1/12      1/4                       32 //  1/3 |      1/12      1/4
 33 //  1/2 |      1/8       0          3/8            33 //  1/2 |      1/8       0          3/8
 34 //  3/5 |      91/500    -27/100    78/125         34 //  3/5 |      91/500    -27/100    78/125    8/125
 35 //   1  |      -11/20    27/20      12/5           35 //   1  |      -11/20    27/20      12/5      -36/5    5
 36 //   1  |      1/12      0          27/32          36 //   1  |      1/12      0          27/32     -4/3     125/96    5/48
 37 //--------------------------------------------     37 //----------------------------------------------------------------------------
 38 //             1/12      0          27/32          38 //             1/12      0          27/32     -4/3     125/96    5/48    0
 39 //             2/15      0          27/80          39 //             2/15      0          27/80     -2/15    25/48     1/24    1/10
 40 //                                                 40 //
 41 // Author: Dmitry Sorokin, Google Summer of Co     41 // Author: Dmitry Sorokin, Google Summer of Code 2017
 42 // Supervision: John Apostolakis, CERN             42 // Supervision: John Apostolakis, CERN
 43 // -------------------------------------------     43 // --------------------------------------------------------------------
 44                                                    44 
 45 #include "G4RK547FEq1.hh"                          45 #include "G4RK547FEq1.hh"
 46 #include "G4LineSection.hh"                        46 #include "G4LineSection.hh"
 47 #include "G4FieldUtils.hh"                         47 #include "G4FieldUtils.hh"
 48                                                    48 
 49 using namespace field_utils;                       49 using namespace field_utils;
 50                                                    50 
 51 G4RK547FEq1::G4RK547FEq1(G4EquationOfMotion* E     51 G4RK547FEq1::G4RK547FEq1(G4EquationOfMotion* EqRhs, G4int integrationVariables)
 52   : G4MagIntegratorStepper(EqRhs, integrationV     52   : G4MagIntegratorStepper(EqRhs, integrationVariables)
 53 {                                                  53 {
 54 }                                                  54 }
 55                                                    55 
 56 void G4RK547FEq1::makeStep( const G4double yIn     56 void G4RK547FEq1::makeStep( const G4double yInput[],
 57                             const G4double dyd     57                             const G4double dydx[],
 58                             const G4double hst     58                             const G4double hstep,
 59                                   G4double yOu     59                                   G4double yOutput[],
 60                                   G4double* dy     60                                   G4double* dydxOutput,
 61                                   G4double* yE     61                                   G4double* yError ) const
 62 {                                                  62 {
 63     G4double yTemp[G4FieldTrack::ncompSVEC];       63     G4double yTemp[G4FieldTrack::ncompSVEC];
 64     for (G4int i=GetNumberOfVariables(); i<Get     64     for (G4int i=GetNumberOfVariables(); i<GetNumberOfStateVariables(); ++i)
 65     {                                              65     {
 66         yOutput[i] = yTemp[i] = yInput[i];         66         yOutput[i] = yTemp[i] = yInput[i];
 67     }                                              67     }
 68                                                    68 
 69     G4double ak2[G4FieldTrack::ncompSVEC],         69     G4double ak2[G4FieldTrack::ncompSVEC],
 70              ak3[G4FieldTrack::ncompSVEC],         70              ak3[G4FieldTrack::ncompSVEC],
 71              ak4[G4FieldTrack::ncompSVEC],         71              ak4[G4FieldTrack::ncompSVEC],
 72              ak5[G4FieldTrack::ncompSVEC],         72              ak5[G4FieldTrack::ncompSVEC],
 73              ak6[G4FieldTrack::ncompSVEC];         73              ak6[G4FieldTrack::ncompSVEC];
 74                                                    74 
 75     const G4double b21 = 2./9.,                    75     const G4double b21 = 2./9.,
 76                    b31 = 1./12., b32 = 1./4.,      76                    b31 = 1./12., b32 = 1./4.,
 77                    b41 = 1./8., b42 = 0., b43      77                    b41 = 1./8., b42 = 0., b43 = 3./8.,
 78                    b51 = 91./500., b52 = -27./     78                    b51 = 91./500., b52 = -27./100.,
 79                      b53 = 78./125., b54 = 8./     79                      b53 = 78./125., b54 = 8./125.,
 80                    b61 = -11./20., b62 = 27./2     80                    b61 = -11./20., b62 = 27./20., b63 = 12./5.,
 81                      b64 = -36./5., b65 = 5.,      81                      b64 = -36./5., b65 = 5.,
 82                    b71 = 1./12.,    b72 = 0.,      82                    b71 = 1./12.,    b72 = 0., b73 = 27./32.,
 83                      b74 = -4./3., b75 = 125./     83                      b74 = -4./3., b75 = 125./96., b76 = 5./48.;
 84                                                    84 
 85     const G4double dc1 = b71 - 2./15.,             85     const G4double dc1 = b71 - 2./15.,
 86                    dc2 = b72 - 0.,                 86                    dc2 = b72 - 0.,
 87                    dc3 = b73 - 27./80.,            87                    dc3 = b73 - 27./80.,
 88                    dc4 = b74 + 2./15.,             88                    dc4 = b74 + 2./15.,
 89                    dc5 = b75 - 25./48.,            89                    dc5 = b75 - 25./48.,
 90                    dc6 = b76 - 1./24.,             90                    dc6 = b76 - 1./24.,
 91                    dc7 = 0. - 1./10.;              91                    dc7 = 0. - 1./10.;
 92                                                    92 
 93     // RightHandSide(yInput, dydx);                93     // RightHandSide(yInput, dydx);
 94     for(G4int i = 0; i < GetNumberOfVariables(     94     for(G4int i = 0; i < GetNumberOfVariables(); ++i)
 95     {                                          <<  95         yTemp[i] = yInput[i] + hstep * b21 * dydx[i];
 96       yTemp[i] = yInput[i] + hstep * b21 * dyd << 
 97     }                                          << 
 98                                                    96 
 99     RightHandSide(yTemp, ak2);                     97     RightHandSide(yTemp, ak2);
100     for(G4int i = 0; i < GetNumberOfVariables(     98     for(G4int i = 0; i < GetNumberOfVariables(); ++i)
101     {                                          <<  99         yTemp[i] = yInput[i] + hstep * (b31 * dydx[i] + b32 * ak2[i]);
102       yTemp[i] = yInput[i] + hstep * (b31 * dy << 
103     }                                          << 
104                                                   100 
105     RightHandSide(yTemp, ak3);                    101     RightHandSide(yTemp, ak3);
106     for(G4int i = 0;i < GetNumberOfVariables()    102     for(G4int i = 0;i < GetNumberOfVariables(); ++i)
107     {                                          << 103         yTemp[i] = yInput[i] + hstep * (b41 * dydx[i] + b42 * ak2[i] +
108       yTemp[i] = yInput[i] + hstep * (b41 * dy << 104                                         b43 * ak3[i]);
109                                       b43 * ak << 
110     }                                          << 
111                                                   105 
112     RightHandSide(yTemp, ak4);                    106     RightHandSide(yTemp, ak4);
113     for(G4int i = 0; i < GetNumberOfVariables(    107     for(G4int i = 0; i < GetNumberOfVariables(); ++i)
114     {                                          << 108         yTemp[i] = yInput[i] + hstep * (b51 * dydx[i] + b52 * ak2[i] +
115       yTemp[i] = yInput[i] + hstep * (b51 * dy << 109                                         b53 * ak3[i] + b54 * ak4[i]);
116                                       b53 * ak << 
117     }                                          << 
118                                                   110 
119     RightHandSide(yTemp, ak5);                    111     RightHandSide(yTemp, ak5);
120     for(G4int i = 0; i < GetNumberOfVariables(    112     for(G4int i = 0; i < GetNumberOfVariables(); ++i)
121     {                                          << 113         yTemp[i] = yInput[i] + hstep * (b61 * dydx[i] + b62 * ak2[i] +
122       yTemp[i] = yInput[i] + hstep * (b61 * dy << 114                                         b63 * ak3[i] + b64 * ak4[i] +
123                                       b63 * ak << 115                                         b65 * ak5[i]);
124                                       b65 * ak << 
125     }                                          << 
126                                                   116 
127     RightHandSide(yTemp, ak6);                    117     RightHandSide(yTemp, ak6);
128     for(G4int i = 0; i < GetNumberOfVariables(    118     for(G4int i = 0; i < GetNumberOfVariables(); ++i)
129     {                                          << 119         yOutput[i] = yInput[i] + hstep * (b71 * dydx[i] + b72 * ak2[i] +
130       yOutput[i] = yInput[i] + hstep * (b71 *  << 120                                           b73 * ak3[i] + b74 * ak4[i] +
131                                         b73 *  << 121                                           b75 * ak5[i] + b76 * ak6[i]);
132                                         b75 *  << 122     if (dydxOutput && yError)
133     }                                          << 
134     if ((dydxOutput != nullptr) && (yError !=  << 
135     {                                             123     {
136         RightHandSide(yOutput, dydxOutput);       124         RightHandSide(yOutput, dydxOutput);
137         for(G4int i = 0; i < GetNumberOfVariab    125         for(G4int i = 0; i < GetNumberOfVariables(); ++i)
138         {                                      << 126             yError[i] = hstep * (dc1 * dydx[i] + dc2 * ak2[i] + dc3 * ak3[i] +
139           yError[i] = hstep * (dc1 * dydx[i] + << 127                                  dc4 * ak4[i] + dc5 * ak5[i] + dc6 * ak6[i] +
140                                dc4 * ak4[i] +  << 128                                  dc7 * dydxOutput[i]);
141                                dc7 * dydxOutpu << 
142         }                                      << 
143     }                                             129     }
144 }                                                 130 }
145                                                   131 
146 void G4RK547FEq1::Stepper( const G4double yInp    132 void G4RK547FEq1::Stepper( const G4double yInput[],
147                            const G4double dydx    133                            const G4double dydx[],
148                                  G4double hste    134                                  G4double hstep,
149                                  G4double yOut    135                                  G4double yOutput[],
150                                  G4double yErr    136                                  G4double yError[] )
151 {                                                 137 {
152     copy(fyIn, yInput);                           138     copy(fyIn, yInput);
153     copy(fdydx, dydx);                            139     copy(fdydx, dydx);
154     fhstep = hstep;                               140     fhstep = hstep;
155                                                   141 
156     makeStep(fyIn, fdydx, fhstep, fyOut, fdydx    142     makeStep(fyIn, fdydx, fhstep, fyOut, fdydxOut, yError);
157                                                   143 
158     copy(yOutput, fyOut);                         144     copy(yOutput, fyOut);
159 }                                                 145 }
160                                                   146 
161 void G4RK547FEq1::Stepper( const G4double yInp    147 void G4RK547FEq1::Stepper( const G4double yInput[],
162                            const G4double dydx    148                            const G4double dydx[],
163                                  G4double hste    149                                  G4double hstep,
164                                  G4double yOut    150                                  G4double yOutput[],
165                                  G4double yErr    151                                  G4double yError[],
166                                  G4double dydx    152                                  G4double dydxOutput[] )
167 {                                                 153 {
168     copy(fyIn, yInput);                           154     copy(fyIn, yInput);
169     copy(fdydx, dydx);                            155     copy(fdydx, dydx);
170     fhstep = hstep;                               156     fhstep = hstep;
171                                                   157 
172     makeStep(fyIn,fdydx, fhstep, fyOut, fdydxO    158     makeStep(fyIn,fdydx, fhstep, fyOut, fdydxOut, yError);
173                                                   159 
174     copy(yOutput, fyOut);                         160     copy(yOutput, fyOut);
175     copy(dydxOutput, fdydxOut);                   161     copy(dydxOutput, fdydxOut);
176 }                                                 162 }
177                                                   163 
178 G4double G4RK547FEq1::DistChord() const           164 G4double G4RK547FEq1::DistChord() const
179 {                                                 165 {
180     G4double yMid[G4FieldTrack::ncompSVEC];       166     G4double yMid[G4FieldTrack::ncompSVEC];
181     makeStep(fyIn, fdydx, fhstep / 2., yMid);     167     makeStep(fyIn, fdydx, fhstep / 2., yMid);
182                                                   168 
183     const G4ThreeVector begin = makeVector(fyI    169     const G4ThreeVector begin = makeVector(fyIn, Value3D::Position);
184     const G4ThreeVector mid = makeVector(yMid,    170     const G4ThreeVector mid = makeVector(yMid, Value3D::Position);
185     const G4ThreeVector end = makeVector(fyOut    171     const G4ThreeVector end = makeVector(fyOut, Value3D::Position);
186                                                   172 
187     return G4LineSection::Distline(mid, begin,    173     return G4LineSection::Distline(mid, begin, end);
188 }                                                 174 }
189                                                   175