Get rot from xparm: Difference between revisions

From XDSwiki
Jump to navigation Jump to search
(Created page with '</pre> ! program to calculate rotations of unit cell axes with respect to detector axes, rotation axis, and beam. ! KD 9/2010 implicit none integer i real rota…')
 
(warning)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
</pre>
Attention: this program needs to be modified to read the "new format" (since 2013) of XPARM.XDS.


! program to calculate rotations of unit cell axes with respect to detector axes, rotation axis, and beam.
To be compiled with e.g.
! KD 9/2010
gfortran -C get_rot_from_xparm.f90 -o get_rot_from_xparm
 
<pre>
 
! program to calculate rotations of unit cell axes with respect to detector axes, rotation axis, and beam.
! KD 9/2010
       implicit none
       implicit none
       integer i
       integer i
       real rotation(3),beam(3),detector_x(3),detector_y(3),x,xyz(3)
       real rotation(3),beam(3),detector_x(3),detector_y(3),x,xyz(3)
       real, parameter :: r2d=57.2957795
       real, parameter :: r2d=57.2957795
       character axnam*1(3)/'a','b','c'/
       character*1 :: axnam(3)=(/'a','b','c'/)
        
        
open(1,file='XPARM.XDS')
      open(1,file='XPARM.XDS')
        
        
       read(1,*) beam,rotation ! 1. record: read ROTATION_AXIS
       read(1,*) beam,rotation ! 1. record: read ROTATION_AXIS
Line 31: Line 36:
         xyz=xyz/x
         xyz=xyz/x
         x=dot_product(xyz,rotation)
         x=dot_product(xyz,rotation)
         print*,axnam(i),' axis rotation w.r.t. ROTATION_AXIS:          ',acos(x)*r2d
         print*,'angle between ',axnam(i),' axis and ROTATION_AXIS:          ',acos(x)*r2d
         x=dot_product(xyz,detector_x)
         x=dot_product(xyz,detector_x)
         print*,axnam(i),' axis rotation w.r.t. DETECTOR_X-AXIS:        ',acos(x)*r2d
         print*,'angle between ',axnam(i),' axis and DETECTOR_X-AXIS:        ',acos(x)*r2d
         x=dot_product(xyz,detector_y)
         x=dot_product(xyz,detector_y)
         print*,axnam(i),' axis rotation w.r.t. DETECTOR_Y-AXIS:        ',acos(x)*r2d
         print*,'angle between ',axnam(i),' axis and DETECTOR_Y-AXIS:        ',acos(x)*r2d
         x=dot_product(xyz,beam)
         x=dot_product(xyz,beam)
         print*,axnam(i),' axis rotation w.r.t. INCIDENT_BEAM DIRECTION:',acos(x)*r2d
         print*,'angle between ',axnam(i),' axis and INCIDENT_BEAM DIRECTION:',acos(x)*r2d
       end do
       end do
end  
end  

Latest revision as of 10:51, 11 June 2014

Attention: this program needs to be modified to read the "new format" (since 2013) of XPARM.XDS.

To be compiled with e.g.

gfortran -C get_rot_from_xparm.f90 -o get_rot_from_xparm

 ! program to calculate rotations of unit cell axes with respect to detector axes, rotation axis, and beam.
 ! KD 9/2010
      implicit none
      integer i
      real rotation(3),beam(3),detector_x(3),detector_y(3),x,xyz(3)
      real, parameter :: r2d=57.2957795
      character*1 :: axnam(3)=(/'a','b','c'/)
      
      open(1,file='XPARM.XDS')
      
      read(1,*) beam,rotation ! 1. record: read ROTATION_AXIS
      print*,' ROTATION_AXIS=',rotation
      read(1,*) x,beam        ! 2. record: read INCIDENT_BEAM_DIRECTION
      beam=beam*x 
      print*,' normalized INCIDENT_BEAM_DIRECTION=',beam
      read(1,*) x             ! 3. record: read nothing
      read(1,*) x             ! 4. record: read nothing
      read(1,*) detector_x    ! 5. record: read DIRECTION_OF_DETECTOR_X-AXIS
      print*,' DIRECTION_OF_DETECTOR_X-AXIS=',detector_x
      read(1,*) detector_y    ! 6. record: read DIRECTION_OF_DETECTOR_Y-AXIS
      print*,' DIRECTION_OF_DETECTOR_Y-AXIS=',detector_y
      read(1,*) x             ! 7. record: read nothing
      read(1,*) x             ! 8. record: read nothing
      
      do i=1,3
        print*,' '
        read(1,*)xyz
        x=sqrt(xyz(1)**2 + xyz(2)**2 + xyz(3)**2)
        xyz=xyz/x
        x=dot_product(xyz,rotation)
        print*,'angle between ',axnam(i),' axis and ROTATION_AXIS:          ',acos(x)*r2d
        x=dot_product(xyz,detector_x)
        print*,'angle between ',axnam(i),' axis and DETECTOR_X-AXIS:        ',acos(x)*r2d
        x=dot_product(xyz,detector_y)
        print*,'angle between ',axnam(i),' axis and DETECTOR_Y-AXIS:        ',acos(x)*r2d
        x=dot_product(xyz,beam)
        print*,'angle between ',axnam(i),' axis and INCIDENT_BEAM DIRECTION:',acos(x)*r2d
      end do
end