We are running a solid-state physics simulation, including charge carriers with an electric field bias. We have written our own equation-of-motion class (`G4CMPEqEMField`

) as a subclass of `G4EqMagElectricField`

.

I’m having trouble reconciling the sparse guidance in the Toolkit Guide with the code in `G4EqMagElectricField::EvaluateRhsGivenB()`

, which we used as a guide for our own code. The documentation says

the derivative vector dydx is a vector with six components. The first three are the derivative of the position with respect to the curve length. Thus they should set equal to the normalised velocity, which is components 3, 4 and 5 of y.

`(dydx[0], dydx[1], dydx[2]) = (y[3], y[4], y[5])`

But the code assumes that `y[3,4,5]`

is the actual *momentum* (in Geant4 energy units), and computes the output components above as

```
G4double pSquared = y[3]*y[3] + y[4]*y[4] + y[5]*y[5] ;
G4double pModuleInverse = 1.0/std::sqrt(pSquared) ;
dydx[0] = y[3]*pModuleInverse ;
dydx[1] = y[4]*pModuleInverse ;
dydx[2] = y[5]*pModuleInverse ;
```

So `dydx[0,1,2]`

does come out as a unit (direction) vector. The documentation also doesn’t mention the `dydx[6]=0.`

and `dydx[7]=inverse_velocity;`

components.

Besides the documentation, I’m also having a physics problem. I would expect the field to change the particle’s kinetic energy by an amount equal to the voltage drop (field * path length). This is what happens with `G4EqMagElectricField`

, but not with our code. Instead, I seem to get systematically too much energy (by about 25% or so).

Unfortunately, the “stepper” code is sufficiently abstract that I really can’t tell how it is that the particle’s momentum and energy get changed by the output of `EvaluateRhsGivenB()`

. Is there somewhere (slides from a talk, maybe?) that would provide a physically motivated connection that I could follow?