Skip to content

Commit

Permalink
Merge branch 'garysbranch' of github.com:/gafusion/gacode into garysb…
Browse files Browse the repository at this point in the history
…ranch
  • Loading branch information
gmstaebler committed Oct 26, 2024
2 parents 6f94adb + d5df629 commit e343a8b
Show file tree
Hide file tree
Showing 275 changed files with 8,636 additions and 2,797 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ glf23/src/glf23
gyro/src/gyro
cgyro/src/cgyro
cgyro/mpi_tests/*
qlgyro/src/qlgyro
neo/src/neo
neo/tools/pneo/src/pneo
neo/tools/pneo/src/pneo_rbf
Expand Down
Empty file removed .gitmodules
Empty file.
2 changes: 2 additions & 0 deletions cgyro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export EXTRA_LIBS = \
all:
gacode_getversion > .VERSION
cd ${GACODE_ROOT}/shared/math ; make
cd ${GACODE_ROOT}/shared/landau ; make
cd ${GACODE_ROOT}/f2py ; make
cd src && make

Expand All @@ -27,6 +28,7 @@ clean:

deepclean:
cd ${GACODE_ROOT}/shared/math ; make clean
cd ${GACODE_ROOT}/shared/landau ; make clean
cd ${GACODE_ROOT}/f2py ; make clean
cd ${GACODE_ROOT}/modules ; rm -f cgyro*.mod
cd src && make clean
Expand Down
22 changes: 9 additions & 13 deletions cgyro/bin/README_omp.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
Running CGYRO with high nomp
============================

CGYRO allocates some of its data on the stack,
and the amount is proportional with the
number of omp threads you use.
(omp==openMP)
CGYRO allocates some of its data on the stack, and the amount is
proportional to the number of omp (OpenMP) threads you use. The
default stack limit of 8M is only sufficient for up to about 4 omp
threads. Thus, when using CGYRO with openMP, it is recommended
that you put the following line into your .bashrc

The default stack limit of 8M is only sufficient
for up to about 4 omp threads.
ulimit -s 32768

Thus, when using CGYRO with openMP,
it is recommended that you put the following line
into your .bashrc
ulimit -s 32768
(must be set on all the nodes running CGYRO)
(This must be set on all the nodes running CGYRO). Moreover, for
platforms that do not use the system stack limit for OpenMP
threads, also set

Moreover, for platform that do not use the
system stack limit for OpenMP threads, also set
export OMP_STACKSIZE=32M

This should be sufficient for at least 128 omp threads.
15 changes: 13 additions & 2 deletions cgyro/bin/cgyro
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ then
echo " -rs <case>"
echo " Run specified regression case."
echo
echo " -rt"
echo " Enable restart regression testing."
echo
echo " -reset"
echo " Reset regression data."
echo
Expand Down Expand Up @@ -104,6 +107,7 @@ MPINUMA=0
TEST_FLAG=0
GENERATE_FLAG=0
REGRESS_FLAG=0
REGRESS_RESTART=0
MTEST_FLAG=0
CLEAN=0
COMPRESS_FLAG=0
Expand Down Expand Up @@ -142,6 +146,8 @@ while [ $# -gt 0 ] ; do

-rs) REGRESS_FLAG=1 ; shift ; SCASE=$1 ;;

-rt) REGRESS_RESTART=1 ;;

-reset) RESET=1 ;;

-m) MTEST_FLAG=1 ;;
Expand Down Expand Up @@ -219,7 +225,12 @@ then
exit 1
fi
# NOMP=1 RESET=0
gacode_reg_do $NPROC $NOMP $RESET cgyro 1e-6 $SCASE
if [ $REGRESS_RESTART -eq 0 ]
then
gacode_reg_do $NPROC $NOMP $RESET cgyro 1e-6 $SCASE
else
gacode_reg_do_restart $NPROC $NOMP $RESET cgyro 1e-6 $SCASE
fi
exit 0
fi
#============================================================
Expand Down Expand Up @@ -325,7 +336,7 @@ then
version_tag=`gacode_getversion`
if [ -f out.cgyro.tag ]
then
simtime=`tail -1 out.cgyro.tag`
simtime=`head -n2 out.cgyro.tag | tail -n1`
simtime=`echo $simtime`
else
simtime=0.0
Expand Down
26 changes: 0 additions & 26 deletions cgyro/bin/cgyro_b2b.py

This file was deleted.

43 changes: 0 additions & 43 deletions cgyro/bin/cgyro_compress

This file was deleted.

116 changes: 116 additions & 0 deletions cgyro/bin/cgyro_converge
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env python

import numpy as np
import os
import matplotlib as mpl
import matplotlib.pyplot as plt

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


# --- to visualize results for one case plot=True------
plot=True

if plot:
directory='./'
write_output=False
else:
directory= "/global/cfs/cdirs/cgyrodb/"
write_output=True
fout = "./cases_results_20%.txt"
fo = open(fout, "w")


for path, folders, files in os.walk(directory):
# Open file#
for filename in files:
if 'out.cgyro.info' in filename:
if write_output:
fo.write(f"#-----{path}-----#")
# read minimal data for setup (look in current directory)
sim = data.cgyrodata(f'{path}/',fast=True,silent=True)

# copy time vector and number of species
t = sim.t
ns = sim.n_species
linestyles=['-','--',':','-.']
# read bin.cgyro.ky_flux
sim.getflux()


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




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


if plot:
#add plot for visualization
fig = plt.figure(figsize=(12,6))

plt.xlabel('time [$c_s$/a]')
plt.ylabel('Flux')
colors = mpl.cm.rainbow(np.linspace(0, 1, nwin))


convergance = True

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

if plot:
plt.plot(t,y, label=f"Q_{species_index}", linestyle=linestyles[species_index], color=colors[species_index])

average_array=[]

# 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)
average_array.append(ave)
if plot:
plt.hlines(y=ave, xmin=t[imin], xmax=t[imax], color=colors[i], lw=3, linestyle=linestyles[species_index])







# define the convergence by std between last free averaged regions as a pesentage to the total

if np.std(average_array[:3]/np.mean(average_array[:3])) > 0.2:
convergance = False

if convergance:
if write_output:
fo.write("TRUE \n")
else:
plt.title('Converged')
else:
if write_output:
fo.write("FALSE \n")
else:
plt.title("Didn't converge")

if plot:
plt.legend()
plt.show()



Loading

0 comments on commit e343a8b

Please sign in to comment.