6. Components: a slip wall
A particle hits the slanted face of the tetrahedron. At a slip wall the component of its velocity along the wall survives and the component across the wall reverses. probe splits the velocity with two operators.
program probe
!< Tutorial, chapter 6: a velocity at the slanted face, its normal and tangential components, a slip wall.
use penf, only : R8P
use vecfor, only : ex, ey, ez, face_normal3, vector
implicit none
type(vector) :: p(4) ! the vertices
type(vector) :: n ! the outward normal of the slanted face
type(vector) :: v ! the velocity of a particle hitting the face
type(vector) :: vn ! its normal component
type(vector) :: vt ! its tangential component
type(vector) :: r ! its velocity after the bounce
p(2) = ex ; p(3) = ey ; p(4) = ez
n = face_normal3(pt1=p(2), pt2=p(3), pt3=p(4)) ! not a unit vector: only its direction matters
v = -2 * ex - ey + 0.5_R8P * ez
vn = v .paral. n
vt = v .ortho. n
call vn%printf(prefix='normal component = ')
call vt%printf(prefix='tangential component = ')
print '(A,ES9.1)', 'vn . vt ', vn .dot. vt
r = vt - vn ! a slip wall: the normal component reverses
print '(A,3F8.4)', 'v before the bounce ', v%x, v%y, v%z
print '(A,3F8.4)', 'v after the bounce ', r%x, r%y, r%z
print '(A,2F8.4)', 'speed before and after ', v%normL2(), r%normL2()
print '(A,2F8.4)', 'v . n before and after ', v .dot. n, r .dot. n
endprogram probe$ probe
normal component = -0.8333333333333335, -0.8333333333333335, -0.8333333333333335
tangential component = -1.1666666666666665, -0.16666666666666652, +1.3333333333333335
vn . vt -2.2E-16
v before the bounce -2.0000 -1.0000 0.5000
v after the bounce -0.3333 0.6667 2.1667
speed before and after 2.2913 2.2913
v . n before and after -1.2500 1.2500The face seen edge-on, from the direction of n .cross. v: the velocities are drawn at 0.4 of their length.
Parallel and orthogonal components
v .paral. n is the component of v along n, v .ortho. n is the rest, n. Their sum is v, their dot product is zero up to rounding (-2.2E-16). Only the direction of n matters: here it is the normal of face_normal3 without norm, as long as the face is large, and the components are the same as with a unit normal.
The right operand must not be the zero vector, which has no direction: v .paral. 0 is NaN in every component (see The components parallel and orthogonal to a vector).
The bounce
After the bounce the velocity is vt - vn: the tangential component unchanged, the normal one reversed. The speed is the same before and after, and v . n changes sign: the particle now leaves the wall. The same reflection is a mirror across the plane of the wall, call v%mirror(normal=n) (see A velocity reflected by a wall), the subject of the next chapter.
What you learned
.paral. and .ortho.: the components of a vector along and across a direction; a slip-wall reflection. Reference: Operators.
Next: 7. Rotations and mirrors.