Example #1
0
def read_database_h5(hdf5_database_file, comm, size, rank):

    """Read the snapshot database from a hdf5 file and distribute it into the corresponding database"""

###read database in h5 files


    if rank == 0:
        print "-----------------------------------------------"
        print "Reading preprocessed HDF5 file with snapshots"
        print "-----------------------------------------------"

    ### read datatable ###
    fhdf = h5py.File(hdf5_database_file, "r", driver='mpio', comm=MPI.COMM_WORLD)

    coors = coordinates()


    ts_dim = fhdf['ts_dim'][()]
    coors.coors_global_dim_rounded = fhdf['coors_global_dim_rounded'][()]

    new_indexes = Intexes()
    new_indexes.set_index(coors.coors_global_dim_rounded)
    new_indexes.set_csr(comm, size, rank)
    new_indexes.organize_split_vectors(copy.deepcopy(coors.coors_global_dim_rounded),
                                       number_ghosh_cells)

    coors.coors_dim_rounded =\
        new_indexes.scatter_vector(copy.deepcopy(coors.coors_global_dim_rounded))

    [neigbours, boundaries] = calculate_neighbors(coors.coors_dim_rounded,
                                                  comm, size, rank)

    dim_vars = Vectors()

    dim_vars.read_in_hdf5_file(fhdf, new_indexes.patch_indexes_ghosh_cells)

    fhdf.close()

    if rank == 0:
        print "-----------------------------------------------"
        print "Reading and postprocesing database finished    "
        print "-----------------------------------------------"

    return [dim_vars, coors, neigbours, boundaries, ts_dim, new_indexes]
Example #2
0
 def ema (series, period):
   result = []
   for i in range(period-1):
     result.append(0)
   k = (2.0/(period+1))
   initSlice = series[0:period]
   previousDay = Vectors.avgVector(initSlice)
   result.append(previousDay)
   emaSlice = series[period:]
   for i in emaSlice:
     previousDay = i * float(k) + previousDay * float((1-k))
     result.append(previousDay)
   return result
Example #3
0
def save_snapshot(ind, a, eigenvectors, coors, path, snapshots_path,
                  new_indexes, snapshots_files, snapshots_names, comm, rank,
                  size):

    fields_local = Vectors()

    fields_local.dot_lumped_separated(eigenvectors, a)

    fields_local.make_non_homogeneous_bc(coors, Tup_dimless, Tdown_dimless,
                                         ymax_dimless, P00, RR)

    fields_local_dim = copy.deepcopy(fields_local)
    fields_local_dim.make_dimensional(v0, T0, T1, p0)

    #coors_local_dim = coors * L0

    sols_snap = np.vstack(
        (fields_local_dim.P[new_indexes.local_indices_inner],
         fields_local_dim.u[new_indexes.local_indices_inner]))
    sols_snap = np.vstack(
        (sols_snap, fields_local_dim.v[new_indexes.local_indices_inner]))
    sols_snap = np.vstack(
        (sols_snap, fields_local_dim.w[new_indexes.local_indices_inner]))
    sols_snap = np.vstack(
        (sols_snap, fields_local_dim.T[new_indexes.local_indices_inner]))
    sols_snap = np.vstack(
        (sols_snap, coors.coors_dim_rounded[new_indexes.local_indices_inner,
                                            0]))
    sols_snap = np.vstack(
        (sols_snap, coors.coors_dim_rounded[new_indexes.local_indices_inner,
                                            1]))
    sols_snap = np.vstack(
        (sols_snap, coors.coors_dim_rounded[new_indexes.local_indices_inner,
                                            2]))
    sols_snap = sols_snap.transpose()

    q = "%05i" % (ind)

    nasol_h = path + "Solutions_" + q + ".h5"
    npsol_h = "Solutions_" + q + ".h5"
    namel_h = "Solutions_" + q

    comm.Barrier()
    snap_h = h5py.File(nasol_h, "w", driver='mpio', comm=MPI.COMM_WORLD)
    all = snap_h.create_dataset(
        "All",
        (coors.coors_global_dimless_rounded.shape[0], sols_snap.shape[1]),
        dtype=np.float64)
    all[new_indexes.global_indices_inner, :] = sols_snap[:, :]
    snap_h.close()
    comm.Barrier()

    snapshots_files.append(npsol_h)
    snapshots_names.append(namel_h)
Example #4
0
def main(text):

    # FORMAT
    parsed = parse(text)

    # BRIDGING
    vectors = Vectors(optimize=False, filename="GoogleNewsVecs.txt")
    bridging(parsed, vectors)

    # CFS
    cfs = centered_f(parsed)

    # CBS
    cbs = cb_finder(parsed)

    # CLASSIFY
    transitions = classify_transitions(cfs, cbs)

    # SCORE
    score = scoring(transitions)
    print "COHERENCE: {}".format(score)

    return
Example #5
0
    def solve_it(self):
        self.not_yet_solved = []
        for i in range(len(self.unknown_vars)):
            solve_attempt = False
            for j in range(len(self.get_equations())):
                if solve_attempt is True:
                    continue
                if self.unknown_vars[i] in self.get_equations()[j]:
                    solved = self.separate_equation_rearrange(
                        self.equations[j], self.unknown_vars[i])[0]
                    solved, solved_factor_sols = str(solved), solved
                    if ', ' in solved:
                        try:
                            solved = eval(solved)
                            for t in range(len(solved)):
                                if solved[t] >= 0:
                                    solved = str(solved[t])
                        except:
                            continue
                    if '[' and ']' in solved:
                        solved = str(solved[1:-1])
                    if check_if_unique(solved, self.unknown_vars) == True:
                        if self.show_full == True:
                            self.answer += str(
                                r'@Solving for ' +
                                self.names[self.unknown_vars[i]] + r':@')
                            self.answer += r'\newline@\newline@Using the equation,@' + r'\begin{equation*}' + sp.latex(
                                sp.sympify(self.display_equations[j]),
                                mode='plain'
                            ) + ' = 0 ' + r'\end{equation*}' + '@Rearrange for $' + self.unknown_vars[
                                i] + '$:@'
                            filler = str(
                                self.separate_equation_rearrange(
                                    self.display_equations[j],
                                    self.unknown_vars[i])[0])[1:-1]

                            if ',' in filler:  # selects answer of positive quadratic factor.
                                if solved_factor_sols[0] >= 0:
                                    filler = filler[:filler.find(',')] + ')'
                                else:
                                    filler = filler[filler.find(',') + 2:]

                            self.answer += str(
                                r'\begin{equation*}' + self.unknown_vars[i] +
                                ' = ' +
                                sp.latex(sp.sympify(filler), mode='plain') +
                                r'\end{equation*}@')

                            solved_fill = self.separate_equation_fill(filler)
                            solved_simplified = self.separate_equation_simplify(
                                solved_fill)
                            solved_evaluated = self.separate_equation_evaluate(
                                solved_fill)

                            solved_fill_display = sp.latex(
                                self.separate_equation_fill_display(
                                    filler, self.display_vars_order),
                                mode='plain')

                            if 'a_v' in filler:
                                self.answer += r'\begin{equation*}' + ' = ' + solved_fill_display
                            else:
                                self.answer += r'\begin{equation*}' + ' = ' + sp.latex(
                                    solved_fill, mode='plain')

                            solved_fill = self.separate_equation_fill(filler)
                            solved_simplified = self.separate_equation_simplify(
                                solved_fill)
                            solved_evaluated = self.separate_equation_evaluate(
                                solved_fill)

                            if 'a_v' == self.unknown_vars[i]:
                                solved_simplified, solved_evaluated = math.degrees(
                                    solved_evaluated), math.degrees(
                                        solved_evaluated)
                            if str(solved_fill) != str(solved_simplified):
                                try:
                                    self.answer += str(
                                        r'\end{equation*}' +
                                        r'@\begin{equation*}' + ' = ' +
                                        sp.latex(round(solved_simplified, 2),
                                                 mode='plain') + '\;' +
                                        self.units[self.unknown_vars[i]] +
                                        r'\end{equation*}@')
                                except:
                                    self.answer += str(
                                        r'\end{equation*}' +
                                        r'@\begin{equation*}' + ' = ' +
                                        sp.latex(solved_simplified,
                                                 mode='plain') +
                                        r'\end{equation*}@')
                            else:
                                self.answer += '\;' + self.units[
                                    self.unknown_vars[i]] + r'\end{equation*}@'

                            if str(
                                    solved_simplified
                            )[str(solved_simplified).
                              find('.'):str(solved_simplified).find('.') +
                              3] != str(solved_evaluated
                                        )[str(solved_evaluated).find('.'):
                                          str(solved_evaluated).find('.') + 3]:
                                try:
                                    self.answer += str(
                                        r'\begin{equation*}' + r'\;or\;' +
                                        sp.latex(round(solved_evaluated, 2),
                                                 mode='plain') + '\;' +
                                        self.units[self.unknown_vars[i]] +
                                        r'\end{equation*}@')
                                except:
                                    self.answer += str(
                                        r'\begin{equation*}' + r'\;or\;' +
                                        sp.latex(round(solved_evaluated, 2),
                                                 mode='plain') +
                                        r'\end{equation*}@')

                            # Called again to reset the values to radians.
                            if 'a_v' == self.unknown_vars[i]:
                                solved_fill = self.separate_equation_fill(
                                    filler)
                                solved_fill = str(solved_fill)
                                solved_simplified = self.separate_equation_simplify(
                                    solved_fill)
                                solved_evaluated = self.separate_equation_evaluate(
                                    solved_fill)
                        else:
                            solved_fill = self.separate_equation_fill(solved)
                            solved_fill = str(solved_fill)
                            solved_simplified = self.separate_equation_simplify(
                                solved_fill)
                            solved_simplified = str(solved_simplified)
                            self.answer += self.unknown_vars[
                                i] + ' = ' + solved_simplified + '\n'

                        try:
                            self.add_known_var(self.unknown_vars[i],
                                               str(round(solved_evaluated, 2)))
                            self.display_vars_order.append(
                                round(solved_evaluated, 2))
                        except:
                            self.add_known_var(self.unknown_vars[i],
                                               str(solved_evaluated))
                            self.display_vars_order.append(solved_evaluated)

                        for t in range(len(self.equations)):
                            self.equations_fill(t)
                            solved, solved_fill, solved_simplified = '', '', ''
                            solve_attempt = True
                        else:
                            solved, solved_fill, solved_simplified = '', '', ''
                else:
                    solved, solved_fill, solved_simplified = '', '', ''
            if solve_attempt is False:
                self.not_yet_solved.append(self.unknown_vars[i])
            if self.unknown_vars[i] == self.unknown_vars[-1]:
                self.unknown_vars = self.not_yet_solved
                self.solve_it()
            if self.solve_for_velocity == True and 'v_T' in self.known_vars and 'a_v' in self.known_vars and 'v_x' in self.known_vars and 'v_y' in self.known_vars:  # Solves the velocity vector when the magnitude and angle are found.
                self.solved_velocity = (Vectors.get_vector([
                    self.vars_order[self.known_vars.index('v_x')],
                    self.vars_order[self.known_vars.index('v_y')]
                ]))
                self.velocity_magnitude = self.solved_velocity[0]
                self.velocity_angle = self.vars_order[self.known_vars.index(
                    'a_v')]
                if self.show_full == True:
                    self.answer += 'Therefore, the magnitude and direction of initial velocity is:@'
                    self.answer += r'\begin{equation*}' + str(
                        round(self.velocity_magnitude, 2)) + r'\;m/s\;' + str(
                            Vectors.get_directions([
                                [self.velocity_magnitude, self.velocity_angle]
                            ])[0][1]).replace(' ', r'\;') + r'\end{equation*}@'
                else:
                    self.answer += 'initial velocity = ' + str(
                        round(self.velocity_magnitude, 2)) + ' m/s ' + str(
                            Vectors.get_directions([[
                                self.velocity_magnitude, self.velocity_angle
                            ]])[0][1]) + '\n'
                self.solve_for_velocity = False
Example #6
0
 def test_combineVectors(self):
     serie1 = [2, 3, -5, 90.4]
     serie2 = [1, 2, 3, 4]
     expected = [3, 5, -2, 94.4]
     self.assertEqual(Vectors.combineVectors(serie1, serie2, self.sumFunct),
                      expected)
Example #7
0
        temp = numpy.array(
            [distance for distance in distances if not numpy.isnan(distance)])

        min_distance = temp.min()

        if type is 'conservative':
            threshold = temp.mean() - (2 * temp.std())
        else:
            threshold = temp.mean() - temp.std()

        if min_distance <= threshold:
            xrenner.markables[i].antecedent = xrenner.markables[
                distances.index(min_distance)]
            xrenner.markables[i].coref_type = 'bridge'

    return None


if __name__ == "__main__":

    xrenner = Xrenner(override='GUM')
    xrenner.analyze('clinton_example.conll10', 'conll')

    vecs = Vectors('../vectors/GoogleNewsVecs.txt', False)

    bridging(xrenner, vecs)

    for markable in xrenner.markables:
        print(markable.text, markable.antecedent, markable.coref_type)
Example #8
0
 def test_absVector(self):
     serie = [-1, -1.4, 0, 5, 5e29, -5e4]
     expected = [1, 1.4, 0, 5, 5e29, 5e4]
     self.assertEqual(Vectors.absVector(serie), expected)
     self.assertEqual(Vectors.absVector([]), [])
Example #9
0
 def test_divVectors(self):
     serie1 = [4.5, 4, 10, -5]
     serie2 = [2, 2, 5, -1]
     expected = [2.25, 2, 2, 5]
     self.assertEqual(Vectors.divVectors(serie1, serie2), expected)
Example #10
0
 def test_avgVector (self):
   serie = [4,5,6,0]
   expected = 3.75
   self.assertEqual (Vectors.avgVector(serie), 3.75)
   self.assertEqual (Vectors.avgVector([]), 0)
Example #11
0
 def test_avgVector(self):
     serie = [4, 5, 6, 0]
     expected = 3.75
     self.assertEqual(Vectors.avgVector(serie), 3.75)
     self.assertEqual(Vectors.avgVector([]), 0)
Example #12
0
def read_database(newnames_files, comm, size, rank):

    """Read the database from separated txt files. Distribute it between processes"""

### reading database in texfiles

    ### initilize vectors ###
    coors = coordinates()

    dim_vars = Vectors()
    dim_vars.zeros()

    neigbours = Neigbors()
    boundaries = Boundary()

    new_indexes = Intexes()
    new_indexes.set_csr(comm, size, rank)

    first_flag = True

    for my_file in newnames_files:

        #### read file ####
        comm.barrier()
        if rank == 0:
            print "-------------------------------------------------------------------"
        sys.stdout.flush()
        comm.barrier()
        print "Processor %d Reading and processing data of file %s" % (rank, my_file)
        sys.stdout.flush()
        comm.barrier()
        if rank == 0:
            print "-------------------------------------------------------------------"
        sys.stdout.flush()
        comm.barrier()
        datos_ori = np.loadtxt(my_file, delimiter=',', skiprows=1, dtype=np.float64)

        ### re-order read data
        datos_ori = datos_ori.copy(order='C')

        if first_flag:

            new_indexes.re_order(datos_ori[:, -3:datos_ori.shape[1]])
            datos = datos_ori[new_indexes.inew[:]]

            coors_round = round_coordinates(copy.deepcopy(datos[:, -3:datos.shape[1]]),
                                            round_cell_size)

            new_indexes.organize_split_vectors(coors_round, number_ghosh_cells)

            coors.coors_dim_rounded = new_indexes.scatter_vector(coors_round.copy())
            [neigbours, boundaries] = calculate_neighbors(coors.coors_dim_rounded,
                                                          comm, size, rank)

            temp_local = new_indexes.scatter_vector(datos[:, 4])
            pres_local = new_indexes.scatter_vector(datos[:, 0])
            vels_local = new_indexes.scatter_vector(datos[:, 1:4])

            coors.coors_global_dim_rounded = round_coordinates(datos[:, -3:datos.shape[1]],
                                                               round_cell_size)

            dim_vars.append(pres_local,
                            vels_local[:, 0],
                            vels_local[:, 1],
                            vels_local[:, 2],
                            temp_local)

            first_flag = False
        else:

            datos = datos_ori[new_indexes.inew[:]]

            temp_local = new_indexes.scatter_vector(datos[:, 4])
            pres_local = new_indexes.scatter_vector(datos[:, 0])
            vels_local = new_indexes.scatter_vector(datos[:, 1:4])

            dim_vars.vstack(pres_local,
                            vels_local[:, 0],
                            vels_local[:, 1],
                            vels_local[:, 2],
                            temp_local)

    dim_vars.transpose()
    new_indexes.local_indices()
    new_indexes.distribute_indexes()

    return [dim_vars, coors, neigbours, boundaries, new_indexes]
Example #13
0
 def test_diffVectors(self):
     s1 = [1.5, 1, 56, 45, -4.5]
     s2 = [2, 4, 5, 45, -1]
     expected = [-0.5, -3, 51, 0, -3.5]
     result = Vectors.diffVectors(s1, s2)
     self.assertEqual(result, expected)
Example #14
0
 def sumWindow (series):
   return Vectors.avgVector (series)
Example #15
0
 def test_diffVectors (self):
   s1 = [1.5, 1, 56, 45, -4.5]
   s2 = [2, 4, 5, 45, -1]
   expected = [-0.5, -3, 51, 0, -3.5]
   result = Vectors.diffVectors (s1, s2)
   self.assertEqual (result, expected)
Example #16
0
 def test_combineVectors (self):
   serie1 = [2,3,-5,90.4]
   serie2 = [1,2,3,4]
   expected = [3,5,-2, 94.4]
   self.assertEqual (Vectors.combineVectors(serie1, serie2, self.sumFunct), expected)
Example #17
0
 def test_divVectors (self):
   serie1 = [4.5, 4, 10, -5]
   serie2 = [2, 2, 5, -1]
   expected = [2.25, 2, 2, 5]
   self.assertEqual (Vectors.divVectors (serie1, serie2), expected)
Example #18
0
 def test_absVector (self):
   serie = [-1, -1.4, 0, 5, 5e29, -5e4]
   expected = [1, 1.4, 0, 5, 5e29, 5e4]
   self.assertEqual (Vectors.absVector(serie), expected)
   self.assertEqual (Vectors.absVector([]), [])
Example #19
0
def variables_info(coors, dimless_homogeneous_vars, name, path, new_indexes,
                   snapshots_path, comm, rank, size):

    pod = Vectors()

    pod.P = np.vstack([
        dimless_homogeneous_vars.P[
            new_indexes.get_local_inner_indices(), :].transpose(),
        coors.coors_dim_rounded[
            new_indexes.get_local_inner_indices(), :].transpose()
    ]).transpose()
    pod.u = np.vstack([
        dimless_homogeneous_vars.u[
            new_indexes.get_local_inner_indices(), :].transpose(),
        coors.coors_dim_rounded[
            new_indexes.get_local_inner_indices(), :].transpose()
    ]).transpose()
    pod.v = np.vstack([
        dimless_homogeneous_vars.v[
            new_indexes.get_local_inner_indices(), :].transpose(),
        coors.coors_dim_rounded[
            new_indexes.get_local_inner_indices(), :].transpose()
    ]).transpose()
    pod.w = np.vstack([
        dimless_homogeneous_vars.w[
            new_indexes.get_local_inner_indices(), :].transpose(),
        coors.coors_dim_rounded[
            new_indexes.get_local_inner_indices(), :].transpose()
    ]).transpose()
    pod.T = np.vstack([
        dimless_homogeneous_vars.T[
            new_indexes.get_local_inner_indices(), :].transpose(),
        coors.coors_dim_rounded[
            new_indexes.get_local_inner_indices(), :].transpose()
    ]).transpose()

    #    print "Number of POD obtained: "
    #    print "For Pressure: %i" % eigenvalues.P.size
    #    print "For U velocity: %i" % eigenvalues.u.size
    #    print "For V velocity: %i" % eigenvalues.v.size
    #    print "For W velocity: %i" % eigenvalues.w.size
    #    print "For Temperature: %i" % eigenvalues.T.size
    if rank == 0:
        print "------------------------------------------------"
        print "---            OUTPUTTING VARIABLES          ---"
        print "------------------------------------------------"

    for p in range(size):
        if rank == p:
            if rank == 0:

                fp = open(path + name + 'pi.dat', 'wb')
                np.savetxt(fp, pod.P)
                fp.close()

                ftau = open(path + name + 'tau.dat', 'wb')
                np.savetxt(ftau, pod.T)
                ftau.close()

                fu = open(path + name + 'u.dat', 'wb')
                np.savetxt(fu, pod.u)
                fu.close()

                fv = open(path + name + 'v.dat', 'wb')
                np.savetxt(fv, pod.v)
                fv.close()

                fw = open(path + name + 'w.dat', 'wb')
                np.savetxt(fw, pod.w)
                fw.close()

            else:

                fp = open(path + name + 'pi.dat', 'ab')
                np.savetxt(fp, pod.P)
                fp.close()

                ftau = open(path + name + 'tau.dat', 'ab')
                np.savetxt(ftau, pod.T)
                ftau.close()

                fu = open(path + name + 'u.dat', 'ab')
                np.savetxt(fu, pod.u)
                fu.close()

                fv = open(path + name + 'v.dat', 'ab')
                np.savetxt(fv, pod.v)
                fv.close()

                fw = open(path + name + 'w.dat', 'ab')
                np.savetxt(fw, pod.w)
                fw.close()

        comm.Barrier()

    #modeploter_function(path, file_pod, name, pod_yes=False, dir=2, dx=0.000625):

    files_pod = [
        name + 'pi.dat', name + 'tau.dat', name + 'u.dat', name + 'v.dat',
        name + 'w.dat'
    ]
    names = [name + 'pi', name + 'tau', name + 'u', name + 'v', name + 'w']
    # argumentos.append('python ./mode_plotter.py --file_pod '+name+'pi.dat --path ' + path[:-1] + ' --name '+name+'pi --pod')
    # argumentos.append('python ./mode_plotter.py --file_pod '+name+'tau.dat --path ' + path[:-1] + ' --name '+name+'tau --pod')
    # argumentos.append('python ./mode_plotter.py --file_pod '+name+'u.dat --path ' + path[:-1] + ' --name '+name+'u --pod')
    # argumentos.append('python ./mode_plotter.py --file_pod '+name+'v.dat --path ' + path[:-1] + ' --name '+name+'v --pod')
    # argumentos.append('python ./mode_plotter.py --file_pod '+name+'w.dat --path ' + path[:-1] + ' --name '+name+'w --pod')

    # for p in range(len(files_pod)):
    #     if p%size==rank:
    #         # os.system(argumentos[p])
    #         modeploter_function(path, files_pod[p], names[p], True, False)
    #     # os.system(argumentop)
    #     # os.system(argumentou)
    #     # os.system(argumentov)
    #     # os.system(argumentow)
    #     # os.system(argumentot)
    #
    # if rank==len(files_pod)%size:
    #     plot_velocity_field_files('Vels_database_', path, path+name+'u.dat', path+name+'v.dat', snapshots_path)

    for p in range(len(files_pod)):
        if rank == 0:
            # os.system(argumentos[p])
            modeploter_function(path, files_pod[p], names[p], True, False)
            plot_velocity_field_files('Vels_database_', path,
                                      path + name + 'u.dat',
                                      path + name + 'v.dat', snapshots_path)
Example #20
0
 def test_powVectors(self):
     serie = [2, 5, 6, 7.6]
     expected = [4, 25, 36, 57.76]
     result = Vectors.powVector(serie)
     self.assertEqual(result, expected)
Example #21
0
def pod_info(coors_dim, eigenvectors, path, comm, rank, size):

    pod = Vectors()

    pod.P = np.vstack([eigenvectors.P.transpose(),
                       coors_dim.transpose()]).transpose()
    pod.u = np.vstack([eigenvectors.u.transpose(),
                       coors_dim.transpose()]).transpose()
    pod.v = np.vstack([eigenvectors.v.transpose(),
                       coors_dim.transpose()]).transpose()
    pod.w = np.vstack([eigenvectors.w.transpose(),
                       coors_dim.transpose()]).transpose()
    pod.T = np.vstack([eigenvectors.T.transpose(),
                       coors_dim.transpose()]).transpose()

    #    print "Number of POD obtained: "
    #    print "For Pressure: %i" % eigenvalues.P.size
    #    print "For U velocity: %i" % eigenvalues.u.size
    #    print "For V velocity: %i" % eigenvalues.v.size
    #    print "For W velocity: %i" % eigenvalues.w.size
    #    print "For Temperature: %i" % eigenvalues.T.size
    print "-----------------------"
    print "--- OUTPUTTING PODS ---"
    print "-----------------------"

    for p in range(size):
        if rank == p:
            if rank == 0:

                fp = open(path + 'pod_pi.dat', 'wb')
                np.savetxt(fp, pod.P)
                fp.close()

                ftau = open(path + 'pod_tau.dat', 'wb')
                np.savetxt(ftau, pod.T)
                ftau.close()

                fu = open(path + 'pod_u.dat', 'wb')
                np.savetxt(fu, pod.u)
                fu.close()

                fv = open(path + 'pod_v.dat', 'wb')
                np.savetxt(fv, pod.v)
                fv.close()

                fw = open(path + 'pod_w.dat', 'wb')
                np.savetxt(fw, pod.w)
                fw.close()

            else:

                fp = open(path + 'pod_pi.dat', 'ab')
                np.savetxt(fp, pod.P)
                fp.close()

                ftau = open(path + 'pod_tau.dat', 'ab')
                np.savetxt(fp, pod.T)
                ftau.close()

                fu = open(path + 'pod_u.dat', 'ab')
                np.savetxt(fp, pod.u)
                fu.close()

                fv = open(path + 'pod_v.dat', 'ab')
                np.savetxt(fp, pod.v)
                fv.close()

                fw = open(path + 'pod_w.dat', 'ab')
                np.savetxt(fp, pod.w)
                fw.close()

        comm.Barrier()

    argumentop = 'python ./mode_plotter.py --file_pod pod_pi.dat --path ' + path[:
                                                                                 -1] + ' --name pod_obtenido_pi --pod'
    argumentot = 'python ./mode_plotter.py --file_pod pod_tau.dat --path ' + path[:
                                                                                  -1] + ' --name pod_obtenido_tau --pod'
    argumentou = 'python ./mode_plotter.py --file_pod pod_u.dat --path ' + path[:
                                                                                -1] + ' --name pod_obtenido_u --pod'
    argumentov = 'python ./mode_plotter.py --file_pod pod_v.dat --path ' + path[:
                                                                                -1] + ' --name pod_obtenido_v --pod'
    argumentow = 'python ./mode_plotter.py --file_pod pod_w.dat --path ' + path[:
                                                                                -1] + ' --name pod_obtenido_w --pod'

    os.system(argumentop)
    os.system(argumentou)
    os.system(argumentov)
    os.system(argumentow)
    os.system(argumentot)

    plot_velocity_field_files(
        'Pods_vectorial_',
        path,
        path + 'pod_u.dat',
        path + 'pod_v.dat',
    )
Example #22
0
 def test_powVectors (self):
   serie = [2,5,6,7.6]
   expected = [4, 25, 36, 57.76]
   result = Vectors.powVector(serie)
   self.assertEqual(result, expected)