Example #1
0
def diags_cp_cm(x, y):
    dd.read_parameters()
    diagdir = '/scratch/01658/drhatch/dna_out'
    par['diagdir'] = "\'" + diagdir + "\'"

    time = dd.get_time_from_gout()
    kx, ky, kz, hermiteNumbers = dd.get_grids()

    print 'kx =', np.shape(kx)
    print 'ky =', np.shape(ky)
    print 'kz =', np.shape(kz)
    print 'n =', np.shape(hermiteNumbers)

    g_in = dd.read_time_step_g(len(time) - 1)
    g_in = np.reshape(g_in,
                      (par['nkx0'], par['nky0'], par['nkz0'], par['nv0']),
                      order='F')

    x = x
    y = y
    dist = g_in[x, y, :, :]  #distribution function: 2d slice of 4d g_in

    #make a new 2d array with the same dimensions as dist_
    shape = np.shape(dist)
    dist_t = np.empty(shape)

    for i in range(len(kz)):
        for j in range(len(hermiteNumbers)):
            dist_t[i,
                   j] = (1j * np.sign(kz[i]))**hermiteNumbers[j] * dist[i, j]

    dist_tp = np.empty(shape)
    dist_tm = np.empty(shape)

    for i in range(len(kz)):
        for j in range(len(hermiteNumbers) + 1):
            if j < (len(hermiteNumbers) - 1):
                dist_tp[i, j] = (dist_t[i, j] + dist_t[i, j + 1]) / 2
                dist_tm[i, j] = (dist_t[i, j] - dist_t[i, j + 1]) / 2

    c_p = np.empty(np.shape(dist_tp))
    c_m = np.empty(np.shape(dist_tm))

    for i in range(len(kz)):
        for j in range(len(kz)):
            c_p[i, j] = dist_tp[i, j] * np.conjugate(dist_tp[i, j])
            c_m[i, j] = dist_tm[i, j] * np.conjugate(dist_tm[i, j])

    c_ps = np.sum(c_p, axis=0)
    c_ms = np.sum(c_m, axis=0)
    xf = kx[x]
    yf = ky[y]
    return c_ps, c_ms, xf, yf
Example #2
0
def calculate_g(kx, ky, kz, nmax, nu, gam0):
    """calculates g using eigenvector g"""
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    dd.read_parameters()

    diagdir = '/scratch/01658/drhatch/dna_out'
    par['diagdir'] = "\'" + diagdir + "\'"
    time = dd.get_time_from_gout()
    kx, ky, kz, herm_grid = dd.get_grids()
    nmax = 36
    mat.set_nmax(nmax)
    Gam0 = mat.get_gamma0()

    par['nu'] = 0.002222
    print 'nu = ', par['nu']

    par['omn'] = 0
    par['omt'] = 0
    par['hyp_x'] = 0
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
    omega, freq, growth, evec = mat.get_spectrum(kx, ky, kz, Gam0, nu)
    g_max, gi_max = max_g(growth)
    g_0 = evec[:, gi_max]

    nu_bar = nu / kz
    g_calc = np.empty(nmax, dtype=complex)

    for n in range(nmax):
        if n == 0 or n == 1:
            g_calc[0] = g_0[0]
            g_calc[1] = g_0[1]
        else:
            g_calc[n] = ((omega[gi_max] / kz + 1j * nu_bar *
                          (n - 1)) * g_0[n - 1] -
                         (n - 1)**(.5) * g_0[n - 2]) / ((n)**(.5))
    err = find_error(g_0, g_calc, nmax)
    plot_eig_vec(g_calc, g_0, herm_grid, nmax)
    plot_error(err, herm_grid, nmax)

    return g_calc, g_0
Example #3
0
from scipy.stats import linregress
from config import *
import new_dd as dd
from ev_diags import *
import time as t2
from spectra import *
from nlt_diags import *
#from landau_tests import *
import os
import matrix_maker as mat

dd.read_parameters()

diagdir = '/scratch/01658/drhatch/dna_out'
par['diagdir'] = "\'" + diagdir + "\'"
time = dd.get_time_from_gout()
kx, ky, kz, herm_grid = dd.get_grids()
nmax = 40
mat.set_nmax(nmax)

par['nu'] = 0.05
print 'nu = ', par['nu']
print 'kz = ', kz

par['omn'] = 0
par['omt'] = 0
par['hyp_x'] = 0
par['hyp_y'] = 0
par['hyp_v'] = 0
par['nuno_closure'] = False