Exemple #1
0
def avgrate(p, y=None, tind=None):
    
    if tind == None : tind =0

    rmsp_f=moment_xyzt(p, 'RMS').rms

    ni=np.shape(rmsp_f)[1]
    nj=np.shape(rmsp_f)[2]

    growth=np.zeros((ni,nj))

    with np.errstate(divide='ignore'):
        

        for i in range(ni):
            for j in range(nj):
                growth[i,j]=np.gradient(np.log(rmsp_f[tind::,i,j]))[-1]

    d=np.ma.masked_array(growth,np.isnan(growth))

# masked arrays
# http://stackoverflow.com/questions/5480694/numpy-calculate-averages-with-nans-removed    
                        
    print('Total average growth rate= ', np.mean(np.ma.masked_array(d,np.isinf(d))))
    if y != None : print('Growth rate in plane', y, '= ', np.mean(np.ma.masked_array(growth[:,y],np.isnan(growth[:,y]))))
Exemple #2
0
def avgrate(p, y=None, tind=None):

    if tind == None: tind = 0

    rmsp_f = moment_xyzt(p, 'RMS').rms

    ni = np.shape(rmsp_f)[1]
    nj = np.shape(rmsp_f)[2]

    growth = np.zeros((ni, nj))

    with np.errstate(divide='ignore'):

        for i in range(ni):
            for j in range(nj):
                growth[i, j] = np.gradient(np.log(rmsp_f[tind::, i, j]))[-1]

    d = np.ma.masked_array(growth, np.isnan(growth))

    # masked arrays
    # http://stackoverflow.com/questions/5480694/numpy-calculate-averages-with-nans-removed

    print('Total average growth rate= ',
          np.mean(np.ma.masked_array(d, np.isinf(d))))
    if y != None:
        print(
            'Growth rate in plane', y, '= ',
            np.mean(np.ma.masked_array(growth[:, y], np.isnan(growth[:, y]))))
Exemple #3
0
def gr(p):
	rmsp_f=moment_xyzt(p, 'RMS').rms

	ni=np.shape(rmsp_f)[1]
	nj=np.shape(rmsp_f)[2]

	growth=np.zeros((ni,nj))

	for i in range(ni):
    		for j in range(nj):
       			 growth[i,j]=np.gradient(np.log(rmsp_f[ik::,i,j]))[-1]

	return growth
Exemple #4
0
from __future__ import print_function
######
# Computes the rms of a variable and prints the growth rate value at the last timestep
###### 

import numpy as np
from boutdata import collect
from boututils import moment_xyzt



path='./data/'


p=collect('P',path=path)
rmsp_f=moment_xyzt(p[:,34:35,32:33,:], 'RMS').rms


print(np.gradient(np.log(rmsp_f[:,0,0]))[-1])

if not os.path.exists('image'):
   os.makedirs('image')

g = file_import('../cbm18_dens8.grid_nx68ny64.nc')
psi = old_div((g['psixy'][:, 32] - g['psi_axis']), (g['psi_bndry'] - g['psi_axis']))

path = './data'

plt.figure()

#p0 = transpose(readsav(os.path.join(path, 'p0.idl.dat'))['p0'])
p0=collect('P0', path=path)

#dcp = transpose(readsav(os.path.join(path, 'dcp.idl.dat'))['dcp'])
p=collect('P', path=path)
res = moment_xyzt(p,'RMS','DC')
rmsp = res.rms
dcp = res.dc
nt = dcp.shape[2]

plt.plot(psi, p0[:, 32], 'k--', label='t=0')
plt.plot(psi, p0[:, 32] + dcp[old_div(nt,4), :, 32], 'r-', label='t='+np.str(old_div(nt,4)))
plt.plot(psi, p0[:, 32] + dcp[old_div(nt,2), :, 32], 'g-', label='t='+np.str(old_div(nt,2)))
plt.plot(psi, p0[:, 32] + dcp[3*nt/4, :, 32], 'b-', label='t='+np.str(3*nt/4))
plt.plot(psi, p0[:, 32] + dcp[-1, :, 32], 'c-', label='t='+np.str(nt))

plt.legend()
#plt.xlim(0.6, 1.0)
plt.xlabel(r'Normalized poloidal flux ($\psi$)')
plt.ylabel(r'$\langle p\rangle_\xi$')
plt.title(r'Pressure')
Exemple #6
0
save('t_array.dat', t_array)
p0 = collect('P0', path=path)
save('p0.dat', p0)

# n0=collect('n0', path=path)
# save('n0.dat', n0
# ti0=collect('ti0', path=path)
# save('ti0.dat', ti0)
# te0=collect('te0', path=path)
# save('te0.idl.dat', te0)

gfile = file_import('./cbm18_dens8.grid_nx68ny64.nc')

p = collect('P', path=path)
save('p.dat', p)
res = moment_xyzt(p, 'RMS', 'DC')
rmsp = res.rms
dcp = res.dc
save('rmsp.dat', rmsp)
save('dcp.dat', dcp)
elmsp = elm_size(dcp, p0, gfile, yind=32, Bbar=gfile['bmag'])
save('elmsp.dat', elmsp)

figure(0)
plot(t_array, elmsp.s2, 'k-')
xlabel('t/Ta')
ylabel('Elm size')
title('Elm size, P')
tight_layout()
show()
Exemple #7
0
    os.makedirs('image')

g = file_import('../cbm18_dens8.grid_nx68ny64.nc')
psi = old_div((g['psixy'][:, 32] - g['psi_axis']),
              (g['psi_bndry'] - g['psi_axis']))

path = './data'

plt.figure()

#p0 = transpose(readsav(os.path.join(path, 'p0.idl.dat'))['p0'])
p0 = collect('P0', path=path)

#dcp = transpose(readsav(os.path.join(path, 'dcp.idl.dat'))['dcp'])
p = collect('P', path=path)
res = moment_xyzt(p, 'RMS', 'DC')
rmsp = res.rms
dcp = res.dc
nt = dcp.shape[2]

plt.plot(psi, p0[:, 32], 'k--', label='t=0')
plt.plot(psi,
         p0[:, 32] + dcp[old_div(nt, 4), :, 32],
         'r-',
         label='t=' + np.str(old_div(nt, 4)))
plt.plot(psi,
         p0[:, 32] + dcp[old_div(nt, 2), :, 32],
         'g-',
         label='t=' + np.str(old_div(nt, 2)))
plt.plot(psi,
         p0[:, 32] + dcp[3 * nt / 4, :, 32],
Exemple #8
0
from __future__ import print_function
######
# Computes the rms of a variable and prints the growth rate value at the last timestep
######

import numpy as np
from boutdata import collect
from boututils import moment_xyzt

path = './data/'

p = collect('P', path=path)
rmsp_f = moment_xyzt(p[:, 34:35, 32:33, :], 'RMS').rms

print(np.gradient(np.log(rmsp_f[:, 0, 0]))[-1])
p0=collect('P0', path=path)
save('p0.dat', p0)


# n0=collect('n0', path=path)
# save('n0.dat', n0
# ti0=collect('ti0', path=path)
# save('ti0.dat', ti0)
# te0=collect('te0', path=path)
# save('te0.idl.dat', te0)

gfile=file_import('./cbm18_dens8.grid_nx68ny64.nc')

p=collect('P', path=path)
save('p.dat', p)
res=moment_xyzt(p,'RMS','DC')
rmsp=res.rms
dcp=res.dc
save('rmsp.dat', rmsp)
save('dcp.dat',  dcp)
elmsp=elm_size(dcp,p0,gfile,yind=32,Bbar=gfile['bmag'])
save('elmsp.dat',  elmsp)

figure(0)
plot(t_array,elmsp.s2, 'k-')
xlabel('t/Ta')
ylabel('Elm size')
title('Elm size, P')
tight_layout()
show()
Exemple #10
0
fig=figure()
plot(psix,-Dphi0[:,32], 'r', linewidth=5)
plot(psix,Epsi,'k',linewidth=5)
annotate('w/o flow', xy=(.3, .7),  xycoords='axes fraction',horizontalalignment='center', verticalalignment='center', size=30)
annotate('w/ flow', xy=(.7, .4),  xycoords='axes fraction',horizontalalignment='center', verticalalignment='center', color='r', size=30)
xlabel('Radial $\psi$',fontsize=25)
ylabel('$\Omega(\psi)/\omega_A$',fontsize=25)
ylim([-.05,0])
xlim([0.4,1.2])
fig.set_tight_layout(True)
show(block=False)

p_f0 = collect("P", path=path0)
p_f = collect("P", path=path1)
#
rmsp_f0=moment_xyzt(p_f0, 'RMS').rms
rmsp_f=moment_xyzt(p_f, 'RMS').rms
#

fig=figure(figsize=(10, 8))
plot(np.gradient(np.log(rmsp_f0[:,34,32])), color='k',linewidth=3)
plot(np.gradient(np.log(rmsp_f[:,34,32])),color='red',linewidth=3)

ylabel('$\gamma / \omega_A$',fontsize=25)
xlabel('Time$(\\tau_A)$',fontsize=25)
annotate('w/o flow', xy=(.5, .7),  xycoords='axes fraction',horizontalalignment='center', verticalalignment='center', size=30)
annotate('w/ flow', xy=(.5, .4),  xycoords='axes fraction',horizontalalignment='center', verticalalignment='center', color='r', size=30)
ylim([0,0.5])
xlim([0,100])
fig.set_tight_layout(True)
show(block=False)
Exemple #11
0
         xycoords='axes fraction',
         horizontalalignment='center',
         verticalalignment='center',
         color='r',
         size=30)
xlabel('Radial $\psi$', fontsize=25)
ylabel('$\Omega(\psi)/\omega_A$', fontsize=25)
ylim([-.05, 0])
xlim([0.4, 1.2])
fig.set_tight_layout(True)
show(block=False)

p_f0 = collect("P", path=path0)
p_f = collect("P", path=path1)
#
rmsp_f0 = moment_xyzt(p_f0, 'RMS').rms
rmsp_f = moment_xyzt(p_f, 'RMS').rms
#

fig = figure(figsize=(10, 8))
plot(np.gradient(np.log(rmsp_f0[:, 34, 32])), color='k', linewidth=3)
plot(np.gradient(np.log(rmsp_f[:, 34, 32])), color='red', linewidth=3)

ylabel('$\gamma / \omega_A$', fontsize=25)
xlabel('Time$(\\tau_A)$', fontsize=25)
annotate('w/o flow',
         xy=(.5, .7),
         xycoords='axes fraction',
         horizontalalignment='center',
         verticalalignment='center',
         size=30)