def test_TasUBDEG_CalculateAngles(
):  # TODO: Redo these calculations as one needs to do the trick with a3 to calculate anything correctly...
    cell = [
        6.11, 6.11, 11.35, 1.187430040454027, 1.1874300210500532,
        0.5535845899562842, 90., 90., 120., 90., 90., 60.
    ]
    B = calculateBMatrix(cell)
    OM = 0.00  # Offset known
    sgu = 0.0
    sgl = 0.0
    UB = calcUBFromAngles(B, OM, sgu, sgl)

    planeNormal = np.array([0, 0, 1.0])
    qe = np.array([1.0, 0.0, 0.0, 5.0, 5])
    ss = 1  # Scattering sense
    A3Off = 0.0

    UBINV = np.linalg.inv(UB)
    QE = np.array([[1.0, 0.0, 0.0, 5.0, 5], [0.0, 0.5, 0.0, 8.0, 9.2],
                   [-1.1, -0.1, 0.0, 5.4, 4.4]])
    for qe in QE:

        a3, a4, sgu, sgl = calcTasQAngles(UB, planeNormal, ss, A3Off, qe)

        print('------------------\nA3:{}\nA4{}'.format(a3, a4))
        hkl = calcTasQH(UBINV, [a3, a4], qe[3], qe[4])[0]
        print('{}'.format(hkl))
        assert (np.all(np.isclose([sgu, sgl],
                                  0.0)))  # Sgu and sgl are 0 by definition
        assert (np.all(np.isclose(hkl, qe[:3])))
Exemple #2
0
    def calculateA4(self, alignment=1):
        cell = self.getCell()
        r = self.getAlignment(alignment=alignment)

        Cell = calcCell(cell)
        B = calculateBMatrix(Cell)

        # H,K,L,Ei,Ef
        qe = np.concatenate([r[:3], r[-2:]])

        A4 = calTwoTheta(B=B, qe=qe, ss=-1)
        return A4
def test_TasUBDeg_CreateUB():

    UBFile = np.array([[ 1.7459887e-01,  2.4665387e-02,  2.1624945e-08],
       [-7.2323568e-02, -1.8736884e-01, -5.1334577e-09],
       [ 4.7066340e-08,  1.6969278e-08, -8.8105723e-02]])*2*np.pi

    cell = [6.11,   6.11,  11.35, 1.187430040454027, 1.1874300210500532, 0.5535845899562842, 90.  ,  90.  , 120., 90., 90., 120.]
    B = calculateBMatrix(cell)
    OM = 360-22.500 # Offset known 
    sgu = 0.0
    sgl = 0.0
    UB = calcUBFromAngles(B,OM,sgu,sgl)
    
    assert(np.all(np.isclose(UBFile,UB,atol=4)))
def textChangedCalculate(manager):
    cell = manager.getCell()
    r = manager.getPoint()

    Cell = calcCell(cell)
    B = calculateBMatrix(Cell)

    # H,K,L,Ei,Ef
    qe = np.concatenate([r[:3],r[-2:]])

    A4 = calTwoTheta(B=B,qe=qe,ss=-1)

    qLength = np.linalg.norm(np.dot(B,np.array(r[:3])))
    d = WavelengthK(qLength)

    dE = r[-2]-r[-1]

    manager.scattering_q_label.setText('{:.4}'.format(qLength))
    manager.scattering_d_label.setText('{:.4}'.format(d))
    manager.scattering_a4_label.setText('{:.4}'.format(A4))

    manager.scattering_de_spinBox.setValue(dE)