vector_test Subroutine

public subroutine vector_test()

Unit test routine for the vector_module.

Arguments

None

Calls

proc~~vector_test~~CallsGraph proc~vector_test vector_module::vector_test proc~axis_angle_rotation vector_module::axis_angle_rotation proc~vector_test->proc~axis_angle_rotation proc~axis_angle_rotation_to_rotation_matrix vector_module::axis_angle_rotation_to_rotation_matrix proc~vector_test->proc~axis_angle_rotation_to_rotation_matrix proc~rotation_matrix vector_module::rotation_matrix proc~vector_test->proc~rotation_matrix proc~cross vector_module::cross proc~axis_angle_rotation->proc~cross proc~unit vector_module::unit proc~axis_angle_rotation->proc~unit proc~cross_matrix vector_module::cross_matrix proc~axis_angle_rotation_to_rotation_matrix->proc~cross_matrix proc~axis_angle_rotation_to_rotation_matrix->proc~unit

Source Code

    subroutine vector_test()

    implicit none

    integer :: i
    real(wp) :: theta
    real(wp),dimension(3) :: v,k,v2,v3
    real(wp),dimension(3,3) :: rotmat

    write(*,*) ''
    write(*,*) '---------------'
    write(*,*) ' vector_test'
    write(*,*) '---------------'
    write(*,*) ''

    v = [1.2_wp, 3.0_wp, -5.0_wp]
    k = [-0.1_wp, 16.2_wp, 2.1_wp]
    theta = 0.123_wp

    call axis_angle_rotation(v,k,theta,v2)

    call axis_angle_rotation_to_rotation_matrix(k,theta,rotmat)
    v3 = matmul(rotmat,v)

    write(*,*) 'Single test:'
    write(*,*) ''
    write(*,*) '  v1   :', v
    write(*,*) '  v2   :', v2
    write(*,*) '  v3   :', v3
    write(*,*) '  Error:', v3-v2

    write(*,*) ''
    write(*,*) '0-360 test:'
    write(*,*) ''
    do i=0,360,10

        theta = i * 180.0_wp/pi

        call axis_angle_rotation(v,k,theta,v2)

        call axis_angle_rotation_to_rotation_matrix(k,theta,rotmat)
        v3 = matmul(rotmat,v)

        write(*,*) 'Error:', norm2(v3-v2)

    end do

    !z-axis rotation test:
    theta = pi / 4.0_wp
    v = [one/cos(theta), 0.0_wp, 0.0_wp]
    rotmat = rotation_matrix(z_axis,theta)
    v2 = matmul(rotmat,v)
    write(*,*) v2    !should be [1, -1, 0]


    end subroutine vector_test