Exemple #1
0
    def diagnose_var(self, state):
        #bc.apply_bc_on_velocity(state, self.neighbours)
        self.halo.fill(state.b)
        self.halo.fill(state.u)

        # Diagnostic variables
        cov_to_contra.U_from_u(state, self.grid)
        projection.compute_p(self.mg, state, self.grid, self.neighbours)
        self.halo.fill(state.u)
        cov_to_contra.U_from_u(state, self.grid)

        # this computation is only to check the divergence
        # after the projection, this could be drop if
        # we don't need to know the information (that can
        # always be estimated offline, from 'u')
        projection.compute_div(self.state, timing=False)
        self.halo.fill(state.div)
        self.update_stats()

        if self.nonlinear:
            vort.vorticity(state, self.fparameter)
            #bc.apply_bc_on_vorticity(state, self.neighbours)
            kinetic.kinenergy(state, self.grid, self.orderKE)
            self.halo.fill(state.vor)
            self.halo.fill(state.ke)
Exemple #2
0
    u = ds.u['i'].view('i')
    v = ds.u['j'].view('i')
    w = ds.u['k'].view('i')

    plt.close('all')
    plt.ion()

    d = div.view('i')
    fields = [('div', d), ('u', u), ('v', v), ('w', w)]
    fig, ax = plt.subplots(2, 2)
    fig.set_size_inches([15, 8])
    for i in range(4):
        a = ax[i // 2, i % 2]
        name, f = fields[i]
        im = a.imshow(f[10, :, :], origin='xy')
        a.set_xlabel('x')
        a.set_ylabel('y')
        a.set_title(name)
        plt.colorbar(im, ax=a)

    plt.show()
    for direc in 'ijk':
        s.u[direc].view('i')[:] = ds.u[direc].view('i')[:]

    vort.vorticity(s, 0.)
    vor = s.vor
    wy = vor['j'].view('i')
    plt.figure()
    plt.imshow(wy[:, :, 10], origin='xy')
    plt.colorbar()
Exemple #3
0
# pitch = [10]
# radius = [10]

# load the grids
grids = ag.getGrid()

t1 = time.time()

# loop over grids to calculate averages

print('Commencing vorticity calculation')
for grid in grids:

    # loop over current grid
    for i in range(np.size(grid, axis=0)):
        for j in range(np.size(grid, axis=1)):
            for k in range(np.size(grid, axis=2)):

                # current bin
                thisBin = grid[i, j, k]

                if len(thisBin.vectors) > minParticlesForAverages:
                    thisBin.vorticity = vort.vorticity(grid, thisBin, [
                        gridBin.nrBinsX - 1, gridBin.nrBinsY - 1,
                        gridBin.nrBinsZ - 1
                    ], 3)
                    #print(thisBin.vorticity)

# TESTING::

#print(grids[0][50,30,25].vorticity)
Exemple #4
0
def compute_diagnostic_variables(state):
    """Update vorticity and kinetic energy in state."""
    # Calculate the new vorticity
    vorticity(state)
    # Calculate the new kinetic energy
    kinenergy(state)
Exemple #5
0
print("----------------------------------------")

for grid in grids:

    # loop over current grid
    for i in range(np.size(grid, axis=0)):
        for j in range(np.size(grid, axis=1)):
            for k in range(np.size(grid, axis=2)):

                # current bin
                thisBin = grid[i, j, k]

                if len(thisBin.vectors) > minParticlesForAverages:
                    thisBin.vorticity = vort.vorticity(grid, thisBin, [
                        np.size(grid, axis=0) - 1,
                        np.size(grid, axis=1) - 1,
                        np.size(grid, axis=2) - 1
                    ], 3)


def plotting(planes, typ, location, unit, number, start, stop, title):
    t1 = time.time()
    m = 0
    n = 0
    l = 0
    for grid in grids:
        # figure, axes = plt.subplots(nrows=1, ncols=3)

        levels = np.linspace(start, stop, number)

        uyz_values, vyz_values, wyz_values = [], [], []
Exemple #6
0
    #output the data 



    # Move boundary at the local fluid velocity

    b1, b2 = mv_b.move_boundary(b1,b2,f.Q,u,v)
    #print b1, b2
    # now we need to output the data, right now we are only making a vorticity movie 
# this needs to be changed to output full data of u,v,umag,vort, and forces 
    #print u, v 
    if f.time>ptime:
        rec.record(u,v,vort,press,f1,f2,b1,b2,k)
    #make a vorticity plot
        plt.figure()
        vort = vrt.vorticity(u,v,vort)
        cmaxx = np.max(vort)
        cmxx = np.max(cmaxx)
        plt.pcolor(xcoord, ycoord, vort,cmap = cm.hot, vmax=cmxx/16.0, vmin=-cmxx/16.0)
        plt.colorbar()

        plt.plot(b1,b2, 'yo')
        plt.plot(b1t, b2t, 'go')
    
        ptime = f.graphtime + ptime   #this makes 'print time' increase so taht this if statement doesn't run every time step 
        save = str('%03d' % k) + '.png'
        plt.savefig(save, dpi = 100, bbox_inches='tight')
        print 'wrote file', save
        plt.show()
        plt.clf()
        k = k+1   #update frame number
Exemple #7
0
                                        w2, pft, f.time, press)

    #output the data

    # Move boundary at the local fluid velocity

    b1, b2 = mv_b.move_boundary(b1, b2, f.Q, u, v)
    #print b1, b2
    # now we need to output the data, right now we are only making a vorticity movie
    # this needs to be changed to output full data of u,v,umag,vort, and forces
    #print u, v
    if f.time > ptime:
        rec.record(u, v, vort, press, f1, f2, b1, b2, k)
        #make a vorticity plot
        plt.figure()
        vort = vrt.vorticity(u, v, vort)
        cmaxx = np.max(vort)
        cmxx = np.max(cmaxx)
        plt.pcolor(xcoord,
                   ycoord,
                   vort,
                   cmap=cm.hot,
                   vmax=cmxx / 16.0,
                   vmin=-cmxx / 16.0)
        plt.colorbar()

        plt.plot(b1, b2, 'yo')
        plt.plot(b1t, b2t, 'go')

        ptime = f.graphtime + ptime  #this makes 'print time' increase so taht this if statement doesn't run every time step
        save = str('%03d' % k) + '.png'