!+ ! Function spinor_to_polar (spinor) result (polar) ! ! Converts a spinor into a spin polar vector of unit length ! ! Input: ! spinor(2) -- complex(rp): Spinor ! ! Output: ! polar -- Spin_polar_struct: The resultant Unitary Vector in polar coordinates !- function spinor_to_polar (spinor) result (polar) use equal_mod, dummy_except => spinor_to_polar implicit none type (spin_polar_struct) :: polar complex(rp) spinor(2) real(rp) temp(2) character(20) :: r_name = "spinor_to_polar" ! temp(1) = atan2 (imag(spinor(1)), real(spinor(1))) temp(2) = atan2 (imag(spinor(2)), real(spinor(2))) polar%xi = temp(1) polar%phi = temp(2) - temp(1) temp=abs(spinor) polar%theta = 2 * atan2(temp(2), temp(1)) ! no sqrt here! spinor scales with sqrt(r) polar%polarization = dot_product(temp, temp) end function spinor_to_polar