c c monod - calculator to find wavelengths and b-factors of various c diffraction peaks for a given setting of the monochromator c angles using our double-asymmetric Si(331) crystals on c CHESS beamline C. c c Author: Richard Jones c May 2, 2009 c c Notes: c 1. There are several reference frames to know about in order to use monod. c * the hkl frame - the frame defined in terms of the axes of the silicon c ingot slice from which the monochromator crystals were cut. To find c the orientation for this frame, imagine holding the planar wedge from c which the monochromator crystals were cut with its wide end down and c resting on a horiztonal flat surface. Viewing the wedge-shaped sheet c edge-on with the scribed surface to your right, lean the wedge slightly c to the right 3.5 degrees from the vertical. In this orientation, the c direction [1 -1 0] is horiztonally to the right, [1 1 1] is vertically c up, and [1 1 -2] points horizontally away from you. c * the crystal frame - the frame defined in terms of the surfaces of the c monochromator crystal. To find this frame, imagine holding one of the c crystals with the scribe v-mark facing up and located in the lower c left corner. In this orientation, the z axis points to the right in c the plane of the crystal, the x axis points up in the plane of the c crystal, and y is normal to the flat surface. c * the beamline frame - the frame defined in terms of the C-line axes. c The z axis is horizontal along the nominal beam direction, the y axis c points vertically up, and the x axis points toward the back wall of c the hutch. c 2. I checked out the sense of rotation of each of the three monochromator c axis motors, theta, phi, and tilt. I made sure that the sense of c rotation embodied in the formulas below is consistent with the signs c used by the controllers and the spec software. subroutine monod print *, 'monod - crystal and monochromator set up with defaults' end subroutine crystal_setup(tipdeg,cutdeg) real tipdeg,cutdeg common /crystal_angles/tip_angle,cut_angle real tip_angle,cut_angle data tip_angle/0.0611/ ! 3.5 degress data cut_angle/0.3707/ ! 21 degrees, 14.4 minutes tip_angle = tipdeg*3.1415926/180 cut_angle = cutdeg*3.1415926/180 end subroutine mono_setup(thetadeg,phideg,tiltdeg) real thetadeg,phideg,tiltdeg common /mono_angles/thetamono,phimono,tiltmono real thetamono,phimono,tiltmono data thetamono,phimono,tiltmono/0,0,0/ thetamono = thetadeg*3.1415926/180 phimono = phideg*3.1415926/180 tiltmono = tiltdeg*3.1415926/180 end subroutine from_hkl_to_crystal(qin,qout) real qin(3),qout(3) common /crystal_angles/tip_angle,cut_angle real tip_angle,cut_angle real q1(3),q2(3) q1(1) = (qin(1)+qin(2)+qin(3))/sqrt(3.) q1(2) = (qin(1)-qin(2))/sqrt(2.) q1(3) = (qin(1)+qin(2)-2*qin(3))/sqrt(6.) q2(1) = q1(1)*cos(tip_angle)+q1(2)*sin(tip_angle) q2(2) = q1(2)*cos(tip_angle)-q1(1)*sin(tip_angle) q2(3) = q1(3) qout(1) = q2(1)*cos(cut_angle)+q2(3)*sin(cut_angle) qout(2) = q2(2) qout(3) = q2(3)*cos(cut_angle)-q2(1)*sin(cut_angle) correction: The following reversal was discovered during alignment in 2007 * qout(1) = -qout(1) * qout(3) = -qout(3) correction: End of reversal end subroutine from_crystal_to_hkl(qin,qout) real qin(3),qout(3) common /crystal_angles/tip_angle,cut_angle real tip_angle,cut_angle real q1(3),q2(3) q1(1) = qin(1)*cos(cut_angle)-qin(3)*sin(cut_angle) q1(2) = qin(2) q1(3) = qin(3)*cos(cut_angle)+qin(1)*sin(cut_angle) correction: The following reversal was discovered during alignment in 2007 * q1(1) = -q1(1) * q1(3) = -q1(3) correction: End of reversal q2(1) = q1(1)*cos(tip_angle)-q1(2)*sin(tip_angle) q2(2) = q1(2)*cos(tip_angle)+q1(1)*sin(tip_angle) q2(3) = q1(3) qout(1) = q2(1)/sqrt(3.)+q2(2)/sqrt(2.)+q2(3)/sqrt(6.) qout(2) = q2(1)/sqrt(3.)-q2(2)/sqrt(2.)+q2(3)/sqrt(6.) qout(3) = q2(1)/sqrt(3.)-2*q2(3)/sqrt(6.) end subroutine from_crystal_to_beamline(qin,qout) real qin(3),qout(3) common /mono_angles/thetamono,phimono,tiltmono real thetamono,phimono,tiltmono real q1(3),q2(3) q1(1) = qin(1)*cos(phimono)-qin(3)*sin(phimono) q1(2) = qin(2) q1(3) = qin(3)*cos(phimono)+qin(1)*sin(phimono) q2(1) = q1(1)*cos(tiltmono)-q1(2)*sin(tiltmono) q2(2) = q1(2)*cos(tiltmono)+q1(1)*sin(tiltmono) q2(3) = q1(3) qout(1) = q2(1) qout(2) = q2(2)*cos(thetamono)+q2(3)*sin(thetamono) qout(3) = q2(3)*cos(thetamono)-q2(2)*sin(thetamono) end subroutine from_beamline_to_crystal(qin,qout) real qin(3),qout(3) common /mono_angles/thetamono,phimono,tiltmono real thetamono,phimono,tiltmono real q1(3),q2(3) q1(1) = qin(1) q1(2) = qin(2)*cos(thetamono)-qin(3)*sin(thetamono) q1(3) = qin(3)*cos(thetamono)+qin(2)*sin(thetamono) q2(1) = q1(1)*cos(tiltmono)+q1(2)*sin(tiltmono) q2(2) = q1(2)*cos(tiltmono)-q1(1)*sin(tiltmono) q2(3) = q1(3) qout(1) = q2(1)*cos(phimono)+q2(3)*sin(phimono) qout(2) = q2(2) qout(3) = q2(3)*cos(phimono)-q2(1)*sin(phimono) end real function diffract(kin,h,k,l,kout,bfact) real kin(3),kout(3) integer h,k,l real qhkl(3),qxtal(3),qlab(3) real nhat(3),nlab(3) real kdotq,qdotq,kdiff real koutdotn,kindotn,kmag real alattice parameter (alattice=5.43095) ! Angstroms real keV keV = (2*3.1415926/alattice)*1970 qhkl(1) = h*keV qhkl(2) = k*keV qhkl(3) = l*keV call from_hkl_to_crystal(qhkl,qxtal) call from_crystal_to_beamline(qxtal,qlab) nhat(1) = 0 nhat(2) = 1 nhat(3) = 0 call from_crystal_to_beamline(nhat,nlab) qdotq = qlab(1)**2+qlab(2)**2+qlab(3)**2 kdotq = qlab(1)*kin(1)+qlab(2)*kin(2)+qlab(3)*kin(3) kmag = sqrt(kin(1)**2+kin(2)**2+kin(3)**2) kdiff = qdotq*kmag/(-2*kdotq-1e-20) kout(1) = kin(1)+qlab(1)*kmag/kdiff kout(2) = kin(2)+qlab(2)*kmag/kdiff kout(3) = kin(3)+qlab(3)*kmag/kdiff kindotn = kin(1)*nlab(1)+kin(2)*nlab(2)+kin(3)*nlab(3) koutdotn = kout(1)*nlab(1)+kout(2)*nlab(2)+kout(3)*nlab(3) bfact = -koutdotn/(kindotn+1e-20) diffract = kdiff end