Example #1
0
def drawDispercionCurvesFromFile(number_of_curves_to_draw=10, save_plot_to_file=False):

    plt.figure(1)
    plt.subplot(211)

    path_to_kvect_file = config.ROOT_DIR + '/../eig/kvect'
    path_to_omega_files = config.ROOT_DIR + '/../eig/omega'
    kvect = np.array(rd.read_kvect(path_to_kvect_file))
    k_v = kvect * 1e3

    curves = [i for i in range(number_of_curves_to_draw)]
    # curves = [10]

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files, ind) / (2 * np.pi)
        plt.plot(f_v * 1e-3, k_v, 'g.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Wavenumber [rad/m]")
    plt.xlim([-5, 200])#600
    plt.ylim([-5, 400])#2000

    plt.subplot(212)
    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files, ind) / (2 * np.pi)
        v_p = (f_v / k_v) * 2 * np.pi
        # v_p = (2 * np.pi * (f_v / k_v)) / (np.sqrt(config.young_mod / config.density) * 1e-3)
        plt.plot(f_v * 1e-3, v_p, 'g.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Phase velocity [m/s]")
    plt.xlim([-5, 200])#500
    plt.ylim([-5, 10000])#50

    if save_plot_to_file:
        plt.savefig('dis_curves.png')
    plt.show()
Example #2
0
def calculateExcitablity(mode, f):
    # k_vect = np.linspace(1e-10, np.pi / 8, num=51)
    k_vect = rd.read_kvect("../eig/kvect")
    omega = rd.read_complex_omega("../eig/omega", mode)
    omega_string = rd.read_string_omega("../eig/omega", mode)
    a = []
    for kv, om in zip(k_vect, omega_string):
        # x = calculate_displacement(om)
        # dim = int(len(x)/3)
        # x0 = x[dim : 2 * dim]

        # eigv = rd.readEigMap("../eig/normeig/normeig_{}".format(kv), str(om))
        print(om)
        eigv = rd.readEigMap("../eig/eig_{}".format(kv), eigval=om)

        p = calculateP(config.kr, config.kl, kv, eigv)

        temp = np.dot(eigv, f[0:len(eigv)])
        a.append(temp / p)

    abs_a = []
    for aa in a:
        abs_a.append(abs(aa.imag))

    frequency = []
    for om in omega:
        frequency.append(om.real * 1e-3 / (2 * np.pi))

    return frequency, abs_a
Example #3
0
    def selectMode(self):
        #Wczytujemy kolejne k, dla których mamy omegi
        kvect = np.array(rd.read_kvect(self.eig_path))  #'../eig/kvect'
        self.k_v = kvect * 1e3

        #AllModes jest obiektem typu Mode, który przechowuje wszyskit nieprzydzielone jeszcze do żadnego modu obiekty
        AllPoints = Mode()

        #Czytamy z pliku wszystkie omegi i robimy z nich pointy o współrzędnych omega i k
        for ind in range(
                426
        ):  #Jak to sparametryzować? :/ to jest liczba wierszy w tym omega
            #temp = np.array(rd.read_complex_omega('../eig/omega', ind))/(2 * np.pi)
            temp = np.array(rd.read_complex_omega(self.omega_path,
                                                  ind))  #'../eig/omega'
            for p in range(len(temp)):
                AllPoints.addPoint(Point(temp[p], self.k_v[p]))

        #obiekt Mode, w którym są punktu z najmniejszym K czyli pierwsze punkty kolejnych modów
        MinKTable = Mode()
        #drugie punkty kolejnych modów
        MinKTable2 = Mode()
        mink = min(self.k_v)
        #Wyszukiwanie pierwszych dwóch punktów kolejnych modów (punktów o najmniejszym i prawie najmniejszym k)
        for wszystko in AllPoints.points:
            if (wszystko.k == mink):
                MinKTable.addPoint(wszystko)
            elif (wszystko.k == self.k_v[1]):
                MinKTable2.addPoint(wszystko)

        #usuwanie punktów które już znalazły swój mod
        AllPoints.delDuplicats(MinKTable.points)
        AllPoints.delDuplicats(MinKTable2.points)

        #sortowanie po omegach
        AllPoints.quicksort(0, len(AllPoints.points) - 1)
        MinKTable.quicksort(0, len(MinKTable.points) - 1)
        MinKTable2.quicksort(0, len(MinKTable.points) - 1)

        #dodajemy pierwsze dwa punkty do odpowiednich modów
        for ind, m in enumerate(MinKTable.points):
            self.AllModes.addMode(Mode())
            self.AllModes.modeTable[ind].addPoint(m)
            self.AllModes.modeTable[ind].addPoint(MinKTable2.points[ind])

        #Segregowanie punktów do modów
        for i in range(2, len(self.k_v)):
            actk = self.k_v[i]
            potentialPoints = AllPoints.findPointsWithK(actk)
            test = np.array(potentialPoints)
            AllPoints.delDuplicats(potentialPoints)
            j = 0

            for mod in self.AllModes.modeTable:
                j += 1
                ind = mod.findSmallestAngle(potentialPoints)
                mod.addPoint(potentialPoints[ind])
                if (len(potentialPoints) > 3):
                    potentialPoints.pop(ind)
Example #4
0
def getCurvesInSignalArgs(numberOfModes, args):
    path_to_exc = config.ROOT_DIR + '/../eig/exc'
    path_to_kvect_file = config.ROOT_DIR + '/../eig/kvect'
    path_to_omega_file = config.ROOT_DIR + '/../eig/omega'

    kvect = rd.read_kvect(path_to_kvect_file)
    omega = []
    for mode in range(numberOfModes):
        om = rd.read_complex_omega(path_to_omega_file, mode)
        omega.append(om.real)

    excArgs, excVal = rd.read_exc(path_to_exc)

    newKvect = []
    newAmps = []

    for mode in range(numberOfModes):
        newKvect.append(functionValueInArg(args, omega[mode], kvect))
        newAmps.append(functionValueInArg(args, excArgs[mode], excVal[mode]))
    newKvect = np.array(newKvect)
    newAmps = np.array(newAmps)
    return newKvect, newAmps
Example #5
0
def comparison(number_of_curves_to_draw=20):
    lowF = -5
    highF = 75
    lowK = -5
    highK = 150
    lowV = -5
    highV = 10000

    path_to_kvect_file1 = config.ROOT_DIR + '/../eig/kvect1'
    path_to_kvect_file2 = config.ROOT_DIR + '/../eig/kvect2'
    path_to_kvect_file3 = config.ROOT_DIR + '/../eig/kvect3'
    path_to_omega_files1 = config.ROOT_DIR + '/../eig/omega1'
    path_to_omega_files2 = config.ROOT_DIR + '/../eig/omega2'
    path_to_omega_files3 = config.ROOT_DIR + '/../eig/omega3'

    kvect1 = np.array(rd.read_kvect(path_to_kvect_file1))
    kvect2 = np.array(rd.read_kvect(path_to_kvect_file2))
    kvect3 = np.array(rd.read_kvect(path_to_kvect_file3))
    k_v1 = kvect1 * 1e3
    k_v2 = kvect2 * 1e3
    k_v3 = kvect3 * 1e3

    curves = [i for i in range(number_of_curves_to_draw)]

    plt.figure(1)
    plt.subplot(211)

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files1, ind) / (2 * np.pi)
        plt.plot(f_v * 1e-3, k_v1, 'g.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Wavenumber [rad/m]")
    plt.xlim([lowF, highF])  #600
    plt.ylim([-5, highK])  #2000

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files2, ind) / (2 * np.pi)
        plt.plot(f_v * 1e-3, k_v2, 'b.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Wavenumber [rad/m]")
    plt.xlim([lowF, highF])  #600
    plt.ylim([-5, highK])  #2000

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files3, ind) / (2 * np.pi)
        plt.plot(f_v * 1e-3, k_v3, 'r.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Wavenumber [rad/m]")
    plt.xlim([lowF, highF])  #600
    plt.ylim([-5, highK])  #2000

    plt.subplot(212)
    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files1, ind) / (2 * np.pi)
        v_p = (f_v / k_v1) * 2 * np.pi
        # v_p = (2 * np.pi * (f_v / k_v)) / (np.sqrt(config.young_mod / config.density) * 1e-3)
        plt.plot(f_v * 1e-3, v_p, 'g.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Phase velocity [m/s]")
    plt.xlim([lowF, highF])  #500
    plt.ylim([-5, 10000])  #50

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files2, ind) / (2 * np.pi)
        v_p = (f_v / k_v2) * 2 * np.pi
        # v_p = (2 * np.pi * (f_v / k_v)) / (np.sqrt(config.young_mod / config.density) * 1e-3)
        plt.plot(f_v * 1e-3, v_p, 'b.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Phase velocity [m/s]")
    plt.xlim([lowF, highF])  #500
    plt.ylim([-5, 10000])  #50

    for ind in curves:
        f_v = rd.read_complex_omega(path_to_omega_files3, ind) / (2 * np.pi)
        v_p = (f_v / k_v3) * 2 * np.pi
        # v_p = (2 * np.pi * (f_v / k_v)) / (np.sqrt(config.young_mod / config.density) * 1e-3)
        plt.plot(f_v * 1e-3, v_p, 'r.', markersize=3)
    plt.xlabel("Frequency [kHz]")
    plt.ylabel("Phase velocity [m/s]")
    plt.xlim([lowF, highF])  #500
    plt.ylim([-5, 10000])  #50

    plt.show()