Esempio n. 1
0
    def plotMiddle(self):
        """Function to plot the graph on the Middle Canvas"""

        self.ui.factorPlot.canvas.ax.cla()
        self.ui.factorPlot.canvas.ax.grid(True)

        self.elementList = Utility.molToElemList(self.molecule)
        self.elementParameters = Utility.read_parameters(
            self.elementList, "./elementParameters.txt")

        if self.ui.formFactorCheck.isChecked():
            # print("test fe check")
            self.Q, self.I_Q, self.Qbkg, self.Ibkg_Q = UtilityAnalysis.check_data_length(
                self.Q, self.I_Q, self.Qbkg, self.Ibkg_Q, self.ui.minQ.value(),
                self.ui.maxQ.value())
            self.fe_Q, self.Ztot = MainFunctions.calc_eeff(
                self.elementList, self.Q, self.elementParameters)

            self.ui.factorPlot.canvas.ax.plot(self.Q,
                                              self.fe_Q,
                                              label=r"$f_e(Q)$")
            self.ui.factorPlot.canvas.ax.legend()
            self.ui.factorPlot.canvas.draw()
        # else:
        #     # print("test unchecked")
        #     self.ui.factorPlot.canvas.ax.lines.pop(0)
        #     self.ui.factorPlot.canvas.draw()

        if self.ui.SQCheck.isChecked():
            S_Q = self.SQ()
            self.ui.factorPlot.canvas.ax.plot(self.Q, S_Q, label=r"$S(Q)$")
            self.ui.factorPlot.canvas.ax.legend()
            self.ui.factorPlot.canvas.draw()

        if self.ui.incohCheck.isChecked():
            self.Iincoh_Q = MainFunctions.calc_Iincoh(self.elementList, self.Q,
                                                      self.elementParameters)

            self.ui.factorPlot.canvas.ax.plot(self.Q,
                                              self.Iincoh_Q,
                                              label=r"$I_{incoh}(Q)$")
            self.ui.factorPlot.canvas.ax.legend()
            self.ui.factorPlot.canvas.draw()

        if self.ui.QiQCheck.isChecked():
            self.Sinf = MainFunctions.calc_Sinf(self.elementList, self.fe_Q,
                                                self.Q, self.Ztot,
                                                self.elementParameters)
            self.i_Q = MainFunctions.calc_iQ(S_Q, self.Sinf)
            # self.r = MainFunctions.calc_r(self.Q)
            Qi_Q = self.Q * self.i_Q

            self.ui.factorPlot.canvas.ax.plot(self.Q, Qi_Q, label=r"$Qi(Q)$")
            self.ui.factorPlot.canvas.ax.legend()
            self.ui.factorPlot.canvas.draw()
Esempio n. 2
0
    def SQ(self):
        """Function to calculate and plot the structure factor S(Q)"""

        self.elementList = Utility.molToElemList(self.molecule)
        # self.elementList = Utility.molToElemList("Ar")
        self.elementParameters = Utility.read_parameters(
            self.elementList, "./elementParameters.txt")

        # print(elementList)
        # print(elementParameters)

        self.Q, self.I_Q, self.Qbkg, self.Ibkg_Q = UtilityAnalysis.check_data_length(
            self.Q, self.I_Q, self.Qbkg, self.Ibkg_Q, self.ui.minQ.value(),
            self.ui.maxQ.value())

        two_theta = UtilityAnalysis.Qto2theta(self.Q)
        absCorrFactor = Geometry.calcAbsCorrection(
            self.ui.absLength.value(), two_theta, self.ui.dacThickness.value(),
            self.ui.dacAngle.value())
        self.I_Q = self.I_Q / absCorrFactor
        self.Ibkg_Q = self.Ibkg_Q / absCorrFactor

        self.fe_Q, self.Ztot = MainFunctions.calc_eeff(self.elementList,
                                                       self.Q,
                                                       self.elementParameters)
        self.Iincoh_Q = MainFunctions.calc_Iincoh(self.elementList, self.Q,
                                                  self.elementParameters)
        self.J_Q = MainFunctions.calc_JQ(self.Iincoh_Q, self.Ztot, self.fe_Q)
        self.Sinf = MainFunctions.calc_Sinf(self.elementList, self.fe_Q,
                                            self.Q, self.Ztot,
                                            self.elementParameters)

        self.dampingFunct = UtilityAnalysis.calc_dampingFunction(
            self.Q,
            self.ui.dampingFactor.value(), self.ui.QmaxIntegrate.value(),
            self.ui.dampingFunction.currentText())

        Isample_Q = MainFunctions.calc_IsampleQ(
            self.I_Q, self.ui.scaleFactorValue.value(), self.Ibkg_Q)
        alpha = MainFunctions.calc_alpha(
            self.J_Q[self.Q <= self.ui.QmaxIntegrate.value()], self.Sinf,
            self.Q[self.Q <= self.ui.QmaxIntegrate.value()],
            Isample_Q[self.Q <= self.ui.QmaxIntegrate.value()],
            self.fe_Q[self.Q <= self.ui.QmaxIntegrate.value()], self.Ztot,
            self.ui.densityValue.value())
        Icoh_Q = MainFunctions.calc_Icoh(alpha, Isample_Q, self.Iincoh_Q)

        S_Q = MainFunctions.calc_SQ(Icoh_Q, self.Ztot, self.fe_Q, self.Sinf,
                                    self.Q, self.ui.minQ.value(),
                                    self.ui.QmaxIntegrate.value(),
                                    self.ui.maxQ.value())
        Ssmooth_Q = UtilityAnalysis.calc_SQsmoothing(
            self.Q, S_Q, self.Sinf, self.ui.smoothingFactor.value(),
            self.ui.minQ.value(), self.ui.QmaxIntegrate.value(),
            self.ui.maxQ.value())
        self.SsmoothDamp_Q = UtilityAnalysis.calc_SQdamp(
            Ssmooth_Q, self.Sinf, self.dampingFunct)

        # self.ui.factorPlot.canvas.ax.plot(self.Q, self.SsmoothDamp_Q, "b", label=r"$S(Q)$")
        # self.ui.factorPlot.canvas.ax.legend()
        # self.ui.factorPlot.canvas.draw()

        return self.SsmoothDamp_Q
Esempio n. 3
0
    elementList = Utility.molToelemList(variables.molecule)
    elementParameters = Utility.read_parameters(elementList,
                                                variables.element_params_path)

    path = Utility.path_xyz_file(variables.molecule)
    numAtoms, element, x, y, z = Utility.read_xyz_file(path)

    Q, I_Q = Utility.read_file(variables.data_file)
    Qbkg, Ibkg_Q = Utility.read_file(variables.bkg_file)

    # -------------------Preliminary calculation-------------------------------

    fe_Q, Ztot = MainFunctions.calc_eeff(elementList, Q, elementParameters)
    Iincoh_Q = MainFunctions.calc_Iincoh(elementList, Q, elementParameters)
    J_Q = MainFunctions.calc_JQ(Iincoh_Q, Ztot, fe_Q)
    Sinf = MainFunctions.calc_Sinf(elementList, fe_Q, Q, Ztot,
                                   elementParameters)

    dampingFunction = UtilityAnalysis.calc_dampingFunction(
        Q, variables.dampingFactor, variables.QmaxIntegrate,
        variables.typeFunction)

    # ------------------Intra-molecular components-----------------------------

    iintra_Q = Optimization.calc_iintra(Q, fe_Q, Ztot, variables.QmaxIntegrate,
                                        variables.maxQ, elementList, element,
                                        x, y, z, elementParameters)
    iintradamp_Q = UtilityAnalysis.calc_iintradamp(iintra_Q, dampingFunction)
    Qiintradamp_Q = Q * iintradamp_Q
    rintra, Fintra_r = MainFunctions.calc_Fr(
        Q[Q <= variables.QmaxIntegrate],
        Qiintradamp_Q[Q <= variables.QmaxIntegrate])