Skip to content

Commit

Permalink
Merge branch 'master' into glopro
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Sep 17, 2024
2 parents 4c56cd0 + 6f8640b commit 0152e30
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions cgyro/bin/cgyro_converge
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python

import numpy as np

from pygacode.cgyro import data
from pygacode.gacodefuncs import *

# read minimal data for setup (look in current directory)
sim = data.cgyrodata('./',fast=True,silent=True)

# copy time vector and number of species
t = sim.t
ns = sim.n_species

# read bin.cgyro.ky_flux
sim.getflux()

# select field=0 (phi), moment=1 (Q), species (0), and sum over kx
field=0 ; moment=1 ; species=0
y = np.sum(sim.ky_flux[species,moment,field,:,:],axis=0)

# Simulation length (max time)
tmax = t[-1]

# size and number of time windows
dt = 50.0
nwin = int(tmax/dt)
t0 = tmax-nwin*dt

# averaging over all windows (note that time_average function is fast/optimized)
for i in range(nwin):
w=str(tmax-(i+1)*dt)+','+str(tmax-i*dt)
imin,imax=time_index(t,w)
ave = time_average(y[:],t,imin,imax)
print(i,ave)

4 changes: 2 additions & 2 deletions f2py/pygacode/cgyro/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
class cgyrodata:

# constructor reads in basic (not all) simulation data
def __init__(self,sim_directory,silent=False):
def __init__(self,sim_directory,silent=False,fast=False):

self.silent = silent
self.dir = sim_directory
hastime = self.gettime()
self.getgrid()
if hastime:
if hastime and not fast:
self.getdata()

# standard routine to read binary or ASCII data
Expand Down

0 comments on commit 0152e30

Please sign in to comment.