diff --git a/.gitignore b/.gitignore index ae8dd4808..5a061923c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29bb..000000000 diff --git a/cgyro/Makefile b/cgyro/Makefile index 57b2daed1..ae5888e3a 100644 --- a/cgyro/Makefile +++ b/cgyro/Makefile @@ -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 @@ -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 diff --git a/cgyro/bin/README_omp.txt b/cgyro/bin/README_omp.txt index c115d4eb9..326eace84 100644 --- a/cgyro/bin/README_omp.txt +++ b/cgyro/bin/README_omp.txt @@ -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. diff --git a/cgyro/bin/cgyro b/cgyro/bin/cgyro index 96ffe23a5..01ef54795 100755 --- a/cgyro/bin/cgyro +++ b/cgyro/bin/cgyro @@ -53,6 +53,9 @@ then echo " -rs " echo " Run specified regression case." echo + echo " -rt" + echo " Enable restart regression testing." + echo echo " -reset" echo " Reset regression data." echo @@ -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 @@ -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 ;; @@ -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 #============================================================ @@ -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 diff --git a/cgyro/bin/cgyro_b2b.py b/cgyro/bin/cgyro_b2b.py deleted file mode 100644 index c16ab66b8..000000000 --- a/cgyro/bin/cgyro_b2b.py +++ /dev/null @@ -1,26 +0,0 @@ -# file processed by 2to3 -from __future__ import print_function, absolute_import -from builtins import map, filter, range -import os -import sys -import numpy as np - -if len(sys.argv) == 1: - print('python cgyro_b2b.py ') - sys.exit() - -afile = sys.argv[1] -bfile = sys.argv[2] - -if not os.path.isfile(afile): - print("INFO: (cgyro_b2b) "+afile+' not found') - sys.exit() - -arr = np.fromfile(afile,dtype='float64') -brr = arr.astype('float32') - -print("INFO: (cgyro_b2b) Read float64 data in "+afile) - -brr.tofile(bfile) - -print("INFO: (cgyro_t2b) Wrote float32 data to "+bfile) diff --git a/cgyro/bin/cgyro_compress b/cgyro/bin/cgyro_compress deleted file mode 100755 index 16ccb9901..000000000 --- a/cgyro/bin/cgyro_compress +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -#============================================================= -# cgyro_compress -# -# PURPOSE: -# Create "small" version of CGYRO directory. -#============================================================= - -if [ -d $1-s ] -then - echo "WARNING: (cgyro_compress) Removed old directory $1-s." - rm -r $1-s -fi - -SDIR=$1-s -echo "INFO: (cgyro) Compressing $2 -> $2-s" - -# Basic content -mkdir $SDIR -cp -p $1/input.cgyro $SDIR -cp -p $1/input.cgyro.gen $SDIR/input.cgyro.gen.original -cp -p $1/out.cgyro.grids $SDIR -cp -p $1/out.cgyro.equilibrium $SDIR -cp -p $1/out.cgyro.time $SDIR -cp -p $1/out.cgyro.timing $SDIR -cp -p $1/out.cgyro.info $SDIR -cp -p $1/*.cgyro.geo $SDIR - -# Linear data -if ! grep -q NONLINEAR_FLAG=1 $SDIR/input.cgyro -then - cp -p $1/*.cgyro.freq $SDIR - cp -p $1/*.cgyro.phib $SDIR -fi - -# Large files (but no restart) -cp -p $1/bin.cgyro.*flux* $SDIR - -# We will have a version if NOT run through TGYRO -if [ -f $1/out.cgyro.version ] -then - cp -p $1/out.cgyro.version $SDIR -fi diff --git a/cgyro/bin/cgyro_converge b/cgyro/bin/cgyro_converge new file mode 100755 index 000000000..f98b0347b --- /dev/null +++ b/cgyro/bin/cgyro_converge @@ -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() + + + diff --git a/cgyro/bin/cgyro_json b/cgyro/bin/cgyro_json new file mode 100755 index 000000000..1a01be4a6 --- /dev/null +++ b/cgyro/bin/cgyro_json @@ -0,0 +1,125 @@ +#!/usr/bin/env python + +import json +import numpy as np + +from pygacode.cgyro import data + +sim = data.cgyrodata('./') + +try: + with open('out.cgyro.version', 'r') as file: + version = file.read().rstrip() +except: + version = 'unavailable' + + +#-------------------------------------------------------------- +# json.cgyro.localdump + +d = {} + +d['RMIN'] = sim.rmin +d['RMAJ'] = sim.rmaj +d['Q'] = sim.q +d['SHEAR'] = sim.shear +d['MACH'] = sim.mach +d['GAMMA_E'] = sim.gamma_e +d['GAMMA_P'] = sim.gamma_p +d['BETAE_UNIT'] = sim.betae_unit + +d['Z'] = sim.z[:].tolist() +d['MASS'] = sim.mass[:].tolist() +d['DENS'] = sim.dens[:].tolist() +d['TEMP'] = sim.temp[:].tolist() +d['DLNNDR'] = sim.dlnndr[:].tolist() +d['DLNTDR'] = sim.dlntdr[:].tolist() + +d['ZMAG'] = sim.zmag +d['DZMAG'] = sim.dzmag +d['SHIFT'] = sim.shift +d['KAPPA'] = sim.kappa +d['S_KAPPA'] = sim.s_kappa +d['DELTA'] = sim.delta +d['S_DELTA'] = sim.s_delta +d['ZETA'] = sim.zeta +d['S_ZETA'] = sim.s_zeta + +d['SHAPE_SIN'] = sim.shape_sin[:].tolist() + +d['SHAPE_COS'] = sim.shape_cos[:].tolist() + +# JSON output +with open('json.cgyro.localdump','w') as f: + json.dump(d,f,indent=2,sort_keys=True) + +# standard localdump output +nmax = 0 +with open('out.cgyro.localdump','w') as f: + for key in d: + x = d[key] + if 'SHAPE' in key: + for i in range(len(x)): + if not x[i] == 0.0: + f.write(key+'_'+str(i)+'='+str(x[i])+'\n') + if i > nmax: + nmax = i + elif isinstance(x,list): + for i in range(len(x)): + f.write(key+'_'+str(i+1)+'='+str(x[i])+'\n') + else: + f.write(key+'='+str(x)+'\n') + +#-------------------------------------------------------------- +# json.cgyro.imas + +nmax = nmax+1 + +lref=sim.rmaj +vthref = np.sqrt(2.0) +bref = sim.b_gs2 + +d = {} + +d['name'] = 'CGYRO' +d['version'] = version +d['r_minor_norm'] = sim.rmin/lref +d['magnetic_shear_r_minor'] = sim.shear +d['q'] = sim.q +d['charge_norm'] = sim.z[:].tolist() +d['mass_norm'] = sim.mass[:].tolist() +d['density_norm'] = sim.dens[:].tolist() +d['temperature_norm'] = sim.temp[:].tolist() +d['density_log_gradient_norm'] = (lref*sim.dlnndr[:]).tolist() +d['temperature_log_gradient_norm'] = (lref*sim.dlntdr[:]).tolist() + +# Rotation parameters +d['velocity_tor_norm'] = sim.mach/vthref +# -L/v 1/B (r/q Bu) (-dw/dr) = L/v Bu/B (r/q dw/dr) = L/v Bu/B (-GAMMA_E) +d['shearing_rate_norm'] = -(lref/vthref)/bref*sim.gamma_e +# -L^2/v dw/dr = -L/v (L dw/dr) = -L/v (-GAMMA_P) +d['velocity_tor_gradient_norm'] = lref/vthref*sim.gamma_p + +d['beta_reference'] = sim.betae_unit/bref**2 + +d['dgeometric_axis_r_dr_minor'] = sim.shift +d['dgeometric_axis_z_dr_minor'] = sim.dzmag + +d['elongation'] = sim.kappa +d['delongation_dr_minor_norm'] = sim.s_kappa*sim.kappa*lref/sim.rmin + +# Shape coefficients (cn,sn) +d['shapecoefficients_c'] = sim.shape_cos[:nmax].tolist() +d['shapecoefficients_s'] = sim.shape_sin[:nmax].tolist() +d['shapecoefficients_s'][1] = np.arcsin(sim.delta) +d['shapecoefficients_s'][2] = -sim.zeta + +# Derivatives of (cn,sn) +d['dc_dr_minor_norm'] = (sim.shape_s_cos[:nmax]*lref/sim.rmin).tolist() +d['ds_dr_minor_norm'] = (sim.shape_s_sin[:nmax]*lref/sim.rmin).tolist() +d['ds_dr_minor_norm'][1] = sim.s_delta*lref/sim.rmin/np.cos(np.arcsin(sim.delta)) +d['ds_dr_minor_norm'][2] = -sim.s_zeta*lref/sim.rmin + +with open('json.cgyro.imas','w') as f: + json.dump(d,f,indent=2,sort_keys=True) + diff --git a/cgyro/bin/cgyro_mpi_grid.py b/cgyro/bin/cgyro_mpi_grid.py index d9e2f7ded..8c6c86989 100644 --- a/cgyro/bin/cgyro_mpi_grid.py +++ b/cgyro/bin/cgyro_mpi_grid.py @@ -12,12 +12,12 @@ def gcd(m,n): a = b b = c - while True: - c = np.mod(a,b) + while True: + c = np.mod(a,b) if c == 0: break - a = b - b = c + a = b + b = c d = b diff --git a/cgyro/bin/cgyro_parse.py b/cgyro/bin/cgyro_parse.py index dcd597138..221e9016d 100644 --- a/cgyro/bin/cgyro_parse.py +++ b/cgyro/bin/cgyro_parse.py @@ -49,6 +49,9 @@ x.add('COLLISION_FIELD_MODEL','1') x.add('COLLISION_ION_MODEL','0') x.add('COLLISION_PRECISION_MODE','0') +x.add('COLLISION_TEST_MODE','0') +x.add('COLLISION_FIELD_MAX_L','-2') +x.add('COLLISION_TEST_MAX_L','-2') x.add('Z_EFF','1.0') x.add('Z_EFF_METHOD','2') x.add('ZF_TEST_MODE','0') @@ -136,6 +139,7 @@ x.add('DLNTDR','1.0',n=n) x.add('SDLNNDR','0.0',n=n) x.add('SDLNTDR','0.0',n=n) +x.add('SBETA_STAR','0.0',n=n) x.add('DLNNDR_SCALE','1.0',n=n) x.add('DLNTDR_SCALE','1.0',n=n) diff --git a/cgyro/bin/libcgyrorestart.py b/cgyro/bin/libcgyrorestart.py new file mode 100644 index 000000000..98aee42cf --- /dev/null +++ b/cgyro/bin/libcgyrorestart.py @@ -0,0 +1,212 @@ +# restart_resize module + +import sys,os +import struct + +header_size = 1024*16 # 2xDouble precisio +restart_fname="bin.cgyro.restart" + +class CGyroGrid: + def __init__(self): + # nc = n_radial*n_theta + self.n_theta = 0 + self.n_radial = 0 + + # nv = n_energy*n_xi*n_species + self.n_xi = 0 + self.n_energy = 0 + self.n_species = 0 + + # toroidal + self.n_toroidal = 0 + + def __str__(self): + nc_str = "=== nc ===\nn_theta=%i\nn_radial=%i"%(self.n_theta,self.n_radial) + nv_str = "=== nv ===\nn_xi=%i\nn_energy=%i\nn_species=%i"%(self.n_xi,self.n_energy,self.n_species) + tor_str= "=== tor ===\nn_toroidal=%i"%self.n_toroidal + return "%s\n%s\n%s"%(nc_str,nv_str,tor_str) + + def load_from_dict(self,adict): + self.n_theta = int(adict["N_THETA"]) + self.n_radial = int(adict["N_RADIAL"]) + self.n_xi = int(adict["N_XI"]) + self.n_energy = int(adict["N_ENERGY"]) + self.n_species = int(adict["N_SPECIES"]) + self.n_toroidal = int(adict["N_TOROIDAL"]) + + def get_nc(self): + return self.n_radial*self.n_theta + + def get_nv(self): + return self.n_energy*self.n_xi*self.n_species + + def isSame(self,other,exclude_species=False): + isSame=( (self.n_theta==other.n_theta) and + (self.n_xi==other.n_xi) and + (self.n_energy==other.n_energy) ) + if (not exclude_species): + isSsame = isSame and (self.n_species==other.n_species) + isSame= isSame and ( + (self.n_radial==other.n_radial) and + (self.n_toroidal==other.n_toroidal) ) + return isSame + +class CGyroRestartFormat: + def __init__(self): + self.el_size = 16 # 2xDouble precision (complex) + # nv split used in restart formatting + self.nv_loc = 0 + # toroidals_per_proc + self.nt_loc = 0 + # velocity_order + self.velocity_order = 0 + + def __str__(self): + return "nv_loc=%i\nnt_loc=%i\nvelocity_order=%i"%(self.nv_loc,self.nt_loc,self.velocity_order) + + def load_from_dict(self,adict): + # self.nv_loc not in dict, has to be computed + if 'VELOCITY_ORDER' in adict: + # some old versions did not have the option of changing the velocity order + self.velocity_order = int(adict["VELOCITY_ORDER"]) + if 'TOROIDALS_PER_PROC' in adict: + # some old versions did not have the option of changing toroidals_per_proc + self.nt_loc = int(adict["TOROIDALS_PER_PROC"]) + +class CGyroRestartHeader: + def __init__(self): + self.grid = CGyroGrid() + self.fmt = CGyroRestartFormat() + self.info_only_keys = [ "nc_loc", "n_toroidal_procs", "n_proc" , "mpi_rank_order", + "delta_t_method", "nonlinear_flag", "n_jtheta", "nsplit", "nsplitA", "nsplitB", + "nup_theta", "nv", "nc" ] + self.info_only = {} + self.reset_info() + + def __str__(self): + out="%s\n=== formatting ==="%self.grid + out += "\n%s\n=== info ==="%self.fmt + for k in self.info_only_keys: + out += "\n%s=%i"%(k,self.info_only[k]) + return out + + def reset_info(self): + for k in self.info_only_keys: + self.info_only[k] = 0 + + def load(self,fdir, allow_old=False): + fname = os.path.join(fdir,restart_fname) + with open(fname,"rb") as fd: + magic_b = fd.read(4) + [magic] = struct.unpack('i',magic_b) + if (magic==140906808): + self.fmt.velocity_order = 1 + read_velocity_order = False + elif (magic==140916753): + self.fmt.velocity_order = 2 + read_velocity_order = False + elif (magic==140974129): + read_velocity_order = True + else: + raise IOError("Wrong CGyroRestartHeader magic number %i"%magic) + magic1=magic + version_b = fd.read(4) + [version] = struct.unpack('i',version_b) + if (not(( (magic==140974129) and (version==3) ) or + ( (magic!=140974129) and (version==2) ) + ) ): + raise IOError("Unsupported CGyroRestartHeader version %i for magic %i"%(version,magic)) + if ((version!=3) and (not allow_old)): + raise IOError("Not latest CGyroRestartHeader version") + + grid_b = fd.read(6*4) + [self.grid.n_theta,self.grid.n_radial, + self.grid.n_species, + self.grid.n_xi,self.grid.n_energy, + self.grid.n_toroidal] = struct.unpack('6i',grid_b) + + self.reset_info() # will keep to 0 anything I do not know + if (version==3): + # new format + grid_c = fd.read(3*4) + [self.fmt.velocity_order, + self.fmt.nt_loc, self.fmt.nv_loc] = struct.unpack('3i',grid_c) + read_velocity_order = False + opt_b = fd.read(len(self.info_only_keys)*4) + opt_up = struct.unpack('%ii'%len(self.info_only_keys),opt_b) + i=0 + for k in self.info_only_keys: + self.info_only[k] = opt_up[i] + i+=1 + else: + # assume old format + self.fmt.nt_loc = 0 # unknown + self.fmt.nv_loc = 0 # unknown + mpi_b = fd.read(2*4) + [self.info_only["mpi_rank_order"],self.info_only["n_proc"]] = struct.unpack('2i',mpi_b) + + magic_b = fd.read(4) + [magic] = struct.unpack('i',magic_b) + if (magic!=magic1): + raise IOError("Wrong CGyroRestartHeader magic(2) number %i!=%i"%(magic,magic1)) + + def savev3(self,fd): + fd.seek(0) + magic = 140974129 + magic_b= struct.pack('i',magic) + fd.write(magic_b) + version_b= struct.pack('i',3) + fd.write(version_b) + gridarr=[self.grid.n_theta,self.grid.n_radial, + self.grid.n_species, + self.grid.n_xi,self.grid.n_energy, + self.grid.n_toroidal, + self.fmt.velocity_order, + self.fmt.nt_loc, self.fmt.nv_loc] + for g in gridarr: + g_b = struct.pack('i',g) + fd.write(g_b) + for k in self.info_only_keys: + v_b = struct.pack('i',self.info_only[k]) + fd.write(v_b) + fd.write(magic_b) + + def get_thetabytes(self): + return self.fmt.el_size*self.grid.n_theta + + def get_ncbytes(self): + return self.get_thetabytes()*self.grid.n_radial + + def get_total_bytes(self): + return ( header_size + + self.get_ncbytes()*self.grid.get_nv()*self.grid.n_toroidal) + + def get_ic(self, i_t, i_r): + return i_r*self.grid.n_theta+i_t + + def get_iv(self, i_s, i_x, i_e): + iv = 0 + if self.fmt.velocity_order==1: + iv = (i_e*self.grid.n_xi+i_x)*self.grid.n_species+ i_s; + else: + iv = (i_s*self.grid.n_energy+i_e)*self.grid.n_xi+ i_x; + return iv + + # offset to start of nc block + # not including the header + def nc_offset(self, i_s, i_x, i_e, i_t): + nv = self.grid.get_nv() + nv_loc = self.fmt.nv_loc + nt_loc = self.fmt.nt_loc + iv = self.get_iv(i_s,i_x,i_e) + off_block = (iv%nv_loc) + (i_t%nt_loc)*nv_loc + off_row = (iv//nv_loc)*(nv_loc*nt_loc) + off_col = (i_t//nt_loc)*(nv*nt_loc) + offset = self.get_ncbytes()*(off_block+off_row+off_col) + return offset + + # offset to start of nc block + # not including the header + def theta_offset(self, i_r, i_s, i_x, i_e, i_t): + return self.nc_offset(i_s,i_x,i_e,i_t)+i_r*self.get_thetabytes() + diff --git a/cgyro/bin/restart_add_dims.py b/cgyro/bin/restart_add_dims.py new file mode 100755 index 000000000..6ab4ce93e --- /dev/null +++ b/cgyro/bin/restart_add_dims.py @@ -0,0 +1,309 @@ +#!/usr/bin/env python3 +# +# This tool evolves the cgyro restart file +# Given an original (input.gen,restart) pair +# and a new input.gen,it generates a new restart file +# that keeps the old info +# +# Currently limited to adding radial and toroidal dimensions +# + +import sys,os +import argparse +import libcgyrorestart +import array + +class CgyroInput: + """Input parser for input.cgyro.gen file""" + def __init__(self): + self.user_dict = {} + self.def_fname = "input.cgyro.gen" + + def readInput(self,fdir): + inputfile=os.path.join(fdir,self.def_fname) + with open(inputfile,'r') as fin: + in_lines = fin.readlines() + for line in in_lines: + # Remove leading and trailing whitespace from line + line = line.strip() + + # Skip blank lines + if len(line) > 0 and line[0] != '#': + (val,arg) = line.split() + self.user_dict[arg] = val + + def isSameGrid(self, other): + cmpArgs=["N_ENERGY","N_XI","N_THETA","N_SPECIES"] + isSame=True + for arg in cmpArgs: isSame = isSame and (self.user_dict[arg]==other.user_dict[arg]) + return isSame + + def isSameDims(self, other): + cmpArgs=["N_RADIAL","N_TOROIDAL"] + isSame=True + for arg in cmpArgs: isSame = isSame and (self.user_dict[arg]==other.user_dict[arg]) + return isSame + + # if true, also return pre, post and new species + def isDimsSuperset(self, other): + my_n_radial = int(self.user_dict["N_RADIAL"]) + my_n_toroidal = int(self.user_dict["N_TOROIDAL"]) + other_n_radial = int(other.user_dict["N_RADIAL"]) + other_n_toroidal = int(other.user_dict["N_TOROIDAL"]) + if (my_n_radial0): + print("INFO: Shifting radial by %i"%dim_offset) + + +try: + if (scale_val==1.0): + print("INFO: Using elements from border as fill") + add_dims_1(old_dir, new_dir, old_grid_obj, new_grid_obj, dim_offset) + elif (scale_val==0.0): + print("INFO: Filling with zeros") + add_dims_0(old_dir, new_dir, old_grid_obj, new_grid_obj, dim_offset) + else: + print("INFO: Scaling additional elements from border by %f"%scale_val) + print("INFO: Using slow scaling variant") + add_dims_scale(old_dir, new_dir, old_grid_obj, new_grid_obj, dim_offset, scale_val) +except IOError as err: + print("IO error: {0}".format(err)) + sys.exit(21) diff --git a/cgyro/bin/restart_add_species.py b/cgyro/bin/restart_add_species.py index 7e985767e..90771aee9 100755 --- a/cgyro/bin/restart_add_species.py +++ b/cgyro/bin/restart_add_species.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This tool evolves the cgyro restart file # Given an original (input.gen,restart) pair @@ -10,7 +10,7 @@ import sys,os import argparse -import restart_resize +import libcgyrorestart class CgyroInput: """Input parser for input.cgyro.gen file""" @@ -32,7 +32,7 @@ def readInput(self,fdir): self.user_dict[arg] = val def isSameGrid(self, other): - cmpArgs=["N_ENERGY","N_XI","N_THETA","N_RADIAL","N_TOROIDAL","VELOCITY_ORDER"] + cmpArgs=["N_ENERGY","N_XI","N_THETA","N_RADIAL","N_TOROIDAL"] isSame=True for arg in cmpArgs: isSame = isSame and (self.user_dict[arg]==other.user_dict[arg]) return isSame @@ -131,6 +131,80 @@ def get_arguments(): return args.o,args.n +def add_species(org_dir, new_dir, org_grid, new_grid, org_pre_species, org_post_species, new_species): + org_fname = os.path.join(org_dir,libcgyrorestart.restart_fname) + new_fname = os.path.join(new_dir,libcgyrorestart.restart_fname) + + header_size = libcgyrorestart.header_size + + org_header = libcgyrorestart.CGyroRestartHeader() + org_header.load(org_dir) + if (not org_grid.isSame(org_header.grid)): + raise IOError("Wrong CGyroRestartHeader grid content") + if (not new_grid.isSame(org_header.grid, exclude_species=True)): + raise IOError("Incompatible CGyroRestartHeader grid content") + if (org_header.grid.n_species!=(org_pre_species+org_post_species)): + raise IOError("Incompatible CGyroRestartHeader number of species") + ncbytes = org_header.get_ncbytes() + org_fsize = org_header.get_total_bytes() + if os.stat(org_fname).st_size!=org_fsize: + raise IOError("Wrong restart file size") + + zerobuf = bytearray(ncbytes) + for i in range(ncbytes): + zerobuf[i] = 0 # 0.0 is also a binary 0 + + new_header = libcgyrorestart.CGyroRestartHeader() + new_header.load(org_dir) # keep the same format as the old one + # add the species + new_header.grid.n_species += new_species + # nv_loc must scale with nv + # But not all values are valid (simple scaling may result in fractional number) + # just set it to nv, which is always a valid value + new_header.fmt.nv_loc = new_header.grid.get_nv() + # at this point, may as well set velocity order to 1, which is less restrictive + new_header.fmt.velocity_order = 1 + # and keep nt_loc=1 to be on the safe side, too + new_header.fmt.nt_loc = 1 + # invlidate optional info, to maintain consistency + new_header.reset_info() + new_fsize = new_header.get_total_bytes() + with open(org_fname,"rb") as org_fd: + with open(new_fname,"wb") as new_fd: + new_fd.truncate(new_fsize) + new_header.savev3(new_fd) + + for i_t in range(org_grid.n_toroidal): + for i_e in range(org_grid.n_energy): + for i_x in range(org_grid.n_xi): + # copy the initial species + for i_s in range(org_pre_species): + org_off = org_header.nc_offset(i_s, i_x, i_e, i_t) + new_off = new_header.nc_offset(i_s, i_x, i_e, i_t) + org_fd.seek(header_size+org_off) + new_fd.seek(header_size+new_off) + tmp=org_fd.read(ncbytes) + new_fd.write(tmp) + + # fill additional species with 0 + for i in range(org_post_species): + i_s = org_pre_species+new_species + i + new_off = new_header.nc_offset(i_s, i_x, i_e, i_t) + new_fd.seek(header_size+new_off) + new_fd.write(zerobuf) + + # copy the final species + for i in range(org_post_species): + i_s = org_pre_species+new_species + i + org_off = org_header.nc_offset(i_s, i_x, i_e, i_t) + new_off = new_header.nc_offset(i_s, i_x, i_e, i_t) + org_fd.seek(header_size+org_off) + new_fd.seek(header_size+new_off) + tmp=org_fd.read(ncbytes) + new_fd.write(tmp) + + return + old_dir,new_dir=get_arguments() try: @@ -150,9 +224,6 @@ def get_arguments(): print("ERROR: Grids not the same") sys.exit(11) -grid_obj = restart_resize.CGyroGrid() -grid_obj.load_from_dict(new_cfg.user_dict) - if (new_cfg.isSameSpecies(old_cfg)): print("INFO: No changes detected. No restart file generated") sys.exit(1) @@ -167,9 +238,16 @@ def get_arguments(): print("INFO: Adding %i species"%diff_species["new_species"]) if diff_species["org_post"]>0: print("INFO: Keeping last %i species"%diff_species["org_post"]) + + +old_grid_obj = libcgyrorestart.CGyroGrid() +new_grid_obj = libcgyrorestart.CGyroGrid() +old_grid_obj.load_from_dict(old_cfg.user_dict) +new_grid_obj.load_from_dict(new_cfg.user_dict) + try: - restart_resize.add_species(old_dir, new_dir, grid_obj, - diff_species["org_pre"],diff_species["org_post"],diff_species["new_species"]) + add_species(old_dir, new_dir, old_grid_obj, new_grid_obj, + diff_species["org_pre"],diff_species["org_post"],diff_species["new_species"]) except IOError as err: print("IO error: {0}".format(err)) sys.exit(21) diff --git a/cgyro/bin/restart_info.py b/cgyro/bin/restart_info.py new file mode 100755 index 000000000..0fdaa3b21 --- /dev/null +++ b/cgyro/bin/restart_info.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# +# This tool evolves the cgyro restart file +# Given an original (input.gen,restart) pair +# and a new input.gen,it generates a new restart file +# that keeps the old info +# +# Currently limited to adding an additional species +# + +import sys,os +import argparse +import libcgyrorestart + +def get_arguments(): + + parser=argparse.ArgumentParser(description="Utility get info of a CGYRO restart file") + + parser.add_argument('-d', + metavar='ORIG', + help="Directory containing bin.cgyro.restart", + type=str, + required=True) + + args=parser.parse_args() + + return args.d + + +d=get_arguments() +head=libcgyrorestart.CGyroRestartHeader() +head.load(d, allow_old=True) +print(head) diff --git a/cgyro/bin/restart_resize.py b/cgyro/bin/restart_resize.py deleted file mode 100644 index ffb8f49b0..000000000 --- a/cgyro/bin/restart_resize.py +++ /dev/null @@ -1,262 +0,0 @@ -# restart_resize module - -import sys,os -import struct - -header_size = 1024*16 # 2xDouble precisio -restart_v1_fname="out.cgyro.restart" -restart_fname="bin.cgyro.restart" - -class CGyroGrid: - def __init__(self): - # nc - self.n_theta = 0 - self.n_radial = 0 - - # nv - self.n_xi = 0 - self.n_energy = 0 - - # toroidal - self.n_toroidal = 0 - - # velocity_order - self.velocity_order = 1 - - def load_from_dict(self,adict): - self.n_theta = int(adict["N_THETA"]) - self.n_radial = int(adict["N_RADIAL"]) - self.n_xi = int(adict["N_XI"]) - self.n_energy = int(adict["N_ENERGY"]) - self.n_toroidal = int(adict["N_TOROIDAL"]) - if 'VELOCITY_ORDER' in adict: - # some old versions did not have the option of changing the velocity order - self.velocity_order = int(adict["VELOCITY_ORDER"]) - - def get_nc(self): - return self.n_radial*self.n_theta - - def get_nvg(self): - return self.n_energy*self.n_xi - - def isSame(self,other): - return ( (self.n_theta==other.n_theta) and - (self.n_radial==other.n_radial) and - (self.n_xi==other.n_xi) and - (self.n_energy==other.n_energy) and - (self.n_toroidal==other.n_toroidal) and - (self.velocity_order==other.velocity_order)) - -class CGyroRestartHeader: - def __init__(self): - self.grid = CGyroGrid() - self.n_species = 0 - self.mpi_rank_order = 0 - self.n_proc = 0 - - def load(self,fdir): - fname = os.path.join(fdir,restart_fname) - with open(fname,"rb") as fd: - magic_b = fd.read(4) - [magic] = struct.unpack('i',magic_b) - if (magic==140906808): - self.grid.velocity_order = 1 - elif (magic==140916753): - self.grid.velocity_order = 2 - else: - raise IOError("Wrong CGyroRestartHeader magic number %i"%magic) - magic1=magic - version_b = fd.read(4) - [version] = struct.unpack('i',version_b) - if (version!=2): - raise IOError("Unsupported CGyroRestartHeader version %i"%version) - - grid_b = fd.read(6*4) - [self.grid.n_theta,self.grid.n_radial, - self.n_species, - self.grid.n_xi,self.grid.n_energy, - self.grid.n_toroidal] = struct.unpack('6i',grid_b) - - mpi_b = fd.read(2*4) - [self.mpi_rank_order,self.n_proc] = struct.unpack('2i',mpi_b) - - magic_b = fd.read(4) - [magic] = struct.unpack('i',magic_b) - if (magic!=magic1): - raise IOError("Wrong CGyroRestartHeader magic(2) number %i!=%i"%(magic,magic1)) - - def savev2(self,fdir): - fname = os.path.join(fdir,restart_fname) - with open(fname,"rb+") as fd: - magic = 140906808 if (self.grid.velocity_order == 1) else 140916753 - magic_b= struct.pack('i',magic) - fd.write(magic_b) - version_b= struct.pack('i',2) - fd.write(version_b) - gridarr=[self.grid.n_theta,self.grid.n_radial, - self.n_species, - self.grid.n_xi,self.grid.n_energy, - self.grid.n_toroidal, - self.mpi_rank_order,self.n_proc] - for g in gridarr: - g_b = struct.pack('i',g) - fd.write(g_b) - fd.write(magic_b) - -# mpi_rank_order == 1 -def upgrade_v1v2_ro1(org_dir, new_dir, grid, n_species, n_proc): - org_fname = os.path.join(org_dir,restart_v1_fname) - new_fname = os.path.join(new_dir,restart_fname) - - # Data structure (in fortran terms) - # doublex2 h_x[nc,nv,n_toroidal] - - el_size = 16 # 2xDouble precision - nc = grid.get_nc() - ncbytes = nc*el_size - nv = grid.get_nvg()*n_species - - zerobuf = bytearray(header_size) - for i in range(header_size): - zerobuf[i] = 0 - - with open(org_fname,"rb") as org_fd: - with open(new_fname,"wb") as new_fd: - new_fd.write(zerobuf) # dummy header - - for t in range(grid.n_toroidal*nv): # do loop to save tmp memory - tmp=org_fd.read(ncbytes) - new_fd.write(tmp) - - # update the header - new_header = CGyroRestartHeader() - new_header.grid = grid - new_header.n_species = n_species - new_header.mpi_rank_order = 1 - new_header.n_proc = n_proc - new_header.savev2(new_dir) - -# mpi_rank_order == 2 -def upgrade_v1v2_ro2(org_dir, new_dir, grid, n_species, n_proc): - org_fname = os.path.join(org_dir,restart_v1_fname) - new_fname = os.path.join(new_dir,restart_fname) - - # Data structure (in fortran terms) - # input: - # double*2 h_x[nc,nv_loc,n_proc_2,n_proc_1] - # output: - # double*2 h_x[nc,nv,n_toroidal] - - el_size = 16 # 2xDouble precision - nc = grid.get_nc() - ncbytes = nc*el_size - nv = grid.get_nvg()*n_species - - n_proc_1 = n_proc/grid.n_toroidal - n_proc_2 = grid.n_toroidal - - nv_loc = nv / n_proc_1 - - zerobuf = bytearray(header_size) - for i in range(header_size): - zerobuf[i] = 0 - - with open(org_fname,"rb") as org_fd: - with open(new_fname,"wb") as new_fd: - new_fd.write(zerobuf) # dummy header - - for t in range(n_proc_2): - for n in range(n_proc_1): - # org file out of order, out file in order - org_fd.seek(ncbytes*nv_loc*(n*n_proc_2+t)) - - for v in range(nv_loc): # do loop to save tmp memory - tmp=org_fd.read(ncbytes) - new_fd.write(tmp) - - - # update the header - new_header = CGyroRestartHeader() - new_header.grid = grid - new_header.n_species = n_species - new_header.mpi_rank_order = 2 - new_header.n_proc = n_proc - new_header.savev2(new_dir) - -def add_species(org_dir, new_dir, grid, org_pre_species, org_post_species, new_species): - org_fname = os.path.join(org_dir,restart_fname) - new_fname = os.path.join(new_dir,restart_fname) - - tag_fname="out.cgyro.tag" - new_tag_fname = os.path.join(new_dir,tag_fname) - - - # Data structure (in fortran terms) - # if velocity_order==1 - # doublex2 h_x[nc,n_species,nvg,n_toroidal] - # else - # doublex2 h_x[nc,nvg,n_species,n_toroidal] - - el_size = 16 # 2xDouble precision - nc = grid.get_nc() - ncbytes = nc*el_size - - nvg = grid.get_nvg() - - zerobuf = bytearray(ncbytes*new_species) - for i in range(ncbytes*new_species): - zerobuf[i] = 0 # 0.0 is also a binary 0 - - org_header = CGyroRestartHeader() - org_header.load(org_dir) - # TODO: verify consistency - if (not grid.isSame(org_header.grid)): - raise IOError("Wrong CGyroRestartHeader grid content") - if (org_header.n_species!=(org_pre_species+org_post_species)): - raise IOError("Wrong CGyroRestartHeader number of species") - - with open(org_fname,"rb") as org_fd: - with open(new_fname,"wb") as new_fd: - tmp=org_fd.read(header_size) - new_fd.write(tmp) - - for t in range(grid.n_toroidal): - if org_header.grid.velocity_order==1: - if (org_pre_species>0): - tmp=org_fd.read(ncbytes*org_pre_species) - new_fd.write(tmp) - - new_fd.write(zerobuf) - for n in range(nvg-1): - # write the pre and post together - tmp=org_fd.read(ncbytes*(org_pre_species+org_post_species)) - new_fd.write(tmp) - - new_fd.write(zerobuf) - - if (org_post_species>0): - tmp=org_fd.read(ncbytes*org_post_species) - new_fd.write(tmp) - else: # velocity_order==2 - if (org_pre_species>0): - # keep memory footprint small - for n in range(nvg): - tmp=org_fd.read(ncbytes*org_pre_species) - new_fd.write(tmp) - - # keep memory footprint small - for n in range(nvg): - new_fd.write(zerobuf) - - if (org_post_species>0): - # keep memory footprint small - for n in range(nvg): - tmp=org_fd.read(ncbytes*org_post_species) - new_fd.write(tmp) - - - new_header = org_header - new_header.n_species = org_header.n_species + new_species - new_header.savev2(new_dir) - - return diff --git a/cgyro/bin/restart_upgrade.py b/cgyro/bin/restart_upgrade.py deleted file mode 100755 index 5ebabec09..000000000 --- a/cgyro/bin/restart_upgrade.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python -# -# This tool upgrades the cgyro restart file version -# Given an original (input.gen,restart) pair -# and the n_proc used to generate it -# it generates a new restart file that keeps the old info -# -# Currently limited to v1 -> v2 upgrade -# - -import sys,os -import restart_resize - -class CgyroInput: - """Input parser for input.cgyro.gen file""" - def __init__(self): - self.user_dict = {} - self.def_fname = "input.cgyro.gen" - - def readInput(self,fdir): - inputfile=os.path.join(fdir,self.def_fname) - with open(inputfile,'r') as fin: - in_lines = fin.readlines() - for line in in_lines: - # Remove leading and trailing whitespace from line - line = line.strip() - - # Skip blank lines - if len(line) > 0 and line[0] != '#': - (val,arg) = line.split() - self.user_dict[arg] = val - - def getNSpecies(self): - return int(self.user_dict["N_SPECIES"]) - - def getMpiRankOrder(self): - return int(self.user_dict["MPI_RANK_ORDER"]) - -old_dir="." -new_dir="t1/" - -if len(sys.argv)!=4: - print("ERROR: Wrong argument count") - print("Usage:") - print(" restart_upgrade.py org_dir new_dir n_proc") - sys.exit(10) - -old_dir=sys.argv[1] -new_dir=sys.argv[2] -n_proc =int(sys.argv[3]) - -try: - old_cfg = CgyroInput() - old_cfg.readInput(old_dir) -except IOError as err: - print("IO error: {0}".format(err)) - sys.exit(21) -except: - print("Unexpected error:", sys.exc_info()[0]) - sys.exit(22) - -grid_obj=restart_resize.CGyroGrid() -grid_obj.load_from_dict(old_cfg.user_dict) - -n_species=old_cfg.getNSpecies() -mpi_rank_order=old_cfg.getMpiRankOrder() - -if mpi_rank_order==1: - try: - restart_resize.upgrade_v1v2_ro1(old_dir, new_dir, grid_obj, n_species, n_proc) - except IOError as err: - print("IO error: {0}".format(err)) - sys.exit(21) - except: - print("Unexpected error:", sys.exc_info()[0]) - sys.exit(22) -elif mpi_rank_order==2: - try: - restart_resize.upgrade_v1v2_ro2(old_dir, new_dir, grid_obj, n_species, n_proc) - except IOError as err: - print("IO error: {0}".format(err)) - sys.exit(21) - except: - print("Unexpected error:", sys.exc_info()[0]) - sys.exit(22) -else: - print("ERROR: MPI_RANK_ORDER %i not supported"%mpi_rank_order) - sys.exit(21) - diff --git a/cgyro/install/make.ext.LUMI b/cgyro/install/make.ext.LUMI new file mode 100644 index 000000000..f0747935a --- /dev/null +++ b/cgyro/install/make.ext.LUMI @@ -0,0 +1,2 @@ +cgyro_nl_fftw.o : cgyro_nl_fftw.gpu.F90 + $(FC) $(FMATH) $(FFLAGS) -o cgyro_nl_fftw.o -c cgyro_nl_fftw.gpu.F90 diff --git a/cgyro/src/Makefile b/cgyro/src/Makefile index f446a6025..ad5293929 100644 --- a/cgyro/src/Makefile +++ b/cgyro/src/Makefile @@ -15,9 +15,9 @@ FC += ${FOMP} ${FACC} EXEC = cgyro OBJECTS = cgyro_globals.o \ - cgyro_timer_lib.o \ cgyro_math.o \ cgyro_globals_math.o \ + cgyro_timer_lib.o \ cgyro_parallel_lib.o \ cgyro_step.o \ cgyro_io.o \ @@ -32,12 +32,13 @@ OBJECTS = cgyro_globals.o \ cgyro_field_coefficients.o \ cgyro_flux.o \ cgyro_freq.o \ - cgyro_global.o \ + cgyro_globalshear.o \ cgyro_upwind.o \ cgyro_init.o \ cgyro_init_h.o \ cgyro_init_arrays.o \ cgyro_init_collision_simple.o \ + cgyro_init_collision_landau.o \ cgyro_init_collision.o \ cgyro_init_manager.o \ cgyro_init_kernel.o \ @@ -61,7 +62,9 @@ OBJECTS = cgyro_globals.o \ cgyro_write_initdata.o \ cgyro_write_timedata.o \ cgyro_write_hosts.o \ - cgyro_zftest_em.o + cgyro_zftest_em.o \ + ${GACODE_ROOT}/shared/landau/landau.o \ + ${GACODE_ROOT}/shared/landau/gyrotransformation.o .SUFFIXES : .o .f90 .F90 diff --git a/cgyro/src/cgyro_advect_wavenumber.F90 b/cgyro/src/cgyro_advect_wavenumber.F90 index ed6c09a8a..2f4aaca76 100644 --- a/cgyro/src/cgyro_advect_wavenumber.F90 +++ b/cgyro/src/cgyro_advect_wavenumber.F90 @@ -2,7 +2,7 @@ ! cgyro_advect_wavenumber.f90 ! ! PURPOSE: -! Manage shearing by wavenumber advection. +! Manage shearing by wavenumber advection (legacy method) !--------------------------------------------------------- subroutine cgyro_advect_wavenumber(ij) @@ -14,7 +14,7 @@ subroutine cgyro_advect_wavenumber(ij) integer, intent(in) :: ij integer :: ir,l,ll,j,iccj,ivc,itor,llnt - complex :: rl,he1,he2 + complex :: rh,rl,he1,he2 if (nonlinear_flag == 0) return @@ -23,19 +23,21 @@ subroutine cgyro_advect_wavenumber(ij) #if defined(OMPGPU) !$omp target teams distribute parallel do simd collapse(4) & -!$omp& private(ivc,ir,l,iccj,j,ll,rl,llnt,he1,he2) +!$omp& private(ivc,ir,l,iccj,j,ll,rl,rh,llnt,he1,he2) #elif defined(_OPENACC) !$acc parallel loop collapse(4) gang vector & -!$acc& private(ivc,ir,l,iccj,j,ll,rl,llnt,he1,he2) & +!$acc& private(ivc,ir,l,iccj,j,ll,rl,rh,llnt,he1,he2) & !$acc& present(rhs(:,:,:,ij),omega_ss,field,h_x,c_wave) #else -!$omp parallel do collapse(4) private(ivc,ir,l,iccj,j,ll,rl,llnt,he1,he2) +!$omp parallel do collapse(3) private(ivc,ir,l,iccj,j,ll,rl,rh,llnt,he1,he2) & +!$omp& firstprivate(shear_method,profile_shear_flag) #endif do itor=nt1,nt2 do ivc=1,nv_loc do ir=1,n_radial do j=1,n_theta iccj = (ir-1)*n_theta+j + rh = rhs(iccj,ivc,itor,ij) ! Wavenumber advection ExB shear if (shear_method == 2) then @@ -62,13 +64,12 @@ subroutine cgyro_advect_wavenumber(ij) ! Thus sign below has been checked and is correct rl = rl+c_wave(l)*(he1-he2) enddo - rhs(iccj,ivc,itor,ij) = rhs(iccj,ivc,itor,ij) + omega_eb_base*itor*rl + rh = rh + omega_eb_base*itor*rl endif ! Wavenumber advection profile shear if (profile_shear_flag == 1) then iccj = (ir-1)*n_theta+j - rl = rhs(iccj,ivc,itor,ij) #if (!defined(OMPGPU)) && defined(_OPENACC) !$acc loop seq #endif @@ -88,10 +89,10 @@ subroutine cgyro_advect_wavenumber(ij) he2 = 0.0 endif ! Note opposite sign to ExB shear - rl = rl-c_wave(l)*(he1-he2) + rh = rh-c_wave(l)*(he1-he2) enddo - rhs(iccj,ivc,itor,ij) = rl endif + rhs(iccj,ivc,itor,ij) = rh enddo enddo enddo diff --git a/cgyro/src/cgyro_check.f90 b/cgyro/src/cgyro_check.f90 index dde7fad18..c2dbb04fe 100644 --- a/cgyro/src/cgyro_check.f90 +++ b/cgyro/src/cgyro_check.f90 @@ -7,6 +7,7 @@ subroutine cgyro_check integer :: is character(len=1), dimension(7) :: ctag + character(1000) :: outstr character(len=7) :: floatstr !----------------------------------------------------------------------- @@ -233,17 +234,32 @@ subroutine cgyro_check call cgyro_info('Collision model: Lorentz ee+ei') case (2) call cgyro_info('Collision model: Connor') - case (4,6) + case (4) call cgyro_info('Collision model: Sugama') ctag(2) = 'x' case(5) call cgyro_info('Collision model: Simple Lorentz ee+ei') + case(6) + call cgyro_info('Collision model: Landau') + case(7) + call cgyro_info('Collision model: New (Galerkin) Sugama') case default call cgyro_error('Invalid value for collision_model') return end select + if (collision_model == 6 .or. collision_model == 7) then + ! if any is below -1 the l-numbers are unlimited. + if (collision_field_max_l>=-1) then + write(outstr,*) collision_field_max_l + call cgyro_info('Field particle collisions limited to l<='//trim(outstr)//' collisions') + endif + if (collision_test_max_l>=-1) then + write(outstr,*) collision_test_max_l + call cgyro_info('Test particle collisions limited to l<='//trim(outstr)//' collisions') + endif + end if if (collision_model /= 5) then if(collision_model /= 1) then @@ -321,6 +337,8 @@ subroutine cgyro_check end select endif + if (collision_model > 5) ctag = 'x' + call cgyro_info('Collision terms: L D Rm Re kp ions field') call cgyro_info(' '// & ' '//ctag(1)// & @@ -330,7 +348,7 @@ subroutine cgyro_check ' '//ctag(5)// & ' '//ctag(6)// & ' '//ctag(7)) - + if (collision_model == 5 .or. collision_model == 1) then select case(z_eff_method) case(1) @@ -350,6 +368,13 @@ subroutine cgyro_check return endif + + if (collision_test_mode>0) then + write(unit=outstr,fmt='(A,I1)') 'Warning, 0= 1 ) then - he2 = h_x(iccj-llnt,ivc,itor) - else - he2 = 0.0 - endif - ! Sign throughout paper is incorrect (or gamma -> - gamma) - ! Thus sign below has been checked and is correct - rl = rl+c_wave(l)*(he1-he2) - enddo - rhs(iccj,ivc,itor,ij) = rhs(iccj,ivc,itor,ij) + omega_eb_base*itor*rl - endif - - ! Wavenumber advection profile shear - if (profile_shear_flag == 1) then - iccj = (ir-1)*n_theta+j - rl = rhs(iccj,ivc,itor,ij) -#if (!defined(OMPGPU)) && defined(_OPENACC) -!$acc loop seq -#endif - do l=1,n_wave - ll = 2*l-1 - llnt = ll*n_theta - ! was he(j,ir+ll) - if ( (ir+ll) <= n_radial ) then - he1 = sum(omega_ss(:,iccj+llnt,ivc,itor)*field(:,iccj+llnt,itor)) - else - he1 = 0.0 - endif - ! was he(j,ir-ll) - if ( (ir-ll) >= 1 ) then - he2 = sum(omega_ss(:,iccj-llnt,ivc,itor)*field(:,iccj-llnt,itor)) - else - he2 = 0.0 - endif - ! Note opposite sign to ExB shear - rl = rl-c_wave(l)*(he1-he2) - enddo - rhs(iccj,ivc,itor,ij) = rl - endif - enddo - enddo - enddo - enddo - - call timer_lib_out('shear') - - endif - -end subroutine cgyro_global diff --git a/cgyro/src/cgyro_globals.F90 b/cgyro/src/cgyro_globals.F90 index 1c6efec0c..67087a032 100644 --- a/cgyro/src/cgyro_globals.F90 +++ b/cgyro/src/cgyro_globals.F90 @@ -62,6 +62,9 @@ module cgyro_globals integer :: collision_field_model integer :: collision_ion_model integer :: collision_precision_mode + integer :: collision_test_mode + integer :: collision_field_max_l + integer :: collision_test_max_l real :: z_eff integer :: z_eff_method integer :: zf_test_mode @@ -135,6 +138,7 @@ module cgyro_globals real, dimension(11) :: dlntdr real, dimension(11) :: sdlnndr real, dimension(11) :: sdlntdr + real, dimension(11) :: sbeta_star integer :: subroutine_flag ! only used for cgyro_read_input @@ -348,6 +352,7 @@ module cgyro_globals complex, dimension(:,:,:), allocatable :: omega_cap_h complex, dimension(:,:,:), allocatable :: omega_h complex, dimension(:,:,:,:), allocatable :: omega_s,omega_ss + complex, dimension(:,:,:), allocatable :: omega_sbeta complex, dimension(:,:,:), allocatable :: cap_h_c complex, dimension(:,:,:), allocatable :: cap_h_c_dot complex, dimension(:,:,:), allocatable :: cap_h_c_old diff --git a/cgyro/src/cgyro_globalshear.F90 b/cgyro/src/cgyro_globalshear.F90 new file mode 100644 index 000000000..9b4c34874 --- /dev/null +++ b/cgyro/src/cgyro_globalshear.F90 @@ -0,0 +1,84 @@ +!----------------------------------------------------------------- +! cgyro_globalshear.F90 +! +! PURPOSE: +! Manage shearing by wavenumber advection (new Dudkovskaia terms) +!----------------------------------------------------------------- + +subroutine cgyro_globalshear(ij) + + use cgyro_globals + use timer_lib + + implicit none + + integer, intent(in) :: ij + integer :: ir,l,ll,j,iccj,ivc,itor,llnt + complex :: rl,h1,h2 + + if (nonlinear_flag == 0) return + + call timer_lib_in('shear') + +#if defined(OMPGPU) +!$omp target teams distribute parallel do simd collapse(4) & +!$omp& private(ivc,ir,l,iccj,j,ll,rl,llnt,h1,h2) +#elif defined(_OPENACC) +!$acc parallel loop collapse(4) gang vector & +!$acc& private(ivc,ir,l,iccj,j,ll,rl,llnt,h1,h2) & +!$acc& present(rhs(:,:,:,ij),omega_ss,omega_sbeta,field,h_x,cap_h_c,c_wave) +#else +!$omp parallel do collapse(4) private(ivc,ir,l,iccj,j,ll,rl,llnt,h1,h2) +#endif + do itor=nt1,nt2 + do ivc=1,nv_loc + do ir=1,n_radial + do j=1,n_theta + + iccj = (ir-1)*n_theta+j + rl = rhs(iccj,ivc,itor,ij) + +#if (!defined(OMPGPU)) && defined(_OPENACC) +!$acc loop seq +#endif + do l=1,n_wave + + ll = (2*l-1) + llnt = ll*n_theta + + if ( (ir+ll) <= n_radial ) then + ! ExB shear + h1 = omega_eb_base*itor*h_x(iccj+llnt,ivc,itor) + ! omega_star shear + h1 = h1-sum(omega_ss(:,iccj+llnt,ivc,itor)*field(:,iccj+llnt,itor)) + ! beta_star shear + h1 = h1-omega_sbeta(iccj+llnt,ivc,itor)*cap_h_c(iccj+llnt,ivc,itor) + else + h1 = 0.0 + endif + + if ( (ir-ll) >= 1 ) then + ! ExB shear + h2 = omega_eb_base*itor*h_x(iccj-llnt,ivc,itor) + ! omega_star shear + h2 = h2-sum(omega_ss(:,iccj-llnt,ivc,itor)*field(:,iccj-llnt,itor)) + ! beta_star shear + h2 = h2-omega_sbeta(iccj-llnt,ivc,itor)*cap_h_c(iccj-llnt,ivc,itor) + else + h2 = 0.0 + endif + + rl = rl+c_wave(l)*(h1-h2) + + enddo + + rhs(iccj,ivc,itor,ij) = rl + + enddo + enddo + enddo + enddo + + call timer_lib_out('shear') + +end subroutine cgyro_globalshear diff --git a/cgyro/src/cgyro_init_arrays.F90 b/cgyro/src/cgyro_init_arrays.F90 index a6884486c..9a3901fe7 100644 --- a/cgyro/src/cgyro_init_arrays.F90 +++ b/cgyro/src/cgyro_init_arrays.F90 @@ -8,7 +8,7 @@ subroutine cgyro_init_arrays real :: arg real :: efac - real :: u + real :: u,sm,sb real :: fac integer :: ir,it,is,ie,ix integer :: itm,itl,itor,mytor,itf @@ -25,6 +25,14 @@ subroutine cgyro_init_arrays real, dimension(:,:), allocatable :: res_weight real, external :: spectraldiss + real, dimension(:), allocatable :: gdlnndr,gdlntdr + + allocate(gdlnndr(n_species)) + allocate(gdlntdr(n_species)) + + gdlntdr = 0 + gdlnndr = 0 + !------------------------------------------------------------------------- ! Distributed Bessel-function Gyroaverages @@ -111,9 +119,7 @@ subroutine cgyro_init_arrays !$acc enter data copyin(jvec_c) #endif - do i_field=1,n_field - call parallel_lib_rtrans_real(jvec_c(i_field,:,:,:),jvec_v(i_field,:,:,:)) - enddo + call parallel_lib_rtrans_real(jvec_c,jvec_v) if (nonlinear_flag == 1) then ! @@ -182,7 +188,7 @@ subroutine cgyro_init_arrays enddo enddo endif - + res_loc(:,:,:) = 0.0 !$omp parallel private(ic,iv_loc,is,ix,ie) @@ -390,80 +396,91 @@ subroutine cgyro_init_arrays ! Streaming coefficients (for speed optimization) !$omp parallel do collapse(3) & -!$omp& private(iv,ic,iv_loc,is,ix,ie,ir,it,carg,u) +!$omp& private(iv,ic,iv_loc,is,ix,ie,ir,it,arg,carg,u,sm,sb) do itor=nt1,nt2 - do iv=nv1,nv2 - do ic=1,nc - - iv_loc = iv-nv1+1 - is = is_v(iv) - ix = ix_v(iv) - ie = ie_v(iv) - ir = ir_c(ic) - it = it_c(ic) - - u = (pi/n_toroidal)*itor - - ! omega_dalpha - omega_cap_h(ic,iv_loc,itor) = & - -omega_adrift(it,is)*energy(ie)*(1.0+xi(ix)**2)*& - (n_toroidal*q/pi/rmin)*(i_c*u) - - ! omega_dalpha [UPWIND: iu -> spectraldiss] - omega_h(ic,iv_loc,itor) = & - -abs(omega_adrift(it,is))*energy(ie)*(1.0+xi(ix)**2)*& - (n_toroidal*q/pi/rmin)*spectraldiss(u,nup_alpha)*up_alpha - - ! (i ktheta) components from drifts - omega_cap_h(ic,iv_loc,itor) = omega_cap_h(ic,iv_loc,itor) & - - i_c*k_theta_base*itor*(omega_aprdrift(it,is)*energy(ie)*xi(ix)**2 & - + omega_cdrift(it,is)*vel(ie)*xi(ix) + omega_rot_drift(it,is) & - + omega_rot_edrift(it)) + do iv=nv1,nv2 + do ic=1,nc + + iv_loc = iv-nv1+1 + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + ir = ir_c(ic) + it = it_c(ic) + + u = (pi/n_toroidal)*itor + + ! omega_dalpha + omega_cap_h(ic,iv_loc,itor) = & + -omega_adrift(it,is)*energy(ie)*(1.0+xi(ix)**2)*& + (n_toroidal*q/pi/rmin)*(i_c*u) + + ! omega_dalpha [UPWIND: iu -> spectraldiss] + omega_h(ic,iv_loc,itor) = & + -abs(omega_adrift(it,is))*energy(ie)*(1.0+xi(ix)**2)*& + (n_toroidal*q/pi/rmin)*spectraldiss(u,nup_alpha)*up_alpha + + ! (i ktheta) components from drifts + omega_cap_h(ic,iv_loc,itor) = omega_cap_h(ic,iv_loc,itor) & + - i_c*k_theta_base*itor*(omega_aprdrift(it,is)*energy(ie)*xi(ix)**2 & + + omega_cdrift(it,is)*vel(ie)*xi(ix) + omega_rot_drift(it,is) & + + omega_rot_edrift(it)) - ! Note that we shift the dissipation with px0 (ballooning angle linear mode) - u = (2.0*pi/n_radial)*(px(ir)+px0) + ! Note that we shift the dissipation with px0 (ballooning angle linear mode) + u = (2.0*pi/n_radial)*(px(ir)+px0) - ! (d/dr) components from drifts + ! (d/dr) components from drifts - omega_cap_h(ic,iv_loc,itor) = omega_cap_h(ic,iv_loc,itor) & - - (n_radial/length)*i_c*u & - * (omega_rdrift(it,is)*energy(ie)*(1.0+xi(ix)**2) & - + omega_cdrift_r(it,is)*vel(ie)*xi(ix) & - + omega_rot_drift_r(it,is) & - + omega_rot_edrift_r(it)) + omega_cap_h(ic,iv_loc,itor) = omega_cap_h(ic,iv_loc,itor) & + - (n_radial/length)*i_c*u & + * (omega_rdrift(it,is)*energy(ie)*(1.0+xi(ix)**2) & + + omega_cdrift_r(it,is)*vel(ie)*xi(ix) & + + omega_rot_drift_r(it,is) & + + omega_rot_edrift_r(it)) - ! (d/dr) upwind components from drifts [UPWIND: iu -> spectraldiss] - omega_h(ic,iv_loc,itor) = omega_h(ic,iv_loc,itor) & - - (n_radial/length)*spectraldiss(u,nup_radial)*up_radial & - * (abs(omega_rdrift(it,is))*energy(ie)*(1.0+xi(ix)**2) & - + abs(omega_cdrift_r(it,is)*xi(ix))*vel(ie) & - + abs(omega_rot_drift_r(it,is)) & - + abs(omega_rot_edrift_r(it))) + ! (d/dr) upwind components from drifts [UPWIND: iu -> spectraldiss] + omega_h(ic,iv_loc,itor) = omega_h(ic,iv_loc,itor) & + - (n_radial/length)*spectraldiss(u,nup_radial)*up_radial & + * (abs(omega_rdrift(it,is))*energy(ie)*(1.0+xi(ix)**2) & + + abs(omega_cdrift_r(it,is)*xi(ix))*vel(ie) & + + abs(omega_rot_drift_r(it,is)) & + + abs(omega_rot_edrift_r(it))) - ! omega_star - carg = -i_c*k_theta_base*itor*rho*(dlnndr(is)+dlntdr(is)*(energy(ie)-1.5)) & - -i_c*k_theta_base*itor*rho*(vel2(ie)*xi(ix)/vth(is) & - *omega_gammap(it)) -i_c*k_theta_base*itor*rho*omega_rot_star(it,is) + ! omega_star + carg = -i_c*k_theta_base*itor*rho*(dlnndr(is)+dlntdr(is)*(energy(ie)-1.5)) & + -i_c*k_theta_base*itor*rho*(vel2(ie)*xi(ix)/vth(is) & + *omega_gammap(it)) -i_c*k_theta_base*itor*rho*omega_rot_star(it,is) + + omega_s(:,ic,iv_loc,itor) = carg*jvec_c(:,ic,iv_loc,itor) + + ! global-Taylor corrections via wavenumber advection (ix -> d/dp) + ! JC: Re-checked sign and normalization (Oct 2019) - omega_s(:,ic,iv_loc,itor) = carg*jvec_c(:,ic,iv_loc,itor) + ! NEW GLOBAL TERMS - ! Profile curvature via wavenumber advection (ix -> d/dp) - ! See whiteboard notes. - ! JC: Re-checked sign and normalization (Oct 2019) - carg = -k_theta_base*itor*length*(sdlnndr(is)+sdlntdr(is)*(energy(ie)-1.5))/(2*pi) + ! generalized omega_star shear (acts on phi) + sm = sdlnndr(is)+sdlntdr(is)*(energy(ie)-1.5) - omega_ss(:,ic,iv_loc,itor) = carg*jvec_c(:,ic,iv_loc,itor) + ! generalized beta/drift shear (acts on H) + sb = sbeta_star(is)*energy(ie)/bmag(it)**2 + arg = -k_theta_base*itor*length/(2*pi) + + omega_ss(:,ic,iv_loc,itor) = arg*sm*jvec_c(:,ic,iv_loc,itor) + omega_sbeta(ic,iv_loc,itor) = arg*sb + + enddo enddo - enddo enddo #if defined(OMPGPU) -!$omp target enter data map(to:omega_cap_h,omega_h,omega_s,omega_ss) +!$omp target enter data map(to:omega_cap_h,omega_h,omega_s,omega_ss,omega_sbeta) #elif defined(_OPENACC) -!$acc enter data copyin(omega_cap_h,omega_h,omega_s,omega_ss) +!$acc enter data copyin(omega_cap_h,omega_h,omega_s,omega_ss,omega_sbeta) #endif !------------------------------------------------------------------------- + deallocate(gdlnndr,gdlntdr) + end subroutine cgyro_init_arrays ! Spectral dissipation function diff --git a/cgyro/src/cgyro_init_collision.F90 b/cgyro/src/cgyro_init_collision.F90 index c90804d40..64a7e605c 100644 --- a/cgyro/src/cgyro_init_collision.F90 +++ b/cgyro/src/cgyro_init_collision.F90 @@ -5,6 +5,7 @@ subroutine cgyro_init_collision use cgyro_globals use mpi use cgyro_io + use cgyro_init_collision_landau implicit none @@ -48,304 +49,311 @@ subroutine cgyro_init_collision cmap_fp32_error_abs_cnt_loc(:) = 0 cmap_fp32_error_rel_cnt_loc(:) = 0 - allocate(nu_d(n_energy,n_species,n_species)) - allocate(nu_par(n_energy,n_species,n_species)) - allocate(klor_fac(n_species,n_species)) - allocate(kdiff_fac(n_species,n_species)) - nu_d(:,:,:) = 0.0 - nu_par(:,:,:) = 0.0 - klor_fac(:,:) = 0.0 - kdiff_fac(:,:) = 0.0 - - do js=1,n_species - do is=1,n_species - do ie=1,n_energy - - xa = vel(ie) - xb = xa*vth(is)/vth(js) - tauinv_ab = nu(is)*z(js)**2/z(is)**2*dens(js)/dens(is) - - select case (collision_model) + do_old_coll1: if (collision_model>=6) then + ! collision_model=6 (Landau) or 7 (New Sugama method [Galerkin]) + ! The way this is included now isn't harmonic with Igor's changes + ! cmat -> cmat_loc. The reason is to make the merge simpler. + if (collision_precision_mode/=0) allocate(cmat(nv,nv,nc_loc,nt1:nt2)) + call cgyro_init_landau + else + allocate(nu_d(n_energy,n_species,n_species)) + allocate(nu_par(n_energy,n_species,n_species)) + allocate(klor_fac(n_species,n_species)) + allocate(kdiff_fac(n_species,n_species)) + nu_d(:,:,:) = 0.0 + nu_par(:,:,:) = 0.0 + klor_fac(:,:) = 0.0 + kdiff_fac(:,:) = 0.0 + + do js=1,n_species + do is=1,n_species + do ie=1,n_energy + + xa = vel(ie) + xb = xa*vth(is)/vth(js) + tauinv_ab = nu(is)*z(js)**2/z(is)**2*dens(js)/dens(is) + + select case (collision_model) + + case (1) + + ! Only ee,ei Connor-like Lorentz + if (is == is_ele) then + if (is == js) then + ! e-e + nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & + * (exp(-xb*xb)/(xb*sqrt(pi)) & + + (1.0-1.0/(2.0*xb*xb)) * erf(xb)) + else + ! e-i + if(z_eff_method == 2) then + nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) + else + nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & + * z(is)**2 / z(js)**2 & + * dens(is)/dens(js) * z_eff/(n_species-1) + endif + endif + endif - case (1) + case (2) - ! Only ee,ei Connor-like Lorentz - if (is == is_ele) then - if (is == js) then - ! e-e + ! Connor model + if (is == js .or. & + (abs(mass(is) - mass(js)) < epsilon(0.0))) then + ! case 1: like-species/same mass collisions nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & * (exp(-xb*xb)/(xb*sqrt(pi)) & + (1.0-1.0/(2.0*xb*xb)) * erf(xb)) + + else if (mass(is) < mass(js)) then + ! case 2: ele-ion and ion-imp(heavy) collisions + nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) + else - ! e-i - if(z_eff_method == 2) then - nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) - else - nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & - * z(is)**2 / z(js)**2 & - * dens(is)/dens(js) * z_eff/(n_species-1) - endif + ! case 3: ion-ele and imp(heavy)-ion collisions + nu_d(ie,is,js) = tauinv_ab * 4.0/(3.0*sqrt(pi)) & + * sqrt(mass(js)/mass(is)) * (temp(is)/temp(js))**1.5 endif - endif - case (2) + case(4) - ! Connor model - if (is == js .or. & - (abs(mass(is) - mass(js)) < epsilon(0.0))) then - ! case 1: like-species/same mass collisions + ! Ad hoc op + ! (Fix for underflow) nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & * (exp(-xb*xb)/(xb*sqrt(pi)) & + (1.0-1.0/(2.0*xb*xb)) * erf(xb)) + ! No i-e Lorentz + !if (is /= is_ele .and. js == is_ele) then + ! nu_d(ie,is,js) = 0.0 + !endif + if(collision_kperp == 1) then + klor_fac(is,js) = 1.0 + endif - else if (mass(is) < mass(js)) then - ! case 2: ele-ion and ion-imp(heavy) collisions - nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) - - else - ! case 3: ion-ele and imp(heavy)-ion collisions - nu_d(ie,is,js) = tauinv_ab * 4.0/(3.0*sqrt(pi)) & - * sqrt(mass(js)/mass(is)) * (temp(is)/temp(js))**1.5 - endif - - case(4) - - ! Ad hoc op - ! (Fix for underflow) - nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & - * (exp(-xb*xb)/(xb*sqrt(pi)) & - + (1.0-1.0/(2.0*xb*xb)) * erf(xb)) - ! No i-e Lorentz - !if (is /= is_ele .and. js == is_ele) then - ! nu_d(ie,is,js) = 0.0 - !endif - if(collision_kperp == 1) then - klor_fac(is,js) = 1.0 - endif + ! Diffusion + nu_par(ie,is,js) = tauinv_ab * (2.0/xa**3) & + * (-exp(-xb*xb)/(xb*sqrt(pi)) & + + (1.0/(2.0*xb*xb)) * erf(xb)) + if(collision_kperp == 1) then + kdiff_fac(is,js) = 1.0 + endif - ! Diffusion - nu_par(ie,is,js) = tauinv_ab * (2.0/xa**3) & - * (-exp(-xb*xb)/(xb*sqrt(pi)) & - + (1.0/(2.0*xb*xb)) * erf(xb)) - if(collision_kperp == 1) then - kdiff_fac(is,js) = 1.0 - endif - - end select + end select + enddo enddo enddo - enddo - if (collision_ion_model == 1) then - do is=1,n_species - if(is /= is_ele) then - do js=1,n_species - nu_d(:,is,js) = 0.0 - nu_par(:,is,js) = 0.0 - enddo - endif - enddo - endif - - ! Printout used for CGYRO paper. - !if (i_proc == 0) then - ! do ie=1,n_energy - ! print '(i1,3(" &{\tt ",f9.5,"}")," \\")',& - ! ie,vel(ie),w_e(ie),nu_d(ie,n_species,n_species) - ! enddo - ! print *,sum(w_e) - !endif - - if ( collision_model == 4 .and. collision_kperp == 1 .and. & - (collision_mom_restore == 1 .or. collision_ene_restore == 1)) then - allocate(bessel(0:1,nv,nc_loc,nt1:nt2)) + if (collision_ion_model == 1) then + do is=1,n_species + if(is /= is_ele) then + do js=1,n_species + nu_d(:,is,js) = 0.0 + nu_par(:,is,js) = 0.0 + enddo + endif + enddo + endif + + ! Printout used for CGYRO paper. + !if (i_proc == 0) then + ! do ie=1,n_energy + ! print '(i1,3(" &{\tt ",f9.5,"}")," \\")',& + ! ie,vel(ie),w_e(ie),nu_d(ie,n_species,n_species) + ! enddo + ! print *,sum(w_e) + !endif + + if ( collision_model == 4 .and. collision_kperp == 1 .and. & + (collision_mom_restore == 1 .or. collision_ene_restore == 1)) then + allocate(bessel(0:1,nv,nc_loc,nt1:nt2)) !$omp parallel do collapse(2) private(ic_loc,it,ie,ix,is,iv,arg,xi_s1s,xi_prop) - do itor=nt1,nt2 - do ic=nc1,nc2 - ic_loc = ic-nc1+1 - it = it_c(ic) - do iv=1,nv - is = is_v(iv) - ix = ix_v(iv) - ie = ie_v(iv) - xi_s1s = sqrt(1.0-xi(ix)**2) - xi_prop = xi_s1s / xi(ix) + do itor=nt1,nt2 + do ic=nc1,nc2 + ic_loc = ic-nc1+1 + it = it_c(ic) + do iv=1,nv + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + xi_s1s = sqrt(1.0-xi(ix)**2) + xi_prop = xi_s1s / xi(ix) arg = k_perp(ic,itor)*rho*vth(is)*mass(is)& /(z(is)*bmag(it)) * vel2(ie) * xi_s1s bessel(0,iv,ic_loc,itor) = bessel_j0(arg) ! always used with the correction, so do it here bessel(1,iv,ic_loc,itor) = bessel_j1(arg) * xi_prop + enddo + enddo enddo - enddo - enddo - endif - - allocate(ctest(n_species,n_species,n_xi,n_xi,n_energy,n_energy)) + endif + + allocate(ctest(n_species,n_species,n_xi,n_xi,n_energy,n_energy)) - ! Collision test particle component - ! ctest + ! Collision test particle component + ! ctest - ! Lorentz + ! Lorentz !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) - do je=1,n_energy - do ie=1,n_energy - if (je == ie ) then - do jx=1,n_xi - do ix=1,n_xi - do js=1,n_species - do is=1,n_species - ctest(is,js,ix,jx,ie,je) = & - + xi_lor_mat(ix,jx) *0.5*nu_d(ie,is,js) + do je=1,n_energy + do ie=1,n_energy + if (je == ie ) then + do jx=1,n_xi + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + ctest(is,js,ix,jx,ie,je) = & + + xi_lor_mat(ix,jx) *0.5*nu_d(ie,is,js) + enddo enddo enddo enddo - enddo - else - ctest(:,:,:,:,ie,je) = 0 - endif + else + ctest(:,:,:,:,ie,je) = 0 + endif + enddo enddo - enddo - - ! Diffusion - if (collision_model == 4 .and. collision_ene_diffusion == 1) then + + ! Diffusion + if (collision_model == 4 .and. collision_ene_diffusion == 1) then !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) - do je=1,n_energy - do ie=1,n_energy - do ix=1,n_xi - jx = ix - do js=1,n_species - do is=1,n_species - ! From K. Hallatschek - ! self-adjoint part of ctest written self-adjointly - ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & - -0.5 / w_e(ie) & - *sum(w_e(:)*e_deriv1_mat(:,ie)*energy(:) & - *nu_par(:,is,js) *e_deriv1_mat(:,je))/(1.0*e_max) - ! non-self-adjoint part proportional 1-Ta/Tb written - ! in a way that supports inherent particle number - ! conservation for small kperp - ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & - + (1-temp(is)/temp(js)) / sqrt(1.0*e_max)/w_e(ie) & - * w_e(je)*e_deriv1_mat(je,ie) & - * nu_par(je,is,js)*energy(je)**1.5 + do je=1,n_energy + do ie=1,n_energy + do ix=1,n_xi + jx = ix + do js=1,n_species + do is=1,n_species + ! From K. Hallatschek + ! self-adjoint part of ctest written self-adjointly + ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & + -0.5 / w_e(ie) & + *sum(w_e(:)*e_deriv1_mat(:,ie)*energy(:) & + *nu_par(:,is,js) *e_deriv1_mat(:,je))/(1.0*e_max) + ! non-self-adjoint part proportional 1-Ta/Tb written + ! in a way that supports inherent particle number + ! conservation for small kperp + ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & + + (1-temp(is)/temp(js)) / sqrt(1.0*e_max)/w_e(ie) & + * w_e(je)*e_deriv1_mat(je,ie) & + * nu_par(je,is,js)*energy(je)**1.5 + enddo enddo enddo enddo enddo - enddo - endif - - allocate(cmat_base1(nv,nv)) - allocate(cmat_base2(nv,nv)) + endif - allocate(rs(n_species,n_species)) - allocate(rsvec(n_species,n_species,n_xi,n_energy)) - allocate(rsvect0(n_species,n_species,n_xi,n_energy)) + allocate(cmat_base1(nv,nv)) + allocate(cmat_base2(nv,nv)) + + allocate(rs(n_species,n_species)) + allocate(rsvec(n_species,n_species,n_xi,n_energy)) + allocate(rsvect0(n_species,n_species,n_xi,n_energy)) - select case (collision_model) + select case (collision_model) - case(2) - if (collision_mom_restore == 1) then - do js=1,n_species - do is=1,n_species - rs(is,js) = 0.0 - do ie=1,n_energy - rs(is,js) = rs(is,js) + w_e(ie)*nu_d(ie,is,js)*energy(ie) + case(2) + if (collision_mom_restore == 1) then + do js=1,n_species + do is=1,n_species + rs(is,js) = 0.0 + do ie=1,n_energy + rs(is,js) = rs(is,js) + w_e(ie)*nu_d(ie,is,js)*energy(ie) + enddo enddo enddo - enddo !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) - do jv=1,nv - do iv=1,nv - js = is_v(jv) - jx = ix_v(jv) - je = ie_v(jv) + do jv=1,nv + do iv=1,nv + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) - is = is_v(iv) - ix = ix_v(iv) - ie = ie_v(iv) + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) - if (abs(rs(is,js)) > epsilon(0.0)) then - cmat_base1(iv,jv) = & + if (abs(rs(is,js)) > epsilon(0.0)) then + cmat_base1(iv,jv) = & + 3.0 * (mass(js)/mass(is)) & * (vth(js)/vth(is)) * nu_d(ie,is,js) & * vel(ie) * xi(ix) & * nu_d(je,js,is) * vel(je) & * xi(jx) * w_exi(je,jx) / rs(is,js) & / dens(is) - else - cmat_base1(iv,jv) = 0 - endif + else + cmat_base1(iv,jv) = 0 + endif + enddo enddo - enddo - endif + endif - case(4) + case(4) - ! Momentum Restoring + ! Momentum Restoring - if (collision_mom_restore == 1) then + if (collision_mom_restore == 1) then + + ! C_test_ab(v_par f0a,f0b) and w_e v_par C_test_ab(H_a) + rs(:,:) = 0.0 - ! C_test_ab(v_par f0a,f0b) and w_e v_par C_test_ab(H_a) - rs(:,:) = 0.0 - - do ie=1,n_energy - do ix=1,n_xi - do js=1,n_species - do is=1,n_species - rsvtmp = 0 - rsvtmp0 = 0 - do je=1,n_energy - do jx=1,n_xi - rsvtmp = rsvtmp & - + ctest(is,js,ix,jx,ie,je) & - * vel2(je) * xi(jx) - rsvtmp0 = rsvtmp0 & - + ctest(is,js,jx,ix,je,ie) & - * vel2(je) * xi(jx) & - * w_exi(je,jx) + do ie=1,n_energy + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + rsvtmp = 0 + rsvtmp0 = 0 + do je=1,n_energy + do jx=1,n_xi + rsvtmp = rsvtmp & + + ctest(is,js,ix,jx,ie,je) & + * vel2(je) * xi(jx) + rsvtmp0 = rsvtmp0 & + + ctest(is,js,jx,ix,je,ie) & + * vel2(je) * xi(jx) & + * w_exi(je,jx) + enddo enddo + rsvtmp = rsvtmp * vth(is) + rsvtmp0 = rsvtmp0 * vth(is) + rsvec(is,js,ix,ie) = rsvtmp + rsvect0(is,js,ix,ie) = rsvtmp0 + ! int v_par C_test_ab(v_par f0a,f0b) / n_0a + rs(is,js) = rs(is,js) + w_exi(ie,ix) * dens(is) & + * rsvtmp * vel2(ie) * xi(ix) & + * vth(is) enddo - rsvtmp = rsvtmp * vth(is) - rsvtmp0 = rsvtmp0 * vth(is) - rsvec(is,js,ix,ie) = rsvtmp - rsvect0(is,js,ix,ie) = rsvtmp0 - ! int v_par C_test_ab(v_par f0a,f0b) / n_0a - rs(is,js) = rs(is,js) + w_exi(ie,ix) * dens(is) & - * rsvtmp * vel2(ie) * xi(ix) & - * vth(is) enddo enddo enddo - enddo - - if (collision_kperp == 0) then + + if (collision_kperp == 0) then !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) - do jv=1,nv - do iv=1,nv - js = is_v(jv) - jx = ix_v(jv) - je = ie_v(jv) + do jv=1,nv + do iv=1,nv + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) - is = is_v(iv) - ix = ix_v(iv) - ie = ie_v(iv) + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) - if (abs(rs(is,js))>epsilon(0.0)) then - cmat_base1(iv,jv) = & + if (abs(rs(is,js))>epsilon(0.0)) then + cmat_base1(iv,jv) = & - mass(js)/mass(is) & * rsvec(is,js,ix,ie) / rs(is,js) & * rsvect0(js,is,jx,je) - else - cmat_base1(iv,jv) = 0 - endif + else + cmat_base1(iv,jv) = 0 + endif + enddo enddo - enddo - else + else !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) do jv=1,nv do iv=1,nv @@ -367,43 +375,43 @@ subroutine cgyro_init_collision endif enddo enddo - endif + endif - endif - - ! Energy Restoring + endif + + ! Energy Restoring + + if (collision_ene_restore == 1) then - if (collision_ene_restore == 1) then - - ! C_test_ab(u_a^2 f0a,f0b) and w_e u_a^2 C_test_ab(H_a) - rs(:,:) = 0.0 + ! C_test_ab(u_a^2 f0a,f0b) and w_e u_a^2 C_test_ab(H_a) + rs(:,:) = 0.0 - do ie=1,n_energy - do ix=1,n_xi - do js=1,n_species - do is=1,n_species - rsvtmp = 0 - rsvtmp0 = 0 - do je=1,n_energy - do jx=1,n_xi - rsvtmp = rsvtmp & - + ctest(is,js,ix,jx,ie,je) * energy(je) - rsvtmp0 = rsvtmp0 & - + ctest(is,js,jx,ix,je,ie) * energy(je) & - * w_exi(je,jx) + do ie=1,n_energy + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + rsvtmp = 0 + rsvtmp0 = 0 + do je=1,n_energy + do jx=1,n_xi + rsvtmp = rsvtmp & + + ctest(is,js,ix,jx,ie,je) * energy(je) + rsvtmp0 = rsvtmp0 & + + ctest(is,js,jx,ix,je,ie) * energy(je) & + * w_exi(je,jx) + enddo enddo - enddo - rsvec(is,js,ix,ie) = rsvtmp - rsvect0(is,js,ix,ie) = rsvtmp0 - ! int v^2 C_test_ab(u_a^2 f0a,f0b) - rs(is,js) = rs(is,js) + w_exi(ie,ix) & + rsvec(is,js,ix,ie) = rsvtmp + rsvect0(is,js,ix,ie) = rsvtmp0 + ! int v^2 C_test_ab(u_a^2 f0a,f0b) + rs(is,js) = rs(is,js) + w_exi(ie,ix) & * dens(is) * rsvtmp * energy(ie) + enddo enddo enddo enddo - enddo - if (collision_kperp == 0) then + if (collision_kperp == 0) then !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) do jv=1,nv do iv=1,nv @@ -425,8 +433,8 @@ subroutine cgyro_init_collision endif enddo enddo - - else + + else !$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) do jv=1,nv do iv=1,nv @@ -437,7 +445,7 @@ subroutine cgyro_init_collision is = is_v(iv) ix = ix_v(iv) ie = ie_v(iv) - + if (abs(rs(is,js)) > epsilon(0.0)) then cmat_base2(iv,jv) = & - temp(js)/temp(is) & @@ -448,18 +456,19 @@ subroutine cgyro_init_collision endif enddo enddo + endif + endif - - endif - - end select - deallocate(rs) - deallocate(rsvec) - deallocate(rsvect0) + end select + deallocate(rs) + deallocate(rsvec) + deallocate(rsvect0) + endif do_old_coll1 + ! matrix solve parameters allocate(i_piv(nv)) - + allocate(amat(nv,nv)) allocate(cmat_loc(nv,nv)) @@ -489,317 +498,321 @@ subroutine cgyro_init_collision !$omp& reduction(+:cmat_diff_global_loc,cmat32_diff_global_loc) & !$omp& reduction(+:cmap_fp32_error_abs_cnt_loc,cmap_fp32_error_rel_cnt_loc) do itor=nt1,nt2 - do ic=nc1,nc2 - - ic_loc = ic-nc1+1 + do ic=nc1,nc2 - it = it_c(ic) - ir = ir_c(ic) + ic_loc = ic-nc1+1 - ! Collision field particle component - amat(:,:) = 0.0 + it = it_c(ic) + ir = ir_c(ic) - select case (collision_model) + ! Collision field particle component + amat(:,:) = 0.0 - case(2) - if (collision_mom_restore == 1) then - do jv=1,nv - js = is_v(jv) - my_dens2_rot = dens2_rot(it,js) + select case (collision_model) - do iv=1,nv + case(2) + if (collision_mom_restore == 1) then + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) - ! we know we are the first one to modify cmat_loc, so no need for += - cmat_loc(iv,jv) = & + do iv=1,nv + + ! we know we are the first one to modify cmat_loc, so no need for += + cmat_loc(iv,jv) = & cmat_base1(iv,jv) & * my_dens2_rot - enddo - enddo + enddo + enddo - else - cmat_loc(:,:) = 0.0 - endif + else + cmat_loc(:,:) = 0.0 + endif - case(4) + case(4) - ! Momentum Restoring + ! Momentum Restoring - if (collision_mom_restore == 1) then + if (collision_mom_restore == 1) then - if (collision_kperp == 0) then - do jv=1,nv - js = is_v(jv) - my_dens2_rot = dens2_rot(it,js) + if (collision_kperp == 0) then + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) - do iv=1,nv + do iv=1,nv - ! we know we are the first one to modify cmat_loc, so no need for += - cmat_loc(iv,jv) = & + ! we know we are the first one to modify cmat_loc, so no need for += + cmat_loc(iv,jv) = & cmat_base1(iv,jv) & * my_dens2_rot - enddo - enddo + enddo + enddo - else - do jv=1,nv - js = is_v(jv) - my_dens2_rot = dens2_rot(it,js) - my_bj0 = bessel(0,jv,ic_loc,itor) - my_bj1 = bessel(1,jv,ic_loc,itor) + else + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + my_bj0 = bessel(0,jv,ic_loc,itor) + my_bj1 = bessel(1,jv,ic_loc,itor) - do iv=1,nv + do iv=1,nv ! we know we are the first one to modify cmat_loc, so no need for += cmat_loc(iv,jv) = & cmat_base1(iv,jv) & * ( bessel(0,iv,ic_loc,itor) * my_bj0 & - + bessel(1,iv,ic_loc,itor) * my_bj1 ) & + + bessel(1,iv,ic_loc,itor) * my_bj1 ) & * my_dens2_rot + enddo enddo - enddo - endif + endif - else - cmat_loc(:,:) = 0.0 - endif + else + cmat_loc(:,:) = 0.0 + endif - ! Energy Restoring + ! Energy Restoring - if (collision_ene_restore == 1) then + if (collision_ene_restore == 1) then - if (collision_kperp == 0) then - do jv=1,nv - js = is_v(jv) - my_dens2_rot = dens2_rot(it,js) + if (collision_kperp == 0) then + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) - do iv=1,nv + do iv=1,nv ! likely not the first, use += cmat_loc(iv,jv) & = cmat_loc(iv,jv) & + cmat_base2(iv,jv) & * my_dens2_rot + enddo enddo - enddo - else - do jv=1,nv - js = is_v(jv) - my_dens2_rot = dens2_rot(it,js) - my_bj0 = bessel(0,jv,ic_loc,itor) - - do iv=1,nv + else + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + my_bj0 = bessel(0,jv,ic_loc,itor) + + do iv=1,nv ! likely not the first, use += cmat_loc(iv,jv) & = cmat_loc(iv,jv) & + cmat_base2(iv,jv) & * bessel(0,iv,ic_loc,itor) * my_bj0 & * my_dens2_rot + enddo enddo - enddo - endif - - endif + endif - case default - cmat_loc(:,:) = 0.0 - - end select + endif - ! Avoid singularity of n=0,p=0: - if (px(ir) == 0 .and. itor == 0) then + case(6,7) + ! write the Landau/new collision matrix into the local array + cmat_loc(:,:)=cmat(:,:,ic_loc,itor) - do iv=1,nv - cmat_loc(iv,iv) = 1.0 - amat(iv,iv) = 1.0 - enddo + case default + cmat_loc(:,:) = 0.0 - else + end select - ! Already has field particle collisions - do iv=1,nv - do jv=1,nv - rval = (0.5*delta_t) * cmat_loc(jv,iv) - amat(jv,iv) = rval - cmat_loc(jv,iv) = -rval - enddo - enddo + ! Avoid singularity of n=0,p=0: + if (px(ir) == 0 .and. itor == 0) then - do jv=1,nv + do iv=1,nv + cmat_loc(iv,iv) = 1.0 + amat(iv,iv) = 1.0 + enddo - js = is_v(jv) - jx = ix_v(jv) - je = ie_v(jv) + else + ! Already has field particle collisions do iv=1,nv + do jv=1,nv + rval = (0.5*delta_t) * cmat_loc(jv,iv) + amat(jv,iv) = rval + cmat_loc(jv,iv) = -rval + enddo + enddo - is = is_v(iv) - ix = ix_v(iv) - ie = ie_v(iv) - - ! Collision component: Test particle - if (is == js) then - do ks=1,n_species - rval = (0.5*delta_t) * ctest(is,ks,ix,jx,ie,je) & - * dens_rot(it,ks) - cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval - amat(iv,jv) = amat(iv,jv) + rval - enddo - endif + do jv=1,nv - ! Trapping - ! (not part of collision operator but contains xi-derivative) - if (explicit_trap_flag == 0 .and. is == js .and. ie == je) then - rval = (0.5*delta_t) * (omega_trap(it,is,itor) * vel(ie) & - + omega_rot_trap(it,is) / vel(ie)) & - * (1.0 - xi(ix)**2) * xi_deriv_mat(ix,jx) - cmat_loc(iv,jv) = cmat_loc(iv,jv) + rval - amat(iv,jv) = amat(iv,jv) - rval - endif + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) - ! Rotation energy derivative - ! (not part of collision operator but contains e-derivative) - if (explicit_trap_flag == 0 .and. is == js .and. ix == jx) then - rval = (0.5*delta_t) * omega_rot_u(it,is) * xi(ix) & - * e_deriv1_rot_mat(ie,je)/sqrt(1.0*e_max) - cmat_loc(iv,jv) = cmat_loc(iv,jv) + rval - amat(iv,jv) = amat(iv,jv) - rval - endif + do iv=1,nv + + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) - ! Finite-kperp test particle corrections - if (collision_model == 4 .and. collision_kperp == 1) then - if (is == js .and. jx == ix .and. je == ie) then + ! Collision component: Test particle + if (collision_model<6 .and. is == js) then do ks=1,n_species - rval = (0.5*delta_t) & - * (-0.25*(k_perp(ic,itor)*rho*vth(is)*mass(is) & - / (z(is)*bmag(it)))**2 * 2.0*energy(ie) & - * (klor_fac(is,ks)*nu_d(ie,is,ks) * (1+xi(ix)**2) & - + kdiff_fac(is,ks)*nu_par(ie,is,ks)* (1-xi(ix)**2))) + rval = (0.5*delta_t) * ctest(is,ks,ix,jx,ie,je) & + * dens_rot(it,ks) cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval amat(iv,jv) = amat(iv,jv) + rval enddo endif - endif - - if (collision_field_model == 1) then - ! Poisson component l - if (itor == 0 .and. ae_flag == 1) then - ! Cannot include Poisson in collision matrix - ! for n=0 with ade because depends on theta - ! i.e. ne0 ~ phi - - !cmat_loc(iv,jv) = cmat_loc(iv,jv) + 0.0 - !amat(iv,jv) = amat(iv,jv) + 0.0 - else - rval = z(is)/temp(is) * jvec_v(1,ic_loc,itor,iv) & - / (k_perp(ic,itor)**2 * lambda_debye**2 & - * dens_ele / temp_ele + sum_den_h(it)) & - * z(js)*dens2_rot(it,js) & - * jvec_v(1,ic_loc,itor,jv) * w_exi(je,jx) - cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval + ! Trapping + ! (not part of collision operator but contains xi-derivative) + if (explicit_trap_flag == 0 .and. is == js .and. ie == je) then + rval = (0.5*delta_t) * (omega_trap(it,is,itor) * vel(ie) & + + omega_rot_trap(it,is) / vel(ie)) & + * (1.0 - xi(ix)**2) * xi_deriv_mat(ix,jx) + cmat_loc(iv,jv) = cmat_loc(iv,jv) + rval amat(iv,jv) = amat(iv,jv) - rval endif - ! Ampere component - if (n_field > 1) then - rval = z(is)/temp(is) * (jvec_v(2,ic_loc,itor,iv) & - / (2.0*k_perp(ic,itor)**2 * rho**2 / betae_unit & - * dens_ele * temp_ele)) & - * z(js)*dens2_rot(it,js) & - * jvec_v(2,ic_loc,itor,jv) * w_exi(je,jx) + ! Rotation energy derivative + ! (not part of collision operator but contains e-derivative) + if (explicit_trap_flag == 0 .and. is == js .and. ix == jx) then + rval = (0.5*delta_t) * omega_rot_u(it,is) * xi(ix) & + * e_deriv1_rot_mat(ie,je)/sqrt(1.0*e_max) cmat_loc(iv,jv) = cmat_loc(iv,jv) + rval - amat(iv,jv) = amat(iv,jv) + rval + amat(iv,jv) = amat(iv,jv) - rval endif - ! Ampere Bpar component - if (n_field > 2) then - rval = jvec_v(3,ic_loc,itor,iv) & - * (-0.5*betae_unit)/(dens_ele*temp_ele) & - * w_exi(je,jx)*dens2_rot(it,js)*temp(js) & - * jvec_v(3,ic_loc,itor,jv)/(temp(is)/z(is))/(temp(js)/z(js)) - cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval - amat(iv,jv) = amat(iv,jv) - rval + ! Finite-kperp test particle corrections + if (collision_model == 4 .and. collision_kperp == 1) then + if (is == js .and. jx == ix .and. je == ie) then + do ks=1,n_species + rval = (0.5*delta_t) & + * (-0.25*(k_perp(ic,itor)*rho*vth(is)*mass(is) & + / (z(is)*bmag(it)))**2 * 2.0*energy(ie) & + * (klor_fac(is,ks)*nu_d(ie,is,ks) * (1+xi(ix)**2) & + + kdiff_fac(is,ks)*nu_par(ie,is,ks)* (1-xi(ix)**2))) + cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval + amat(iv,jv) = amat(iv,jv) + rval + enddo + endif endif - endif + if (collision_field_model == 1) then - ! constant part - if ( iv == jv ) then - cmat_loc(iv,iv) = cmat_loc(iv,iv) + 1.0 - amat(iv,iv) = amat(iv,iv) + 1.0 - endif + ! Poisson component l + if (itor == 0 .and. ae_flag == 1) then + ! Cannot include Poisson in collision matrix + ! for n=0 with ade because depends on theta + ! i.e. ne0 ~ phi - + !cmat_loc(iv,jv) = cmat_loc(iv,jv) + 0.0 + !amat(iv,jv) = amat(iv,jv) + 0.0 + else + rval = z(is)/temp(is) * jvec_v(1,ic_loc,itor,iv) & + / (k_perp(ic,itor)**2 * lambda_debye**2 & + * dens_ele / temp_ele + sum_den_h(it)) & + * z(js)*dens2_rot(it,js) & + * jvec_v(1,ic_loc,itor,jv) * w_exi(je,jx) + cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval + amat(iv,jv) = amat(iv,jv) - rval + endif + + ! Ampere component + if (n_field > 1) then + rval = z(is)/temp(is) * (jvec_v(2,ic_loc,itor,iv) & + / (2.0*k_perp(ic,itor)**2 * rho**2 / betae_unit & + * dens_ele * temp_ele)) & + * z(js)*dens2_rot(it,js) & + * jvec_v(2,ic_loc,itor,jv) * w_exi(je,jx) + cmat_loc(iv,jv) = cmat_loc(iv,jv) + rval + amat(iv,jv) = amat(iv,jv) + rval + endif + + ! Ampere Bpar component + if (n_field > 2) then + rval = jvec_v(3,ic_loc,itor,iv) & + * (-0.5*betae_unit)/(dens_ele*temp_ele) & + * w_exi(je,jx)*dens2_rot(it,js)*temp(js) & + * jvec_v(3,ic_loc,itor,jv)/(temp(is)/z(is))/(temp(js)/z(js)) + cmat_loc(iv,jv) = cmat_loc(iv,jv) - rval + amat(iv,jv) = amat(iv,jv) - rval + endif + + endif + + ! constant part + if ( iv == jv ) then + cmat_loc(iv,iv) = cmat_loc(iv,iv) + 1.0 + amat(iv,iv) = amat(iv,iv) + 1.0 + endif + enddo enddo - enddo - endif + endif - ! H_bar = (1 - dt/2 C - Poisson)^(-1) * (1 + dt/2 C + Poisson) H - ! Lapack factorization and inverse of LHS - call DGESV(nv,nv,cmat_loc(:,:),size(cmat_loc,1), & - i_piv,amat,size(amat,1),info) - - - ! result in amat, transfer to the right cmat matrix - if (collision_precision_mode == 1) then - ! keep all cmat in fp32 precision - cmat_fp32(:,:,ic_loc,itor) = amat(:,:) - ! keep the remaining precision for select elements - do jv=1,nv - je = ie_v(jv) - js = is_v(jv) - jx = ix_v(jv) - amat_sum = 0.0 - cmat_sum = 0.0 - cmat32_sum = 0.0 - do iv=1,nv - ! using abs values, as I am gaugung precision errors, and this avoid symmetry cancellations - amat_sum = amat_sum + abs(amat(iv,jv)) - cmat32_sum = cmat32_sum + abs(cmat_fp32(iv,jv,ic_loc,itor)) - ie = ie_v(iv) - is = is_v(iv) - ix = ix_v(iv) - my_cmat_fp32 = cmat_fp32(iv,jv,ic_loc,itor) - if (ie<=n_low_energy) then ! always keep all detail for lowest energy - cmat_e1(ix,is,ie,jv,ic_loc,itor) = amat(iv,jv) - my_cmat_fp32 - ! my_cmat_fp32 not used for the original purpose anymore, reuse to represent the reduced precsion - my_cmat_fp32 = my_cmat_fp32 + cmat_e1(ix,is,ie,jv,ic_loc,itor) ! my_cmat_fp32 is actually fp64, so sum OK - else ! only keep if energy and species the same - if ((je == ie) .AND. (js == is)) then - cmat_stripes(ix,is,ie,jx,ic_loc,itor) = amat(iv,jv) - my_cmat_fp32 + ! H_bar = (1 - dt/2 C - Poisson)^(-1) * (1 + dt/2 C + Poisson) H + ! Lapack factorization and inverse of LHS + call DGESV(nv,nv,cmat_loc(:,:),size(cmat_loc,1), & + i_piv,amat,size(amat,1),info) + + + ! result in amat, transfer to the right cmat matrix + if (collision_precision_mode == 1) then + ! keep all cmat in fp32 precision + cmat_fp32(:,:,ic_loc,itor) = amat(:,:) + ! keep the remaining precision for select elements + do jv=1,nv + je = ie_v(jv) + js = is_v(jv) + jx = ix_v(jv) + amat_sum = 0.0 + cmat_sum = 0.0 + cmat32_sum = 0.0 + do iv=1,nv + ! using abs values, as I am gaugung precision errors, and this avoid symmetry cancellations + amat_sum = amat_sum + abs(amat(iv,jv)) + cmat32_sum = cmat32_sum + abs(cmat_fp32(iv,jv,ic_loc,itor)) + ie = ie_v(iv) + is = is_v(iv) + ix = ix_v(iv) + my_cmat_fp32 = cmat_fp32(iv,jv,ic_loc,itor) + if (ie<=n_low_energy) then ! always keep all detail for lowest energy + cmat_e1(ix,is,ie,jv,ic_loc,itor) = amat(iv,jv) - my_cmat_fp32 ! my_cmat_fp32 not used for the original purpose anymore, reuse to represent the reduced precsion - my_cmat_fp32 = my_cmat_fp32 + cmat_stripes(ix,is,ie,jx,ic_loc,itor) ! my_cmat_fp32 is actually fp64, so sum OK + my_cmat_fp32 = my_cmat_fp32 + cmat_e1(ix,is,ie,jv,ic_loc,itor) ! my_cmat_fp32 is actually fp64, so sum OK + else ! only keep if energy and species the same + if ((je == ie) .AND. (js == is)) then + cmat_stripes(ix,is,ie,jx,ic_loc,itor) = amat(iv,jv) - my_cmat_fp32 + ! my_cmat_fp32 not used for the original purpose anymore, reuse to represent the reduced precsion + my_cmat_fp32 = my_cmat_fp32 + cmat_stripes(ix,is,ie,jx,ic_loc,itor) ! my_cmat_fp32 is actually fp64, so sum OK + endif endif - endif - cmat_sum = cmat_sum + abs(my_cmat_fp32) - enddo - cmat_diff = abs(amat_sum-cmat_sum) - cmat_diff_global_loc = cmat_diff_global_loc + cmat_diff - cmat32_diff = abs(amat_sum-cmat32_sum) - cmat32_diff_global_loc = cmat32_diff_global_loc + cmat32_diff - cmat_rel_diff = cmat_diff/abs(amat_sum) - ! reuse amt_sum as 10^-(ie), to reduce numbe rof variables in use - do ie=8,18 - amat_sum = 10.0 ** (-ie) - if (cmat_diff>amat_sum) then - cmap_fp32_error_abs_cnt_loc(ie) = cmap_fp32_error_abs_cnt_loc(ie) + 1 - endif - if (cmat_rel_diff>amat_sum) then - cmap_fp32_error_rel_cnt_loc(ie) = cmap_fp32_error_rel_cnt_loc(ie) + 1 - endif + cmat_sum = cmat_sum + abs(my_cmat_fp32) + enddo + cmat_diff = abs(amat_sum-cmat_sum) + cmat_diff_global_loc = cmat_diff_global_loc + cmat_diff + cmat32_diff = abs(amat_sum-cmat32_sum) + cmat32_diff_global_loc = cmat32_diff_global_loc + cmat32_diff + cmat_rel_diff = cmat_diff/abs(amat_sum) + ! reuse amt_sum as 10^-(ie), to reduce numbe rof variables in use + do ie=8,18 + amat_sum = 10.0 ** (-ie) + if (cmat_diff>amat_sum) then + cmap_fp32_error_abs_cnt_loc(ie) = cmap_fp32_error_abs_cnt_loc(ie) + 1 + endif + if (cmat_rel_diff>amat_sum) then + cmap_fp32_error_rel_cnt_loc(ie) = cmap_fp32_error_rel_cnt_loc(ie) + 1 + endif + enddo + ! use 19 as absolute counter for normalization + cmap_fp32_error_abs_cnt_loc(19) = cmap_fp32_error_abs_cnt_loc(19) + 1 enddo - ! use 19 as absolute counter for normalization - cmap_fp32_error_abs_cnt_loc(19) = cmap_fp32_error_abs_cnt_loc(19) + 1 - enddo - else if (collision_precision_mode == 32) then - ! keep all cmat in fp32 precision - cmat_fp32(:,:,ic_loc,itor) = amat(:,:) - else - ! keep all cmat in full precision - cmat(:,:,ic_loc,itor) = amat(:,:) - endif + else if (collision_precision_mode == 32) then + ! keep all cmat in fp32 precision + cmat_fp32(:,:,ic_loc,itor) = amat(:,:) + else + ! keep all cmat in full precision + cmat(:,:,ic_loc,itor) = amat(:,:) + endif - enddo + enddo enddo deallocate(cmat_loc) deallocate(amat) @@ -847,34 +860,34 @@ subroutine cgyro_init_collision ! reuse amat_sum to reduce number of variables amat_sum = 0.01 * cmap_fp32_error_abs_cnt(19) write (msg, "(A,A,A,A,A,A,A,A,A)") & - " ", & - " >1.e-8", " e-9", & - " e-10", " e-11", & - " e-12", " e-13", & - " e-14", " e-15" + " ", & + " >1.e-8", " e-9", & + " e-10", " e-11", & + " e-12", " e-13", & + " e-14", " e-15" call cgyro_info(msg) write (msg, "(A,4(F6.2,A),4(F6.1,A))") & - "Abs cmat_fp32 error rates: ", cmap_fp32_error_abs_cnt(8)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(9)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(10)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(11)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(12)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(13)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(14)/amat_sum, & - "%", cmap_fp32_error_abs_cnt(15)/amat_sum, "%" + "Abs cmat_fp32 error rates: ", cmap_fp32_error_abs_cnt(8)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(9)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(10)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(11)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(12)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(13)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(14)/amat_sum, & + "%", cmap_fp32_error_abs_cnt(15)/amat_sum, "%" call cgyro_info(msg) write (msg, "(A,4(F6.2,A),4(F6.1,A))") & - "Rel cmat_fp32 error rates: ", cmap_fp32_error_rel_cnt(8)/amat_sum, & - "%", cmap_fp32_error_rel_cnt(9)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(10)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(11)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(12)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(13)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(14)/amat_sum, & - "%",cmap_fp32_error_rel_cnt(15)/amat_sum, "%" + "Rel cmat_fp32 error rates: ", cmap_fp32_error_rel_cnt(8)/amat_sum, & + "%", cmap_fp32_error_rel_cnt(9)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(10)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(11)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(12)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(13)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(14)/amat_sum, & + "%",cmap_fp32_error_rel_cnt(15)/amat_sum, "%" call cgyro_info(msg) write (msg, "(A,1PE9.2)") & - "Abs cmat_fp32 error avg: ", 0.01*cmap_fp32_error_sum(1)/amat_sum + "Abs cmat_fp32 error avg: ", 0.01*cmap_fp32_error_sum(1)/amat_sum call cgyro_info(msg) ! Printout used for CGYRO paper. !write (msg, "(A,1PE9.2)") & @@ -898,13 +911,17 @@ subroutine cgyro_init_collision #endif endif - deallocate(cmat_base2) - deallocate(cmat_base1) deallocate(i_piv) - deallocate(nu_d) - deallocate(nu_par) - deallocate(ctest) - deallocate(klor_fac) - deallocate(kdiff_fac) + do_old_coll2: if (collision_model<6) then + deallocate(cmat_base2) + deallocate(cmat_base1) + deallocate(nu_d) + deallocate(nu_par) + deallocate(ctest) + deallocate(klor_fac) + deallocate(kdiff_fac) + else if (collision_precision_mode/=0) then + deallocate(cmat) + endif do_old_coll2 end subroutine cgyro_init_collision diff --git a/cgyro/src/cgyro_init_collision_landau.F90 b/cgyro/src/cgyro_init_collision_landau.F90 new file mode 100644 index 000000000..3387f624e --- /dev/null +++ b/cgyro/src/cgyro_init_collision_landau.F90 @@ -0,0 +1,1859 @@ +module cgyro_init_collision_landau + implicit none + logical, parameter :: DIFF_OFF=.false. + ! ^^ Switch off energy restoration for new Sugama op + logical, parameter :: KPERP_FIELD_OFF=.false. + ! ^^ Switch off gyrotrafo of field part, i.e., treat that one drift-kinetic + integer, parameter :: verbose=1000 + real, parameter :: eps=1e-13 + integer,parameter :: ng2=8 ! number of Gauss points for inner integration + real,private,parameter :: pi1=atan(1.)*4 + private :: qsort,old_sugama +!!$ interface +!!$ function qsort ( base, nmemb, size,cmp ) bind ( c,name="qsort") +!!$ use iso_c_binding +!!$ type (*) :: base +!!$ integer :: nmemb,size +!!$ interface +!!$ integer,value :: function cmp(a,b) !<-- this is probably illegal which is why one can't use this. +!!$ type (*),intent(in) :: a,b +!!$ end function cmp +!!$ end interface +!!$ end function qsort +!!$ end interface +contains + subroutine cgyro_init_landau() + ! populate cmat with Galerkin based gyrokinetic Landau operator. + ! cmat1 is only for comparison purposes + use cgyro_globals, only : vth,temp,mass,dens,temp_ele,mass_ele,dens_ele,rho,z,& + n_energy,e_max,n_xi,n_radial,n_theta,n_species,n_toroidal,nt1,nt2,nc_loc,nc1,nc2,nc,nv,& + nu_ee,& + xi,w_xi,& !needed for projleg calc + collision_model,& ! if this is 7, we switch to calculating Sugama. + collision_field_max_l,collision_test_max_l,& + collision_test_mode,& !if this is 1, we print out comparisons with traditional matrix element + ic_c,it_c,iv_v,& + k_perp,bmag,& + alpha_poly,& + i_proc,n_proc,& + cmat + use landau, landauvb=>verbose + use gyrotransformation, gtvb=>verbose + use half_hermite + use mpi + ! need to calculate up to lphys=n_xi-1, n_energy polynomials and for n_species. + use, intrinsic :: ieee_exceptions + implicit none + !character(*),parameter :: sr='init_collision_landau: ' + real, dimension(:), allocatable :: a1,b1,c1,lg,a,bsq,sp,sw,gw,gp,gw2,gp2 + real, dimension(:,:), allocatable :: projsteen,projleg,L2xi,xi2L,poly2v,v2poly,Landau2v,& + lor,lor1,lor_self,dif,dif1,dif_self,t1t2,t1t21,energymatrix + real, dimension(:,:,:), allocatable :: field,field2 + real, dimension(:,:,:,:), allocatable :: Landauop,dk_self_field !<- only for KPERP_FIELD_OFF + real, dimension(:,:,:,:,:,:,:), allocatable :: gyrocolmat + + ! for comparison purposes only for collision_test_mode==1: + real, allocatable :: cmat1(:,:,:,:) + + ! for Lapack + real, dimension(:),allocatable :: work + integer,dimension(:),allocatable :: iwork,isuppz,ifail + integer lwork,liwork,info + + ! for MPI + !type(MPI_Status) :: status !mpi_f08 + integer status(MPI_STATUS_SIZE) + integer ierror + + ! for IEEE + type(ieee_status_type) ieee_status + + ! for processor allocation + integer,allocatable:: proc(:,:,:),load(:),gtcost(:,:,:),sortidx(:) + integer idx,max_load,min_load,cost + + ! for timing + real t(11),t1,t2 + + ! for calculating Sugama op + real,allocatable :: polyrep(:,:) + + integer ngauss + integer it,ic,itor,ic_loc,ia,ib,ik,nkmax,is,is1,ns + integer js + integer,allocatable :: nk(:,:) + real, allocatable :: kperp_arr(:,:,:),loss(:),dist(:),id(:,:) + real,allocatable:: AF(:,:),pv(:,:),em(:,:),Sc(:),ferr(:),berr(:) + real rcond + character equed + real, allocatable, dimension(:,:,:,:) :: m1,m2 + real, allocatable :: chebweightarr(:) + real target_k,target_ik + integer ix,ie,jx,je,iv,jv + integer i,j,k,l,m + real xmax,kperp_bmag_max,rhomax,kperprhomax + real kperp_bmag,md,d,md1,d1,devi,s,s1 + integer nmaxpoly,lmax,lmax_field,lmax_test + integer totalcost,lneeded + real beta,t1t2ratio,normalization,fieldnormalization,fieldnormalization_ba,testnormalization + logical t1t2flag + character(1000) :: fn + real, allocatable, dimension(:,:,:,:,:) :: c + real, allocatable, dimension(:,:) :: v2polytimesemat,mommat,v2momtimesemat,mom2v + integer, allocatable, dimension(:) :: nc1_proc,nc2_proc,nt1_proc,nt2_proc + integer, allocatable, dimension(:,:) :: proc_c +1 format ("init_collision_landau: ",9A) + if (i_proc==0) print 1,'WARNING: dens_rot not yet implemented!!' + if (i_proc==0) print 1,'WARNING: nu_global not yet implemented!!' + if (i_proc==0 .and. collision_test_mode==1) print 1,'collision_test_mode==1, comparing ...' +#ifdef __PGI + if (i_proc==0) print 1,'WARNING: precision loss in landau.F90 - can''t use quad precision in PGI!!' +#endif + if (i_proc==0 .and. maxval(abs(temp(1:n_species)-temp(1)))/=0) then + print 1,'Warning: Landau not yet working for different species temperatures!!' + end if + + + if (i_proc==0 .and. verbose>0) then ! verboseness settings of modules + landauvb=1 + gtvb=1 + end if + + !$ call MPI_Barrier(MPI_COMM_WORLD,ierror) ! may improve timing + call cpu_time(t1) + ns=ispec(n_species,n_species) !number of non-redundant species pairs + xmax=sqrt(e_max) !cut off at exp(-xmax^2) + ! find kperp_max in the system + ! 1st local: + kperp_bmag_max=0 + if (i_proc==0) then + do itor=nt1,nt2 + print 9,"itor=",itor + do i=1,nc +9 format ("init_collision_landau: ",A,I0,5(A,G24.16E3)) + print 9,'kperp(',i,')=',k_perp(i,itor)/bmag(it_c(i))*rho,"bmag(it)=",bmag(it_c(i)) + end do + enddo + end if + do itor=nt1,nt2 + do i=1,n_theta + do j=1,n_radial + kperp_bmag=k_perp(ic_c(j,i),itor)/bmag(i) + ! global array k_perp(1 ... nc,nt1 ... nt2) nc=n_theta*n_radial + kperp_bmag_max=max(kperp_bmag_max,kperp_bmag) + end do + end do + end do + ! kperp_bmag_max is not completely global, there is still the n dependence. + ! we need to maximize over the toroidal mode numbers: + call MPI_ALLREDUCE(MPI_IN_PLACE,kperp_bmag_max,1,MPI_REAL8,MPI_MAX,MPI_COMM_WORLD,ierror) + rhomax=maxval(abs(rho_spec([(i,i=1,n_species)])))*xmax + kperprhomax=kperp_bmag_max*rhomax + if (verbose>0 .and. i_proc==0) print 6,'using kperprhomax=',kperprhomax + + ! first calculate the required polynomials + nmaxpoly=n_energy+est_extradegree(kperprhomax,eps) + lmax=n_xi+est_mpullback(kperprhomax,eps=eps) + lmax=lmax+mod(lmax,2) + if (verbose>1 .and. i_proc==0) print 7,'using nmaxpoly',nmaxpoly,'lmax=',lmax + + lmax_field=lmax + if (collision_field_max_l>=-1) lmax_field=min(lmax_field,collision_field_max_l+1) + lmax_test=lmax + if (collision_test_max_l>=-1) lmax_test=min(lmax_test,collision_test_max_l+1) + allocate(a1(nmaxpoly+1),b1(nmaxpoly+1),c1(nmaxpoly+1),a(nmaxpoly+1),bsq(nmaxpoly+1),lg(nmaxpoly+1)) + call half_hermite_norm(nmaxpoly+1,0.,xmax,1.,alpha_poly,a1,b1,c1,a,bsq,lg) + allocate(sp(nmaxpoly),sw(nmaxpoly),projsteen(nmaxpoly,nmaxpoly)) + + !dstevr: liwork>=1,10*nmaxpoly + liwork=10*nmaxpoly + !dstevr: lwork >=1,20*nmaxpoly + lwork=20*nmaxpoly + !dstevr: isuppz: dim>=2*nmaxpoly + + !dstein: ifail: dim>=nmaxpoly + !dstein: work: dim>=5*nmaxpoly + !dstein: iwork: dim>=nmaxpoly + + !later need for dposvx below: + !lowest dimensions: work(3*n_energy), iwork(n) + + allocate(iwork(liwork),work(lwork),isuppz(2*nmaxpoly),ifail(nmaxpoly)) + call ieee_set_flag(ieee_all,.false.) + call ieee_get_status(ieee_status) + call ieee_set_halting_mode(ieee_invalid,.false.) + call ieee_set_halting_mode(ieee_divide_by_zero,.false.) + call dstevr('N','A',nmaxpoly,a(1:nmaxpoly),bsq(2:nmaxpoly),0.,0.,0,0,0.,m,sp,& + projsteen,nmaxpoly,isuppz,work,lwork,iwork,liwork,info) + if (info/=0 .or. m/=nmaxpoly) then + if (i_proc==0) print '("init_collision_landau: ",A,9(I3))','dstevr error, here is info,m,nmaxpol',info,m,nmaxpoly + stop + end if + call dstein(nmaxpoly,a(1:nmaxpoly),bsq(2:nmaxpoly),nmaxpoly,sp,(/(1,i=1,nmaxpoly)/),& + (/(nmaxpoly,i=1,nmaxpoly)/),projsteen,nmaxpoly,work ,iwork,ifail,info) + call ieee_set_status(ieee_status) + if (info/=0) then + if (i_proc==0) print '("init_collision_landau: ",A,2I3," ",A,I3)','dstein error, here is i,info',i,info,'and ifail',ifail + stop + end if + do i=1,nmaxpoly + if (projsteen(1,i)<0) projsteen(:,i)=-projsteen(:,i) + end do + sw=projsteen(1,:)**2/c1(1)**2 ! Steen weights + + if (collision_test_mode==1 .or. collision_model==7) then + ! Calculate representation of the monomials in terms of the + ! fine grained half_hermite polynomials. + ! This is useful for moment calculations, needed for Sugama and diagnostics. + ! Not more than 3 moments are actually needed at present. + allocate(polyrep(nmaxpoly,nmaxpoly)) + polyrep=0 + i=1 + polyrep(i,1)=c1(1) + do i=2,nmaxpoly + polyrep(i,2:i)=c1(i)*polyrep(i-1,1:i-1) + polyrep(i,1:i-1)=polyrep(i,1:i-1)-polyrep(i-1,1:i-1)*a1(i) + if (i>2) polyrep(i,1:i-2)=polyrep(i,1:i-2)-polyrep(i-2,1:i-2)*b1(i) + enddo + ! polyrep(i,j) significant for j<=i otherwise zero. + ! invert Lower triangular matrix, diagonal is Non-unit i.e. significant + call dtrtri('L','N',nmaxpoly,polyrep,nmaxpoly,info) + if (info /=0) then + print 7,'dtrtriinfo',info + stop + end if + end if + + ngauss=max(70,ceiling(15*xmax))+nmaxpoly+ceiling(alpha_poly/2) ! this is a good empirical value for sqrt(2)*xmax +7 format ("init_collision_landau: ",9(A,I0,' ')) + if (i_proc==0 .and. verbose>1) print 7,'using ng2=',ng2,'and ngauss=',ngauss + allocate(gw(ngauss),gp(ngauss),gw2(ng2),gp2(ng2)) + call gauss_legendre(0.,1.,gp,gw,ngauss) + call gauss_legendre(0.,1.,gp2,gw2,ng2) + + ! now we go for the real space Landauop collision matrix (Galerkin coefficients) + allocate(Landauop(nmaxpoly,nmaxpoly,lmax,ns)) + if (KPERP_FIELD_OFF) allocate(dk_self_field(nmaxpoly,nmaxpoly,lmax,n_species)) + allocate(lor_self(nmaxpoly,nmaxpoly),dif_self(nmaxpoly,nmaxpoly),& + lor(nmaxpoly,nmaxpoly),dif(nmaxpoly,nmaxpoly),& + lor1(nmaxpoly,nmaxpoly),dif1(nmaxpoly,nmaxpoly),field(nmaxpoly,nmaxpoly,lmax)) + t1t2flag=maxval(abs(temp(1:n_species)-temp(1)))>0 ! need to take different T into account. + if (t1t2flag) then + allocate(t1t2(nmaxpoly,nmaxpoly),t1t21(nmaxpoly,nmaxpoly),field2(nmaxpoly,nmaxpoly,lmax)) + end if + ! first the self-collision matrices + ! (obviously could save here, since these are symmetric) + + call cpu_time(t2) + t(6)=t2-t1 + t1=t2 + + call gentestkernel(nmaxpoly,a1,b1,c1,xmax,1.,gp,gw,ngauss,lor_self,dif_self) + if (collision_model==7) then + ! calc. mock up Sugama field op. + field=0 + ! cancel l=2 (lphys=1) v^1 and l=1 (lphys=0) v^2 polynomial. + if (.not. DIFF_OFF .and. lmax_field>=1) then + l=1;k=3 + do i=1,nmaxpoly + field(:,i,l)=matmul(dif_self,polyrep(k,:))*dot_product(polyrep(k,:),dif_self(:,i))& + /dot_product(polyrep(k,:),matmul(dif_self,polyrep(k,:))) + end do + end if + if (lmax_field>=2) then + l=2;k=2 + do i=1,nmaxpoly + field(:,i,l)=matmul(dif_self+lor_self*l*(l-1),polyrep(k,:))*& + dot_product(polyrep(k,:),dif_self(:,i)+lor_self(:,i)*l*(l-1))& + /dot_product(polyrep(k,:),matmul(dif_self+lor_self*l*(l-1),polyrep(k,:))) + end do + end if + else + if (lmax_field>=1) & + call genfieldkernel(nmaxpoly,lmax_field,a1,b1,c1,xmax,1.,1.,gp,gw,ngauss,gp2,gw2,ng2,field) + field(:,:,lmax_field+1:lmax)=0 + end if + ialoop: do ia=1,n_species + is=ispec(ia,ia) + normalization=z(ia)**4*dens(ia)**2/& + (sqrt(mass(ia))*temp(ia)**1.5) !*normcol <- this we save for later. + lor=lor_self*normalization + dif=dif_self*normalization + if (t1t2flag) t1t2=0 + ibloop: do ib=1,n_species + if (ib==ia) cycle + t1t2ratio=temp(ia)/temp(ib) + beta=sqrt(mass(ib)/mass(ia)*t1t2ratio) + testnormalization=(z(ia)*z(ib))**2*dens(ia)*dens(ib)*mass(ib)/& + (mass(ia)**1.5*sqrt(temp(ia))*temp(ib)) !*normcol <- this we save for later. + ! ^^^ cgyrolandauop.tex Eq. (82) before "Analogously ..." + if (temp(ia)==temp(ib)) then + call gentestkernel(nmaxpoly,a1,b1,c1,xmax,beta,gp,gw,ngauss,lor1,dif1) + else + call gentestkernel(nmaxpoly,a1,b1,c1,xmax,beta,gp,gw,ngauss,lor1,dif1,t1t2_int=t1t21) + dif1=dif1+(t1t2ratio-1)*t1t21 + end if + lor=lor+testnormalization*lor1 + dif=dif+testnormalization*dif1 + if (collision_model==7) then + ! calc. mock up Sugama field op. + ! left out for the moment t1t2ratio !!!! + ! cancel l=2 (lphys=1) v^1 and l=1 (lphys=0) v^2 polynomial. + ! at this point for every pair a,b with b>a we first have (ia,ib)=(b,a) and then (a,b) + if (ib>ia) then + Landauop(:,:,:,ispec(ia,ib))=0 + Landauop(:,:,:,ispec(ib,ia))=0 + end if + if (.not. DIFF_OFF .and. lmax_field>=1) then + l=1;k=3 + if (ib>ia) then !first half + Landauop(:,1,l,ispec(ia,ib))=-matmul(dif1,polyrep(k,:)-polyrep(1,:)*1.5)/& + dot_product(polyrep(k,:)-polyrep(1,:)*1.5,matmul(dif1,polyrep(k,:)-polyrep(1,:)*1.5))& + /(dens(ia)*temp(ia)) + Landauop(1,:,l,ispec(ib,ia))=-matmul(polyrep(k,:)-polyrep(1,:)*1.5,dif1(:,:))& + *testnormalization*dens(ia)*temp(ia) + else + do i=nmaxpoly,1,-1 + Landauop(i,:,l,ispec(ia,ib))=Landauop(1,:,l,ispec(ia& + ,ib))*dot_product(dif1(i,:),polyrep(k,:)-polyrep(1& + ,:)*1.5)/ dot_product(polyrep(k,:)-polyrep(1,:)& + *1.5,matmul(dif1,polyrep(k,:)-polyrep(1,:)*1.5)) & + /(dens(ia)*temp(ia)) + Landauop(:,i,l,ispec(ib,ia))=dot_product(polyrep(k,:)& + -polyrep(1,:)*1.5,dif1(:,i))*Landauop(:,1,l& + ,ispec(ib,ia)) *testnormalization*dens(ia)*temp(ia) + end do + end if + end if + if (.not. DIFF_OFF .and. lmax_field>=2) then + l=2;k=2 + if (ib>ia) then !first half + Landauop(:,1,l,ispec(ia,ib))=-matmul(dif1+lor1*l*(l-1),polyrep(k,:))/& + dot_product(polyrep(k,:),matmul(dif1+lor1*l*(l-1),polyrep(k,:)))& + /(dens(ia)*sqrt(temp(ia)*mass(ia))) + Landauop(1,:,l,ispec(ib,ia))=-matmul(polyrep(k,:),dif1+lor1*l*(l-1))& + *testnormalization*dens(ia)*sqrt(temp(ia)*mass(ia)) + else + do i=nmaxpoly,1,-1 + Landauop(i,:,l,ispec(ia,ib))=Landauop(1,:,l,ispec(ia,ib))*& + dot_product(dif1(i,:)+lor1(i,:)*l*(l-1),polyrep(k,:))/& + dot_product(polyrep(k,:),matmul(dif1+lor1*l*(l-1),polyrep(k,:)))& + /(dens(ia)*sqrt(temp(ia)*mass(ia))) + Landauop(:,i,l,ispec(ib,ia))=dot_product(polyrep(k,:),dif1(:,i)+lor1(:,i)*l*(l-1))& + *Landauop(:,1,l,ispec(ib,ia))& + *testnormalization*dens(ia)*sqrt(temp(ia)*mass(ia)) + end do + end if + end if + end if + end do ibloop + Landauop(:,:,lmax_test+1:,is)=0 + do l=1,lmax_test + Landauop(:,:,l,is)=((l-1)*l)*lor+dif + end do + if (KPERP_FIELD_OFF) then + dk_self_field(:,:,:lmax_field,ia)=-field(:,:,:lmax_field)*normalization + dk_self_field(:,:,lmax_field+1:,ia)=0 + else + Landauop(:,:,:lmax_field,is)=Landauop(:,:,:lmax_field,is)-field(:,:,:lmax_field)*normalization + end if + end do ialoop + if (collision_model==7) then +!!$ ! **Now** normalize interspecies Sugama field terms +!!$ do ia=1,n_species +!!$ do ib=1,n_species +!!$ if (ib==ia) cycle +!!$ l=1 +!!$ Landauop(:,:,l,ispec(ia,ib))=Landauop(:,:,l,ispec(ia,ib))& +!!$ /(temp(ia)*dens(ia))*temp(ib)*dens(ib) +!!$ l=2 +!!$ Landauop(:,:,l,ispec(ia,ib))=Landauop(:,:,l,ispec(ia,ib))& +!!$ /(sqrt(temp(ia)*mass(ia))*dens(ia))*sqrt(temp(ib)*mass(ib))*dens(ib) +!!$ end do +!!$ end do + !Now check momentum and energy conservation (purely for diagnostics) + if (i_proc==0) then + allocate(loss(nmaxpoly),dist(nmaxpoly)) + l=1;k=3 !energy + do ib=1,n_species + dist=0 + do ia=1,n_species + if (ib==ia) then + loss=matmul(polyrep(k,:),Landauop(:,:,l,ispec(ia,ib)))*temp(ia)*dens(ia) + else + dist=dist+matmul(polyrep(k,:),Landauop(:,:,l,ispec(ia,ib)))*temp(ia)*dens(ia) + end if + end do +6 format ("init_collision_landau: ",A,5(G24.16)) + + print 9,'spec',ib,' energy:' + print 6,'loss',loss + print 6,'dist',dist + end do + l=2;k=2 !momentum + do ib=1,n_species + dist=0 + do ia=1,n_species + if (ib==ia) then + loss=matmul(polyrep(k,:),Landauop(:,:,l,ispec(ia,ib)))*& + sqrt(temp(ia)*mass(ia))*dens(ia) + else + dist=dist+matmul(polyrep(k,:),Landauop(:,:,l,ispec(ia,ib)))*& + sqrt(temp(ia)*mass(ia))*dens(ia) + end if + end do + print 9,'spec',ib,' momentum:' + print 6,'loss',loss + print 6,'dist',dist + end do + deallocate(loss,dist) + end if + end if + ! Now the interspecies collision matrices + call cpu_time(t2) + t(5)=t2-t1 + t1=t2 + if (collision_model==6) then + do ib=1,n_species + do ia=1,n_species + if (ia==ib) cycle + is=ispec(ia,ib) + is1=ispec(ib,ia) + t1t2ratio=temp(ia)/temp(ib) + beta=sqrt(mass(ib)/mass(ia)*t1t2ratio) + fieldnormalization=(z(ia)*z(ib))**2*dens(ia)*dens(ib)/& + (sqrt(mass(ia)*temp(ia))*temp(ib)) !*normcol <- this we save for later. + ! fieldnormalization for a<->b is this /(beta*t1t2ratio) + fieldnormalization_ba=fieldnormalization/(beta*t1t2ratio) + Ta_eq_Tb: if (temp(ia)==temp(ib)) then +!!$ if (ia>ib .or. (i_proc==0 .and. verbose>4)) then + if (ia>ib) then + if (lmax_field>=1) then + call genfieldkernel(nmaxpoly,lmax_field,a1,b1,c1,xmax,beta,1.,& + gp,gw,ngauss,gp2,gw2,ng2,Landauop(:,:,:,is)) + call dscal(nmaxpoly**2*lmax_field,-fieldnormalization,Landauop(:,:,:,is),1) + end if + Landauop(:,:,lmax_field+1:,is)=0 + end if +!!$ if (ia>ib .and. .not. (i_proc==0 .and. verbose>4)) then + if (ia>ib) then + do l=1,lmax + ! in this case Landauop is self-adjoint, i.e. for given l and ia and ib + ! Landauop=Landauop^T +#ifdef DIMATCOPY +#ifdef __INTEL_COMPILER + !use MKL + call mkl_domatcopy('c','t',nmaxpoly,nmaxpoly,1.,Landauop(:,:,l,is),& + nmaxpoly,Landauop(:,:,l,is1),nmaxpoly) +#else + !use openBLAS + call domatcopy('c','t',nmaxpoly,nmaxpoly,1.,Landauop(:,:,l,is),& + nmaxpoly,Landauop(:,:,l,is1),nmaxpoly) +#endif +#else + !alternative to domatcopy + do i=1,nmaxpoly + do j=1,nmaxpoly + Landauop(j,i,l,is1)=Landauop(i,j,l,is) + end do + end do +#endif + end do + end if + !Now check self-adjointness, when possible: + if (verbose>4 .and. i_proc==0 .and. ia1e-15) then +4 format("init_collision_landau: ",A,5(I0," "),A,2(I0," "),A,3G24.16E3) + print 4,'SA-error',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is),Landauop(j,i,l,is1) + elseif (d>md) then + md=d + print 4,'so far max SA deviation',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is),Landauop(j,i,l,is1),d + end if + end do + end do + end do + end if + else if (ia>ib) then ! Ta /= Tb + ! in this case genfieldkernel calculates ab and ba field simultaneously + if (lmax_field>=1) then + call genfieldkernel(nmaxpoly,lmax_field,a1,b1,c1,xmax,beta,t1t2ratio,& + gp,gw,ngauss,gp2,gw2,ng2,Landauop(:,:,:,is),intkernel2=Landauop(:,:,:,is1)) + end if + Landauop(:,:,lmax_field+1:,is)=0 + Landauop(:,:,lmax_field+1:,is1)=0 + if (verbose>4 .and. i_proc==0 .and. lmax_field>=1) then + print '("init_collision_landau: ",2(A,I0),2(A,G24.16))',& + 'Checking symmetries of field kernel at ia=',ia,' ib=',ib,' Ta',temp(ia),' Tb',temp(ib) + call genfieldkernel(nmaxpoly,lmax_field,a1,b1,c1,xmax,1./beta,1./t1t2ratio,& + gp,gw,ngauss,gp2,gw2,ng2,field,intkernel2=field2) + md=-1 + md1=-1 + do l=1,lmax_field + do i=1,nmaxpoly + do j=1,nmaxpoly + d=abs(Landauop(i,j,l,is)-field2(i,j,l)) + if (d>1e-15) then + print 4,'symm-error',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is),field2(i,j,l),d + elseif (d>md) then + md=d + print 4,'so far max symm error',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is),field2(i,j,l),d + end if + d1=abs(Landauop(i,j,l,is1)-field(i,j,l)) + if (d1>1e-15) then + print 4,'symm-error (2)',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is1),field(i,j,l),d1 + elseif (d1>md1) then + md1=d1 + print 4,'so far max symm error (2)',i,j,l,ia,ib,'is',is,is1,& + 'cm',Landauop(i,j,l,is1),field(i,j,l),d1 + end if + end do + end do + end do + end if + + call dscal(nmaxpoly**2*lmax_field,-fieldnormalization,Landauop(:,:,:,is),1) + call dscal(nmaxpoly**2*lmax_field,-fieldnormalization_ba,Landauop(:,:,:,is1),1) + + end if Ta_eq_Tb + end do + end do + end if + ! Final touch to the normalization: (cgyrolandauop.tex eq. 122,124) + call cpu_time(t2) + t(4)=t2-t1 + t1=t2 + call dscal(nmaxpoly**2*lmax*ns,normcolcgyro*nu_ee*sqrt(mass_ele)*temp_ele**1.5/dens_ele,Landauop,1) + if (KPERP_FIELD_OFF) & + call dscal(nmaxpoly**2*lmax*n_species,normcolcgyro*nu_ee*sqrt(mass_ele)*temp_ele**1.5/dens_ele,dk_self_field,1) + ! Got the Landauop + ! The only thing left is its gyro-transformation. + ! now need to find out how many Chebyshev points for k we need to compute for each combination of species. + if (i_proc==0) then + print 6,'landauop(1,1,2,1)',Landauop(1,1,2,1) + end if + call cpu_time(t2) + t(1)=t2-t1 + t1=t2 + + allocate(nk(n_species,n_species)) + do ia=1,n_species + do ib=1,n_species + nk(ia,ib)=est_k_sampling(kperp_bmag_max*xmax*& + (abs(rho_spec(ia))+abs(rho_spec(ib))),eps) + if (i_proc==0 .and. verbose>0) then + print 7,'number Chebyshev k-points nk(',ia,',',ib,')=',nk(ia,ib) + end if + end do + end do + + ! Now distribute the species pairs, the k, the l, and the n onto the processors + ! + ! Noting that for equal temperatures, we have self-adjointness. + ! Higher k require more computer time. + ! In particular: A measure is nmaxpoly**2*mpullback*lmax + ! which for large krho is propto krho**4. + ! nmaxpoly=n_energy+est_extradegree(kperprho,eps) + ! lmax=n_xi+est_mpullback(kperprho,eps=eps) + ! mpullback=est_mpullback(kperprho,eps=eps) + ! Then one should not distribute over k but rather over + ! n and l. + ! and only as a last resort over k in a sort of round robin fashion. + ! problem is: for every k we'd need a different set of + ! - associated Legendre polys + ! - Steen polys + ! - would hate this. + ! So (at first) *only* distribute over k, but using a cost estimate to achieve + ! balanced distribution. We use the multiplication with the collision matrix + ! in the inner loop as cost estimate. + nkmax=maxval(nk) + allocate(gtcost(nkmax,n_species,n_species),kperp_arr(nkmax,n_species,n_species)) + do ia=1,n_species + do ib=1,n_species + do ik=1,nk(ia,ib) + !chebyshev points to be used for species ia in this pairing (ia,ib): + kperp_arr(ik,ia,ib)=kperp_bmag_max*rho_spec(ia)*sin(.5*pi1*(ik-.5)/nk(ia,ib))**2 + end do + end do + end do + gtvb=0 + gtcost=0 + do ia=1,n_species + do ib=1,n_species + if (ia>=ib .or. temp(ia)/=temp(ib)) then + do ik=1,nk(ia,ib) + lneeded=n_xi+est_mpullback(kperp_arr(ik,ia,ib)*xmax,kboundb=kperp_arr(ik,ib,ia)*xmax,eps=eps) + ! npolyneeded=n_energy+est_extradegree(kbound=max(kperp_arr(ik,ia,ib),kperp_arr(ik,ib,ia))*xmax,eps=eps) + ! for simplicity, always the maximum available Steen(-like) polys are used. + gtcost(ik,ia,ib)=(lneeded-n_xi+1)*lneeded !*nmaxpoly**2 !only need relative estimate + if (gtcost(ik,ia,ib)==0) then + print '("init_collision_landau: ",A,I0,A,3I3)','ERROR iproc',i_proc,' cost=0, (ik,ia,ib)=',ik,ia,ib + stop + end if + if (i_proc==0 .and. verbose>0) then + print '("init_collision_landau: ",3(A,I0),A,G24.16E3)',& + 'cost estimate for ia=',ia,' ib=',ib,' ik=',ik,' is',gtcost(ik,ia,ib) + end if + if (i_proc==0 .and. gtcost(ik,ia,ib)==0) then + print 7,'WARNING: gtcost for ia=',ia,'ib=',ib,'ik=',ik,'is zero!' + end if + end do + end if + end do + end do + if (i_proc==0 .and. verbose>0) gtvb=1 + + ! Now distribute the ia,ib,k *fairly* among the processors, and + ! when Ta=Tb only do the ia>=ib case. + ! I.e. minimize max. cost on single processor. + totalcost=sum(gtcost) + !sort gtcost: + allocate(sortidx(n_species**2*nkmax)) + sortidx=[(i,i=1,n_species**2*nkmax)] + if (i_proc==0) print 7,'qsort:' + call qsort(sortidx,gtcost,n_species**2*nkmax) +!!$ if (i_proc==0) then +!!$ do i=1,n_species**2*nkmax +!!$ idx=sortidx(i)-1 +!!$ ik=mod(idx,nkmax)+1 +!!$ idx=idx/nkmax +!!$ ia=mod(idx,n_species)+1 +!!$ idx=idx/n_species +!!$ ib=idx+1 +!!$ print 1,'i',i,sortidx(i),'cost',gtcost(ik,ia,ib) +!!$ end do +!!$ end if + ! Now distribute the work on the processors in a simple heuristic form. + allocate(load(n_proc),proc(nkmax,n_species,n_species)) + load=0 + proc=0 + allocate(gyrocolmat(n_energy,n_xi,n_energy,n_xi,n_species,n_species,nkmax)) + ! could be optimized + gyrocolmat=1e300 + + min_load=0 + max_load=0 + do i=1,n_species**2*nkmax + idx=sortidx(i)-1 + ik=mod(idx,nkmax)+1 + idx=idx/nkmax + ia=mod(idx,n_species)+1 + idx=idx/n_species + ib=idx+1 + cost=gtcost(ik,ia,ib) + if (cost==0) exit !done. + !if (i_proc==0) print *,'init_collision_landau: i=',i,sortidx(i),ik,ia,ib,cost + do j=1,n_proc + if (load(j)==min_load .or. load(j)+cost<=max_load) then + if (i_proc==0) then + print '("init_collision_landau: ",A,3I3,2(" ",A,I0))','assigning (ik,ia,ib)=',ik,ia,ib,'to proc',j-1,'cost',cost + end if + load(j)=load(j)+cost + proc(ik,ia,ib)=j + max_load=max(max_load,load(j)) + min_load=minval(load) + exit + end if + end do + enddo + call cpu_time(t2) + t(2)=t2-t1 + call cpu_time(t1) + do i=1,n_species**2*nkmax + idx=sortidx(i)-1 + ik=mod(idx,nkmax)+1 + idx=idx/nkmax + ia=mod(idx,n_species)+1 + idx=idx/n_species + ib=idx+1 + if (proc(ik,ia,ib)==0) exit + if (i_proc==proc(ik,ia,ib)-1) then + ! NOTE: Somehow writing these routines the notion of a and b species flipped. + ! in gyrotrafo the a species are the source of the perturbation, and the b species + ! the recipient. But b is on the left of the operator and a on the right. + ! in the landauoperator here it is oposite. + if (.not. KPERP_FIELD_OFF .or. ia==ib) then + call gyrotrafo(gyrocolmat(:,:,:,:,ia,ib,ik),n_energy,n_xi,& + Landauop(:,:,:,ispec(ia,ib)),nmaxpoly,lmax,& + projsteen,sp,nmaxpoly,xmax,& + kperp_arr(ik,ib,ia),kperp_arr(ik,ia,ib),eps=eps) + end if + if (KPERP_FIELD_OFF) then + if (ia==ib) then + do l=1,n_xi + gyrocolmat(:,l,:,l,ia,ia,ik)=gyrocolmat(:,l,:,l,ia,ia,ik)+& + dk_self_field(:n_energy,:n_energy,l,ia) + end do + else + gyrocolmat(:,:,:,:,ia,ib,ik)=0 + do l=1,n_xi + gyrocolmat(:,l,:,l,ia,ib,ik)=Landauop(:n_energy,:n_energy,l,ispec(ia,ib)) + end do + end if + end if + end if + enddo + call cpu_time(t2) + t(3)=t2-t1 + t1=t2 + ! Now do the fill in of potentially left out symmetric halfs + do i=1,n_species**2*nkmax + idx=sortidx(i)-1 + ik=mod(idx,nkmax)+1 + idx=idx/nkmax + ia=mod(idx,n_species)+1 + idx=idx/n_species + ib=idx+1 + if (proc(ik,ia,ib)==0) exit + if (i_proc==proc(ik,ia,ib)-1 .and. ia>ib .and. temp(ia)==temp(ib)) then +#ifdef DIMATCOPY +#ifdef __INTEL_COMPILER + !use MKL + call mkl_domatcopy('c','t',n_xi*n_energy,n_xi*n_energy,1.,& + gyrocolmat(:,:,:,:,ia,ib,ik),n_xi*n_energy,& + gyrocolmat(:,:,:,:,ib,ia,ik),n_xi*n_energy) +#else + !use openBLAS + call domatcopy('c','t',n_xi*n_energy,n_xi*n_energy,1.,& + gyrocolmat(:,:,:,:,ia,ib,ik),n_xi*n_energy,& + gyrocolmat(:,:,:,:,ib,ia,ik),n_xi*n_energy) +#endif +#else + !alternative to domatcopy + do k=1,n_xi + do l=1,n_energy + do j=1,n_xi + do m=1,n_energy + gyrocolmat(m,j,l,k,ib,ia,ik)=gyrocolmat(l,k,m,j,ia,ib,ik) + end do + end do + end do + end do +#endif + end if + end do + call cpu_time(t2) + t(9)=t2-t1 + t1=t2 + ! next: transform from polynomial into vertex spaced for angular and + ! radial direction + allocate(projleg(n_xi,n_xi),L2xi(n_xi,n_xi),xi2L(n_xi,n_xi)) +!!$ if (i_proc==0) gtvb=5 + call calc_projleg(projleg,n_xi,n_xi,xi,2*w_xi) !interval=[-1,1] so w_xi*=2 +!!$ if (i_proc==0) gtvb=1 + do i=1,n_xi + L2xi(i,:)=projleg(i,:)/sqrt(w_xi(i)) + xi2L(:,i)=projleg(i,:)*sqrt(w_xi(i)) + end do + if (verbose>2 .and. i_proc==0) then + allocate(id(n_xi,n_xi)) + call dgemm('N','N',n_xi,n_xi,n_xi,1.,xi2L,n_xi,L2xi,n_xi,0.& + ,id,n_xi) + devi=0 + do i=1,n_xi + do j=1,n_xi + if (i==j) then + d=abs(id(i,j)-1) + else + d=abs(id(i,j)) + end if + if (d>devi) then + print '("init_collision_landau: ",A,G24.16E3,A,2I4,A,G23.16E3)',& + 'so far max xi-mat deviation',d,' at i,j',i,j,' mat=',id(i,j) + devi=d + end if + end do + end do + deallocate(id) + end if + ! do the same thing from above again for the lesser n_energy vertices: + deallocate(projsteen) + + allocate(projsteen(n_energy,n_energy)) + call ieee_get_status(ieee_status) + call ieee_set_halting_mode(ieee_invalid,.false.) + call ieee_set_halting_mode(ieee_divide_by_zero,.false.) + call dstevr('N','A',n_energy,a(1:n_energy),bsq(2:n_energy),0.,0.,0,0,0.,m,sp,& + projsteen,n_energy,isuppz,work,lwork,iwork,liwork,info) + if (info/=0 .or. m/=n_energy) then + if (i_proc==0) print 4,'dstevr error, here is info,m,nmaxpol',info,m,n_energy + stop + end if + call dstein(n_energy,a(1:n_energy),bsq(2:n_energy),n_energy,sp,(/(1,i=1,n_energy)/),& + (/(n_energy,i=1,n_energy)/),projsteen,n_energy,work ,iwork,ifail,info) + if (info/=0) then + if (i_proc==0) print '(A,2I0," ",A,I0)','dstein error, here is i,info',i,info,'and ifail',ifail + stop + end if + call ieee_set_status(ieee_status) + do i=1,n_energy + if (projsteen(1,i)<0) projsteen(:,i)=-projsteen(:,i) + end do + !sw=projsteen(1,:)**2/c1(1)**2 ! Steen weights + ! now polycoeff=projsteen*vertexcoeff*sqrt(weights) + ! vertexcoeff*sqrt(weights)=projsteen^T*polycoeff. + allocate(v2poly(n_energy,n_energy),poly2v(n_energy,n_energy)) + do i=1,n_energy + v2poly(:,i)=projsteen(:,i)*(projsteen(1,i)/c1(1)) + poly2v(:,i)=projsteen(:,i)/(projsteen(1,i)/c1(1)) + ! ^^ purposely calculating the "transposed" matrix + end do + ! now polycoeff=v2poly*vertexcoeff + ! vertexcoeff=poly2v^T*polycoeff. + if (verbose>2 .and. i_proc==0) then + allocate(id(n_energy,n_energy)) + call dgemm('T','N',n_energy,n_energy,n_energy,1.,poly2v,n_energy,v2poly,n_energy,0.& + ,id,n_energy) + devi=0 + do i=1,n_energy + do j=1,n_energy + if (i==j) then + d=abs(id(i,j)-1) + else + d=abs(id(i,j)) + end if + if (d>devi) then + print '("init_collision_landau: ",A,G24.16,A,2I4,A,G23.16E3)',& + 'so far max "e"-mat deviation',d,' at i,j',i,j,' mat=',id(i,j) + devi=d + end if + end do + end do + deallocate(id) + end if + call ieee_set_flag(ieee_all,.false.) + + allocate(energymatrix(n_energy,n_energy)) + call genenergymatrix(n_energy,a1,b1,c1,xmax,gp,gw,ngauss,energymatrix) + ! polycoeff=emat^-1*Landauop. ; vertexcoeff=poly2v^T*emat^-1*Landauop + ! ==> Landau2v=poly2v^T*emat^-1=(emat^-1*poly2v)^T + allocate(Landau2v(n_energy,n_energy)) + allocate(AF(n_energy,n_energy),Sc(n_energy),ferr(n_energy),& + berr(n_energy)) + ! lowest dimensions: work(3*n_energy), iwork(n_energy) + ! solve for vertex projection matrix + allocate(pv(n_energy,n_energy),em(n_energy,n_energy)) + em=energymatrix + pv=poly2v + call dposvx('E','U', n_energy,n_energy,em,n_energy, AF,n_energy,& + EQUED, Sc, pv,n_energy,Landau2v,n_energy,& + RCOND, FERR, BERR, WORK, IWORK, INFO) + ! note: energymatrix, poly2v are potentially destroyed by this call. + if (verbose>1 .and. i_proc==0) print 6,'energy matrix dposvx rcond=',rcond + if (info/=0) then + print 7,'dposvx info=',info,'i_proc',i_proc + stop + end if + deallocate(AF,Sc,ferr,berr,pv,em) + ! *** Note that Landau2v needs to be transposed upon application. + allocate(m1(n_energy,n_xi,n_energy,n_xi),m2(n_energy,n_xi,n_energy,n_xi)) + do i=1,n_species**2*nkmax + idx=sortidx(i)-1 + ik=mod(idx,nkmax)+1 + idx=idx/nkmax + ia=mod(idx,n_species)+1 + idx=idx/n_species + ib=idx+1 + if (proc(ik,ia,ib)==0) exit + if (i_proc==proc(ik,ia,ib)-1) then + call dgemm('T','N',n_energy,n_xi**2*n_energy,n_energy,1.,Landau2v& + ,n_energy,gyrocolmat(:,:,:,:,ia,ib,ik),n_energy,0.,& + m1,n_energy) + do k=1,n_xi + do j=1,n_energy + call dgemm('N','T',n_energy,n_xi,n_xi,1.,m1(:,:,j,k),n_energy,& + L2xi,n_xi,0.,m2(:,:,j,k),n_energy) + end do + end do + do j=1,n_xi + call dgemm('N','N',n_xi*n_energy,n_energy,n_energy,1.,m2(:,:,:& + ,j),n_xi*n_energy,v2poly,n_energy,0.,& + m1(:,:,:,j),n_xi*n_energy) + end do + call dgemm('N','N',n_xi*n_energy**2,n_xi,n_xi,1.,m1,n_xi*n_energy& + **2,xi2L,n_xi,0.,gyrocolmat(:,:,:,:,ia,ib,ik),n_xi*n_energy**2) + if (ia>ib .and. temp(ia)==temp(ib)) then + call dgemm('T','N',n_energy,n_xi**2*n_energy,n_energy,1.,Landau2v& + ,n_energy,gyrocolmat(:,:,:,:,ib,ia,ik),n_energy,0.,& + m1,n_energy) + do k=1,n_xi + do j=1,n_energy + call dgemm('N','T',n_energy,n_xi,n_xi,1.,m1(:,:,j,k),n_energy,& + L2xi,n_xi,0.,m2(:,:,j,k),n_energy) + end do + end do + do j=1,n_xi + call dgemm('N','N',n_xi*n_energy,n_energy,n_energy,1.,m2(:,:,:& + ,j),n_xi*n_energy,v2poly,n_energy,0.,& + m1(:,:,:,j),n_xi*n_energy) + end do + call dgemm('N','N',n_xi*n_energy**2,n_xi,n_xi,1.,m1,n_xi*n_energy& + **2,xi2L,n_xi,0.,gyrocolmat(:,:,:,:,ib,ia,ik),n_xi*n_energy**2) + end if + end if + enddo + !deallocate(m1) + deallocate(m2) + call cpu_time(t2) + t(7)=t2-t1 + if (i_proc==0) then + print 7,'pre_scatter timing:' + do i=1,n_proc + if (i>1) then + call MPI_Recv(t,11,MPI_REAL8,i-1,i-1,MPI_COMM_WORLD,status,ierror) + end if +5 format("init_collision_landau: ",A,I0,A,7G24.16E3,A,I0,A,G24.16E3) + print 5,'i_proc=',i-1,' took',t(1:7),' load ',load(i),' rel',t(3)/load(i) + end do + else + call MPI_Send(t,11,MPI_REAL8,0,i_proc,MPI_COMM_WORLD,ierror) + end if + call cpu_time(t1) + ! Now do the scatter + + do i=1,n_species**2*nkmax + idx=sortidx(i)-1 + ik=mod(idx,nkmax)+1 + idx=idx/nkmax + ia=mod(idx,n_species)+1 + idx=idx/n_species + ib=idx+1 + if (proc(ik,ia,ib)/=0) then +!!$ do j=1,n_proc +!!$ call MPI_BARRIER(MPI_COMM_WORLD,ierror) +!!$! if (i_proc==0 .and. verbose>100) then +!!$ if (i_proc==j-1) print *,'bcasting (ik,ia,ib,proc)=',ik,ia,ib,proc(ik,ia,ib)-1,'ip',i_proc +!!$ ! end if +!!$ call MPI_BARRIER(MPI_COMM_WORLD,ierror) +!!$ end do + call MPI_Bcast(gyrocolmat(:,:,:,:,ia,ib,ik),n_xi**2*n_energy**2,& + MPI_REAL8,proc(ik,ia,ib)-1,MPI_COMM_WORLD,ierror) + if (ia>ib .and. temp(ia)==temp(ib)) then + call MPI_Bcast(gyrocolmat(:,:,:,:,ib,ia,ik),n_xi**2*n_energy**2,& + MPI_REAL8,proc(ik,ia,ib)-1,MPI_COMM_WORLD,ierror) + end if + end if + enddo + call cpu_time(t2) + t(8)=t2-t1 + t1=t2 + + ! now to the k-interpolation of cmat + allocate(chebweightarr(nkmax)) + !allocate(m1(n_energy,n_xi,n_energy,n_xi)) + do itor=nt1,nt2 + do ic_loc=1,nc_loc + ic=ic_loc-1+nc1 + it=it_c(ic) + target_k=k_perp(ic,itor)/bmag(it)/kperp_bmag_max + !target_k=sin(.5*pi1*(target_ik-.5)/nk(ia,ib))**2 + do ia=1,n_species + do ib=1,n_species + target_ik=asin(sqrt(target_k))*(nk(ia,ib)/(.5*pi1))+.5 + ! for sinc --> see below + chebweightarr(1:nk(ia,ib))=[(sinc(target_ik-i,nk(ia,ib))+sinc(target_ik+i-1,nk(ia,ib)),& + i=1,nk(ia,ib))] + if (verbose>4 .and. i_proc==0) then + print *,'interpolation for krel=',target_k,'target_ik=',target_ik,& + 'weightsum',sum(chebweightarr(1:nk(ia,ib))),& + 'ipoltest',sum(chebweightarr(1:nk(ia,ib))*kperp_arr(1:nk(ia,ib),ia,ib)),& + 'should be',target_k*rho_spec(ia)*kperp_bmag_max + print *,'interpolationtest',sum(chebweightarr(1:nk(ia,ib))*& + [(sin(.5*pi1*(i-.5)/nk(ia,ib))**2,i=1,nk(ia,ib))]),& + 'should be',sin(.5*pi1*(target_ik-.5)/nk(ia,ib))**2,nk(ia,ib) + end if + call dgemm('N','N',n_xi**2*n_energy**2,1,nk(ia,ib),1.,& + gyrocolmat(:,:,:,:,ia,ib,1),n_xi**2*n_energy**2*n_species**2,chebweightarr,nk(ia,ib),& + 0.,m1,n_xi**2*n_energy**2) + do jx=1,n_xi + do je=1,n_energy + jv=iv_v(je,jx,ib) + do ix=1,n_xi + do ie=1,n_energy + iv=iv_v(ie,ix,ia) + cmat(iv,jv,ic_loc,itor)=-m1(ie,ix,je,jx) +!!$ if (gyrocolmat(ie,ix,je,jx,ia,ib,1)==0 .and. ic_loc==1) & +!!$ print *,'zero gc i_proc',i_proc,& +!!$ '(ie,ix,ia,je,jx,ib,ic_loc)',ie,ix,ia,je,jx,ib,ic_loc + end do + end do + end do + end do + end do + end do + end do + end do + deallocate(chebweightarr) + deallocate(m1) + call cpu_time(t2) + t(10)=t2-t1 + t1=t2 + + if (i_proc==0) then + do i=1,n_proc + if (i>1) then + call MPI_Recv(t,11,MPI_REAL8,i-1,i-1,MPI_COMM_WORLD,status,ierror) + end if + print *,'i_proc=',i-1,'took',t(1:10),'load',load(i),'rel',t(3)/load(i) + end do + else + call MPI_Send(t,11,MPI_REAL8,0,i_proc,MPI_COMM_WORLD,ierror) + end if + + coltestmode: if(collision_test_mode==1) then + allocate(cmat1(nv,nv,nc_loc,nt1:nt2)) + ! compute old collision operator in cmat1 + call old_sugama(cmat1) !<--- this is in this module. +!!$ do ia=1,n_species +!!$ do ib=1,n_species +!!$ if (ia>=ib .and. temp(ia)/=temp(ib)) then +!!$ ! need to do it, otherwise use self-adjointness +!!$ is=ispec(ia,ib) +!!$ do ik=1,nk(is) +!!$ do l=1,n_xi +!!$ do i=1,n_energy !polynomial index + + !compare with supplied cmat1 + allocate(m1(n_energy,n_xi,n_energy,n_xi),m2(n_energy,n_xi,n_energy,n_xi),& + c(n_energy,n_xi,n_energy,n_xi,2)) + allocate(v2polytimesemat(n_energy,n_energy)) + ! I do not know how everything is distributed. I only know the collision matrix + allocate (nc1_proc(n_proc),nc2_proc(n_proc),nt1_proc(n_proc),nt2_proc(n_proc),proc_c(nc,0:n_toroidal)) + nc1_proc(i_proc+1)=nc1 + nc2_proc(i_proc+1)=nc2 + nt1_proc(i_proc+1)=nt1 + nt2_proc(i_proc+1)=nt2 + proc_c=0 ! dummy value if no processor is responsible + do i=1,n_proc + call MPI_BCAST(nc1_proc(i),1,MPI_INTEGER,i-1,MPI_COMM_WORLD,ierror) + call MPI_BCAST(nc2_proc(i),1,MPI_INTEGER,i-1,MPI_COMM_WORLD,ierror) + call MPI_BCAST(nt1_proc(i),1,MPI_INTEGER,i-1,MPI_COMM_WORLD,ierror) + call MPI_BCAST(nt2_proc(i),1,MPI_INTEGER,i-1,MPI_COMM_WORLD,ierror) + ! this assigns the processor with the highest number to the respective + ! nc and nt range + proc_c(nc1_proc(i):nc2_proc(i),nt1_proc(i):nt2_proc(i))=i + end do + if (i_proc==0) then + print *,'nc1',nc1_proc + print *,'nc2',nc2_proc + print *,'nt1',nt1_proc + print *,'nt2',nt2_proc + print *,'proc_c',proc_c + end if + call dgemm('n','n',n_energy,n_energy,n_energy,1.,energymatrix,n_energy,v2poly,n_energy,& + 0.,v2polytimesemat,n_energy) + md=-1 + do itor=1,n_toroidal ! don't know what toroidal indices actually exist. We don't try 0 here. + do ic=1,nc,nc-1 + ! If proc_c==0 then there is nothing to be done. + ! Otherwise we deal with it, if we are either the responsible processor or proc 0 + if (.not. (proc_c(ic,itor)==i_proc+1 .or. i_proc==0 .and. proc_c(ic,itor)/=0)) continue + ic_loc=ic+1-nc1 + do ia=1,n_species + specbloop: do ib=1,n_species + if (proc_c(ic,itor)==i_proc+1) then + do jx=1,n_xi + do je=1,n_energy + jv=iv_v(je,jx,ib) + do ix=1,n_xi + do ie=1,n_energy + iv=iv_v(ie,ix,ia) + c(ie,ix,je,jx,1)=cmat(iv,jv,ic_loc,itor) + c(ie,ix,je,jx,2)=cmat1(iv,jv,ic_loc,itor) + end do + end do + end do + end do + do l=1,2 + call dgemm('N','N',n_energy,n_xi**2*n_energy,n_energy,1.,v2polytimesemat& + ,n_energy,c(:,:,:,:,l),n_energy,0.,& + m1,n_energy) + do k=1,n_xi + do j=1,n_energy + call dgemm('N','T',n_energy,n_xi,n_xi,1.,m1(:,:,j,k),n_energy,& + xi2L,n_xi,0.,m2(:,:,j,k),n_energy) + end do + end do + do j=1,n_xi + call dgemm('N','T',n_xi*n_energy,n_energy,n_energy,1.,m2(:,:,:& + ,j),n_xi*n_energy,poly2v,n_energy,0.,& + m1(:,:,:,j),n_xi*n_energy) + end do + call dgemm('N','N',n_xi*n_energy**2,n_xi,n_xi,1.,m1,n_xi*n_energy& + **2,L2xi,n_xi,0.,c(:,:,:,:,l),n_xi*n_energy**2) + end do + if (i_proc/=0) then + call MPI_SEND(c,size(c),MPI_REAL8,0,1234,MPI_COMM_WORLD,ierror) + end if + else + if (i_proc==0) then + call MPI_RECV(c,size(c),MPI_REAL8,proc_c(ic,itor)-1,1234,MPI_COMM_WORLD,status,ierror) + end if + end if +!!$ block +!!$ real s(n_energy,n_xi),s1(n_energy,n_xi) +!!$ if (i_proc==0) then +!!$ s=0 +!!$ s1=0 +!!$ do ix=1,n_xi +!!$ do ie=1,n_energy +!!$ do jx=1,n_xi +!!$ do je=1,n_energy +!!$ s(je,jx)=s(je,jx)+cmat(iv_v(je,jx,ia),iv_v(ie,ix,ib),ic_loc,itor) +!!$ s1(je,jx)=s1(je,jx)+cmat1(iv_v(je,jx,ia),iv_v(ie,ix,ib),ic_loc,itor) +!!$ end do +!!$ end do +!!$ end do +!!$ end do +!!$ +!!$ print *,'particle conservation',ia,ib,'s',s +!!$ print *,'particle conservation',ia,ib,'s1',s1 +!!$ end if +!!$ end block + if (i_proc==0) then + jxloop: do jx=1,n_xi !n_xi + do je=1,n_energy/2 + do ix=1,n_xi + do ie=1,n_energy/2 !n_energy + s=c(ie,ix,je,jx,1) + s1=c(ie,ix,je,jx,2) + d=abs(s-s1) + if (d>md) then + md=d + end if + print '(A,4I3,G14.6,2(A,I3,I4),A,G25.16E3,A,2G25.16E3)','ia,ib,itor,ic_loc,kp',ia,& + ib,itor,ic_loc,k_perp(ic,itor)/bmag(it_c(ic))*rho*sqrt(2.),& + 'jx,je',jx,je,' ix,ie',ix,ie,' d',d,' c,c1',s,s1 + end do + end do + end do + end do jxloop + end if + end do specbloop + end do + end do + end do + ! print out all kradial for certain moments: + allocate(mommat(3,n_energy)) + mommat(1,:)=polyrep(1,:n_energy) + mommat(2,:)=polyrep(2,:n_energy) + mommat(3,:)=polyrep(3,:n_energy)-1.5*polyrep(1,:n_energy) !no units attached + allocate(v2momtimesemat(3,n_energy)) + call dgemm('n','n',3,n_energy,n_energy,1.,mommat,3,v2polytimesemat,n_energy,0.,v2momtimesemat,3) + allocate(mom2v(3,n_energy)) + call dgemm('n','n',3,n_energy,n_energy,1.,mommat,3,poly2v,n_energy,0.,mom2v,3) + if (i_proc==0) then + do l=1,2 + do ia=1,n_species + do ib=1,n_species + if (collision_model==6) then + ! V3=Landau V2=old sugama V1=new sugama + write(fn,"('cgyro.moments.V',I1,'a',I1,'b',I1)") 4-l,ia,ib + else + write(fn,"('cgyro.moments.V',I1,'a',I1,'b',I1)") l,ia,ib + end if + open(6+ib+n_species*(ia+n_species*l),file=fn) + end do + enddo + end do + end if + do itor=1,n_toroidal ! don't know what toroidal indices actually exist. We don't try 0 here. + do ic=1,nc + ! If proc_c==0 then there is nothing to be done. + ! Otherwise we deal with it, if we are either the responsible processor or proc 0 + if (.not. (proc_c(ic,itor)==i_proc+1 .or. i_proc==0 .and. proc_c(ic,itor)/=0)) continue + ic_loc=ic+1-nc1 + do ia=1,n_species + specbloop2: do ib=1,n_species + if (ic>=nc1 .and. ic<=nc2) then + do jx=1,n_xi + do je=1,n_energy + jv=iv_v(je,jx,ib) + do ix=1,n_xi + do ie=1,n_energy + iv=iv_v(ie,ix,ia) + c(ie,ix,je,jx,1)=cmat(iv,jv,ic_loc,itor) + c(ie,ix,je,jx,2)=cmat1(iv,jv,ic_loc,itor) + end do + end do + end do + end do +!!$ do l=1,2 +!!$ call dgemm('N','N',n_energy,n_xi**2*n_energy,n_energy,1.,v2polytimesemat& +!!$ ,n_energy,c(:,:,:,:,l),n_energy,0.,& +!!$ m1,n_energy) +!!$ do k=1,n_xi +!!$ do j=1,n_energy +!!$ call dgemm('N','T',n_energy,n_xi,n_xi,1.,m1(:,:,j,k),n_energy,& +!!$ xi2L,n_xi,0.,m2(:,:,j,k),n_energy) +!!$ end do +!!$ end do +!!$ do j=1,n_xi +!!$ call dgemm('N','T',n_xi*n_energy,n_energy,n_energy,1.,m2(:,:,:& +!!$ ,j),n_xi*n_energy,poly2v,n_energy,0.,& +!!$ m1(:,:,:,j),n_xi*n_energy) +!!$ end do +!!$ call dgemm('N','N',n_xi*n_energy**2,n_xi,n_xi,1.,m1,n_xi*n_energy& +!!$ **2,L2xi,n_xi,0.,c(:,:,:,:,l),n_xi*n_energy**2) +!!$ end do + + do l=1,2 + call dgemm('N','N',3,n_xi**2*n_energy,n_energy,1.,v2momtimesemat& + ,3,c(:,:,:,:,l),n_energy,0.,& + m1,n_energy) + do k=1,n_xi + do j=1,n_energy + call dgemm('N','T',n_energy,n_xi,n_xi,1.,m1(:,:,j,k),n_energy,& + xi2L,n_xi,0.,m2(:,:,j,k),n_energy) + end do + end do + do j=1,n_xi + call dgemm('N','T',n_xi*n_energy,3,n_energy,1.,m2(:,:,:& + ,j),n_xi*n_energy,mom2v,3,0.,& + m1(:,:,:,j),n_xi*n_energy) + end do + call dgemm('N','N',n_xi*n_energy*3,n_xi,n_xi,1.,m1,n_xi*n_energy& + **2,L2xi,n_xi,0.,c(:,:,:,:,l),n_xi*n_energy**2) + end do + if (i_proc/=0) then + call MPI_SEND(c,size(c),MPI_REAL8,0,1234,MPI_COMM_WORLD,ierror) + end if + else + if (i_proc==0) then + call MPI_RECV(c,size(c),MPI_REAL8,proc_c(ic,itor)-1,1234,MPI_COMM_WORLD,status,ierror) + end if + end if + + if (i_proc==0) then + do l=1,2 + ! kperp n-diff,mom-diff heat-diff T->n n->T + write(6+ib+n_species*(ia+n_species*l),'(6(G24.16))') & + k_perp(ic,itor)/bmag(it_c(ic))*rho,c(1,1,1,1,l),c(2,2,2,2,l),& + c(3,1,3,1,l),c(1,1,3,1,l),c(3,1,1,1,l) + end do + end if + end do specbloop2 + end do + end do + end do + if (i_proc==0) then + do i=1,2*n_species**2 + close(6+i) + end do + end if + deallocate(m1,m2,c,v2polytimesemat,nc1_proc,nc2_proc,nt1_proc,nt2_proc,proc_c) + + ! now let's compare on processor 0 + md=-1 + if (i_proc==0) then + do itor=nt1,nt2 + do ic_loc=1,nc_loc + do is=1,n_species + do ix=1,n_xi + do ie=1,n_energy + iv=iv_v(ie,ix,is) + do js=1,n_species + do jx=1,n_xi + do je=1,n_energy + jv=iv_v(je,jx,js) + d=abs(cmat(iv,jv,ic_loc,itor)-cmat1(iv,jv,ic_loc,itor)) + if (d>md) then + md=d +77 format (A,2I3,2(A,3I3),3(A,G23.16)) + !if (i_proc==0) & + print 77,'so far max cmat diff @ (itor,ic_loc)',itor,ic_loc,'(is,ix,ie)=',is,ix,ie,& + '(js,jx,je)=',js,jx,je,'d=',d,'c=',cmat(iv,jv,ic_loc,itor),& + 'c1=',cmat1(iv,jv,ic_loc,itor) + end if + end do + end do + end do + end do + end do + end do + end do + enddo + end if + call MPI_reduce(md,d,1,MPI_REAL8,MPI_MAX,0,MPI_COMM_WORLD,ierror) + if (i_proc==0) print 11,'Max. deviation over all processors:',d +11 format ('cgyro_in._col.: ',A,G23.16) + + call MPI_Barrier(MPI_COMM_WORLD,ierror) + call MPI_finalize(ierror) + stop + end if coltestmode + +!!$ call MPI_Barrier(MPI_COMM_WORLD,ierror) +!!$ print *,'i_proc',i_proc,'done with init_landau' +!!$ call MPI_Barrier(MPI_COMM_WORLD,ierror) + + contains + elemental real function sinc(target_k,halfperiod) + ! sinc function for chebyshev interpolation + real target_k + integer halfperiod + intent(in):: target_k,halfperiod + if (target_k==0.) then + sinc=1. + else + sinc=sin(pi1*target_k)/tan((.5*pi1/halfperiod)*target_k)/(2*halfperiod) + end if + end function sinc + elemental real function rho_spec(ia) + implicit none + integer,intent(in) :: ia + rho_spec=vth(ia)*mass(ia)/z(ia)*sqrt(2.)*rho + end function rho_spec + integer function ispec(ia,ib) + implicit none + integer ia,ib + ! unfortunately, for the case of unequal temperatures we do not have a + ! self-adjoint (symmetric) matrix + ! maybe we will switch at a later time to a self-adjoint formulation + ! even for unequal temperatures. + ispec=ia+(ib-1)*n_species +!!$ !1<=ib>=ia>=1 +!!$ ! E.g. (ia,ib)= (1,1) (1,2) (2,2) (1,3) (2,3) (3,3) +!!$ ! 1 2 3 4 5 6 +!!$ !(1,ib) at 1 2 4 for ib=1,2,3 +!!$ ! at 1 , 1+1 , 1+1+2 ... for 1,2,3 +!!$ ! at 1+ (ib-1)*ib/2 +!!$ !(ia,ib) at ia+(ib-1)*ib/2 +!!$ ! max at ia=ib=n_species: n_species+(n_species-1)n_species/2 +!!$ ! =(n_species+1)n_species/2 +!!$ ispec=ia+((ib-1)*ib)/2 + end function ispec + end subroutine cgyro_init_landau + + subroutine old_sugama(cmat) + + use cgyro_globals, only : vth,temp,mass,dens,temp_ele,dens_ele,rho,z,& + n_energy,e_max,n_xi,n_species,nt1,nt2,nc_loc,nc1,nc2,nv,& + xi,w_e,w_exi,e_deriv1_mat,xi_lor_mat,energy,dens2_rot,dens_rot,vel,vel2,nu,& + collision_ene_diffusion,collision_mom_restore,collision_kperp,& + collision_ene_restore,collision_ion_model,& + is_v,ix_v,ie_v,ir_c,it_c,k_perp,bmag,is_ele,pi + + use mpi + + implicit none + + real,intent(out) :: cmat(:,:,:,:) + real, dimension(:,:,:), allocatable :: nu_d, nu_par + real, dimension(:,:), allocatable :: rs + real, dimension(:,:,:,:), allocatable :: rsvec, rsvect0 + real, dimension(:,:), allocatable :: klor_fac, kdiff_fac + real :: rsvtmp, rsvtmp0 + real :: my_dens2_rot,my_bj0,my_bj1 + + real :: arg,xi_s1s,xi_prop + real :: xa, xb, tauinv_ab + real :: rval + integer :: jv + integer :: is,ir,it,ix,ie,iv,js,je,jx,ks + integer :: ic,ic_loc,itor + real, dimension(:,:), allocatable :: cmat_base1,cmat_base2 + real, dimension(:,:), allocatable :: cmat_loc + real, dimension(:,:,:,:,:,:), allocatable :: ctest + real, dimension(:,:,:,:), allocatable :: bessel + allocate(nu_d(n_energy,n_species,n_species)) + allocate(nu_par(n_energy,n_species,n_species)) + allocate(klor_fac(n_species,n_species)) + allocate(kdiff_fac(n_species,n_species)) + nu_d(:,:,:) = 0.0 + nu_par(:,:,:) = 0.0 + klor_fac(:,:) = 0.0 + kdiff_fac(:,:) = 0.0 + + do js=1,n_species + do is=1,n_species + do ie=1,n_energy + xa = vel(ie) + xb = xa*vth(is)/vth(js) + tauinv_ab = nu(is)*z(js)**2/z(is)**2*dens(js)/dens(is) + ! Ad hoc op + ! (Fix for underflow) + nu_d(ie,is,js) = tauinv_ab * (1.0/xa**3) & + * (exp(-xb*xb)/(xb*sqrt(pi)) & + + (1.0-1.0/(2.0*xb*xb)) * erf(xb)) + ! No i-e Lorentz + !if (is /= is_ele .and. js == is_ele) then + ! nu_d(ie,is,js) = 0.0 + !endif + if(collision_kperp == 1) then + klor_fac(is,js) = 1.0 + endif + + ! Diffusion + nu_par(ie,is,js) = tauinv_ab * (2.0/xa**3) & + * (-exp(-xb*xb)/(xb*sqrt(pi)) & + + (1.0/(2.0*xb*xb)) * erf(xb)) + if(collision_kperp == 1) then + kdiff_fac(is,js) = 1.0 + endif + enddo + enddo + enddo + + if (collision_ion_model == 1) then + do is=1,n_species + if(is /= is_ele) then + do js=1,n_species + nu_d(:,is,js) = 0.0 + nu_par(:,is,js) = 0.0 + enddo + endif + enddo + endif + + if (collision_kperp == 1 .and. & + (collision_mom_restore == 1 .or. collision_ene_restore == 1)) then + allocate(bessel(0:1,nv,nc_loc,nt1:nt2)) +!$omp parallel do collapse(2) private(ic_loc,it,ie,ix,is,iv,arg,xi_s1s,xi_prop) + do itor=nt1,nt2 + do ic=nc1,nc2 + ic_loc = ic-nc1+1 + it = it_c(ic) + do iv=1,nv + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + xi_s1s = sqrt(1.0-xi(ix)**2) + xi_prop = xi_s1s / xi(ix) + arg = k_perp(ic,itor)*rho*vth(is)*mass(is)& + /(z(is)*bmag(it)) * vel2(ie) * xi_s1s + bessel(0,iv,ic_loc,itor) = bessel_j0(arg) + ! always used with the correction, so do it here + bessel(1,iv,ic_loc,itor) = bessel_j1(arg) * xi_prop + enddo + enddo + enddo + endif + allocate(ctest(n_species,n_species,n_xi,n_xi,n_energy,n_energy)) + ! Collision test particle component + ! ctest + + ! Lorentz +!$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) + do je=1,n_energy + do ie=1,n_energy + if (je == ie ) then + do jx=1,n_xi + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + ctest(is,js,ix,jx,ie,je) = & + + xi_lor_mat(ix,jx) *0.5*nu_d(ie,is,js) + enddo + enddo + enddo + enddo + else + ctest(:,:,:,:,ie,je) = 0 + endif + enddo + enddo + + ! Diffusion + if (collision_ene_diffusion == 1) then +!$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) + do je=1,n_energy + do ie=1,n_energy + do ix=1,n_xi + jx = ix + do js=1,n_species + do is=1,n_species + ! From K. Hallatschek + ! self-adjoint part of ctest written self-adjointly + ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & + -0.5 / w_e(ie) & + *sum(w_e(:)*e_deriv1_mat(:,ie)*energy(:) & + *nu_par(:,is,js) *e_deriv1_mat(:,je))/(1.0*e_max) + ! non-self-adjoint part proportional 1-Ta/Tb written + ! in a way that supports inherent particle number + ! conservation for small kperp + ctest(is,js,ix,jx,ie,je) = ctest(is,js,ix,jx,ie,je) & + + (1-temp(is)/temp(js)) / sqrt(1.0*e_max)/w_e(ie) & + * w_e(je)*e_deriv1_mat(je,ie) & + * nu_par(je,is,js)*energy(je)**1.5 + enddo + enddo + enddo + enddo + enddo + endif + allocate(cmat_base1(nv,nv)) + allocate(cmat_base2(nv,nv)) + + allocate(rs(n_species,n_species)) + allocate(rsvec(n_species,n_species,n_xi,n_energy)) + allocate(rsvect0(n_species,n_species,n_xi,n_energy)) + ! Momentum Restoring + + if (collision_mom_restore == 1) then + + ! C_test_ab(v_par f0a,f0b) and w_e v_par C_test_ab(H_a) + rs(:,:) = 0.0 + + do ie=1,n_energy + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + rsvtmp = 0 + rsvtmp0 = 0 + do je=1,n_energy + do jx=1,n_xi + rsvtmp = rsvtmp & + + ctest(is,js,ix,jx,ie,je) & + * vel2(je) * xi(jx) + rsvtmp0 = rsvtmp0 & + + ctest(is,js,jx,ix,je,ie) & + * vel2(je) * xi(jx) & + * w_exi(je,jx) + enddo + enddo + rsvtmp = rsvtmp * vth(is) + rsvtmp0 = rsvtmp0 * vth(is) + rsvec(is,js,ix,ie) = rsvtmp + rsvect0(is,js,ix,ie) = rsvtmp0 + ! int v_par C_test_ab(v_par f0a,f0b) / n_0a + rs(is,js) = rs(is,js) + w_exi(ie,ix) * dens(is) & + * rsvtmp * vel2(ie) * xi(ix) & + * vth(is) + enddo + enddo + enddo + enddo + +!$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) + do jv=1,nv + do iv=1,nv + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) + + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + + if (abs(rs(is,js))>epsilon(0.0)) then + cmat_base1(iv,jv) = & + - mass(js)/mass(is) & + * rsvec(is,js,ix,ie) / rs(is,js) & + * rsvect0(js,is,jx,je) + else + cmat_base1(iv,jv) = 0 + endif + enddo + enddo + endif + + ! Energy Restoring + + if (collision_ene_restore == 1) then + + ! C_test_ab(u_a^2 f0a,f0b) and w_e u_a^2 C_test_ab(H_a) + rs(:,:) = 0.0 + + do ie=1,n_energy + do ix=1,n_xi + do js=1,n_species + do is=1,n_species + rsvtmp = 0 + rsvtmp0 = 0 + do je=1,n_energy + do jx=1,n_xi + rsvtmp = rsvtmp & + + ctest(is,js,ix,jx,ie,je) * energy(je) + rsvtmp0 = rsvtmp0 & + + ctest(is,js,jx,ix,je,ie) * energy(je) & + * w_exi(je,jx) + enddo + enddo + rsvec(is,js,ix,ie) = rsvtmp + rsvect0(is,js,ix,ie) = rsvtmp0 + ! int v^2 C_test_ab(u_a^2 f0a,f0b) + rs(is,js) = rs(is,js) + w_exi(ie,ix) & + * dens(is) * rsvec(is,js,ix,ie) * (energy(ie)-1.5) + !Using temperature, not energy here. Matters for Ta/=Tb. + enddo + enddo + enddo + enddo +!$omp parallel do collapse(2) private(is,js,ix,jx,ie,je) + do jv=1,nv + do iv=1,nv + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) + + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + + if (abs(rs(is,js)) > epsilon(0.0)) then + cmat_base2(iv,jv) = & + - temp(js)/temp(is) & + * rsvec(is,js,ix,ie) / rs(is,js) & + * rsvect0(js,is,jx,je) + else + cmat_base2(iv,jv) = 0 + endif + enddo + enddo + endif + deallocate(rs) + deallocate(rsvec) + deallocate(rsvect0) + allocate(cmat_loc(nv,nv)) +!$omp parallel do collapse(2) default(none) & +!$omp& shared(nc1,nc2,nt1,nt2,nv,n_species,rho,is_ele,n_energy,n_xi) & +!$omp& shared(collision_kperp) & +!$omp& firstprivate(collision_mom_restore,collision_ene_restore) & +!$omp& shared(dens_ele,temp_ele,dens_rot,dens2_rot) & +!$omp& shared(cmat_base1,cmat_base2,bessel) & +!$omp& shared(it_c,ir_c,is_v,ix_v,ie_v,ctest) & +!$omp& shared(temp,dens,energy,vel,vel2) & +!$omp& shared(xi_lor_mat) & +!$omp& shared(k_perp,vth,mass,z,bmag,nu_d,xi,nu_par,w_e,w_exi) & +!$omp& shared(klor_fac,kdiff_fac) & +!$omp& private(ic,ic_loc,it,ir,rval,my_dens2_rot,my_bj0,my_bj1) & +!$omp& private(iv,is,ix,ie,jv,js,jx,je,ks) & +!$omp& private(cmat_loc) & +!$omp& shared(cmat) + do itor=nt1,nt2 + do ic=nc1,nc2 + + ic_loc = ic-nc1+1 + + it = it_c(ic) + ir = ir_c(ic) + ! Momentum Restoring + + if (collision_mom_restore == 1) then + + if (collision_kperp == 0) then + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + + do iv=1,nv + + ! we know we are the first one to modify cmat_loc, so no need for += + cmat_loc(iv,jv) = & + cmat_base1(iv,jv) & + * my_dens2_rot + enddo + enddo + + else + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + my_bj0 = bessel(0,jv,ic_loc,itor) + my_bj1 = bessel(1,jv,ic_loc,itor) + + do iv=1,nv + + ! we know we are the first one to modify cmat_loc, so no need for += + cmat_loc(iv,jv) = & + cmat_base1(iv,jv) & + * ( bessel(0,iv,ic_loc,itor) * my_bj0 & + + bessel(1,iv,ic_loc,itor) * my_bj1 ) & + * my_dens2_rot + enddo + enddo + endif + + else + cmat_loc(:,:) = 0.0 + endif + + ! Energy Restoring + + if (collision_ene_restore == 1) then + + if (collision_kperp == 0) then + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + + do iv=1,nv + + ! likely not the first, use += + cmat_loc(iv,jv) & + = cmat_loc(iv,jv) & + + cmat_base2(iv,jv) & + * my_dens2_rot + enddo + enddo + + else + do jv=1,nv + js = is_v(jv) + my_dens2_rot = dens2_rot(it,js) + my_bj0 = bessel(0,jv,ic_loc,itor) + + do iv=1,nv + ! likely not the first, use += + cmat_loc(iv,jv) & + = cmat_loc(iv,jv) & + + cmat_base2(iv,jv) & + * bessel(0,iv,ic_loc,itor) * my_bj0 & + * my_dens2_rot + enddo + enddo + endif + + endif + ! Change necessary to be able to compare with Landau operator: combine + ! cmat and ctest right now here into one matrix cmat, including the kperp components. + + do iv=1,nv + + is = is_v(iv) + ix = ix_v(iv) + ie = ie_v(iv) + + do jv=1,nv + + js = is_v(jv) + jx = ix_v(jv) + je = ie_v(jv) + + ! Collision component: Test particle + if (is == js) then + do ks=1,n_species + cmat_loc(iv,jv) = cmat_loc(iv,jv) & + + ctest(is,ks,ix,jx,ie,je) & + * dens_rot(it,ks) + enddo + endif + ! Finite-kperp test particle corrections + if (collision_kperp == 1) then + if (is == js .and. jx == ix .and. je == ie) then + do ks=1,n_species + cmat_loc(iv,jv) = cmat_loc(iv,jv) & + + (-0.25*(k_perp(ic,itor)*rho*vth(is)*mass(is) & + / (z(is)*bmag(it)))**2 * 2.0*energy(ie) & + * (klor_fac(is,ks)*nu_d(ie,is,ks) * (1+xi(ix)**2) & + + kdiff_fac(is,ks)*nu_par(ie,is,ks)* (1-xi(ix)**2))) + enddo + endif + endif + end do + end do + cmat(:,:,ic_loc,itor) = cmat_loc(:,:) + enddo ! ic loop + enddo ! itor loop + deallocate(cmat_loc) + + end subroutine old_sugama + + subroutine qsort(sortidx,val,n) + use cgyro_globals, only : i_proc + implicit none + integer,intent(in):: n,val(n) + integer,intent(inout) :: sortidx(n) + integer is,ie,i,j,ic,vic,s,isstack(n),iestack(n),sp +!!$ integer v +!!$ v(i)=val(sortidx(i)) !forced by fortran standard (LOL) to use obsolete statement function here. + is=1 + ie=n + sp=0 + do + ic=(is+ie)/2 + vic=v(ic) + i=is + j=ie +!!$ if (i_proc==0 .and. verbose>1000) then +!!$ print *,'Sorting',is,ie +!!$ end if + do + do while (v(i)>vic) + i=i+1 + end do + do while (v(j)1000) then +!!$ print *,'found',i,j,v(i),v(j),vic +!!$ end if + if (i1000) then +!!$ print *,'stopped at',i,j,v(i),v(j) +!!$ do k=is,j +!!$ if (v(k)=j and all j are >=vic + ! the element at i is >= vic and the one at j is <=vic + + if (i-1>is) then + if (j+10) then + is=isstack(sp) + ie=iestack(sp) + sp=sp-1 + else + exit + end if + end do + if (verbose>=1000 .and. i_proc==0) then + do i=1,n-1 + if (v(i) 0.0) then + ! Saved from restart data + delta_t_gk = delta_t_last + else + ! New run + delta_t_gk = delta_t + endif end subroutine cgyro_init_kernel diff --git a/cgyro/src/cgyro_init_manager.F90 b/cgyro/src/cgyro_init_manager.F90 index 1876eacdd..aec0a8149 100644 --- a/cgyro/src/cgyro_init_manager.F90 +++ b/cgyro/src/cgyro_init_manager.F90 @@ -250,6 +250,7 @@ subroutine cgyro_init_manager allocate(omega_h(nc,nv_loc,nt1:nt2)) allocate(omega_s(n_field,nc,nv_loc,nt1:nt2)) allocate(omega_ss(n_field,nc,nv_loc,nt1:nt2)) + allocate(omega_sbeta(nc,nv_loc,nt1:nt2)) allocate(jvec_c(n_field,nc,nv_loc,nt1:nt2)) allocate(jvec_v(n_field,nc_loc,nt1:nt2,nv)) allocate(dvjvec_c(n_field,nc,nv_loc,nt1:nt2)) @@ -257,7 +258,7 @@ subroutine cgyro_init_manager allocate(jxvec_c(n_field,nc,nv_loc,nt1:nt2)) allocate(upfac1(nc,nv_loc,nt1:nt2)) allocate(upfac2(nc,nv_loc,nt1:nt2)) - + #if defined(OMPGPU) !$omp target enter data map(alloc:cap_h_c,cap_h_ct,cap_h_c_dot,cap_h_c_old,cap_h_c_old2) !$omp target enter data map(alloc:cap_h_v,dvjvec_c,dvjvec_v) diff --git a/cgyro/src/cgyro_make_profiles.F90 b/cgyro/src/cgyro_make_profiles.F90 index 843e75c36..798fc0f15 100644 --- a/cgyro/src/cgyro_make_profiles.F90 +++ b/cgyro/src/cgyro_make_profiles.F90 @@ -122,13 +122,14 @@ subroutine cgyro_make_profiles z_eff = z_eff_loc b_unit = b_unit_loc - dens(1:n_species) = dens_loc(1:n_species) - temp(1:n_species) = temp_loc(1:n_species) - dlnndr(1:n_species) = dlnndr_loc(1:n_species) - dlntdr(1:n_species) = dlntdr_loc(1:n_species) + dens(1:n_species) = dens_loc(1:n_species) + temp(1:n_species) = temp_loc(1:n_species) + dlnndr(1:n_species) = dlnndr_loc(1:n_species) + dlntdr(1:n_species) = dlntdr_loc(1:n_species) sdlnndr(1:n_species) = sdlnndr_loc(1:n_species) sdlntdr(1:n_species) = sdlntdr_loc(1:n_species) - + sbeta_star(1:n_species) = sbeta_loc(1:n_species) + if (ae_flag == 1) then is_ele = n_species+1 else @@ -180,17 +181,10 @@ subroutine cgyro_make_profiles loglam = 24.0 - log(sqrt(dens_ele*1e13)/(temp_ele*1e3)) nu_ee = cc * loglam * dens_ele / (sqrt(mass_ele)*temp_ele**1.5) & / (vth_norm/a_meters) - - ! beta calculation in CGS: - ! - ! 8*pi ( n[1e19/m^3]*1e-6*1e19 )( T[keV]*1.6022*1e-9 ) - ! beta = ------------------------------------------------------ - ! ( 1e4*B[T] )^2 - ! - ! = 4.027e-3 n[1e19/m^3]*T[keV]/B[T]^2 - - betae_unit = 4.027e-3 * dens_ele * temp_ele / b_unit**2 - + + ! Electron beta + betae_unit = betae_loc + ! Debye length (from NRL plasma formulary): ! Use input lambda_debye as scaling parameter @@ -217,11 +211,11 @@ subroutine cgyro_make_profiles enddo ! Re-scaling - lambda_star = lambda_star * lambda_star_scale - gamma_e = gamma_e * gamma_e_scale - gamma_p = gamma_p * gamma_p_scale - mach = mach * mach_scale - betae_unit = betae_unit * betae_unit_scale + lambda_star = lambda_star * lambda_star_scale + gamma_e = gamma_e * gamma_e_scale + gamma_p = gamma_p * gamma_p_scale + mach = mach * mach_scale + betae_unit = betae_unit * betae_unit_scale do is=1,n_species dlnndr(is) = dlnndr(is) * dlnndr_scale(is) dlntdr(is) = dlntdr(is) * dlntdr_scale(is) @@ -259,13 +253,13 @@ subroutine cgyro_make_profiles dlntdr_ele = dlntdr_ae else is_ele = -1 - do is=1, n_species - if(z(is) < 0.0) then + do is=1,n_species + if (z(is) < 0.0) then is_ele = is exit endif enddo - if(is_ele == -1) then + if (is_ele == -1) then call cgyro_error('No electron species specified') return endif @@ -291,8 +285,8 @@ subroutine cgyro_make_profiles ! Always compute beta_* consistently with parameters in input.cgyro and then re-scale ! note: beta_star(0) will be over-written with sonic rotation call set_betastar - beta_star(0) = beta_star(0) * beta_star_scale - beta_star_fac = beta_star_fac * beta_star_scale + beta_star(0) = beta_star(0)*beta_star_scale + beta_star_fac = beta_star_fac*beta_star_scale endif @@ -342,7 +336,7 @@ subroutine cgyro_make_profiles ! ! Note: nt1,nt2,nt_loc properly initialized in cgyro_mpi_grid ! - if (zf_test_mode > 0) then + if (zf_test_mode > 0 .or. collision_test_mode>0) then if (zf_test_mode > 2) then ! The Apar and Bpar initial conditions could later be @@ -452,7 +446,11 @@ subroutine cgyro_make_profiles ! Fourier index mapping ! allocate(px(n_radial)) - if (zf_test_mode > 0) then + if (collision_test_mode>0) then + do ir=1,n_radial + px(ir) = ir-1 + enddo + else if (zf_test_mode > 0) then ! Need positive k_r Fourier coefficients only do ir=1,n_radial px(ir) = ir diff --git a/cgyro/src/cgyro_mpi_grid.F90 b/cgyro/src/cgyro_mpi_grid.F90 index 21e0dda75..95965b1ae 100644 --- a/cgyro/src/cgyro_mpi_grid.F90 +++ b/cgyro/src/cgyro_mpi_grid.F90 @@ -281,7 +281,7 @@ subroutine cgyro_mpi_grid ! ni -> nc ! nj -> nv - call parallel_lib_init(nc,nv,nt1,nt_loc,nc_loc,nv_loc,NEW_COMM_1) + call parallel_lib_init(nc,nv,nt1,nt_loc,n_field,nc_loc,nv_loc,NEW_COMM_1) nv1 = 1+i_proc_1*nv_loc nv2 = (1+i_proc_1)*nv_loc diff --git a/cgyro/src/cgyro_parallel_lib.F90 b/cgyro/src/cgyro_parallel_lib.F90 index ba346270e..e649f2244 100644 --- a/cgyro/src/cgyro_parallel_lib.F90 +++ b/cgyro/src/cgyro_parallel_lib.F90 @@ -21,8 +21,10 @@ module parallel_lib integer, private :: nk1,nk2 integer, private :: lib_comm integer, private :: nsend + integer, private :: n_field + integer, private :: nsend_real - real, dimension(:,:,:,:), allocatable, private :: fsendr_real + real, dimension(:,:,:,:,:), allocatable, private :: fsendr_real ! (expose these) complex, dimension(:,:,:,:), allocatable :: fsendf @@ -146,14 +148,14 @@ module parallel_lib ! parallel_lib_r -> g(nj_loc,ni) -> f(ni_loc,nj) !========================================================= - subroutine parallel_lib_init(ni_in,nj_in,nk1_in,nk_loc_in,ni_loc_out,nj_loc_out,comm) + subroutine parallel_lib_init(ni_in,nj_in,nk1_in,nk_loc_in,n_field_in,ni_loc_out,nj_loc_out,comm) use mpi implicit none integer, intent(in) :: ni_in,nj_in - integer, intent(in) :: nk1_in,nk_loc_in + integer, intent(in) :: nk1_in,nk_loc_in,n_field_in integer, intent(in) :: comm integer, intent(inout) :: ni_loc_out,nj_loc_out integer, external :: parallel_dim @@ -183,7 +185,10 @@ subroutine parallel_lib_init(ni_in,nj_in,nk1_in,nk_loc_in,ni_loc_out,nj_loc_out, allocate(fsendf(nj_loc,nk1:nk2,ni_loc,nproc)) allocate(fsendr(ni_loc,nk1:nk2,nj_loc,nproc)) - if (.not. allocated(fsendr_real)) allocate(fsendr_real(ni_loc,nk1:nk2,nj_loc,nproc)) + + n_field = n_field_in + nsend_real = n_field*nsend + if (.not. allocated(fsendr_real)) allocate(fsendr_real(n_field,ni_loc,nk1:nk2,nj_loc,nproc)) #if defined(OMPGPU) !$omp target enter data map(alloc:fsendf,fsendr) @@ -419,33 +424,35 @@ subroutine parallel_lib_rtrans_real(fin,f) implicit none - real, intent(in), dimension(:,:,:) :: fin - real, intent(inout), dimension(:,:,:) :: f - integer :: ierr,j_loc,i,j,k,j1,j2,itor + real, intent(in), dimension(:,:,:,:) :: fin + real, intent(inout), dimension(:,:,:,:) :: f + integer :: ierr,j_loc,i,j,k,j1,j2,itor,fi j1 = 1+iproc*nj_loc j2 = (1+iproc)*nj_loc !$omp parallel do collapse(2) if (size(fsendr_real) >= default_size) default(none) & -!$omp& shared(nproc,j1,j2,ni_loc,nk1,nk2) & -!$omp& private(j,j_loc,i) & +!$omp& firstprivate(nproc,j1,j2,ni_loc,nk1,nk2,n_field) & +!$omp& private(j,j_loc,i,fi) & !$omp& shared(fin,fsendr_real) do k=1,nproc do itor=nk1,nk2 do j=j1,j2 j_loc = j-j1+1 do i=1,ni_loc - fsendr_real(i,itor,j_loc,k) = fin(i+(k-1)*ni_loc,j_loc,1+(itor-nk1)) + do fi=1,n_field + fsendr_real(fi,i,itor,j_loc,k) = fin(fi,i+(k-1)*ni_loc,j_loc,1+(itor-nk1)) + enddo enddo enddo enddo enddo call MPI_ALLTOALL(fsendr_real, & - nsend, & + nsend_real, & MPI_DOUBLE_PRECISION,& f, & - nsend, & + nsend_real, & MPI_DOUBLE_PRECISION, & lib_comm, & ierr) diff --git a/cgyro/src/cgyro_read_input.f90 b/cgyro/src/cgyro_read_input.f90 index faab599b5..c95124f36 100644 --- a/cgyro/src/cgyro_read_input.f90 +++ b/cgyro/src/cgyro_read_input.f90 @@ -52,6 +52,9 @@ subroutine cgyro_read_input call cgyro_readbc_int(collision_field_model,'COLLISION_FIELD_MODEL') call cgyro_readbc_int(collision_ion_model,'COLLISION_ION_MODEL') call cgyro_readbc_int(collision_precision_mode,'COLLISION_PRECISION_MODE') + call cgyro_readbc_int(collision_test_mode,'COLLISION_TEST_MODE') + call cgyro_readbc_int(collision_field_max_l,'COLLISION_FIELD_MAX_L') + call cgyro_readbc_int(collision_test_max_l,'COLLISION_TEST_MAX_L') call cgyro_readbc_real(z_eff) call cgyro_readbc_int(z_eff_method,'Z_EFF_METHOD') call cgyro_readbc_int(zf_test_mode,'ZF_TEST_MODE') @@ -126,6 +129,7 @@ subroutine cgyro_read_input call cgyro_readbc_realv(dlntdr,is) call cgyro_readbc_realv(sdlnndr,is) call cgyro_readbc_realv(sdlntdr,is) + call cgyro_readbc_realv(sbeta_star,is) call cgyro_readbc_realv(dlnndr_scale,is) call cgyro_readbc_realv(dlntdr_scale,is) diff --git a/cgyro/src/cgyro_restart.F90 b/cgyro/src/cgyro_restart.F90 index cbada0800..44409c232 100644 --- a/cgyro/src/cgyro_restart.F90 +++ b/cgyro/src/cgyro_restart.F90 @@ -25,34 +25,21 @@ subroutine cgyro_write_restart use mpi use cgyro_globals use cgyro_io + use cgyro_step implicit none - integer :: j,ic0 - ! Print this data on restart steps only; otherwise exit now if (mod(i_time,restart_step*print_step) /= 0) return call cgyro_write_restart_one - - ! Unpack h(0,0) into source - if (source_flag == 1 .and. nt1 == 0) then - ic0 = (n_radial/2)*n_theta - do j=1,n_theta - source(j,:,0) = h_x(ic0+j,:,0) - h_x(ic0+j,:,0) = 0.0 - enddo - sa = 0.0 - do j=1,nint(t_current/delta_t) - sa = 1.0+exp(-delta_t/tau_ave)*sa - enddo - endif ! Write restart tag if (i_proc == 0) then open(unit=io,file=trim(path)//runfile_restart_tag,status='replace') write(io,*) i_current write(io,fmtstr) t_current + write(io,*) delta_t_gk close(io) endif @@ -350,31 +337,36 @@ subroutine cgyro_read_restart use mpi use cgyro_globals use cgyro_io + use cgyro_step implicit none + integer :: igk + integer :: j,ic0 + + !--------------------------------------------------------- - ! Read restart parameters from ASCII file. + ! Read restart parameters from ASCII tag file. ! if (restart_flag == 1) then + delta_t_last = 0.0 if (i_proc == 0) then open(unit=io,file=trim(path)//runfile_restart_tag,status='old') read(io,*) i_current read(io,fmtstr) t_current + read(io,*,iostat=igk) delta_t_last close(io) - + endif - ! Broadcast to all cores. - - call MPI_BCAST(i_current,& - 1,MPI_INTEGER,0,CGYRO_COMM_WORLD,i_err) - - call MPI_BCAST(t_current,& - 1,MPI_DOUBLE_PRECISION,0,CGYRO_COMM_WORLD,i_err) + ! Broadcast to all cores + call MPI_BCAST(i_current,1,MPI_INTEGER,0,CGYRO_COMM_WORLD,i_err) + call MPI_BCAST(t_current,1,MPI_DOUBLE_PRECISION,0,CGYRO_COMM_WORLD,i_err) + call MPI_BCAST(delta_t_last,1,MPI_DOUBLE_PRECISION,0,CGYRO_COMM_WORLD,i_err) + endif if (i_proc == 0) then @@ -384,6 +376,20 @@ subroutine cgyro_read_restart call cgyro_read_restart_one + ! Unpack h(0,0) into source + if (source_flag == 1 .and. nt1 == 0) then + ic0 = (n_radial/2)*n_theta + do j=1,n_theta + source(j,:,0) = h_x(ic0+j,:,0) + h_x(ic0+j,:,0) = 0.0 + enddo + sa = 0.0 + do j=1,nint(t_current/delta_t) + sa = 1.0+exp(-delta_t/tau_ave)*sa + enddo + endif + + end subroutine cgyro_read_restart diff --git a/cgyro/src/cgyro_rhs.F90 b/cgyro/src/cgyro_rhs.F90 index 8955746f9..c47a6038f 100644 --- a/cgyro/src/cgyro_rhs.F90 +++ b/cgyro/src/cgyro_rhs.F90 @@ -338,6 +338,7 @@ subroutine cgyro_rhs(ij,update_cap) ! Wavenumber advection shear terms ! depends on h_x and field only, updates rhs call cgyro_advect_wavenumber(ij) + !call cgyro_globalshear(ij) call cgyro_rhs_comm_test diff --git a/cgyro/src/cgyro_write_initdata.f90 b/cgyro/src/cgyro_write_initdata.f90 index cab06fbc2..1c95d8192 100644 --- a/cgyro/src/cgyro_write_initdata.f90 +++ b/cgyro/src/cgyro_write_initdata.f90 @@ -41,6 +41,13 @@ subroutine cgyro_write_initdata endif write(io,*) + ! Compute kymax + if (n_toroidal == 1) then + kymax = q/rmin*rho + else + kymax = q/rmin*(n_toroidal-1)*rho + endif + if (kymax < -99.9) then lfmt = '(a,i4,2x,2(f7.2,2x),2x,f6.2,5x,i4,2a)' else @@ -49,13 +56,6 @@ subroutine cgyro_write_initdata if (zf_test_mode == 0) then - ! Compute kymax - if (n_toroidal == 1) then - kymax = q/rmin*rho - else - kymax = q/rmin*(n_toroidal-1)*rho - endif - if (nonlinear_flag == 0) then write(io,*) ' n Delta Max L/rho' @@ -99,7 +99,7 @@ subroutine cgyro_write_initdata write(io,*) write(io,21) 'r/a',rmin,'R/a',rmaj,'q',q,'zmag',zmag,'kappa',kappa write(io,22) 'shift',shift,'s',s,'dzmag',dzmag,'s_kappa',s_kappa - write(io,*) + write(io,*) if (abs(shape_cos(0))+abs(shape_s_cos(0)) > 1e-6) then write(io,23) 'c0',shape_cos(0),'s_c0',shape_s_cos(0) endif @@ -132,12 +132,12 @@ subroutine cgyro_write_initdata ! where x = r/rho. The half-domain has -L/4 < r < L/4. if (profile_shear_flag == 1) then write(io,*) - write(io,'(a)') ' i s(a/Ln) (a/Ln)_L (a/Ln)_R | s(a/Lt) (a/Lt)_L (a/Lt)_R ' + write(io,'(a)') ' i s(a/Ln) (a/Ln)_L (a/Ln)_R | s(a/Lt) (a/Lt)_L (a/Lt)_R | sbeta_*' do is=1,n_species dn = sdlnndr(is)*length/rho/4 dt = sdlntdr(is)*length/rho/4 - write(io,'(t1,i2,3(1x,1pe9.2),2x,3(1x,1pe9.2))') & - is,sdlnndr(is),dlnndr(is)-dn,dlnndr(is)+dn,sdlntdr(is),dlntdr(is)-dt,dlntdr(is)+dt + write(io,'(t1,i2,3(1x,1pe9.2),2x,3(1x,1pe9.2),2x,1(1x,1pe9.2))') & + is,sdlnndr(is),dlnndr(is)-dn,dlnndr(is)+dn,sdlntdr(is),dlntdr(is)-dt,dlntdr(is)+dt,sbeta_star(is) enddo endif diff --git a/cgyro/src/cgyro_write_timedata.f90 b/cgyro/src/cgyro_write_timedata.f90 index 6e56f7777..3d6b808a1 100644 --- a/cgyro/src/cgyro_write_timedata.f90 +++ b/cgyro/src/cgyro_write_timedata.f90 @@ -135,7 +135,7 @@ subroutine cgyro_write_timedata endif !--------------------------------------------------------------- - ! Linear frequency diagnostics for every value of n + ! out.cgyro.freq: linear frequency diagnostics for every value of n call cgyro_freq fvec(1,:) = real(freq(:)) ; fvec(2,:) = aimag(freq(:)) if (n_toroidal > 1) then @@ -148,7 +148,7 @@ subroutine cgyro_write_timedata ! Output to screen if (printout) call print_scrdata() - ! Output to files + ! out.cgyro.time: time,total_error,rk_error,delta_t vec(1) = t_current ; vec(2:3) = integration_error(:) ; vec(4) = delta_t_gk call write_ascii(trim(path)//runfile_time,4,vec(1:4)) @@ -567,11 +567,11 @@ subroutine write_ascii(datafile,n_fn,fn) open(unit=io,file=datafile,status='old') do i=1,i_current - read(io,fmtstr) fn(1) + read(io,fmtstrn) fn(:) enddo endfile(io) close(io) - + end select end subroutine write_ascii diff --git a/cgyro/tools/egrid/egrid.10.10 b/cgyro/tools/egrid/egrid.10.10 deleted file mode 100644 index 2d27be140..000000000 --- a/cgyro/tools/egrid/egrid.10.10 +++ /dev/null @@ -1,20 +0,0 @@ -0.001080800997307183 0.00020426130746863828 -0.028485185373405367 0.011586932557960784 -0.1581236165115708 0.081942534861976642 -0.49027004939912009 0.22569636973267224 -1.1198682695594655 0.31384884670980554 -2.122368886779475 0.2377639676017251 -3.5458409847671925 0.10050944351576312 -5.3887094065837813 0.024255612624282838 -7.5164224459760019 0.0036186041906932008 -9.4078062874613871 0.00057342689765190416 --47.282560455358898 75.057191881976586 -46.114035367839096 29.575187327540359 -17.111993617949723 8.3571401331600654 -3.2909325178441376 1.0077183392894998 -0.23159522855733962 0.033879505582684822 --7.2138766943028281 -8.1425054659641561 22.785057596582262 -11.513633576395306 6.1155931675734112 -2.8642280599297896 1.101132768074873 -0.33213537958406736 0.07559140261452001 -0.010995758668918479 -1.6297602724206168 -8.3784624362071555 -2.0453212802577883 12.263511675858846 -4.9933384130326626 2.1121647049952451 -0.77060778840890813 0.22536802985299768 -0.050314216402163609 0.0072394511809722502 --0.75929002016334056 3.0755032395430943 -8.9084969927654592 0.62117617261252713 7.8519968348067009 -2.5200248341051836 0.82478496637799234 -0.22792894549778372 0.049238453849296268 -0.0069588746578437483 -0.55583299061405469 -2.0668354156937678 4.5892753146028061 -9.9344456641292097 2.5347663742729503 5.3807556569261977 -1.3304590378413257 0.32905150297797247 -0.067164211880001704 0.0092224901503236418 --0.5901289546225012 2.1043619074573502 -4.2201357539411928 6.9312868484563877 -11.697385417183971 4.2718085734524353 3.7962547254298499 -0.70885025558390451 0.12975190901788278 -0.016963582482336172 -0.88768766693323846 -3.0903274052884178 5.8814445161702316 -8.6656622441680823 11.048390267616445 -14.501312625220919 6.0416296292504126 2.7325448028212419 -0.37948210584470004 0.045087497730549798 --1.8948076697910963 6.4977755990945033 -11.990234614749123 16.693417892721393 -19.04785779192428 18.875185686111852 -19.048117175584179 8.0567158209660424 2.0469212787802133 -0.18899902562532528 -5.8848811789682184 -19.984997216579976 36.174972150782074 -48.734028209321207 52.541480177031859 -46.6909389762513 35.748529641762331 -27.661979803622469 11.130554840435418 1.5915262167950523 --32.057871145561014 108.25461305145591 -193.82627975532413 256.48173426221525 -268.65943968626362 227.31387772642018 -158.16578438120945 95.111100890241422 -59.265686752565608 24.813735790591057 diff --git a/cgyro/tools/egrid/egrid.10.12 b/cgyro/tools/egrid/egrid.10.12 deleted file mode 100644 index 10f25b1b8..000000000 --- a/cgyro/tools/egrid/egrid.10.12 +++ /dev/null @@ -1,20 +0,0 @@ -0.0011915097972465837 0.00023635836877225166 -0.031352182505669739 0.013329332384872197 -0.1737000911804777 0.092765637482954926 -0.53790622254179267 0.24716772915209655 -1.2291743200597211 0.32420755703723524 -2.3363121664810007 0.22347319574262962 -3.9291805177220961 0.081473679915510568 -6.045816303074884 0.015591017684028797 -8.6177681843894002 0.0016188447472210464 -11.13021201913165 0.00013664748467881372 --49.314560220530211 78.185325720426818 -47.745020770947498 30.196906116023644 -17.026227336926741 7.9673419658306279 -2.9332325083070587 0.80920838106728015 -0.15883637554588871 0.01909502890902679 --7.5533303549663737 -8.447477541685838 23.664952190270967 -11.790532539210793 6.1018059332632664 -2.7376022899359612 0.98369676515600268 -0.26722968169756892 0.051920408247681663 -0.0062028894413822263 -1.7200711431773713 -8.8249189409374776 -2.019966619411606 12.650633351837205 -5.0170625629664359 2.0322162887424168 -0.69269183701551184 0.18234355852268768 -0.034723280615540422 0.0040988986668911458 --0.81355219610850782 3.2880859728362231 -9.4605616164243309 0.84909860871796121 7.9995831592499626 -2.4573097712255192 0.75091079125043735 -0.18662450306133675 0.034345403042897399 -0.0039758482777870051 -0.61083282602582501 -2.2659436270652676 4.9961461421108889 -10.652421058317541 2.9470472401863242 5.3703056541625978 -1.2387676752154673 0.27521370060636288 -0.04777408543083569 0.0053608829371127239 --0.67480333645491362 2.4000533135733819 -4.7776614065740061 7.7250393066688096 -12.678235886177278 4.8696287771155994 3.6645087793423746 -0.61368478797925074 0.095305130733005628 -0.010149890247722537 -1.0784291168239706 -3.7436318104387443 7.0691445443153356 -10.247324473292722 12.694951313351915 -15.907323698759365 6.8247911455179816 2.495795083093153 -0.29306474514824271 0.028233524536718265 --2.5231672016930739 8.6249606652869555 -15.781844546044714 21.598885879369749 -23.919481898835077 22.592654106447804 -21.166520320283816 8.9947832287171304 1.7066160838408142 -0.1268859968057712 -8.9765671200991253 -30.372824659534118 54.47067296729081 -72.045350460099175 75.257321282360746 -63.59351527217806 45.048338310003126 -30.932177232302056 12.007841351057402 1.183126593302198 --57.648927828997161 193.84371528424002 -343.49448833358894 445.53081195538908 -451.13165130870058 361.79994559673044 -231.8413492772671 122.85672995802066 -63.203600076141677 23.288814030315256 diff --git a/cgyro/tools/egrid/egrid.10.5 b/cgyro/tools/egrid/egrid.10.5 deleted file mode 100644 index 81c4a54ef..000000000 --- a/cgyro/tools/egrid/egrid.10.5 +++ /dev/null @@ -1,20 +0,0 @@ -0.00067365483811569568 0.00010063173673357396 -0.017856041430655202 0.0058302934969803458 -0.099786584009429934 0.043734482622810485 -0.31052025774589023 0.13628743013430426 -0.70711568455510923 0.23545416943352616 -1.3227789439704295 0.25151420668699301 -2.1522635980340438 0.17724179175943694 -3.1310208078634192 0.088153299938629711 -4.1041724269271791 0.033602511941723079 -4.8109511970144611 0.028081182248862431 --42.405334139567797 67.636279560475487 -42.53014482383104 28.769830812855059 -18.358623037577559 10.502324126246585 -5.2377670487988325 2.2340199576749736 -0.78164864262209262 0.17106323514521634 --6.3765776460988455 -7.4518041073034988 20.773125738152412 -11.07894581308858 6.4950862644609452 -3.5662751183344771 1.7380988287771464 -0.731097004508147 0.25365885280117898 -0.055269994858134662 -1.3985274722070573 -7.2454947882076796 -2.2029562675817987 11.484223098987923 -5.1675845326422107 2.5663548260438887 -1.1890210551038126 0.48591576772078104 -0.16577499044022468 0.035810469016076443 --0.61570364958519951 2.5149242952568888 -7.4741515629917535 -0.094059429083123936 7.715981161256824 -2.9131847213128218 1.2136831090932675 -0.47005241566358821 0.1557143116116665 -0.033151098582159731 -0.41008258978548579 -1.5388922368453194 3.5103035752720506 -8.0535612462246282 1.296567837112155 5.7064323399977467 -1.8016628241214522 0.62692377182046838 -0.19716561438195596 0.040971807585449249 --0.37672407597886353 1.3568906833756754 -2.7995003139129485 4.882829530401442 -9.1637114183486892 2.5099301010996599 4.5106179462280228 -1.191096421468864 0.33807341205650997 -0.06730944345194484 -0.45965584681591029 -1.6179054377141036 3.1732333819748672 -4.9768837600655287 7.0782989302738431 -11.035313976833662 3.7808185951091225 3.8155778419168709 -0.82870258965722131 0.15122116817990203 --0.73626129664955029 2.5557124313005258 -4.8700315453430876 7.2386368895930248 -9.2497167447025026 10.943440570805753 -14.329090686304123 5.4494162080891685 3.499996222915414 -0.50210204970462305 -1.5993105680520054 -5.5050759005433997 10.314925608179738 -14.887279401045457 18.060142731634174 -19.283874080138512 19.321165270123259 -21.72920723540775 8.9438538841531924 3.1660385549927504 --6.2218835643330164 21.322920157481574 -39.60965567325681 56.341538678823518 -66.714324918348545 68.250091688179261 -62.674543221518649 55.413077429852766 -56.280787894853019 30.17356731797292 diff --git a/cgyro/tools/egrid/egrid.10.6 b/cgyro/tools/egrid/egrid.10.6 deleted file mode 100644 index 5347e899d..000000000 --- a/cgyro/tools/egrid/egrid.10.6 +++ /dev/null @@ -1,20 +0,0 @@ -0.00077274129391803325 0.00012359681272578516 -0.020454685277827135 0.0071244519026719062 -0.11412890413177082 0.052680642872748628 -0.35487594903715429 0.15927492451254477 -0.80888775977239523 0.26095710207378726 -1.5183831994878789 0.25664156077432349 -2.4869024482572844 0.16061272836480556 -3.6546828978757328 0.068257443106698691 -4.8523474726629732 0.021682612844396436 -5.7533751128334127 0.012644936735297463 --43.35768159144174 69.07400113504418 -43.185670941085794 28.830384357553677 -17.958850169289255 9.8874023545900632 -4.6658331506153307 1.8502981900805196 -0.59571898080298828 0.12166879596666906 --6.5428722002011581 -7.5813597855173464 21.152491126411696 -11.131566710714837 6.3691989332135227 -3.3649589650607325 1.5513906180010228 -0.60656487640018782 0.19360075785567309 -0.039358897587653053 -1.4454398164682914 -7.4742572253155802 -2.1596489072226965 11.615529884732782 -5.0995007127267509 2.4359200480078058 -1.067178225007027 0.40519137123441147 -0.12710398187609669 0.025607931704860887 --0.64525585314659858 2.6301710288193084 -7.7671233898086733 0.067402291284710652 7.7113505454507472 -2.7989638045603508 1.1020061118199284 -0.39626658160203771 0.12061534359189648 -0.023935691848930766 -0.43979933861784334 -1.6466717481820116 3.7311555859982663 -8.4377172938889561 1.5703893193691642 5.5989839586630326 -1.6693339860965567 0.53884830981735032 -0.15556243252798759 0.03010894822985526 --0.41831828650419386 1.5029709648527861 -3.0791250691808642 5.291032196010158 -9.6729250077805214 2.8953808011531805 4.3124534105919979 -1.0551904643054315 0.27458956697124865 -0.05086811180836016 -0.53580997431627313 -1.8808273270505653 3.661492949514086 -5.6543680283803871 7.8279632842134829 -11.705268047027891 4.2688518539525383 3.5289876392379075 -0.70161399712096151 0.11897169834551699 --0.91365586022103628 3.1620181221506096 -5.9777915379829165 8.7427256075421092 -10.865041771145907 12.315360683227322 -15.174328019202749 5.9990869813580608 3.1279306161605097 -0.41630482188600168 -2.1290644156429342 -7.3046698615369888 13.572072699999042 -19.260537443770755 22.70262336953636 -23.195661022914292 21.835544124357824 -22.639329187830017 9.3760171741410695 2.7848757323748225 --8.7735314730631307 29.962933449539673 -55.170813596078571 77.118698700291292 -88.657354548475874 86.699422148336778 -74.706312443730659 60.79470411155168 -56.189308211294247 28.921561862923059 diff --git a/cgyro/tools/egrid/egrid.10.8 b/cgyro/tools/egrid/egrid.10.8 deleted file mode 100644 index ddc043a6e..000000000 --- a/cgyro/tools/egrid/egrid.10.8 +++ /dev/null @@ -1,20 +0,0 @@ -0.00094292217258163245 0.00016651626457668531 -0.024900284002816643 0.0095142277796766923 -0.13854737212760994 0.06864002539949516 -0.43016226077851089 0.19707988677838358 -0.98180276204377369 0.29486571884279738 -1.8531878264002936 0.25119835859381806 -3.0693145217093205 0.1270839375398665 -4.5935770445560175 0.04009478740889129 -6.2553105837178952 0.0087375069095364821 -7.6078193040567293 0.0026190344829581778 --45.297009047087559 72.019625243171708 -44.591347188354423 29.110900029050669 -17.404289108078704 8.9683065758698311 -3.8351918779724574 1.3264593772220605 -0.36046104831526008 0.063007044494135582 --6.8771447604525659 -7.8535606948291412 21.946634992818551 -11.291094429303901 6.1986654293196748 -3.063987275516175 1.2796121276143846 -0.43613269511809294 0.11742895108085898 -0.020421645613592756 -1.5382475311496346 -7.9284130023239241 -2.091249120546483 11.916678072595562 -5.0170253620067816 2.2408344832706937 -0.88863433119676097 0.29387372855270114 -0.077689440653631161 0.013377441158989851 --0.70315530694197789 2.8561062302127564 -8.3440173757653335 0.36174186141974926 7.752822795750773 -2.6290129747473488 0.93601854918779133 -0.2928016566923736 0.075002093421731791 -0.012704215845768028 -0.49860106391765302 -1.8596781958820044 4.1664634382048365 -9.1951992312255092 2.0774589818251101 5.4521803139888131 -1.4680565604182697 0.41157223980741721 -0.099800109229421697 0.016458059011375093 --0.50382194045491921 1.8025871829597527 -3.6492261308710185 6.114539202188545 -10.69153171778075 3.6154007616612069 4.0054262207321229 -0.84939451728180555 0.18517991623282962 -0.029158977385963722 -0.70407770392630474 -2.4601100393582239 4.7291266945290323 -7.1141386327532469 9.4076114258801524 -13.08927526519244 5.1906037462012871 3.0682445031043357 -0.50931372153454383 0.0731735851973422 --1.3513863109877878 4.6531483350020624 -8.6790200355980855 12.349900674320967 -14.636415285363619 15.403818193773565 -17.027152715104685 7.0571607568095696 2.5120118736549818 -0.28206548650696882 -3.6367459335347103 -12.407163151911837 22.721708389040347 -31.327979059399451 35.147037528796944 -33.256908340043467 27.990232278398979 -24.876584202409333 10.250294561044407 2.1226160629487004 --17.067300020494512 57.93074864007797 -105.04445460563504 142.47148540947206 -155.61713579554323 140.59872204159969 -107.96837223898379 74.996345741796168 -56.989197365791174 26.689158193501854 diff --git a/cgyro/tools/egrid/egrid.11.10 b/cgyro/tools/egrid/egrid.11.10 deleted file mode 100644 index 8e35b6d59..000000000 --- a/cgyro/tools/egrid/egrid.11.10 +++ /dev/null @@ -1,22 +0,0 @@ -0.00078162522977972264 0.00012580212018106104 -0.020784989033861812 0.0073163190015824437 -0.11690950333652926 0.054857589374632127 -0.36774870523270904 0.16821535517818118 -0.85150411280932063 0.27698683027125787 -1.6331074520647189 0.26686991436696413 -2.7575942384524092 0.15507272010096483 -4.2404067936135436 0.055390535047007117 -6.0386688592278706 0.012655755493774156 -7.9700561708904427 0.0020589605044181947 -9.5417201047891252 0.00045021854103688625 --55.7736692304305 89.10400904289693 -56.222072790980335 37.955530076581289 -23.87836895352375 13.187659379241886 -6.1502759457761858 2.3548583111333079 -0.72573923715822973 0.17629690308941738 -0.028227555073829442 --8.3099329877369986 -9.8297205341801059 27.259503189717859 -14.505172615876477 8.3805481269538449 -4.4401448015434573 2.0221503484785004 -0.76278260039922732 0.23276560517369507 -0.056174240117019397 0.0089605095293862371 -1.8044168810985176 -9.3809687198063994 -2.8748273018032091 14.87090915052479 -6.5900389247580785 3.1550244073280121 -1.3641475473715672 0.49899886270682747 -0.14931181018695062 0.035579911162587302 -0.0056349088945294108 --0.78735445875818555 3.2263973672072165 -9.6117556637978927 -0.027473608929822925 9.7279329704351075 -3.5356142229327619 1.3718910670790421 -0.47421256156229927 0.13719410154052664 -0.032017884671438161 0.005012894390507771 -0.52303590841028226 -1.9683349093973744 4.4976411211173639 -10.271933208082138 1.8791688472294128 6.8692051300877442 -2.0141531969101502 0.62293542157339501 -0.17003956944462309 0.038377870743339374 -0.0059034153272518382 --0.48532287403229807 1.7521040600332 -3.6177265273250354 6.2723846245130748 -11.540979710894217 3.5255131447419334 5.0337697449958045 -1.1744889758865291 0.28677269878572779 -0.061178739010630402 0.0091525540789699599 -0.60999030798638983 -2.1505101588371495 4.2156024769775658 -6.559228054275536 9.1199820877682614 -13.566213249955974 5.1337739963948613 3.7790471464098785 -0.69688840834495007 0.13349461932285179 -0.019050763446199519 --1.0292031075362996 3.5746770203880582 -6.7952561921516559 9.9911189909707956 -12.429466455444304 13.948329971383191 -16.652915745988038 6.8361307238615095 2.9275764325293817 -0.4264641000695779 0.055472462056939735 -2.3346231215528572 -8.0288752174748024 14.965812877561671 -21.275334070402666 24.972345079830067 -25.067495316070449 22.603260298749006 -21.548056880996401 8.8726426698878914 2.4164443032688365 -0.24536686590601063 --7.2600311073708915 24.804514302782543 -45.652927212509048 63.561070639163891 -72.151909054571267 68.459114915682307 -55.428002333844082 40.182778980391385 -30.933880909841819 12.333500371283614 2.0857714088333682 -37.80918032500984 -128.6934453698696 235.16943147676524 -323.68108697956786 360.99442079608182 -333.12195996357079 257.28119866142967 -170.00634603008353 102.16537561922107 -67.841729457360279 29.924960921944416 diff --git a/cgyro/tools/egrid/egrid.11.12 b/cgyro/tools/egrid/egrid.11.12 deleted file mode 100644 index bdc946847..000000000 --- a/cgyro/tools/egrid/egrid.11.12 +++ /dev/null @@ -1,22 +0,0 @@ -0.00086744981161080053 0.00014704123345161459 -0.023034936117218304 0.0085099882402882185 -0.12933106975320789 0.062961130642995224 -0.4062613153863279 0.18776470508294332 -0.94048789063778387 0.29439141185683367 -1.8067404012317331 0.26230497483578047 -3.0637820397721043 0.13536760338593561 -4.7488850039302279 0.040524852214637215 -6.8539206139009902 0.0071317797410709307 -9.2360977653175534 0.00080007124992550516 -11.339983358082477 9.6441516138226003e-5 --57.980028836843403 92.53281442675353 -58.090267135596259 38.759364908709629 -23.859145989332156 12.715579105325821 -5.6145787646270788 1.9818918837972599 -0.54247203976946387 0.11182596158939514 -0.014983520007274132 --8.6674131487511838 -10.17673637004307 28.241332689645783 -14.850426037839123 8.3940811896797044 -4.2908675626196777 1.8498438727977354 -0.64316003565386021 0.17425981779773335 -0.035674602534530132 0.0047601875204885205 -1.894927856768903 -9.8351449892827905 -2.8827024802739222 15.321732132436878 -6.6410621252893517 3.0667643545630304 -1.2548014245703756 0.42290482916099927 -0.11230067254621231 0.022685769647588854 -0.0030032506147469521 --0.83770670713587848 3.4265772454075291 -10.151586022217166 0.16092564046678519 9.9227616930859592 -3.4773251397480881 1.2762819213489339 -0.40625029642512245 0.10422968500910314 -0.020601312878121096 0.0026932930860656877 -0.56880198657886308 -2.1364151478190761 4.853493432799078 -10.945193176419947 2.2414477449035418 6.8948121814230468 -1.9112288333664993 0.54393509070015297 -0.13154473594640652 0.025112250958600048 -0.0032207938113534028 --0.54600062367154739 1.9670181992447938 -4.0369009616078638 6.9085507897820606 -12.41861676298791 4.0619409433753238 4.9288766480294075 -1.0572694257014655 0.22842517408917891 -0.041146278742952926 0.0051222981909747237 -0.72168196809684219 -2.5384582439612203 4.9444088133401461 -7.590317672928025 10.304695288000071 -14.754334665917138 5.8479963608459662 3.5620330195043076 -0.58024528108820421 0.093629002474375526 -0.011088588367121348 --1.3101739016046023 4.5391476387026698 -8.570424289437613 12.425885158617944 -15.0830736674591 16.277123686235532 -18.319695489445085 7.7233430847656624 2.6018701970583096 -0.31822438612456887 0.034221968690851679 -3.3013519602204576 -11.321865660582305 20.951133265039984 -29.348813852709399 33.580080451264235 -32.374378401510763 27.472451194716467 -23.952514421983576 9.8855111619490081 1.9716695545407964 -0.16462525094490606 --11.847011606142659 40.348889727591454 -73.676737053073332 100.98240976454141 -111.59522326521611 101.51722593102441 -77.169892199025025 50.9977064760687 -34.323046932139942 13.198053176310899 1.5676259800601831 -71.87621278592691 -243.78201822659813 441.64528843108419 -597.77756205501054 648.07914574855246 -572.24129636004651 413.82709277327694 -248.32894203085388 129.76372826999292 -70.981898910867558 27.920249574543208 diff --git a/cgyro/tools/egrid/egrid.11.5 b/cgyro/tools/egrid/egrid.11.5 deleted file mode 100644 index 910f7476f..000000000 --- a/cgyro/tools/egrid/egrid.11.5 +++ /dev/null @@ -1,22 +0,0 @@ -0.00047851480464084019 6.0316695814716745e-5 -0.012785366131807039 0.0035675425885915484 -0.072350124347872725 0.028039573933244801 -0.22855891264816246 0.094965136535479891 -0.52902733011077034 0.18635803219195356 -1.0070622818691502 0.23675851074912009 -1.671869979239801 0.20648141699103404 -2.4976558844070206 0.1299967240660233 -3.4081388750550733 0.062825732872708075 -4.2597170766202368 0.024893085502876628 -4.8472427070319154 0.026053927873153351 --50.457466917339377 80.915990415950262 -52.007595902621331 36.646625552142837 -24.955506925280348 15.66213376466279 -8.8282978449804007 4.4033344171172116 -1.9184596807495052 0.69790505066741609 -0.15866192956955442 --7.4296887636506265 -9.0268433516218905 24.977524585532139 -13.879079362059677 8.6846467406176145 -5.2319662656792588 2.8818926561450595 -1.4172176041852255 0.61191845915156422 -0.22136377842166096 0.050176684171962422 -1.5744934266573999 -8.2354474724207224 -2.9342656099744943 13.911644039803887 -6.6829947804069666 3.6418841023181536 -1.9067470402570563 0.91052263830743956 -0.38610264770214988 0.13814941412987532 -0.031136070455365472 --0.6555699377230069 2.7040170868812166 -8.2203332272731909 -0.61907569917787937 9.4466093398194595 -3.9135558057753596 1.8417910485013789 -0.83268345236123047 0.34216019168259771 -0.12019740074642631 0.026837856172440873 -0.40257738861654022 -1.5258044353304387 3.5610660659097363 -8.5187112671283295 0.79992321300476724 7.0705509967836806 -2.5197058425761333 1.0217845067312207 -0.3973145699999881 0.13542859456120975 -0.029794650572265164 --0.33128805754743113 1.2052677051923232 -2.5445260378145837 4.6274458286825911 -9.2709689903302161 1.9556957411661205 5.6379614240244885 -1.7301842057228543 0.60408196845598734 -0.19546711414871962 0.041981738042294248 -0.35051850488726746 -1.2461648789969591 2.5006504083896993 -4.0877967337556173 6.2015583540875262 -10.582815437097652 3.0741341167975441 4.7581831796316725 -1.2607902164018165 0.36836472446880905 -0.075842022010474233 --0.46747914068587089 1.6386297626633926 -3.1929876748411758 4.9416895915692369 -6.7244520056736842 8.6839648872134256 -12.72294796159933 4.3311130716576133 4.2914616661499002 -0.96038026915008506 0.18138807269657726 -0.78316558027669366 -2.7205593420381384 5.2063051888172792 -7.8080998252256372 10.054313556337593 -11.658480125079138 12.963126890405625 -16.501582163177397 6.1224846182036444 4.1808477254674151 -0.62152210398793939 --1.7180984884955693 5.9350175389659504 -11.233800026458013 16.540999606303685 -20.667079199346393 22.749432321078182 -22.83998293314302 22.269700491448666 -25.21245572529936 10.236613638514345 3.9396527764315271 -6.6324768358108022 -22.843818543892384 42.992503795108469 -62.714186324021407 77.207292767794789 -82.967608685106501 79.850738951766092 -71.421862164024603 63.644176713726021 -66.897400525930886 36.517687178769607 diff --git a/cgyro/tools/egrid/egrid.11.6 b/cgyro/tools/egrid/egrid.11.6 deleted file mode 100644 index d7344bcbe..000000000 --- a/cgyro/tools/egrid/egrid.11.6 +++ /dev/null @@ -1,22 +0,0 @@ -0.00055096139171664452 7.4504213814003083e-5 -0.014704651930401701 0.0043891203623695476 -0.083094092559045433 0.03411055267046823 -0.26225078695271277 0.11279693902581413 -0.60714573619221334 0.212202108945168 -1.1580761889105543 0.25238858077930636 -1.9307874735488468 0.20023226570727583 -2.9043805847923937 0.11105546616395465 -4.0007145689173001 0.045908208856819596 -5.0545407724025656 0.01539377908268732 -5.8022707356303589 0.011448474192322334 --51.497917538975257 82.509054882379649 -52.794645379113312 36.816411503868347 -24.594564310276571 14.969541675960871 -8.071154388192075 3.7929902230227431 -1.5363032672333779 0.51745236250484669 -0.11086576394586359 --7.6042995069761829 -9.1797380582087316 25.413018849409339 -13.973371040855672 8.5762813096355875 -5.0099219750098396 2.6392023353699385 -1.2226262677197902 0.49067113450507867 -0.16431266174852702 0.035095881598799642 -1.6209332328234809 -8.4659150526312397 -2.9125812610744497 14.082041754769396 -6.6338448029430208 3.5045121032130277 -1.7542794656466515 0.78889781116372853 -0.31083053181222804 0.10291799755146409 -0.021851785413507836 --0.68256891490038935 2.8109210011533832 -8.5034552179749777 -0.48560043225874885 9.4753348038793922 -3.8040462384688224 1.7109887991091525 -0.72814492808815043 0.27787337809874195 -0.090286820827937311 0.018984570278356213 -0.42715631712941046 -1.6161777232142964 3.7526473816049098 -8.8764071348046143 1.0375940563401579 6.9935695672882546 -2.3807372342985476 0.90824687454765308 -0.32778061018866348 0.10327491758288593 -0.021386411987149981 --0.3617102352459091 1.3134866258916364 -2.7580657125180587 4.9578459819246773 -9.7297906010090397 2.2981012310910105 5.4688658877425663 -1.5777679453558684 0.51086344133140943 -0.15267500152362548 0.030846327671201434 -0.39836308277723032 -1.4133786124205165 2.8201159209023323 -4.5549702601950022 6.7656136553577775 -11.17090629388335 3.5192556294961542 4.5005442594961344 -1.10483595986354 0.29783929249360963 -0.057640714160829348 --0.5599669219644279 1.9584693123836117 -3.793378268779212 5.7982031614797124 -7.7203477391106767 9.6398768154284274 -13.461772825780158 4.8651744511838314 3.9426181934396809 -0.81309181558154901 0.14421563730075987 -0.99951681697382444 -3.463746179304814 6.5866043035556426 -9.7511321400181943 12.278596020365263 -13.755161113271518 14.563559104557778 -17.374696333060472 6.6950750748244676 3.7434072796256862 -0.52202283424766364 --2.3426926453009959 8.0715765421708858 -15.176129310234856 22.04774871389878 -26.921056351771512 28.606226870242367 -27.320176563184044 24.93468461461521 -26.049468653277387 10.644758542867992 3.5045282399735604 -9.5117695719033042 -32.67099954059159 61.062635461752726 -87.853605068459622 105.64625233081709 -109.5254484413952 100.19586293427878 -83.809947790320349 68.839897596412187 -66.412295359110902 35.015878304713573 diff --git a/cgyro/tools/egrid/egrid.11.8 b/cgyro/tools/egrid/egrid.11.8 deleted file mode 100644 index 2bf82ea9a..000000000 --- a/cgyro/tools/egrid/egrid.11.8 +++ /dev/null @@ -1,22 +0,0 @@ -0.00067719366524741201 0.00010148466449944254 -0.018038026058451199 0.0059367839111422566 -0.10167547906913413 0.045242268016746655 -0.32033093006435747 0.14353592784140394 -0.74174910579708373 0.25098184615790085 -1.4193259452211786 0.26601855054383132 -2.3833271742583086 0.17827423716411172 -3.6286890445210819 0.078236928773411962 -5.0873603648811928 0.023829748995953488 -6.5698588126873495 0.0056118018340298158 -7.6908409923379657 0.0022304220969685591 --53.612999706807806 85.762369109556312 -54.454591647047524 37.300754993988811 -24.107252188586271 13.910817865233302 -6.931614134131353 2.9199708442575987 -1.0267124675739941 0.29438998516274239 -0.055132654051817144 --7.9556281193550347 -9.4972057938071368 26.316013904722773 -14.210519441499996 8.4360686099234356 -4.6708507140272763 2.2733580075817851 -0.94372727271527131 0.32867000466364861 -0.093660020478492403 0.017480834991564845 -1.7131123329470968 -8.9247023057836299 -2.8843108474487722 14.456297494559495 -6.584478815994122 3.2954753686238493 -1.5233690251839633 0.61353526197110312 -0.20964254299627292 0.059028610723642812 -0.01094553141842727 --0.73562652148762558 3.0211480251205923 -9.0624473617934888 -0.24211418326205911 9.5763721970212729 -3.6402426630379752 1.5109563676811763 -0.57542712317241991 0.19026404528603054 -0.052519252259332763 0.0096364699038293 -0.4757016432402569 -1.7945242814505454 4.1300661651866202 -9.5818242665336718 1.4791529777247929 6.8983013360143508 -2.1652072020437701 0.73843571002119885 -0.23062274831919349 0.061648474610266033 -0.011127808450304837 --0.42348514840949013 1.5328646262875708 -3.1889833647759198 5.619220819161563 -10.642428495041792 2.9390667800916075 5.2082363291131965 -1.3415090484025638 0.37530977004637498 -0.094998174156160751 0.016705906085614108 -0.50100034313879397 -1.7713067342320048 3.4999144553583592 -5.5375264274518768 7.9307848297528064 -12.365418160052992 4.3588161888908648 4.0845397768348539 -0.86467130722490134 0.19698762224660014 -0.03312058726050396 --0.77608498595847955 2.7039556739800968 -5.1834505389306314 7.7549917362136336 -9.9461846293593396 11.712210065549507 -15.020011033136629 5.8837195468762381 3.3659016124909914 -0.58497329534563109 0.089925847620243931 -1.5675746003505906 -5.4095575884486113 10.174368551397454 -14.729783116405224 17.844097391835896 -18.822778532968734 18.265298971727085 -19.335260722697292 7.8077204976343235 2.9998106136267447 -0.36149066605223218 --4.2215744133018061 14.478646374860953 -26.906836714065296 38.188288545551726 -44.800907565565884 44.748775491981393 -39.082893626108516 31.561431377212957 -28.175126362831751 11.479789006184772 2.7304078860814523 -19.226322749263649 -65.716102386112466 121.33129828877766 -170.39841159793208 196.6572806837659 -191.36911331106231 159.80181688324618 -117.98888641146181 82.566720429873196 -66.399290862281095 32.288365533923175 diff --git a/cgyro/tools/egrid/egrid.12.10 b/cgyro/tools/egrid/egrid.12.10 deleted file mode 100644 index a5b2630d7..000000000 --- a/cgyro/tools/egrid/egrid.12.10 +++ /dev/null @@ -1,24 +0,0 @@ -0.0005790181468232419 8.0295568763743382e-5 -0.015503887657345132 0.0047577727495427017 -0.088129138024743147 0.037266886682710347 -0.28058713396466014 0.12387051143704642 -0.65752629547589708 0.23180516042672817 -1.2751096657841748 0.2681521689492147 -2.1749786999981842 0.19856610420917394 -3.3786636811836024 0.095868508470709737 -4.8754157827826925 0.030928990094868442 -6.5916289007307334 0.0070491909046323877 -8.3228097039673093 0.0012783016358408085 -9.6358655457526151 0.00037610887076860512 --64.953178292835244 104.26603549973057 -67.10679139994504 47.07313582934871 -31.536278608636809 19.104513823651464 -10.110169267623518 4.5621095808660278 -1.7274890437383254 0.5444348077077314 -0.14070412177377718 0.024381193248206765 --9.5047694357938515 -11.633045147110587 32.070147160166089 -17.736042518621255 10.915114118639432 -6.3448472146893872 3.2796039014635039 -1.4581604525021733 0.54671881715084818 -0.17113781395485758 0.044028050138741342 -0.0076094648865023742 -2.0023321229237594 -10.497161226606216 -3.7251215792288611 17.658137297045379 -8.3386121410220065 4.3816547430235359 -2.1508602137476408 0.92752880683814856 -0.34099502701351717 0.10534312623267115 -0.026866697086117063 0.0046207886408647956 --0.83088448314390379 3.4341994465029864 -10.445825512115306 -0.65167866781888545 11.724410771960084 -4.6789425385655187 2.0618564162214366 -0.84034069594716984 0.29865430939752672 -0.090280435470467598 0.0227067979678541 -0.0038754089886357247 -0.51220276103354335 -1.9447376692831357 4.5389521532115627 -10.788348793581894 1.282191710995313 8.4527224731331066 -2.8154894507201497 1.0267425343604315 -0.34413877629934692 0.10046416270978844 -0.02473438613574553 0.0041732805765260889 --0.4285738669145883 1.5613926781695194 -3.2942625483668337 5.9466159161943651 -11.674944752463546 2.8731560603071372 6.3569098003932037 -1.7485220198850153 0.52378781547363468 -0.14420338872947652 0.034339478100586129 -0.0056951722789856842 -0.46997581776241511 -1.6723984418159513 3.3508858313511304 -5.4301019779731265 8.0582273927758759 -13.172658689903246 4.3728036363642985 4.9109857536795806 -1.1093451729378088 0.27323465333517258 -0.061545787842705963 0.0099369852043658344 --0.66609339264922436 2.3354791940462535 -4.5386550781468502 6.951160089692181 -9.2299531196860759 11.380224338920851 -15.424851859294909 5.8968320953612618 3.897076533649537 -0.72548699218028272 0.14693303910513284 -0.022664848817874858 -1.2136423848183538 -4.2134779914532893 8.0288591377137948 -11.887121481095629 14.885984834107447 -16.40367399583939 16.765829529704872 -18.751886059871265 7.5605659963987241 3.2294874290870976 -0.49844987768911539 0.070240094118399455 --2.8394910162187343 9.791334105893299 -18.413280865539223 26.676002072808412 -32.260739115256063 33.525895448547378 -30.655846195652837 25.915215978054435 -23.974677855564066 9.6598122382092051 2.8952922739614484 -0.31951706924325502 -8.6835714438338812 -29.807275985634241 55.569463046947823 -79.392584433271726 93.98558022795693 -94.470357072251046 81.709548723128586 -62.107151414290775 43.786236874955844 -34.260157715657709 13.612244671159482 2.6908816331229513 --43.232827854709004 148.01784554099567 -274.60291958265523 389.32178941438326 -455.62211889411302 450.16928251855814 -379.04977620296628 275.25936295391807 -177.28350856771609 108.63209005657861 -77.314636660472287 35.705417278198156 diff --git a/cgyro/tools/egrid/egrid.12.12 b/cgyro/tools/egrid/egrid.12.12 deleted file mode 100644 index 983d589fc..000000000 --- a/cgyro/tools/egrid/egrid.12.12 +++ /dev/null @@ -1,24 +0,0 @@ -0.00064626004300033564 9.4660108829414282e-5 -0.017283434397890251 0.0055861799434219056 -0.098083275109541413 0.043270840147710758 -0.31183560399149727 0.14050651993023427 -0.73033033150087335 0.2523071616558029 -1.417437746667542 0.27335877839697193 -2.4243719794863083 0.18357313040722624 -3.7862228138672567 0.076965106383358184 -5.5122543884580083 0.02031988446288503 -7.5551276289931599 0.0035019421172229501 -9.7229080630130747 0.00044127942303948139 -11.484526237758244 7.4517023296930438e-5 --67.33388939877573 107.99433664578957 -69.213208024773834 48.075073887863803 -31.621754547254986 18.590476410327611 -9.4018272090019416 3.9723954801583042 -1.3705242113768256 0.3800176585193922 -0.083451942227935123 0.012355250752576064 --9.8810080916438031 -12.020737221922894 33.153364662032462 -18.15368824567642 10.967712256108321 -6.1863397886946957 3.0554371465664464 -1.2718093215892698 0.43439472009806985 -0.11960621241163023 0.026139008903323047 -0.0038589117699090088 -2.0937694191072778 -10.961429877318181 -3.7634078481511098 18.172997145584267 -8.4231265738145672 4.2938930353144422 -2.0135488322658864 0.81268809295991784 -0.27208609188971511 0.073905245011232749 -0.016003693107312985 0.002349978569634754 --0.87862913027487719 3.6261873347468746 -10.979241114573866 -0.49857035845022038 11.968246801351756 -4.6323207064494565 1.9494249394457599 -0.74333661882314208 0.24046919700900103 -0.063876491746949229 0.013630979617935133 -0.0019848318528154481 -0.55195796675002089 -2.0923571483851327 4.8601927873009282 -11.430492466190013 1.5999386177597339 8.5178597990944124 -2.7083816821280923 0.92361007774823703 -0.28161637533025995 0.072186223548346303 -0.015064216107792071 0.0021664159396113042 --0.47548221627141278 1.7293275303811089 -3.6304052565086152 6.4827121837988697 -12.481138530242261 3.3543043890025512 6.2840146962906859 -1.615361248602527 0.43986081001470588 -0.10622252420897253 0.021413379606553622 -0.0030232132606867671 -0.54408674321675965 -1.9325420816472943 3.8519281041161631 -6.1727225864678332 8.9793666250942774 -14.218353652235616 5.021643301807496 4.720256296378612 -0.96826837534639546 0.20891977954315363 -0.039771451634366579 0.0054572971750433066 --0.81911572470762179 2.8662529462368558 -5.5395796066063949 8.3867302487041418 -10.910920823226643 13.023229246952891 -16.819089642797291 6.7155438954185007 3.5953952019531221 -0.58533990443383957 0.0999709094251781 -0.013076746918899563 -1.6233847099484984 -5.6236593186174571 10.653718286223654 -15.585062734535435 19.11052423319481 -20.370713924721702 19.818674621697952 -20.65325891246423 8.5377248396747895 2.8098649201071321 -0.36464054500933309 0.043443824501321853 --4.2580072810740367 14.647249722511199 -27.373984056824929 39.161384754406892 -46.33795903166673 46.5345459350466 -40.450724246556885 31.806652946892119 -26.579898935000533 10.729888296746685 2.3381258519214543 -0.21727395640183482 -15.033463748417043 -51.464937397556862 95.302204648294632 -134.35815666152003 155.47089561995788 -150.8217803531953 123.80499575691103 -87.338044660380383 55.456546877576182 -37.591345248538431 14.445902531667492 2.0602551383667431 --85.853274586214158 293.06899551088039 -539.79558637563464 754.64619050302342 -862.43644374844946 821.35390357433081 -655.2801695047406 440.6687312133893 -254.8582003791675 134.74428406150498 -79.470089224145234 33.211658955222706 diff --git a/cgyro/tools/egrid/egrid.12.5 b/cgyro/tools/egrid/egrid.12.5 deleted file mode 100644 index c71e8632f..000000000 --- a/cgyro/tools/egrid/egrid.12.5 +++ /dev/null @@ -1,24 +0,0 @@ -0.00034911787444645519 3.7621491933100122e-5 -0.0093854513085253953 0.0022597984653866167 -0.053637584704808168 0.018386386752812368 -0.17153322450400056 0.06624741078931107 -0.4024688699227456 0.14305705276489707 -0.77741041363099717 0.20744186199827264 -1.3116495416038282 0.21365747455631796 -1.9980645854789112 0.16284455787436834 -2.7987800880540143 0.096024965936340033 -3.6348759010166636 0.046289819212260007 -4.3797995754796496 0.019136297765568922 -4.8740928306755287 0.024616752392531869 --59.198989021657207 95.317341329104727 -62.264074505454309 45.216220290496496 -32.313755628829949 21.734080812373741 -13.426448579149294 7.511809449395761 -3.7757867673675946 1.6863839086195605 -0.6359677879261802 0.1491865003942481 --8.5793220722973112 -10.723170799160625 29.522331330608272 -16.90861017135294 11.104823396492887 -7.1701623402494392 4.32854770096894 -2.3874831979960828 1.1889871755281137 -0.52779879123153835 0.19827370263456031 -0.046415933944836713 -1.7714434797608707 -9.3316697676401276 -3.6969308681775377 16.52116139239564 -8.3314178211995937 4.8665549624922462 -2.7924120793172315 1.4952816650921117 -0.73094921273419623 0.32060506555414061 -0.11954170104475182 0.02787488481842953 --0.70700827938843047 2.9373595064399499 -9.0798997659600463 -1.1355932046680364 11.296451487189499 -5.0165791466475482 2.587083550847805 -1.3110281125499638 0.62047740494761183 -0.26675515141089942 0.09826009677287399 -0.022768385572815666 -0.40814694064667205 -1.5583310127255987 3.6987779594458885 -9.1251688054546117 0.34171073837040377 8.5240661132807485 -3.3276054683791694 1.5113946166371917 -0.67592844994917802 0.28125926250779294 -0.10165001944614315 0.023328125066003513 --0.30887508125290025 1.1321123606929628 -2.4309356614970382 4.5595188975729933 -9.5908985115085433 1.474897186533454 6.8416548597937868 -2.3486927340383819 0.94107222133865857 -0.3703348415661212 0.12984116463989923 -0.029359860708769901 -0.29341250007298426 -1.0509416771297475 2.1449007640653661 -3.6157439652488264 5.7573174849264365 -10.520515618422358 2.5095167858654711 5.7740284772206382 -1.7498460974098795 0.61822759912958985 -0.20579543602516859 0.045439182955493669 --0.3421164034119723 1.20806028542435 -2.3936606483498279 3.8186609127320926 -5.449769033301383 7.526861835863137 -12.03346772594858 3.5786403115641543 5.1382426706158712 -1.3781184363956216 0.41442023063567094 -0.08775399942789099 -0.4838929970610994 -1.6929260804687764 3.2926025982056229 -5.0855462035997852 6.8582528729134405 -8.4863948762767556 10.261817133139672 -14.458630304615088 4.8537287471299274 4.8793292542814805 -1.1247419599233818 0.21861582215254519 --0.83191398097065814 2.8927394149795716 -5.559075729923401 8.4159770963619875 -10.984990810994445 12.855084961073017 -13.955741086064575 14.92722851103977 -18.781930173455721 6.8101793613480892 4.9739805476906455 -0.76153811108428095 -1.827554430813889 -6.3302267500200982 12.074380843486242 -18.058519628056952 23.126694235277282 -26.254636442607066 27.061600705511304 -26.148502042802365 25.220066190891945 -28.974590757657064 11.639582254098148 4.816596961064736 --6.9940556642716682 24.176064173343094 -45.932795377187218 68.265543436681573 -86.586519713016923 96.852749402182646 -97.479347339626732 90.331067327079078 -79.972242015853284 72.37177544205914 -78.578668180143463 43.546428508753759 diff --git a/cgyro/tools/egrid/egrid.12.6 b/cgyro/tools/egrid/egrid.12.6 deleted file mode 100644 index 7975e7016..000000000 --- a/cgyro/tools/egrid/egrid.12.6 +++ /dev/null @@ -1,24 +0,0 @@ -0.00040325147999376303 4.6694568188575549e-5 -0.010830735556014332 0.0027958790857347423 -0.061820797442425338 0.022545485446579709 -0.19750629488179535 0.079695634114549005 -0.46331735026212013 0.16634792580721456 -0.89591211154395519 0.22868308400326323 -1.5157502543452721 0.21812717752163666 -2.3198972913733698 0.14992897712417912 -3.2717567382015309 0.07760230427996965 -4.2856004562318542 0.032167340991385112 -5.2105049209099726 0.011437719367854046 -5.8380953333649251 0.010621777689445593 --60.327259501134324 97.064041378653594 -63.181361498058878 45.504148193213751 -32.021755122413298 21.009607521222181 -12.51776019034298 6.6690883644207342 -3.1518128193070575 1.3112786267306744 -0.46098248805296916 0.10276753506857266 --8.7627585892934266 -10.898141375943513 30.012690612468103 -17.046340129290052 11.022832456678376 -6.9419573587117431 4.0414021292686246 -2.1224157614114744 0.99366125016641637 -0.41082181401984014 0.14384809135145401 -0.031999511262924782 -1.817917297049667 -9.5654982237689135 -3.6942813999429536 16.729662708590056 -8.3052263145665513 4.7309051350268213 -2.6172755725100736 1.3341217492955406 -0.61295043502992164 0.25033607088656989 -0.086981162187536876 0.019270147157296104 --0.7322867206198772 3.0386371408822369 -9.3569048488844419 -1.0261955347762526 11.358182296233574 -4.9176124301185133 2.4444520015890772 -1.178825989242181 0.52418096405364215 -0.20976266162845297 0.071978133674157807 -0.01584235116296939 -0.42937632779236934 -1.6372073821721608 3.8704306936058578 -9.4639324218880211 0.5480909689694323 8.4780112059352833 -3.1889684999575201 1.3778152520096703 -0.57868400978183531 0.22403042073145758 -0.075392218623376836 0.016429663378843418 --0.33273142792548511 1.2177982581445016 -2.6039640393982715 4.8394946337997207 -10.013292561157249 1.7788519729923613 6.7027491305225067 -2.1877835115528407 0.82280207966832686 -0.30107670226230576 0.098237458624879861 -0.021085291456145155 -0.3267993095057116 -1.1687028185579448 2.3747550136092795 -3.9655720726994923 6.2088585659387486 -11.049219052405359 2.9116777239846124 5.5473639985466164 -1.576961775658168 0.51769866986204849 -0.16027171394712676 0.033574151821074007 --0.39823903531253952 1.4038649786512523 -2.7687750839600112 4.374182390922422 -6.1358590979383843 8.2490857091899552 -12.688477566505248 4.0744572091557888 4.8223971304092101 -1.2008272091159787 0.33556707550914096 -0.06737650100560774 -0.59498599899654653 -2.0777926472030589 4.0214858472609974 -6.1488996334522653 8.1469461429442481 -9.8076695555910851 11.402838991784858 -15.245158548515738 5.4247242692987602 4.4687489483704295 -0.95634839250872519 0.17613857861503184 --1.0887075487295561 3.7782202395891374 -7.2236141774803758 10.822167892524715 -13.87171894123471 15.784016196231797 -16.46413042835292 16.696268344602175 -19.654223034120066 7.3974270461703977 4.4726920932193593 -0.64839768241995364 -2.5425062910178331 -8.7881858959461378 16.67315060838694 -24.668799809387854 31.010671255302344 -34.212029916683782 33.859456831346998 -30.994140411576266 27.941351723163043 -29.711895476732606 12.018065357334691 4.3298494437747966 --10.168879970137859 35.073414600199149 -66.27001529615967 97.410696208224078 -121.2419412221994 131.74098474622707 -127.25291167676654 111.64731398081688 -92.326280565420647 77.275599569751014 -77.68056363842508 41.792583263890999 diff --git a/cgyro/tools/egrid/egrid.12.8 b/cgyro/tools/egrid/egrid.12.8 deleted file mode 100644 index f93edc30f..000000000 --- a/cgyro/tools/egrid/egrid.12.8 +++ /dev/null @@ -1,24 +0,0 @@ -0.00049870046436814101 6.4198906819244184e-5 -0.013372237569685424 0.003822307357003001 -0.076157990187546039 0.030339982758609593 -0.24286630934144347 0.10371344254705938 -0.56944754312111059 0.20396908309586134 -1.1029947642128064 0.25526947060725961 -1.8746984330356739 0.21233518181393799 -2.8928608891829636 0.12085190596952608 -4.1304255527890896 0.048848154652198644 -5.5000270698934894 0.014961742618817467 -6.812850065911872 0.003846675960382888 -7.7504424874460537 0.0019778537125247551 --62.617651673844112 100.62228995265779 -65.094401924824834 46.21046477680039 -31.655872645268907 19.885022784787097 -11.11033276381722 5.4154837196020348 -2.278379330235071 0.82313189453964176 -0.24923886631150862 0.049484075914697988 --9.1320714649811815 -11.258707148963007 31.022705045353278 -17.365108989232746 10.929136634522839 -6.5885784568034908 3.5962029120524996 -1.7274830796215385 0.71979180532072707 -0.25835210443599624 0.077893573072490642 -0.015428726283872944 -1.9104045561029453 -10.031970883853885 -3.7017172025885897 17.175965515793665 -8.296743022513223 4.5224946815686989 -2.344934818952653 1.0928876656031907 -0.44668147799292857 0.15829793763243203 -0.047337541382135366 0.0093345905824829105 --0.78209882749614222 3.2383494146035421 -9.9051430875697535 -0.82688329863661059 11.519173252524223 -4.7704136881932518 2.2213573536788165 -0.97891562638974759 0.38698791015251565 -0.13428351656140869 0.039629701913979331 -0.0077595880261618707 -0.47127497379781317 -1.7927958516876914 4.2086811286757522 -10.132581368222387 0.93258763251813137 8.4364098239234013 -2.9708690038087399 1.1721340743952341 -0.43731744232760297 0.14667182618724092 -0.042412263939688885 0.0082164704885367898 --0.38076656359744229 1.3901105158754046 -2.9507272832982503 5.3971868787307683 -10.851013215359796 2.3492818384511329 6.4920254200992538 -1.9333461308957467 0.64525517652413189 -0.20431512974989443 0.057215782675609282 -0.010907289455170959 -0.39693098170127855 -1.4156536572555305 2.8545457175685986 -4.6890521553344603 7.1293731530810317 -12.112545787131754 3.6707762576480882 5.180619058648644 -1.3052932112442357 0.37028234287596249 -0.0982401667911695 0.018257466233546511 --0.52433042531580607 1.8429200805164371 -3.6054678320115507 5.600048234001867 -7.6229839963847056 9.7756289021369005 -14.039819743466343 5.0173179567107269 4.2985362004233076 -0.92330150911693128 0.22071103203477657 -0.039258899528678744 -0.86909273452732076 -3.0253239155516968 5.8057232219061638 -8.722002093714076 11.20512740311402 -12.854017092607266 13.936709093714123 -16.935299095866394 6.5226730223689136 3.7744559456024457 -0.68943269862164093 0.11229347512808743 --1.8012178471103113 6.229220586858759 -11.802944478097588 17.361938724683828 -21.558742383417577 23.348803364684437 -22.679939034716664 20.867602347243072 -21.652651449374228 8.5473258159134831 3.6013531590898917 -0.46074880575710208 -4.7930145422598272 -16.50515095305295 31.018227235770983 -45.029019148899327 54.785338210128273 -57.461387843234428 52.880327844696463 -43.837846976208263 34.757198934600918 -31.649137536226018 12.800709330892463 3.4477263592720587 --21.197933369770639 72.825425018836429 -136.25160556192344 196.40178214247593 -236.42493050558142 244.01256220149814 -218.91757700466471 173.69942277283375 -126.10795787423976 90.197700330635042 -76.801175619628707 38.564287469529381 diff --git a/cgyro/tools/egrid/egrid.3.10 b/cgyro/tools/egrid/egrid.3.10 deleted file mode 100644 index b5cce42ac..000000000 --- a/cgyro/tools/egrid/egrid.3.10 +++ /dev/null @@ -1,6 +0,0 @@ -0.036072020178494836 0.036204581804380407 -0.71522095240122346 0.640812324406001 -3.2170200718833122 0.32298309378961859 --6.7940444074279473 8.1582499671906281 -1.3642055597626808 --2.8502654927366086 1.4860599329739279 1.3642055597626808 -2.8502654927366086 -8.1582499671906281 5.3079844744540194 diff --git a/cgyro/tools/egrid/egrid.3.12 b/cgyro/tools/egrid/egrid.3.12 deleted file mode 100644 index 4f4a9d349..000000000 --- a/cgyro/tools/egrid/egrid.3.12 +++ /dev/null @@ -1,6 +0,0 @@ -0.036254634519788115 0.036468594587106346 -0.71853573031441475 0.64311656184145647 -3.234340609135627 0.32041484357143719 --7.4247967493219241 8.9140312994646475 -1.4892345501427234 --3.1162682807271972 1.6270337305844738 1.4892345501427234 -3.1162682807271972 -8.9140312994646475 5.7977630187374502 diff --git a/cgyro/tools/egrid/egrid.3.5 b/cgyro/tools/egrid/egrid.3.5 deleted file mode 100644 index 2a7990810..000000000 --- a/cgyro/tools/egrid/egrid.3.5 +++ /dev/null @@ -1,6 +0,0 @@ -0.031594387316455898 0.029882724439699718 -0.62938219127866873 0.57396082616869423 -2.7144824539168663 0.39615644939160606 --5.1537302631794611 6.2500436946966094 -1.0963134315171483 --2.1110894730502803 1.014776041533132 1.0963134315171483 -2.1110894730502803 -6.2500436946966094 4.1389542216463291 diff --git a/cgyro/tools/egrid/egrid.3.6 b/cgyro/tools/egrid/egrid.3.6 deleted file mode 100644 index 1bfc6a6f5..000000000 --- a/cgyro/tools/egrid/egrid.3.6 +++ /dev/null @@ -1,6 +0,0 @@ -0.033485259330646849 0.032512405270187693 -0.66614183788145753 0.60383683881133886 -2.931753195575477 0.36365075591847344 --5.4702818011486122 6.6021381473061265 -1.1318563461575143 --2.2667568142559577 1.1349004680984433 1.1318563461575143 -2.2667568142559577 -6.6021381473061265 4.3353813330501689 diff --git a/cgyro/tools/egrid/egrid.3.8 b/cgyro/tools/egrid/egrid.3.8 deleted file mode 100644 index efc9f00d9..000000000 --- a/cgyro/tools/egrid/egrid.3.8 +++ /dev/null @@ -1,6 +0,0 @@ -0.035420307772432247 0.03526506607676504 -0.70309695621716619 0.63207439053518717 -3.1492958282861045 0.33266054338804779 --6.1322755094732506 7.3708261347259593 -1.2385506252527087 --2.5664829770982034 1.3279323518454947 1.2385506252527087 -2.5664829770982034 -7.3708261347259593 4.8043431576277559 diff --git a/cgyro/tools/egrid/egrid.4.10 b/cgyro/tools/egrid/egrid.4.10 deleted file mode 100644 index 05dcfdafb..000000000 --- a/cgyro/tools/egrid/egrid.4.10 +++ /dev/null @@ -1,8 +0,0 @@ -0.017464583561151317 0.012676122499575775 -0.38105773414581114 0.36138999977307824 -1.7612174286077164 0.54517176187973252 -4.9635907338983819 0.080762115847613469 --10.673461413020445 14.278671192979433 -4.2081316021345961 0.60292182217560851 --2.9755613027470784 0.099705101972930356 3.2339951139771254 -0.35813891320297737 -1.6642078217710364 -6.1372878913758638 3.5909524445733182 0.88212762503150919 --3.7762147781124264 10.763811574913752 -13.970400663275522 6.9828038664741968 diff --git a/cgyro/tools/egrid/egrid.4.12 b/cgyro/tools/egrid/egrid.4.12 deleted file mode 100644 index b2f66c69f..000000000 --- a/cgyro/tools/egrid/egrid.4.12 +++ /dev/null @@ -1,8 +0,0 @@ -0.017758676888704603 0.012990515049680003 -0.38703232067347519 0.36760179445029222 -1.7897031312439988 0.54367442275362088 -5.0741346182588882 0.075733267746406896 --11.596529688606685 15.502284035384394 -4.55105898844021 0.64530464166250104 --3.2390744845981179 0.12120383701131765 3.5012802632873876 -0.38340961570058738 -1.8173102770554745 -6.6914193584102924 3.9293946723625467 0.94471440899227116 --4.1402106747238335 11.773224002070423 -15.178944506579411 7.5459311792328207 diff --git a/cgyro/tools/egrid/egrid.4.5 b/cgyro/tools/egrid/egrid.4.5 deleted file mode 100644 index 20b7ae5f3..000000000 --- a/cgyro/tools/egrid/egrid.4.5 +++ /dev/null @@ -1,8 +0,0 @@ -0.014000522013451696 0.0091537663892632731 -0.30856962939516844 0.28346038808038656 -1.4050615086367067 0.53679854433325395 -3.5871105921745716 0.17058730119709622 --8.469811951939503 11.495118888456308 -3.6446512396186953 0.61934430310188995 --2.2759489254366299 -0.10578623837744817 2.7473313109436164 -0.36559614712953834 -1.204929113442944 -4.5874095316175461 2.4901393877816492 0.89234103039295286 --2.5605101700807258 7.6339080340395154 -11.158856666494091 6.0854588025353019 diff --git a/cgyro/tools/egrid/egrid.4.6 b/cgyro/tools/egrid/egrid.4.6 deleted file mode 100644 index 84018a306..000000000 --- a/cgyro/tools/egrid/egrid.4.6 +++ /dev/null @@ -1,8 +0,0 @@ -0.015206116720190582 0.010339797732991252 -0.33408696226970963 0.31126248696526224 -1.5307589020473773 0.5452909495859268 -4.0482722889960273 0.13310676571581972 --8.8830471822823574 11.989063307673347 -3.6972173569042195 0.59120123151323029 --2.4206733428324406 -0.036596481511077483 2.8071505907514776 -0.34988076640795951 -1.3078685759697061 -4.918174106262985 2.7531468144216484 0.85715871587163048 --2.8449937419872785 8.3390220152771834 -11.660525122661691 6.1664968493717864 diff --git a/cgyro/tools/egrid/egrid.4.8 b/cgyro/tools/egrid/egrid.4.8 deleted file mode 100644 index 5a199e16f..000000000 --- a/cgyro/tools/egrid/egrid.4.8 +++ /dev/null @@ -1,8 +0,0 @@ -0.016734293080743924 0.011905095084645682 -0.36602454805937901 0.34554647592983909 -1.6880575515010224 0.54736000727866269 -4.6683706953337336 0.095188421706852538 --9.7567084038545985 13.084467408091686 -3.9059737238759886 0.5782147196389006 --2.7025882194415503 0.05435778219941272 2.9913625208821039 -0.34313208363996631 -1.4964748718057467 -5.5486244311364459 3.2081739049914551 0.84397565433924412 --3.3532133336888858 9.6340642647359817 -12.775027647710827 6.4941767166637306 diff --git a/cgyro/tools/egrid/egrid.5.10 b/cgyro/tools/egrid/egrid.5.10 deleted file mode 100644 index 4447bfcb5..000000000 --- a/cgyro/tools/egrid/egrid.5.10 +++ /dev/null @@ -1,10 +0,0 @@ -0.0094744691268020601 0.0051635638422637785 -0.22053975179009048 0.19259229247048785 -1.065857136751423 0.52464172625325671 -2.9816956580653753 0.25786173441674512 -6.5170032662704747 0.019740683017246541 --15.104800980936069 21.561695389914909 -8.4782576947162557 2.3005376143940658 -0.27917432865664934 --3.3464038061454897 -1.1580224442480288 5.5494875640063542 -1.1746979562930776 0.12963664268024178 -1.3489884042722647 -5.6893027792564091 2.3667231061278176 2.1534362269912115 -0.17984495813488466 --1.6372070299577235 5.3864798089981616 -9.6317382841074088 5.1824147115973088 0.70005079346966199 -5.9407703539899422 -17.774591160365173 24.052706254551971 -20.932571055635712 8.7136856074589717 diff --git a/cgyro/tools/egrid/egrid.5.12 b/cgyro/tools/egrid/egrid.5.12 deleted file mode 100644 index 495b94ef5..000000000 --- a/cgyro/tools/egrid/egrid.5.12 +++ /dev/null @@ -1,10 +0,0 @@ -0.0098082429964163734 0.0054350948110145241 -0.22788245006880138 0.20066532372396497 -1.1010125099383012 0.53232176146891167 -3.0921781976430063 0.24600141349301797 -6.8881005857101452 0.01557640650309086 --16.260843597821531 23.17818922025575 -9.0468760760942865 2.4088909163276097 -0.2793604626675419 --3.6170250340620285 -1.2181314305166636 5.9379787441549731 -1.2326248167247772 0.12980253714849625 -1.4689344200310144 -6.178319936929692 2.6185473028227922 2.2713135502150706 -0.18047533613918531 --1.8090483772493477 5.9318743551273626 -10.50524953440473 5.6764672581369277 0.7059562983897869 -6.7348443584885978 -20.052743245036762 26.796416275875747 -22.662477856706057 9.1839604673784751 diff --git a/cgyro/tools/egrid/egrid.5.5 b/cgyro/tools/egrid/egrid.5.5 deleted file mode 100644 index 5709c1d7a..000000000 --- a/cgyro/tools/egrid/egrid.5.5 +++ /dev/null @@ -1,10 +0,0 @@ -0.0070541225839585282 0.0033330038857797633 -0.16613555563689687 0.13347920405303734 -0.80105077903612234 0.4397149724305339 -2.1556766544631753 0.33309601338717831 -4.1033825955907986 0.090376806243470688 --12.433872758708881 18.006354639847225 -7.5912381069430246 2.4289796999114925 -0.41022347410681136 --2.6515782006839497 -1.1679706660711771 4.847141726498712 -1.216496025065969 0.18890316532238374 -1.001355503228947 -4.3419293554645185 1.4660458964009525 2.1303890190151574 -0.25586106318053843 --1.0743046063019705 3.6537228931638076 -7.1431010234327827 3.613427929194313 0.95025480737663256 -3.2328744300328425 -10.109482450284693 15.28610551157612 -16.931867090509062 8.5223695991847927 diff --git a/cgyro/tools/egrid/egrid.5.6 b/cgyro/tools/egrid/egrid.5.6 deleted file mode 100644 index dc81bd92b..000000000 --- a/cgyro/tools/egrid/egrid.5.6 +++ /dev/null @@ -1,10 +0,0 @@ -0.0077920772849776169 0.0038639912256898431 -0.18290011837968154 0.15146686351273275 -0.88301394140815791 0.47105156382941688 -2.407069759609781 0.31413394865340449 -4.7599853970617872 0.059483632778756039 --12.938302156178257 18.649015052267111 -7.6874936711640143 2.3370697608678487 -0.360288985792689 --2.793078978698292 -1.1428584839153722 4.9471269836716484 -1.177601082501531 0.16641156144354683 -1.076671962979073 -4.6261996779263629 1.6849620185271698 2.0918277374156783 -0.22726204099555811 --1.1991452470042508 4.0343260425255613 -7.6635041851451844 3.9711012520290719 0.85722213759480199 -3.7998661846331597 -11.718539708712881 17.113765903938043 -17.620189749395709 8.425097369537387 diff --git a/cgyro/tools/egrid/egrid.5.8 b/cgyro/tools/egrid/egrid.5.8 deleted file mode 100644 index 1bb86ed0c..000000000 --- a/cgyro/tools/egrid/egrid.5.8 +++ /dev/null @@ -1,10 +0,0 @@ -0.0088467926037850703 0.0046648830148533834 -0.20660263302450561 0.1772868022405056 -0.99848223982362118 0.50751269169793179 -2.7686430673861949 0.28002565591027031 -5.8221439106064917 0.030509967136438912 --13.9924701042414 20.040813370472902 -8.0112283761155546 2.2642069137145364 -0.30132180383048367 --3.0719670340562683 -1.1292612455509125 5.2122446117754162 -1.1507041468247047 0.13968781465646927 -1.2187585423932306 -5.1729959960046919 2.0612149321380006 2.085803849611391 -0.1927813281379302 --1.4336672736444983 4.7532945854531402 -8.6813479629451502 4.6193934412258875 0.74232720991062083 -4.9375603948010471 -14.932728812662577 20.764824733422221 -19.210779291989116 8.4411229764284241 diff --git a/cgyro/tools/egrid/egrid.6.10 b/cgyro/tools/egrid/egrid.6.10 deleted file mode 100644 index a05da22f8..000000000 --- a/cgyro/tools/egrid/egrid.6.10 +++ /dev/null @@ -1,12 +0,0 @@ -0.0055556405939560374 0.0023437521500942139 -0.13515422758605122 0.10293442533976129 -0.68031805402181734 0.40354885517572904 -1.9400837366648828 0.38581820003693019 -4.1915106919233629 0.099365498855810511 -7.6720376188385802 0.0059892684416747492 --20.178890834164224 30.003546543071412 -14.023198441577296 5.3441668652094451 -1.2899724742049884 0.14434834166565081 --3.8797553212760888 -2.4112339385664689 8.2755558757298706 -2.4711393176038839 0.54481318050214374 -0.058240478785572752 -1.2668020256431655 -5.7813212231887708 1.3523214460822436 3.7277393407211789 -0.62566237817486042 0.060120788917043247 --1.0766385587225291 3.8499528073304351 -8.3133063965334641 3.9214782585140837 1.7453342517242331 -0.12682036231275869 -1.9918722004327986 -6.5057427827453768 10.694473258202821 -13.377338581328192 6.527611276120204 0.66912462931774572 --9.5361121154531055 29.754505829898347 -43.966566456994325 41.587098356064581 -28.627639405529659 10.788713792014162 diff --git a/cgyro/tools/egrid/egrid.6.12 b/cgyro/tools/egrid/egrid.6.12 deleted file mode 100644 index 79cad2382..000000000 --- a/cgyro/tools/egrid/egrid.6.12 +++ /dev/null @@ -1,12 +0,0 @@ -0.0058571993831975855 0.002535436119600537 -0.14217103031924801 0.11016573696794486 -0.71479496008926225 0.4199175549969152 -2.0427569114144451 0.37817041514118631 -4.4543045475496072 0.085652069195374665 -8.4360906286568206 0.0035587875789784316 --21.520926434724402 31.938615463615313 -14.789742437353327 5.5134833201023961 -1.2691971352109324 0.12776722357095277 --4.1601460923924205 -2.5299415369480689 8.7624014046388901 -2.5581941444802664 0.53747549199627247 -0.051595122814406684 -1.3723180692795504 -6.2420151537404892 1.5463169707236043 3.8915273974933368 -0.62160070852730249 0.053453424771300174 --1.1894345777121984 4.2369710694373812 -9.0477463336958445 4.3539608171212343 1.7600081849117164 -0.11375916006228894 -2.2853595537300766 -7.4300480654669294 12.062651580144518 -14.690130259864036 7.1615059645604725 0.61066122689589849 --11.743957692624324 36.409203192218436 -52.95127055927424 48.46931731373412 -31.172376473321151 10.98908421926716 diff --git a/cgyro/tools/egrid/egrid.6.5 b/cgyro/tools/egrid/egrid.6.5 deleted file mode 100644 index de9dc380c..000000000 --- a/cgyro/tools/egrid/egrid.6.5 +++ /dev/null @@ -1,12 +0,0 @@ -0.0039125356491909352 0.0013900559277242118 -0.09624538402908979 0.064615356103599494 -0.48634766401545603 0.29511330840818805 -1.3634144894837774 0.38954941077081179 -2.7800631489786778 0.19079892121431671 -4.399768812396907 0.058532947575359742 --17.06573886674637 25.688770928110215 -12.733498667659165 5.5455412436164568 -1.7411253921777423 0.30605075485660509 --3.1727093842133328 -2.2544175486531662 7.3378935009988199 -2.5118698355460604 0.72356479645948281 -0.12246152904574339 -0.97431436062756769 -4.546066599180623 0.64077718295282054 3.6047722785225497 -0.79683924532579338 0.12304202240347849 --0.73827886142273503 2.7076134184364988 -6.2719555556794791 2.5067557788820433 2.0402410285299018 -0.24437580874622979 -1.1150571080778075 -3.7519541559717 6.6693947024028081 -9.8145873352371743 4.6235442401040739 1.1585454406241848 --3.9449587123265016 12.780908270510263 -20.727699870237192 23.66087085551175 -23.318199756918918 11.549079213460599 diff --git a/cgyro/tools/egrid/egrid.6.6 b/cgyro/tools/egrid/egrid.6.6 deleted file mode 100644 index bb4169ff2..000000000 --- a/cgyro/tools/egrid/egrid.6.6 +++ /dev/null @@ -1,12 +0,0 @@ -0.0043737338263850465 0.001641345547891113 -0.10726981453794568 0.075103566725822746 -0.5416457127600696 0.32863962350439801 -1.5267983556337945 0.39668743612219023 -3.165521188001838 0.16426720300612663 -5.1791331914424008 0.033660825093571272 --17.660928837716386 26.488912379045043 -12.906999090879317 5.410757819687004 -1.5826925911374928 0.25095032100114889 --3.3152846566974202 -2.2679345802511637 7.4883400290833776 -2.4651665056233589 0.66073708324548125 -0.10069136975691603 -1.0360832991793335 -4.8028414869771086 0.81300109326380078 3.5880613224038123 -0.73633415616717989 0.10202992829734189 --0.81075710450434925 2.9513602830228869 -6.6976605088831821 2.8326023668517926 1.9308197706779273 -0.20636480716507546 -1.2918469923592114 -4.3090992186516676 7.4872108172917147 -10.517767807005385 5.0389585467398712 1.0088506692662557 --4.896905801040091 15.698911679600699 -24.80231288616933 26.874287755160373 -24.118282158663735 11.244301411112085 diff --git a/cgyro/tools/egrid/egrid.6.8 b/cgyro/tools/egrid/egrid.6.8 deleted file mode 100644 index cc2be50b9..000000000 --- a/cgyro/tools/egrid/egrid.6.8 +++ /dev/null @@ -1,12 +0,0 @@ -0.005079697814833255 0.0020512575735082488 -0.12399331908490879 0.091601594923980207 -0.62507095863790835 0.37538184356490534 -1.7751255447520463 0.39439005861489066 -3.7741780259511806 0.12383280734837294 -6.5698902532653286 0.012742437974342606 --18.892025852839936 28.184539705420492 -13.387776592954378 5.2970091009462158 -1.3825608778385793 0.18081451726618588 --3.5984475606733216 -2.3226045922274755 7.8476388459846876 -2.4350112783066388 0.58123914709273378 -0.072814561869985528 -1.1548094800011675 -5.3019626079017858 1.1105562989654829 3.6215248060690999 -0.65958384005235671 0.074655862918392227 --0.94969330320849596 3.4193960203521412 -7.5273521997545441 3.4177748079660959 1.7948774608700111 -0.15500278622520813 -1.652144999576744 -5.440195688215779 9.137597407739439 -11.963163664155568 5.8197701829056918 0.79384676214947201 --7.1251298075768177 22.473643824783108 -34.105272224208575 34.067976026530075 -26.17774697475793 10.866529155230141 diff --git a/cgyro/tools/egrid/egrid.7.10 b/cgyro/tools/egrid/egrid.7.10 deleted file mode 100644 index 4e32e8538..000000000 --- a/cgyro/tools/egrid/egrid.7.10 +++ /dev/null @@ -1,14 +0,0 @@ -0.0034587177698453423 0.0011588462243667974 -0.086762515389005902 0.056497204455552375 -0.45161559075587033 0.28086399434434699 -1.3188689350312386 0.41024504988226492 -2.8767620336915414 0.21111883291564114 -5.2785126987248666 0.037687423685056893 -8.431230683914022 0.0024286484927708783 --25.928698093049924 39.589640306602236 -20.677213162986905 9.7361329781613118 -3.3939846192326759 0.75991339606204905 -0.085790805556090647 --4.5450375704314589 -3.7141417206596502 11.38151524711802 -4.2096486120450776 1.3434020440946043 -0.28778406855202635 0.031694680475589038 -1.2861327528145295 -6.1664889293412955 0.44618916795974126 5.5537390949504353 -1.3533166613921899 0.26102012427660906 -0.027275549267829671 --0.86511108958379374 3.2581817481553514 -7.9337235320298799 2.9160450257850363 3.0244760450045719 -0.44131646575911991 0.041448268427833962 -1.0991027713410885 -3.7894703751903375 7.0458609563014952 -11.022832294731288 5.1726009320389212 1.6097535678297435 -0.11501555758962278 --2.6257161278530538 8.6615276832789116 -14.499862039750813 17.161230342180921 -17.17570745971918 7.730088286191607 0.74843931567160737 -14.402614502555784 -46.348005209660578 73.617370774756665 -78.310789163903115 59.625048729555317 -36.364156035038341 13.377916401734269 diff --git a/cgyro/tools/egrid/egrid.7.12 b/cgyro/tools/egrid/egrid.7.12 deleted file mode 100644 index 3c3aace63..000000000 --- a/cgyro/tools/egrid/egrid.7.12 +++ /dev/null @@ -1,14 +0,0 @@ -0.0037020634934982126 0.0012825158726868288 -0.092657115578556505 0.061916225982789356 -0.4814539756628903 0.299874638527487 -1.4069690081648075 0.4150615735523261 -3.0849127722867015 0.19278904398664557 -5.7439635378316699 0.028013568628916991 -9.5731477969463656 0.0010624334491481516 --27.442075980151947 41.819957978866181 -21.639386311312806 9.9732323332168075 -3.3330594011930087 0.68718045378895514 -0.065849073214181611 --4.8374358782010347 -3.8828842169966142 11.962013137427102 -4.3288656107787608 1.3237424076638332 -0.26092085068025441 0.024351011565728518 -1.3838709588888159 -6.6133773137544498 0.59201667667893214 5.7652065041367753 -1.3450546230877419 0.23838201461822618 -0.021044217480557845 --0.95016471915081892 3.5653768334188322 -8.5886949235748062 3.2914451084837337 3.0590093411901939 -0.40928476680583218 0.032313126438697493 -1.2523286798507073 -4.2997888174644315 7.9025006272276839 -12.064049541408663 5.7638432406306447 1.5366917003259001 -0.091525889161840914 --3.200623718295509 10.506086638661803 -17.361476294363033 20.00904855756485 -19.049136512032427 8.4780059875080017 0.61809534095631449 -19.807416007332736 -63.323299182971071 98.9829246933288 -102.02207961568686 73.273483667969125 -39.918094753819977 13.199649183847249 diff --git a/cgyro/tools/egrid/egrid.7.5 b/cgyro/tools/egrid/egrid.7.5 deleted file mode 100644 index d1174a411..000000000 --- a/cgyro/tools/egrid/egrid.7.5 +++ /dev/null @@ -1,14 +0,0 @@ -0.0023358171700548784 0.00064484117322836433 -0.059165799421280891 0.032857283341432527 -0.30998670673379334 0.18423878073346643 -0.89945147268706321 0.3452018029043774 -1.9052547305060673 0.28063324447397846 -3.2639034399456192 0.11273890297573054 -4.5762571570315072 0.043685144397786273 --22.374521812900356 34.501476203731411 -18.890801106737908 9.8898452296952909 -4.2068408348555411 1.328569125374217 -0.24772680430711392 --3.8147357070423544 -3.406924399672587 10.186554970298349 -4.1975151138062604 1.6386265071202235 -0.49684766028142737 0.090841403384056859 -1.0238824687091569 -4.9934451929028068 -0.096920763956915204 5.2916012999394837 -1.5840395696504278 0.43512484449961746 -0.076203086638108243 --0.62407079492157873 2.3955754592376192 -6.1607239164944269 1.7047538943452097 3.2589445569238276 -0.68374348718958571 0.10926428809893478 -0.66991381601166005 -2.3600220063577663 4.6540296793002031 -8.2242340626051983 3.3460492803768994 2.1866246611686984 -0.27236136789449633 --1.2173100439626107 4.1173095701416243 -7.3558217972825998 9.9280941830560681 -12.581384581644452 5.618373436633616 1.4907392330583538 -4.616738169253773 -15.311555136686145 26.202038250230582 -32.269788671144537 31.874611319210056 -30.321234296037861 15.209190365174133 diff --git a/cgyro/tools/egrid/egrid.7.6 b/cgyro/tools/egrid/egrid.7.6 deleted file mode 100644 index 200302a38..000000000 --- a/cgyro/tools/egrid/egrid.7.6 +++ /dev/null @@ -1,14 +0,0 @@ -0.002634471451943744 0.00077185567297518652 -0.066564481034158514 0.038874735199831708 -0.34821461380004305 0.21110456630219252 -1.012540727633488 0.37022931577051849 -2.1628449022012247 0.26749934116433684 -3.7711941755101504 0.088710416553889156 -5.4284691956934779 0.022809769336256101 --23.059926080236398 35.462319348387558 -19.167686565540526 9.750664721766606 -3.9364664863586942 1.1439441687599109 -0.19284910677845654 --3.9610756760903513 -3.4542852689719862 10.392791834882609 -4.1589073337546379 1.5398380191404107 -0.42924338898414947 0.070881813778104743 -1.0783871618844011 -5.2346932244897028 0.034695130986084045 5.3070312658901425 -1.5049868344727068 0.37947419015433633 -0.0599076899525543 --0.67480712599383157 2.57678792849828 -6.528179285063669 1.9820091135906989 3.164913806542095 -0.60805763215256052 0.087333194578987208 -0.75661562872371725 -2.6497065822934719 5.1415781390980396 -8.7899256120924306 3.7537617390361441 2.0118834816444333 -0.22420679411643182 --1.4673499844394317 4.9293141245683638 -8.6517929154067582 11.270110916016012 -13.426504395569594 6.063391817880498 1.2828304369509106 -5.9924564378067403 -19.71859979791203 33.08756576397487 -39.212195914751112 36.246599841018197 -31.076179877851625 14.680353547714959 diff --git a/cgyro/tools/egrid/egrid.7.8 b/cgyro/tools/egrid/egrid.7.8 deleted file mode 100644 index 4029f7dc4..000000000 --- a/cgyro/tools/egrid/egrid.7.8 +++ /dev/null @@ -1,14 +0,0 @@ -0.0031120316451281019 0.00098986845047919515 -0.078308444321113428 0.048928958571816184 -0.40852912694288926 0.25244433426029455 -1.1912743581622841 0.39820824806432419 -2.576964144019096 0.23684199308877189 -4.6274235783248693 0.055745893007702539 -7.0267918910144193 0.0068407045566114473 --24.468588020749405 37.470025321808585 -19.847905483747166 9.649233630728281 -3.5779642430822411 0.89849214643385088 -0.12329335139190487 --4.2531697579152156 -3.5706896081545812 10.856490111788371 -4.1483592577832467 1.4092191920877733 -0.33895479790451339 0.045464117881412825 -1.1843398193961494 -5.7071903623018397 0.26201420999081228 5.3972886520081075 -1.4017640350004656 0.30416342569821984 -0.038851709790983664 --0.77295592971600025 2.9275851872161188 -7.2456259223434068 2.4819999417624741 3.0537591599265158 -0.50283448518480965 0.058072048339107992 -0.93125138350762334 -3.231325839551238 6.1142641875077749 -9.9221047159943293 4.5044405777363088 1.7595968599131115 -0.15612245311925126 --2.0279571082795511 6.739963352128195 -11.505084766636182 14.167969825048542 -15.259022849726109 6.9221330340265013 0.96199851343860398 -9.6353511040826571 -31.301700034661587 50.883429505053851 -56.654331613785225 46.877270738358602 -33.308709564436188 13.868689865387889 diff --git a/cgyro/tools/egrid/egrid.8.10 b/cgyro/tools/egrid/egrid.8.10 deleted file mode 100644 index fe855b8b7..000000000 --- a/cgyro/tools/egrid/egrid.8.10 +++ /dev/null @@ -1,16 +0,0 @@ -0.0022601794137520722 0.00061474171374098953 -0.057946151957390183 0.03212706131927514 -0.30977949155149041 0.18754124385139411 -0.92544181520255896 0.36500814879820113 -2.0493510495993213 0.29510536795114503 -3.7923433616365785 0.1029129158768592 -6.1943120506153151 0.015422124756486588 -8.9082498474213623 0.0012683957328978125 --32.361393954493046 50.299604831218724 -28.299755740840084 15.343464910946008 -6.7538387267162528 2.1920210126481039 -0.47783648165259162 0.057734148889138599 --5.3274187412589756 -5.0937527335433248 14.842801921582557 -6.3308197192366039 2.5545570315656212 -0.79412745207825888 0.16887171311832121 -0.020112020149336286 -1.3636990966608054 -6.7530427103794553 -0.40277788263461001 7.5971241462415305 -2.345105903706355 0.65729905333713075 -0.13252638099709933 0.015330581478053018 --0.77938040742072906 3.0362234132066872 -8.0082827261306705 2.0640559787550065 4.486588895094219 -0.95250494844867711 0.17219464887795468 -0.018894853933790695 -0.77298002578248072 -2.7604566254092783 5.5698587267132863 -10.108991309406212 4.1316989603352006 2.7312386428753832 -0.3732653819012166 0.036936961010355618 --1.2639079627325809 4.3232334267935852 -7.8649846263547774 10.812146910048506 -13.759821491257358 6.2414744434305828 1.6359950888874927 -0.12413578881544972 -3.5113956365430576 -11.716694576808522 20.210028869297067 -24.911166976702894 23.966277802074963 -20.850271753537463 8.86334163303056 0.92708936610323114 --20.07805071804829 66.037741735564998 -110.63984049255575 129.361868087016 -112.2360449696545 74.871244224346598 -43.874271421788681 16.557353555119631 diff --git a/cgyro/tools/egrid/egrid.8.12 b/cgyro/tools/egrid/egrid.8.12 deleted file mode 100644 index 1017b6036..000000000 --- a/cgyro/tools/egrid/egrid.8.12 +++ /dev/null @@ -1,16 +0,0 @@ -0.0024483409748454819 0.000692744249755156 -0.062639106157008409 0.035899918089297841 -0.33419920863469866 0.20486245976693026 -0.99809613926900059 0.38059549208900479 -2.2165206798970189 0.28286718360033173 -4.1353373562684859 0.085002214921442463 -6.8829104253846759 0.0096526885628588223 -10.329483796611555 0.00042729872037894055 --34.046119701814038 52.826479134653049 -29.472627335796631 15.67629666989884 -6.6551978733299647 2.025443065505928 -0.39326118365061633 0.038987224533432699 --5.6339585793192039 -5.3097108285703237 15.520474856861311 -6.49234896063614 2.5257797807069569 -0.73593628856109869 0.13929485806031473 -0.01359483854181596 -1.457058386021684 -7.1945083835587115 -0.30081151118111721 7.8626633504410529 -2.3386861643768008 0.61391508006514963 -0.11003789908458948 0.010407141673332507 --0.84895883903517881 3.2967273558720555 -8.6130058015386441 2.3855835164747701 4.5515998497577881 -0.90399572777342493 0.14501218624843451 -0.012962540005800398 -0.87037608253274041 -3.097272913320241 6.1867108697657244 -10.991751203480128 4.6609067695270538 2.6677779415644425 -0.32260994295300906 0.02586239636341684 --1.50503386575119 5.1274858098394257 -9.2273380568513991 12.403648484997521 -15.157582266527232 6.9698903694159078 1.479026010932664 -0.090096486055697938 -4.605389836171574 -15.295314722066701 26.065706694051187 -31.357877245718518 28.887974274718854 -23.309603993900607 9.6886461089593512 0.71507904778485883 --30.736666457048124 100.49547691232917 -165.96167513040737 188.70412520080103 -155.90399091221506 95.590793232911216 -48.139678123559269 15.951615277188396 diff --git a/cgyro/tools/egrid/egrid.8.5 b/cgyro/tools/egrid/egrid.8.5 deleted file mode 100644 index 7dd65475e..000000000 --- a/cgyro/tools/egrid/egrid.8.5 +++ /dev/null @@ -1,16 +0,0 @@ -0.0014774376647444569 0.00032553747265217572 -0.038190095195975489 0.017605808533841688 -0.20566375147802114 0.11295565708461491 -0.61390523661375762 0.26723811433584375 -1.3387449054840226 0.30567300663694864 -2.3856886770335485 0.1895609934903589 -3.6278180684341885 0.070880232531414086 -4.6870899503696456 0.035760649914325846 --28.365472516370073 44.431155056235414 -25.947275430212937 15.300878310361153 -7.8607107119579107 3.2990038238112088 -1.0693557142928969 0.21177718242604232 --4.5662933799608299 -4.6489343767849141 13.378050392504359 -6.2145491541334297 2.9313888791311118 -1.1806600963107376 0.37430093729433915 -0.073303201739899169 -1.1185301143691476 -5.6114169452369809 -0.79912565801651465 7.1723233508254698 -2.5949409190910589 0.94552342808146855 -0.28552703753864714 0.054633666607115592 --0.58863168483209303 2.3262730763994215 -6.4007551719136318 1.0411856035618999 4.6172936634592927 -1.280553633902972 0.34912925087928789 -0.063941103651205199 -0.50834137523818652 -1.8445518775541659 3.8928278700451118 -7.7616466624768235 2.5096568048233229 3.2605527494332705 -0.67880385914229398 0.11362359963339161 --0.66813197269674097 2.3266342328368336 -4.4421765065932457 6.7413974820702585 -10.21120560483754 4.0862036349284855 2.4939552762159464 -0.32667654192399738 -1.3424871887160704 -4.572278362301738 8.3153259088612347 -11.393231386298393 13.177669539236849 -15.459561828260483 6.6509596714049659 1.9386292686414948 --5.2209226067605526 17.583884650008458 -31.244423680246817 40.975186897095707 -43.315465644778171 39.76551424756715 -38.069300699338603 19.525526836452828 diff --git a/cgyro/tools/egrid/egrid.8.6 b/cgyro/tools/egrid/egrid.8.6 deleted file mode 100644 index e792bb9cb..000000000 --- a/cgyro/tools/egrid/egrid.8.6 +++ /dev/null @@ -1,16 +0,0 @@ -0.0016778684934979874 0.00039378353896864624 -0.043282651937483615 0.021112576886313571 -0.23268086301543032 0.13221206508310277 -0.69488106407576066 0.29748992742023885 -1.5219620020823359 0.3116642595713754 -2.739228458947155 0.16815043166330058 -4.2358523839562101 0.051519939815532069 -5.5833694692462465 0.01745701602116812 --29.140411877182594 45.552571268661871 -26.343694298915824 15.197897563575282 -7.5045586186769082 2.9572385480118347 -0.8776530337915422 0.15861044831787963 --4.7181704382381427 -4.7263413163000324 13.642116779270287 -6.1976058989623342 2.8086690446169362 -1.0616308957261737 0.30796675466501472 -0.05500402932555486 -1.1689439059637941 -5.8443743641707246 -0.70183215539255901 7.2248482329331047 -2.5095897636496785 0.85741575159167794 -0.23666503249362545 0.041253425218010804 --0.62838082252437197 2.4740167567375485 -6.7321090903682789 1.2738294286221929 4.5491681954691106 -1.1815353314955968 0.29397821597138902 -0.048967352411993365 -0.56201988210207721 -2.0307963028483417 4.2355739278673235 -8.2398462861009519 2.8715087099354337 3.0999359983524958 -0.58764699715804938 0.089251067850012803 --0.77876099670743832 2.699172581388746 -5.0885295178504626 7.5253228570648548 -10.900440177571825 4.5562241797551494 2.2540045027225483 -0.2669934288015722 -1.6801538427293867 -5.6920577639728487 10.210412624742552 -13.611372887646513 15.021599790309037 -16.385629731803159 7.1050798742959782 1.6718142513455675 --7.0163679973890819 23.491694389964286 -41.126673794566261 52.389925388307157 -52.719036210065539 44.850088610292372 -38.631573542809364 18.761943156266431 diff --git a/cgyro/tools/egrid/egrid.8.8 b/cgyro/tools/egrid/egrid.8.8 deleted file mode 100644 index 9db540bb0..000000000 --- a/cgyro/tools/egrid/egrid.8.8 +++ /dev/null @@ -1,16 +0,0 @@ -0.0020083370133140582 0.00051524499532447699 -0.05162929305989569 0.027228736366557564 -0.27670273676425863 0.1638470306613323 -0.82667964783192935 0.33948206739912748 -1.8226126438822352 0.30717148372869492 -3.3335222968028368 0.13005784422263566 -5.3123790165206113 0.027268655866086934 -7.3082775893575498 0.004428936760240668 --30.726539961733852 47.874575933282044 -27.252336719752112 15.172049156099688 -7.0170859332398101 2.4808270952741118 -0.62411488173672953 0.092625311806659363 --5.0223299374772557 -4.8988923347435844 14.21517114862089 -6.2284239047916436 2.6419985896407846 -0.89520615052073463 0.21989317389864452 -0.032210584627100907 -1.2676963912460152 -6.3032321237235454 -0.53530930625330958 7.3815682257401056 -2.3972475017690482 0.73315394669012854 -0.17102197676152255 0.024392344831176319 --0.70568588002484358 2.7615000136275103 -7.3808149527429003 1.6953710088969083 4.4808746826556005 -1.0396118449829638 0.2179674753594006 -0.029600502788711987 -0.66920770111291422 -2.401797656029162 4.9147960663954555 -9.187550653157719 3.5373760405889714 2.8679849954630776 -0.45620821623857559 0.056191721865037866 --1.0166602130309267 3.4970519885182404 -6.4589660275684808 9.1597445821542674 -12.324010823765917 5.4376236953268821 1.8848455982681677 -0.17962879990223288 -2.5095226715190837 -8.4282621110238984 14.783150540918423 -18.843045315264699 19.234706011758048 -18.493667015921359 7.998548580829204 1.2390466371851968 --12.219817223772824 40.507303568685593 -69.179444489493907 83.95893642444602 -77.732606813287922 57.827133428524062 -40.653327172189801 17.49182227708878 diff --git a/cgyro/tools/egrid/egrid.9.10 b/cgyro/tools/egrid/egrid.9.10 deleted file mode 100644 index ffc681ec9..000000000 --- a/cgyro/tools/egrid/egrid.9.10 +++ /dev/null @@ -1,18 +0,0 @@ -0.0015371318880617639 0.00034575923721219747 -0.040037987402397245 0.018956427631948922 -0.21859456231313721 0.1237570162164171 -0.66625665381337518 0.29469342637770393 -1.4991028315381053 0.32636083634463718 -2.8063943539938842 0.17885200209986637 -4.6376868389889456 0.04918227881381394 -6.9339042807561671 0.0070533245050748051 -9.2103741936182843 0.00079892877332556288 --39.478879006542312 62.122885366202671 -36.796892640371284 22.003191502214457 -11.360390640149397 4.689095090559364 -1.4582911070008353 0.32201004257875061 -0.04272860749141384 --6.2186690551011523 -6.5662949314054388 18.6458061840737 -8.779397189086256 4.1588900752616941 -1.6453935017967866 0.49938979724894241 -0.10861756172892362 0.014286182534220572 -1.4812294437277773 -7.4980188841686892 -1.2262055285554556 9.8373168355869372 -3.5692556744183734 1.2744686198181034 -0.36691597315084097 0.07738429571450996 -0.010003134553968636 --0.75271137199923077 3.0002791909944693 -8.3600383048608939 1.3106017723093621 6.1016085767868306 -1.6518278207513236 0.42644538116395396 -0.085028295484180784 0.010670871841013126 -0.62667701699256735 -2.2918285083344778 4.8912174427883265 -9.8390246174107594 3.2732852045350521 3.9964157955412435 -0.77938982830309194 0.13925259582066945 -0.016605101629529848 --0.79676813038750122 2.7929738281613171 -5.3797348436426777 8.2047413035775912 -12.310142473384247 5.1522611197326474 2.6572793723297532 -0.35941725803844533 0.038807081651562078 -1.5339572159159727 -5.2476257962136671 9.5879210060034429 -13.112624825041953 14.861862905312488 -16.449902225204078 7.1894691330457614 1.785897843706243 -0.14895525752420965 --4.6151140529085615 15.551319533897173 -27.552097433316894 35.623262911658641 -36.179771473846306 30.315800041460551 -24.333277863932609 9.9833383894623073 1.2065399475256977 -26.079429545463313 -87.106330031591246 151.67159990415164 -190.38663287791332 183.72590012982698 -139.39507108980409 86.430328823707227 -51.381648251258593 20.362423847418076 diff --git a/cgyro/tools/egrid/egrid.9.12 b/cgyro/tools/egrid/egrid.9.12 deleted file mode 100644 index 027b5c9b1..000000000 --- a/cgyro/tools/egrid/egrid.9.12 +++ /dev/null @@ -1,18 +0,0 @@ -0.0016812009175345747 0.0003953318619408711 -0.043709350162447976 0.021521947623887336 -0.23815467031531264 0.13783629638989768 -0.72522400645160068 0.3155223905519014 -1.6339930104215325 0.32583661866075812 -3.073869134246596 0.15894189475448515 -5.1340661775452793 0.036016602537714967 -7.8402265173498371 0.0037084973082809156 -10.815392784642259 0.00022042031113356321 --41.336781490005591 64.949836749866002 -38.194585174934457 22.465589728475321 -11.249225800339832 4.408395534559357 -1.258338942675403 0.24115774686049107 -0.026048351805887555 --6.5410391811625382 -6.827632268693364 19.423891827595426 -8.9941980413130213 4.1310490877229732 -1.5512544539464762 0.43196043634825952 -0.081494897227863316 0.0087174906766045064 -1.5723452741417856 -7.9398753818586018 -1.1643544612059126 10.162131152593853 -3.5734554238788217 1.2104531772930243 -0.31950570661467515 0.058390014929343189 -0.0061286453999950246 --0.81292773199480347 3.2316764613872604 -8.9324951545978111 1.5828115673784547 6.2052197066298747 -1.5924934527305422 0.37656441247145884 -0.064958952013492291 0.0066031434696004434 -0.69682897219912633 -2.540944818857873 5.3770715042003173 -10.622496879075546 3.7414124057479819 3.9553360916399115 -0.70555548129962477 0.10882123142607905 -0.010473025980371861 --0.92847446032692288 3.2441711878860077 -6.1928602668733182 9.2690014041778622 -13.448357190282386 5.8164737570238802 2.5064640109965946 -0.29170368018457228 0.025285237582854601 -1.9265662974076237 -6.566918189038221 11.882800852636899 -15.932777082564648 17.438692779115753 -18.22042011192914 8.0332121246148137 1.5411827487176927 -0.10233941896077362 --6.5367919806052101 21.934370588257024 -38.446420469412154 48.659578328118328 -47.61825959926936 37.541873947412612 -27.285459051027202 10.849746867759121 0.90136136876684018 -43.677335897580999 -145.14386937295862 249.62855561355761 -305.97962612238287 283.49441529289605 -201.3045180908372 112.08113426821579 -55.758538983452367 19.305111497380616 diff --git a/cgyro/tools/egrid/egrid.9.5 b/cgyro/tools/egrid/egrid.9.5 deleted file mode 100644 index a8434712c..000000000 --- a/cgyro/tools/egrid/egrid.9.5 +++ /dev/null @@ -1,18 +0,0 @@ -0.00097886782892669946 0.00017597471176321896 -0.02567178808317328 0.0099095292151211521 -0.14117370325715766 0.069688199497278397 -0.43121290499880005 0.19368641546813713 -0.96289129553539191 0.28151301278742347 -1.7632919872321582 0.23872321498151677 -2.7932169048369309 0.12775454916905547 -3.899748878723051 0.047474751210847202 -4.7603428860938834 0.031074352958857183 --35.041755684675781 55.475552191400032 -33.838142593258773 21.630549388597811 -12.620103893365275 6.3563497304054818 -2.6733885077845453 0.89882795928887816 -0.18788859060782912 --5.4213957555786183 -5.9943531128108243 16.90709976779062 -8.5181827318579709 4.5647411294930317 -2.2064852148214233 0.90704339987856844 -0.30094977272179732 0.062482290628413575 -1.2454496304336538 -6.3676515460456017 -1.4951355615194338 9.23768222278637 -3.7983623414442927 1.6606004295776609 -0.64924589099249744 0.20958379327475391 -0.042920736070613065 --0.59103452977671594 2.3816765400663612 -6.8578608788872998 0.45265166204305842 6.1052030695681323 -2.0296508123777509 0.71429041480876884 -0.21906859653890586 0.043793131094351674 -0.4390106512869969 -1.6248706823679417 3.5899538584660072 -7.7726110703557771 1.853704612930063 4.4347338333401364 -1.1850879183041481 0.32793962872479807 -0.062772913720134644 --0.467894618580027 1.6620030251486279 -3.3211291149716904 5.4678461810782854 -9.384166356015571 3.1836434567065218 3.4639744133848763 -0.73265602789147067 0.1283790411404478 -0.69537251038659073 -2.4142043668936875 4.5882280862865397 -6.7996249599904074 8.8612274637147457 -12.240237675110532 4.7772808196394703 2.9356072703358259 -0.4036491483685449 --1.4727472479508296 5.0458715255911088 -9.3301728836234634 13.136705634230753 -15.446618489173197 16.308405738649779 -18.492437514820508 7.7528783707298102 2.4981148663665469 -5.7540934826007904 -19.580508654474599 35.712809238334049 -49.083689222940431 55.263280959418719 -53.410957827384848 47.525325918717822 -46.691439331228618 24.511085436957115 diff --git a/cgyro/tools/egrid/egrid.9.6 b/cgyro/tools/egrid/egrid.9.6 deleted file mode 100644 index c22b3ea00..000000000 --- a/cgyro/tools/egrid/egrid.9.6 +++ /dev/null @@ -1,18 +0,0 @@ -0.0011178021862322767 0.00021465967047412486 -0.029266839259130881 0.012008518470478389 -0.16066803598275914 0.082898680089322051 -0.49057761816888328 0.22165602723382999 -1.0978550653535201 0.30111749410444044 -2.0221783376104521 0.22973557558551471 -3.2367861981558394 0.10559066624369419 -4.5869923722803036 0.032307459866778075 -5.6844250286378568 0.014470918735468026 --35.905634817729617 56.75606021365534 -34.36246464083079 21.597322572543701 -12.220065170658962 5.8626672349931147 -2.2995979266128617 0.70838664092289168 -0.13667410628281623 --5.5800377498971067 -6.0989214512618009 17.229187506401506 -8.5328139460059622 4.4332138096046943 -2.0405260024663788 0.78200935514345028 -0.23763152630360556 0.04552000478520302 -1.2935617335530548 -6.5969433545352749 -1.426921059759856 9.3293870660483647 -3.7174226467637013 1.5467258183263659 -0.56340643281898292 0.16644886411813755 -0.031429988168107776 --0.62449235610846252 2.5095427135307213 -7.1660109949586862 0.64686663614914026 6.0677747647713037 -1.9183458450207574 0.62841845108206153 -0.17620016452397707 0.032446795078656451 -0.47719967657407124 -1.7608420454964884 3.8562546515753715 -8.1946207298818426 2.169079252913447 4.2985979686868459 -1.0679475847733743 0.26978689261033218 -0.047508082208362568 --0.53076456527751884 1.8789875985879083 -3.7197791673408566 6.0062910102829834 -9.9656788378212851 3.6149065175165722 3.2399565898153991 -0.62439178810284757 0.10047264233964508 -0.83690958267639142 -2.8947674760066405 5.4468520609937724 -7.9094875735107735 9.9529071246199307 -13.024442626235803 5.2936207353877675 2.6296783818906461 -0.33127020981529134 --1.9055439817592628 6.5017127165268996 -11.893963372082667 16.39184022392555 -18.584155985902128 18.552358194295684 -19.436793408286413 8.2013413075027617 2.1732043057795745 -7.9441026466315758 -26.911382384883672 48.528846461228766 -65.223364572397421 70.713036228001326 -64.50594645370633 52.907148460676538 -46.958103264832369 23.505662879281586 diff --git a/cgyro/tools/egrid/egrid.9.8 b/cgyro/tools/egrid/egrid.9.8 deleted file mode 100644 index fc4a76e51..000000000 --- a/cgyro/tools/egrid/egrid.9.8 +++ /dev/null @@ -1,18 +0,0 @@ -0.0013521884854722962 0.00028541951688299264 -0.035302538758994193 0.015788928019662101 -0.19322119719597086 0.10564631326900017 -0.5894654378958968 0.26471204938498172 -1.32347701343901 0.32078811699616074 -2.460708622278783 0.20379934167848753 -4.0096557518488259 0.070986674062383296 -5.8455793720380635 0.014731806957627389 -7.4880555912730103 0.0032613501148140669 --37.668669341358577 59.391141994466185 -35.515870100323347 21.703263063477603 -11.663922062853115 5.1468909791446786 -1.7798688053657703 0.4615909809806818 -0.074556708168339927 --5.8984555978739777 -6.3230797221815444 17.913034649593644 -8.622072205566463 4.2529093484532487 -1.7995283361642924 0.60762823636934268 -0.15532564832953287 0.024889275699574869 -1.3883360726584678 -7.0505772714447417 -1.312879818085883 9.5574118494237392 -3.6128436135681145 1.3806345645273212 -0.44260135027626208 0.10984550838002634 -0.017325941614553254 --0.68982168202881596 2.7593502087607981 -7.7710545626071392 1.0000937681641252 6.0518651004069904 -1.7551001717251245 0.5051908992585248 -0.118751173482101 0.018227613252742098 -0.55302646079728154 -2.0303494393804192 4.3820599674104956 -9.0277336025395924 2.7510864103202324 4.1048609998107388 -0.89414786331775071 0.18883091352942029 -0.027633846630406283 --0.66235138344173168 2.3317690301927336 -4.5451693710146989 7.1061370823329554 -11.141422188814013 4.4200175949857765 2.8935195670954071 -0.46433205353322013 0.061831722196791143 -1.1633057388731006 -3.9987770224955378 7.4002512429810296 -10.388422189572517 12.325766030063627 -14.695650813458488 6.2760068481166916 2.1392077972869515 -0.22168763179485729 --3.0571524618810546 10.358248359497235 -18.611009779810506 24.744910477312133 -26.377375074985468 23.897087256068324 -21.677384306833663 9.0971745034369336 1.6255010271960659 -14.722630764474175 -49.487363360945333 87.52324136589234 -113.24438945241022 115.09030366565807 -94.878226927156382 66.978324701001675 -48.464770513116568 21.760249756602245 diff --git a/cgyro/tools/egrid/script b/cgyro/tools/egrid/script deleted file mode 100755 index d2027f0eb..000000000 --- a/cgyro/tools/egrid/script +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -nvec="3 4 5 6 7 8 9 10 11 12" -evec="5 6 8 10 12" - -for n in $nvec -do - for e in $evec - do - python $GACODE_ROOT/shared/math/gauss_exp_quad.py $e $n 0 - OUT=egrid.$n.$e - mv out.cgyro.egrid $OUT - echo "Created $OUT" - done -done diff --git a/cgyro/tools/input/reg01/out.cgyro.prec.1 b/cgyro/tools/input/reg01/out.cgyro.prec.1 new file mode 100644 index 000000000..d0575a24a --- /dev/null +++ b/cgyro/tools/input/reg01/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.013013119164E+00 +2.486568726776E+00 +2.559561538001E+00 +2.473776730333E+00 +2.420263807834E+00 +2.396080604402E+00 +2.402558768716E+00 +2.425182399755E+00 diff --git a/cgyro/tools/input/reg01/out.cgyro.prec.2 b/cgyro/tools/input/reg01/out.cgyro.prec.2 new file mode 100644 index 000000000..f68737c0b --- /dev/null +++ b/cgyro/tools/input/reg01/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +2.013013119164E+00 +2.486568726776E+00 +2.559561538001E+00 +2.473776730333E+00 +2.420263807834E+00 +2.396080604402E+00 +2.402558768716E+00 +2.425182399755E+00 +2.454628140585E+00 +2.483013963694E+00 +2.505870980565E+00 +2.521047993198E+00 diff --git a/cgyro/tools/input/reg02/out.cgyro.prec.1 b/cgyro/tools/input/reg02/out.cgyro.prec.1 new file mode 100644 index 000000000..5b4dccf95 --- /dev/null +++ b/cgyro/tools/input/reg02/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.979346853662E+00 +2.508012799496E+00 +2.574077406326E+00 +2.504034806000E+00 +2.452071665652E+00 +2.433113352374E+00 +2.443397378591E+00 +2.469445542057E+00 diff --git a/cgyro/tools/input/reg02/out.cgyro.prec.2 b/cgyro/tools/input/reg02/out.cgyro.prec.2 new file mode 100644 index 000000000..24ae6f96a --- /dev/null +++ b/cgyro/tools/input/reg02/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.979346853662E+00 +2.508012799496E+00 +2.574077406326E+00 +2.504034806000E+00 +2.452071665652E+00 +2.433113352374E+00 +2.443397378591E+00 +2.469445542057E+00 +2.500154168710E+00 +2.527804972465E+00 +2.548148846507E+00 +2.559807893916E+00 diff --git a/cgyro/tools/input/reg03/out.cgyro.prec.1 b/cgyro/tools/input/reg03/out.cgyro.prec.1 new file mode 100644 index 000000000..947ab9d87 --- /dev/null +++ b/cgyro/tools/input/reg03/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.421669971683E+00 +2.307245962457E+00 +2.524153058625E+00 +2.561615140337E+00 +2.429605635528E+00 +2.403103209457E+00 +2.387877290711E+00 +2.366290588048E+00 diff --git a/cgyro/tools/input/reg03/out.cgyro.prec.2 b/cgyro/tools/input/reg03/out.cgyro.prec.2 new file mode 100644 index 000000000..d46bab095 --- /dev/null +++ b/cgyro/tools/input/reg03/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +2.421669971683E+00 +2.307245962457E+00 +2.524153058625E+00 +2.561615140337E+00 +2.429605635528E+00 +2.403103209457E+00 +2.387877290711E+00 +2.366290588048E+00 +2.362318747903E+00 +2.362541441803E+00 +2.362472161487E+00 +2.364531625492E+00 diff --git a/cgyro/tools/input/reg04/out.cgyro.prec.1 b/cgyro/tools/input/reg04/out.cgyro.prec.1 new file mode 100644 index 000000000..20c4d349b --- /dev/null +++ b/cgyro/tools/input/reg04/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +8.723019189894E-01 +3.922565014553E+00 +4.221614198458E+00 +4.491679856946E+00 +4.473821806778E+00 +4.470422978528E+00 +4.379870852232E+00 +4.317550367044E+00 diff --git a/cgyro/tools/input/reg04/out.cgyro.prec.2 b/cgyro/tools/input/reg04/out.cgyro.prec.2 new file mode 100644 index 000000000..f5d55e5e9 --- /dev/null +++ b/cgyro/tools/input/reg04/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +8.723019189894E-01 +3.922565014553E+00 +4.221614198458E+00 +4.491679856946E+00 +4.473821806778E+00 +4.470422978528E+00 +4.379870852232E+00 +4.317550367044E+00 +4.277701338439E+00 +4.245213280151E+00 +4.222512341360E+00 +4.207953623964E+00 diff --git a/cgyro/tools/input/reg05/out.cgyro.prec.1 b/cgyro/tools/input/reg05/out.cgyro.prec.1 new file mode 100644 index 000000000..f38b10f94 --- /dev/null +++ b/cgyro/tools/input/reg05/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.870402145742E-04 +3.458409451344E-04 +4.639347854870E-04 +5.427862510043E-04 +5.925446017430E-04 +6.265709885667E-04 +6.573655601493E-04 +6.950033032386E-04 diff --git a/cgyro/tools/input/reg05/out.cgyro.prec.2 b/cgyro/tools/input/reg05/out.cgyro.prec.2 new file mode 100644 index 000000000..9869dc227 --- /dev/null +++ b/cgyro/tools/input/reg05/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.870402145742E-04 +3.458409451344E-04 +4.639347854870E-04 +5.427862510043E-04 +5.925446017430E-04 +6.265709885667E-04 +6.573655601493E-04 +6.950033032386E-04 +7.477440506395E-04 +8.225500588855E-04 +9.259382570892E-04 +1.064422742241E-03 diff --git a/cgyro/tools/input/reg06/out.cgyro.prec.1 b/cgyro/tools/input/reg06/out.cgyro.prec.1 new file mode 100644 index 000000000..a35a0deee --- /dev/null +++ b/cgyro/tools/input/reg06/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.279651406955E-03 +2.399311429728E-03 +3.497741973365E-03 +5.037420719768E-03 +8.204438224472E-03 +1.398363333973E-02 +2.391820265253E-02 +4.150226324676E-02 diff --git a/cgyro/tools/input/reg06/out.cgyro.prec.2 b/cgyro/tools/input/reg06/out.cgyro.prec.2 new file mode 100644 index 000000000..565e83668 --- /dev/null +++ b/cgyro/tools/input/reg06/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.279651406955E-03 +2.399311429728E-03 +3.497741973365E-03 +5.037420719768E-03 +8.204438224472E-03 +1.398363333973E-02 +2.391820265253E-02 +4.150226324676E-02 +7.402538034069E-02 +1.442278751776E-01 +2.933799857723E-01 +6.059408567834E-01 diff --git a/cgyro/tools/input/reg07/out.cgyro.prec.1 b/cgyro/tools/input/reg07/out.cgyro.prec.1 new file mode 100644 index 000000000..1a5d58d49 --- /dev/null +++ b/cgyro/tools/input/reg07/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.874828574249E-04 +3.498799027781E-04 +4.781834107938E-04 +5.767228615583E-04 +6.563167839234E-04 +7.277945434430E-04 +7.984600858466E-04 +8.715835735689E-04 diff --git a/cgyro/tools/input/reg07/out.cgyro.prec.2 b/cgyro/tools/input/reg07/out.cgyro.prec.2 new file mode 100644 index 000000000..99ba3c0b3 --- /dev/null +++ b/cgyro/tools/input/reg07/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.874828574249E-04 +3.498799027781E-04 +4.781834107938E-04 +5.767228615583E-04 +6.563167839234E-04 +7.277945434430E-04 +7.984600858466E-04 +8.715835735689E-04 +9.474364432724E-04 +1.023881431146E-03 +1.097122731828E-03 +1.160698794088E-03 diff --git a/cgyro/tools/input/reg08/out.cgyro.prec.1 b/cgyro/tools/input/reg08/out.cgyro.prec.1 new file mode 100644 index 000000000..5dc5b47c6 --- /dev/null +++ b/cgyro/tools/input/reg08/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.370589712493E+00 +2.384271985470E+00 +2.561022875987E+00 +2.627239705581E+00 +2.573511547085E+00 +2.562847192966E+00 +2.563369314914E+00 +2.558757886050E+00 diff --git a/cgyro/tools/input/reg08/out.cgyro.prec.2 b/cgyro/tools/input/reg08/out.cgyro.prec.2 new file mode 100644 index 000000000..c078e5d45 --- /dev/null +++ b/cgyro/tools/input/reg08/out.cgyro.prec.2 @@ -0,0 +1,9 @@ +2.370589712493E+00 +2.384271985470E+00 +2.561022875987E+00 +2.627239705581E+00 +2.573511547085E+00 +2.562847192966E+00 +2.563369314914E+00 +2.558757886050E+00 +2.557567320249E+00 diff --git a/cgyro/tools/input/reg09/out.cgyro.prec.1 b/cgyro/tools/input/reg09/out.cgyro.prec.1 new file mode 100644 index 000000000..15541f60b --- /dev/null +++ b/cgyro/tools/input/reg09/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.279823859110E-03 +2.420361783525E-03 +3.548259949601E-03 +5.132832971564E-03 +8.403746796842E-03 +1.438153973583E-02 +2.470204676818E-02 +4.305302986243E-02 diff --git a/cgyro/tools/input/reg09/out.cgyro.prec.2 b/cgyro/tools/input/reg09/out.cgyro.prec.2 new file mode 100644 index 000000000..54715afda --- /dev/null +++ b/cgyro/tools/input/reg09/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.279823859110E-03 +2.420361783525E-03 +3.548259949601E-03 +5.132832971564E-03 +8.403746796842E-03 +1.438153973583E-02 +2.470204676818E-02 +4.305302986243E-02 +7.717675763479E-02 +1.513932781538E-01 +3.092477818032E-01 +6.410808829719E-01 diff --git a/cgyro/tools/input/reg10/out.cgyro.prec.1 b/cgyro/tools/input/reg10/out.cgyro.prec.1 new file mode 100644 index 000000000..51f0f60b6 --- /dev/null +++ b/cgyro/tools/input/reg10/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.101502827565E+00 +1.633603073065E+00 +2.047170567269E+00 +2.648606283857E+00 +3.255350458294E+00 +3.765533902115E+00 +4.025664356559E+00 +3.873436452363E+00 diff --git a/cgyro/tools/input/reg10/out.cgyro.prec.2 b/cgyro/tools/input/reg10/out.cgyro.prec.2 new file mode 100644 index 000000000..e724cfd6f --- /dev/null +++ b/cgyro/tools/input/reg10/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.101502827565E+00 +1.633603073065E+00 +2.047170567269E+00 +2.648606283857E+00 +3.255350458294E+00 +3.765533902115E+00 +4.025664356559E+00 +3.873436452363E+00 +3.318962359148E+00 +2.911720396277E+00 +2.777991128462E+00 +2.620672104498E+00 diff --git a/cgyro/tools/input/reg11/out.cgyro.prec.1 b/cgyro/tools/input/reg11/out.cgyro.prec.1 new file mode 100644 index 000000000..1c18db7f4 --- /dev/null +++ b/cgyro/tools/input/reg11/out.cgyro.prec.1 @@ -0,0 +1,16 @@ +1.316064580013E+00 +2.006581595910E+00 +2.390519084792E+00 +2.488440650372E+00 +2.485484898183E+00 +2.560143360494E+00 +2.527940553213E+00 +2.474071035919E+00 +2.449276535063E+00 +2.420591248181E+00 +2.405003080415E+00 +2.396328451931E+00 +2.399969896097E+00 +2.403241100832E+00 +2.412604984369E+00 +2.425444561401E+00 diff --git a/cgyro/tools/input/reg11/out.cgyro.prec.2 b/cgyro/tools/input/reg11/out.cgyro.prec.2 new file mode 100644 index 000000000..22b4d44b8 --- /dev/null +++ b/cgyro/tools/input/reg11/out.cgyro.prec.2 @@ -0,0 +1,24 @@ +1.316064580013E+00 +2.006581595910E+00 +2.390519084792E+00 +2.488440650372E+00 +2.485484898183E+00 +2.560143360494E+00 +2.527940553213E+00 +2.474071035919E+00 +2.449276535063E+00 +2.420591248181E+00 +2.405003080415E+00 +2.396328451931E+00 +2.399969896097E+00 +2.403241100832E+00 +2.412604984369E+00 +2.425444561401E+00 +2.439901682643E+00 +2.454904964522E+00 +2.469506936672E+00 +2.483304562283E+00 +2.495626713599E+00 +2.506172359164E+00 +2.514764664295E+00 +2.521354688032E+00 diff --git a/cgyro/tools/input/reg12/out.cgyro.prec.1 b/cgyro/tools/input/reg12/out.cgyro.prec.1 new file mode 100644 index 000000000..f865e054b --- /dev/null +++ b/cgyro/tools/input/reg12/out.cgyro.prec.1 @@ -0,0 +1,80 @@ +1.469587008039E-02 +1.616316399211E-02 +1.576713132328E-02 +1.406815395677E-02 +1.598907613720E-02 +1.306236101631E-02 +1.407190958068E-02 +1.324734001040E-02 +1.123779361754E-02 +1.267188218223E-02 +9.522388999330E-03 +1.010224578072E-02 +9.034629147033E-03 +6.755051470026E-03 +7.901719216590E-03 +4.635374062866E-03 +4.952495289324E-03 +3.827790975603E-03 +2.870504094896E-03 +3.694801233727E-03 +2.683363810892E-03 +9.730295113092E-04 +1.786865031049E-03 +3.924817885512E-03 +3.803663934235E-03 +5.823670260700E-03 +5.297033298298E-03 +6.171445246254E-03 +8.216028495594E-03 +6.758751794733E-03 +9.551305832791E-03 +8.697819977464E-03 +9.248181908804E-03 +1.085353854845E-02 +9.087899561158E-03 +1.139481266931E-02 +1.018128889053E-02 +1.029134693332E-02 +1.143886479425E-02 +9.304016475865E-03 +1.110130508852E-02 +9.531123869895E-03 +9.174545550241E-03 +9.922845893029E-03 +7.409942489134E-03 +8.786670944171E-03 +6.894327014956E-03 +6.165247667067E-03 +6.605211508900E-03 +3.975674660630E-03 +4.900345922473E-03 +2.777839287049E-03 +1.856124083042E-03 +2.732073170450E-03 +2.920938124637E-03 +2.278374606498E-03 +2.091922094769E-03 +3.036268469160E-03 +3.058210328050E-03 +5.671820545085E-03 +4.690900845186E-03 +6.755131057997E-03 +7.568729201781E-03 +7.243012070703E-03 +9.821284263012E-03 +8.676134244378E-03 +1.043761446767E-02 +1.099322526023E-02 +1.037109030928E-02 +1.258750429909E-02 +1.114296948562E-02 +1.249776278312E-02 +1.270137356942E-02 +1.168657704874E-02 +1.348855535296E-02 +1.166458123882E-02 +1.259077029727E-02 +1.239418883687E-02 +1.098296250218E-02 +1.236551614225E-02 diff --git a/cgyro/tools/input/reg12/out.cgyro.prec.2 b/cgyro/tools/input/reg12/out.cgyro.prec.2 new file mode 100644 index 000000000..78688b481 --- /dev/null +++ b/cgyro/tools/input/reg12/out.cgyro.prec.2 @@ -0,0 +1,120 @@ +1.469587008039E-02 +1.616316399211E-02 +1.576713132328E-02 +1.406815395677E-02 +1.598907613720E-02 +1.306236101631E-02 +1.407190958068E-02 +1.324734001040E-02 +1.123779361754E-02 +1.267188218223E-02 +9.522388999330E-03 +1.010224578072E-02 +9.034629147033E-03 +6.755051470026E-03 +7.901719216590E-03 +4.635374062866E-03 +4.952495289324E-03 +3.827790975603E-03 +2.870504094896E-03 +3.694801233727E-03 +2.683363810892E-03 +9.730295113092E-04 +1.786865031049E-03 +3.924817885512E-03 +3.803663934235E-03 +5.823670260700E-03 +5.297033298298E-03 +6.171445246254E-03 +8.216028495594E-03 +6.758751794733E-03 +9.551305832791E-03 +8.697819977464E-03 +9.248181908804E-03 +1.085353854845E-02 +9.087899561158E-03 +1.139481266931E-02 +1.018128889053E-02 +1.029134693332E-02 +1.143886479425E-02 +9.304016475865E-03 +1.110130508852E-02 +9.531123869895E-03 +9.174545550241E-03 +9.922845893029E-03 +7.409942489134E-03 +8.786670944171E-03 +6.894327014956E-03 +6.165247667067E-03 +6.605211508900E-03 +3.975674660630E-03 +4.900345922473E-03 +2.777839287049E-03 +1.856124083042E-03 +2.732073170450E-03 +2.920938124637E-03 +2.278374606498E-03 +2.091922094769E-03 +3.036268469160E-03 +3.058210328050E-03 +5.671820545085E-03 +4.690900845186E-03 +6.755131057997E-03 +7.568729201781E-03 +7.243012070703E-03 +9.821284263012E-03 +8.676134244378E-03 +1.043761446767E-02 +1.099322526023E-02 +1.037109030928E-02 +1.258750429909E-02 +1.114296948562E-02 +1.249776278312E-02 +1.270137356942E-02 +1.168657704874E-02 +1.348855535296E-02 +1.166458123882E-02 +1.259077029727E-02 +1.239418883687E-02 +1.098296250218E-02 +1.236551614225E-02 +1.017082662707E-02 +1.070727652307E-02 +1.013554097239E-02 +8.401619732007E-03 +9.415350346990E-03 +6.945563151329E-03 +7.176493900517E-03 +6.336900045998E-03 +4.402409654755E-03 +5.161929962168E-03 +2.637834952746E-03 +2.621227861726E-03 +1.690744274398E-03 +2.074439463353E-03 +2.424752267134E-03 +2.518644612225E-03 +2.219792082115E-03 +3.087705661502E-03 +4.991823486085E-03 +4.225034701534E-03 +6.605666568755E-03 +6.416673029313E-03 +7.069142188908E-03 +8.733396099246E-03 +7.722050623239E-03 +9.797393566994E-03 +9.315985477973E-03 +9.641610068991E-03 +1.094468984428E-02 +9.601130435057E-03 +1.127829301770E-02 +1.043070750466E-02 +1.037266794839E-02 +1.125985010521E-02 +9.558794572785E-03 +1.080784361463E-02 +9.595401414631E-03 +9.154318483470E-03 +9.649338599401E-03 +7.624831510270E-03 diff --git a/cgyro/tools/input/reg13/out.cgyro.prec.1 b/cgyro/tools/input/reg13/out.cgyro.prec.1 new file mode 100644 index 000000000..c71dd06d4 --- /dev/null +++ b/cgyro/tools/input/reg13/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +6.767515743951E-01 +1.263322568909E+00 +1.685807857268E+00 +1.943933408378E+00 +2.093200277349E+00 +2.183379312307E+00 +2.243317828175E+00 +2.286358717479E+00 diff --git a/cgyro/tools/input/reg13/out.cgyro.prec.2 b/cgyro/tools/input/reg13/out.cgyro.prec.2 new file mode 100644 index 000000000..8b3dd1838 --- /dev/null +++ b/cgyro/tools/input/reg13/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +6.767515743951E-01 +1.263322568909E+00 +1.685807857268E+00 +1.943933408378E+00 +2.093200277349E+00 +2.183379312307E+00 +2.243317828175E+00 +2.286358717479E+00 +2.317919142261E+00 +2.340500623703E+00 +2.355950106587E+00 +2.366068634753E+00 diff --git a/cgyro/tools/input/reg14/out.cgyro.prec.1 b/cgyro/tools/input/reg14/out.cgyro.prec.1 new file mode 100644 index 000000000..a50df502e --- /dev/null +++ b/cgyro/tools/input/reg14/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.365411622234E+00 +3.277402984939E+00 +3.868223262528E+00 +3.951681412406E+00 +3.905081944058E+00 +3.805996478587E+00 +3.707545902267E+00 +3.618691366958E+00 diff --git a/cgyro/tools/input/reg14/out.cgyro.prec.2 b/cgyro/tools/input/reg14/out.cgyro.prec.2 new file mode 100644 index 000000000..630fee91a --- /dev/null +++ b/cgyro/tools/input/reg14/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +2.365411622234E+00 +3.277402984939E+00 +3.868223262528E+00 +3.951681412406E+00 +3.905081944058E+00 +3.805996478587E+00 +3.707545902267E+00 +3.618691366958E+00 +3.543816588584E+00 +3.482591858460E+00 +3.432066570646E+00 +3.390494232292E+00 diff --git a/cgyro/tools/input/reg15/out.cgyro.prec.1 b/cgyro/tools/input/reg15/out.cgyro.prec.1 new file mode 100644 index 000000000..672ebccd1 --- /dev/null +++ b/cgyro/tools/input/reg15/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.861093129360E+00 +2.820221225163E+00 +3.082079734472E+00 +3.132106621646E+00 +3.007283944062E+00 +2.985059054356E+00 +2.972139913549E+00 +2.955887581563E+00 diff --git a/cgyro/tools/input/reg15/out.cgyro.prec.2 b/cgyro/tools/input/reg15/out.cgyro.prec.2 new file mode 100644 index 000000000..76aa812b1 --- /dev/null +++ b/cgyro/tools/input/reg15/out.cgyro.prec.2 @@ -0,0 +1,10 @@ +2.861093129360E+00 +2.820221225163E+00 +3.082079734472E+00 +3.132106621646E+00 +3.007283944062E+00 +2.985059054356E+00 +2.972139913549E+00 +2.955887581563E+00 +2.954470911640E+00 +2.955102809721E+00 diff --git a/cgyro/tools/input/reg16/out.cgyro.prec.1 b/cgyro/tools/input/reg16/out.cgyro.prec.1 new file mode 100644 index 000000000..9bc10dad7 --- /dev/null +++ b/cgyro/tools/input/reg16/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +4.761292029556E+00 +7.677423412451E+00 +8.011141935648E+00 +7.360476536186E+00 +6.725492691678E+00 +6.225709845962E+00 +5.834399915796E+00 +5.530517464311E+00 diff --git a/cgyro/tools/input/reg16/out.cgyro.prec.2 b/cgyro/tools/input/reg16/out.cgyro.prec.2 new file mode 100644 index 000000000..4a5d6a213 --- /dev/null +++ b/cgyro/tools/input/reg16/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +4.761292029556E+00 +7.677423412451E+00 +8.011141935648E+00 +7.360476536186E+00 +6.725492691678E+00 +6.225709845962E+00 +5.834399915796E+00 +5.530517464311E+00 +5.299281396483E+00 +5.127813528100E+00 +5.004794488682E+00 +4.920358898018E+00 diff --git a/cgyro/tools/input/reg17/out.cgyro.prec.1 b/cgyro/tools/input/reg17/out.cgyro.prec.1 new file mode 100644 index 000000000..1a5d58d49 --- /dev/null +++ b/cgyro/tools/input/reg17/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.874828574249E-04 +3.498799027781E-04 +4.781834107938E-04 +5.767228615583E-04 +6.563167839234E-04 +7.277945434430E-04 +7.984600858466E-04 +8.715835735689E-04 diff --git a/cgyro/tools/input/reg17/out.cgyro.prec.2 b/cgyro/tools/input/reg17/out.cgyro.prec.2 new file mode 100644 index 000000000..99ba3c0b3 --- /dev/null +++ b/cgyro/tools/input/reg17/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.874828574249E-04 +3.498799027781E-04 +4.781834107938E-04 +5.767228615583E-04 +6.563167839234E-04 +7.277945434430E-04 +7.984600858466E-04 +8.715835735689E-04 +9.474364432724E-04 +1.023881431146E-03 +1.097122731828E-03 +1.160698794088E-03 diff --git a/cgyro/tools/input/reg18/out.cgyro.prec.1 b/cgyro/tools/input/reg18/out.cgyro.prec.1 new file mode 100644 index 000000000..15541f60b --- /dev/null +++ b/cgyro/tools/input/reg18/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.279823859110E-03 +2.420361783525E-03 +3.548259949601E-03 +5.132832971564E-03 +8.403746796842E-03 +1.438153973583E-02 +2.470204676818E-02 +4.305302986243E-02 diff --git a/cgyro/tools/input/reg18/out.cgyro.prec.2 b/cgyro/tools/input/reg18/out.cgyro.prec.2 new file mode 100644 index 000000000..74d915ee2 --- /dev/null +++ b/cgyro/tools/input/reg18/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.279823859110E-03 +2.420361783525E-03 +3.548259949601E-03 +5.132832971564E-03 +8.403746796842E-03 +1.438153973583E-02 +2.470204676818E-02 +4.305302986243E-02 +7.717675763480E-02 +1.513932781538E-01 +3.092477818032E-01 +6.410808829719E-01 diff --git a/cgyro/tools/input/reg19/out.cgyro.prec.1 b/cgyro/tools/input/reg19/out.cgyro.prec.1 new file mode 100644 index 000000000..226b28e13 --- /dev/null +++ b/cgyro/tools/input/reg19/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +2.475782394120E-02 +4.549663932099E-02 +5.895058001338E-02 +6.560495382805E-02 +7.097486774048E-02 +8.257273488298E-02 +1.100906226727E-01 +1.793218026003E-01 diff --git a/cgyro/tools/input/reg19/out.cgyro.prec.2 b/cgyro/tools/input/reg19/out.cgyro.prec.2 new file mode 100644 index 000000000..ea8fef9a6 --- /dev/null +++ b/cgyro/tools/input/reg19/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +2.475782394120E-02 +4.549663932099E-02 +5.895058001338E-02 +6.560495382805E-02 +7.097486774048E-02 +8.257273488298E-02 +1.100906226727E-01 +1.793218026003E-01 +2.744165711851E-01 +3.681865382361E-01 +4.923965567733E-01 +6.565633621334E-01 diff --git a/cgyro/tools/input/reg20/out.cgyro.prec.1 b/cgyro/tools/input/reg20/out.cgyro.prec.1 new file mode 100644 index 000000000..5b919d497 --- /dev/null +++ b/cgyro/tools/input/reg20/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.280344256711E-03 +2.440825475070E-03 +3.582475718422E-03 +5.171078009873E-03 +8.445611022409E-03 +1.445249181210E-02 +2.482099717833E-02 +4.326264388383E-02 diff --git a/cgyro/tools/input/reg20/out.cgyro.prec.2 b/cgyro/tools/input/reg20/out.cgyro.prec.2 new file mode 100644 index 000000000..218086105 --- /dev/null +++ b/cgyro/tools/input/reg20/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.280344256711E-03 +2.440825475070E-03 +3.582475718422E-03 +5.171078009873E-03 +8.445611022409E-03 +1.445249181210E-02 +2.482099717833E-02 +4.326264388383E-02 +7.755587905658E-02 +1.524758060437E-01 +3.114501091091E-01 +6.455609432616E-01 diff --git a/cgyro/tools/input/reg21/input.cgyro b/cgyro/tools/input/reg21/input.cgyro new file mode 100644 index 000000000..63eb01ddd --- /dev/null +++ b/cgyro/tools/input/reg21/input.cgyro @@ -0,0 +1,42 @@ +# Numerical Resolution +N_ENERGY=8 +E_MAX=8 +N_XI=16 + +N_THETA=24 +N_RADIAL=4 + +DELTA_T=0.01 +PRINT_STEP=100 +MAX_TIME=4.0 + +KY=0.3 + +# Geometry +EQUILIBRIUM_MODEL=2 +RMIN=0.5 +RMAJ=3.0 +Q=2.0 +S=1.0 + +# Collisions +COLLISION_MODEL=7 +NU_EE=0.1 + +# Profiles +N_SPECIES=2 + +Z_1=1 +DENS_1=1.0 +TEMP_1=1.0 +MASS_1=1.0 +DLNNDR_1=1.0 +DLNTDR_1=3.0 + +Z_2=-1 +DENS_2=1.0 +TEMP_2=1.0 +MASS_2=0.0002724486 +DLNNDR_2=1.0 +DLNTDR_2=3.0 + diff --git a/cgyro/tools/input/reg21/out.cgyro.prec b/cgyro/tools/input/reg21/out.cgyro.prec new file mode 100644 index 000000000..968f8f320 --- /dev/null +++ b/cgyro/tools/input/reg21/out.cgyro.prec @@ -0,0 +1,4 @@ +1.980979281808E+00 +2.509517596894E+00 +2.574336671720E+00 +2.503776663961E+00 diff --git a/cgyro/tools/input/reg21/out.cgyro.prec.1 b/cgyro/tools/input/reg21/out.cgyro.prec.1 new file mode 100644 index 000000000..8bb4be805 --- /dev/null +++ b/cgyro/tools/input/reg21/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.980979281808E+00 +2.509517596894E+00 +2.574336671720E+00 +2.503776663962E+00 +2.451533982140E+00 +2.432108723023E+00 +2.442239345311E+00 +2.468444985485E+00 diff --git a/cgyro/tools/input/reg21/out.cgyro.prec.2 b/cgyro/tools/input/reg21/out.cgyro.prec.2 new file mode 100644 index 000000000..428955e19 --- /dev/null +++ b/cgyro/tools/input/reg21/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.980979281808E+00 +2.509517596894E+00 +2.574336671720E+00 +2.503776663962E+00 +2.451533982140E+00 +2.432108723023E+00 +2.442239345311E+00 +2.468444985485E+00 +2.499403717828E+00 +2.527199800738E+00 +2.547538443893E+00 +2.559125387208E+00 diff --git a/cgyro/tools/input/reg22/input.cgyro b/cgyro/tools/input/reg22/input.cgyro new file mode 100644 index 000000000..2982419e7 --- /dev/null +++ b/cgyro/tools/input/reg22/input.cgyro @@ -0,0 +1,42 @@ +# Numerical Resolution +N_ENERGY=8 +E_MAX=8 +N_XI=16 + +N_THETA=24 +N_RADIAL=4 + +DELTA_T=0.01 +PRINT_STEP=100 +MAX_TIME=4.0 + +KY=0.3 + +# Geometry +EQUILIBRIUM_MODEL=2 +RMIN=0.5 +RMAJ=3.0 +Q=2.0 +S=1.0 + +# Collisions +COLLISION_MODEL=6 +NU_EE=0.1 + +# Profiles +N_SPECIES=2 + +Z_1=1 +DENS_1=1.0 +TEMP_1=1.0 +MASS_1=1.0 +DLNNDR_1=1.0 +DLNTDR_1=3.0 + +Z_2=-1 +DENS_2=1.0 +TEMP_2=1.0 +MASS_2=0.0002724486 +DLNNDR_2=1.0 +DLNTDR_2=3.0 + diff --git a/cgyro/tools/input/reg22/out.cgyro.prec b/cgyro/tools/input/reg22/out.cgyro.prec new file mode 100644 index 000000000..405192f78 --- /dev/null +++ b/cgyro/tools/input/reg22/out.cgyro.prec @@ -0,0 +1,4 @@ +1.972384968053E+00 +2.497025365253E+00 +2.563883017519E+00 +2.491855829059E+00 diff --git a/cgyro/tools/input/reg22/out.cgyro.prec.1 b/cgyro/tools/input/reg22/out.cgyro.prec.1 new file mode 100644 index 000000000..ce21b39ce --- /dev/null +++ b/cgyro/tools/input/reg22/out.cgyro.prec.1 @@ -0,0 +1,8 @@ +1.972384968053E+00 +2.497025365253E+00 +2.563883017519E+00 +2.491855829059E+00 +2.438986491186E+00 +2.418416515286E+00 +2.427104214808E+00 +2.451743792267E+00 diff --git a/cgyro/tools/input/reg22/out.cgyro.prec.2 b/cgyro/tools/input/reg22/out.cgyro.prec.2 new file mode 100644 index 000000000..7a47adcaa --- /dev/null +++ b/cgyro/tools/input/reg22/out.cgyro.prec.2 @@ -0,0 +1,12 @@ +1.972384968053E+00 +2.497025365253E+00 +2.563883017519E+00 +2.491855829059E+00 +2.438986491186E+00 +2.418416515286E+00 +2.427104214808E+00 +2.451743792267E+00 +2.481368850914E+00 +2.508391257159E+00 +2.528587626845E+00 +2.540553013698E+00 diff --git a/cgyro/tools/input/reg_list b/cgyro/tools/input/reg_list index 8a857e995..e66e68731 100644 --- a/cgyro/tools/input/reg_list +++ b/cgyro/tools/input/reg_list @@ -18,3 +18,5 @@ reg17 reg18 reg19 reg20 +reg21 +reg22 diff --git a/cgyro/tools/input/simdir_list b/cgyro/tools/input/simdir_list index c712f0889..f00ff4ec6 100644 --- a/cgyro/tools/input/simdir_list +++ b/cgyro/tools/input/simdir_list @@ -17,6 +17,8 @@ reg14: c1+f1+lin+ie +pro+mil+frot reg15: c4+f2+lin+ie +loc+mil+frot [GPU_BIGMEM] reg16: c1+f1+lin+i +loc+mil+ rot [negative shear] reg20: c4+f3+ nl+ie +loc+mil+nrot [t_method=1] +reg21: c7+f1+lin+ie +loc+mil+nrot +reg22: c6+f1+lin+ie +loc+mil+nrot Nonlinear cases: diff --git a/cgyro/tools/zf/getdata.py b/cgyro/tools/zf/getdata.py deleted file mode 100644 index 2a1693b0f..000000000 --- a/cgyro/tools/zf/getdata.py +++ /dev/null @@ -1,38 +0,0 @@ -# file processed by 2to3 -from __future__ import print_function, absolute_import -from builtins import map, filter, range -import sys -import numpy as np -import matplotlib.pyplot as plt -from gacodefuncs import * -from cgyro.data import cgyrodata - -# Get data directory from command line -data_dir=sys.argv[1] - -# Read data using cgyro data class -data = cgyrodata(data_dir+'/') - -print("Time vector:") -print(data.t) - -print() -print("Theta vector:") -print(data.theta) - -data.getgeo() -print() -print("B(theta):") -print(data.geo[:,2]) - -data.getdata() -print() -print("B_unit:") -print(data.b_unit) - -print() -print("Re[phi(theta)] at last time:") -print(data.phib[0,:,-1]) -print() -print("Im[phi(theta)] at last time:") -print(data.phib[1,:,-1]) diff --git a/cgyro/tools/zf/timeaverage_fields.py b/cgyro/tools/zf/timeaverage_fields.py deleted file mode 100644 index 4dd1fc70c..000000000 --- a/cgyro/tools/zf/timeaverage_fields.py +++ /dev/null @@ -1,98 +0,0 @@ -import sys -import numpy as np -import matplotlib.pyplot as plt -import math -from gacodefuncs import * -from cgyro.data import cgyrodata - -# This is the fraction of the simulation length at the end -# that is considered for the average -frac=0.5 - -# Get data directory from command line -data_dir=sys.argv[1] - -# Read data using cgyro data class -data = cgyrodata(data_dir+'/') - -# print "Time vector:" -# print data.t - -# print -# print "Theta vector:" -# print data.theta - -data.getgeo() - -data.getdata() - -ntheta=len(data.theta) -ntime=len(data.t) - -tmin=math.ceil(ntime*(1-frac)) -tlength=len(data.t[tmin:ntime]) - -rephiaver=math.fsum(list(map(math.fsum, data.phib[0,:,tmin:ntime-1])))/(ntheta*tlength) -reapaver=math.fsum(list(map(math.fsum, data.aparb[0,:,tmin:ntime-1])))/(ntheta*tlength) -rebpaver=math.fsum(list(map(math.fsum, data.bparb[0,:,tmin:ntime-1])))/(ntheta*tlength) - -imphiaver=math.fsum(list(map(math.fsum, data.phib[1,:,tmin:ntime-1])))/(ntheta*tlength) -imapaver=math.fsum(list(map(math.fsum, data.aparb[1,:,tmin:ntime-1])))/(ntheta*tlength) -imbpaver=math.fsum(list(map(math.fsum, data.bparb[1,:,tmin:ntime-1])))/(ntheta*tlength) - - -print("Average Re[delta phi] and Im[delta phi] during time interval") -print(rephiaver) -print(imphiaver) -print("Average Re[delta A||] and Im[delta A||] during time interval") -print(reapaver) -print(imapaver) -print("Average Re[delta B||] and Im[delta B||] during time interval") -print(rebpaver) -print(imbpaver) - -# writing time traces of poloidal averages into files -# Time - -with open("PhiAv.txt","w+") as fphi, open("ApaAv.txt","w+") as fapa, open("BpaAv.txt","w+") as fbpa, open("BpaCos.txt","w+") as cosbpa: - rebpcosaver=0.0 - for i in range(ntime): - rephifsa=math.fsum(data.phib[0,:,i])/ntheta - imphifsa=math.fsum(data.phib[1,:,i])/ntheta - - fphi.write("%11.3e"% (data.t[i])) - fphi.write("%11.3e"% (rephifsa)) - fphi.write("%11.3e\n"% (imphifsa)) - - reapafsa=math.fsum(data.aparb[0,:,i])/ntheta - imapafsa=math.fsum(data.aparb[1,:,i])/ntheta - - fapa.write("%11.3e"% (data.t[i])) - fapa.write("%11.3e"% (reapafsa)) - fapa.write("%11.3e\n"% (imapafsa)) - - rebpafsa=math.fsum(data.bparb[0,:,i])/ntheta - imbpafsa=math.fsum(data.bparb[1,:,i])/ntheta - - fbpa.write("%11.3e"% (data.t[i])) - fbpa.write("%11.3e"% (rebpafsa)) - fbpa.write("%11.3e\n"% (imbpafsa)) - - rebpacos=0.0 - imbpacos=0.0 - for j in range(ntheta): - rebpacos=rebpacos+2.0*math.cos(data.theta[j])*data.bparb[0,j,i]/ntheta - imbpacos=imbpacos+2.0*math.cos(data.theta[j])*data.bparb[1,j,i]/ntheta - - cosbpa.write("%11.3e"% (data.t[i])) - cosbpa.write("%11.3e"% (rebpacos)) - cosbpa.write("%11.3e\n"% (imbpacos)) - - if i >= tmin: - rebpcosaver=rebpcosaver+rebpacos/tlength - -print("Average cos component of Re[delta B||] during time interval") -print(rebpcosaver) - -# print "theta dependence of Re[delta B||] at last time point" -# print data.bparb[0,:,ntime-1] diff --git a/f2py/expro/expro_locsim.f90 b/f2py/expro/expro_locsim.f90 index 2587bcdf1..d987c6602 100644 --- a/f2py/expro/expro_locsim.f90 +++ b/f2py/expro/expro_locsim.f90 @@ -14,6 +14,7 @@ module expro_locsim_interface double precision, dimension(:,:), allocatable :: dlnndr_exp double precision, dimension(:,:), allocatable :: sdlntdr_exp double precision, dimension(:,:), allocatable :: sdlnndr_exp + double precision, dimension(:,:), allocatable :: sbeta_exp double precision, dimension(:), allocatable :: gamma_e_exp double precision, dimension(:), allocatable :: gamma_p_exp @@ -72,6 +73,7 @@ module expro_locsim_interface double precision :: beta_star_loc double precision, dimension(9) :: mass_loc + double precision, dimension(9) :: z_loc double precision, dimension(9) :: dens_loc double precision, dimension(9) :: temp_loc @@ -79,6 +81,7 @@ module expro_locsim_interface double precision, dimension(9) :: dlntdr_loc double precision, dimension(9) :: sdlnndr_loc double precision, dimension(9) :: sdlntdr_loc + double precision, dimension(9) :: sbeta_loc integer :: geo_ny_loc double precision, dimension(:,:), allocatable :: geo_yin_loc @@ -106,6 +109,7 @@ subroutine expro_locsim_alloc(flag) allocate(dlnndr_exp(n_species_exp,expro_n_exp)) allocate(sdlntdr_exp(n_species_exp,expro_n_exp)) allocate(sdlnndr_exp(n_species_exp,expro_n_exp)) + allocate(sbeta_exp(n_species_exp,expro_n_exp)) allocate(gamma_e_exp(expro_n_exp)) allocate(gamma_p_exp(expro_n_exp)) @@ -121,6 +125,7 @@ subroutine expro_locsim_alloc(flag) if (allocated(dlnndr_exp)) deallocate(dlnndr_exp) if (allocated(sdlntdr_exp)) deallocate(sdlntdr_exp) if (allocated(sdlnndr_exp)) deallocate(sdlnndr_exp) + if (allocated(sbeta_exp)) deallocate(sbeta_exp) if (allocated(gamma_e_exp)) deallocate(gamma_e_exp) if (allocated(gamma_p_exp)) deallocate(gamma_p_exp) @@ -237,11 +242,11 @@ subroutine expro_locsim_profiles(& integer :: i,j,i_ion rmin_loc = rmin - + n_species_exp = n_species_in mass_deuterium = expro_mass_deuterium*1e24 - + !-------------------------------------------------------------- ! use expro routines to read data: ! @@ -282,7 +287,7 @@ subroutine expro_locsim_profiles(& mass_loc(n_species_exp) = expro_masse z_loc(n_species_exp) = -1d0 - + ! Pack ions from the bottom do i_ion=1,n_species_exp-1 ! ion temps should be equal, but not enforced @@ -292,7 +297,7 @@ subroutine expro_locsim_profiles(& mass_loc(i_ion) = expro_mass(i_ion) z_loc(i_ion) = expro_z(i_ion) - + ! First species density is reset by quasi-neutrality if (quasineutral_flag == 1 .and. i_ion == 1) then dens_exp(i_ion,:) = expro_ni_new(:) @@ -303,6 +308,7 @@ subroutine expro_locsim_profiles(& dlnndr_exp(i_ion,:) = expro_dlnnidr(i_ion,:)*a_meters sdlnndr_exp(i_ion,:) = expro_sdlnnidr(i_ion,:)*a_meters endif + enddo ! Rotation @@ -359,7 +365,7 @@ subroutine expro_locsim_profiles(& call cub_spline1(rmin_exp,expro_polflux,expro_n_exp,rmin,psi_norm_loc) psi_norm_loc = psi_norm_loc/expro_polflux(expro_n_exp) psi_a_loc = expro_polflux(expro_n_exp) - + beta_star_loc = 0d0 do i=1,n_species_exp ! Note: mapping is only done for n_species (not n_species_exp) @@ -371,13 +377,25 @@ subroutine expro_locsim_profiles(& call cub_spline1(rmin_exp,sdlnndr_exp(i,:),expro_n_exp,rmin,sdlnndr_loc(i)) beta_star_loc = beta_star_loc+dens_loc(i)*temp_loc(i)*(dlnndr_loc(i)+dlntdr_loc(i)) enddo - ! CGS beta calculation - betae_loc = 4.027e-3*dens_loc(n_species_exp)*temp_loc(n_species_exp)/b_unit_loc**2 + ! beta calculation in CGS: + ! + ! 8*pi ( n[1e19/m^3]*1e-6*1e19 )( T[keV]*1.6022*1e-9 ) + ! beta = ------------------------------------------------------ + ! ( 1e4*B[T] )^2 + ! + ! = 4.027e-3 n[1e19/m^3]*T[keV]/B[T]^2 + + betae_loc = 4.027e-3*dens_loc(n_species_exp)*temp_loc(n_species_exp)/b_unit_loc**2 beta_star_loc = beta_star_loc*betae_loc/(dens_loc(n_species_exp)*temp_loc(n_species_exp)) + + ! Add extra effective curvature terms to omega_star shear + sdlnndr_loc = sdlnndr_loc+(1.5*dlntdr_loc**2+dlnndr_loc**2-dlnndr_loc*dlntdr_loc)*rhos_loc/a_meters + sdlntdr_loc = sdlntdr_loc+dlntdr_loc**2*rhos_loc/a_meters + sbeta_loc = beta_star_loc*(sdlnndr_loc+sdlntdr_loc-2*dlntdr_loc*dlnndr_loc*rhos_loc/a_meters)/(dlnndr_loc+dlntdr_loc) if (numeq_flag == 1 .and. expro_nfourier > 0) then - + geo_ny_loc = expro_nfourier allocate(geo_yin_exp(8,0:geo_ny_loc,expro_n_exp)) if(allocated(geo_yin_loc)) deallocate(geo_yin_loc) diff --git a/f2py/expro/expro_util.f90 b/f2py/expro/expro_util.f90 index 8b0210f3b..c0050dcd2 100644 --- a/f2py/expro/expro_util.f90 +++ b/f2py/expro/expro_util.f90 @@ -30,6 +30,7 @@ subroutine expro_compute_derived double precision :: eps0,m0,ipma double precision :: bt2_ave double precision :: bp2_ave + mp = expro_mass_deuterium/2d0 ! mass_deuterium/2.0 (g) @@ -136,7 +137,7 @@ subroutine expro_compute_derived call bound_deriv(expro_dlntedr,-log(expro_te),expro_rmin,expro_n_exp) ! NOTE: expro_sdln* will be renormalized after calculation of rhos later - + ! sne = -ne''/ne (1/m^2) [not fully normalized yet] call bound_deriv(expro_sdlnnedr,expro_ne*expro_dlnnedr,expro_rmin,expro_n_exp) expro_sdlnnedr = expro_sdlnnedr/expro_ne @@ -314,7 +315,6 @@ subroutine expro_compute_derived expro_vol(1) = 0d0 expro_volp(1) = 0d0 expro_thetascale(1) = expro_thetascale(2) - !-------------------------------------------------------------- !----------------------------------------------------------------- @@ -331,7 +331,7 @@ subroutine expro_compute_derived !----------------------------------------------------------------- !----------------------------------------------------------------- - ! Renormalize shearing parameters + ! Renormalize curvatures ! ! sn = -n''/n*rhos (1/m) ! sT = -T''/T*rhos (1/m) diff --git a/f2py/pygacode/cgyro/avconv_wrapper b/f2py/pygacode/cgyro/avconv_wrapper index 11e4c571a..9a6298634 100755 --- a/f2py/pygacode/cgyro/avconv_wrapper +++ b/f2py/pygacode/cgyro/avconv_wrapper @@ -1,7 +1,7 @@ #!/bin/bash # Comment Information -TITLE="CGYRO Turbulence" +TITLE="CGYRO TEAM" TIMESTAMP=`date -Iseconds` START=$1 @@ -10,7 +10,7 @@ QUALITY=$3 PRE=$4 # Main movie definitions -BASENAME=$PRE%d.png +BASENAME=$PRE%d.jpg OUT=${PRE}movie.mp4 if hash avconv 2>/dev/null ; then diff --git a/f2py/pygacode/cgyro/data.py b/f2py/pygacode/cgyro/data.py index 05ad1d423..721a38b79 100644 --- a/f2py/pygacode/cgyro/data.py +++ b/f2py/pygacode/cgyro/data.py @@ -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 diff --git a/f2py/pygacode/cgyro/data_plot.py b/f2py/pygacode/cgyro/data_plot.py index b7e8f51b1..309ee7106 100644 --- a/f2py/pygacode/cgyro/data_plot.py +++ b/f2py/pygacode/cgyro/data_plot.py @@ -55,7 +55,7 @@ def plot_freq(self,xin): # set normalizations t = self.getnorm(xin['norm']) - + #====================================== # Omega ax = fig.add_subplot(121) @@ -70,6 +70,13 @@ def plot_freq(self,xin): ax.set_xlim([0,t[-1]]) #====================================== + # Alfven diagnostic + rho = sum(self.mass*self.dens) + betae = self.betae_unit/self.b_gs2**2 + v_A = np.sqrt(2/(betae*rho)) + w_TAE = v_A/(2*self.q*self.rmaj) + ax.plot([0,t[-1]],[w_TAE,w_TAE],linestyle='--') + #====================================== # Gamma ax = fig.add_subplot(122) diff --git a/f2py/pygacode/cgyro/data_template.py b/f2py/pygacode/cgyro/data_template.py new file mode 100644 index 000000000..cf0e61d6a --- /dev/null +++ b/f2py/pygacode/cgyro/data_template.py @@ -0,0 +1,14 @@ +import os +import numpy as np +from gacodefuncs import * +from cgyro.data import cgyrodata + +sim = cgyrodata('reg01/') + +# all relevant quantities available in gacode/f2py/pygacode/cgyro/data.py + +print('kappa',sim.kappa) +print('ky*rho',sim.ky0) + +print('omega',sim.freq[0,0,-1]) +print('gamma',sim.freq[1,0,-1]) diff --git a/f2py/pygacode/cgyro/vis_torcut.py b/f2py/pygacode/cgyro/vis_torcut.py index df171dffa..6b05e6b42 100644 --- a/f2py/pygacode/cgyro/vis_torcut.py +++ b/f2py/pygacode/cgyro/vis_torcut.py @@ -182,7 +182,7 @@ def frame(): ax.set_ylabel("Z/a") ax.set_xlabel("R/a") else: - mlab.figure(size=(900,900),bgcolor=(1,1,1)) + mlab.figure(size=(350,500),bgcolor=(1,1,1)) if isfield: c = a[0,:,:,:]+1j*a[1,:,:,:] @@ -213,6 +213,7 @@ def frame(): # View from positive z-axis mlab.view(azimuth=0, elevation=0) + print('INFO: (vis_torcut) min={:.3E} | max={:.3E}'.format(f0,f1)) if ftype == 'screen': @@ -226,7 +227,7 @@ def frame(): plt.close("all") else: # Filename uses frame number - mlab.savefig(pre+str(i)+'.'+ftype) + mlab.savefig(pre+str(i)+'.'+ftype,magnification=2) # Close each time to prevent memory accumulation mlab.close() diff --git a/f2py/pygacode/gacodeinput.py b/f2py/pygacode/gacodeinput.py index 504a0f764..da64f5570 100644 --- a/f2py/pygacode/gacodeinput.py +++ b/f2py/pygacode/gacodeinput.py @@ -247,6 +247,8 @@ def read_input(self,datafile): # Detect the code to be run in each directory if os.path.isfile(basedir+'/input.gyro'): code='gyro' + elif os.path.isfile(basedir+'/input.qlgyro'): + code='qlgyro' elif os.path.isfile(basedir+'/input.cgyro'): code='cgyro' elif os.path.isfile(basedir+'/input.tglf'): diff --git a/gyro/install/make.ext.OSX_SONOMA b/gyro/install/make.ext.OSX_SONOMA new file mode 100644 index 000000000..aaf9436e5 --- /dev/null +++ b/gyro/install/make.ext.OSX_SONOMA @@ -0,0 +1,4 @@ +gyro_nl_setup.o : gyro_nl_setup.legacy.f90 + $(FC) $(FMATH) $(FFLAGS) -o gyro_nl_setup.o -c gyro_nl_setup.legacy.f90 +gyro_nl_fft.o : gyro_nl_fft.legacy.f90 + $(FC) $(FMATH) $(FFLAGS) -o gyro_nl_fft.o -c gyro_nl_fft.legacy.f90 diff --git a/gyro/src/Makefile b/gyro/src/Makefile index 080ea6fc7..7e39b9679 100644 --- a/gyro/src/Makefile +++ b/gyro/src/Makefile @@ -141,7 +141,8 @@ OBJECTS += gyro_globals.o \ gyro_write_step.o \ gyro_write_timedata.o \ gyro_write_timers.o \ - gyro_velocity_sum.o + gyro_velocity_sum.o \ + i0.o .SUFFIXES : .o .f90 diff --git a/gyro/src/gyro_ballooning_mode.f90 b/gyro/src/gyro_ballooning_mode.f90 index ed2a9d109..3b29ffb96 100644 --- a/gyro/src/gyro_ballooning_mode.f90 +++ b/gyro/src/gyro_ballooning_mode.f90 @@ -11,7 +11,6 @@ subroutine gyro_ballooning_mode(datafile,io,index,is_in) use gyro_globals - use math_constants !-------------------------------------------------- implicit none diff --git a/gyro/src/gyro_banana_operators.f90 b/gyro/src/gyro_banana_operators.f90 index 1b942ecd0..511825807 100644 --- a/gyro/src/gyro_banana_operators.f90 +++ b/gyro/src/gyro_banana_operators.f90 @@ -39,7 +39,6 @@ subroutine gyro_banana_operators use gyro_globals - use math_constants !------------------------------------------- implicit none @@ -210,7 +209,7 @@ subroutine gyro_banana_operators ! (evenly-spaced on [-pi,pi]) ! do j=1,n_theta_int - theta_int(j) = -pi+(j-1)*pi_2/n_theta_int + theta_int(j) = -pi+(j-1)*2*pi/n_theta_int enddo if (n_theta_plot > 1) then @@ -218,7 +217,7 @@ subroutine gyro_banana_operators ! Span [-pi,pi] do j=1,n_theta_plot - theta_plot(j) = -pi+(j-1)*pi_2/n_theta_plot + theta_plot(j) = -pi+(j-1)*2*pi/n_theta_plot enddo else diff --git a/gyro/src/gyro_bessel_operator.f90 b/gyro/src/gyro_bessel_operator.f90 index ce33f2207..3143a4436 100644 --- a/gyro/src/gyro_bessel_operator.f90 +++ b/gyro/src/gyro_bessel_operator.f90 @@ -42,8 +42,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) - use gyro_globals, only : z_gyro, i_gyro, m_gyro, n_x - use math_constants + use gyro_globals, only : i_c,pi,z_gyro, i_gyro, m_gyro, n_x !----------------------------------------- implicit none @@ -74,7 +73,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! J_0 do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = bessel_j0(x)/n_x enddo @@ -82,7 +81,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! J_0^2 do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = bessel_j0(x)**2/n_x enddo @@ -92,15 +91,15 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! The factor -(i/2) will be applied outside this loop do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) - func(p) = (pi_2*p*a+u)*rho*(bessel_j0(x)+bessel_jn(2,x))/n_x + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) + func(p) = (2*pi*p*a+u)*rho*(bessel_j0(x)+bessel_jn(2,x))/n_x enddo case (4) ! G = (1/2)*[ J_0(z)+J_2(z) ] do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = 0.5*(bessel_j0(x)+bessel_jn(2,x))/n_x enddo @@ -108,7 +107,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! G^2 do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = (0.5*(bessel_j0(x)+bessel_jn(2,x)))**2/n_x enddo @@ -116,7 +115,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! G * J_0 do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = 0.5*(bessel_j0(x)+bessel_jn(2,x))*bessel_j0(x)/n_x enddo @@ -124,7 +123,7 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! I_0 do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) func(p) = besei0(x*x)/n_x enddo @@ -135,8 +134,8 @@ subroutine gyro_bessel_operator(rho,a,u,v,g,itype) ! The factor i will be applied outside this loop if (u**2+v**2 > 1e-8) then do p=-p0,p0-1 - x = abs(rho)*sqrt((pi_2*p*a+u)**2+v**2) - func(p) = (pi_2*p*a+u)*rho*(bessel_j0(x)-bessel_j1(x)/x)/x**2/n_x + x = abs(rho)*sqrt((2*pi*p*a+u)**2+v**2) + func(p) = (2*pi*p*a+u)*rho*(bessel_j0(x)-bessel_j1(x)/x)/x**2/n_x enddo else ! Case is n=0, which will ultimately give zero contribution so we diff --git a/gyro/src/gyro_bessel_stencils.f90 b/gyro/src/gyro_bessel_stencils.f90 index bc3d54af6..e69e8ddf0 100644 --- a/gyro/src/gyro_bessel_stencils.f90 +++ b/gyro/src/gyro_bessel_stencils.f90 @@ -10,7 +10,6 @@ subroutine gyro_bessel_stencils use gyro_globals use gyro_pointers - use math_constants !----------------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_blend_ampere.f90 b/gyro/src/gyro_blend_ampere.f90 index 46d5c5bd7..b49580b87 100644 --- a/gyro/src/gyro_blend_ampere.f90 +++ b/gyro/src/gyro_blend_ampere.f90 @@ -11,7 +11,6 @@ subroutine gyro_blend_ampere use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_blend_ampereperp.f90 b/gyro/src/gyro_blend_ampereperp.f90 index 9b1d7bed3..51ed74b7e 100644 --- a/gyro/src/gyro_blend_ampereperp.f90 +++ b/gyro/src/gyro_blend_ampereperp.f90 @@ -10,7 +10,6 @@ subroutine gyro_blend_ampereperp use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_blend_poisson.f90 b/gyro/src/gyro_blend_poisson.f90 index 3e785de32..718cd0623 100644 --- a/gyro/src/gyro_blend_poisson.f90 +++ b/gyro/src/gyro_blend_poisson.f90 @@ -13,7 +13,6 @@ subroutine gyro_blend_poisson(i_elec) use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_bounce_points.f90 b/gyro/src/gyro_bounce_points.f90 index 4e98b20e6..fe2e6e615 100644 --- a/gyro/src/gyro_bounce_points.f90 +++ b/gyro/src/gyro_bounce_points.f90 @@ -18,7 +18,6 @@ subroutine gyro_bounce_points(lambda,theta_bp,theta_bm) - use math_constants use geo !--------------------------------- @@ -41,8 +40,11 @@ subroutine gyro_bounce_points(lambda,theta_bp,theta_bm) real :: dtheta ! real :: b0 + real :: pi !--------------------------------- + pi = 4.0*atan(1.0) + theta_b = 0.0 call geo_interp(1,theta_b,.false.) ; b0 = GEO_b(1) lambda_max = 1.0/b0 diff --git a/gyro/src/gyro_build_sparse_ampere.f90 b/gyro/src/gyro_build_sparse_ampere.f90 index 69f112e83..c17e70616 100644 --- a/gyro/src/gyro_build_sparse_ampere.f90 +++ b/gyro/src/gyro_build_sparse_ampere.f90 @@ -9,7 +9,6 @@ subroutine gyro_build_sparse_ampere use gyro_globals use gyro_collision_private - use math_constants !------------------------ implicit none diff --git a/gyro/src/gyro_build_sparse_maxwell.f90 b/gyro/src/gyro_build_sparse_maxwell.f90 index 0264b6e80..b588a02e5 100644 --- a/gyro/src/gyro_build_sparse_maxwell.f90 +++ b/gyro/src/gyro_build_sparse_maxwell.f90 @@ -24,7 +24,6 @@ subroutine gyro_build_sparse_maxwell use gyro_globals - use math_constants use gyro_maxwell_private !------------------------ diff --git a/gyro/src/gyro_build_sparse_poisson.f90 b/gyro/src/gyro_build_sparse_poisson.f90 index 7b0f99d97..dfe5d4730 100644 --- a/gyro/src/gyro_build_sparse_poisson.f90 +++ b/gyro/src/gyro_build_sparse_poisson.f90 @@ -12,7 +12,6 @@ subroutine gyro_build_sparse_poisson use gyro_globals - use math_constants use gyro_poisson_private !------------------------ diff --git a/gyro/src/gyro_build_sparse_poissonaperp.f90 b/gyro/src/gyro_build_sparse_poissonaperp.f90 index a60712c5a..cc85ea98a 100644 --- a/gyro/src/gyro_build_sparse_poissonaperp.f90 +++ b/gyro/src/gyro_build_sparse_poissonaperp.f90 @@ -8,7 +8,6 @@ subroutine gyro_build_sparse_poissonaperp use gyro_globals - use math_constants use gyro_poissonaperp_private !------------------------ diff --git a/gyro/src/gyro_collision_grid_write.f90 b/gyro/src/gyro_collision_grid_write.f90 index be0b4f41c..f365e4217 100644 --- a/gyro/src/gyro_collision_grid_write.f90 +++ b/gyro/src/gyro_collision_grid_write.f90 @@ -2,7 +2,6 @@ subroutine gyro_collision_grid_write(datafile,io) use gyro_globals use gyro_collision_private - use math_constants !---------------------------------------- implicit none diff --git a/gyro/src/gyro_collision_kernel.f90 b/gyro/src/gyro_collision_kernel.f90 index 47b70c078..a62c342b6 100644 --- a/gyro/src/gyro_collision_kernel.f90 +++ b/gyro/src/gyro_collision_kernel.f90 @@ -11,7 +11,6 @@ subroutine gyro_collision_kernel(ic) use gyro_globals use gyro_collision_private use gyro_pointers - use math_constants !-------------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_collision_setup.f90 b/gyro/src/gyro_collision_setup.f90 index ac161dcf3..a305895c3 100644 --- a/gyro/src/gyro_collision_setup.f90 +++ b/gyro/src/gyro_collision_setup.f90 @@ -31,7 +31,6 @@ subroutine gyro_collision_setup use gyro_globals use gyro_collision_private use gyro_pointers - use math_constants !----------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_do.f90 b/gyro/src/gyro_do.f90 index 2c62a3b08..0faabe168 100644 --- a/gyro/src/gyro_do.f90 +++ b/gyro/src/gyro_do.f90 @@ -11,7 +11,6 @@ subroutine gyro_do use gyro_globals use gyro_pointers use gyro_interface - use math_constants use geo !-------------------------------------- diff --git a/gyro/src/gyro_entropy.f90 b/gyro/src/gyro_entropy.f90 index d7a6ed7b2..b7902c984 100644 --- a/gyro/src/gyro_entropy.f90 +++ b/gyro/src/gyro_entropy.f90 @@ -22,7 +22,6 @@ subroutine gyro_entropy use mpi use gyro_globals use gyro_pointers - use math_constants !------------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_field_plot.f90 b/gyro/src/gyro_field_plot.f90 index b5d507537..2a7a1bbe3 100644 --- a/gyro/src/gyro_field_plot.f90 +++ b/gyro/src/gyro_field_plot.f90 @@ -9,7 +9,6 @@ subroutine gyro_field_plot use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_field_time_derivative.f90 b/gyro/src/gyro_field_time_derivative.f90 index e86e1b4fa..d887f3dcb 100644 --- a/gyro/src/gyro_field_time_derivative.f90 +++ b/gyro/src/gyro_field_time_derivative.f90 @@ -13,7 +13,6 @@ subroutine gyro_field_time_derivative use mpi use gyro_globals - use math_constants use ompdata !--------------------------------------------------- diff --git a/gyro/src/gyro_fieldeigen.f90 b/gyro/src/gyro_fieldeigen.f90 index 705876408..c11e761ab 100644 --- a/gyro/src/gyro_fieldeigen.f90 +++ b/gyro/src/gyro_fieldeigen.f90 @@ -24,7 +24,6 @@ subroutine gyro_fieldeigen use mpi use gyro_globals use gyro_pointers - use math_constants use gyro_collision_private, only : nu_total use gyro_fieldeigen_private diff --git a/gyro/src/gyro_fieldeigen_df.f90 b/gyro/src/gyro_fieldeigen_df.f90 index c51f79e3f..7855c42f6 100644 --- a/gyro/src/gyro_fieldeigen_df.f90 +++ b/gyro/src/gyro_fieldeigen_df.f90 @@ -10,7 +10,6 @@ subroutine gyro_fieldeigen_df use mpi use gyro_globals use gyro_pointers - use math_constants use gyro_fieldeigen_private !--------------------------------------------------------------- diff --git a/gyro/src/gyro_fieldeigen_kernel.f90 b/gyro/src/gyro_fieldeigen_kernel.f90 index aae2ea6a7..817db07b1 100644 --- a/gyro/src/gyro_fieldeigen_kernel.f90 +++ b/gyro/src/gyro_fieldeigen_kernel.f90 @@ -11,7 +11,6 @@ subroutine gyro_fieldeigen_kernel use mpi use gyro_globals use gyro_pointers - use math_constants use gyro_fieldeigen_private !--------------------------------------------------------------- diff --git a/gyro/src/gyro_gbflux.f90 b/gyro/src/gyro_gbflux.f90 index e13619434..4a93d1383 100644 --- a/gyro/src/gyro_gbflux.f90 +++ b/gyro/src/gyro_gbflux.f90 @@ -16,7 +16,6 @@ subroutine gyro_gbflux use mpi use gyro_globals - use math_constants !------------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_get_he_implicit.f90 b/gyro/src/gyro_get_he_implicit.f90 index 53015bf5d..f012ee4fc 100644 --- a/gyro/src/gyro_get_he_implicit.f90 +++ b/gyro/src/gyro_get_he_implicit.f90 @@ -10,7 +10,6 @@ subroutine gyro_get_he_implicit use gyro_globals use gyro_pointers - use math_constants use ompdata !--------------------------- diff --git a/gyro/src/gyro_globals.f90 b/gyro/src/gyro_globals.f90 index 6e46d83f4..35912c29d 100644 --- a/gyro/src/gyro_globals.f90 +++ b/gyro/src/gyro_globals.f90 @@ -8,6 +8,9 @@ module gyro_globals + real, parameter :: pi=3.141592653589793238 + complex, parameter :: i_c=(0.0,1.0) + !---------------------------------------------------- ! Standard precision for IO ! diff --git a/gyro/src/gyro_initial_condition.f90 b/gyro/src/gyro_initial_condition.f90 index a3668d870..3599a1b34 100644 --- a/gyro/src/gyro_initial_condition.f90 +++ b/gyro/src/gyro_initial_condition.f90 @@ -15,7 +15,6 @@ subroutine gyro_initial_condition use gyro_globals use gyro_pointers - use math_constants !--------------------------------- implicit none diff --git a/gyro/src/gyro_kxky_spectrum.f90 b/gyro/src/gyro_kxky_spectrum.f90 index e7a186211..2cfd66f63 100644 --- a/gyro/src/gyro_kxky_spectrum.f90 +++ b/gyro/src/gyro_kxky_spectrum.f90 @@ -25,7 +25,6 @@ subroutine gyro_kxky_spectrum use gyro_globals - use math_constants use ompdata !------------------------------------- diff --git a/gyro/src/gyro_lambda_grid.f90 b/gyro/src/gyro_lambda_grid.f90 index dd39dce71..741ead305 100644 --- a/gyro/src/gyro_lambda_grid.f90 +++ b/gyro/src/gyro_lambda_grid.f90 @@ -8,7 +8,6 @@ subroutine gyro_lambda_grid use gyro_globals - use math_constants !------------------------------------------ implicit none diff --git a/gyro/src/gyro_make_ampere_matrix.f90 b/gyro/src/gyro_make_ampere_matrix.f90 index 18cd39a2e..0d1192872 100644 --- a/gyro/src/gyro_make_ampere_matrix.f90 +++ b/gyro/src/gyro_make_ampere_matrix.f90 @@ -11,7 +11,6 @@ subroutine gyro_make_ampere_matrix use gyro_globals use gyro_collision_private - use math_constants !------------------------ implicit none diff --git a/gyro/src/gyro_make_implicit_advect.f90 b/gyro/src/gyro_make_implicit_advect.f90 index 45ce7f7f2..23c78f961 100644 --- a/gyro/src/gyro_make_implicit_advect.f90 +++ b/gyro/src/gyro_make_implicit_advect.f90 @@ -12,7 +12,6 @@ subroutine gyro_make_implicit_advect(i_print) use mpi use gyro_globals use gyro_pointers - use math_constants !-------------------------------------------------- implicit none diff --git a/gyro/src/gyro_make_jpar_elec.f90 b/gyro/src/gyro_make_jpar_elec.f90 index 6c3a9fc44..faf97e1f8 100644 --- a/gyro/src/gyro_make_jpar_elec.f90 +++ b/gyro/src/gyro_make_jpar_elec.f90 @@ -11,7 +11,6 @@ subroutine gyro_make_jpar_elec(i_print) use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none @@ -88,7 +87,7 @@ subroutine gyro_make_jpar_elec(i_print) if (i_print == 1) then - d_theta = pi_2/n_blend + d_theta = 2*pi/n_blend do i=1,n_x print *,i diff --git a/gyro/src/gyro_make_jperp_elec.f90 b/gyro/src/gyro_make_jperp_elec.f90 index 87e37347a..867bea5f7 100644 --- a/gyro/src/gyro_make_jperp_elec.f90 +++ b/gyro/src/gyro_make_jperp_elec.f90 @@ -11,7 +11,6 @@ subroutine gyro_make_jperp_elec use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_make_poisson_matrix.f90 b/gyro/src/gyro_make_poisson_matrix.f90 index aa730182f..7b20b8d28 100644 --- a/gyro/src/gyro_make_poisson_matrix.f90 +++ b/gyro/src/gyro_make_poisson_matrix.f90 @@ -9,7 +9,6 @@ subroutine gyro_make_poisson_matrix use gyro_globals - use math_constants use gyro_poisson_private !------------------------ diff --git a/gyro/src/gyro_miscellaneous_math.f90 b/gyro/src/gyro_miscellaneous_math.f90 index 541de05c3..74f20f3ca 100644 --- a/gyro/src/gyro_miscellaneous_math.f90 +++ b/gyro/src/gyro_miscellaneous_math.f90 @@ -82,11 +82,12 @@ end subroutine invert_p32 real function p32(x) - use math_constants - implicit none real, intent(in) :: x + real :: pi + + pi = 4.0*atan(1.0) p32 = erf(sqrt(x))-sqrt(x)*exp(-x)/(0.5*sqrt(pi)) @@ -227,8 +228,6 @@ end subroutine pascal subroutine energy_integral(n_energy,energy_max,energy,w_energy) - use math_constants - !------------------------------------------ implicit none ! diff --git a/gyro/src/gyro_moments_plot.f90 b/gyro/src/gyro_moments_plot.f90 index ea6b2f4bf..412d044f8 100644 --- a/gyro/src/gyro_moments_plot.f90 +++ b/gyro/src/gyro_moments_plot.f90 @@ -21,7 +21,6 @@ subroutine gyro_moments_plot use mpi use gyro_globals use gyro_pointers - use math_constants use ompdata !--------------------------------------------------- diff --git a/gyro/src/gyro_nl_direct.f90 b/gyro/src/gyro_nl_direct.f90 index 0bfb704d4..ea402b654 100644 --- a/gyro/src/gyro_nl_direct.f90 +++ b/gyro/src/gyro_nl_direct.f90 @@ -12,7 +12,6 @@ subroutine gyro_nl_direct use gyro_globals use gyro_pointers use gyro_nl_private - use math_constants use ompdata !-------------------------------------------- diff --git a/gyro/src/gyro_nl_fft.f90 b/gyro/src/gyro_nl_fft.f90 index 988c3ce08..93e528310 100644 --- a/gyro/src/gyro_nl_fft.f90 +++ b/gyro/src/gyro_nl_fft.f90 @@ -15,7 +15,6 @@ subroutine gyro_nl_fft use gyro_globals use gyro_pointers use gyro_nl_private - use math_constants use ompdata !-------------------------------------------- diff --git a/gyro/src/gyro_nl_fft.fftw.f90 b/gyro/src/gyro_nl_fft.fftw.f90 index 9f2f8ac4a..144994db5 100644 --- a/gyro/src/gyro_nl_fft.fftw.f90 +++ b/gyro/src/gyro_nl_fft.fftw.f90 @@ -15,7 +15,6 @@ subroutine gyro_nl_fft use gyro_globals use gyro_pointers use gyro_nl_private - use math_constants !-------------------------------------------- implicit none diff --git a/gyro/src/gyro_nonlinear_flux.f90 b/gyro/src/gyro_nonlinear_flux.f90 index a1211abc7..a19d67dd8 100644 --- a/gyro/src/gyro_nonlinear_flux.f90 +++ b/gyro/src/gyro_nonlinear_flux.f90 @@ -19,7 +19,6 @@ subroutine gyro_nonlinear_flux use mpi use gyro_globals use gyro_pointers - use math_constants use ompdata !--------------------------------------------------- diff --git a/gyro/src/gyro_omegas.f90 b/gyro/src/gyro_omegas.f90 index 0daf7df3c..544c91c15 100644 --- a/gyro/src/gyro_omegas.f90 +++ b/gyro/src/gyro_omegas.f90 @@ -10,7 +10,6 @@ subroutine gyro_omegas use gyro_globals use gyro_pointers - use math_constants !------------------------------------- implicit none diff --git a/gyro/src/gyro_phi_kp_squared.f90 b/gyro/src/gyro_phi_kp_squared.f90 index c22e75be4..220e5778a 100644 --- a/gyro/src/gyro_phi_kp_squared.f90 +++ b/gyro/src/gyro_phi_kp_squared.f90 @@ -15,7 +15,6 @@ subroutine gyro_phi_kp_squared use mpi use gyro_globals use gyro_pointers - use math_constants use ompdata !--------------------------------------------------- diff --git a/gyro/src/gyro_profile_init.f90 b/gyro/src/gyro_profile_init.f90 index 069c154fe..1fc96d6a7 100644 --- a/gyro/src/gyro_profile_init.f90 +++ b/gyro/src/gyro_profile_init.f90 @@ -27,7 +27,6 @@ subroutine gyro_profile_init use gyro_globals use gyro_profile_exp - use math_constants !--------------------------------------------------- implicit none @@ -621,12 +620,12 @@ subroutine gyro_profile_init ! Calculation of phase ! do i=1,n_x - phase(in_1,i) = exp(-pi_2*i_c*n_1(in_1)*q(i)) + phase(in_1,i) = exp(-2*pi*i_c*n_1(in_1)*q(i)) angp(i) = n_1(in_1)*q(i)-int(n_1(in_1)*q(i)) if (angp(i) > 0.5) angp(i) = angp(i)-1.0 enddo !------------------------------------------------------------- - + if (debug_flag == 1 .and. i_proc == 0) then print *,"[gyro_profile_init done]" endif diff --git a/gyro/src/gyro_radial_operators.f90 b/gyro/src/gyro_radial_operators.f90 index d0c911488..cd5528559 100644 --- a/gyro/src/gyro_radial_operators.f90 +++ b/gyro/src/gyro_radial_operators.f90 @@ -11,7 +11,6 @@ subroutine gyro_radial_operators use gyro_globals - use math_constants !-------------------------------------- implicit none @@ -41,7 +40,7 @@ subroutine gyro_radial_operators ! c's are the matrix elements for m -> p - cr(i,ip) = exp(i_c*m*p*(pi_2/n_x)) + cr(i,ip) = exp(i_c*m*p*(2*pi/n_x)) enddo enddo @@ -177,24 +176,24 @@ subroutine gyro_radial_operators do m=-m_dx,m_dx-1 do p=-m_dx,m_dx-1 - z0 = exp(i_c*p*m*(pi_2/n_x)) + z0 = exp(i_c*p*m*(2*pi/n_x)) w_d1(m) = w_d1(m)+p*z0 enddo enddo - w_d1(:) = -(1.0/n_x)*(pi_2*i_c/x_length)*w_d1(:) + w_d1(:) = -(1.0/n_x)*(2*pi*i_c/x_length)*w_d1(:) w_d2(:) = (0.0,0.0) do m=-m_dx,m_dx-1 do p=-m_dx,m_dx-1 - z0 = exp(i_c*p*m*(pi_2/n_x)) + z0 = exp(i_c*p*m*(2*pi/n_x)) w_d2(m) = w_d2(m)+p*p*z0 enddo enddo ! Note the sign change - w_d2(:) = (1.0/n_x)*(pi_2*i_c/x_length)**2*w_d2(:) + w_d2(:) = (1.0/n_x)*(2*pi*i_c/x_length)**2*w_d2(:) if (m_dx == 2) then diff --git a/gyro/src/gyro_radial_simulation_box.f90 b/gyro/src/gyro_radial_simulation_box.f90 index e550945c7..35d3a2f10 100644 --- a/gyro/src/gyro_radial_simulation_box.f90 +++ b/gyro/src/gyro_radial_simulation_box.f90 @@ -13,7 +13,6 @@ subroutine gyro_radial_simulation_box use gyro_globals - use math_constants !-------------------------- implicit none diff --git a/gyro/src/gyro_rhs_nonlinear.f90 b/gyro/src/gyro_rhs_nonlinear.f90 index 06ad5eec3..b66eb9165 100644 --- a/gyro/src/gyro_rhs_nonlinear.f90 +++ b/gyro/src/gyro_rhs_nonlinear.f90 @@ -2,7 +2,6 @@ subroutine gyro_rhs_nonlinear use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------------------- implicit none diff --git a/gyro/src/gyro_rhs_total.f90 b/gyro/src/gyro_rhs_total.f90 index 4f7dfbf93..59962f4d7 100644 --- a/gyro/src/gyro_rhs_total.f90 +++ b/gyro/src/gyro_rhs_total.f90 @@ -13,7 +13,6 @@ subroutine gyro_rhs_total use gyro_globals use gyro_pointers - use math_constants use ompdata !----------------------------------------------------------------------------- diff --git a/gyro/src/gyro_set_blend_arrays.f90 b/gyro/src/gyro_set_blend_arrays.f90 index fc9378a4f..1f566c16c 100644 --- a/gyro/src/gyro_set_blend_arrays.f90 +++ b/gyro/src/gyro_set_blend_arrays.f90 @@ -10,7 +10,6 @@ subroutine gyro_set_blend_arrays use mpi use gyro_globals use gyro_pointers - use math_constants !--------------------------------------------------- implicit none diff --git a/gyro/src/gyro_set_phase_space.f90 b/gyro/src/gyro_set_phase_space.f90 index bf982be76..4648d2453 100644 --- a/gyro/src/gyro_set_phase_space.f90 +++ b/gyro/src/gyro_set_phase_space.f90 @@ -12,7 +12,6 @@ subroutine gyro_set_phase_space(datafile,io) use gyro_globals - use math_constants implicit none @@ -49,7 +48,7 @@ subroutine gyro_set_phase_space(datafile,io) write(io,'(a)') '--- ------------ ------------ ------------ -----------' do k=1,n_lambda write(io,'(i2,4(2x,f12.10))') & - k,1.0/(pi_2*omega(i,k)),s_lambda(k),lambda(i,k),w_lambda(i,k) + k,1.0/(2*pi*omega(i,k)),s_lambda(k),lambda(i,k),w_lambda(i,k) if (k == n_pass) write(io,'(a,t33,f12.10)') 'lambda-TP:',lambda_tp(i) if (k == n_lambda) write(io,'(a,t33,f12.10)') 'lambda-MAX:',lambda_max(i) enddo diff --git a/gyro/src/gyro_theta_grid.f90 b/gyro/src/gyro_theta_grid.f90 index deebb58d3..8bdd72a8d 100644 --- a/gyro/src/gyro_theta_grid.f90 +++ b/gyro/src/gyro_theta_grid.f90 @@ -1,7 +1,6 @@ subroutine gyro_theta_grid use gyro_globals - use math_constants implicit none @@ -53,7 +52,7 @@ subroutine gyro_theta_grid d_tau(2) = 2.0/n_tau(2) !------------------------------------------------------- - d_theta = pi_2/n_blend + d_theta = 2*pi/n_blend ! Real theta grid (arbitrary size) n_theta_int = 2*n_blend diff --git a/gyro/src/gyro_write_freq.f90 b/gyro/src/gyro_write_freq.f90 index 816b084b8..c11a7def5 100644 --- a/gyro/src/gyro_write_freq.f90 +++ b/gyro/src/gyro_write_freq.f90 @@ -18,7 +18,6 @@ subroutine gyro_write_freq(datafile,io) use mpi use gyro_globals - use math_constants !-------------------------------------------------- implicit none diff --git a/gyro/src/gyro_write_initdata.f90 b/gyro/src/gyro_write_initdata.f90 index 5af8c7190..79030538d 100644 --- a/gyro/src/gyro_write_initdata.f90 +++ b/gyro/src/gyro_write_initdata.f90 @@ -13,7 +13,6 @@ subroutine gyro_write_initdata(datafile1,datafile2,datafile3,io) use gyro_globals use gyro_profile_exp - use math_constants use geo !--------------------------------------------------- @@ -187,7 +186,7 @@ subroutine gyro_write_initdata(datafile1,datafile2,datafile3,io) GEO_fourier_in(:,:) = a_fourier_geo_s(:,:,i) do j=1,n_wedge - ttmp(j) = -pi+(j-1)*pi_2/n_wedge + ttmp(j) = -pi+(j-1)*2*pi/n_wedge enddo if (n_wedge == 1) ttmp = 0.0 diff --git a/gyro/src/gyro_write_input.f90 b/gyro/src/gyro_write_input.f90 index fc04b10c7..0d52e2ebc 100644 --- a/gyro/src/gyro_write_input.f90 +++ b/gyro/src/gyro_write_input.f90 @@ -12,7 +12,6 @@ subroutine gyro_write_input use gyro_globals use gyro_profile_exp use gyro_pointers - use math_constants use geo use ompdata diff --git a/gyro/src/i0.f90 b/gyro/src/i0.f90 new file mode 100644 index 000000000..336101cdc --- /dev/null +++ b/gyro/src/i0.f90 @@ -0,0 +1,244 @@ +SUBROUTINE CALCI0(ARG,RESULT,JINT) + + !-------------------------------------------------------------------- + ! + ! This packet computes modified Bessel functions of the first kind + ! and order zero, I0(X) and EXP(-ABS(X))*I0(X), for real + ! arguments X. It contains two function type subprograms, BESI0 + ! and BESEI0, and one subroutine type subprogram, CALCI0. + ! The calling statements for the primary entries are + ! + ! Y=BESI0(X) + ! and + ! Y=BESEI0(X) + ! + ! where the entry points correspond to the functions I0(X) and + ! EXP(-ABS(X))*I0(X), respectively. The routine CALCI0 is + ! intended for internal packet use only, all computations within + ! the packet being concentrated in this routine. The function + ! subprograms invoke CALCI0 with the statement + ! CALL CALCI0(ARG,RESULT,JINT) + ! where the parameter usage is as follows + ! + ! Function Parameters for CALCI0 + ! Call ARG RESULT JINT + ! + ! BESI0(ARG) ABS(ARG) .LE. XMAX I0(ARG) 1 + ! BESEI0(ARG) any real ARG EXP(-ABS(ARG))*I0(ARG) 2 + ! + ! The main computation evaluates slightly modified forms of + ! minimax approximations generated by Blair and Edwards, Chalk + ! River (Atomic Energy of Canada Limited) Report AECL-4928, + ! October, 1974. This transportable program is patterned after + ! the machine-dependent FUNPACK packet NATSI0, but cannot match + ! that version for efficiency or accuracy. This version uses + ! rational functions that theoretically approximate I-SUB-0(X) + ! to at least 18 significant decimal digits. The accuracy + ! achieved depends on the arithmetic system, the compiler, the + ! intrinsic functions, and proper selection of the machine- + ! dependent constants. + ! + !******************************************************************* + !******************************************************************* + ! + ! Explanation of machine-dependent constants + ! + ! beta = Radix for the floating-point system + ! maxexp = Smallest power of beta that overflows + ! XSMALL = Positive argument such that 1.0 - X = 1.0 to + ! machine precision for all ABS(X) .LE. XSMALL. + ! XINF = Largest positive machine number; approximately + ! beta**maxexp + ! XMAX = Largest argument acceptable to BESI0; Solution to + ! equation: + ! W(X) * (1+1/(8*X)+9/(128*X**2) = beta**maxexp + ! where W(X) = EXP(X)/SQRT(2*PI*X) + ! + ! + ! Approximate values for some important machines are: + ! + ! beta maxexp XSMALL + ! + ! CRAY-1 (S.P.) 2 8191 3.55E-15 + ! Cyber 180/855 + ! under NOS (S.P.) 2 1070 3.55E-15 + ! IEEE (IBM/XT, + ! SUN, etc.) (S.P.) 2 128 2.98E-8 + ! IEEE (IBM/XT, + ! SUN, etc.) (D.P.) 2 1024 5.55D-17 + ! IBM 3033 (D.P.) 16 63 6.95D-18 + ! VAX (S.P.) 2 127 2.98E-8 + ! VAX D-Format (D.P.) 2 127 6.95D-18 + ! VAX G-Format (D.P.) 2 1023 5.55D-17 + ! + ! + ! XINF XMAX + ! + ! CRAY-1 (S.P.) 5.45E+2465 5682.810 + ! Cyber 180/855 + ! under NOS (S.P.) 1.26E+322 745.893 + ! IEEE (IBM/XT, + ! SUN, etc.) (S.P.) 3.40E+38 91.900 + ! IEEE (IBM/XT, + ! SUN, etc.) (D.P.) 1.79D+308 713.986 + ! IBM 3033 (D.P.) 7.23D+75 178.182 + ! VAX (S.P.) 1.70D+38 91.203 + ! VAX D-Format (D.P.) 1.70D+38 91.203 + ! VAX G-Format (D.P.) 8.98D+307 713.293 + ! + !******************************************************************* + !******************************************************************* + ! + ! Error returns + ! + ! The program returns XINF for BESI0 for ABS(ARG) .GT. XMAX. + ! + ! + ! Intrinsic functions required are: + ! + ! ABS, SQRT, EXP + ! + ! + ! Authors: W. J. Cody and L. Stoltz + ! Mathematics and Computer Science Division + ! Argonne National Laboratory + ! Argonne, IL 60439 + ! + ! Latest modification: June 7, 1988 + ! + !-------------------------------------------------------------------- + INTEGER :: I,JINT + REAL :: A,ARG,B,EXP40,FORTY,ONE,ONE5,P,PP,Q,QQ,RESULT, & + REC15,SUMP,SUMQ,TWO25,X,XINF,XMAX,XSMALL,XX + + DIMENSION P(15),PP(8),Q(5),QQ(7) + !-------------------------------------------------------------------- + ! Mathematical constants + !-------------------------------------------------------------------- + DATA ONE/1.0/,ONE5/15.0/,EXP40/2.353852668370199854e17/, & + FORTY/40.0/,REC15/6.6666666666666666666e-2/, & + TWO25/225.0/ + !-------------------------------------------------------------------- + ! Machine-dependent constants + !-------------------------------------------------------------------- + DATA XSMALL/5.55e-17/,XINF/1.79e308/,XMAX/713.986/ + !-------------------------------------------------------------------- + ! Coefficients for XSMALL .LE. ABS(ARG) .LT. 15.0 + !-------------------------------------------------------------------- + DATA P/-5.2487866627945699800D-18,-1.5982226675653184646D-14, & + -2.6843448573468483278D-11,-3.0517226450451067446D-08,& + -2.5172644670688975051D-05,-1.5453977791786851041D-02,& + -7.0935347449210549190D+00,-2.4125195876041896775D+03,& + -5.9545626019847898221D+05,-1.0313066708737980747D+08,& + -1.1912746104985237192D+10,-8.4925101247114157499D+11,& + -3.2940087627407749166D+13,-5.5050369673018427753D+14,& + -2.2335582639474375249D+15/ + DATA Q/-3.7277560179962773046D+03, 6.5158506418655165707D+06, & + -6.5626560740833869295D+09, 3.7604188704092954661D+12, & + -9.7087946179594019126D+14/ + !-------------------------------------------------------------------- + ! Coefficients for 15.0 .LE. ABS(ARG) + !-------------------------------------------------------------------- + DATA PP/-3.9843750000000000000e-01, 2.9205384596336793945e+00,& + -2.4708469169133954315e+00, 4.7914889422856814203e-01,& + -3.7384991926068969150e-03,-2.6801520353328635310e-03,& + 9.9168777670983678974e-05,-2.1877128189032726730e-06/ + DATA QQ/-3.1446690275135491500e+01, 8.5539563258012929600e+01,& + -6.0228002066743340583e+01, 1.3982595353892851542e+01,& + -1.1151759188741312645e+00, 3.2547697594819615062e-02,& + -5.5194330231005480228e-04/ + !-------------------------------------------------------------------- + X = ABS(ARG) + IF (X < XSMALL) THEN + RESULT = ONE + ELSE IF (X < ONE5) THEN + !-------------------------------------------------------------------- + ! XSMALL .LE. ABS(ARG) .LT. 15.0 + !-------------------------------------------------------------------- + XX = X * X + SUMP = P(1) + DO I = 2, 15 + SUMP = SUMP * XX + P(I) + enddo + XX = XX - TWO25 + SUMQ = ((((XX+Q(1))*XX+Q(2))*XX+Q(3))*XX+Q(4))*XX+Q(5) + RESULT = SUMP / SUMQ + IF (JINT == 2) RESULT = RESULT * EXP(-X) + ELSE IF (X >= ONE5) THEN + IF ((JINT .EQ. 1) .AND. (X .GT. XMAX)) THEN + RESULT = XINF + ELSE + !-------------------------------------------------------------------- + ! 15.0 .LE. ABS(ARG) + !-------------------------------------------------------------------- + XX = ONE / X - REC15 + SUMP = ((((((PP(1)*XX+PP(2))*XX+PP(3))*XX+PP(4))*XX+ & + PP(5))*XX+PP(6))*XX+PP(7))*XX+PP(8) + SUMQ = ((((((XX+QQ(1))*XX+QQ(2))*XX+QQ(3))*XX+ & + QQ(4))*XX+QQ(5))*XX+QQ(6))*XX+QQ(7) + RESULT = SUMP / SUMQ + IF (JINT == 2) THEN + RESULT = (RESULT - PP(1)) / SQRT(X) + ELSE + !-------------------------------------------------------------------- + ! Calculation reformulated to avoid premature overflow + !-------------------------------------------------------------------- + IF (X <= (XMAX-ONE5)) THEN + A = EXP(X) + B = ONE + ELSE + A = EXP(X-FORTY) + B = EXP40 + END IF + RESULT = ((RESULT*A-PP(1)*A)/SQRT(X))*B + END IF + END IF + END IF + !-------------------------------------------------------------------- + ! Return for ABS(ARG) .LT. XSMALL + !-------------------------------------------------------------------- + RETURN + +END SUBROUTINE CALCI0 + +REAL FUNCTION BESI0(X) + + !-------------------------------------------------------------------- + ! + ! This long precision subprogram computes approximate values for + ! modified Bessel functions of the first kind of order zero for + ! arguments ABS(ARG) .LE. XMAX (see comments heading CALCI0). + ! + !-------------------------------------------------------------------- + + INTEGER :: JINT + REAL :: X, RESULT + + JINT=1 + CALL CALCI0(X,RESULT,JINT) + BESI0=RESULT + RETURN + +END FUNCTION BESI0 + +REAL FUNCTION BESEI0(X) + + !-------------------------------------------------------------------- + ! + ! This function program computes approximate values for the + ! modified Bessel function of the first kind of order zero + ! multiplied by EXP(-ABS(X)), where EXP is the + ! exponential function, ABS is the absolute value, and X + ! is any argument. + ! + !-------------------------------------------------------------------- + + INTEGER :: JINT + REAL :: X, RESULT + + JINT=2 + CALL CALCI0(X,RESULT,JINT) + BESEI0=RESULT + RETURN + +END FUNCTION BESEI0 diff --git a/platform/build/make.inc.FRONTIER b/platform/build/make.inc.FRONTIER index 4f2aeac2e..587717693 100644 --- a/platform/build/make.inc.FRONTIER +++ b/platform/build/make.inc.FRONTIER @@ -23,11 +23,11 @@ endif FOMP =-homp FMATH =-s real64 FOPT =-Ofast -FDEBUG =-O0 -g +FDEBUG =-O1 -g F2PY = f2py --fcompiler=pg # System math libraries -LMATH=-L${ROCM_PATH}/lib -L${HIPFORT_DIR}/lib -lhipfort-amdgcn -lhipfft -lamdhip64 +LMATH=-L${HIPFORT_DIR}/lib -L${ROCM_PATH}/lib -lhipfort-amdgcn -lhipfft -lamdhip64 # NetCDF NETCDF=-L${NETCDF_DIR}/lib -lnetcdff -lnetcdf diff --git a/platform/build/make.inc.LUMI b/platform/build/make.inc.LUMI new file mode 100644 index 000000000..3e9f167f6 --- /dev/null +++ b/platform/build/make.inc.LUMI @@ -0,0 +1,39 @@ +#---------------------------------------------------------- +# Cray (lumi.csc.fi) [GPU nodes] +# +# - 7*2*4 CPU cores (AMD Epyc) + 4x2 GPUs (MI250X) +#---------------------------------------------------------- + +IDENTITY="LUMI" +CORES_PER_NODE=56 +NUMAS_PER_NODE=8 + +# Fortran 90/95 compiler +FC = ftn -J ${GACODE_ROOT}/modules +#FC = /opt/rocm/llvm/bin/flang -J ${GACODE_ROOT}/modules +# Fortran 77 compiler +F77 = ${FC} + +# Compiler options/flags +ifneq ($(GACODE_OMPGPU),1) +FACC =-hacc -DHIPGPU -DGACODE_GPU_AMD -I${HIPFORT_DIR}/include/hipfort/amdgcn -hacc_model=auto_async_none:no_fast_addr:no_deep_copy +else +FACC = -DOMPGPU -DHIPGPU -DGACODE_GPU_AMD -I${HIPFORT_DIR}/include/hipfort/amdgcn +endif +FOMP =-homp +FMATH =-s real64 +FOPT =-Ofast +FDEBUG =-O0 -g +F2PY = f2py --fcompiler=pg + + +# System math libraries +LMATH=-L${ROCM_PATH}/lib -L${HIPFORT_DIR}/lib -lhipfort-amdgcn -lhipfft -lamdhip64 + +# NetCDF +#NETCDF=-L${NETCDF_DIR}/lib -lnetcdff -lnetcdf +#NETCDF_INC = ${NETCDF_DIR}/include + +# Archive +ARCH = ar cr + diff --git a/platform/build/make.inc.MARCONI b/platform/build/make.inc.MARCONI index 3164f5a8c..ba6b742dd 100644 --- a/platform/build/make.inc.MARCONI +++ b/platform/build/make.inc.MARCONI @@ -15,19 +15,19 @@ NUMAS_PER_NODE=2 # Compilers and flags -FC = mpiifort -mod ${GACODE_ROOT}/modules -I ${GACODE_ROOT}/modules +FC = mpiifort -module ${GACODE_ROOT}/modules F77 = ${FC} FOMP = -qopenmp FMATH = -r8 -FOPT = -xhost -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ip -qoverride-limits -mkl=sequential#-fast -no-ipo +FOPT = -xhost -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ipo -qoverride-limits #-ip -no-ipo FDEBUG = -shared-intel -implicitnone -check all -check noarg_temp_created -traceback #FPETSC = F2PY = f2py # System math libraries -LMATH = +LMATH = -L${GSL_LIB} -mkl=sequential # -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster # -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3 -mkl=cluster diff --git a/platform/build/make.inc.MARCONI_KNL b/platform/build/make.inc.MARCONI_KNL index ebd8d8025..121ee6ff3 100644 --- a/platform/build/make.inc.MARCONI_KNL +++ b/platform/build/make.inc.MARCONI_KNL @@ -15,19 +15,20 @@ NUMAS_PER_NODE=1 # Compilers and flags -FC = mpiifort -mod ${GACODE_ROOT}/modules -I ${GACODE_ROOT}/modules +FC = mpiifort -module ${GACODE_ROOT}/modules F77 = ${FC} FOMP = -qopenmp FMATH = -r8 -FOPT = -xMIC-AVX512 -mtune=knl -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ip -qoverride-limits -mkl=sequential #-fast -no-ipo +FOPT = -xMIC-AVX512 -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ipo -qoverride-limits # -ip -no-ipo FDEBUG = -shared-intel -implicitnone -check all -check noarg_temp_created -traceback #FPETSC = F2PY = f2py # System math libraries -LMATH = -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster +LMATH = -L${GSL_LIB} -mkl=sequential +# -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster # -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3 -mkl=cluster # NetCDF diff --git a/platform/build/make.inc.MARCONI_SKL b/platform/build/make.inc.MARCONI_SKL index bd994fb3f..ef6d48b70 100644 --- a/platform/build/make.inc.MARCONI_SKL +++ b/platform/build/make.inc.MARCONI_SKL @@ -15,19 +15,20 @@ NUMAS_PER_NODE=1 # Compilers and flags -FC = mpiifort -mod ${GACODE_ROOT}/modules -I ${GACODE_ROOT}/modules +FC = mpiifort -module ${GACODE_ROOT}/modules F77 = ${FC} FOMP = -qopenmp FMATH = -r8 -FOPT = -xCORE-AVX512 -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ip -qoverride-limits -mkl=sequential #-fast -no-ipo +FOPT = -xSKYLAKE-AVX512 -implicitnone -no-prec-div -O3 -fp-model fast=2 -pad -ipo -qoverride-limits #-ip -no-ipo FDEBUG = -shared-intel -implicitnone -check all -check noarg_temp_created -traceback #FPETSC = F2PY = f2py # System math libraries -LMATH = -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster +LMATH = -L${GSL_LIB} -mkl=sequential +# -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster # -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3 -mkl=cluster # NetCDF diff --git a/platform/build/make.inc.MARCONI_pgi b/platform/build/make.inc.MARCONI_pgi new file mode 100644 index 000000000..cad8742fc --- /dev/null +++ b/platform/build/make.inc.MARCONI_pgi @@ -0,0 +1,46 @@ +#--------------------------------------------------- +# MARCONI [BROADWELL component] +# +# SYSTEM INFO: +# - 2 18-core Intel "Broadwell" E5-2697v4 (2.3GHz) per node +# +#--------------------------------------------------- +$(info Compiling for MARCONI Broadwell) + +# FIXED Hardware parameters + +IDENTITY="MARCONI Broadwell" +CORES_PER_NODE=36 +NUMAS_PER_NODE=2 + +# Compilers and flags + +FC = mpif90 -m64 -module ${GACODE_ROOT}/modules -Mpreprocess -DUSE_INLINE -fpic -I${MKL_INC}/fftw +F77 = ${FC} + +FOMP = -mp -Mstack_arrays +FMATH = -r8 +FOPT =-fast -fastsse -Mvect +FDEBUG =-g -Kieee -Ktrap=fp,divz -Mbounds -Mchkptr -Mchkstk -traceback -Minform=inform +#FPETSC = +F2PY = f2py + +# System math libraries + +LMATH = -L${GSL_LIB} -L${MKL_LIB} -lmkl_intel_lp64 -lmkl_sequential -lmkl_core +# -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -mkl=cluster +# -L${FFTW_DIR}/lib -lfftw3_threads -lfftw3 -mkl=cluster + +# NetCDF +#NETCDF = -K${NETCDF_LIB} -l${NETCDF_LIB}netcdf -lnetcdff +#NETCDF = ${NETCDFF_LIB}/libnetcdff.a ${NETCDF_LIB}/libnetcdf.a -L{HDF5_LIB} -lhdf5_hl -lhdf5 -lcurl +#NETCDF not tested since not needed for [c]gyro +NETCDF = -L${NETCDF_LIB} -lnetcdf +NETCDF_INC = ${NETCDF_INCLUDE} + +GATOFLAGS = -r8 -i8 + +# Archive +ARCH = ar cr + + diff --git a/platform/build/make.inc.OSX_CATALINA b/platform/build/make.inc.OSX_CATALINA index 7b98a8295..4202f665c 100644 --- a/platform/build/make.inc.OSX_CATALINA +++ b/platform/build/make.inc.OSX_CATALINA @@ -17,7 +17,7 @@ # Compilers and flags -FC = mpif90-mpich-gcc11 -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate +FC = mpif90-mpich-gcc11 -DNO_DIMATCOPY -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate F77 = mpif77 -std=legacy CC = ${FC} diff --git a/platform/build/make.inc.OSX_SONOMA b/platform/build/make.inc.OSX_SONOMA index 6f7f74380..8d898c1b7 100644 --- a/platform/build/make.inc.OSX_SONOMA +++ b/platform/build/make.inc.OSX_SONOMA @@ -17,7 +17,7 @@ # Compilers and flags -FC = mpif90-mpich-gcc13 -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate +FC = mpif90-mpich-gcc13 -DNO_DIMATCOPY -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate F77 = mpif77 -std=legacy CC = ${FC} diff --git a/platform/build/make.inc.OSX_YOSEMITE b/platform/build/make.inc.OSX_YOSEMITE index 2308b544e..c01a32319 100644 --- a/platform/build/make.inc.OSX_YOSEMITE +++ b/platform/build/make.inc.OSX_YOSEMITE @@ -17,7 +17,7 @@ # Compilers and flags -FC = mpif90-mpich-gcc5 -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate +FC = mpif90-mpich-gcc5 -DNO_DIMATCOPY -I$(GACODE_ROOT)/modules -J$(GACODE_ROOT)/modules -fPIC -framework Accelerate F77 = mpif77 CC = ${FC} diff --git a/platform/build/make.inc.PPPL_FLUX b/platform/build/make.inc.PPPL_FLUX index bbdfc9b16..8e89feda7 100644 --- a/platform/build/make.inc.PPPL_FLUX +++ b/platform/build/make.inc.PPPL_FLUX @@ -23,10 +23,10 @@ FDEBUG = -check all -traceback F2PY = f2py # System math libraries -LMATH = -mkl +LMATH = -qmkl # NetCDF -NETCDF = -L${NETCDF_FORTRAN_HOME}/lib -lnetcdff -L${NETCDF_C_HOME}/lib -lnetcdf +NETCDF = -L${NETCDF_FORTRAN_HOME}/lib -lnetcdff -L${NETCDF_C_HOME}/lib64 -lnetcdf NETCDF_INC =-I${NETCDF_FORTRAN_HOME}/include -I${NETCDF_C_HOME}/include # Mapping diff --git a/platform/build/make.inc.PPPL_PORTAL b/platform/build/make.inc.PPPL_PORTAL index ff964c799..cd4dd3336 100755 --- a/platform/build/make.inc.PPPL_PORTAL +++ b/platform/build/make.inc.PPPL_PORTAL @@ -21,11 +21,11 @@ F2PY = f2py FOMP = -fopenmp # System math libraries -LMATH = -L/usr/lib64 -lopenblas $(FFTW_HOME)/lib/libfftw3.a $(FFTW_HOME)/lib/libfftw3_omp.a +LMATH = -L$(LAPACKHOME)/lib64 -llapack -lblas $(FFTW_HOME)/lib/libfftw3.a $(FFTW_HOME)/lib/libfftw3_omp.a FFTW_INC = $(FFTW_HOME)/include # NetCDF -NETCDF = -L/usr/pppl/gcc/11.2-pkgs/netcdf-fortran-4.5.4/lib -lnetcdff -L/usr/lib64/hdf -L/usr/pppl/gcc/11.2-pkgs/netcdf-c-4.8.1/lib -lnetcdf -lnetcdf -ldl -lm +NETCDF = -L$(NETCDF_FORTRAN_HOME)/lib -lnetcdff -L$(HDF5_HOME)/lib -L$(NETCDF_C_HOME)/lib -lnetcdf -ldl -lm NETCDF_INC =${NETCDF_FORTRAN_HOME}/include -I${NETCDF_C_HOME}/include # Mapping diff --git a/platform/build/make.inc.STAMPEDE3_GPU_IFX b/platform/build/make.inc.STAMPEDE3_GPU_IFX index a812ad2e1..f0fc17f1c 100644 --- a/platform/build/make.inc.STAMPEDE3_GPU_IFX +++ b/platform/build/make.inc.STAMPEDE3_GPU_IFX @@ -7,7 +7,7 @@ CORES_PER_NODE=96 NUMAS_PER_NODE=8 # Compilers and flags -FC = mpiifx -gen-interfaces -module ${GACODE_ROOT}/modules -I${GACODE_ROOT}/module -DDISABLE_GPUDIRECT_MPI -DNO_ASYNC_MPI -allow nofpp-comments +FC = mpiifx -gen-interfaces -module ${GACODE_ROOT}/modules -I${GACODE_ROOT}/module -allow nofpp-comments F77 = ${FC} FOMP = -fiopenmp -fopenmp-targets=spir64 -DOMPGPU -DMKLGPU diff --git a/platform/build/make.inc.TUMBLEWEED b/platform/build/make.inc.TUMBLEWEED new file mode 100644 index 000000000..c502f5b36 --- /dev/null +++ b/platform/build/make.inc.TUMBLEWEED @@ -0,0 +1,42 @@ +#--------------------------------------------------- +# Linux Tumbleweed modified from "Mint" +#--------------------------------------------------- + +IDENTITY="Linux TUMBLEWEED gfortran+OpenBLAS+OPENMPI" +CORES_PER_NODE=8 +NUMAS_PER_NODE=1 +#SOLVER_OPT=slumt +#need packages fftw_openmp_devel openblas_devel +#need for old gyro: netcdf-fortran-gnu-openmpi4-hpc-devel +#m lo gnu openmpi netcdf-fortran pfftw3 + +#ROOT=${HOME}/GIT + +# Compilers + +FC = mpifort -DDIMATCOPY -std=gnu -fallow-argument-mismatch -fall-intrinsics -fimplicit-none -J $(GACODE_ROOT)/modules #-fPIC +#FC = mpifort -std=f2008 -fall-intrinsics -fimplicit-none -J $(GACODE_ROOT)/modules #-fPIC +F77 = mpifort -fimplicit-none -fallow-argument-mismatch +FOMP =-fopenmp +FMATH =-fdefault-real-8 -fdefault-double-8 -I$(FFTW_INC) +FOPT =-O3 -fexternal-blas -march=native -ffree-line-length-0 +# -floop-nest-optimize -floop-parallelize-all -flto +FDEBUG =-Wall -W -fcheck=all -g -fbacktrace -ffpe-trap=invalid,zero,overflow -finit-real=snan # -std=f2003 -fall-intrinsics +F2PY = f2py + +# System math libraries +#LMATH = /usr/lib64/libopenblas_serial.so.0 -lfftw3 -lfftw3_omp +LMATH = -llapack -lblas -lfftw3 -lfftw3_omp + +ifdef FANN_ROOT + # neural net libraries + NN_LIB=-L$(GACODE_ROOT)/../neural/ -I$(GACODE_ROOT)/../neural/ -lbrainfuse -lfann +endif + +# OPTIONAL NetCDF: +NETCDF=-lnetcdff -lnetcdf +NETCDF_INC=$(NETCDF_FORTRAN_INC) + +# Archive + +ARCH = ar cr diff --git a/platform/env/env.FRONTIER b/platform/env/env.FRONTIER index fcde5ee60..d7e05b357 100644 --- a/platform/env/env.FRONTIER +++ b/platform/env/env.FRONTIER @@ -15,16 +15,16 @@ if [ -n "$SSH_TTY" ] ; then fi fi -module load PrgEnv-cray -module load craype-accel-amd-gfx90a -module load rocm -#module load cray-mpich +module load cpe/23.09 +module load craype-accel-amd-gfx90a rocm module load cray-python +module load cray-mpich +module use /lustre/orion/stf243/world-shared/hagertnl/test_environment/modulefiles/ +module load hipfort/5.5.1 + -#export MPICH_SMP_SINGLE_COPY_MODE=NONE -module load cray-mpich/8.1.25 export LD_LIBRARY_PATH="${CRAY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}" export MPICH_GPU_SUPPORT_ENABLED=1 -export HIPFORT_DIR=/lustre/orion/proj-shared/fus140/hipfort/cce_15.0.0-rocm_5.3.0 +export HIPFORT_DIR=${OLCF_HIPFORT_ROOT} export ROCFFT_RTC_CACHE_PATH=/dev/null diff --git a/platform/env/env.LUMI b/platform/env/env.LUMI new file mode 100644 index 000000000..3635ee8e5 --- /dev/null +++ b/platform/env/env.LUMI @@ -0,0 +1,31 @@ +if [ -n "$SSH_TTY" ] ; then + echo "Setting up $GACODE_PLATFORM environment for gacode" +fi + +if [ "x${GACODE_OMPGPU}" == "x" ]; then + # default to OpenACC if not defined + export GACODE_OMPGPU=0 +fi + +if [ -n "$SSH_TTY" ] ; then + if [ "x${GACODE_OMPGPU}" == "x1" ]; then + echo "Using OMPGPU offload setup" + else + echo "Using OpenACC offload setup" + fi +fi + +module --force purge +module load LUMI/23.09 partition/G +module load PrgEnv-cray +module load rocm +module load cray-mpich +module load cray-python + +#export MPICH_SMP_SINGLE_COPY_MODE=NONE +export LD_LIBRARY_PATH="${CRAY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}" + +export MPICH_GPU_SUPPORT_ENABLED=1 +export HIPFORT_DIR=/scratch/project_462000507/cce_16.0.1-rocm_5.6.0 +#export HIPFORT_DIR=/opt/rocm/hipfort +export ROCFFT_RTC_CACHE_PATH=/dev/null diff --git a/platform/env/env.PPPL_FLUX b/platform/env/env.PPPL_FLUX index bd2715d97..d8f744823 100644 --- a/platform/env/env.PPPL_FLUX +++ b/platform/env/env.PPPL_FLUX @@ -1,11 +1,12 @@ #!/bin/bash #module purge -module load intel@2023.2.0 -module load openmpi-4.1.5/intel-2023.2.0/netcdf-c/4.9.2-3wxlq -module load openmpi-4.1.5/intel-2023.2.0/netcdf-cxx4/4.3.1-frhsv -module load openmpi-4.1.5/intel-2023.2.0/netcdf-fortran/4.6.0-hz3b2 -module load openmpi-4.1.5/intel-2023.2.0/fftw/3.3.10-zp3rj -module load openmpi-4.1.5/intel-2023.2.0/hdf5/1.14.1-2-x7cbk +module load intel@2023.2 +module load openmpi/4.1.6-intel-2023.2.0 +module load openmpi-4.1.6/intel-2023.2.0/netcdf-c/main-nzscm +module load openmpi-4.1.6/intel-2023.2.0/netcdf-cxx4/4.3.1-gqm7t +module load openmpi-4.1.6/intel-2023.2.0/netcdf-fortran/4.6.1-cepgo +module load openmpi-4.1.6/intel-2023.2.0/fftw/3.3.10-7lhns +module load openmpi-4.1.6/intel-2023.2.0/hdf5/1.14.3-4nzzy module load git -export NETCDF_FORTRAN_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen3/intel-2023.2.0/netcdf-fortran-4.6.0-hz3b2mq6ld2u2u6ktdodbx72k37opcdf -export FFTW_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen3/intel-2023.2.0/fftw-3.3.10-zp3rj3oyvya5ntql27775l5gsfyou6ga +export NETCDF_FORTRAN_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen/intel-2023.2.0/netcdf-fortran-4.6.1-cepgoinrjitqdehlejpd7lrpn3l3pqwd +export FFTW_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen/intel-2023.2.0/fftw-3.3.10-7lhnskibvn5gqyjbwalabizccpr2ty3q diff --git a/platform/env/env.PPPL_PORTAL b/platform/env/env.PPPL_PORTAL index 8f9ac678f..0bd83ca83 100644 --- a/platform/env/env.PPPL_PORTAL +++ b/platform/env/env.PPPL_PORTAL @@ -1,7 +1,10 @@ +#%Module1.0 #!/bin/bash -module load gcc/11.2.0 -module load openmpi/4.1.2 -module load fftw/3.3.10 -module load netcdf-c/4.8.1 -module load netcdf-fortran/4.5.4 +module load gcc/9.3.0 +module load openmpi/4.0.3 +module load fftw/3.3.8 +module load szip/2.1.1 +module load netcdf-c/4.7.3 +module load netcdf-fortran/4.5.2 +module load lapack/3.9.0 diff --git a/platform/env/env.STAMPEDE3_GPU_IFX b/platform/env/env.STAMPEDE3_GPU_IFX index eef5707a1..620007479 100644 --- a/platform/env/env.STAMPEDE3_GPU_IFX +++ b/platform/env/env.STAMPEDE3_GPU_IFX @@ -6,3 +6,6 @@ fi module load python module load netcdf + +#needed with Intel MPI for GPU-aware MPI +export I_MPI_OFFLOAD=1 diff --git a/platform/exec/exec.LUMI b/platform/exec/exec.LUMI new file mode 100755 index 000000000..ade79dd80 --- /dev/null +++ b/platform/exec/exec.LUMI @@ -0,0 +1,45 @@ +#! /usr/bin/env bash +# GACODE Parallel execution script + +simdir=${1} +nmpi=${2} +exec=${3} +nomp=${4} +numa=${5} +mpinuma=${6} + +# nmpi = MPI tasks +# nomp = OpenMP threads per MPI task +# numa = NUMAs active per node +# mpinuma = MPI tasks per active NUMA + +. $GACODE_ROOT/shared/bin/gacode_mpi_tool + +cd $simdir + +let proc_per_node=8 + +export MPICH_MAX_THREAD_SAFETY=funneled +export OMP_NUM_THREADS=$nomp +export OMP_STACKSIZE=400M +export MPICH_GPU_SUPPORT_ENABLED=1 + +#export SLURM_CPU_BIND="cores" +ulimit -c unlimited + +# +# As recommended by +# https://docs.lumi-supercomputer.eu/runjobs/scheduled-jobs/lumig-job/ +# + +CPU_BIND="mask_cpu:fe000000000000,fe00000000000000" +CPU_BIND="${CPU_BIND},fe0000,fe000000" +CPU_BIND="${CPU_BIND},fe,fe00" +CPU_BIND="${CPU_BIND},fe00000000,fe0000000000" + +#echo "> srun -n$nmpi -c$nomp --gpus-per-task=1 --partition=standard-g --account=project_462000507 --gpu-bind=closest $exec" +#srun -n$nmpi -c$nomp --gpus-per-task=1 --account=project_462000507 --partition=standard-g --gres=gpu:4 --gpu-bind=closest $exec +#$exec + +echo "> srun -n $nmpi --cpu-bind=${CPU_BIND} $GACODE_ROOT/platform/exec/wrap.${GACODE_PLATFORM} $exec" +srun -n $nmpi --cpu-bind=${CPU_BIND} $GACODE_ROOT/platform/exec/wrap.${GACODE_PLATFORM} $exec diff --git a/platform/exec/exec.MARCONI_pgi b/platform/exec/exec.MARCONI_pgi new file mode 100755 index 000000000..471fbcaf3 --- /dev/null +++ b/platform/exec/exec.MARCONI_pgi @@ -0,0 +1,35 @@ +#! /usr/bin/env bash +# +# SCRIPT: +# gyro.MARCONI +# +# FUNCTION: +# Parallel execution script +#--------------------------------------------------- + +simdir=${1} +nmpi=${2} +exec=${3} +nomp=${4} +numa=${5} +mpinuma=${6} +nidle=${7} + +# nmpi = MPI tasks +# nomp = OpenMP threads per MPI task +# numa = NUMAs active per node +# mpinuma = MPI tasks per active NUMA + +. $GACODE_ROOT/shared/bin/gacode_mpi_tool + +# Do not know how to properly run it on broadwell and knl. + + +cd $simdir + +export OMP_NUM_THREADS=$nomp +export KMP_AFFINITY=compact +#mpirun -ppn $ppn -np $nmpi $exec +#Using for now 32 instead of 36 processors per node. +#mostly the processor numbers are actually powers of 2. +mpirun -np $nmpi $exec diff --git a/platform/exec/exec.STAMPEDE3_GPU_IFX b/platform/exec/exec.STAMPEDE3_GPU_IFX index 4250fe407..dd2ca28d1 100755 --- a/platform/exec/exec.STAMPEDE3_GPU_IFX +++ b/platform/exec/exec.STAMPEDE3_GPU_IFX @@ -23,5 +23,8 @@ cd $simdir export OMP_NUM_THREADS=$nomp export OMP_STACKSIZE=32M -echo ibrun $GACODE_ROOT/platform/exec/wrap.${GACODE_PLATFORM} $exec -ibrun $GACODE_ROOT/platform/exec/wrap.${GACODE_PLATFORM} $exec + +export I_MPI_OFFLOAD=1 + +echo ibrun $exec +ibrun $exec diff --git a/platform/exec/exec.TUMBLEWEED b/platform/exec/exec.TUMBLEWEED new file mode 100755 index 000000000..10b85c147 --- /dev/null +++ b/platform/exec/exec.TUMBLEWEED @@ -0,0 +1,12 @@ +#!/bin/sh +# GACODE Parallel execution script (MINT) + +simdir=${1} +nmpi=${2} +exec=${3} +nomp=${4} +numa=${5} +mpinuma=${6} + +cd $simdir +mpiexec -oversubscribe -quiet -x OMP_NUM_THREADS=$nomp -n $nmpi $exec diff --git a/platform/exec/wrap.LUMI b/platform/exec/wrap.LUMI new file mode 100755 index 000000000..eb13ee5e5 --- /dev/null +++ b/platform/exec/wrap.LUMI @@ -0,0 +1,24 @@ +#! /usr/bin/env bash +# GACODE Parallel execution script (LUMI) + +# +# As recommended by +# https://docs.lumi-supercomputer.eu/runjobs/scheduled-jobs/lumig-job/ +# + +export MPICH_GPU_SUPPORT_ENABLED=1 + +#env 1>&2 + +#echo $SLURM_LOCALID +let ACC_DEVICE_NUM=$SLURM_LOCALID +export ACC_DEVICE_NUM +export OMP_DEFAULT_DEVICE=${ACC_DEVICE_NUM} +export HIP_VISIBLE_DEVICES=${ACC_DEVICE_NUM} + +echo "`uname -n` $SLURM_PROCID $SLURM_LOCALID $ACC_DEVICE_NUM `taskset -pc $$`" +#ecno "uname -n` $SLURM_LOCALID LL $LD_LIBRARY_PATH" + +# no MPS +exec "$@" + diff --git a/platform/exec/wrap.STAMPEDE3_GPU_IFX b/platform/exec/wrap.STAMPEDE3_GPU_IFX deleted file mode 100755 index 4a941f898..000000000 --- a/platform/exec/wrap.STAMPEDE3_GPU_IFX +++ /dev/null @@ -1,13 +0,0 @@ -#! /usr/bin/env bash -# GACODE Parallel execution script (FRONTIER_GPU) - -#env 1>&2 - -#echo $MPI_LOCALRANKID -let r8=MPI_LOCALRANKID/8 -let l8="$MPI_LOCALRANKID-($r8*8)" -export OMP_DEFAULT_DEVICE=${l8} - -echo "`uname -n` $SLURM_PROCID $SLURM_LOCALID $OMP_DEFAULT_DEVICE `taskset -pc $$`" - -exec "$@" diff --git a/platform/modulefiles/gacode/PPPL_FLUX b/platform/modulefiles/gacode/PPPL_FLUX new file mode 100644 index 000000000..e1e6b166b --- /dev/null +++ b/platform/modulefiles/gacode/PPPL_FLUX @@ -0,0 +1,16 @@ +#%Module +# +# Module file for setting the GACODE machine-dependent environmental variables +# + +module purge +module load intel@2023.2 +module load openmpi/4.1.6-intel-2023.2.0 +module load openmpi-4.1.6/intel-2023.2.0/netcdf-c/main-nzscm +module load openmpi-4.1.6/intel-2023.2.0/netcdf-cxx4/4.3.1-gqm7t +module load openmpi-4.1.6/intel-2023.2.0/netcdf-fortran/4.6.1-cepgo +module load openmpi-4.1.6/intel-2023.2.0/fftw/3.3.10-7lhns +module load openmpi-4.1.6/intel-2023.2.0/hdf5/1.14.3-4nzzy +module load git +export NETCDF_FORTRAN_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen/intel-2023.2.0/netcdf-fortran-4.6.1-cepgoinrjitqdehlejpd7lrpn3l3pqwd +export FFTW_HOME=/opt/pppl/spack-pkgs/linux-rocky9-zen/intel-2023.2.0/fftw-3.3.10-7lhnskibvn5gqyjbwalabizccpr2ty3q diff --git a/platform/qsub/qsub.OMEGA_INTEL b/platform/qsub/qsub.OMEGA_INTEL new file mode 100644 index 000000000..fead5e1c5 --- /dev/null +++ b/platform/qsub/qsub.OMEGA_INTEL @@ -0,0 +1,26 @@ +bfile=$SIMDIR/batch.src +echo "#!/bin/bash -l" > $bfile +echo "#SBATCH -J $LOCDIR" >> $bfile +echo "#SBATCH -o $SIMDIR/batch.out" >> $bfile +echo "#SBATCH -e $SIMDIR/batch.err" >> $bfile +echo "#SBATCH -t $WALLTIME" >> $bfile +echo "#SBATCH -n $cores_used" >> $bfile + +# Corrected section +if [ -n "$MEMPERNODE" ] +then + echo "#SBATCH --mem $MEMPERNODE" >> $bfile +elif [ -n "$MEMPERCPU" ] +then + echo "#SBATCH --mem-per-cpu $MEMPERCPU" >> $bfile +else + echo "#SBATCH --mem-per-cpu 16GB" >> $bfile +fi + +if [ "$QUEUE" = "null_queue" ] +then + echo "#SBATCH -p medium" >> $bfile +else + echo "#SBATCH -p $QUEUE" >> $bfile +fi +echo "$CODE -e $LOCDIR -n $nmpi -nomp $nomp -numa $numa -mpinuma $mpinuma -p $SIMROOT" >> $bfile diff --git a/profiles_gen/locpargen/locpargen.f90 b/profiles_gen/locpargen/locpargen.f90 index bda3c7a80..42b261f0f 100644 --- a/profiles_gen/locpargen/locpargen.f90 +++ b/profiles_gen/locpargen/locpargen.f90 @@ -91,6 +91,8 @@ program locpargen print 10,'INFO: (locpargen) beta_* =',beta_star_loc print 10,'INFO: (locpargen) ky*rhos (n=1) =',abs(q_loc/rmin_loc*rhos_loc/a) + betae_unit = betae_loc + ! Compute collision frequency ! ! 4 pi ne e^4 ne ln(Lambda) @@ -104,8 +106,6 @@ program locpargen loglam = 24.0-log(sqrt(dens_loc(ise)*1e13)/(temp_loc(ise)*1e3)) nu_ee = cc*loglam*dens_loc(ise)/(sqrt(mass_loc(ise)/2.0)*temp_loc(ise)**1.5) - betae_unit = 4.027e-3*dens_loc(ise)*temp_loc(ise)/b_unit_loc**2 - lambda_star = 7.43 * sqrt((1e3*temp_loc(ise))/(1e13*dens_loc(ise)))/rhos_loc tag(:) = (/'1','2','3','4','5','6','7','8','9'/) diff --git a/profiles_gen/locpargen/locpargen_cgyro.f90 b/profiles_gen/locpargen/locpargen_cgyro.f90 index c0f00a28f..fa862fa56 100644 --- a/profiles_gen/locpargen/locpargen_cgyro.f90 +++ b/profiles_gen/locpargen/locpargen_cgyro.f90 @@ -113,6 +113,7 @@ subroutine locpargen_cgyro write(1,10) 'DLNTDR_'//tag(is)//'=',dlntdr_loc(is) write(1,10) 'SDLNNDR_'//tag(is)//'=',sdlnndr_loc(is) write(1,10) 'SDLNTDR_'//tag(is)//'=',sdlntdr_loc(is) + write(1,10) 'SBETA_'//tag(is)//'=',sbeta_loc(is) enddo close(1) diff --git a/profiles_gen/locpargen/locpargen_tglf.f90 b/profiles_gen/locpargen/locpargen_tglf.f90 index f45ab455b..ca012ba6c 100644 --- a/profiles_gen/locpargen/locpargen_tglf.f90 +++ b/profiles_gen/locpargen/locpargen_tglf.f90 @@ -22,6 +22,31 @@ subroutine locpargen_tglf write(1,10) 'S_DELTA_LOC=',s_delta_loc write(1,10) 'ZETA_LOC=',zeta_loc write(1,10) 'S_ZETA_LOC=',s_zeta_loc + write(1,*) + write(1,'(a)') '# Geometry (Advanced)' + write(1,10) 'SHAPE_SIN3=',shape_sin3_loc + write(1,10) 'SHAPE_S_SIN3=',shape_s_sin3_loc + write(1,10) 'SHAPE_SIN4=',shape_sin4_loc + write(1,10) 'SHAPE_S_SIN4=',shape_s_sin4_loc + write(1,10) 'SHAPE_SIN5=',shape_sin5_loc + write(1,10) 'SHAPE_S_SIN5=',shape_s_sin5_loc + write(1,10) 'SHAPE_SIN6=',shape_sin6_loc + write(1,10) 'SHAPE_S_SIN6=',shape_s_sin6_loc + write(1,10) 'SHAPE_COS0=',shape_cos0_loc + write(1,10) 'SHAPE_S_COS0=',shape_s_cos0_loc + write(1,10) 'SHAPE_COS1=',shape_cos1_loc + write(1,10) 'SHAPE_S_COS1=',shape_s_cos1_loc + write(1,10) 'SHAPE_COS2=',shape_cos2_loc + write(1,10) 'SHAPE_S_COS2=',shape_s_cos2_loc + write(1,10) 'SHAPE_COS3=',shape_cos3_loc + write(1,10) 'SHAPE_S_COS3=',shape_s_cos3_loc + write(1,10) 'SHAPE_COS4=',shape_cos4_loc + write(1,10) 'SHAPE_S_COS4=',shape_s_cos4_loc + write(1,10) 'SHAPE_COS5=',shape_cos5_loc + write(1,10) 'SHAPE_S_COS5=',shape_s_cos5_loc + write(1,10) 'SHAPE_COS6=',shape_cos6_loc + write(1,10) 'SHAPE_S_COS6=',shape_s_cos6_loc + write(1,*) write(1,10) 'SIGN_BT=',btccw write(1,10) 'SIGN_IT=',ipccw write(1,*) diff --git a/profiles_gen/locpargen/locpargen_tglf_stack.f90 b/profiles_gen/locpargen/locpargen_tglf_stack.f90 index 0366b26f6..1318871b6 100644 --- a/profiles_gen/locpargen/locpargen_tglf_stack.f90 +++ b/profiles_gen/locpargen/locpargen_tglf_stack.f90 @@ -17,7 +17,18 @@ subroutine locpargen_tglf_stack 'ZMAJ_LOC=',zmag_loc, 'DZMAJDX_LOC=',dzmag_loc, 'Q_LOC=',abs(q_loc), & 'Q_PRIME_LOC=',(q_loc/r0)**2*s_loc, 'KAPPA_LOC=',kappa_loc, 'S_KAPPA_LOC=',s_kappa_loc, & 'DELTA_LOC=',delta_loc, 'S_DELTA_LOC=',s_delta_loc, 'ZETA_LOC=',zeta_loc, & - 'S_ZETA_LOC=',s_zeta_loc, 'SIGN_BT=',btccw, 'SIGN_IT=',ipccw, & + 'S_ZETA_LOC=',s_zeta_loc, 'SHAPE_SIN3=',shape_sin3_loc, 'SHAPE_S_SIN3=',shape_s_sin3_loc, & + 'SHAPE_SIN4=' ,shape_sin4_loc, 'SHAPE_S_SIN4=' ,shape_s_sin4_loc, & + 'SHAPE_SIN5=' ,shape_sin5_loc, 'SHAPE_S_SIN5=' ,shape_s_sin5_loc, & + 'SHAPE_SIN6=' ,shape_sin6_loc, 'SHAPE_S_SIN6=' ,shape_s_sin6_loc, & + 'SHAPE_COS0=' ,shape_cos0_loc, 'SHAPE_S_COS0=' ,shape_s_cos0_loc, & + 'SHAPE_COS1=' ,shape_cos1_loc, 'SHAPE_S_COS1=' ,shape_s_cos1_loc, & + 'SHAPE_COS2=' ,shape_cos2_loc, 'SHAPE_S_COS2=' ,shape_s_cos2_loc, & + 'SHAPE_COS3=' ,shape_cos3_loc, 'SHAPE_S_COS3=' ,shape_s_cos3_loc, & + 'SHAPE_COS4=' ,shape_cos4_loc, 'SHAPE_S_COS4=' ,shape_s_cos4_loc, & + 'SHAPE_COS5=' ,shape_cos5_loc, 'SHAPE_S_COS5=' ,shape_s_cos5_loc, & + 'SHAPE_COS6=' ,shape_cos6_loc, 'SHAPE_S_COS6=' ,shape_s_cos6_loc, & + 'SIGN_BT=',btccw, 'SIGN_IT=',ipccw, & 'ZEFF=',z_eff_loc, 'XNUE=',nu_ee*a/cs_loc, & 'DEBYE=',7.43*sqrt(1e3*temp_loc(ise)/(1e13*dens_loc(ise)))/abs(rhos_loc), & 'BETAE=',betae_unit, 'P_PRIME_LOC=',(abs(q_loc)/r0)*(-beta_star_loc/(8*pi)), & @@ -57,6 +68,6 @@ subroutine locpargen_tglf_stack 'VPAR_1=',mach_loc/cs_loc close(1) -10 format(sp,21(a,1pe12.5,2x),a,s,i0,2x,4(a,s,i0,2x,sp,7(a,1pe12.5,2x))) +10 format(sp,43(a,1pe12.5,2x),a,s,i0,2x,4(a,s,i0,2x,sp,7(a,1pe12.5,2x))) end subroutine locpargen_tglf_stack diff --git a/qlgyro/bin/qlgyro_parse.py b/qlgyro/bin/qlgyro_parse.py index 75cbef2ab..ca936c62d 100755 --- a/qlgyro/bin/qlgyro_parse.py +++ b/qlgyro/bin/qlgyro_parse.py @@ -20,6 +20,7 @@ x.add('SAT_RULE', '1') x.add('N_PX0', '1') x.add('PX0GRID_MODEL', '1') +x.add('RESTART_MODE', '0') # Perform the parsing x.read_input('input.qlgyro') diff --git a/qlgyro/src/qlgyro.f90 b/qlgyro/src/qlgyro.f90 index 307419674..e7c622f41 100644 --- a/qlgyro/src/qlgyro.f90 +++ b/qlgyro/src/qlgyro.f90 @@ -97,7 +97,7 @@ program qlgyro call qlgyro_comm_sync ! Apply saturation rule - if (sat_rule .eq. 1) then + if (sat_rule .gt. 0) then call qlgyro_sat1 else if (sat_rule .eq. -1) then call qlgyro_sat_mg diff --git a/qlgyro/src/qlgyro_cgyro_cleanup.F90 b/qlgyro/src/qlgyro_cgyro_cleanup.F90 index 71dac91ab..4dc6aa125 100644 --- a/qlgyro/src/qlgyro_cgyro_cleanup.F90 +++ b/qlgyro/src/qlgyro_cgyro_cleanup.F90 @@ -103,6 +103,10 @@ subroutine qlgyro_cgyro_cleanup if (adjoint .eq. 0) then open(unit=io, iostat=i_err, file=trim(runpath)//runfile_restart_tag, status='old') if (i_err == 0) close(io, status='delete') + if (restart_mode .eq. 1) then + open(unit=io, iostat=i_err, file=trim(runpath)//runfile_restart, status='old') + if (i_err == 0) close(io, status='delete') + end if end if end if diff --git a/qlgyro/src/qlgyro_globals.f90 b/qlgyro/src/qlgyro_globals.f90 index 7a389a9a4..d1a68217c 100644 --- a/qlgyro/src/qlgyro_globals.f90 +++ b/qlgyro/src/qlgyro_globals.f90 @@ -267,7 +267,7 @@ module qlgyro_globals real, dimension(:, :, :), allocatable :: qlgyro_k_perp, qlgyro_jacobian - integer :: sat_rule + integer :: sat_rule, restart_mode ! ! ! Iteration variables (global) diff --git a/qlgyro/src/qlgyro_px0_spectrum.f90 b/qlgyro/src/qlgyro_px0_spectrum.f90 index a68cad4da..1b32d3d53 100644 --- a/qlgyro/src/qlgyro_px0_spectrum.f90 +++ b/qlgyro/src/qlgyro_px0_spectrum.f90 @@ -18,10 +18,11 @@ SUBROUTINE qlgyro_px0_spectrum px0_spectrum(n_px0-1) = 0.25 px0_spectrum(n_px0) = 0.5 else if (px0grid_model .eq. 3) then - do i=1, n_px0 - 2 - px0_spectrum(i) = (i-1) * 0.016 + do i=1, n_px0 - 3 + px0_spectrum(i) = (i-1) * 0.1 / (2.0 * pi) end do - px0_spectrum(n_px0-1) = 0.2 + px0_spectrum(n_px0-2) = 0.4 / (2.0 * pi) + px0_spectrum(n_px0-1) = 1.2 / (2.0 * pi) px0_spectrum(n_px0) = 0.5 else do i=1, n_px0 diff --git a/qlgyro/src/qlgyro_read_input.f90 b/qlgyro/src/qlgyro_read_input.f90 index 16eebb05a..17cf5ec90 100644 --- a/qlgyro/src/qlgyro_read_input.f90 +++ b/qlgyro/src/qlgyro_read_input.f90 @@ -47,6 +47,7 @@ subroutine qlgyro_read_input call ql_readbc_int(sat_rule) call ql_readbc_int(n_px0) call ql_readbc_int(px0grid_model) + call ql_readbc_int(restart_mode) ! DONE reading data. !-------------------------------------------------------- @@ -58,11 +59,11 @@ subroutine qlgyro_read_input stop end if - if (sat_rule .eq. 1 .and. n_px0 .ne. 1) then + if (sat_rule .ne. -1 .and. n_px0 .ne. 1) then open(unit=1,file=trim(runfile),position='append') - write(1,*) '---------------------------------------------------------' - write(1,*) 'Saturation rule 1 can only be run with a single PX0 value' - write(1,*) '---------------------------------------------------------' + write(1,*) '-----------------------------------------------------------' + write(1,*) 'Only saturation rule -1 can be run with multiple PX0 values' + write(1,*) '-----------------------------------------------------------' stop end if diff --git a/qlgyro/src/qlgyro_run.f90 b/qlgyro/src/qlgyro_run.f90 index ccf0b619c..92bbaa24a 100644 --- a/qlgyro/src/qlgyro_run.f90 +++ b/qlgyro/src/qlgyro_run.f90 @@ -65,7 +65,7 @@ subroutine qlgyro_run(lpath_in, qlgyro_comm_in, i_tran_in) call qlgyro_comm_sync ! Apply saturation rule - if (sat_rule .eq. 1) then + if (sat_rule .gt. 0) then call qlgyro_sat1 else if (sat_rule .eq. -1) then call qlgyro_sat_mg diff --git a/qlgyro/src/qlgyro_run_cgyro_balloon.f90 b/qlgyro/src/qlgyro_run_cgyro_balloon.f90 index 8fef13fb6..0bd34b3ec 100644 --- a/qlgyro/src/qlgyro_run_cgyro_balloon.f90 +++ b/qlgyro/src/qlgyro_run_cgyro_balloon.f90 @@ -11,7 +11,8 @@ subroutine qlgyro_run_cgyro_balloon integer :: ios character(len=5) :: kystr, px0str - real :: ky, timestep, maxtime, kx_max_default, px0 + character(len=6) :: fmt_str + real :: ky, timestep, maxtime, kx_max_default, px0, ky_min integer, dimension(:), allocatable :: ky_run, px0_run integer, dimension(:), allocatable :: ky_px0_run @@ -46,8 +47,14 @@ subroutine qlgyro_run_cgyro_balloon call map_global2interface call allocate_cgyro_interface if (i_proc_global .eq. 0) call tglf_dump_local - - call qlgyro_ky_spectrum(0.005) + + if (transport_method .eq. 0) then + ky_min = cgyro_ky_in + else if (transport_method .eq. 1) then + ky_min = cgyro_q_in / cgyro_rmin_in * cgyro_rho_star_norm_in + end if + + call qlgyro_ky_spectrum(ky_min) call qlgyro_px0_spectrum maxtime = cgyro_max_time_in @@ -57,6 +64,12 @@ subroutine qlgyro_run_cgyro_balloon tglf_nmodes_in = n_px0 n_ky = tglf_nky_in + + if (tglf_ky_spectrum_out(1) .lt. 0.01) then + fmt_str = "(F5.3)" + else + fmt_str = "(F5.2)" + end if ! Set up ky px0 grid n_kypx0 = n_ky * n_px0 @@ -157,7 +170,7 @@ subroutine qlgyro_run_cgyro_balloon px0 = px0_spectrum(i_px0_local) ! Creates directory for each ky and changes into it for that run - write(kystr, '(F5.2)') ky + write(kystr, fmt_str) ky write(px0str, '(F5.2)') px0 runpath = trim(trim(path)//'/KY_'//trim(adjustl(kystr)))//"_PX0_"//trim(adjustl(px0str))//"/" diff --git a/shared/Makefile b/shared/Makefile index 528c8ec70..17a3f3b29 100644 --- a/shared/Makefile +++ b/shared/Makefile @@ -2,19 +2,12 @@ include ../platform/build/make.inc.${GACODE_PLATFORM} all: cd math ; make "OPT=${OPT}" + cd landau ; make "OPT=${OPT}" cd nclass ; make "OPT=${OPT}" cd UMFPACK ; make "OPT=${OPT}" -ifdef FANN_ROOT - cd ${GACODE_ROOT}/../neural && make -endif clean: cd math ; make clean + cd landau ; make clean cd nclass ; make clean cd UMFPACK ; make clean -ifdef FANN_ROOT - cd ${GACODE_ROOT}/../neural && make clean -endif - -distclean: - cd math ; make clean diff --git a/shared/bin/gacode_reg_do_restart b/shared/bin/gacode_reg_do_restart new file mode 100755 index 000000000..a78df9943 --- /dev/null +++ b/shared/bin/gacode_reg_do_restart @@ -0,0 +1,101 @@ +#!/bin/bash +# +# SCRIPT: +# gacode_reg_do_restart +# +# PURPOSE: +# Run three times through full suite of regression tests defined for +# Check that both base, mid and final results are correct +# +# EXAMPLE: +# gacode_reg_do_restart 2 1 0 cgyro 1e-6 reg01 +#---------------------------------------------------- + +n=$# + +if [ $n -lt 5 ] +then + echo "Usage: gacode_reg_do " + exit 1 +fi + +# Define list of test directories: + +n_proc=${1} +n_omp=${2} +reset=${3} +code=${4} +tol=${5} +scase=${6} + +echo "REGRESSION TESTING: $code" + +testdir=$PWD/${code}_regression_test + +# Is data in GACODE + +if [ -d "$GACODE_ROOT/$code/tools/input" ] +then + compdir=$GACODE_ROOT/$code/tools/input +fi + +# Is data in GACODE_ADD +if [ -d "$GACODE_ADD_ROOT/$code/tools/input" ] +then + compdir=$GACODE_ADD_ROOT/$code/tools/input +fi + +precfile=out.$code.prec +infile=input.$code + +if [ "$scase" == "" ] +then + list=`cat $compdir/reg_list` +else + list=$scase +fi + +rm -rf $testdir ; mkdir $testdir +cd $testdir + +for sim in $list +do + $code -g $sim -p $testdir > out.$sim + rm -f $sim/$precfile + # patch input file to have frequent checkpointing + mv $sim/$infile $sim/$infile.org + grep -v RESTART_STEP $sim/$infile.org > $sim/$infile + echo "RESTART_STEP=1" >> $sim/$infile + # now run it 3 times + for ((i=0; $i<3; i=$i+1)) + do + if [ $i -ne 0 ] + then + cp $sim/$precfile $sim/$precfile.$oi + fi + if [ $n_omp -eq 1 ] && [ $n_proc -eq 1 ] ; then + $code -e $sim -p $testdir > out.$sim + else + $code -e $sim -n $n_proc -nomp $n_omp -p $testdir > out.$sim + fi + cp $sim/$precfile $sim/$precfile.$i + if [ $i -eq 0 ] + then + # reuse the non-checkpointed result from original regression test + myprecfile=$precfile + else + # use the additional iterations else + myprecfile=$precfile.$i + fi + gacode_reg $sim $compdir $myprecfile $tol + oi=$i + done + if [ $reset -eq 1 ] + then + # Overwrite regression data with current data + echo "$sim/$precfile -> $GACODE_ROOT/$code/tools/input/$sim" + cp $sim/$precfile.0 $compdir/$sim/$precfile + cp $sim/$precfile.1 $compdir/$sim/$precfile.1 + cp $sim/$precfile.2 $compdir/$sim/$precfile.2 + fi +done diff --git a/shared/landau/Makefile b/shared/landau/Makefile new file mode 100644 index 000000000..69c82f389 --- /dev/null +++ b/shared/landau/Makefile @@ -0,0 +1,25 @@ +include ${GACODE_ROOT}/platform/build/make.inc.${GACODE_PLATFORM} + +ifeq ($(OPT),debug) + FFLAGS=${FDEBUG} +else + FFLAGS=${FOPT} +endif + +OBJECTS = landau.o \ + gyrotransformation.o + +.PHONY: clean all + +.SUFFIXES: +.SUFFIXES: .o .f90 .f .F90 + +all: $(OBJECTS) + +.f90.o .F90.o: + $(FC) $(FMATH) $(FFLAGS) -c $< + +clean: + rm -rf landau.o gyrotransformation.o + rm -f ${GACODE_ROOT}/modules/landau.mod + rm -f ${GACODE_ROOT}/modules/gyrotransformation.mod diff --git a/shared/landau/gyrotransformation.f90 b/shared/landau/gyrotransformation.f90 new file mode 100644 index 000000000..a4d51de15 --- /dev/null +++ b/shared/landau/gyrotransformation.f90 @@ -0,0 +1,1579 @@ +!gfortran -march=native -g -fcheck=all -fno-stack-arrays -fimplicit-none -fdefault-real-8 gyrotransformation.f90 -c +!gfortran -march=native -O3 -fno-stack-arrays -fimplicit-none -fdefault-real-8 gyrotransformation.f90 -c +!gfortran -march=native -O3 -fno-stack-arrays -fimplicit-none -fdefault-real-8 gyrotransformation.f90 landau.f90 half_hermite.f90 gauss_legendre.f90 -c +!intel: +!ifort -stand f15 -warn all -march=native -O3 -heap-arrays 10 -implicitnone -real-size 64 gyrotransformation.f90 -c +!ifort -stand f15 -warn all -xCORE-AVX512 -O3 -heap-arrays 10 -implicitnone -real-size 64 gyrotransformation.f90 -c + +module gyrotransformation + real, parameter,private :: epspullback=1e-13,epsgyrocolmat=1e-15 + real, parameter,private :: pi1=atan(1.)*4 + integer :: verbose=0 +contains + integer function est_mpullback(kbounda,kboundb,eps) + implicit none + !real :: kbounda=16. + real,intent(in) :: kbounda,kboundb, & !usually krho*xmax with maximum + eps !krho planned. + optional :: kboundb,eps + real val,val1,kba,kbb,epsp + integer mmax + ! The maximum mpullback (with two species) relies on m being a conserved + ! quantum number in the collisions. Therefore we can use the product of + ! the smallnesses of the Bessel functions as indicator of the global + ! smallness. (For large m, the Bessel functions are asymptotically equal + ! to Jn[x]~(2/m)^(1/3) Ai[(2/m)^(1/3)(n-x)] increase slowly up to their + ! 1st maximum, which is around n+1.01879*(n/2)^(1/3) and on the order of + ! (2/m)^(1/3)*0.535656656015.) So mpullback depends on kbounda and + ! kboundb + + if (verbose>0) print '(A)','Warning, need abs(kbound) est_mpullback!' + if (present(kboundb)) then + kbb=kboundb + else + kbb=kbounda + end if + !kbb=kbounda + if (present(eps)) then + epsp=eps + else + epsp=epspullback + endif + if (verbose>0) print '(A)','WARNING: using max of kb for both species in est_mpullback please improve me.' + kba=kbounda + kba=max(kbounda,kbb) + kbb=kba + val=0 + mmax=max(200,ceiling(2*max(kbounda,kbb))) + do est_mpullback=mmax,1,-1 + val1=val + val=val+abs(bessel_jn(est_mpullback,kba)*bessel_jn(est_mpullback,kbb)) + if (val>epsp) exit + end do +! est_mpullback=est_mpullback*2 +!!$ if (verbose>0) print "(3(A,G0),4(A,ES11.4),2ES11.4)",'mpullback based on Jn is ',est_mpullback,' initial guess was ',ceiling(2 *max(kbounda& +!!$ ,kbb)),'k1,k2',kbounda,kbb,' Bessel_j(' ,est_mpullback,',',kbounda,')=',bessel_jn(est_mpullback ,kbounda),' squaresum=',val,' sqrt=' & +!!$ ,sqrt(val) ,val1,sqrt(val1) + if (verbose>0) print '(2(A,I0),A,2G23.16,A,I0,4(A,G23.16),5(G24.16))','mpullback based on Jn is ',& + est_mpullback,' initial guess was ',ceiling(2*max(kbounda,kbb)),' k1,k2',kbounda,kbb,& + ' Bessel_j(' ,est_mpullback,',',kbounda,')=',& + bessel_jn(est_mpullback ,kbounda),' squaresum=',val,' sqrt=',sqrt(val) ,val1,sqrt(val1) + if (est_mpullback==max(200,ceiling(2*max(kbounda,kbb)))) then + print '(A)','mpullback wrong!' + stop + end if + end function est_mpullback + + integer function est_extradegree(kbound,eps,mmode) + ! kbound is necessary only for the species for which the extradegree is to + ! be calculated. The extradegree may be different for two species. + ! OBSERVATION: est_extradegree near identical est_k_sampling + implicit none + !real :: kbound=16. + real,intent(in) :: kbound, & !usually krho*xmax with maximum krho planned. + eps + integer,intent(in),optional :: mmode ! azimuthal mode number m used for + ! estimation, normally should be 0, the worst + ! case. + optional :: eps + real epsp + real val,x + integer i,j,k,mm + real, allocatable :: sample(:) + + if (verbose>0) print '(A)','Warning, need abs(kbound) est_extradegree!' + mm=0 + if (present(mmode)) mm=mmode + if (present(eps)) then + epsp=eps + else + epsp=epspullback + endif + k=ceiling(kbound)+20 + allocate(sample(2*k)) + do i=1,2*k + x=(2*i-1)*(.25*pi1/k) + !Now if we want to deal with polynomials up to degree k, + !we need at least k vertices. With 2k vertices we can deal with + !polynomials up to degree 2k. + !x should from pi/4k up to pi-pi/4k + + if (mm==0) then + sample(i)=bessel_j0((cos(x)+1)*(.5*kbound))-1. + else + sample(i)=bessel_jn(mm,(cos(x)+1)*(.5*kbound)) + endif + ! subtracting bessel(0) here cures numerical precision issues for krho~0 + !! sample(i)=gsl_sf_bessel_jl(mm,(sin(x)+1)*.5*kbound)-gsl_sf_bessel_jl(mm,0.) + end do + do j=k,1,-1 + val=0 + do i=1,2*k + x=(2*i-1)*(.25*pi1/k) + val=val+sample(i)*cos(j*x) + end do + val=val/k + if (verbose>4) print '(A,I5,G24.16)','deg',j,val + if (abs(val)>epsp) exit + end do +!!$ if (j==0) then +!!$ print 2,'Did not find proper degree to sample Bessel fct!' +!!$ stop +!!$ end if + if (verbose>0) print '(A,I0,A,G23.16)',& + 'Extra degree needed for sampling of Bessel fct=',j,' at k=',kbound + est_extradegree=j + end function est_extradegree + + integer function est_k_sampling(kb1,eps) + ! Estimate number of Chebyshev points needed to represent exp(i k) + ! in the range k=0...kbound with at most eps error. + ! This is necessary because we do not want to calculate the gyro- + ! transformation for *every* individual kperp occuring in the code, + ! which would cause much double work due to many near-identities. + + implicit none + !real :: kb1=16. + real,intent(in) :: kb1, & !usually max(kperp)*xmax*2 for worst species + eps + optional :: eps + real epsp + real x,kbound + complex val + integer i,j,k + + kbound=abs(kb1) + if (present(eps)) then + epsp=eps + else + epsp=epspullback + endif + k=ceiling(kbound)+20 +!!$ chebysample: block +!!$ complex*16 sample(2*k),val +!!$ do i=1,2*k +!!$ x=(i-.5)*(.5_16*pi1/k) +!!$ ! with n=2k +!!$ ! sampling exp(i kbound*y) at y=.5*(1+cos(pi/n*(2*i-1))) +!!$ sample(i)=exp(sin(.5*x)**2*((0,1)*kbound))-1 +!!$ end do + do j=k,1,-1 +!!$ val=0 +!!$ do i=1,2*k +!!$ x=(i-.5)*(.5*pi1/k) +!!$ val=val+sample(i)*cos(j*x) +!!$ end do +!!$ val=val/k +!!$ if (verbose>4) print 2,'deg',j,val,'should',& +!!$ exp((0,.5)*kbound)*(0,1.)**j*2*bessel_jn(j,kbound*.5) + val=exp((0,.5)*kbound)*(0,1.)**j*2*bessel_jn(j,kbound*.5) + if (verbose>4) print '(A,I5,": (",G23.16,",",G23.16,")")','deg',j,val + if (abs(val)>epsp) exit + end do +!!$ end block chebysample + j=j+1 ! j is the min. *frequency* - we need one more interpolation point + if (verbose>0) print '(A,I0,A,G23.16,A)','Found k-sample-number needed for gyro phases=',& + j,' at k=',kbound,' WARNING should depend on both species' + est_k_sampling=j + end function est_k_sampling + + subroutine calc_projleg(projleg,lmax2,lmax0,gpl,gwl) + ! calculate half of the projection matrix for the Legendrepolynomials. + ! only half is needed, because the other half can be infered from parity. + ! the complete set of vertices is therefore lmax2*2, which is even. + ! actually--> this is part of calc_projassleg. Should use that one. + implicit none + integer,intent(in) :: lmax2,lmax0 + real,intent(out) :: projleg(lmax2,lmax0) + real,intent(in) :: gwl(lmax2),gpl(lmax2) ! gauss weights and points + ! ^^may be defined also for more than lmax2, no problemo + real p1,p0,pi,x + integer i,k,j,l + + ! projleg might be improvable by using an eigenvector routine or real*16 variables + k=0 + do i=1,lmax2 + x=gpl(i) + p1=0 + pi=sqrt(gwl(i)) + j=1 + projleg(i,j)=pi*sqrt(j-1+.5) + do j=2,lmax0 + p0=pi + pi=((2*(j-2)+1)*x*pi-(j-2)*p1)/(j-1) + p1=p0 + projleg(i,j)=pi*sqrt(j-1+.5) + enddo + if (verbose>4) then + do l=1,lmax0 + if (projleg(i,l)==0) then + print *,'projleg zero??',i,l,projleg(i,l) + k=k+1 + else if(abs(projleg(i,l))4) then + print '(A,I5,A)','projleg had',k,' strange coefficients.' + do l=1,lmax0 + print 2,'projleg l norm=1',l,sum(projleg(:,l)**2) + enddo + do l=1,lmax0-1 + print 2,'projleg l norm=0',l,sum(projleg(:,l)*projleg(:,l+1)) + enddo + do l=1,lmax2 + print 2,'projleg l norm=1',l,sum(projleg(l,:)**2) + enddo + do l=1,lmax2-1 + print 2,'projleg l norm=0',l,sum(projleg(l,:)*projleg(l+1,:)) + enddo + end if +2 format (A,I5,G25.16) + + end subroutine calc_projleg + + + subroutine gyrotrafo(gyrocolmat,nmax0,lmax0,colmat,ncolmat,lcolmat,projsteen,sp,nsteen,xmax,krhoa,krhob,eps) + implicit none + integer,intent(in) :: lmax0,nmax0,ncolmat,lcolmat,nsteen + real,intent(in) :: xmax,krhoa,krhob,eps !for a and b species + optional :: krhob,eps !default is equal to krhoa + + ! In the first iteration we use equal nmax0 and nmaxpoly for all species. + ! For unequal n we also need to update landau.f90 + ! In that case we need two projsteen and sp, and beskl (see below) + ! We may however compute the actually needed nmaxpoly and possibly nmax0. + + ! We take the angular functions square normalised to unity (not as the Ylm). + ! As does energymatrix() and the other landau routines. + + real,intent(out) :: gyrocolmat(nmax0,lmax0,nmax0,lmax0) + ! output calculated gyrokinetic collision matrix. + ! a-species: second pair of indices, b: first pair + + real,intent(in) :: colmat(ncolmat,ncolmat,lcolmat) !input Landau collision matrix + real,intent(in) :: projsteen(nsteen,nsteen),sp(nsteen) + !projection matrix (i.e. sqrt(weight(i))*P(sp(i)) and vertices. + real krb + real,dimension(:),allocatable :: gpl,gwl ! Gauss points + real,dimension(:,:),allocatable :: projleg,v_theta_space,v_l_space,steen0_theta_space,tmp_steen_space + real,dimension(:,:,:),allocatable :: beskla,besklb,steen_l_space + real,dimension(:,:,:,:),allocatable :: projassleg + real val + real epsp + integer mpullback,lmax,extradegree,nmaxpoly + integer i,j,k,l,m,m2max,l2 + integer oe,moe !odd even angular momentum =1: even =2:odd, moe=0/1: even/odd m numbers + integer mphys,lphys ! real mode numbers, otherwise indices are used, which are those +1 + integer m1,m2,o,q !used for verbose output in projassleg + integer, external ::idamax + + ! originally in block "timeblock": + real tbes,t(11),tto,t1,t2,cost(11) + real,allocatable,dimension(:,:,:) :: max_n_comp,max_l_comp + + ! originally in block "lminblock": + integer lminb + real lbval,lminbval + + ! originally in certain diagnostic blocks: + integer idx,a(4) + real v1 + integer a1(4),a2(4) + real div,siv,sym,sym1 + + real,allocatable,dimension(:) :: maxn,maxl + + if (present(krhob)) then + krb=krhob + else + krb=krhoa + end if + + if (present(eps)) then + epsp=eps + else + epsp=epspullback + endif + + ! First a few sanity checks and estimates + + + if (verbose>0 .and. mod(lcolmat,2)==1) then +2 format (A,9(I0,A)) + print 2,'Warning in gyrotrafo: lmax is assumed to be even, but input collision matrix has l=',lcolmat,'.' + print 2,'Cannot use this extra information. Because lmax is needed to be even.' + end if + + mpullback=est_mpullback(krhoa*xmax,kboundb=krb*xmax,eps=eps) + if (verbose>0) print 2,'mpullback must be >=',mpullback + lmax=lmax0+mpullback + ! make lmax an even number + if (mod(lmax,2)==1) then + mpullback=mpullback+1 + lmax=lmax0+mpullback + if (verbose>0) print 2,'Corrected mpullback to make lmax even mp.=',mpullback + end if + if (verbose>0) print 2,'Using lmax=',lmax,'. (lmax0=',lmax0,')' + + + if (lcolmat0) print 2,'Need extradegree',extradegree,'-> max. polynomial degree=',nmaxpoly-1 + if (nmaxpoly>ncolmat) then + print *,'Error in gyrotrafo: Max. polynomial degree in colmat='& + ,ncolmat-1,', but need',nmaxpoly-1 + stop + end if + if (nmaxpoly>nsteen) then + print *,'Error in gyrotrafo: Max. polynomial degree in projsteen/sp='& + ,nsteen-1,', but need',nmaxpoly-1 + stop + end if + + ! So now for the pullback: + ! we need first the pullback projection matrices. + ! we define a maximum L, that is considered. Everything above Lmax is + ! projected out in real particle space. + + ! First we set up separate Steen and Legendre Projectionmatrices: (We + ! normalise the Legendre polynomials by the factor sqrt(n+.5) so that the + ! squareintegral is 1). + + !projleg might be improvable by using an + !eigenvector routine or real*16 variables + + if (verbose>4) then + print *,'Steen function projsteen(nmax0,nmaxpoly)=',projsteen(nmax0& + ,nmaxpoly),'at sp=',sp(nmaxpoly),'nmax0=',nmax0 + print *,'Steen function projsteen(nmaxpoly,nmaxpoly)=' & + ,projsteen(nmaxpoly,nmaxpoly),'at gp=',sp(nmaxpoly),'nmaxpoly='& + ,nmaxpoly +!!$ do i=1,nmaxpoly +!!$ print *,'projsteen norm=1',i,sum(projsteen(i,:)**2) +!!$ enddo +!!$ do i=1,nmaxpoly-1 +!!$ print *,'projsteen norm=0',i,sum(projsteen(i,:)*projsteen(i+1,:)) +!!$ enddo + + end if + + allocate(gwl(lmax),gpl(lmax)) + call gauss_legendre(-1.,1.,gpl,gwl,lmax) + ! If lmax is even, we need only half of the vertices. + allocate(projleg(lmax/2,lmax0)) ! Convert from lmax0-L-space to lmax-xi-space + call calc_projleg(projleg,lmax/2,lmax0,gpl,gwl) + + !Now calculate projector for associated Legendre functions at Gauss points gpl. + !These functions are only polynomials for even m. + !Parity: P^m_l is an even function, if m+l even. + !Therefore often only half sums have to be calculated. + ! And we assume lmax to be even. + + allocate(projassleg(lmax/2,lmax/2,2,mpullback+1)) + call calc_projassleg(projassleg,lmax/2,lmax/2,mpullback+1,gpl,gwl) + !Note: projleg(i,j)=projassleg(i,(j+1)/2,mod(j+1,2),1) + !here: m=mphys+1, j=jphys+1: (later m=mphys; mpullback=phys.) + !oe=mod(j+m,2)+1 + !projassleg-old(i,j,m)=projassleg(i,(j-1)/2+1,mod(j+m,2)+1,m) + ! =projassleg(i,(j+1)/2,mod(j+m,2)+1,m) + !projassleg(i,j2,oe,m)=projassleg-old(i,j2*2-mod(j,2),m) + ! =projassleg-old(i,j2*2-mod(oe+m-1,2),m) + ! =projassleg-old(i,j2*2+mod(oe+m,2)-1,m) + !projassleg-old is even, if j+m is even, or if oe is 1 (and not 2). + + !old: + !projassleg(i,j,m)=Pmj(gpl(i))* sqrt( (2lphys+1) (lphys-mphys)! /(2(lphys+mphys)!) ) + ! + ! nor(j,m)=sqrt( (2j-1) (j-m)! /(2(j+m-2)!) ) + ! nor(m,m)=sqrt( (2m-1)/(2 (2m-2)!) + ! nor(m,m)/nor(m-1,m-1)= sqrt((2m-1)/(2m-3)/(2m-2)/(2m-3))=sqrt((2m-1)/(2m-2)) / (2m-3) + ! =sqrt((2m-1)(2m-4)/(2m-3)/(2m-2)) + ! nor(j,m)/nor(j-1,m)=sqrt( (2j-1)/(2j-3)*(j-m)/(j+m-2) ) + + ! projassleg might be improvable by using an eigenvector routine or real*16 variables +!!$ m1=0;m2=0;q=0;o=20 !only for verbose +!!$ projassleg=0 +!!$ j=0 +!!$ do i=1,lmax/2 +!!$ x=gpl(i) +!!$ do m=1,mpullback+1 +!!$ ! we start at pmm and move to higher L +!!$ p1=0 +!!$ mphys=m-1 +!!$ if (m==1) then +!!$ !P00=1*sqrt(1/2) +!!$ pi=sqrt(.5*gwl(i)) +!!$ projassleg(i,1,1,1)=pi +!!$ else +!!$ pi=-sqrt(1-x**2)*projassleg(i,m/2,1,m-1)*sqrt((2*m-1.)/(2*m-2.)) +!!$ projassleg(i,(m+1)/2,1,m)=pi +!!$ endif +!!$ do l=m+1,lmax +!!$ lphys=l-2 +!!$ p0=pi +!!$ pi=( (2*lphys+1)*x*pi-(lphys+mphys)*p1 )/(lphys-mphys+1) +!!$ pi=pi*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) +!!$ p1=p0*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) +!!$ projassleg(i,(l+1)/2,mod(l+m,2)+1,m)=pi +!!$ enddo +!!$ if (verbose>0) then +!!$ do l2=1,lmax/2 +!!$ do oe=1,2 +!!$ if (l2*2+mod(oe+m,2)-1 sum l=0.. sqrt((2l+1)*4pi) Y0l + ! However we are not normalising our P_l and Pml correctly but so that + ! =2pi + ! so exp(i k*v_perp) = sum l=0 ... (2l+1)i^l Jspher_l(kvperp) sqrt(2/(2l+1))myP_l(kvperp*sin(theta)) + ! so exp(i k*v_perp) = sum l=0 ... i^l Jspher_l(kvperp) sqrt(2*(2l+1))myP_l(kvperp*sin(theta)) + ! Now loop over steen index and L index + + allocate(beskla(nsteen,lmax/2,0:mpullback)) + if (krb/=krhoa) allocate(besklb(nsteen,lmax/2,0:mpullback)) + allocate(steen0_theta_space(nmax0,lmax/2)) + allocate(v_theta_space(nsteen,lmax/2)) + allocate(v_l_space(nsteen,lmax/2)) + allocate(steen_l_space(nmaxpoly,0:mpullback/2,lmax/2),tmp_steen_space(nmaxpoly,0:mpullback/2)) + ! Wir zerlegen alle Funktionen in die m,L und setzen sie wieder zusammen. + ! Dann schauen wir ob was am RMS fehlt. + ! print 2,'sumprojsteen',sum(projsteen),sum(projassleg),sum(projleg) + gyrocolmat=0 + val=0 + if (verbose>4) then + allocate(max_n_comp(nmaxpoly,nmax0,lmax0),max_l_comp(lmax,nmax0,lmax0)) + max_n_comp=0 + max_l_comp=0 + q=0;o=20 ! for error messages + end if + tbes=0 + t=0 + cost=0 + call cpu_time(tto) + call cpu_time(t1) + do m=mpullback,0,-1 + do l2=1,lmax/2 + beskla(:,l2,m)=bessel_jn(m,krhoa*sp*sqrt(1-gpl(l2)**2)) + if (krb/=krhoa) then + besklb(:,l2,m)=bessel_jn(m,krb*sp*sqrt(1-gpl(l2)**2)) + end if + ! don't like sqrt(1-gpl(l)**2) for sin theta. Should use something more accurate. ??? + enddo + ! print 2,'m=',m,'sumbeskl',sum(beskla(:,1:lmax/2,m)) + end do + call cpu_time(t2) + tbes=tbes+(t2-t1) + + + jloop: do j=1,lmax0 + oe=mod(j+1,2)+1 !oe=1: even in z oe=2: odd in z + lminb=0 + lminbval=0 + !m=mphys l=lphys+1 here + !l>=m+1, l<=lmax and oe+m+l is even. + !==> l>=m+oe. since lmax is even l<=lmax-mod(oe+m,2) + !the correct arguments are projassleg(,(l+1)/2,oe,m+1) + !==> (l+1)/2 >=(m+oe+1)/2 (l+1)/2<=(lmax-mod(oe+m,2)+1)/2=lmax/2 +(1-mod(oe+m,2))/2=lmax/2 +!!$ do l2=(m+oe+1)/2,lmax/2 !n_elements=lmax/2-(m+oe+1)/2+1=(lmax+2-m-oe)/2 +!!$ lbval=sum(beskla(nmaxpoly,:)*projleg(:lmax/2,j)& +!!$ *projassleg(:,l2,oe,m+1)) +!!$ !if (m==1 .and. j==30) print 2,'m,j,l,lbval',m,j,l,lbval +!!$ if (abs(lbval)>epsp) then +!!$ lminb=l2*2+mod(oe+m,2)-1 +1 +!!$ lminbval=lbval +!!$ end if +!!$ end do +!!$ print 2,'m',m,'j',j,'lminb',lminb,'lminbval',lminbval + !^^ can use this boundary value as estimate of max l needed. + ! most conservative value for m=0. + ! can also reduce lmax by that. But will not be greatly different from lmax. + + iloop: do i=1,nmax0 + moeloop: do moe=0,1 ! do odd and even m separately + ! we do now all odd or even m in one bunch to be able to reuse the read in collision matrix. + ! costs a little more memory. + mloop: do m=mpullback-mod(moe+mpullback,2),moe,-2 ! Leaving out negative m's here. That must be accounted for when doing sums. + !number of loop traversals=(mpullback-mod(moe+mpullback,2)-moe+2)/2 + ! =(mpullback-moe+2-mod(mpullback-moe+2,2))/2 + ! =(mpullback-moe+2)/2 (carefull here: (-1)/2=0) + ! max. traversals occur for moe=0 and are (mpullback+2)/2=mpullback/2+1 since mpullback>=0. + call cpu_time(t1) + do l2=1,lmax/2 + do k=1,nsteen + v_theta_space(k,l2)=beskla(k,l2,m)*projsteen(i,k)*projleg(l2,j) + ! should be same as *projassleg(l2,j/2,oe,1) + ! Note: sum_i=-infty,+infty bessel_jn(i,x)^2 = 1 for any x. + enddo + enddo + call cpu_time(t2) + t(1)=t(1)+(t2-t1) + cost(1)=cost(1)+nsteen*lmax/2 + !cost=lmax*n maybe lmax/2*n + ! Now transform into l space. For this we have to multiply with the Pml for l>=m. + ! for even/odd jphys: l+m must be even/odd. + ! Smallest possible lphys: + ! for even jphys (oe=1): lphys=mphys + ! for odd jphys (oe=2): lphys=mphys+1 + ! (sometimes cannot be mphys, because that has wrong parity.) + ! ==> lphysmin=mphys+oe-1 always. + ! l2min=(lphysmin)/2+1=(mphys+oe-1)/2+1=(mphys+oe+1)/2 + ! Since lmax is even (!): + ! number of l2=lmax/2+1-(m+oe+1)/2=(lmax+2)/2-(m+oe+1)/2=(lmax+2-m+oe)/2 + ! This is independent for every k. + ! Matrix multiply with upper triangular matrix projassleg: + ! v_l_space(:,1:m)=0 + if (verbose>4) v_l_space=1e300 + call cpu_time(t1) + call dgemm('n','n',nsteen,(lmax-m+2-oe)/2,lmax/2,1.,v_theta_space,nsteen,& + projassleg(:,(m+oe+1)/2:lmax/2,oe,m+1),lmax/2,0.,& + v_l_space(:,(m+oe+1)/2:lmax/2),nsteen) + call cpu_time(t2) + t(2)=t(2)+(t2-t1) + cost(2)=cost(2)+nsteen*((lmax-m+2-oe)/2)*lmax/2 + ! Only l remain here, for which m+j+l=even. + ! or j+oe=even. + ! Of course also on the way back parity is conserved. + ! We have therefore separate even l and odd l gyrocolmat. + ! This makes total sense. + ! Pml and projassleg is an even function for + ! Now we work on v_l_space with the steen polynomials and the collision operator. + ! we multiply over the left index of v_l_space + if (verbose>4) steen_l_space(:,m/2,:)=1e300 + call cpu_time(t1) + call dgemm('n','n',nmaxpoly,(lmax-m+2-oe)/2,nsteen,1.,projsteen,nsteen& + ,v_l_space(:,(m+oe+1)/2:lmax/2),nsteen,0.,& + steen_l_space(:,m/2,(m+oe+1)/2),nmaxpoly*(1+mpullback/2)) + call cpu_time(t2) + t(3)=t(3)+(t2-t1) + cost(3)=cost(3)+nmaxpoly*((lmax-m+2-oe)/2)*nsteen + !could conceivably cut off this matrix product + if (verbose>4) then + do k=1,nmaxpoly + max_n_comp(k,i,j)=max(max_n_comp(k,i,j),maxval(steen_l_space(k,m/2,(m+oe+1)/2:lmax/2))) + end do + do k=(m+oe+1)/2,lmax/2 + l=k*2-mod(oe+m,2) + max_l_comp(l,i,j)=max(max_l_comp(l,i,j),maxval(steen_l_space(:,m/2,k))) + end do + end if + ! epspullback-small whenever l>j+mpullback or lm + ! for backtransform small, if + ! j l+mpullback + ! could be checked how far out needed, also |v| cut-off + ! if there is no redistribution of l, + ! it is sufficient to have sqrt(epspullback)?? + ! only lmax cutoff, not mpullback + ! + ! Now we do whatever we want with steen_l_space. + + ! here + ! can use dgemm_batch of mkl library. + if (verbose>4) then + steen_l_space(:,m/2,:(m+oe+1)/2-1)=1e300 + end if + end do mloop + if (verbose>4 .and. (mpullback-mod(moe+mpullback,2))/2 comments in calc_projassleg + ! l=lphys+1 + ! this should be equal (l2-(moe+oe+1)/2)*2+lmin, + ! lmin(moe,oe)=moe+1+mod(oe+1,2)=moe+oe + ! i.e. l=(l2-(moe+oe+1)/2)*2+moe+oe + ! =l2*2-(moe+oe+1)/2*2+moe+oe + ! =l2*2+moe+oe+1-((moe+oe+1)/2*2-1 + ! =l2*2+mod(moe+oe+1,2)-1 + ! =l2*2-mod(moe+oe,2) ok! + + ! for small l2 we do not have to do all m. The condition on m for given l2 is + ! l2>=(m+oe+1)/2 <=> 2*l2>=(m+oe+1)/2*2 <=> 2*l2+1>=m+oe+1 <=> m<=2*l2-oe>=moe + ! check: oe=1 ==> (moe+oe+1)/2*2-oe=moe/2*2+1=1 + ! oe=2 ==> (moe+oe+2)/2*2-oe=(moe+1)/2*2=moe ok. + ! In addition mod(m+moe,2)==0 ==> m<=2*l2-oe-mod(2*l2-oe+moe,2)= + ! =2*l2-oe-mod(oe+moe,2) + ! # ==> m/2<=(2*l2-oe-mod(oe+moe,2))/2=l2-oe+(oe-mod(oe+moe,2))/2 + ! =l2-oe+(moe+oe-moe-mod(oe-moe,2))/2 + ! =l2-oe+(oe-moe)/2 + ! check: case distinction for #: + ! oe=1,moe=0 ==> (2*l2-1-mod(1,2))/2=(2*l2-2)/2=l2-1 + ! oe=1,moe=1 ==> (2*l2-1)/2=l2-1 (l2>=1) + ! oe=2,moe=0 ==> (2*l2-2)/2=l2-1 + ! oe=2,moe=1 ==> (2*l2-2-1)/2=(2*l2-3)/2 and l2>=2 in that case + ! ==> (2*l2-4)/2=l2-2 + ! in total l2-1 excebt if oe+moe=3 then l2-2. ==> l2-(oe+moe+1)/2 + ! ok clear. For every m+=2 we gain another l2 and vice versa. + ! in addition m<=mpullback/2. + m2max=min(l2-(oe+moe+1)/2,mpullback/2) + if (verbose>4 .and. m2max ./gt 5 5 0 1 1 .1 +!!$ Dabei ist hier der Fehler sogar viel zu klein!!! +!!$ evtl. könnte man bei nmax noch eine maximal rechts lokalisierte Funktion ausrechnen. +!!$ und was nicht geht: zu großer error in den diagonalen. +!!$ ksh@gadget:~/w> ./gtt 5 5 0 1 1 .1 + + mloop2: do m=mpullback-mod(moe+mpullback,2),moe,-2 ! Leaving out negative m's here. That must be accounted for when doing sums. + + ! ..... and then: + if (verbose>4) v_l_space=1e300 + call cpu_time(t1) + call dgemm('t','n',nsteen,(lmax-m+2-oe)/2,nmaxpoly,1.,projsteen,nsteen& + ,steen_l_space(:,m/2,(m+oe+1)/2),nmaxpoly*(1+mpullback/2),0.,& + v_l_space(:,(m+oe+1)/2:lmax/2),nsteen) + call cpu_time(t2) + t(4)=t(4)+(t2-t1) + cost(4)=cost(4)+nsteen*((lmax-m+2-oe)/2)*nmaxpoly + + if (verbose>4) v_theta_space=1e300 + call cpu_time(t1) + call dgemm('n','t',nsteen,lmax/2,(lmax-m+2-oe)/2,1.,& + v_l_space(:,(m+oe+1)/2:lmax/2),nsteen,& + projassleg(:,(m+oe+1)/2:lmax/2,oe,m+1),lmax/2,0.,& + v_theta_space,nsteen) + call cpu_time(t2) + t(5)=t(5)+(t2-t1) + cost(5)=cost(5)+lmax/2*((lmax-m+2-oe)/2)*nsteen + + call cpu_time(t1) + if (krb/=krhoa) then + v_theta_space=v_theta_space*besklb(:,:,m) + else + v_theta_space=v_theta_space*beskla(:,:,m) + end if + call cpu_time(t2) + t(6)=t(6)+(t2-t1) + cost(6)=cost(6)+nsteen*lmax/2 + + if (verbose>4) steen0_theta_space=1e300 + call cpu_time(t1) + call dgemm('n','n',nmax0,lmax/2,nsteen,1.,projsteen,nsteen,v_theta_space,nsteen,0.,steen0_theta_space,nmax0) + call cpu_time(t2) + t(7)=t(7)+(t2-t1) + cost(7)=cost(7)+nsteen*lmax/2*nmax0 + ! ! SUM UP gyrocolmat (!) ==> + call cpu_time(t1) + if (m==0) then + !projleg delivers 1<=l<=lmax0. thereby oe=1: 1,3,... oe=2: 2,4,... max(l)=lmax0-mod(oe+lmax0,2) + ! n(l)=(max(l)-oe)/2+1=(lmax0-mod(oe+lmax0,2)-oe+2)/2=(lmax0-oe-mod(lmax0-oe,2)+2)/2=(lmax0-oe+2)/2 correct. + call dgemm('n','n',nmax0,(lmax0-oe)/2+1,lmax/2,4.,steen0_theta_space& + ,nmax0,projleg(:,oe:),lmax,1.,gyrocolmat(:,oe:,i,j),nmax0*2) + !factor 8 because of lmax/2 and in total 4 L projectors in a row. + !note dimensions: projleg(lmax/2,lmax0) gyrocolmat(nmax0,lmax0,nmax0,lmax0) + !note further: parity conservation requires gyrocolmat(_,i,_,j) to be zero for odd i+j. + !lmax and nmax0*2 because of parity conservation + else + call dgemm('n','n',nmax0,(lmax0-oe)/2+1,lmax/2,8.,steen0_theta_space,nmax0,& + projleg(:,oe:),lmax,1.,gyrocolmat(:,oe:,i,j),nmax0*2) + endif + call cpu_time(t2) + t(8)=t(8)+(t2-t1) + cost(8)=cost(8)+lmax/2*nmax0*((lmax0-oe)/2+1) + + + ! Then we transform everything back into normal space. + ! steen_l_space is the nice pullbacked matrix. + ! In principle the full specification is + ! steen_l_space(1..n,m/2,l=m..lmax [,i=1..nmax0,j=1..lmax0,m=1..mpullback+1]) l>=m + ! [..] suppressed (loop variables) + ! it may be useful to actually caclulate this one. + ! ok, we probably don't have to store the m's simultaneously. + ! the outer loop should be over m. + ! totally clear, that the m sum is outside. and we store the bessel_jn(m, ... k ... l) + ! independent from the rest. + ! with that the storage is reduced to n*lmax for bessel, n*nmax0 for projsteen + ! lmax*lmax0 for projleg and (m*) lmax*mpullback. + enddo mloop2 + end do moeloop + end do iloop + enddo jloop + call cpu_time(t1) + if (verbose>4) then + !find index of max absolute element of gyrocolmat: + idx=idamax((nmax0*lmax0)**2,gyrocolmat,1) + a=Mod((idx-1)/(/nmax0*lmax0**2,nmax0*lmax0,lmax0,1/),(/nmax0,lmax0,nmax0,lmax0/))+(/1,1,1,1/) + v1=gyrocolmat(a(1),a(2),a(3),a(4)) + if (abs(v1)>val) then + val=abs(v1) + print "(A,I3,A,4I4,A,ES25.17)",'At m=',m,' component maximum at i,j,k,l=',a,' value=' ,v1 + end if + m1=0 + do i=1,nmax0 + do j=1,lmax0 + do k=1,nmax0 + do l=1,lmax0 + if (mod(j+l,2)==1) then + if (gyrocolmat(i,j,k,l)/=0) then + print *,'gyrocolmat parity??',i,j,k,l,gyrocolmat(i,j,k,l) + m1=m1+1 + end if + else + if (gyrocolmat(i,j,k,l)==0) then + if (m==0 .or. krhoa /=0 .and. krb/=0) then + !in case for some reason kperp=0 we do not print the m>0. + print *,'gyrocolmat zero??',i,j,k,l,gyrocolmat(i,j,k,l) + m1=m1+1 + end if + else if (abs(gyrocolmat(i,j,k,l))<1e-16*epsgyrocolmat) then + print '(A,4I5,G25.16)','extraneous (near) zero at',i,j,k,l,gyrocolmat(i,j,k,l) + end if + end if + if ((iepsgyrocolmat*(1 & + +abs(gyrocolmat(i,j,k,l)))) then +!!$ if(q0) then + print '(A,G24.16)','tbes:',tbes + cost(9)=1 + do i=1,11 + if (t(i)>0 .and. cost(i)>0) & + print "(I2,9(' ',A,ES9.2))",i,'t(i):',t(i),'cost(i):',cost(i),'t(i)/cost(i):',& + t(i)/cost(i),'flops/cycle(i):',2*cost(i)/(t(i)*3.9d9) + end do + print '(A,2(G24.16))','tot',tto,tbes+sum(t) + end if + if (verbose>4) then + allocate(maxn(nmax0:nmaxpoly),maxl(lmax0:lmax)) + do i=nmax0,nmaxpoly + maxn(i)=maxval(max_n_comp(i,:,:)) + end do + do i=lmax0,lmax + maxl(i)=maxval(max_l_comp(i,:,:)) + end do + print '(A,10(ES9.2))','maxl',maxl + print '(A,10(ES9.2))','maxn',maxn + ! e.g. ./gt 5 .1 1 1 1 100 + deallocate(maxn,maxl,max_n_comp,max_l_comp) + end if + ! Now go through gyrocolmat and check for larger than normal discrepancies + if (verbose>4) then + o=20 + q=0 + div=0 + siv=0 + sym=0 + do i=1,nmax0 + do j=1,lmax0 + do k=1,nmax0 + do l=1,lmax0 + if (mod(j+l,2)==1) then + if (gyrocolmat(i,j,k,l)/=0) then + print *,'gyrocolmat parity??',i,j,k,l,gyrocolmat(i,j,k,l) + end if + else + if (gyrocolmat(i,j,k,l)==0) then + !if (abs(j-l)<=2 .and. abs(i-k)<=5) & + print *,'gyrocolmat zero??',i,j,k,l,gyrocolmat(i,j,k,l) + ! this vanishes if xmax<=3: + ! ksh@napoleon:~/w> ./gt 15 5 2 1 1 6 + ! ksh@napoleon:~/w> ./gt 5 30 2 1 1 1 + ! produces zero?? + ! ksh@napoleon:~/w> ./gt 15 3 2 1 1 10 + ! ksh@napoleon:~/w> ./gt 5 1 2 1 1 30 + ! produces nothing. + +!!$ else if (abs(gyrocolmat(i,j,k,l))sym) then + sym=sym1 + if(qepsgyrocolmat) & + print *,'gyrocolmat symmetry??',i,j,k,l,gyrocolmat(i,j ,k,l)& + ,gyrocolmat(k,l,i,j),gyrocolmat(i,j,k ,l)-gyrocolmat(k,l,i,j) + q=q+1 + end if + endif +!!$ if (i==k .and. j==l) then +!!$ if (abs(gyrocolmat(i,j,k,l)-1)>div) then +!!$ div=abs(gyrocolmat(i,j,k,l)-1) +!!$ a1=(/i,j,k,l/) +!!$ print '("gyrocolmat diagonal error",i5,i3,ES24.16)',i,j,gyrocolmat(i,j,k,l)-1 +!!$ endif +!!$ else +!!$ if (abs(gyrocolmat(i,j,k,l))>siv) then +!!$ siv=abs(gyrocolmat(i,j,k,l)) +!!$ a2=(/i,j,k,l/) +!!$ print '("gyrocolmat side error",4i3,ES24.16)',i,j,k,l,gyrocolmat(i,j,k,l) +!!$ end if +!!$ endif + end do + end do + end do + end do +!!$ if (div>epsp*4 .or. siv>epsp*4) then +!!$ print 2,'something went wrong' +!!$ else +!!$ print 2,'everything ok' +!!$ endif + print "(A,ES12.2)",'max symmetry error',sym +!!$ print "(A,ES12.2,2I3,ES25.16)",'max error on diagonal',div,a1(1:2),gyrocolmat(a1(1),a1(2),a1(3),a1(4)) +!!$ print "(A,ES9.2,4I3,2ES25.16)",'max error on sides',siv,a2& +!!$ ,gyrocolmat(a2(1),a2(2),a2(3),a2(4)),gyrocolmat(a2(3),a2(4)& +!!$ ,a2(1),a2(2)) +!!$ do i=2,nmax0-1 +!!$ do j=1,lmax0 +!!$ print 2,'testm',i,j,gyrocolmat(i-1:i+1,j,i,j) +!!$ end do +!!$ enddo +!!$ do i=2,nmax0-1 +!!$ do j=3,lmax0 +!!$ print 2,'testmj-2',i,j,gyrocolmat(i-1:i+1,j-2,i,j) +!!$ end do +!!$ enddo +!!$ do i=2,nmax0-1 +!!$ do j=1,lmax0-2 +!!$ print 2,'testmj+2',i,j,gyrocolmat(i-1:i+1,j+2,i,j) +!!$ end do +!!$ enddo + end if + end subroutine gyrotrafo + + subroutine calc_projassleg(projassleg,ng,lmax2,mmax,gpl,gwl) + !Calculate associated Legendre functions. + !They are normalised, such that their square integrals over [-1,1] is 1. + !Due to known parity, normally only half the values are needed. + !Note also: P-ml=Pml*(-)^m for this normalisation. + implicit none + integer,intent(in) :: lmax2,mmax,ng + real,intent(out) :: projassleg(ng,lmax2,2,mmax) + real,intent(in) :: gpl(ng),gwl(ng) + ! ^^may be defined also for more or less than lmax2, no problemo + + real p1,pi,p0,x + integer i,j,k,l,l2,m,oe + integer lphys,mphys + integer m1,m2,q,o !only for verbose + + !allocate(projassleg(lmax2,lmax2,2,mmax)) + !use projassleg(i_vertex,l2=jphys/2+1,oe,mphys+1) + !here: m=mphys+1, j=jphys+1: (later m=mphys; mpullback=phys.) + !oe=mod(j+m,2)+1=mod(jphys+mphys,2)+1 + ! => jphys=jphys/2*2+mod(jphys,2)=2*(l2-1)+mod(oe-1+mphys,2)=2*l2-2+mod(oe+1+mphys,2)= + ! =2*l2-2+1-mod(oe+mphys,2)=2*l2-1-mod(oe+mphys,2) + ! ==> j=2*l2-mod(oe+mphys,2) + + !projassleg-old(i,j,m)=projassleg(i,(j-1)/2+1,mod(j+m,2)+1,m) + ! =projassleg(i,(j+1)/2,mod(j+m,2)+1,m) + !projassleg(i,j2,oe,m)=projassleg-old(i,j2*2-mod(j,2),m) + ! =projassleg-old(i,j2*2-mod(oe+m-1,2),m) + ! =projassleg-old(i,j2*2+mod(oe+m,2)-1,m) + !projassleg-old is even, if j+m is even, or if oe is 1 (and not 2). + + !old: + !projassleg(i,j,m)=Pmj(gpl(i))* sqrt(gwl(i))*sqrt( (2lphys+1) (lphys-mphys)! /(2(lphys+mphys)!) ) + ! so that int(x=-1..1) projassleg**2/gwl dx=1 or sum_i projassleg**2 =1. + ! possibly not all Gauss points need be calculated due to parity, then ng is reduced to about half. + ! + ! nor(j,m)=sqrt( (2j-1) (j-m)! /(2(j+m-2)!) ) + ! nor(m,m)=sqrt( (2m-1)/(2 (2m-2)!) + ! nor(m,m)/nor(m-1,m-1)= sqrt((2m-1)/(2m-3)/(2m-2)/(2m-3))=sqrt((2m-1)/(2m-2)) / (2m-3) + ! =sqrt((2m-1)(2m-4)/(2m-3)/(2m-2)) + ! nor(j,m)/nor(j-1,m)=sqrt( (2j-1)/(2j-3)*(j-m)/(j+m-2) ) + ! projassleg might be improvable by using an eigenvector routine or real*16 variables + + m1=0;m2=0;q=0;o=20 !only for verbose>4 + projassleg=0 + j=0 + do i=1,ng + x=gpl(i) + do m=1,mmax + ! we start at pmm and move to higher L + p1=0 + mphys=m-1 ! the mphys we are calculating now. + if (m==1) then + !P00=1*sqrt(1/2) + pi=sqrt(.5*gwl(i)) + projassleg(i,1,1,1)=pi + else + pi=-sqrt(1-x**2)*projassleg(i,m/2,1,m-1)*sqrt((2*m-1.)/(2*m-2)) + ! P(l+1,l+1)=-(2l+1)*sqrt(1-x^2)*P(l,l) (l=lphys) + ! Normalised: + ! P(l+1,l+1)=-(2l+1)*sqrt(1-x^2)*P(l,l)*sqrt((2l+3)/[(2l+1)*(2l+2)(2l+1)]) + ! = -sqrt(1-x^2)*P(l,l)*sqrt((2l+3)/(2l+2)) + !here: lphys=mphys=m-1 => l2=(m+1)/2=(lphys+2)/2=lphys/2+1 + projassleg(i,(m+1)/2,1,m)=pi + endif + do l=m+1,2*lmax2 + lphys=l-2 + p0=pi + pi=( (2*lphys+1)*x*pi-(lphys+mphys)*p1 )/(lphys-mphys+1) + ! for (m,l)=phys + ! (l-m+1)P(m,l+1)=(2l+1)xP(m,l)-(l+m)P(m,l-1) + ! Normalised: + ! Pnor(m,l)=P(m,l)*sqrt((2l+1)(l-m)!/[2*(l+m)!]) + ! (l-m+1)Pn(m,l+1)/sqrt((2l+3)(l+1-m)/(l+m+1))= + ! =(2l+1)xPn(m,l)/sqrt(2l+1)-(l+m)Pn(m,l-1)/sqrt((2l-1)(l+m)/(l-m)) + ! Pn(m,l+1)*sqrt((l-m+1)*(l+m+1)/(2l+3))= + ! =xPn(m,l)*sqrt(2l+1)-Pn(m,l-1)*sqrt((l+m)(l-m)/(2l-1)) + ! + pi=pi*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) + p1=p0*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) + projassleg(i,(l+1)/2,mod(l+m,2)+1,m)=pi + enddo + if (verbose>4) then + do l2=1,lmax2 + do oe=1,2 + if (l2*2+mod(oe+m,2)-14) print '(8(A,I3))','projassleg had',m1,'zero and',m2,'near zero coefficients of',j,'total',(mmax)*ng*lmax2*2 + ! Now should better check the normalisation +!!$ m=(lmax+1)/2 +!!$ m=mpullback+1 +!!$ do l=m,lmax +!!$ print 2,'m,l norm=1',m,l,sum(projassleg(:,l,m)**2) +!!$ enddo +!!$ do l=m,lmax-1 +!!$ print 2,'m,l norm=0',m,l,sum(projassleg(:,l,m)*projassleg(:,l+1,m)) +!!$ enddo +!!$ 2 format (5(G0," ")) + end subroutine calc_projassleg + + subroutine calc_projasslegm(projasslegm,ng,lmax,mmode,gpl,gwl) + !Calculate associated Legendre functions. + !Calculate only one specific m-mode with l=mmode .. lmax + !They are normalised, such that their square integrals over [-1,1] is 1. + !That means their RMS is 1/sqrt(2) (over the sphere or over [0,1] or over [-1,1]). + !Note also: P-ml=Pml*(-)^m for this normalisation. + !Due to known parity, normally only half the values are needed. + implicit none + ! do not distinguish any longer between odd and even momenta. To difficult here. + integer,intent(in) :: lmax,mmode,ng + real,intent(out) :: projasslegm(ng,lmax-mmode+1) + real,intent(in) :: gpl(ng),gwl(ng) + ! ^^may be defined also for more than lmax2, no problemo + + real p1,pi,p0,x + integer i,j,k,l,m + integer lphys,mphys + integer m1,m2,q,o !only for verbose>4 + + if (lmax > 2*ng) then + print '(A,I3,A,I3,A)','calc_projasslegm error 2ng=',2*ng,'lmax=',lmax,'-> scalar products incorrect.' + stop + end if + + m1=0;m2=0;q=0;o=20;j=0 !only for verbose + do i=1,ng + x=gpl(i) + ! do m=1,mmax + m=mmode + ! we start at pmm and move to higher L + p1=0 + ! for phys l: + ! Pll=(2l-1)!! (-sqrt(1-x^2))**(l) + ! Necessary normalisation factor: sqrt[ (2l+1) (l-m)!/[2(l+m)! ] + ! = sqrt[ (2l+1)/[2(2l)! ] + pi=sqrt(.5*gwl(i)) + do m=2,mmode + pi=-sqrt(1-x**2)*pi*sqrt((2*m-1.)/(2*m-2)) + end do + projasslegm(i,1)=pi + m=mmode + mphys=m-1 + p1=0 + do l=mmode+1,lmax !l: l idx of poly to be calculated + lphys=l-2 !lphys of poly. stored in pi currently + p0=pi + pi=( (2*lphys+1)*x*pi-(lphys+mphys)*p1 )/(lphys-mphys+1) + ! for (m,l)=phys + ! (l-m+1)P(m,l+1)=(2l+1)xP(m,l)-(l+m)P(m,l-1) + ! Normalised: + ! Pnor(m,l)=P(m,l)*sqrt((2l+1)(l-m)!/[2*(l+m)!]) + ! (l-m+1)Pn(m,l+1)/sqrt((2l+3)(l+1-m)/(l+m+1))= + ! =(2l+1)xPn(m,l)/sqrt(2l+1)-(l+m)Pn(m,l-1)/sqrt((2l-1)(l+m)/(l-m)) + ! Pn(m,l+1)*sqrt((l-m+1)*(l+m+1)/(2l+3))= + ! =xPn(m,l)*sqrt(2l+1)-Pn(m,l-1)*sqrt((l+m)(l-m)/(2l-1)) + ! + pi=pi*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) + p1=p0*sqrt( (2*l-1)/(2*l-3.)* ((l-m)/(l+m-2.)) ) + projasslegm(i,l-mmode+1)=pi + enddo + if (verbose>4) then + do l=mmode,lmax + j=j+1 + if (projasslegm(i,l-mmode+1)==0) then + print '(A,I3,G25.16,I3,I3,G25.16)','projasslegm zero??',i,x,l,mmode,projasslegm(i,l-mmode+1) + m1=m1+1 + else if(abs(projasslegm(i,l-mmode+1))4) then + print '(8(A,I3))','projasslegm had',m1,'zero and',m2,'near zero coefficients of',j,'total',ng*(lmax-mmode+1) + ! Now should better check the normalisation + ! ACTUALLY: Norm is not so accurate and looses 4 digits. Maybe there is a + ! numerically better way to calculate these polynomials + do l=max(mmode,lmax-5),lmax + print '(A,2I3,G25.16)','l norm=1',mmode,l,sum(projasslegm(:,l-mmode+1)**2) + enddo + do l=max(mmode,lmax-7),lmax-2 + print '(A,2I3,G25.16)','l norm=0',mmode,l,sum(projasslegm(:,l-mmode+1)*projasslegm(:,l+2-mmode+1)) + enddo + end if + end subroutine calc_projasslegm + + subroutine gyroproj(fout,nmax0,lmax0,lmode,mmode,projsteen,sp,nsteen,xmax,krho,eps) + ! Gyro-project a given distribution function with given lmode and mmode into the gyrokinetic + ! space. This is useful for creating particle, heat, momentum sources etc.. Different from + ! gyrotrafo, this time the normalisation of the orthogonal angular functions matters, + ! because they are returned. We want the angular coefficients to be equal to the angular + ! RMS they cause, when transformed into real space. That way, the exact geometrical area of + ! validity (sphere, [-1,1], [0,2pi]) does not matter. + ! At krho=0 we expect fout to be exactly the unit matrix in the radial polynomial index for + ! lmode=l and mmode=1 (physical mode numbers by 1 smaller). + ! mphys=mmode-1 + ! For k<0 we get output=(-1)^mphys*output for -k due to the Bessel function. + ! Negative charge corresponds to negative krho. + ! Not sure whether the code works for k<0. + ! For mphys<0 we have Yl,-m=(-1)^m Yl,m^* = (-1)^m [Yl,m*Exp(-imphi)] exp(imphi) + ! J_-m=(-1)^m J_m + ! Pl,-m=(-1)^m Pl,m ==> Identical output. + + + implicit none + integer,intent(in) :: nmax0,lmax0,lmode,mmode,nsteen + real,intent(in) :: xmax,krho,eps + !for a and b species + optional :: eps + + ! In the first iteration we use equal nmax0 and nmaxpoly for all species. + ! For unequal n we also need to update landau.f90 + ! In that case we need two projsteen and sp, and beskl (see below) + ! We may however compute the actually needed nmaxpoly and possibly nmax0. + + real,intent(out) :: fout(nmax0,lmax0,nmax0) ! result is real, + ! since we multiply with the exp(-i*m*theta)-term of the Bessel expansion of a plane wave. + + real,intent(in) :: projsteen(nsteen,nsteen),sp(nsteen) + !projection matrix (i.e. sqrt(weight(i))*P(sp(i)) and vertices. + real,dimension(:),allocatable :: gpl,gwl !,tmp_steen_space ! Gauss points + real,dimension(:,:),allocatable :: projleg,pltest,projasslegm,v_theta_space,beskl,steen0_theta_space + real,dimension(:,:,:,:),allocatable :: paltest + real val + real epsp + integer mpullback,lmax,extradegree,nmaxpoly + integer i,j,k,l,l2 + integer oe !odd even angular momentum =1: even =2:odd. + integer mphys ! real mode numbers, otherwise indices are used, which are those +1 + integer o,q !used for verbose output in projassleg + integer ng2 ! half the Gauss points for Legendre. + logical timing + integer, external ::idamax + integer ngs + + ! originally in block "timeblock": + real tbes,t(11),tto,t1,t2,cost(11) + + ! originally in block "lminblock" + integer lminb + real lbval,lminbval + + timing=verbose>0 + + + if (present(eps)) then + epsp=eps + else + epsp=epspullback + endif + + ! First a few sanity checks and estimates + +1 format (9(A)) + if (lmode>lmax0) then + print 1,'Warning in gyroproj: lmode is larger than lmax0. ',& + 'Projection will work, but result does not at all represent the original.' + end if + + if (mmode>lmode .or. mmode<1 .or. lmode<1) then +2 format (A,30(I3)) + print 2,'Illegal combination of lmode,mmode:',lmode,mmode + stop + end if + + mpullback=est_mpullback(krho*xmax,eps=eps**2) + if (verbose>0) print 2,'mpullback must be >=',mpullback + !mpullback is what the plane wave expansion requires in terms of m and l. + !for gyroprojection we only need m=mmode, but l=mmode ... mpullback+1 + !from the plane wave expansion. + + if (mpullback+1=|l-lp|+mod(lp,2) + ! lo>=mod(m+l,2) due to parity + ! m<=lp<=mpullback + ! ==> lo<=l+mpullback-mod(mpullback,2) and that is sharp if m<=mpullback. + ! >>> incomplete discussion <<< needs to be corrected/refined later. + + + ! The parity of the output mode (lo,0) is mod(lo,2) and must be the same as the one + ! of the input mode, mod(l+m,2) since the plane wave is even. + + ! The product of lmode,mmode and lplanewave,mmode, lplanewave<=mpullback+1, and + ! mod(lplanewave+mmode,2)=0 since the plane wave has even parity, has parity + ! mod(lmode+mmode+lplanewave+mmode,2)=mod(lmode+lplanewave,2)=mod(lmode+mmode,2). + ! The minimum l index is potentially abs(lmode-lplanewave)+1, but only if it has the + ! same parity as (lmode,mmode), i.e., if mod(abs(lmode-lplanewave)+lmode+mmode,2)=0. + ! <=> mod(lplanewave+mmode,2)=0. + ! That means only l indices (lphys+1) from + ! abs(lmode-lplanewave+mod(lplanewave+mmode,2))+1 + ! to (lmode+lplanewave-mod(lplanewave+mmode,2)-1) + ! in steps of 2 can result in fout. + + ! So the maximum l index at all, that could result is: + lmax=lmode+mpullback + ! The minimum l index at all is max(0,lmode-lplanewave+1) + if (verbose>0) print 2,'Minimum physical L after projection is',max(0,lmode-mpullback) + if (lmax0>lmax) then +3 format (A,20(I3,A)) + print 3,'warning gyroproj: lmax0=',lmax0,'>lmax=',lmax,'=lmode(',lmode,& + ')+mpullback(',mpullback,')' + print 3,'=> the coefficients from lmax+1 .. lmax0 will be < epspullback. Reduce lmax0.' + end if + !the maximum m for projassleg is actually mmode+mpullback and not lmax. + !The parity of the mode is mod(lmode+mmode,2) (0=even 1=odd) + !The parity of a mode in the plane wave expansion is + ! make lmax an even number + if (mod(lmax,2)==1) then + mpullback=mpullback+1 + lmax=lmode+mpullback + print 2,'Corrected mpullback to make lmax even mp.=',mpullback + end if + print 3,'Using lmax=',lmax,'. (lmode=',lmode,'lmax0=',lmax0,')' + + extradegree=est_extradegree(abs(krho)*xmax,eps=eps) + + nmaxpoly=nmax0+extradegree + print 3,'Need extradegree',extradegree,'-> max. polynomial degree=',nmaxpoly-1 + + if (nmaxpoly>nsteen) then + print 3,'Error in gyroproj: Max. polynomial degree in projsteen/sp='& + ,nsteen-1,', but need',nmaxpoly-1 + stop + end if + + + ng2=max(lmax/2,(lmax0+1)/2) + allocate(gwl(ng2*2),gpl(ng2*2)) + call gauss_legendre(-1.,1.,gpl,gwl,ng2*2) + ! If lmax is even, we need only half of the vertices. + !Therefore often only half sums have to be calculated. + ! And we assume lmax to be even. + allocate(projleg(ng2,lmax0)) ! Convert from lmax0-L-space to lmax-xi-space + call calc_projasslegm(projleg,ng2,lmax0,1,gpl,gwl) + if (verbose>4) then + allocate(pltest(ng2,lmax0)) + call calc_projleg(pltest,ng2,lmax0,gpl,gwl) + print 2,'Max deviation of projleg,pltest:',maxval(abs(projleg-pltest)) + end if + + allocate(projasslegm(ng2,lmax-mmode+1)) + call calc_projasslegm(projasslegm,ng2,lmax,mmode,gpl,gwl) + + if (verbose>4) then + allocate(paltest(ng2,lmax/2,2,mmode)) ! need actually only one Pml for mmode and lmode. + ! call calc_projassleg(paltest,lmax/2,(lmode+1)/2,mmode,gpl,gwl) + + call calc_projassleg(paltest,ng2,lmax/2,mmode,gpl,gwl) + print 5,'Comparison of new projasslegm with old projassleg:' + ngs=max(1,ng2-4) + do l=mmode,lmax +5 format (A,I3,A,G25.16) + print 5,'l=',l,'projasslegm(ngs:ng2,l)=',projasslegm(ngs:ng2,l-mmode+1) + print 5,'l=',l,' paltest(ngs:ng2,l)=',paltest(ngs:ng2,(l+1)/2,mod(l+mmode,2)+1,mmode) + print 5,'l=',l,' delta(ngs:ng2,l)=',paltest(ngs:ng2,(l+1)/2,mod(l+mmode,2)+1,mmode)& + -projasslegm(ngs:ng2,l-mmode+1) + end do + end if + + allocate(beskl(nsteen,ng2)) + allocate(steen0_theta_space(nmax0,ng2)) + allocate(v_theta_space(nsteen,ng2)) + + + val=0 + if (verbose>4) then + q=0;o=20 ! for error messages + end if + if (timing) then + tbes=0; t=0; cost=0 + call cpu_time(tto) + end if + mphys=mmode-1 !m is mphys here. + + if (timing) call cpu_time(t1) + if (verbose>4) beskl=1e300 + do l2=1,ng2 + beskl(:,l2)=bessel_jn(mphys,krho*sp*sqrt(1-gpl(l2)**2)) + ! The plane wave exp(iky)=sum_(m in Z) bessel_jn(m,k|r|)exp(im phi) + ! r=(x,y) + ! kx*rho_x=-kx*mv_y/qB for B=Bz positive. + ! i.e. + ! exp(i kx rho_x)=exp(-i kx*m/(qB) vy) =sum_m bessel_jn(m,-krho |v|) exp(imphi) + ! call kx*m/(qB)=krho. + ! multiplication of real space distribution function with exp(ikx*rhox) + ! gives the gyrocenter distribution function. (Both Fourier transformed) + ! Thereafter we determine the l,m=0 components == gyro averaging. + ! We take the -mphys component of this expansion to get a non-zero contribution + ! from mphys=(mmode-1) + ! Bessel_jn(-m,-krho |v|) exp(-imphi)=Bessel_jn(m,krho|v|) exp(-imphi) + ! Note bessel_jn(-m)=bessel_jn(m)*(-1)^m + ! Bessel_jn(m,-x)=(-1)^m Bessel_Jn(m,x)=Bessel_jn(-m,x) + ! must use -m, but this gives just a (-1)^m sign. + ! don't like sqrt(1-gpl(l)**2) for sin theta. Should use something more accurate. ??? + enddo + ! print 5,'m=',m,'sumbeskl',sum(beskla(:,1:ng2)) + if (timing) then + call cpu_time(t2) + tbes=tbes+(t2-t1) + end if + j=lmode + oe=mod(lmode+mmode,2)+1 !oe=1: even in z oe=2: odd in z + lminb=0 + lminbval=0 + !m=mphys l=lphys+1 here + !l>=m+1, l<=lmax and oe+m+l is even. + !==> l>=m+oe. since lmax is even l<=lmax-mod(oe+m,2) + !the correct arguments are projassleg(,(l+1)/2,oe,m+1) + !==> (l+1)/2 >=(m+oe+1)/2 (l+1)/2<=(lmax-mod(oe+m,2)+1)/2=ng2 +(1-mod(oe+m,2))/2=ng2 +!!$ do l2=(m+oe+1)/2,ng2 !n_elements=ng2-(m+oe+1)/2+1=(lmax+2-m-oe)/2 +!!$ lbval=sum(beskla(nmaxpoly,:)*projleg(:ng2,j)& +!!$ *projassleg(:,l2,oe,m+1)) +!!$ !if (m==1 .and. j==30) print 2,'m,j,l,lbval',m,j,l,lbval +!!$ if (abs(lbval)>epsp) then +!!$ lminb=l2*2+mod(oe+m,2)-1 +1 +!!$ lminbval=lbval +!!$ end if +!!$ end do +!!$ print 2,'m',m,'j',j,'lminb',lminb,'lminbval',lminbval + !^^ can use this boundary value as estimate of max l needed. + ! most conservative value for m=0. + ! can also reduce lmax by that. But will not be greatly different from lmax. + + iloop: do i=1,nmax0 + if (timing) call cpu_time(t1) + do l2=1,ng2 + do k=1,nsteen + v_theta_space(k,l2)=beskl(k,l2)*projsteen(i,k)*projasslegm(l2,lmode-mmode+1) + ! Now we are at RMS=1/sqrt(2) due to the normalisation of projasslegm. + !write down mode ampl*plane wave with -m. + ! Note: sum_i=-infty,+infty bessel_jn(i,x)^2 = 1 for any x. + enddo + enddo + if (timing) then + call cpu_time(t2) + t(1)=t(1)+(t2-t1) + cost(1)=cost(1)+nsteen*ng2 + !cost=lmax*n maybe ng2*n + end if + if (verbose>4) steen0_theta_space=1e300 + if (timing) call cpu_time(t1) + call dgemm('n','n',nmax0,ng2,nsteen,1.,projsteen,nsteen,v_theta_space,nsteen,& + 0.,steen0_theta_space,nmax0) + ! angular RMS unchanged, just transform into orthonormal radial polynomials. + if (timing) then + call cpu_time(t2) + t(7)=t(7)+(t2-t1) + cost(7)=cost(7)+nsteen*ng2*nmax0 + end if + if (verbose>4) then + fout(:,3-oe::2,i)=1e100 ! these are actually zero due to parity and should not be needed later. + fout(:,oe::2,i)=1e300 + end if + if (timing) call cpu_time(t1) + !projleg delivers 1<=l<=lmax0. thereby oe=1: 1,3,... oe=2: 2,4,... max(l)=lmax0-mod(oe+lmax0,2) + ! n(l)=(max(l)-oe)/2+1=(lmax0-mod(oe+lmax0,2)-oe+2)/2=(lmax0-oe-mod(lmax0-oe,2)+2)/2=(lmax0-oe+2)/2 correct. + if (lmax0>=oe) call dgemm('n','n',nmax0,(lmax0-oe)/2+1,ng2,2.,steen0_theta_space,nmax0,projleg(1& + ,oe),ng2*2,0.,fout(1,oe,i),nmax0*2) + ! Now we have integrated over the domain [0,1] with a function of RMS=1/sqrt(2). + ! i.e. ==> with the RMS=1/sqrt(2.) before we are now in principle at 1/2 and must + ! multiply 2 back. + ! In other words: multiply a factor of 2 because we have exactly one legendre/ass.-legendre projection. + if (timing) then + call cpu_time(t2) + t(8)=t(8)+(t2-t1) + cost(8)=cost(8)+ng2*nmax0*((lmax0-oe)/2+1) + end if + enddo iloop + if (timing) then + call cpu_time(t2) + tto=t2-tto + print '(A,ES9.2)','tbes:',tbes + cost(9)=1 + do i=1,11 + if (t(i)>0 .and. cost(i)>0) & + print "(I2,9(' ',A,ES9.2))",i,'t(i):',t(i),'cost(i):',cost(i),'t(i)/cost(i):',& + t(i)/cost(i),'flops/cycle(i):',2*cost(i)/(t(i)*3.9d9) ! for I7-3770 + end do + print '(A,2ES9.2)','tot',tto,tbes+sum(t) + end if + + end subroutine gyroproj + + subroutine gen_polys(polys,names,unitsenergy,npolys,emat,projsteen,sp,a1,b1,c1,xmax,krho,& + nsteen,nmax0,lmax0,eps) + ! generate unit source terms for standard thermondyn quantities and their energies + ! useful for test programs that calculate the standard fluid transport coefficients. + use landau, only: vunit,intnorm + implicit none + real, dimension(:,:,:), allocatable :: polys + character(12),dimension(:), allocatable :: names + real, dimension(:), allocatable :: unitsenergy + integer npolys,nsteen,nmax0,lmax0 + real :: projsteen(nsteen,nsteen),emat(:,:) + real,dimension(nsteen) :: sp,a1,b1,c1 + real xmax,krho,eps + intent (out) :: polys,names,unitsenergy,npolys + intent (in) :: emat,projsteen,sp,a1,b1,c1,xmax,krho,nsteen,nmax0,lmax0,eps + optional :: eps + + real, dimension(:,:,:,:,:), allocatable :: fout + real, dimension(:), allocatable :: den,dens,en,temp,temps,mom,moms,enfl,hfl,hfls,& + pre,pxx,pxxs,pzz,pzzs,pxx_yy,pxx_yys,pyz,pyzs + real densener,tempsener,momsener,hflsener,pzzsener,pxxsener,pxx_yysener,pyzsener + real v,w + integer l,m + + if (nmax0<4) then + print '(A)','gen_pols: nmax0 must be >=4, otherwise the heat flux cannot be represented.' + stop + end if + allocate(fout(nmax0,lmax0,nmax0,3,3)) + do l=1,3 + do m=1,l + if (l==5 .and. m==3) then + call gyroproj(fout(:,:,:,l,m),nmax0,lmax0,l,m,projsteen,sp,nsteen,xmax,krho,eps)!,verbose) + else + call gyroproj(fout(:,:,:,l,m),nmax0,lmax0,l,m,projsteen,sp,nsteen,xmax,krho,eps) + end if + end do + end do + allocate(den(nmax0),dens(nmax0),temp(nmax0),temps(nmax0),en(nmax0),mom(nmax0),moms(nmax0)) + allocate(enfl(nmax0),hfl(nmax0),hfls(nmax0)) + allocate(pre(nmax0),pzz(nmax0),pxx_yy(nmax0),pyz(nmax0),pzzs(nmax0),pxx_yys(nmax0),pyzs(nmax0)) + ! P(n)=(c1(n)*x-a1(n))*P(n-1)-b1(n)*P(n-2) + ! c1(n)x*P(n-1)=P(n)+a1(n)*P(n-1)+b1(n)*P(n-2) + ! c1(n+1)x*P(n)=P(n+1)+a1(n+1)*P(n)+b1(n+1)*P(n-1) + ! x*P(n)=(P(n+1)+a1(n+1)*P(n)+b1(n+1)*P(n-1))/c1(n+1) + ! the 3 first v powers: + den=0 + den(1)=1/c1(1) + mom=0 + mom(1:2)=[a1(2),1.]*den(1)/c1(2) + mom=mom*vunit + en=0 + en(2:3)=mom(1:2)/c1(2:3) + en(1:2)=en(1:2)+mom(1:2)*a1(2:3)/c1(2:3) + en(1)=en(1)+mom(2)*b1(3)/c1(3) + en=.5*en*vunit + enfl=0 + enfl(2:4)=en(1:3)/c1(2:4) + enfl(1:3)=enfl(1:3)+en(1:3)*a1(2:4)/c1(2:4) + enfl(1:2)=enfl(1:2)+en(2:3)*b1(3:4)/c1(3:4) + enfl=enfl*vunit + + densener=1/(den(1)*emat(1,1)*den(1)*intnorm) + dens=den*densener ! -> now =1. sqrt(m_ref)*Tref^1.5/[ sqrt(ma)*Ta^1.5 ] = 1/(mua*Ta**2) + mua1=1. + mub1=1. + nb1=1. + Za1=1. + Zb1=1. + Ta1=1. + Tb1=1. + if (present(Ta)) Ta1=Ta + if (present(Tb)) Tb1=Tb + if (present(Za)) Za1=Za + if (present(Zb)) Zb1=Zb + if (present(nb)) nb1=nb + if (present(mua)) mua1=mua + if (present(mub)) mub1=mub + tau_ab_inv=sqrt(8./pi1)/3*za1**2*zb1**2*nb1/(mua1*Ta1**2)*& + (1+mua1**2*Ta1/(mub1**2*Tb1))/(1+mua1**2/(mub1**2))**1.5 + end function tau_ab_inv + + subroutine gentestkernel(n,a1,b1,c1,xmax,beta,gp,gw,ngauss,lor_int,dif_int,addcutoff,t1t2_int) + implicit none + integer, intent(in) :: n,ngauss + logical, intent(in) :: addcutoff + real, intent(in) :: a1(n),b1(n),c1(n),& !poly rec-coeffis + gp(ngauss),gw(ngauss),& ! gauss points and weights ngauss> n + xmax,beta !integration range and relative factor in exponential + real, dimension(n,n), intent(out) :: lor_int,dif_int,t1t2_int + optional :: t1t2_int ! only calculate that term if it is present. + optional :: addcutoff + !allocate(lor_int(n,n),dif_int(n,n)) + real p0,p1,pi,q0,q1,qi,r0,r1,ri,s0,s1,si,x,x1,xmax1 + real f1,f2 + integer i,j,k +#ifndef __PGI + real(16) fct1,fct2,fct1lo,fct1hi,fct2lo,fct2hi !inline functions + real(16) w,xmaxx +#else + real fct1,fct2,fct1lo,fct1hi,fct2lo,fct2hi !inline functions + real w,xmaxx +#endif + logical t1t2,addcutoff1 + real t1,t2 ! for timing +#ifndef __PGI + fct1(w)=.125_16*w**(-3)*(exp(-w*w)*w+(2*w*w-1)*.5_16*sqrt(pi1)*erf(w)) + fct2(w)=.25_16*w**(-1)*(.5_16*sqrt(pi1)*erf(w)-w*exp(-w**2)) + fct2hi(w)=-w**(-1)*((1._16/12)*xmaxx*exp(-xmaxx**2)*(3+2*xmaxx**2)-(sqrt(pi1)/8)*erf(xmaxx)) +#else + fct1(w)=.125*w**(-3)*(exp(-w*w)*w+(2*w*w-1)*.5*sqrt(pi1)*erf(w)) + fct2(w)=.25*w**(-1)*(.5*sqrt(pi1)*erf(w)-w*exp(-w**2)) + fct2hi(w)=-w**(-1)*((1./12)*xmaxx*exp(-xmaxx**2)*(3+2*xmaxx**2)-(sqrt(pi1)/8)*erf(xmaxx)) +#endif + fct1lo(w)=fct1(w)-exp(-xmaxx**2)/6 ! for w2) then + print 2,'1,lo,hi',fct1lo(xmaxx),fct1hi(xmaxx),fct1(xmaxx) + print 2,'2,lo,hi',fct2lo(xmaxx),fct2hi(xmaxx),fct2(xmaxx) + end if +#endif + ! lor_int and dif_int are symmetric in i,j + ! t1t2_int is not symmetric (but not antisymmetric.) + ! The first index is in that case the output index + + ! regarding all the signs of the collision operator. + ! we view it as being negative signed, because on the right hand side it + ! reduces the dist.fct + ! the Matrix element is thus + ! -int g1 g2 (1-uhat uhat)/u (grad phi-grad psi)^2 dv1^3 dv2^3 + ! The fieldop=intkernel+deltaintegral should therefore be + ! +2* int g1g2 grad phi grad psi (1-uhat uhat)/u dv1 dv2 + ! (1-uhat uhat)/u is positive and corresponds therefore + ! - nabla nabla /laplace^2. + ! I.e. the fieldop is + ! -2* int g1 grad phi nabla nabla/lap^2 g2 grad psi dv1 + ! I.e. the fieldop is then + ! +2* int phi nabla g1 nabla nabla/lap^2 g2 nabla psi dv1 + ! This integral contains a positive deltaintegral, if the nablas are + ! commuted towards the laplacian. + ! i.e., intkernel calculates the *negativ* other part. + + ! But what should be the true normalisation? + ! When the scattering partner has a more compact distribution function + ! as indicated by an increase in beta, that means it is becoming more + ! massive. The deflection rate of the lighter particle is hardly affected + ! by this. The diffusion rate is however. + ! fct1(w) is for large w proportional to 1/w. I.e. the overall + ! normalisation should be proportional beta. + ! fct2(w) is for large w proportional to 1/w as well. But diffusion should + ! be proportional to 1/beta., so one beta less. + ! Now if we look at the deflection rate for ions off electrons it should + ! decrease for decreasing beta. And it does. But see, we have altered time. + ! if we hold the ion speed fixed, and change the electron mass, the + ! electrons become relatively faster by beta. They carry out more + ! collisions and so on. So there is the additional factor beta. + ! for intkernel it's the same. First you've got to add the beta**3 instead + ! of the beta and then add the time shifting. Maybe one should look at the + ! electrons as basis, or we can look at the middle ground, the geometrical + ! mean of electron and ion speed. + + ! Now the test Operator for phi is + ! + int g1 (grad phi)^2 nabla nabla/lap^2 g2 dv1 + ! This is very roughly + ! int g1 (grad phi)^2 1/lap g2 dv1, which is dominantly negative. + ! howver lor_int and dif_int in the following are dominantly positive. + ! i.e. we take their negatives. + ! for a scattering of a single species, we have to take also two times + ! this test op. If scatter two species, take the two contributions. + + ! calculate test operator matrix elements + ! concretely we calculate the two integrals + ! lor_int=int_0...xmax exp(-x**2) l(l+1)p^2*fct1(v*beta)*beta^-2 dv + ! and + ! dif_int=int_0...xmax exp(-x**2) (p')^2 *fct2(v*beta)*beta^-3 dv + ! where fct1(w)=-1/w ddw 1/lap_w^2 exp(-w^2) + ! = 1/(8w^3)(exp(-w^2) w-(1-2w^2) I(w)) + ! and fct2(w)=-w^2 d2dw2 1/lap_w^2 exp(-w^2)= + ! =1/(4w)(-w exp(-w^2)+I(w)) + ! with I(w)=int_0^w exp(-x^2)dx=sqrt(pi)/2 erf(x) + ! fct1=nulor*v^2 ; fct2=nudif + !fct1(w)=.125*w**(-3)*(exp(-w**2)*w+(2*w**2-1)*.5*sqrt(pi1)*erf(w)) + !fct2(w)=.25*w**(-1)*(.5*sqrt(pi1)*erf(w)-w*exp(-w**2)) + ! ** problem: fct1 and fct2 suffer terrible cancellation near w=0. + ! this reduces accuracy dramatically. + ! can improve with series expansion. + ! we calculate for the moment separately the two integrals. + ! w== x1 + ! v==x + ! pi=phi + ! qi=phi' + + call cpu_time(t1) + lor_int=0 + dif_int=0 + if (t1t2) t1t2_int=0 + if (addcutoff1 .and. beta>1) then + xmax1=xmax/beta + else + xmax1=xmax + end if + do k=1,ngauss + x=gp(k)*xmax1 + x1=x*beta +#ifndef __PGI + if (addcutoff1) then + f1=fct1lo(real(x1,16)) + f2=fct2lo(real(x1,16)) + else + f1=fct1(real(x1,16)) + f2=fct2(real(x1,16)) + endif +#else + if (addcutoff1) then + f1=fct1lo(x1) + f2=fct2lo(x1) + else + f1=fct1(x1) + f2=fct2(x1) + endif +#endif + do j=1,n + if (j==1) then + q1=0 + qi=0 + p1=0 + pi=c1(1)*gw(k)*exp(-x**2)*xmax1 + else + q0=qi + qi=c1(j)*pi+(c1(j)*x-a1(j))*qi-b1(j)*q1 + q1=q0 + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + endif + i=1 + r1=0 + ri=c1(1) + s1=0 + si=0 + lor_int(j,i)=lor_int(j,i)+pi*ri*f1 + if (t1t2) t1t2_int(j,i)=t1t2_int(j,i)+2*qi*ri*x1*f2 + ! ^^ vgl 1.8.19 (2) + do i=2,n + s0=si + si=c1(i)*ri+(c1(i)*x-a1(i))*si-b1(i)*s1 + s1=s0 + r0=ri + ri=(c1(i)*x-a1(i))*ri-b1(i)*r1 + r1=r0 + lor_int(j,i)=lor_int(j,i)+pi*ri*f1 + dif_int(j,i)=dif_int(j,i)+qi*si*f2 + if (t1t2) t1t2_int(j,i)=t1t2_int(j,i)+2*qi*ri*x1*f2 + enddo + enddo + enddo + if (addcutoff1 .and. beta>1) then + do k=1,ngauss + x1=xmax*(1+(beta-1)*gp(k)) + x=x1/beta +#ifndef __PGI + f1=fct1hi(real(x1,16)) + f2=fct2hi(real(x1,16)) +#else + f1=fct1hi(x1) + f2=fct2hi(x1) +#endif + + do j=1,n + if (j==1) then + q1=0 + qi=0 + p1=0 + pi=c1(1)*gw(k)*exp(-x**2)*xmax*(1-1/beta) + else + q0=qi + qi=c1(j)*pi+(c1(j)*x-a1(j))*qi-b1(j)*q1 + q1=q0 + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + endif + i=1 + r1=0 + ri=c1(1) + s1=0 + si=0 + lor_int(j,i)=lor_int(j,i)+pi*ri*f1 + if (t1t2) t1t2_int(j,i)=t1t2_int(j,i)+2*qi*ri*x1*f2 + ! ^^ vgl 1.8.19 (2) + do i=2,n + s0=si + si=c1(i)*ri+(c1(i)*x-a1(i))*si-b1(i)*s1 + s1=s0 + r0=ri + ri=(c1(i)*x-a1(i))*ri-b1(i)*r1 + r1=r0 + lor_int(j,i)=lor_int(j,i)+pi*ri*f1 + dif_int(j,i)=dif_int(j,i)+qi*si*f2 + if (t1t2) t1t2_int(j,i)=t1t2_int(j,i)+2*qi*ri*x1*f2 + enddo + enddo + enddo + end if + + !1/v ddv 1/lap_v^2 exp(-beta**2 x**2) *beta = beta**-2 fct1(beta*x) *beta + ! = beta**-1 1/lap_w exp(-w^2) + !w=beta*v, lap_w=beta**-2 *lap_v + !1/v ddv 1/lap_v^2 propto v^2 =beta**-2 w^2 propto 1/w ddw 1/lap_w^2 + ! or other way: + ! large v,w : 1/v ddv 1/lap_v^2 exp(-beta**2 x**2) propto 1/v 1/beta**3 + ! 1/lap_w exp(-w^2) propto 1/w ==> 1/v 1/beta^3 / (1/w) = 1/beta^2. + ! + ! v^2 ddv^2 1/lap_v^2 exp(-beta**2 x**2) *beta= beta**2/w^2 beta**-2 /lap_w + ! exp(-w) *beta = + ! v^2 ddv^2 1/lap_v^2 propto v^4 = beta**-4 w^4 propto .. + ! =beta/w^2 /lap_w exp(-w^2) + !may need to split the integral into a part up to xmax/beta + ! and one up to xmax for large beta, due to singular behavior. + lor_int=lor_int*beta**(-1) ! ***<--- must be multiplied with lphys(lphys+1) + ! this is the only l dependence. + dif_int=dif_int*beta**(-3) + !*** Note: we have rescaled the above with beta, to account for the + ! changing norm of g2=exp(-beta**2 v2**2) + ! i.e. we multiply with beta!! + if (t1t2) t1t2_int=t1t2_int*beta**(-4) ! ***<--- must be multiplied with (Ta/Tb-1) + call cpu_time(t2) + + if (verbose>0) print '(A,G13.3)','gentestkernel took ',t2-t1 + end subroutine gentestkernel + + subroutine genintkernel(n,lmax,a1,b1,c1,xmax,beta,t1t2ratio,gp,gw,ngauss,gp2,gw2,ng2,addcutoff,intkernel,intlokernel) + implicit none + optional :: intlokernel + logical,intent(in) :: addcutoff + integer, intent(in) :: n,lmax,ngauss,ng2 ! lmax=max l-**index**, lphys=l-1 + real, intent(in) :: a1(n),b1(n),c1(n),& !poly rec-coeffis + gp(ngauss),gw(ngauss),& ! gauss points and weights ngauss> n + gp2(ng2),gw2(ng2),& ! gauss points and weights for small kernel ng2~8 + xmax,beta,t1t2ratio !integration range and relative factor in exponential + real, dimension(n,n,lmax), intent(out) :: intkernel(n,n,lmax),intlokernel(n,n,lmax) !intlokernel only used if t1t2ratio/=1 + real, parameter :: epsmax=1e-17 !epsmax is for cutoff of b1integral + real, dimension(:,:), allocatable :: b1integral + real, dimension(:,:,:), allocatable :: v2integral + real, dimension(:,:,:,:), allocatable :: delta35integral,delta35cutoff + real, dimension(:), allocatable :: pimax ! only needed for addcutoff + real mymin,mymax,v1max,v2max,x,p0,p1,pi + real val,val1,val2 + real s12,s22 + real t1,t2 !for timing + integer i,j,k,k1,l,lphys,m1,m2 + if (n==0 .or. lmax==0) return + call cpu_time(t1) + ! This routine calculates the main part of the field operator for the Background distribution functions + ! g1=exp(-x^2) and g2=exp(-x^2*beta^2)*beta + ! To get the integral for g1=exp(-x^2*alpha^2)*alpha and g2=exp(-x^2*beta^2)*beta with polynomials Pi(x*alpha) ,Pj(x*beta) + ! one can use the fact that multiplication of all the velocity arguments with a factor f causes a change in the + ! integral by a factor f^-3*f^2=1/f. + ! Therefore fcode(alpha,beta)=fcode(1,beta/alpha)/alpha=f(alpha/beta,1)/beta. + ! So fij(1,lambda)=fji(1,1/lambda)/lambda. + ! Otherwise the actual field operator is + ! Fij=-cab*32/pi *Fcode_complete (1,beta/alpha)/(beta^1.5*mu^2.5) ; alpha=sqrt(ma) beta=sqrt(mb) + ! The same normalisation applies to the Testoperator. + ! Fij_code_complete(1,lambda)=Fij_c(1,lambda)+Fji_c(1,1/lambda) + + ! Ok, now for m1, m2 and one p_i and one p_j and one beta calculate + ! #=int v1=0..xmax v2=0..xmax p_i(v1) p_j(v2) exp(-v1**2 -v2**2) v1^m1 v2^m2 theta(beta*v1-v2) dv1 dv2. + ! for this to be valid, m2>0, and m1+m2>-2. But we have assurance that m1+m2>=3 + + ! In the following this is rescaled with a prefactor. to determine it, let + ! us use w2=v2/beta v2=w2*beta as integration variable. We obtain for #: + ! #=int v1=0^xmax w2=0^xmax/beta p_i(v1) p_j(w2 beta ) * + ! *exp(-v1**2 -beta**2 w2**2) * v1^m1 w2^m2 beta^m2 * + ! *theta(v1-w2) dv1 dw2 *beta + ! ***Important: We rescale this with the factor beta^(-m2) . Then we get + ! something similar to the quantities in NEO + ! #rescaled = + ! int v1=0..xmax v2=0..xmax p_i(v1) p_j(v2) exp(-v1**2 -v2**2) v1^m1 v2^m2 beta^-m2 theta(beta*v1-v2) dv1 dv2 + + ! compare the following with the expression in deltaintegrate. + ! intkernel_rescaled(i,j,beta)= + ! =int v1=0^xmax w2=0^xmax/beta p_i(v1) p_j(w2 beta ) * + ! *exp(-v1**2 -beta**2 w2**2) * v1^m1 w2^m2 * theta(v1-w2) dv1 dw2 beta + ! This is for i=1,j=1 equal to jeffs integral F(beta^2,m1,m2)*beta + + ! In the end delta35integral(j,i,idx,l)= + ! int v1=0^xmax v2=0^xmax p_i(v1) p_j(v2) exp(-v1**2 -v2**2) v1^m1 (v2/beta)^m2 theta(beta*v1-v2) dv1 dv2 + ! with m1=1-l m2=l+2 for idx=1 and m2=l+4 for idx=2 (l: physical l = idx_l-1) + ! + ! To get the other half by a call to this routine with 1/beta: + ! 2-half rescaled=int v1=0^xmax w2=0^xmax/beta p_i(v1) p_j(w2 beta ) * + ! *exp(-v1**2 -beta**2 w2**2) * v1^m2 w2^m1 * theta(w2-v1) dv1 dw2 *beta + ! again with m2>0 and m1 maybe <0 + ! we reintroduce v2=w2*beta and replace v1=w1/beta <-> w1=v1*beta + ! 2-half resc=int w1=0^xmax*beta w2=0^xmax p_i(w1/beta) p_j(v2) * + ! * exp(-v1**2 beta**-2 -v2**2) * w1^m2/beta^m2 v2^m1/beta^m1 * + ! *theta(v2-w1) dw1/beta dv2/beta *beta + ! =int w1=0^xmax*beta w2=0^xmax p_i(w1/beta) p_j(v2) * + ! * exp(-v1**2 beta**-2 -v2**2) * w1^m2 v2^m1 * + ! *theta(v2-w1) dw1 dv2/ beta^(m1+m2+1) + ! =intkernel_rescaled(j,i,1/beta)/beta^(m1+m2) + ! Note m1+m2 is either 3 or 5 + ! Note however, that within the intkernel there is a factor 1/(s12*s22) propto + ! beta**2 for the terms with m1+m2=5 and 1/s12 =const or 1/s22 prop beta**2 + ! for m1+m2=3. + ! the factor 1/(s12*s22) flips from beta**2 to beta**-2 + ! ==> taking this into account we get + ! 2-half resc=intkernel_rescaled(j,i,1/beta)/beta^(5)*beta**4 + ! 2-half resc=intkernel_rescaled(j,i,1/beta)/beta + ! in addition + + + + ! beta>1 ==> split integral over v1 into + ! A= int dv1_0^xmax/beta dv2_0^xmax p_i(v1) p_j(v2) exp(-v1**2 -v2**2) v1^m1 v2^m2 theta(beta*v1-v2) dv1 dv2 + ! and B= int_xmax/beta..xmax p_i(v1) v1^m1*beta^-m2 exp(-v1**2) dx * int_0^xmax p_j(v2) v2^m2 exp(-v2**2) dx + ! in general the v1 integral in B is with m1<0 and needs to be cut off at (xmax/beta)*(1e16)^[1/(1-|m1|)] + ! then it contains only about 64 polynomials or so. + ! The 2nd part of the B-integral is trivial more or less, since we have + ! the steen vertices? Yes. + ! For the A integral we carry out the v2 integral for all v1 vertices, that we need for a nice Gauss rule. + ! beta<1 ==> can replace the v2-boundary xmax by beta*xmax, and need only + ! compute values of v2-integral for beta* the Gauss points of the v1-integral. + ! ***** in case beta<1 we rescale the v2 integral components with beta^(-m2) + ! for stepping between. + ! for each l=0...lmax, we need (m1,m2)=(1-l,l+4) (delta=5) + ! (m1,m2)=(1-l,l+2) (delta=3) + ! (m1,m2)=(3-l,l+2) (delta=5) (only for l>=2). + ! i.e. we need delta=3 and delta=5. + ! Leading coeffi for delta=3 m2>=2 for delta=5 m2>=4 ,i.e. + ! m1=1,0,-1,...-(lmax-1), i.e. lmax+1 values. Lmax=nxi-1 ==>nxi values. + ! m2=2..lmax+4 ==> lmax+3 values. + if (beta>1) then + !calculate first half of B-integrals for all n orthonormal polynomials + !*** we originally rescaled b1integral by beta**m1 + ! now we rescale by mymin**(-m1)=(xmax/beta)**(-m1)= + ! =(beta/xmax)**m1 to avoid overflow + allocate(b1integral(n,lmax+1)) + b1integral=0 + mymax=xmax + mymin=xmax/beta + do l=1,lmax+1 + m1=2-l + if (m1<-1) mymax=min(xmax,mymin*epsmax**(1./(m1+1))) + if (verbose>2) print '(I3,A,3I3)',l,'ngauss',ngauss,mymin,mymax + do k=1,ngauss + x=gp(k)*(mymax-mymin)+mymin + p1=0 + pi=c1(1)*(gw(k)*exp(-x**2)*(x/mymin)**m1)*(mymax-mymin) ! ** <--rescaling of v1 here + ! here all constant factors. + j=1 + b1integral(j,l)=b1integral(j,l)+pi + do j=2,n + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + b1integral(j,l)=b1integral(j,l)+pi + enddo + enddo + enddo +!!$2 format (*(G0," ")) +!!$ if (verbose>2) then +!!$ print 2,'Check b1integral:' +!!$ print 2,'n=1 (Pn=const)' +!!$ do l=1,lmax+1 +!!$ m1=2-l +!!$ val=c1(1)*.5*(gsl_sf_gamma_inc(.5*(1+m1),mymin**2)& +!!$ &-gsl_sf_gamma_inc(.5*(1+m1),xmax**2)) +!!$ if (beta>1) val=val*(beta/xmax)**m1 ! ** rescaling of v1 +!!$ print 2,'l=',l,'m1=',m1,b1integral(1,l),val,val/b1integral(1,l)-1 +!!$ enddo +!!$ print 2,'n=2 (Pn=const)' +!!$ do l=1,lmax+1 +!!$ m1=2-l +!!$ val1=c1(1)*.5*(gsl_sf_gamma_inc(.5*(1+m1),mymin**2)& +!!$ &-gsl_sf_gamma_inc(.5*(1+m1),xmax**2)) +!!$ val2=c1(2)*c1(1)*.5*(gsl_sf_gamma_inc(.5*(1+m1+1),mymin**2)& +!!$ &-gsl_sf_gamma_inc(.5*(1+m1+1),xmax**2)) +!!$ val=val2-a1(2)*val1 +!!$ if (beta>1) val=val*(beta/xmax)**m1 ! ** rescaling of v1 +!!$ print 2,'l=',l,'m1=',m1,b1integral(2,l),val,val/b1integral(2,l)-1 +!!$ enddo +!!$ endif + endif + !chacka! + ! now calculate all necessary v2 integrals for the gausspoints of v1 + ! we do this with a secondary gauss rule with lower point number in between + ! the v1 gausspoints. ng2 is relatively small, maybe 8 or so. hope this' + ! nuff. + ! The last igauss index is for the full v2max integral. + ! we rescale each v2integral(n,l,ig) by 1/(v2max*gp(ig))**m2 + ! = 1/(xmax*min(1,beta)*gp(ig))**m2 + ! instead of rescaling all at once by beta**-m2 if beta<0. + + allocate(v2integral(n,lmax+3,ngauss+1)) + v2integral=0 + v2max=xmax*min(1.,beta) + mymin=0. + do k=1,ngauss+1 + do l=1,lmax+3 + m2=l+1 + if (k<=ngauss) then + mymax=gp(k)*v2max + else + mymax=v2max + endif + ! Correctly scale down from the earlier gausspoint: + if (k>1) v2integral(:,l,k)=v2integral(:,l,k-1)*(mymin/mymax)**m2 + + do k1=1,ng2 + x=(mymax-mymin)*gp2(k1)+mymin + p1=0 + ! rescaling by mymax**(-m2)=1/(xmax*min(1,beta)*gp(ig))**m2 : + pi=c1(1)*(gw2(k1)*exp(-x**2)*(x/mymax)**m2)*(mymax-mymin) + + j=1 + v2integral(j,l,k)=v2integral(j,l,k)+pi + do j=2,n + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + v2integral(j,l,k)=v2integral(j,l,k)+pi + enddo + enddo + enddo + mymin=mymax + enddo + if (.true. .and. verbose>2) then + print '(A,G23.16)','Check complete v2integral up to v2=',v2max + do i=1,min(n,lmax+3) + l=i + m2=l+1 + val=0 + do k=1,ngauss + x=v2max*gp(k) + p1=0 + pi=c1(1)*(gw(k)*exp(-x**2)*(x/v2max)**m2)*v2max + j=1 + do j=2,i + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + enddo + val=val+pi + enddo + +4 format (A,2I3,5(G25.16)) + print 4,'v2int',i,l,v2integral(i,l,ngauss+1),val,v2integral(i,l,ngauss+1)/val-1,& + maxval(abs(v2integral(i,l,:)))/v2integral(i,l,ngauss+1) + ! agreement here perfect for beta=0.02 e.g. + ! agreement here less than perfect for n=50 beta=1. + ! even though the integral is *not* zero?? + ! well the integral somehow must be practically zero exactly for beta=1. + ! but not otherwise. + ! however this is probably ok because the results should be practically zero + ! because we have practical orthogonality of the higher polynomials + enddo + endif + ! Compare end result for beta>=1 + if (verbose>2 .and. beta >=1 .and. .false.) then + do l=1,lmax+3,2 + print '(G23.16)',v2max + m2=l+1 + do i=2,n,2 + val2=0 + do k=1,ngauss + x=v2max*gp(k) + p1=0 + pi=c1(1) + j=1 + do j=2,i + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + enddo + val2=val2+gw(k)*pi*exp(-x**2)*(x/v2max)**m2*v2max + enddo + + print 4,'v2compare',i,l,v2integral(i,l,ngauss+1),val2,v2integral(i,l& + &,ngauss+1)/val2-1 + !so for i>m2+1=l+3 this value should be zero. + !looks good. + enddo + enddo + endif + + !now calculate all the v1-integrals and later add the bintegrals. + allocate(delta35integral(n,n,2,lmax+1)) + delta35integral=0 + ! delta35integral(v2-index,v1-index,1 or 2,lindex) + !index 1 is with delta=3 and index 2 with delta=5 + v1max=xmax*min(1.,1./beta) ! in case beta>0 we must add later the missing + ! piece. + do k=1,ngauss + x=v1max*gp(k) + do l=1,lmax+1 + m1=2-l + m2=l+1 + p1=0 + ! we have rescaled v2integral(i,l,ig) by a factor + ! 1/(v2max*gp(ig))**m2, wereby m2=l+1 + ! = 1/(xmax*min(1,beta)*gp(ig))**m2 + ! note, that v2max= beta*v1max + ! now we must multiply each (among other things by + ! x**m1 = (v1max*gp(ig))**m1 + ! i.e. to cancel the scaling and to multiply at the same time + ! we multiply with (v1max*gp(ig))**m1*(v2max*gp(ig))**m2 + ! =(v1max*gp(ig))**(m1+m2) *beta**m2 + !*** now at this point we apply the scaling beta **-m2 + ! so we multiply only with + ! (v1max*gp(ig))**(m1+m2) + + pi=c1(1)*(gw(k)*exp(-x**2)*x**(m1+m2))*v1max !m1+m2=3 + + ! hmm we may get an overflow here for very small x. + ! for too many gausspoints. + ! of course this is then cancelled by the v2integral + ! but that in turn may have had an underflow. + ! so you want to rescale the v2integral by it's boundary + ! x. i.e. divide it by x**m2. + i=1 + delta35integral(:,i,1,l)=delta35integral(:,i,1,l)+pi*v2integral(:,l,k) + delta35integral(:,i,2,l)=delta35integral(:,i,2,l)+pi*v2integral(:,l+2,k)*x**2 ! rescaling since m2 is here +2. + do i=2,n + p0=pi + pi=(c1(i)*x-a1(i))*pi-b1(i)*p1 + p1=p0 + delta35integral(:,i,1,l)=delta35integral(:,i,1,l)+pi*v2integral(:,l,k) + delta35integral(:,i,2,l)=delta35integral(:,i,2,l)+pi*v2integral(:& + &,l+2,k)*x**2 ! rescaling since m2 is here +2. + enddo + enddo + enddo + + ! it seems that for high l there is massive cancellation between + ! hmm this cannot be the only problem for beta!=1. + ! for beta=1 everything is fine for all l. + ! b1integral and delta35integral. + !print 2,'!!!warning leaving out bintegral' + if (verbose>2 .and. beta>1) then + k=ngauss+1 + do l=1,n +5 format (A,I3,5(G25.16)) + print 5,'d35l',l,delta35integral(l,l,1,l),b1integral(l,l)& + &*v2integral(l,l,k)*v1max**3,delta35integral(l,l,1,l)+b1integral(l,l)& + &*v2integral(l,l,k)*v1max**3 + ! for testing, e.g. do a + !./hhv 5 10 0|grep d35l + !and + !./hhv 5 20 0|grep d35l + ! whereby the last column does not change, + ! but the first two do, because of different integral splits. + enddo + do l=1,n + print 5,'d35l',l,delta35integral(l,l,2,l),b1integral(l,l)& + &*v2integral(l,l+2,k)*v1max**5,delta35integral(l,l,2,l)+b1integral(l,l)& + &*v2integral(l,l+2,k)*v1max**5 + enddo + endif + if (beta>1) then + ! add back missing integral: + do l=1,lmax+1 + m1=2-l + m2=l+1 + do i=1,n + ! b1integral(i,l) has been rescaled by (beta/xmax)**m1 m1=2-l + ! we have rescaled v2integral(i,l,ig) by a factor + ! 1/(v2max*gp(ig))**m2 + ! = 1/(xmax*min(1,beta)*gp(ig))**m2, wereby m2=l+1 + ! note, that v2max= beta*v1max always + ! v2integral(i,l,ngauss+1) has been rescaled by 1/v2max**m2 + ! because that is the full integral. + ! since in this section beta>1 v2max=xmax, v1max=xmax/beta + ! in toto we have to rescale by (v1max)**m1*(v2max)**m2 + ! = v1xmax**(m1+m2) beta**(m2) + ! now at this point we apply the rescaling beta**-m2 + ! so we multiply only with v1max**(m1+m2) + delta35integral(:,i,1,l)=delta35integral(:,i,1,l)+b1integral(i,l)& + &*v2integral(:,l,ngauss+1)*v1max**(m1+m2) !m1+m2=3 + delta35integral(:,i,2,l)=delta35integral(:,i,2,l)+b1integral(i,l)& + &*v2integral(:,l+2,ngauss+1)*v1max**(m1+m2+2) !m1+m2+2=5 + enddo + enddo + endif + ! if (beta > 1) then !** need to correct scaling by beta**(-m1-m2) + !! because we rescaled the v1 component integrals above for this case. + !! for delta=3: -m1-m2= -3 for delta=5: -m1-m2=-5 + ! delta35integral(:,:,1,:)=delta35integral(:,:,1,:)*beta**(-3) + ! delta35integral(:,:,2,:)=delta35integral(:,:,2,:)*beta**(-5) + !endif + if (verbose>2) then + do l=1,lmax+1 + print 5,'lend',l,delta35integral(1,1,1,l),delta35integral(1,1,1,l)/c1(1)**2,& + delta35integral(1,1,2,l),delta35integral(1,1,2,l)/c1(1)**2 + enddo + endif + + if (addcutoff) then + ! adding Ia,Ib,Iab to delta35integral(:,:,2,:) + ! j=2...lmax+4 B(text)(max,j)=v2integral(:,j-1,ngauss+1) + ! j=-1,...lmax-1 AN(text)(j)=b1integral(:,j+2) + ! j=-1..lmax-1 I>(text)(j,j+3/5)=delta35integral(:,:,1/2,j+2) + allocate(pimax(n),delta35cutoff(n,n,3,lmax+1)) + pi=c1(1)*exp(-xmax**2) + pimax(1)=pi + p1=0 + do i=2,n + p0=pi + pi=(c1(i)*xmax-a1(i))*pi-b1(i)*p1 + p1=p0 + pimax(i)=pi + end do + do l=1,lmax+1 + m1=l-2 + m2=m1+5 !l+3 + do i=1,n + do j=1,n + !delta35integral(j,i,2,l)=I>(l-2,l+3) for Pi-1,Pj-1 + !v2integral(j,l+2,ngauss+1)=B(v1max,l+3) for Pj-1 + !b1integral(i,l)=AN(l-2) + !==> + !I>a(l-2,l+3)=B(v1max,l+3)xmax^(l+3-(l-2)-1) psia + ! = .... xmax^(5-1) psia + !I>b(l-2,l+3)=An(l-2)v1max^(5-1)phib + !I>ab(l-2,l+3)=psia phib*(1/beta)^(l+3-1)*xmax^(5-2) + !mua=1/2 + delta35cutoff(j,i,1,l)=& + v2integral(j,l+2,ngauss+1)*pimax(i)*xmax**(5-1)*(v1max/xmax)**(l+3) + !pimax(j)=psia(xmax) + !I>a=B(max,m2)vamax^(m2-m1-1) psia(xmax) + if (beta>1) then + !phia(xmax/beta)=pimax(i) + !I>b=AN(m1)phia(xmax/beta)vbmax^(m2-m1-1) + !mub=1/(2beta) + delta35cutoff(j,i,2,l)=& + b1integral(i,l)*pimax(j)*v1max**(5-1)*beta + delta35cutoff(j,i,3,l)=pimax(i)*pimax(j)*beta**(-l-2)*xmax**(5-2)*beta + else + delta35cutoff(j,i,2,l)=0 + if (beta==1) then + delta35cutoff(j,i,3,l)=.5*pimax(i)*pimax(j)*beta**(-l-2)*xmax**(5-2)*beta + else + delta35cutoff(j,i,3,l)=0 + endif + endif + end do + end do + end do + end if + + ! now adding the three kernels together + ! note: in "lowerkernel in gl2check1.nb and in the writeups + ! we have used v1 s12 and s22 + ! are interchanged. + ! I.e. we calculate here the "hikernel" of gl2check1.nb + ! and: sigma1^2=.5, sigma2^2=.5/beta^2 + + ! this does of course not matter if beta=1. and t1=t2 + s12=.5 + s22=.5/beta**2 + !allocate(intkernel(n,n,lmax)) + do l=1,lmax + lphys=l-1 ! difference between index and actual l + intkernel(:,:,l)=-(lphys+1.)*(lphys+2)/(2*(1+2*lphys)*(3+& + &2*lphys)*s12*s22)*delta35integral(:,:,2,l) + if (lphys>=2) then + intkernel(:,:,l)=intkernel(:,:,l)+ 1./(1+2*lphys)* lphys*(lphys-1.)& + /(2*(2*lphys-1.)*s12*s22)* delta35integral(:,:,2,l-2) + endif + if (t1t2ratio/=1) then + intlokernel(:,:,l)=intkernel(:,:,l)*t1t2ratio+1./(1+2*lphys)*& + ((1+lphys)/(s12/t1t2ratio)-lphys/(s22))*delta35integral(:,:,1,l) + if (addcutoff) then + intlokernel(:,:,l)=intlokernel(:,:,l)-(lphys+1.)*(lphys+2)/(2*(1+2*lphys)*(3+& + &2*lphys))*(delta35cutoff(:,:,1,l)/s22& + +delta35cutoff(:,:,2,l)/s12*t1t2ratio& + +delta35cutoff(:,:,3,l)) + if (lphys>=2) then + intlokernel(:,:,l)=intlokernel(:,:,l)+ 1./(1+2*lphys)* lphys*(lphys-1.)& + /(2*(2*lphys-1.))*(delta35cutoff(:,:,1,l-2)/s22& + +delta35cutoff(:,:,2,l-2)/s12*t1t2ratio& + +delta35cutoff(:,:,3,l-2)) + end if + + do i=1,n + intlokernel(:,i,l)=intlokernel(:,i,l)+1./(1+2*lphys)*& + ((1+lphys)*v2integral(:,l,ngauss+1)*pimax(i)*xmax**(3-1)*(v1max/xmax)**(l+1)) + if (beta>1) & + intlokernel(:,i,l)=intlokernel(:,i,l)+1./(1+2*lphys)*(& + -lphys*b1integral(i,l)*pimax(:)*(v1max)**(3-1)) *beta + enddo + endif + endif + intkernel(:,:,l)=intkernel(:,:,l)/t1t2ratio+1./(1+2*lphys)*& + ((1+lphys)/(s12)-lphys/(s22*t1t2ratio))*delta35integral(:,:,1,l) + if (addcutoff) then + intkernel(:,:,l)=intkernel(:,:,l)-(lphys+1.)*(lphys+2)/(2*(1+2*lphys)*(3+& + &2*lphys))*(delta35cutoff(:,:,1,l)/(s22*t1t2ratio)& + +delta35cutoff(:,:,2,l)/s12& + +delta35cutoff(:,:,3,l)) + if (lphys>=2) then + intkernel(:,:,l)=intkernel(:,:,l)+ 1./(1+2*lphys)* lphys*(lphys-1.)& + /(2*(2*lphys-1.))*(delta35cutoff(:,:,1,l-2)/(s22*t1t2ratio)& + +delta35cutoff(:,:,2,l-2)/s12& + +delta35cutoff(:,:,3,l-2)) + end if + do i=1,n + intkernel(:,i,l)=intkernel(:,i,l)+1./(1+2*lphys)*& + ((1+lphys)*v2integral(:,l,ngauss+1)*pimax(i)*xmax**(3-1)*(v1max/xmax)**(l+1)) + if (beta>1) & + intkernel(:,i,l)=intkernel(:,i,l)+1./(1+2*lphys)*(& + -lphys*b1integral(i,l)*pimax(:)*(v1max)**(3-1)) *beta + enddo + endif + enddo + !search for near cancellations: + if (verbose>2) then + do l=1,lmax + lphys=l-1 + do i=1,n + do j=1,n + val=intkernel(i,j,l) + val1=-(lphys+1.)*(lphys+2)/(2*(1+2*lphys)*(3+& + &2*lphys)*s12*s22)*delta35integral(i,j,2,l) + val2=1./(1+2*lphys)*& + &((1+lphys)/s22-lphys/s12)*delta35integral(i,j,1,l) + if (abs(val)=2) then + print 4,'ik3',l,i,1./(1+2*lphys)*& + &lphys*(lphys-1.)/(2*(2*lphys-1.)*s12*s22)*& + &delta35integral(i,1:5,2,l-2) + endif + enddo + enddo + endif + !ts unfortunately, we have calculated the transposed version + ! not easy to turn around. + ! hence: + + do l=1,lmax +#ifdef DIMATCOPY +#ifdef __INTEL_COMPILER + !use MKL + call mkl_dimatcopy('c','t',n,n,1.,intkernel(:,:,l),n,n) + if (t1t2ratio/=1) call mkl_dimatcopy('c','t',n,n,1.,intlokernel(:,:,l),n,n) +#else + !use openBLAS + call dimatcopy('c','t',n,n,1.,intkernel(:,:,l),n,n) + if (t1t2ratio/=1) call dimatcopy('c','t',n,n,1.,intlokernel(:,:,l),n,n) +#endif +#else + !alternative to dimatcopy + do i=1,n + do j=1,i-1 + val=intkernel(i,j,l) + intkernel(i,j,l)=intkernel(j,i,l) + intkernel(j,i,l)=val + if (t1t2ratio/=1) then + val=intkernel(i,j,l) + intlokernel(i,j,l)=intlokernel(j,i,l) + intlokernel(j,i,l)=val + endif + enddo + enddo +#endif + enddo + !** rescale everything with beta**2, since we did not completely balance + !the shrinking of the integral of the exp(-beta**2 x**2) in **3d-space** + !(only 1d) + ! intkernel=intkernel*beta**2 + call cpu_time(t2) + if (verbose>0) print '(A,G13.3)','genintkernel took',t2-t1 + end subroutine genintkernel + + subroutine deltaintegrate(n,a1,b1,c1,xmax,beta,gp,gw,ngauss,deltaintegral) + ! ??? This should be recoded with Steen points not Gauleg points. + implicit none + integer, intent(in) :: n,ngauss + real, intent(in) :: a1(n),b1(n),c1(n),& !poly rec-coeffis + gp(ngauss),gw(ngauss),& ! gauss points and weights + xmax,beta !integration range and relative factor in exponential + real, intent(out) :: deltaintegral(n,n) + !allocate(deltaintegral(n,n)) + + real v2max,x,x1,p0,p1,pi,q0,q1,qi + integer i,j,k + real t1,t2 ! timing + ! Now for the last integral: (v2=w2*beta, w2=v2/beta) + ! deltaintegral(k,j,beta):= + ! int pk(v1) pj(w2*beta) exp(-v1**2-beta**2*w2**2) delta(v1-w2) v1**2 *beta dv1 dw2 + ! = int pk(v1) pj(v2) exp(-v1**2-v2**2) delta(v1-v2/beta) v1**2 dv1 dv2 + ! =int pk(v2/beta) pj(v2) exp(-(1+beta^-2) v2**2) v2**2 dv2 *beta**(-2) + ! v2 di(i,k,beta)=beta**3 di(k,i,1/beta) + v2max=xmax*min(1.,beta) ! same as already defined before + + call cpu_time(t1) + + deltaintegral=0 + do i=1,ngauss + x=gp(i)*v2max ! vertex for v2 + x1=x/beta ! vertex for v1==w2 + do j=1,n + if (j==1) then + p1=0 + pi=c1(1)*gw(i)*exp(-(1+beta**(-2))*x**2)*x1**2*v2max + else + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + endif + q1=0 + qi=c1(1)*pi + k=1 + deltaintegral(k,j)=deltaintegral(k,j)+qi + do k=2,n + q0=qi + qi=(c1(k)*x1-a1(k))*qi-b1(k)*q1 + q1=q0 + deltaintegral(k,j)=deltaintegral(k,j)+qi + enddo + enddo + enddo + call cpu_time(t2) + if (verbose>0) print '(A,G13.3)','deltaintegrate took',t2-t1 + + if (verbose>2) then +5 format (A,I3,5(G25.16)) + do i=1,min(n,6) + print 5,'di',i,deltaintegral(i,:min(6,n)) + enddo + do i=max(1,n-4),n + print 5,'di',i,deltaintegral(i,max(1,n-4):) + enddo + do i=1,min(n,6) + print 5,'di*beta',i,deltaintegral(i,:min(6,n))*beta + enddo + do i=max(1,n-4),n + print 5,'di*beta',i,deltaintegral(i,max(1,n-4):)*beta + enddo + endif + ! new rescaling: + ! deltaintegral=deltaintegral*beta**2 + end subroutine deltaintegrate + + subroutine genenergymatrix(n,a1,b1,c1,xmax,gp,gw,ngauss,deltaintegral) + ! calculates int v^2 exp(-v^2) P_i(v)P_j(v) dv. + ! adapted from deltaintegrate. + implicit none + integer, intent(in) :: n,ngauss + real, intent(in) :: a1(n),b1(n),c1(n),& !poly rec-coeffis + gp(ngauss),gw(ngauss),& ! gauss points and weights + xmax !integration range and relative factor in exponential + real, intent(out) :: deltaintegral(n,n) + !allocate(deltaintegral(n,n)) + !Note on normalisation: + !With cgyro tauab_inv: + ! with lambda=va/vb =sqrt(Ta/Tb * mb/ma) + ! Changerate_a=4*pi^(-1.5) tauab_inv emat_a^-1 *lambda^2 ( Test_ab(1,lambda)+ ma/mb*field_ab(1,lambda)) + ! We have na* = nb* hopefully. + ! and tauab_inv=tauba_inv*nb/na*mb^2/ma^2*vb^3/va^3=tauba_inv*nb/na va/vb Tb^2/Ta^2 + ! changerate_b_dtf=tauab_inv*na/nb vb/va Ta^2/Tb^2 mb/ma*1/lambda^2 field_ab(1,1/lambda) + ! = .... ".....................*1/lambda (field_ab(1,lambda)^T + ! =tauab_inv*na/nb va^2/vb^2 ma/mb * (field_av(1,lambda))^T + ! =tauab_inv*na/nb lambda^2 ma/mb * (field_av(1,lambda))^T ok. + + real x,p0,p1,pi,q0,q1,qi + integer i,j,k + + deltaintegral=0 + do i=1,ngauss + x=gp(i)*xmax + do j=1,n + if (j==1) then + p1=0 + pi=c1(1)*gw(i)*exp(-x**2)*x**2*xmax + else + p0=pi + pi=(c1(j)*x-a1(j))*pi-b1(j)*p1 + p1=p0 + endif + q1=0 + qi=c1(1)*pi + k=1 + deltaintegral(k,j)=deltaintegral(k,j)+qi + do k=2,n + q0=qi + qi=(c1(k)*x-a1(k))*qi-b1(k)*q1 + q1=q0 + deltaintegral(k,j)=deltaintegral(k,j)+qi + enddo + enddo + enddo + end subroutine genenergymatrix + subroutine genfieldkernel(n,lmax,a1,b1,c1,xmax,beta,t1t2ratio,gp,gw,ngauss& + ,gp2,gw2,ng2,intkernel,intkernel2) + ! driver routine. + ! generates field particle kernel in intkernel dependent on beta and + ! t1t2ratio. + implicit none + optional :: intkernel2 + integer, intent(in) :: n,lmax,ngauss,ng2 ! lmax=max l-**index**, lphys=l-1 + real, intent(in) :: a1(n),b1(n),c1(n),& !poly rec-coeffis + gp(ngauss),gw(ngauss),& ! gauss points and weights ngauss> n + gp2(ng2),gw2(ng2),& ! gauss points and weights for small kernel ng2~8 + xmax,beta,t1t2ratio !integration range and relative factor in exponenti + real, dimension(n,n,lmax), intent(out) :: intkernel(n,n,lmax)& + ,intkernel2(n,n,lmax) + real, allocatable,dimension(:,:,:) :: intkernel1,intlokernel,intlokernel1 + real, allocatable,dimension(:,:) :: deltaintegral + integer i,j,l + real t1,t2 + + call cpu_time(t1) + + if (t1t2ratio/=1 .and. .not. present(intkernel2)) then + print '(A,G23.16,A)','genfieldkernel: t1t2ratio=',t1t2ratio,'and optional arg intker& + &nel2 missing.' + end if + + if (t1t2ratio==1) then + call genintkernel(n,lmax,a1,b1,c1,xmax,beta,1.,gp,gw,ngauss,gp2& + ,gw2,ng2,.true.,intkernel) + if (beta==1) then + do i=1,n + do j=1,i-1 + intkernel(i,j,:)=intkernel(i,j,:)+intkernel(j,i,:) + intkernel(j,i,:)=intkernel(i,j,:) + enddo + intkernel(i,i,:)=intkernel(i,i,:)*2 + enddo + else + allocate(intkernel1(n,n,lmax)) + call genintkernel(n,lmax,a1,b1,c1,xmax,1./beta,1.,gp,gw& + ,ngauss,gp2 ,gw2,ng2,.true.,intkernel1) + do i=1,n + do j=1,n + intkernel(i,j,:)=intkernel(i,j,:)+intkernel1(j,i,:)/beta + enddo + enddo + deallocate(intkernel1) + end if + else + allocate(intlokernel(n,n,lmax),intlokernel1(n,n,lmax)) + + call genintkernel(n,lmax,a1,b1,c1,xmax,beta,t1t2ratio,gp,gw,ngauss,gp2& + ,gw2,ng2,.true.,intkernel,intlokernel) + + call genintkernel(n,lmax,a1,b1,c1,xmax,1./beta,1/t1t2ratio,gp,gw& + ,ngauss,gp2 ,gw2,ng2,.true.,intkernel2,intlokernel1) + do i=1,n + do j=1,n + intkernel(i,j,:)=intkernel(i,j,:)+intlokernel1(j,i,:)/beta + intkernel2(i,j,:)=intkernel2(i,j,:)+intlokernel(j,i,:)*beta + enddo + enddo + deallocate(intlokernel,intlokernel1) + end if + allocate(deltaintegral(n,n)) + call deltaintegrate(n,a1,b1,c1,xmax,beta,gp,gw,ngauss,deltaintegral) + do l=1,lmax + intkernel(:,:,l)=deltaintegral-intkernel(:,:,l) + end do + if (t1t2ratio/=1) then + do i=1,n + do j=1,n + intkernel2(i,j,:)=deltaintegral(j,i)*beta-intkernel2(i,j,:) + end do + end do + else + if (present(intkernel2)) then + do i=1,n + do j=1,n + intkernel2(i,j,:)=intkernel(j,i,:)*beta + end do + end do + endif + endif +!!$2 format (*(G0," ")) +!!$ block +!!$ real di1(n,n),val +!!$ call deltaintegrate(n,a1,b1,c1,xmax,1/beta,gp,gw,ngauss,di1) +!!$ print 2,'Check deltaintegral self adjointness:' +!!$ print 2,deltaintegral(2,1),di1(1,2)/beta +!!$ val=0 +!!$ do i=1,n +!!$ do j=1,n +!!$ val=max(val,abs(deltaintegral(i,j)-di1(j,i)/beta)) +!!$ end do +!!$ end do +!!$ print 2,'max nonself',val +!!$ end block + deallocate(deltaintegral) + call cpu_time(t2) + if (verbose>1) print '(A,G13.3)','genfieldkernel took',t2-t1 + end subroutine genfieldkernel +end module landau diff --git a/shared/math/Makefile b/shared/math/Makefile index 378669d06..13d3ce767 100644 --- a/shared/math/Makefile +++ b/shared/math/Makefile @@ -8,10 +8,8 @@ endif LLIB=math_lib -OBJECTS = math_constants.o \ - gauss_legendre.o \ +OBJECTS = gauss_legendre.o \ half_hermite.o \ - i0.o \ parallel_dim.o \ pseudospec_lib.o diff --git a/shared/math/gauss_exp_quad.py b/shared/math/gauss_exp_quad.py deleted file mode 100644 index 5bc9338cd..000000000 --- a/shared/math/gauss_exp_quad.py +++ /dev/null @@ -1,140 +0,0 @@ -import sys -from mpmath import mp - -emax = sys.argv[1] -n = int(sys.argv[2]) -prec = int(sys.argv[3]) - -# Auto-determine precision if prec=0 - -if prec == 0: - if n <= 50: - prec = 90 - elif n <= 40: - prec = 70 - elif n <= 30: - prec = 60 - elif n <= 20: - prec = 50 - -#-------------------- -b = mp.sqrt(emax) -n = n+1 -#----------------------- -mp.dps=prec - -pa = mp.matrix(n,1) -pb = mp.matrix(n,1) -qa = mp.matrix(n,1) -ra = mp.matrix(n,1) -alpha = mp.matrix(n,1) -beta = mp.matrix(n,1) -gamma = mp.matrix(n,1) -xl = mp.matrix(n,1) -xr = mp.matrix(n,1) -xk = mp.matrix(n-1,1) -xf = mp.matrix(n-1,n-1) -wk = mp.matrix(n-1,1) - -z = mp.matrix(n-1,n-1) -zp = mp.matrix(n-1,n-1) -zpp = mp.matrix(n-1,n-1) - -alpha[0] = (mp.exp(-b*b)-1)/(mp.sqrt(mp.pi)*mp.erf(b)) -beta[0] = 0 -gamma[0] = mp.sqrt(mp.pi)/2*mp.erf(b) - -pa[0] = 1 -pb[0] = 1 - -# Compute recursion coefficients - -for k in range(n-1): - if k > 0: - pa[k+1] = alpha[k]*pa[k]+beta[k]*pa[k-1] - pb[k+1] = (b+alpha[k])*pb[k]+beta[k]*pb[k-1] - else: - pa[k+1] = alpha[k]*pa[k] - pb[k+1] = (b+alpha[k])*pa[k] - gamma[k+1] = ((k+1)*gamma[k]-(mp.exp(-b*b)*pb[k+1]*pb[k]-pa[k+1]*pa[k]))/2 - alpha[k+1] = 1/(2*gamma[k+1])*(mp.exp(-b*b)*pb[k+1]*pb[k+1]-pa[k+1]*pa[k+1]) - beta[k+1] = -gamma[k+1]/gamma[k] - -# Print polynomial data - -def poly(x0): - global alpha - global beta - global n - global pa - global qa - global ra - - pa[0] = 1 - qa[0] = 0 - ra[0] = 0 - for k in range(n-1): - if k > 0: - pa[k+1] = (x0+alpha[k])*pa[k]+beta[k]*pa[k-1] - qa[k+1] = (x0+alpha[k])*qa[k]+beta[k]*qa[k-1]+pa[k] - ra[k+1] = (x0+alpha[k])*ra[k]+beta[k]*ra[k-1]+2*qa[k] - else: - pa[k+1] = (x0+alpha[k])*pa[k] - qa[k+1] = (x0+alpha[k])*qa[k]+pa[k] - ra[k+1] = (x0+alpha[k])*ra[k]+2*qa[k] - - f = pa[n-1] - g = qa[n-1] - return f,g - -x0 = mp.mpf(0) -f,g = poly(x0) -k = 0 -nplot = n*8 -for i in range(nplot): - x0 = i*b/(nplot-1) - f0 = f - f,g = poly(x0) - - if f*f0 < 0: - xl[k] = x0-b/(nplot-1) - xr[k] = x0 - k = k+1 - -if k < n-1: - print('ERROR: (gauss_exp_quad) Not all roots bracketed! Need higher precision.') - sys.exit() - -# Solve for roots using Newton's method -for k in range(n-1): - x0 = (xl[k]+xr[k])/2 - f,g = poly(x0) - while abs(f/g) > mp.mpf(10)**(2-prec): - x0 = x0-f/g - f,g = poly(x0) - xk[k] = x0 - wk[k] = gamma[n-2]/(g*pa[n-2]) - # Capture data for derivative matrix - for kp in range(n-1): - z[k,kp] = pa[kp] - zp[k,kp] = qa[kp] - -zp = zp*mp.powm(z,-1)*b - -# Redefine weight and renormalize last element -wg = mp.matrix(n-1,1) -s = mp.mpf(0) -for k in range(n-1): - wg[k] = wk[k]*4/mp.sqrt(mp.pi)*xk[k]**2 - s = s+wg[k] - -wg[n-2] = wg[n-2]+mp.mpf(1)-s - -# Write to datafile -with open('out.cgyro.egrid','w') as fout: - for k in range(n-1): - fout.write(mp.nstr(xk[k]**2,17)+' '+mp.nstr(wg[k],17)+'\n') - for k in range(n-1): - for kp in range(n-1): - fout.write(mp.nstr(zp[k,kp],17)+' ') - fout.write('\n') diff --git a/shared/math/half_hermite.f90 b/shared/math/half_hermite.f90 index 8369b809b..f81a47b85 100644 --- a/shared/math/half_hermite.f90 +++ b/shared/math/half_hermite.f90 @@ -93,7 +93,8 @@ subroutine half_hermite_norm(n,xmin,xmax,sign,alpha,a1,b1,c1,a,bsq,logg,verbos& real w,sech2,sech,sechb,tanhp1,tanhm1,tanhb real eps integer i,j,k,ia - integer leftnew,rightnew + integer leftnew,rightnew ! How many points of the left or right summation have to be computed + ! from scratch in the interval refinement test step. logical makenew logical vb @@ -102,6 +103,14 @@ subroutine half_hermite_norm(n,xmin,xmax,sign,alpha,a1,b1,c1,a,bsq,logg,verbos& integer :: minalloc,maxalloc,i0,nintervals,nn ! current limits of allocation !i0 points to where the index 0 is. + + ! alpha=-0.94 is about the limit for the following reason: + ! int x^(-1+e) dx=x^e/e. ==> to get up to epsilon accuracy xmin^e~epsilon + ! ==> xmin~epsilon^(1/e) but xmin must be >0. min xmin is about 1e-300. + ! real*8 range: 2.225074D-308, 1.797693D+308 + ! so 3e-308^e-Log10(epsilon) + ! e> -log10(epsilon)/308 ~ 16/308=0.053 + ! calculate recursion coefficients for orthogonal polynomials for weight ! function @@ -193,6 +202,7 @@ subroutine half_hermite_norm(n,xmin,xmax,sign,alpha,a1,b1,c1,a,bsq,logg,verbos& a1(1)=0 b1(1)=0 c1(1)=1 + logg(1)=0 ! allocate enough space, so that we do not have to reallocate frequently minalloc=-10*nsafe-9 maxalloc=10*nsafe+9+2*nintervals @@ -204,6 +214,8 @@ subroutine half_hermite_norm(n,xmin,xmax,sign,alpha,a1,b1,c1,a,bsq,logg,verbos& poly=-500 poly1=-500 end if + leftnew=nintervals ! only needed to calm down ifort when in check all mode. + rightnew=nintervals do i=1,n ! first compute g(i)= and using double exponential ! integration. @@ -679,7 +691,7 @@ subroutine gauss_nodes_functions(n,a,bsq,sp,ortho_f) real,allocatable,dimension(:) :: work integer liwork,lwork integer i,m - logical invmode,zeromode !ieee_exception mode storage + type(ieee_status_type) ieee_status if (present(ortho_f)) then projsteen=>ortho_f @@ -706,10 +718,10 @@ subroutine gauss_nodes_functions(n,a,bsq,sp,ortho_f) ! i.e. x pn_i-1(x)=sum_j J_ij pn_j-1(x) for i=1...n-1 and ! x pn_n-1(x)=sum_j J_nj pn_j-1(x) + J_n,n+1 Pn_n(x) - call ieee_get_halting_mode(ieee_invalid,invmode) - call ieee_get_halting_mode(ieee_divide_by_zero,zeromode) + call ieee_get_status(ieee_status) call ieee_set_halting_mode(ieee_invalid,.false.) call ieee_set_halting_mode(ieee_divide_by_zero,.false.) + call dstevr('N','A',n,a(1:n),bsq(2:n),0.,0.,0,0,0.,m,sp,projsteen,n,isuppz,work,lwork,iwork,liwork,info) if (info/=0) then @@ -720,9 +732,7 @@ subroutine gauss_nodes_functions(n,a,bsq,sp,ortho_f) !Using dstein for the eigenvectors instead of dstevr itself, since they are accurate !even in the face of very small components. call dstein(n,a(1:n),bsq(2:n),n,sp,(/(1,i=1,n)/),(/(n,i=1,n)/),projsteen,n,work,iwork,ifail,info) - call ieee_set_halting_mode(ieee_invalid,invmode) - call ieee_set_halting_mode(ieee_divide_by_zero,zeromode) - call ieee_set_flag(ieee_all,.false.) + call ieee_set_status(ieee_status) ! the eigenvectors are normalised to their square sums ! The eigenvectors in projsteen are projsteen(i,j)=pn_(i)(x_j) sqrt(w_j) n_i ! with a normalisation factor n_i and the Gauss weights w_j @@ -733,7 +743,14 @@ subroutine gauss_nodes_functions(n,a,bsq,sp,ortho_f) ! we have the Gauss weights as - if (.not. present(ortho_f)) deallocate(projsteen) + if (present(ortho_f)) then + !some signs may be wrong: + do i=1,n + if (projsteen(1,i)<0) projsteen(:,i)=-projsteen(:,i) + end do + else + deallocate(projsteen) + endif end subroutine gauss_nodes_functions @@ -818,6 +835,6 @@ subroutine pseudo_maxwell_pliocene(n,e_max,x,w_e,d1,alpha,datafile) enddo close(1) end if -2 format (*(EN25.16)) +2 format (5(ES24.16)) end subroutine pseudo_maxwell_pliocene end module half_hermite diff --git a/shared/math/i0.f b/shared/math/i0.f deleted file mode 100644 index 6141fd95c..000000000 --- a/shared/math/i0.f +++ /dev/null @@ -1,269 +0,0 @@ - SUBROUTINE CALCI0(ARG,RESULT,JINT) -C-------------------------------------------------------------------- -C -C This packet computes modified Bessel functions of the first kind -C and order zero, I0(X) and EXP(-ABS(X))*I0(X), for real -C arguments X. It contains two function type subprograms, BESI0 -C and BESEI0, and one subroutine type subprogram, CALCI0. -C The calling statements for the primary entries are -C -C Y=BESI0(X) -C and -C Y=BESEI0(X) -C -C where the entry points correspond to the functions I0(X) and -C EXP(-ABS(X))*I0(X), respectively. The routine CALCI0 is -C intended for internal packet use only, all computations within -C the packet being concentrated in this routine. The function -C subprograms invoke CALCI0 with the statement -C CALL CALCI0(ARG,RESULT,JINT) -C where the parameter usage is as follows -C -C Function Parameters for CALCI0 -C Call ARG RESULT JINT -C -C BESI0(ARG) ABS(ARG) .LE. XMAX I0(ARG) 1 -C BESEI0(ARG) any real ARG EXP(-ABS(ARG))*I0(ARG) 2 -C -C The main computation evaluates slightly modified forms of -C minimax approximations generated by Blair and Edwards, Chalk -C River (Atomic Energy of Canada Limited) Report AECL-4928, -C October, 1974. This transportable program is patterned after -C the machine-dependent FUNPACK packet NATSI0, but cannot match -C that version for efficiency or accuracy. This version uses -C rational functions that theoretically approximate I-SUB-0(X) -C to at least 18 significant decimal digits. The accuracy -C achieved depends on the arithmetic system, the compiler, the -C intrinsic functions, and proper selection of the machine- -C dependent constants. -C -C******************************************************************* -C******************************************************************* -C -C Explanation of machine-dependent constants -C -C beta = Radix for the floating-point system -C maxexp = Smallest power of beta that overflows -C XSMALL = Positive argument such that 1.0 - X = 1.0 to -C machine precision for all ABS(X) .LE. XSMALL. -C XINF = Largest positive machine number; approximately -C beta**maxexp -C XMAX = Largest argument acceptable to BESI0; Solution to -C equation: -C W(X) * (1+1/(8*X)+9/(128*X**2) = beta**maxexp -C where W(X) = EXP(X)/SQRT(2*PI*X) -C -C -C Approximate values for some important machines are: -C -C beta maxexp XSMALL -C -C CRAY-1 (S.P.) 2 8191 3.55E-15 -C Cyber 180/855 -C under NOS (S.P.) 2 1070 3.55E-15 -C IEEE (IBM/XT, -C SUN, etc.) (S.P.) 2 128 2.98E-8 -C IEEE (IBM/XT, -C SUN, etc.) (D.P.) 2 1024 5.55D-17 -C IBM 3033 (D.P.) 16 63 6.95D-18 -C VAX (S.P.) 2 127 2.98E-8 -C VAX D-Format (D.P.) 2 127 6.95D-18 -C VAX G-Format (D.P.) 2 1023 5.55D-17 -C -C -C XINF XMAX -C -C CRAY-1 (S.P.) 5.45E+2465 5682.810 -C Cyber 180/855 -C under NOS (S.P.) 1.26E+322 745.893 -C IEEE (IBM/XT, -C SUN, etc.) (S.P.) 3.40E+38 91.900 -C IEEE (IBM/XT, -C SUN, etc.) (D.P.) 1.79D+308 713.986 -C IBM 3033 (D.P.) 7.23D+75 178.182 -C VAX (S.P.) 1.70D+38 91.203 -C VAX D-Format (D.P.) 1.70D+38 91.203 -C VAX G-Format (D.P.) 8.98D+307 713.293 -C -C******************************************************************* -C******************************************************************* -C -C Error returns -C -C The program returns XINF for BESI0 for ABS(ARG) .GT. XMAX. -C -C -C Intrinsic functions required are: -C -C ABS, SQRT, EXP -C -C -C Authors: W. J. Cody and L. Stoltz -C Mathematics and Computer Science Division -C Argonne National Laboratory -C Argonne, IL 60439 -C -C Latest modification: June 7, 1988 -C -C-------------------------------------------------------------------- - INTEGER I,JINT -C REAL - DOUBLE PRECISION - 1 A,ARG,B,EXP40,FORTY,ONE,ONE5,P,PP,Q,QQ,RESULT, - 2 REC15,SUMP,SUMQ,TWO25,X,XINF,XMAX,XSMALL,XX - DIMENSION P(15),PP(8),Q(5),QQ(7) -C-------------------------------------------------------------------- -C Mathematical constants -C-------------------------------------------------------------------- -C DATA ONE/1.0E0/,ONE5/15.0E0/,EXP40/2.353852668370199854E17/, -C 1 FORTY/40.0E0/,REC15/6.6666666666666666666E-2/, -C 2 TWO25/225.0E0/ - DATA ONE/1.0D0/,ONE5/15.0D0/,EXP40/2.353852668370199854D17/, - 1 FORTY/40.0D0/,REC15/6.6666666666666666666D-2/, - 2 TWO25/225.0D0/ -C-------------------------------------------------------------------- -C Machine-dependent constants -C-------------------------------------------------------------------- -C DATA XSMALL/2.98E-8/,XINF/3.40E38/,XMAX/91.9E0/ - DATA XSMALL/5.55D-17/,XINF/1.79D308/,XMAX/713.986D0/ -C-------------------------------------------------------------------- -C Coefficients for XSMALL .LE. ABS(ARG) .LT. 15.0 -C-------------------------------------------------------------------- -C DATA P/-5.2487866627945699800E-18,-1.5982226675653184646E-14, -C 1 -2.6843448573468483278E-11,-3.0517226450451067446E-08, -C 2 -2.5172644670688975051E-05,-1.5453977791786851041E-02, -C 3 -7.0935347449210549190E+00,-2.4125195876041896775E+03, -C 4 -5.9545626019847898221E+05,-1.0313066708737980747E+08, -C 5 -1.1912746104985237192E+10,-8.4925101247114157499E+11, -C 6 -3.2940087627407749166E+13,-5.5050369673018427753E+14, -C 7 -2.2335582639474375249E+15/ -C DATA Q/-3.7277560179962773046E+03, 6.5158506418655165707E+06, -C 1 -6.5626560740833869295E+09, 3.7604188704092954661E+12, -C 2 -9.7087946179594019126E+14/ - DATA P/-5.2487866627945699800D-18,-1.5982226675653184646D-14, - 1 -2.6843448573468483278D-11,-3.0517226450451067446D-08, - 2 -2.5172644670688975051D-05,-1.5453977791786851041D-02, - 3 -7.0935347449210549190D+00,-2.4125195876041896775D+03, - 4 -5.9545626019847898221D+05,-1.0313066708737980747D+08, - 5 -1.1912746104985237192D+10,-8.4925101247114157499D+11, - 6 -3.2940087627407749166D+13,-5.5050369673018427753D+14, - 7 -2.2335582639474375249D+15/ - DATA Q/-3.7277560179962773046D+03, 6.5158506418655165707D+06, - 1 -6.5626560740833869295D+09, 3.7604188704092954661D+12, - 2 -9.7087946179594019126D+14/ -C-------------------------------------------------------------------- -C Coefficients for 15.0 .LE. ABS(ARG) -C-------------------------------------------------------------------- -C DATA PP/-3.9843750000000000000E-01, 2.9205384596336793945E+00, -C 1 -2.4708469169133954315E+00, 4.7914889422856814203E-01, -C 2 -3.7384991926068969150E-03,-2.6801520353328635310E-03, -C 3 9.9168777670983678974E-05,-2.1877128189032726730E-06/ -C DATA QQ/-3.1446690275135491500E+01, 8.5539563258012929600E+01, -C 1 -6.0228002066743340583E+01, 1.3982595353892851542E+01, -C 2 -1.1151759188741312645E+00, 3.2547697594819615062E-02, -C 3 -5.5194330231005480228E-04/ - DATA PP/-3.9843750000000000000D-01, 2.9205384596336793945D+00, - 1 -2.4708469169133954315D+00, 4.7914889422856814203D-01, - 2 -3.7384991926068969150D-03,-2.6801520353328635310D-03, - 3 9.9168777670983678974D-05,-2.1877128189032726730D-06/ - DATA QQ/-3.1446690275135491500D+01, 8.5539563258012929600D+01, - 1 -6.0228002066743340583D+01, 1.3982595353892851542D+01, - 2 -1.1151759188741312645D+00, 3.2547697594819615062D-02, - 3 -5.5194330231005480228D-04/ -C-------------------------------------------------------------------- - X = ABS(ARG) - IF (X .LT. XSMALL) THEN - RESULT = ONE - ELSE IF (X .LT. ONE5) THEN -C-------------------------------------------------------------------- -C XSMALL .LE. ABS(ARG) .LT. 15.0 -C-------------------------------------------------------------------- - XX = X * X - SUMP = P(1) - DO 50 I = 2, 15 - SUMP = SUMP * XX + P(I) - 50 CONTINUE - XX = XX - TWO25 - SUMQ = ((((XX+Q(1))*XX+Q(2))*XX+Q(3))*XX+Q(4))*XX+Q(5) - RESULT = SUMP / SUMQ - IF (JINT .EQ. 2) RESULT = RESULT * EXP(-X) - ELSE IF (X .GE. ONE5) THEN - IF ((JINT .EQ. 1) .AND. (X .GT. XMAX)) THEN - RESULT = XINF - ELSE -C-------------------------------------------------------------------- -C 15.0 .LE. ABS(ARG) -C-------------------------------------------------------------------- - XX = ONE / X - REC15 - SUMP = ((((((PP(1)*XX+PP(2))*XX+PP(3))*XX+PP(4))*XX+ - 1 PP(5))*XX+PP(6))*XX+PP(7))*XX+PP(8) - SUMQ = ((((((XX+QQ(1))*XX+QQ(2))*XX+QQ(3))*XX+ - 1 QQ(4))*XX+QQ(5))*XX+QQ(6))*XX+QQ(7) - RESULT = SUMP / SUMQ - IF (JINT .EQ. 2) THEN - RESULT = (RESULT - PP(1)) / SQRT(X) - ELSE -C-------------------------------------------------------------------- -C Calculation reformulated to avoid premature overflow -C-------------------------------------------------------------------- - IF (X .LE.(XMAX-ONE5)) THEN - A = EXP(X) - B = ONE - ELSE - A = EXP(X-FORTY) - B = EXP40 - END IF - RESULT = ((RESULT*A-PP(1)*A)/SQRT(X))*B - END IF - END IF - END IF -C-------------------------------------------------------------------- -C Return for ABS(ARG) .LT. XSMALL -C-------------------------------------------------------------------- - RETURN -C----------- Last line of CALCI0 ----------- - END -C REAL - DOUBLE PRECISION - 1 FUNCTION BESI0(X) -C-------------------------------------------------------------------- -C -C This long precision subprogram computes approximate values for -C modified Bessel functions of the first kind of order zero for -C arguments ABS(ARG) .LE. XMAX (see comments heading CALCI0). -C -C-------------------------------------------------------------------- - INTEGER JINT -C REAL - DOUBLE PRECISION - 1 X, RESULT -C-------------------------------------------------------------------- - JINT=1 - CALL CALCI0(X,RESULT,JINT) - BESI0=RESULT - RETURN -C---------- Last line of BESI0 ---------- - END -C REAL - DOUBLE PRECISION - 1 FUNCTION BESEI0(X) -C-------------------------------------------------------------------- -C -C This function program computes approximate values for the -C modified Bessel function of the first kind of order zero -C multiplied by EXP(-ABS(X)), where EXP is the -C exponential function, ABS is the absolute value, and X -C is any argument. -C -C-------------------------------------------------------------------- - INTEGER JINT -C REAL - DOUBLE PRECISION - 1 X, RESULT -C-------------------------------------------------------------------- - JINT=2 - CALL CALCI0(X,RESULT,JINT) - BESEI0=RESULT - RETURN -C---------- Last line of BESEI0 ---------- - END diff --git a/shared/math/math_constants.f90 b/shared/math/math_constants.f90 deleted file mode 100644 index 8788aa98f..000000000 --- a/shared/math/math_constants.f90 +++ /dev/null @@ -1,18 +0,0 @@ -module math_constants - - implicit none - - real, parameter :: & - root_1_by_pi = 5.641895835477563e-1, & - two_by_pi = 6.366197723675813e-1, & - pi_by_4 = 7.853981633974483e-1, & - root_2_by_pi = 7.978845608028654e-1, & - pi_by_2 = 1.570796326794897e0, & - pi_3_by_4 = 2.356194490192345e0, & - pi = 3.141592653589793e0, & - pi_2 = 6.283185307179586e0, & - twothirds = 0.666666666666667e0 - - complex, parameter :: i_c = (0.0,1.0) - -end module math_constants diff --git a/tglf/bin/tglf_defaults.py b/tglf/bin/tglf_defaults.py index 03d3e6969..56136c7d8 100755 --- a/tglf/bin/tglf_defaults.py +++ b/tglf/bin/tglf_defaults.py @@ -162,6 +162,28 @@ def set_defaults() : t.add('S_DELTA_LOC','0.0') t.add('ZETA_LOC','0.0') t.add('S_ZETA_LOC','0.0') + t.add('SHAPE_COS0','0.0') + t.add('SHAPE_S_COS0','0.0') + t.add('SHAPE_COS1','0.0') + t.add('SHAPE_S_COS1','0.0') + t.add('SHAPE_COS2','0.0') + t.add('SHAPE_S_COS2','0.0') + t.add('SHAPE_COS3','0.0') + t.add('SHAPE_S_COS3','0.0') + t.add('SHAPE_COS4','0.0') + t.add('SHAPE_S_COS4','0.0') + t.add('SHAPE_COS5','0.0') + t.add('SHAPE_S_COS5','0.0') + t.add('SHAPE_COS6','0.0') + t.add('SHAPE_S_COS6','0.0') + t.add('SHAPE_SIN3','0.0') + t.add('SHAPE_S_SIN3','0.0') + t.add('SHAPE_SIN4','0.0') + t.add('SHAPE_S_SIN4','0.0') + t.add('SHAPE_SIN5','0.0') + t.add('SHAPE_S_SIN5','0.0') + t.add('SHAPE_SIN6','0.0') + t.add('SHAPE_S_SIN6','0.0') t.add('Q_LOC','2.0') t.add('Q_PRIME_LOC','16.0') t.add('P_PRIME_LOC','0.0') diff --git a/tglf/src/tglf_LS.f90 b/tglf/src/tglf_LS.f90 index 4824cc8f1..25176f249 100644 --- a/tglf/src/tglf_LS.f90 +++ b/tglf/src/tglf_LS.f90 @@ -42,7 +42,6 @@ SUBROUTINE tglf_LS logical :: is_sup_to_drift REAL :: sum_phi, sum_abs_phi REAL, DIMENSION(max_plot) :: even_function, odd_function - ! ! cputime0=MPI_WTIME() ! diff --git a/tglf/src/tglf_driver.f90 b/tglf/src/tglf_driver.f90 index f48457c44..1d816445c 100644 --- a/tglf/src/tglf_driver.f90 +++ b/tglf/src/tglf_driver.f90 @@ -48,7 +48,11 @@ PROGRAM tglf_driver elseif(igeo_tg.eq.1)then ! q_prime_tg = shat_tg*(q_tg/rmin_tg)**2 CALL put_Miller_geometry(rmin_tg,rmaj_tg,zmaj_tg,drmindx_tg,drmajdx_tg,dzmajdx_tg, & - kappa_tg,s_kappa_tg,delta_tg,s_delta_tg,zeta_tg,s_zeta_tg,q_tg,q_prime_tg,p_prime_tg,kx0_tg) + kappa_tg,s_kappa_tg,delta_tg,s_delta_tg,zeta_tg,s_zeta_tg,shape_sin3_tg,shape_s_sin3_tg,& + shape_sin4_tg,shape_s_sin4_tg,shape_sin5_tg,shape_s_sin5_tg,shape_sin6_tg,shape_s_sin6_tg,& + shape_cos0_tg,shape_s_cos0_tg,shape_cos1_tg,shape_s_cos1_tg,shape_cos2_tg,shape_s_cos2_tg,& + shape_cos3_tg,shape_s_cos3_tg,shape_cos4_tg,shape_s_cos4_tg,shape_cos5_tg,shape_s_cos5_tg,& + shape_cos6_tg,shape_s_cos6_tg,q_tg,q_prime_tg,p_prime_tg,kx0_tg) elseif(igeo_tg.eq.2)then CALL put_Fourier_geometry(q_tg,q_prime_tg,p_prime_tg,nfourier_tg,fourier_tg) elseif(igeo_tg.eq.3)then diff --git a/tglf/src/tglf_driver_mpi.f90 b/tglf/src/tglf_driver_mpi.f90 index 4728f2f82..e8b982a28 100644 --- a/tglf/src/tglf_driver_mpi.f90 +++ b/tglf/src/tglf_driver_mpi.f90 @@ -52,7 +52,11 @@ PROGRAM tglf_driver_mpi elseif(igeo_tg.eq.1)then ! q_prime_tg = shat_tg*(q_tg/rmin_tg)**2 CALL put_Miller_geometry(rmin_tg,rmaj_tg,zmaj_tg,drmindx_tg,drmajdx_tg,dzmajdx_tg, & - kappa_tg,s_kappa_tg,delta_tg,s_delta_tg,zeta_tg,s_zeta_tg,q_tg,q_prime_tg,p_prime_tg,kx0_tg) + kappa_tg,s_kappa_tg,delta_tg,s_delta_tg,zeta_tg,s_zeta_tg,shape_sin3_tg,shape_s_sin3_tg,& + shape_sin4_tg,shape_s_sin4_tg,shape_sin5_tg,shape_s_sin5_tg,shape_sin6_tg,shape_s_sin6_tg,& + shape_cos0_tg,shape_s_cos0_tg,shape_cos1_tg,shape_s_cos1_tg,shape_cos2_tg,shape_s_cos2_tg,& + shape_cos3_tg,shape_s_cos3_tg,shape_cos4_tg,shape_s_cos4_tg,shape_cos5_tg,shape_s_cos5_tg,& + shape_cos6_tg,shape_s_cos6_tg,q_tg,q_prime_tg,p_prime_tg,kx0_tg) elseif(igeo_tg.eq.2)then CALL put_Fourier_geometry(q_tg,q_prime_tg,p_prime_tg,nfourier_tg,fourier_tg) elseif(igeo_tg.eq.3)then diff --git a/tglf/src/tglf_eigensolver.f90 b/tglf/src/tglf_eigensolver.f90 index bbe17b6a7..5fff5d6ff 100644 --- a/tglf/src/tglf_eigensolver.f90 +++ b/tglf/src/tglf_eigensolver.f90 @@ -91,7 +91,6 @@ SUBROUTINE tglf_eigensolver COMPLEX,ALLOCATABLE,DIMENSION(:,:) :: vleft,vright COMPLEX,ALLOCATABLE,DIMENSION(:) :: work COMPLEX,ALLOCATABLE,DIMENSION(:) :: zomega - COMMON /block/ max_freq ! ifail = 0 lwork = 8*iur diff --git a/tglf/src/tglf_geometry.f90 b/tglf/src/tglf_geometry.f90 index c89d79fd1..4c40fc3d0 100644 --- a/tglf/src/tglf_geometry.f90 +++ b/tglf/src/tglf_geometry.f90 @@ -1324,6 +1324,7 @@ END SUBROUTINE mercier_write ! squarness shear s_zeta_loc = rmin*d(zeta)/dx. Included elevation Zmaj_loc. ! Also changed definition of s_delta = rmin*d(delta)/dx from Waltz-Miller convention to GYRO's. ! July 26, 2021 set elevation Zmaj_loc =0.0 and DZMAJDX_LOC=0.0 since these break the up/down symmetry of Miller by contributing to Grad_r +! August 1, 2024 Sophia Guizzo(s.guizzo@columbia.edu) revised with MXH parameterization (Arbon et al PPCF 2020) !--------------------------------------------------------------- SUBROUTINE miller_geo @@ -1374,10 +1375,36 @@ SUBROUTINE miller_geo ! compute the arclength around the flux surface ! theta = 0.0 - arg_r = theta+x_delta*sin(theta) - darg_r = 1.0+x_delta*cos(theta) - arg_z = theta + zeta_loc*sin(2.0*theta) - darg_z = 1.0 + zeta_loc*2.0*cos(2.0*theta) + arg_r = theta + shape_cos0_loc + & + shape_cos1_loc*cos(theta) + & + shape_cos2_loc*cos(2*theta) + & + shape_cos3_loc*cos(3*theta) + & + shape_cos4_loc*cos(4*theta) + & + shape_cos5_loc*cos(5*theta) + & + shape_cos6_loc*cos(6*theta) + & + x_delta*sin(theta)- & + zeta_loc*sin(2*theta) + & + shape_sin3_loc*sin(3*theta) +& + shape_sin4_loc*sin(4*theta) + & + shape_sin5_loc*sin(5*theta) +& + shape_sin6_loc*sin(6*theta) + + darg_r = 1 - shape_cos1_loc*sin(theta) - & + 2*shape_cos2_loc*sin(2*theta) - & + 3*shape_cos3_loc*sin(3*theta) - & + 4*shape_cos4_loc*sin(4*theta) - & + 5*shape_cos5_loc*sin(5*theta) - & + 6*shape_cos6_loc*sin(6*theta) + & + x_delta*cos(theta)-& + 2*zeta_loc*cos(2*theta) + & + 3*shape_sin3_loc*cos(3*theta) + & + 4*shape_sin4_loc*cos(4*theta) + & + 5*shape_sin5_loc*cos(5*theta) + & + 6*shape_sin6_loc*cos(6*theta) + + arg_z = theta + darg_z = 1.0 + r_t = -rmin_loc*sin(arg_r)*darg_r z_t = kappa_loc*rmin_loc*cos(arg_z)*darg_z l_t = SQRT(r_t**2+z_t**2) @@ -1387,6 +1414,7 @@ SUBROUTINE miller_geo l_t1 = l_t scale_max=l_t arclength = 0.0 + do while(theta.lt.pi_2) theta = theta + dtheta if(theta.gt.pi_2)then @@ -1395,15 +1423,39 @@ SUBROUTINE miller_geo theta = pi_2 endif ! write(*,*)"theta = ",theta,"dtheta=",dtheta - arg_r = theta+x_delta*sin(theta) + arg_r = theta + shape_cos0_loc + & + shape_cos1_loc*cos(theta) + & + shape_cos2_loc*cos(2*theta) + & + shape_cos3_loc*cos(3*theta) + & + shape_cos4_loc*cos(4*theta) + & + shape_cos5_loc*cos(5*theta) + & + shape_cos6_loc*cos(6*theta) + & + x_delta*sin(theta)- & + zeta_loc*sin(2*theta) + & + shape_sin3_loc*sin(3*theta) +& + shape_sin4_loc*sin(4*theta) + & + shape_sin5_loc*sin(5*theta) +& + shape_sin6_loc*sin(6*theta) + ! d(arg_r)/dtheta - darg_r = 1.0+x_delta*cos(theta) + darg_r = 1 - shape_cos1_loc*sin(theta) - & + 2*shape_cos2_loc*sin(2*theta) - & + 3*shape_cos3_loc*sin(3*theta) - & + 4*shape_cos4_loc*sin(4*theta) - & + 5*shape_cos5_loc*sin(5*theta) - & + 6*shape_cos6_loc*sin(6*theta) + & + x_delta*cos(theta)-& + 2*zeta_loc*cos(2*theta) + & + 3*shape_sin3_loc*cos(3*theta) + & + 4*shape_sin4_loc*cos(4*theta) + & + 5*shape_sin5_loc*cos(5*theta) + & + 6*shape_sin6_loc*cos(6*theta) ! dR/dtheta r_t = -rmin_loc*sin(arg_r)*darg_r ! - arg_z = theta + zeta_loc*sin(2.0*theta) + arg_z = theta ! d(arg_z)/dtheta - darg_z = 1.0 + zeta_loc*2.0*cos(2.0*theta) + darg_z = 1.0 ! dZ/dtheta z_t = kappa_loc*rmin_loc*cos(arg_z)*darg_z ! dl/dtheta @@ -1431,10 +1483,33 @@ SUBROUTINE miller_geo t_s(ms)=-pi_2 ! make a first guess based on theta=0.0 theta=0.0 - arg_r = theta+x_delta*sin(theta) - darg_r = 1.0+x_delta*cos(theta) - arg_z = theta + zeta_loc*sin(2.0*theta) - darg_z = 1.0 + zeta_loc*2.0*cos(2.0*theta) + arg_r = theta + shape_cos0_loc + & + shape_cos1_loc*cos(theta) + & + shape_cos2_loc*cos(2*theta) + & + shape_cos3_loc*cos(3*theta) + & + shape_cos4_loc*cos(4*theta) + & + shape_cos5_loc*cos(5*theta) + & + shape_cos6_loc*cos(6*theta) + & + x_delta*sin(theta)- & + zeta_loc*sin(2*theta) + & + shape_sin3_loc*sin(3*theta) +& + shape_sin4_loc*sin(4*theta) + & + shape_sin5_loc*sin(5*theta) +& + shape_sin6_loc*sin(6*theta) + darg_r = 1 - shape_cos1_loc*sin(theta) - & + 2*shape_cos2_loc*sin(2*theta) - & + 3*shape_cos3_loc*sin(3*theta) - & + 4*shape_cos4_loc*sin(4*theta) - & + 5*shape_cos5_loc*sin(5*theta) - & + 6*shape_cos6_loc*sin(6*theta) + & + x_delta*cos(theta)-& + 2*zeta_loc*cos(2*theta) + & + 3*shape_sin3_loc*cos(3*theta) + & + 4*shape_sin4_loc*cos(4*theta) + & + 5*shape_sin5_loc*cos(5*theta) + & + 6*shape_sin6_loc*cos(6*theta) + arg_z = theta + darg_z = 1.0 r_t = -rmin_loc*sin(arg_r)*darg_r z_t = kappa_loc*rmin_loc*cos(arg_z)*darg_z l_t = SQRT(r_t**2+z_t**2) @@ -1442,11 +1517,34 @@ SUBROUTINE miller_geo theta=dtheta l_t1=l_t ! - do m=1,ms/2 - arg_r = theta+x_delta*sin(theta) - darg_r = 1.0+x_delta*cos(theta) - arg_z = theta + zeta_loc*sin(2.0*theta) - darg_z = 1.0 + zeta_loc*2.0*cos(2.0*theta) + do m=1,ms + arg_r = theta + shape_cos0_loc + & + shape_cos1_loc*cos(theta) + & + shape_cos2_loc*cos(2*theta) + & + shape_cos3_loc*cos(3*theta) + & + shape_cos4_loc*cos(4*theta) + & + shape_cos5_loc*cos(5*theta) + & + shape_cos6_loc*cos(6*theta) + & + x_delta*sin(theta)- & + zeta_loc*sin(2*theta) + & + shape_sin3_loc*sin(3*theta) +& + shape_sin4_loc*sin(4*theta) + & + shape_sin5_loc*sin(5*theta) +& + shape_sin6_loc*sin(6*theta) + darg_r = 1 - shape_cos1_loc*sin(theta) - & + 2*shape_cos2_loc*sin(2*theta) - & + 3*shape_cos3_loc*sin(3*theta) - & + 4*shape_cos4_loc*sin(4*theta) - & + 5*shape_cos5_loc*sin(5*theta) - & + 6*shape_cos6_loc*sin(6*theta) + & + x_delta*cos(theta)-& + 2*zeta_loc*cos(2*theta) + & + 3*shape_sin3_loc*cos(3*theta) + & + 4*shape_sin4_loc*cos(4*theta) + & + 5*shape_sin5_loc*cos(5*theta) + & + 6*shape_sin6_loc*cos(6*theta) + arg_z = theta + darg_z = 1.0 r_t = -rmin_loc*sin(arg_r)*darg_r z_t = kappa_loc*rmin_loc*cos(arg_z)*darg_z l_t = SQRT(r_t**2+z_t**2) @@ -1456,13 +1554,12 @@ SUBROUTINE miller_geo l_t1=l_t enddo ! distribute endpoint error over interior points - dtheta = (t_s(ms/2)-(-pi))/REAL(ms/2) + dtheta = (t_s(ms)-(-pi_2))/REAL(ms) ! write(*,*)"enpoint error =",dtheta ! dtheta=0.0 ! t_s(ms/2)=-pi - do m=1,ms/2 + do m=1,ms t_s(m) = t_s(m)-REAL(m)*dtheta - t_s(ms-m)=-pi_2 - t_s(m) enddo ! write(*,*)"t_s(ms/2)+pi=",t_s(ms/2)+pi ! @@ -1491,10 +1588,33 @@ SUBROUTINE miller_geo do m=0,ms theta = t_s(m) - arg_r = theta + x_delta*sin(theta) - darg_r = 1.0 + x_delta*cos(theta) - arg_z = theta + zeta_loc*sin(2.0*theta) - darg_z = 1.0 + zeta_loc*2.0*cos(2.0*theta) + arg_r = theta + shape_cos0_loc + & + shape_cos1_loc*cos(theta) + & + shape_cos2_loc*cos(2*theta) + & + shape_cos3_loc*cos(3*theta) + & + shape_cos4_loc*cos(4*theta) + & + shape_cos5_loc*cos(5*theta) + & + shape_cos6_loc*cos(6*theta) + & + x_delta*sin(theta)- & + zeta_loc*sin(2*theta) + & + shape_sin3_loc*sin(3*theta) +& + shape_sin4_loc*sin(4*theta) + & + shape_sin5_loc*sin(5*theta) +& + shape_sin6_loc*sin(6*theta) + darg_r = 1 - shape_cos1_loc*sin(theta) - & + 2*shape_cos2_loc*sin(2*theta) - & + 3*shape_cos3_loc*sin(3*theta) - & + 4*shape_cos4_loc*sin(4*theta) - & + 5*shape_cos5_loc*sin(5*theta) - & + 6*shape_cos6_loc*sin(6*theta) + & + x_delta*cos(theta)-& + 2*zeta_loc*cos(2*theta) + & + 3*shape_sin3_loc*cos(3*theta) + & + 4*shape_sin4_loc*cos(4*theta) + & + 5*shape_sin5_loc*cos(5*theta) + & + 6*shape_sin6_loc*cos(6*theta) + arg_z = theta + darg_z = 1.0 ! R(theta) ! Z(theta) @@ -1514,9 +1634,21 @@ SUBROUTINE miller_geo ! dR/dr ! dZ/dr R_r = drmajdx_loc + drmindx_loc*cos(arg_r) & - -sin(arg_r)*s_delta_loc*sin(theta)/sqrt(1.0 - delta_loc**2) - Z_r = dzmajdx_loc + kappa_loc*sin(arg_z)*(drmindx_loc +s_kappa_loc) & - +kappa_loc*cos(arg_z)*s_zeta_loc*sin(2.0*theta) + -sin(arg_r)*(shape_s_cos0_loc + & + shape_s_cos1_loc*cos(theta) + & + shape_s_cos2_loc*cos(2*theta) + & + shape_s_cos3_loc*cos(3*theta) + & + shape_s_cos4_loc*cos(4*theta) + & + shape_s_cos5_loc*cos(5*theta) + & + shape_s_cos6_loc*cos(6*theta) + & + s_delta_loc*sin(theta)/cos(x_delta) - & + s_zeta_loc*sin(2*theta) + & + shape_s_sin3_loc*sin(3*theta) + & + shape_s_sin4_loc*sin(4*theta) + & + shape_s_sin5_loc*sin(5*theta) + & + shape_s_sin6_loc*sin(6*theta)) + + Z_r = dzmajdx_loc + kappa_loc*sin(arg_z)*(drmindx_loc +s_kappa_loc) ! Jacobian det = R_r*z_t - R_t*Z_r ! grad_r diff --git a/tglf/src/tglf_inout.f90 b/tglf/src/tglf_inout.f90 index 0010011d0..86749ae72 100644 --- a/tglf/src/tglf_inout.f90 +++ b/tglf/src/tglf_inout.f90 @@ -454,7 +454,11 @@ END SUBROUTINE put_s_alpha_geometry ! SUBROUTINE put_Miller_geometry(rmin,rmaj,zmaj,drmindx,drmajdx,dzmajdx, & - kappa,s_kappa,delta,s_delta,zeta,s_zeta,q,q_prime,p_prime,beta,kx0_m) + kappa,s_kappa,delta,s_delta,zeta,s_zeta,shape_sin3, shape_s_sin3, shape_sin4, & + shape_s_sin4, shape_sin5, shape_s_sin5, shape_sin6, shape_s_sin6, shape_cos0, & + shape_s_cos0, shape_cos1, shape_s_cos1, shape_cos2, shape_s_cos2, shape_cos3, & + shape_s_cos3, shape_cos4, shape_s_cos4, shape_cos5, shape_s_cos5, shape_cos6, & + shape_s_cos6,q,q_prime,p_prime,beta,kx0_m) ! ! This routine eliminates the need for subroutine miller_init ! and the miller.dat input file. @@ -464,7 +468,11 @@ SUBROUTINE put_Miller_geometry(rmin,rmaj,zmaj,drmindx,drmajdx,dzmajdx, & IMPLICIT NONE REAL,INTENT(IN) :: rmin,rmaj,zmaj,q,q_prime,p_prime,kx0_m,beta REAL,INTENT(IN) :: drmindx,drmajdx,dzmajdx - REAL,INTENT(IN) :: kappa,s_kappa,delta,s_delta,zeta,s_zeta + REAL,INTENT(IN) :: kappa,s_kappa,delta,s_delta,zeta,s_zeta, shape_sin3, shape_s_sin3, shape_sin4, & + shape_s_sin4, shape_sin5, shape_s_sin5, shape_sin6, shape_s_sin6, shape_cos0, & + shape_s_cos0, shape_cos1, shape_s_cos1, shape_cos2, shape_s_cos2, shape_cos3, & + shape_s_cos3, shape_cos4, shape_s_cos4, shape_cos5, shape_s_cos5, shape_cos6, & + shape_s_cos6 if(tglf_isnan(rmin))call tglf_error(1,"input rmin_loc is NAN") if(tglf_isinf(rmin))call tglf_error(1,"input rmin_loc is INF") @@ -528,6 +536,28 @@ SUBROUTINE put_Miller_geometry(rmin,rmaj,zmaj,drmindx,drmajdx,dzmajdx, & s_zeta_loc = s_zeta beta_loc = beta kx0_loc = kx0_m + shape_sin3_loc = shape_sin3 + shape_s_sin3_loc = shape_s_sin3 + shape_sin4_loc = shape_sin4 + shape_s_sin4_loc = shape_s_sin4 + shape_sin5_loc = shape_sin5 + shape_s_sin5_loc = shape_s_sin5 + shape_sin6_loc = shape_sin6 + shape_s_sin6_loc = shape_s_sin6 + shape_cos0_loc = shape_cos0 + shape_s_cos0_loc = shape_s_cos0 + shape_cos1_loc = shape_cos1 + shape_s_cos1_loc = shape_s_cos1 + shape_cos2_loc = shape_cos2 + shape_s_cos2_loc = shape_s_cos2 + shape_cos3_loc = shape_cos3 + shape_s_cos3_loc = shape_s_cos3 + shape_cos4_loc = shape_cos4 + shape_s_cos4_loc = shape_s_cos4 + shape_cos5_loc = shape_cos5 + shape_s_cos5_loc = shape_s_cos5 + shape_cos6_loc = shape_cos6 + shape_s_cos6_loc = shape_s_cos6 ! ! validatiy checks ! @@ -1581,6 +1611,28 @@ SUBROUTINE write_tglf_input write(11,*)" s_delta_tg= ",s_delta_loc write(11,*)" zeta_tg= ",zeta_loc write(11,*)" s_zeta_tg= ",s_zeta_loc + write(11,*)" shape_sin3_tg= ", shape_sin3_loc + write(11,*)" shape_s_sin3_tg= ", shape_s_sin3_loc + write(11,*)" shape_sin4_tg= ", shape_sin4_loc + write(11,*)" shape_s_sin4_tg= ", shape_s_sin4_loc + write(11,*)" shape_sin5_tg= ", shape_sin5_loc + write(11,*)" shape_s_sin5_tg= ", shape_s_sin5_loc + write(11,*)" shape_sin6_tg= ", shape_sin6_loc + write(11,*)" shape_s_sin6_tg= ", shape_s_sin6_loc + write(11,*)" shape_cos0_tg= ", shape_cos0_loc + write(11,*)" shape_s_cos0_tg= ", shape_s_cos0_loc + write(11,*)" shape_cos1_tg= ", shape_cos1_loc + write(11,*)" shape_s_cos1_tg= ", shape_s_cos1_loc + write(11,*)" shape_cos2_tg= ", shape_cos2_loc + write(11,*)" shape_s_cos2_tg= ", shape_s_cos2_loc + write(11,*)" shape_cos3_tg= ", shape_cos3_loc + write(11,*)" shape_s_cos3_tg= ", shape_s_cos3_loc + write(11,*)" shape_cos4_tg= ", shape_cos4_loc + write(11,*)" shape_s_cos4_tg= ", shape_s_cos4_loc + write(11,*)" shape_cos5_tg= ", shape_cos5_loc + write(11,*)" shape_s_cos5_tg= ", shape_s_cos5_loc + write(11,*)" shape_cos6_tg= ", shape_cos6_loc + write(11,*)" shape_s_cos6_tg= ", shape_s_cos6_loc write(11,*)" q_tg= ",q_loc write(11,*)" p_prime_tg= ",p_prime_loc write(11,*)" q_prime_tg= ",q_prime_loc diff --git a/tglf/src/tglf_interface.f90 b/tglf/src/tglf_interface.f90 index a70bdeffd..f75cb3c8a 100644 --- a/tglf/src/tglf_interface.f90 +++ b/tglf/src/tglf_interface.f90 @@ -161,6 +161,28 @@ module tglf_interface real :: tglf_s_delta_loc_in = 0.0 real :: tglf_zeta_loc_in = 0.0 real :: tglf_s_zeta_loc_in = 0.0 + real :: tglf_shape_sin3_loc_in = 0.0 + real :: tglf_shape_s_sin3_loc_in = 0.0 + real :: tglf_shape_sin4_loc_in = 0.0 + real :: tglf_shape_s_sin4_loc_in = 0.0 + real :: tglf_shape_sin5_loc_in = 0.0 + real :: tglf_shape_s_sin5_loc_in = 0.0 + real :: tglf_shape_sin6_loc_in = 0.0 + real :: tglf_shape_s_sin6_loc_in = 0.0 + real :: tglf_shape_cos0_loc_in = 0.0 + real :: tglf_shape_s_cos0_loc_in = 0.0 + real :: tglf_shape_cos1_loc_in = 0.0 + real :: tglf_shape_s_cos1_loc_in = 0.0 + real :: tglf_shape_cos2_loc_in = 0.0 + real :: tglf_shape_s_cos2_loc_in = 0.0 + real :: tglf_shape_cos3_loc_in = 0.0 + real :: tglf_shape_s_cos3_loc_in = 0.0 + real :: tglf_shape_cos4_loc_in = 0.0 + real :: tglf_shape_s_cos4_loc_in = 0.0 + real :: tglf_shape_cos5_loc_in = 0.0 + real :: tglf_shape_s_cos5_loc_in = 0.0 + real :: tglf_shape_cos6_loc_in = 0.0 + real :: tglf_shape_s_cos6_loc_in = 0.0 real :: tglf_q_loc_in = 2.0 real :: tglf_q_prime_loc_in = 16.0 real :: tglf_p_prime_loc_in = 0.0 @@ -356,6 +378,28 @@ subroutine tglf_dump_local() write(1,30) 'S_DELTA_LOC',tglf_s_delta_loc_in write(1,30) 'ZETA_LOC',tglf_zeta_loc_in write(1,30) 'S_ZETA_LOC',tglf_s_zeta_loc_in + write(1,30) 'SHAPE_SIN3',tglf_shape_sin3_loc_in + write(1,30) 'SHAPE_S_SIN3',tglf_shape_s_sin3_loc_in + write(1,30) 'SHAPE_SIN4',tglf_shape_sin4_loc_in + write(1,30) 'SHAPE_S_SIN4',tglf_shape_s_sin4_loc_in + write(1,30) 'SHAPE_SIN5',tglf_shape_sin5_loc_in + write(1,30) 'SHAPE_S_SIN5',tglf_shape_s_sin5_loc_in + write(1,30) 'SHAPE_SIN6',tglf_shape_sin6_loc_in + write(1,30) 'SHAPE_S_SIN6',tglf_shape_s_sin6_loc_in + write(1,30) 'SHAPE_COS0',tglf_shape_cos0_loc_in + write(1,30) 'SHAPE_S_COS0',tglf_shape_s_cos0_loc_in + write(1,30) 'SHAPE_COS1',tglf_shape_cos1_loc_in + write(1,30) 'SHAPE_S_COS1',tglf_shape_cos1_loc_in + write(1,30) 'SHAPE_COS2',tglf_shape_cos2_loc_in + write(1,30) 'SHAPE_S_COS2',tglf_shape_cos2_loc_in + write(1,30) 'SHAPE_COS3',tglf_shape_cos3_loc_in + write(1,30) 'SHAPE_S_COS3',tglf_shape_cos3_loc_in + write(1,30) 'SHAPE_COS4',tglf_shape_cos4_loc_in + write(1,30) 'SHAPE_S_COS4',tglf_shape_s_cos4_loc_in + write(1,30) 'SHAPE_COS5',tglf_shape_cos5_loc_in + write(1,30) 'SHAPE_S_COS5',tglf_shape_cos5_loc_in + write(1,30) 'SHAPE_COS6',tglf_shape_cos6_loc_in + write(1,30) 'SHAPE_S_COS6',tglf_shape_cos6_loc_in write(1,30) 'P_PRIME_LOC',tglf_p_prime_loc_in write(1,30) 'Q_PRIME_LOC',tglf_q_prime_loc_in write(1,30) 'BETA_LOC',tglf_beta_loc_in diff --git a/tglf/src/tglf_modules.f90 b/tglf/src/tglf_modules.f90 index 4effd7f0b..12c6beba5 100644 --- a/tglf/src/tglf_modules.f90 +++ b/tglf/src/tglf_modules.f90 @@ -163,6 +163,28 @@ MODULE tglf_global REAL :: s_delta_loc=0.0 REAL :: zeta_loc=0.0 REAL :: s_zeta_loc=0.0 + REAL :: shape_sin3_loc=0.0 + REAL :: shape_s_sin3_loc=0.0 + REAL :: shape_sin4_loc=0.0 + REAL :: shape_s_sin4_loc=0.0 + REAL :: shape_sin5_loc=0.0 + REAL :: shape_s_sin5_loc=0.0 + REAL :: shape_sin6_loc=0.0 + REAL :: shape_s_sin6_loc=0.0 + REAL :: shape_cos0_loc=0.0 + REAL :: shape_s_cos0_loc=0.0 + REAL :: shape_cos1_loc=0.0 + REAL :: shape_s_cos1_loc=0.0 + REAL :: shape_cos2_loc=0.0 + REAL :: shape_s_cos2_loc=0.0 + REAL :: shape_cos3_loc=0.0 + REAL :: shape_s_cos3_loc=0.0 + REAL :: shape_cos4_loc=0.0 + REAL :: shape_s_cos4_loc=0.0 + REAL :: shape_cos5_loc=0.0 + REAL :: shape_s_cos5_loc=0.0 + REAL :: shape_cos6_loc=0.0 + REAL :: shape_s_cos6_loc=0.0 REAL :: p_prime_loc=0.0 REAL :: q_prime_loc=16.0 REAL :: beta_loc = 0.0 @@ -849,6 +871,28 @@ MODULE tglf_tg REAL :: s_delta_tg=0.0 REAL :: s_kappa_tg=0.0 REAL :: s_zeta_tg=0.0 + REAL :: shape_sin3_tg=0.0 + REAL :: shape_s_sin3_tg=0.0 + REAL :: shape_sin4_tg=0.0 + REAL :: shape_s_sin4_tg=0.0 + REAL :: shape_sin5_tg=0.0 + REAL :: shape_s_sin5_tg=0.0 + REAL :: shape_sin6_tg=0.0 + REAL :: shape_s_sin6_tg=0.0 + REAL :: shape_cos0_tg=0.0 + REAL :: shape_s_cos0_tg=0.0 + REAL :: shape_cos1_tg=0.0 + REAL :: shape_s_cos1_tg=0.0 + REAL :: shape_cos2_tg=0.0 + REAL :: shape_s_cos2_tg=0.0 + REAL :: shape_cos3_tg=0.0 + REAL :: shape_s_cos3_tg=0.0 + REAL :: shape_cos4_tg=0.0 + REAL :: shape_s_cos4_tg=0.0 + REAL :: shape_cos5_tg=0.0 + REAL :: shape_s_cos5_tg=0.0 + REAL :: shape_cos6_tg=0.0 + REAL :: shape_s_cos6_tg=0.0 REAL :: q_prime_tg=0.0 REAL :: p_prime_tg=0.0 REAL :: kx0_tg=0.0 @@ -873,6 +917,12 @@ MODULE tglf_tg rmin_tg, rmaj_tg, zmaj_tg,use_bisection_tg,vpar_tg, & q_tg, xnue_tg, wd_zero_tg, betae_tg, shat_tg, alpha_tg, & xwell_tg,kappa_tg,s_kappa_tg,delta_tg,s_delta_tg,zeta_tg,s_zeta_tg, & + shape_sin3_tg, shape_s_sin3_tg, shape_sin4_tg, shape_s_sin4_tg, & + shape_sin5_tg, shape_s_sin5_tg, shape_sin6_tg, shape_s_sin6_tg, & + shape_cos0_tg, shape_s_cos0_tg, shape_cos1_tg, shape_s_cos1_tg, & + shape_cos2_tg, shape_s_cos2_tg, shape_cos3_tg, shape_s_cos3_tg, & + shape_cos4_tg, shape_s_cos4_tg, shape_cos5_tg, shape_s_cos5_tg, & + shape_cos6_tg, shape_s_cos6_tg, & drmindx_tg,drmajdx_tg,dzmajdx_tg,zeff_tg, debye_tg, use_bper_tg, & use_bpar_tg,use_mhd_rule_tg,q_prime_tg,damp_psi_tg,damp_sig_tg, & p_prime_tg, filter_tg, Linsker_factor_tg, gradB_factor_tg, & diff --git a/tglf/src/tglf_multiscale_spectrum.f90 b/tglf/src/tglf_multiscale_spectrum.f90 index b60bf3bed..0947ea587 100644 --- a/tglf/src/tglf_multiscale_spectrum.f90 +++ b/tglf/src/tglf_multiscale_spectrum.f90 @@ -444,12 +444,13 @@ SUBROUTINE get_multiscale_spectrum field_spectrum_out(2,j,i) = 0.0 if(gamma0.gt.small) then if (ky0 <= kT) then - if(YTs(i)==0.0 .OR. kP>=kT)then + if(kP>=kT)then field_spectrum_out(2,j,i) = 0.0 else if (ky0 <= kP) then ! initial quadratic sig_ratio = (aoverb * (ky0 ** 2) + ky0 + coverb) / (aoverb * (k0 ** 2) + k0 + coverb) field_spectrum_out(2,j,i) = Ys(i) * (sig_ratio ** c_1) * Fky *(eigenvalue_spectrum_out(1,j,i)/gamma0)**(2 * expsub) else ! connecting quadratic + if(YTs(i)==0.0)YTs(i)=1.0E-5 doversig0 = ((Ys(i) / YTs(i))**(1.0/abs(c_1)))- & ((aoverb*(kP**2)+kP+coverb-((kP-kT)*(2*aoverb*kP+1)))/(aoverb*(k0**2)+k0+coverb)) doversig0 = doversig0 * (1.0/((kP-kT)**2)) diff --git a/tglf/src/tglf_read_input.f90 b/tglf/src/tglf_read_input.f90 index 679ffd9f2..c3a5d3515 100644 --- a/tglf/src/tglf_read_input.f90 +++ b/tglf/src/tglf_read_input.f90 @@ -190,6 +190,28 @@ subroutine tglf_read_input read(1,*) tglf_s_delta_loc_in read(1,*) tglf_zeta_loc_in read(1,*) tglf_s_zeta_loc_in + read(1,*) tglf_shape_cos0_loc_in + read(1,*) tglf_shape_s_cos0_loc_in + read(1,*) tglf_shape_cos1_loc_in + read(1,*) tglf_shape_s_cos1_loc_in + read(1,*) tglf_shape_cos2_loc_in + read(1,*) tglf_shape_s_cos2_loc_in + read(1,*) tglf_shape_cos3_loc_in + read(1,*) tglf_shape_s_cos3_loc_in + read(1,*) tglf_shape_cos4_loc_in + read(1,*) tglf_shape_s_cos4_loc_in + read(1,*) tglf_shape_cos5_loc_in + read(1,*) tglf_shape_s_cos5_loc_in + read(1,*) tglf_shape_cos6_loc_in + read(1,*) tglf_shape_s_cos6_loc_in + read(1,*) tglf_shape_sin3_loc_in + read(1,*) tglf_shape_s_sin3_loc_in + read(1,*) tglf_shape_sin4_loc_in + read(1,*) tglf_shape_s_sin4_loc_in + read(1,*) tglf_shape_sin5_loc_in + read(1,*) tglf_shape_s_sin5_loc_in + read(1,*) tglf_shape_sin6_loc_in + read(1,*) tglf_shape_s_sin6_loc_in read(1,*) tglf_q_loc_in read(1,*) tglf_q_prime_loc_in read(1,*) tglf_p_prime_loc_in diff --git a/tglf/src/tglf_run.F90 b/tglf/src/tglf_run.F90 index fdbe33a75..f0d9622bb 100644 --- a/tglf/src/tglf_run.F90 +++ b/tglf/src/tglf_run.F90 @@ -111,6 +111,28 @@ subroutine tglf_run() tglf_s_delta_loc_in, & tglf_zeta_loc_in, & tglf_s_zeta_loc_in, & + tglf_shape_sin3_loc_in, & + tglf_shape_s_sin3_loc_in, & + tglf_shape_sin4_loc_in, & + tglf_shape_s_sin4_loc_in, & + tglf_shape_sin5_loc_in, & + tglf_shape_s_sin5_loc_in, & + tglf_shape_sin6_loc_in, & + tglf_shape_s_sin6_loc_in, & + tglf_shape_cos0_loc_in, & + tglf_shape_s_cos0_loc_in, & + tglf_shape_cos1_loc_in, & + tglf_shape_s_cos1_loc_in, & + tglf_shape_cos2_loc_in, & + tglf_shape_s_cos2_loc_in, & + tglf_shape_cos3_loc_in, & + tglf_shape_s_cos3_loc_in, & + tglf_shape_cos4_loc_in, & + tglf_shape_s_cos4_loc_in, & + tglf_shape_cos5_loc_in, & + tglf_shape_s_cos5_loc_in, & + tglf_shape_cos6_loc_in, & + tglf_shape_s_cos6_loc_in, & tglf_q_loc_in, & tglf_q_prime_loc_in, & tglf_p_prime_loc_in, & diff --git a/tglf/tools/input/tglf02/out.tglf.prec b/tglf/tools/input/tglf02/out.tglf.prec index 727db957a..85deb3f69 100644 --- a/tglf/tools/input/tglf02/out.tglf.prec +++ b/tglf/tools/input/tglf02/out.tglf.prec @@ -1 +1 @@ - 71.623670671890324 + 70.851711653595530 diff --git a/tglf/tools/input/tglf02/out.tglf.run b/tglf/tools/input/tglf02/out.tglf.run index 3f8d1e37d..fb5f5b143 100644 --- a/tglf/tools/input/tglf02/out.tglf.run +++ b/tglf/tools/input/tglf02/out.tglf.run @@ -1,6 +1,7 @@ [Parsing data in input.tglf] no mpi D(R) = -0.0000E+00 D(I) = 0.0000E+00 + kinetic species = 2 non-kinetic species = 0 Gam/Gam_GB Q/Q_GB Q_low/Q_GB Pi/Pi_GB S/S_GB -elec -1.7988E+00 1.1609E+01 9.7591E+00 2.9572E-06 3.0467E+00 -ion1 -1.7988E+00 2.3297E+01 2.3361E+01 -1.3682E-04 -3.0467E+00 +elec -1.8002E+00 1.1546E+01 9.6965E+00 3.5870E-06 2.9850E+00 +ion1 -1.8002E+00 2.2973E+01 2.3036E+01 2.7380E-04 -2.9850E+00 diff --git a/tglf/tools/input/tglf02/out.tglf.version b/tglf/tools/input/tglf02/out.tglf.version index 8b16a48d8..954eb52b1 100644 --- a/tglf/tools/input/tglf02/out.tglf.version +++ b/tglf/tools/input/tglf02/out.tglf.version @@ -1,3 +1,3 @@ -53e1f02 -GFORTRAN_OSX_MACPORTS -Thu Jun 1 13:18:05 PDT 2017 +19387296 [2024-09-04] +OSX_MONTEREY +Mon Sep 16 16:37:05 EDT 2024 diff --git a/tgyro/Makefile b/tgyro/Makefile index 37ee6ae7b..358bc8239 100644 --- a/tgyro/Makefile +++ b/tgyro/Makefile @@ -9,6 +9,7 @@ export EXTRA_LIBS = \ ${GACODE_ROOT}/shared/nclass/nclass_lib.a \ ${GACODE_ROOT}/tglf/src/tglf_lib.a \ ${GACODE_ROOT}/cgyro/src/cgyro_lib.a \ + ${GACODE_ROOT}/qlgyro/src/qlgyro_lib.a \ ${GACODE_ROOT}/f2py/expro/expro_lib.a \ ${GACODE_ROOT}/f2py/geo/geo_lib.a \ ${GACODE_ROOT}/shared/math/math_lib.a \ @@ -21,6 +22,7 @@ all: cd ${GACODE_ROOT}/neo ; make cd ${GACODE_ROOT}/tglf ; make cd ${GACODE_ROOT}/cgyro ; make + cd ${GACODE_ROOT}/qlgyro ; make cd src ; make clean: diff --git a/tgyro/src/Makefile b/tgyro/src/Makefile index 42d431b7e..9e524fcb7 100644 --- a/tgyro/src/Makefile +++ b/tgyro/src/Makefile @@ -30,6 +30,7 @@ OBJECTS += tgyro_globals.o \ tgyro_ped.o \ tgyro_auxiliary_routines.o \ tgyro_catch_error.o \ + tgyro_cgyro_map.o \ tgyro_comm_setup.o \ tgyro_comm_sync.o \ tgyro_etgcrit.o \ diff --git a/tgyro/src/tgyro_auxiliary_routines.f90 b/tgyro/src/tgyro_auxiliary_routines.f90 index e291e630d..897d91f44 100644 --- a/tgyro/src/tgyro_auxiliary_routines.f90 +++ b/tgyro/src/tgyro_auxiliary_routines.f90 @@ -90,16 +90,15 @@ end function sigv real function sivukhin(x) - use math_constants - implicit none real, intent(in) :: x integer :: i - real :: f,dy,yi + real :: f,dy,yi,pi integer, parameter :: n=12 + pi = 4.0*atan(1.0) if (x > 0.1) then diff --git a/tgyro/src/tgyro_cgyro_map.f90 b/tgyro/src/tgyro_cgyro_map.f90 new file mode 100644 index 000000000..449c46061 --- /dev/null +++ b/tgyro/src/tgyro_cgyro_map.f90 @@ -0,0 +1,198 @@ + +!------------------------------------------------------------ +! tgyro_cgyro_map.f90 +! +! PURPOSE: +! Mapping from TGYRO internal variables to CGYRO interface. +!------------------------------------------------------------ + +subroutine tgyro_cgyro_map + + use tgyro_globals + use qlgyro_cgyro_interface + + implicit none + + integer :: i0, i_ion + real :: gamma_eb0 + real :: gamma_p0 + + integer :: qn_spec + real :: delta_n, delta_dn + ! call cgyro_init(lpath, gyro_comm) + + cgyro_profile_model_in = 1 + + !---------------------------------------------------------------- + ! Signs of toroidal magnetic field and current + cgyro_btccw_in = -1.0*signb + cgyro_btccw_in = -1.0*signb*signq + !---------------------------------------------------------------- + + !---------------------------------------------------------------- + ! Number of species (max=11) + cgyro_n_species_in = sum(calc_flag(1:loc_n_ion))+1 + + if (cgyro_n_species_in > 11) then + call tgyro_catch_error('ERROR: (tgyro_cgyro_map) Too many ions in CGYRO.') + endif + !---------------------------------------------------------------- + + !---------------------------------------------------------------- + ! Species loop: + ! + ! Quasieutrality enforcing + delta_n = 0.0 + delta_dn = 0.0 + qn_spec = -1 + + ! Charges: e,i,z + cgyro_z_in(1) = -1.0 + ! + ! Mass ratios: me/md,m(1)/md,m(2)/md, ... + ! [assume md is normalizing mass] + cgyro_mass_in(1) = (me*loc_me_multiplier)/md + ! + ! Density ratios: ne/ne,ni(1)/ne,ni(2)/ne, ... + cgyro_dens_in(1) = 1.0 + ! + ! Density gradients (e,i,z) + cgyro_dlnndr_in(1) = r_min*dlnnedr(i_r) + ! + ! Temperature gradients (e,i,z) + cgyro_dlntdr_in(1) = r_min*dlntedr(i_r) + ! + ! Temperature ratios: Te/Te,Ti(1)/Te,Ti(2)/Te + cgyro_temp_in(1) = 1.0 + if (evo_e(0) /= -1) then + delta_n = delta_n - 1.0 + delta_dn = delta_dn - 1.0*r_min*dlnnedr(i_r) + else + qn_spec = 1 + endif + + i0 = 1 + + do i_ion=1,loc_n_ion + if (calc_flag(i_ion) == 0) cycle + i0 = i0+1 + cgyro_z_in(i0) = zi_vec(i_ion) + cgyro_mass_in(i0) = mi_vec(i_ion) + cgyro_dens_in(i0) = ni(i_ion,i_r)/ne(i_r) + cgyro_dlnndr_in(i0) = r_min*dlnnidr(i_ion,i_r) + cgyro_dlntdr_in(i0) = r_min*dlntidr(i_ion,i_r) + cgyro_temp_in(i0) = ti(i_ion,i_r)/te(i_r) + + if (evo_e(i_ion) /= -1) then + delta_n = delta_n + zi_vec(i_ion) * ni(i_ion, i_r) / ne(i_r) + delta_dn = delta_dn + zi_vec(i_ion) * ni(i_ion, i_r) / ne(i_r) * r_min * dlnnidr(i_ion,i_r) + else + qn_spec = i0 + end if + end do + + ! Force quasineutrality + if (qn_spec .gt. 0) then + cgyro_dens_in(qn_spec) = -delta_n + cgyro_dlnndr_in(qn_spec) = delta_dn / delta_n + end if + + ! Setting density gradient artificially to zero to compute D and v + if (tgyro_zero_dens_grad_flag /= 0) then + cgyro_dlnndr_in(tgyro_zero_dens_grad_flag) = 0 + endif + + ! how to handle scaling of den, ti, te + ! cgyro_dlntdr_scale_in = tgyro_input_dlntdr_scale + + !---------------------------------------------------------------- + ! debye length/rhos te in ev, rho_s in cm ne in 10^13/cm^3 + cgyro_lambda_star_in = 7.43e2*sqrt(te(i_r)/(ne(i_r)))/abs(rho_s(i_r)) + + ! Model (Miller) shape + cgyro_equilibrium_model_in = 2 + + cgyro_rmin_in = r(i_r)/r_min + cgyro_rmaj_in = r_maj(i_r)/r_min + cgyro_zmag_in = zmag(i_r)/r_min + cgyro_shift_in = shift(i_r) + cgyro_dzmag_in = dzmag(i_r) + cgyro_kappa_in = kappa(i_r) + cgyro_s_kappa_in = s_kappa(i_r) + cgyro_delta_in = delta(i_r) + cgyro_s_delta_in = s_delta(i_r) + cgyro_zeta_in = zeta(i_r) + cgyro_s_zeta_in = s_zeta(i_r) + cgyro_q_in = q(i_r) + cgyro_s_in = s(i_r) + cgyro_shape_sin3_in = shape_sin3(i_r) + cgyro_shape_s_sin3_in = shape_ssin3(i_r) + cgyro_shape_cos0_in = shape_cos0(i_r) + cgyro_shape_s_cos0_in = shape_scos0(i_r) + cgyro_shape_cos1_in = shape_cos1(i_r) + cgyro_shape_s_cos1_in = shape_scos1(i_r) + cgyro_shape_cos2_in = shape_cos2(i_r) + cgyro_shape_s_cos2_in = shape_scos2(i_r) + cgyro_shape_cos3_in = shape_cos3(i_r) + cgyro_shape_s_cos3_in = shape_scos3(i_r) + + ! What should this be? + cgyro_beta_star_scale_in = 1.0 + + !---------------------------------------------------------------- + + !---------------------------------------------------------------- + ! Electron beta used for electromagnetic calculations + cgyro_betae_unit_in = betae_unit(i_r) + cgyro_betae_unit_scale_in = loc_betae_scale + !---------------------------------------------------------------- + !---------------------------------------------------------------- + ! Collisions: + ! + ! Electron collision frequency + cgyro_nu_ee_in = nue(i_r)*r_min/c_s(i_r) + cgyro_nu_ee_scale_in = loc_nu_scale + ! + ! Zeff + cgyro_z_eff_in = z_eff(i_r) + !---------------------------------------------------------------- + + !---------------------------------------------------------------- + ! Gamma_ExB (ExB shearing rate, units of a/cs) + if (tgyro_rotation_flag == 1) then + gamma_p0 = -r_maj(i_r)*f_rot(i_r)*w0_norm + gamma_eb0 = gamma_p0*r(i_r)/(q(i_r)*r_maj(i_r)) + ! Currently TGLF uses toroidal current as reference direction + ! Overall minus sign is due to TGYRO toroidal angle in CW direction + cgyro_gamma_e_in = -gamma_eb0*r_min/c_s(i_r) + cgyro_gamma_p_in = -gamma_p0*r_min/c_s(i_r) + cgyro_mach_in = -r_maj(i_r)*w0(i_r)/c_s(i_r) + else + + cgyro_gamma_e_in = 0.0 + cgyro_gamma_p_in = 0.0 + cgyro_mach_in = 0.0 + + endif + + ! cgyro_mach_scale_in = tgyro_w0_scale + + + !---------------------------------------------------------------- + ! CONTROL PARAMETERS + ! + if (loc_betae_scale <= 0.0) then + cgyro_n_field_in = 1 + endif + + cgyro_delta_t_method_in = 1 + + cgyro_b_unit_in = b_unit(i_r) + cgyro_a_meters_in = r_min + cgyro_temp_norm_in = te(i_r) + cgyro_dens_norm_in = ne(i_r) + cgyro_rho_star_norm_in = rho_s(i_r) / r_min + cgyro_vth_norm_in = c_s(i_r) + + +end subroutine tgyro_cgyro_map diff --git a/tgyro/src/tgyro_flux.f90 b/tgyro/src/tgyro_flux.f90 index ff61a3ca9..4273da0c0 100644 --- a/tgyro/src/tgyro_flux.f90 +++ b/tgyro/src/tgyro_flux.f90 @@ -237,6 +237,31 @@ subroutine tgyro_flux endif enddo mflux_i_tur(1,i_r) = (-mmm_chi_phi*w0p(i_r) + mmm_vgx_phi*w0(i_r))*r_min/c_s(i_r)/chi_gb(i_r) + + + case (8) + + ! Map TGYRO parameters to QLGYRO (TGLF+CGYRO) + call tgyro_cgyro_map + + call qlgyro_run(lpath, gyro_comm, i_tran) + + call tgyro_trap_component_error(tglf_error_status,tglf_error_message) + + pflux_e_tur(i_r) = tglf_elec_pflux_out + eflux_e_tur(i_r) = tglf_elec_eflux_out + mflux_e_tur(i_r) = -tglf_sign_It_in*tglf_elec_mflux_out + expwd_e_tur(i_r) = tglf_elec_expwd_out + + i0 = 0 + do i_ion=1,loc_n_ion + if (calc_flag(i_ion) == 0) cycle + i0 = i0+1 + pflux_i_tur(i_ion,i_r) = tglf_ion_pflux_out(i0) + eflux_i_tur(i_ion,i_r) = tglf_ion_eflux_out(i0) + mflux_i_tur(i_ion,i_r) = -tglf_sign_It_in*tglf_ion_mflux_out(i0) + expwd_i_tur(i_ion,i_r) = tglf_ion_expwd_out(i0) + enddo case default diff --git a/tgyro/src/tgyro_globals.f90 b/tgyro/src/tgyro_globals.f90 index 0a33a783a..c4d4ec05e 100644 --- a/tgyro/src/tgyro_globals.f90 +++ b/tgyro/src/tgyro_globals.f90 @@ -47,11 +47,11 @@ module tgyro_globals character(len=80), dimension(:), allocatable :: paths integer, dimension(:), allocatable :: procs real, dimension(:), allocatable :: inputrads - character(len=5), dimension(:), allocatable :: code + character(len=6), dimension(:), allocatable :: code ! character(80) :: lpath, linput integer :: lproc - character(len=5) :: lcode + character(len=6) :: lcode ! ! Control variables ! diff --git a/tgyro/src/tgyro_iteration_driver.f90 b/tgyro/src/tgyro_iteration_driver.f90 index 385e88760..69f948eb3 100644 --- a/tgyro/src/tgyro_iteration_driver.f90 +++ b/tgyro/src/tgyro_iteration_driver.f90 @@ -81,7 +81,13 @@ subroutine tgyro_iteration_driver ! Multi-Mode model gradient flux_method = 6 + else if (lcode == 'qlgyro') then + + ! QLGYRO + flux_method = 8 + endif + !--------------------------------------------- allocate(flux_method_vec(n_inst)) call MPI_ALLGATHER(flux_method,1,MPI_INTEGER,flux_method_vec,1,MPI_INTEGER,gyro_adj,ierr) diff --git a/tgyro/src/tgyro_read_input.f90 b/tgyro/src/tgyro_read_input.f90 index 42287431a..a155e4662 100644 --- a/tgyro/src/tgyro_read_input.f90 +++ b/tgyro/src/tgyro_read_input.f90 @@ -221,7 +221,7 @@ subroutine tgyro_read_input ierr) call MPI_BCAST(code,& - n_inst*5,& + n_inst*6,& MPI_CHARACTER,& 0,& MPI_COMM_WORLD,&