Added other scripts for scan on launching conditions (with beam)
This commit is contained in:
parent
e18281ad87
commit
5cfc903c98
125
scripts/gamma-beam.sh
Executable file
125
scripts/gamma-beam.sh
Executable file
@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set input/working/output folders
|
||||
in=/Users/lorenzo/Desktop/scenario_001
|
||||
work=/Users/lorenzo/Desktop/scenario_001/tmp
|
||||
out=/Users/lorenzo/Desktop/scenario_001/out2
|
||||
|
||||
# check if working folder exists, otherwise create it
|
||||
if [[ ! -e $work ]]; then
|
||||
mkdir $work
|
||||
else
|
||||
if [[ ! -d $work ]]; then
|
||||
echo $work is not a folder.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# move to working folder
|
||||
cd $work
|
||||
if [[ $? != 0 ]]; then
|
||||
echo Cannot move to $work
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if output folder exists, otherwise create it
|
||||
if [[ ! -e $out ]]; then
|
||||
mkdir $out
|
||||
else
|
||||
if [[ ! -d $out ]]; then
|
||||
echo $out is not a folder.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
listfile=$in/v0_22.txt
|
||||
# count number of lines in input file
|
||||
nlines=`wc -l $listfile | awk '{print $1}'`
|
||||
|
||||
eqfile=$in/F4E_Equil_10520.eqdsk
|
||||
# look for time value in equil file
|
||||
base=`basename $eqfile .eqdsk`
|
||||
tstr=`echo $base | grep "[[:digit:]]\{5\}" -o`
|
||||
t=`echo "$tstr-10000" | bc`
|
||||
# copy input files in working folder
|
||||
cp $eqfile ${base}.eqdsk
|
||||
cp $in/${base}.prf ${base}.prf
|
||||
|
||||
# set output file names
|
||||
id=${base}_8beams_gammascan
|
||||
f7file=$out/f7_${id}.txt
|
||||
f48file=$out/f48_${id}.txt
|
||||
rm -f $out/log_${id}.txt
|
||||
# add header in output files
|
||||
echo "# =============================" > $f7file
|
||||
echo "# `date`" >> $f7file
|
||||
echo "# Launching conditions: `basename $listfile`" >> $f7file
|
||||
echo "# time=$t" >> $f7file
|
||||
echo "# =============================" >> $f7file
|
||||
cp $f7file $f48file
|
||||
appendheader=0
|
||||
|
||||
#loop on lines of launching conditions table
|
||||
for (( iline=1; iline<=$nlines+1; iline++ )); do
|
||||
# search full, non-commented lines
|
||||
awkcommand='NR=='$iline' && NF>=13 {print $0}'
|
||||
line=`sed 's/#.*$//' $listfile | awk "$awkcommand"`
|
||||
if (( `echo $line | wc -w`>0 )); then
|
||||
# if valid line extract values
|
||||
ibeam=`echo $line | awk '{print $1}'`
|
||||
gamma=`echo $line | awk '{print -$2}'`
|
||||
alpha=`echo $line | awk '{print $3}'`
|
||||
beta=`echo $line | awk '{print $4}'`
|
||||
r0=`echo $line | awk '{print sqrt($5^2+$6^2)/10.0}'`
|
||||
z0=`echo $line | awk '{print $7/10.0}'`
|
||||
w1=`echo $line | awk '{print $8/10.0}'`
|
||||
w2=`echo $line | awk '{print $9/10.0}'`
|
||||
rci1=`echo $line | awk '{print $10*10.0}'`
|
||||
rci2=`echo $line | awk '{print $11*10.0}'`
|
||||
phiw=`echo $line | awk '{print $12}'`
|
||||
phir=`echo $line | awk '{print $13}'`
|
||||
# extract k0 from gray input file
|
||||
k0=`awk 'NR==2 {print $1*8.0*atan2(1,1)/29.9792}' $in/gray0beam.data`
|
||||
k0sqov4=`echo "0.25*$k0^2" | bc -l`
|
||||
# compute w0,d from w,1/Rc
|
||||
w0x=`echo " $w1 /sqrt(1+$k0sqov4*$w1^4*$rci1^2)" | bc -l`
|
||||
d0x=`echo "-($k0sqov4*$rci1*$w1^4) / (1+$k0sqov4*$w1^4*$rci1^2)" | bc -l`
|
||||
w0y=`echo " $w2 /sqrt(1+$k0sqov4*$w2^4*$rci2^2)" | bc -l`
|
||||
d0y=`echo "-($k0sqov4*$rci2*$w2^4) / (1+$k0sqov4*$w2^4*$rci2^2)" | bc -l`
|
||||
awr=$phiw
|
||||
# replace dummy values in template for gray.data
|
||||
sed "s/-alfa-/$alpha/g; s/-beta-/$beta/g; \
|
||||
s/-x0-/$r0/g; s/-z0-/$z0/g; \
|
||||
s/-w0x-/$w0x/g; s/-w0y-/$w0y/g; \
|
||||
s/-p0x-/$d0x/g; s/-p0y-/$d0y/g; \
|
||||
s/-awr-/$awr/g; \
|
||||
s/-equil-/$base/g; s/-prf-/$base/g" $in/gray0beam.data > gray.data
|
||||
# run gray
|
||||
gray >> $out/log_${id}.txt
|
||||
if (( $appendheader==0 )); then
|
||||
# append parameters to header if first run of the loop
|
||||
cat headers.txt >> $f7file
|
||||
cat headers.txt >> $f48file
|
||||
echo "#beam dgamma`head -n 1 fort.7 | sed 's/#//'`" >> $f7file
|
||||
echo "#beam dgamma`head -n 1 fort.48 | sed 's/#//'`" >> $f48file
|
||||
appendheader=1
|
||||
fi
|
||||
# add beam number and gamma values in first two columns
|
||||
awk 'NR>1 {print '$ibeam','$gamma',$0}' fort.7 >> $f7file
|
||||
awk 'NR>1 {print '$ibeam','$gamma',$0}' fort.48 >> $f48file
|
||||
echo "" >> $f48file
|
||||
else
|
||||
# if first block of data has already been written
|
||||
if (( $appendheader==1 )); then
|
||||
# write blank line in output when invalid (blank) line is found in input
|
||||
echo "" >> $f7file
|
||||
echo "" >> $f48file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
#end of launching conditions loop
|
||||
|
||||
# remove files from working folder
|
||||
rm -f ${base}.eqdsk ${base}.prf fort.*
|
||||
|
||||
exit 0
|
||||
#EOF
|
118
scripts/gamma-beam2.sh
Executable file
118
scripts/gamma-beam2.sh
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set input/working/output folders
|
||||
in=/Users/lorenzo/Desktop/scenario_001
|
||||
work=/Users/lorenzo/Desktop/scenario_001/tmp
|
||||
out=/Users/lorenzo/Desktop/scenario_001/out2
|
||||
|
||||
# check if working folder exists, otherwise create it
|
||||
if [[ ! -e $work ]]; then
|
||||
mkdir $work
|
||||
else
|
||||
if [[ ! -d $work ]]; then
|
||||
echo $work is not a folder.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# move to working folder
|
||||
cd $work
|
||||
if [[ $? != 0 ]]; then
|
||||
echo Cannot move to $work
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if output folder exists, otherwise create it
|
||||
if [[ ! -e $out ]]; then
|
||||
mkdir $out
|
||||
else
|
||||
if [[ ! -d $out ]]; then
|
||||
echo $out is not a folder.
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
listfile=$in/v0_22.txt
|
||||
# count number of lines in input file
|
||||
nlines=`wc -l $listfile | awk '{print $1}'`
|
||||
|
||||
eqfile=$in/F4E_Equil_10520.eqdsk
|
||||
# look for time value in equil file
|
||||
base=`basename $eqfile .eqdsk`
|
||||
tstr=`echo $base | grep "[[:digit:]]\{5\}" -o`
|
||||
t=`echo "$tstr-10000" | bc`
|
||||
# copy input files in working folder
|
||||
cp $eqfile ${base}.eqdsk
|
||||
cp $in/${base}.prf ${base}.prf
|
||||
|
||||
# set temporary file names
|
||||
beambase="tmpbeam"
|
||||
beamfile=${beambase}.txt
|
||||
|
||||
# set output file names
|
||||
id=t${t}_scan_`basename $listfile .txt`
|
||||
f7file=$out/f7_${id}.txt
|
||||
f48file=$out/f48_${id}.txt
|
||||
rm -f $out/log_${id}.txt
|
||||
# add header in output files
|
||||
echo "# =============================" > $f7file
|
||||
echo "# `date`" >> $f7file
|
||||
echo "# Launching conditions: `basename $listfile`" >> $f7file
|
||||
echo "# time=$t" >> $f7file
|
||||
echo "# =============================" >> $f7file
|
||||
cp $f7file $f48file
|
||||
appendheader=0
|
||||
|
||||
#loop on lines of launching conditions table
|
||||
for (( iline=1; iline<=$nlines+1; iline++ )); do
|
||||
# search full, non-commented lines
|
||||
awkcommand='NR=='$iline' && NF>=13 {print $0}'
|
||||
line=`sed 's/#.*$//' $listfile | awk "$awkcommand"`
|
||||
if (( `echo $line | wc -w`>0 )); then
|
||||
# if valid line extract values
|
||||
ibeam=`echo $line | awk '{print $1}'`
|
||||
gamma=`echo $line | awk '{print -$2}'`
|
||||
alpha=`echo $line | awk '{print $3}'`
|
||||
beta=`echo $line | awk '{print $4}'`
|
||||
r0=`echo $line | awk '{print sqrt($5^2+$6^2)/10.0}'`
|
||||
z0=`echo $line | awk '{print $7/10.0}'`
|
||||
# create file for beam description to be read by gray
|
||||
echo 2 > $beamfile
|
||||
echo $line | \
|
||||
awk '{print -$2,$3-0.1,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}' >> $beamfile
|
||||
echo $line | \
|
||||
awk '{print -$2,$3+0.1,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}' >> $beamfile
|
||||
# replace dummy values in template for gray.data
|
||||
sed "s/-alfa-/$alpha/g; s/-beta-/$beta/g; \
|
||||
s/-x0-/$r0/g; s/-z0-/$z0/g; \
|
||||
s/-beam-/$beambase/g; \
|
||||
s/-equil-/$base/g; s/-prf-/$base/g" $in/gray0beam2.data > gray.data
|
||||
# run gray
|
||||
gray >> $out/log_${id}.txt
|
||||
if (( $appendheader==0 )); then
|
||||
# append parameters to header if first run of the loop
|
||||
cat headers.txt >> $f7file
|
||||
cat headers.txt >> $f48file
|
||||
echo "#beam dgamma`head -n 1 fort.7 | sed 's/#//'`" >> $f7file
|
||||
echo "#beam dgamma`head -n 1 fort.48 | sed 's/#//'`" >> $f48file
|
||||
appendheader=1
|
||||
fi
|
||||
# add beam number and gamma values in first two columns
|
||||
awk 'NR>1 {print '$ibeam','$gamma',$0}' fort.7 >> $f7file
|
||||
awk 'NR>1 {print '$ibeam','$gamma',$0}' fort.48 >> $f48file
|
||||
echo "" >> $f48file
|
||||
else
|
||||
# if first block of data has already been written
|
||||
if (( $appendheader==1 )); then
|
||||
# write blank line in output when invalid (blank) line is found in input
|
||||
echo "" >> $f7file
|
||||
echo "" >> $f48file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
#end of launching conditions loop
|
||||
|
||||
# remove files from working folder
|
||||
rm -f ${base}.eqdsk ${base}.prf $beamfile fort.*
|
||||
|
||||
exit 0
|
||||
#EOF
|
28
scripts/gray0beam.data
Normal file
28
scripts/gray0beam.data
Normal file
@ -0,0 +1,28 @@
|
||||
-alfa- -beta- : alfac, betac poloidal and toroidal launching angles
|
||||
170 : f (GHz)
|
||||
1 : P0 (MW) injected power
|
||||
11 16 1 : nray ktx,rhomx
|
||||
-x0- 0. -z0- : x00 y00 z00 (cm) mirror position (y00=0 !)
|
||||
-w0x- -w0y- -p0x- -p0y- -awr- : w0xt w0yt pw0xt pw0yt awr (cm) [pw0>0 towards plasma]
|
||||
0 : ibeam=0 uses data above, >0 read from file beam data (1,2,3)
|
||||
mpusm : filename.txt for beam data max(character*16)
|
||||
2 0 : iequil= 0 vacuum, 1 analytical equilibrium, 2 EQDSK;indXpoint
|
||||
1 : iprof= 0/1 analytical/numerical dens & temp profiles
|
||||
2 5 : iwarm= 0-3 ECRH&CD computation, ilarm order of larmor expans
|
||||
11 : ieccd 0/1 NO/YES ECCD calculation
|
||||
1 2001 : ipec=0/1 profiles in dpsi/drhop; nnd=no. intervals +1 (=< 501)
|
||||
.2 8000 100 5 0 : dst (cm), nsteps < = 8000, istprj,istpl,ist (0,1,2 integration in s,ct,Sr)
|
||||
1 1 4.04 : igrad (0 rtr - 1 gauss beam), ipass=1/2 passes in plasma, R_wall(m)
|
||||
1 0 0 : IOX = 1 : O-MODE IOX = 2 : X-MODE, psi_pol_ant chi_pol_ant
|
||||
-equil- : filename EQDSK : filename.eqdsk max(character 16)
|
||||
0 0.001 : ipsinorm =0/1 [psi normalized (1) or not (0) in EQDSK], sspl spline coeff psi
|
||||
1 1 1 1 : factb, iscal=0/1/2 nustar=const/ngreenw=const/no_scal, factT factn scal.
|
||||
-prf- : filename profiles : filename.prf max(character*16)
|
||||
1.015 : psi plasma boundary
|
||||
-1 -1 11 : signum B_phi I_phi +1=counterclockwise , -1=clockwise from above, icocos (0 old case, 11 iter)
|
||||
8 4 4 : dens190 aln1,aln2 (10^19 m-3)
|
||||
15 0 2 4 : te0,dte0,alt1,alt2 (keV)
|
||||
2 : Zeff
|
||||
620 0 180 : rr0 zr0 a (cm)
|
||||
5.3 : b0 (T)
|
||||
1 3 2 : q0,qa alq
|
28
scripts/gray0beam2.data
Normal file
28
scripts/gray0beam2.data
Normal file
@ -0,0 +1,28 @@
|
||||
-alfa- -beta- : alfac, betac poloidal and toroidal launching angles
|
||||
170 : f (GHz)
|
||||
1 : P0 (MW) injected power
|
||||
11 16 1 : nray ktx,rhomx
|
||||
-x0- 0. -z0- : x00 y00 z00 (cm) mirror position (y00=0 !)
|
||||
2.1 2.1 162 162 0 : w0xt w0yt pw0xt pw0yt awr (cm) [pw0>0 towards plasma]
|
||||
2 : ibeam=0 uses data above, >0 read from file beam data (1,2,3)
|
||||
-beam- : filename.txt for beam data max(character*16)
|
||||
2 0 : iequil= 0 vacuum, 1 analytical equilibrium, 2 EQDSK;indXpoint
|
||||
1 : iprof= 0/1 analytical/numerical dens & temp profiles
|
||||
2 5 : iwarm= 0-3 ECRH&CD computation, ilarm order of larmor expans
|
||||
11 : ieccd 0/1 NO/YES ECCD calculation
|
||||
1 2001 : ipec=0/1 profiles in dpsi/drhop; nnd=no. intervals +1 (=< 501)
|
||||
.2 8000 100 5 0 : dst (cm), nsteps < = 8000, istprj,istpl,ist (0,1,2 integration in s,ct,Sr)
|
||||
1 1 4.04 : igrad (0 rtr - 1 gauss beam), ipass=1/2 passes in plasma, R_wall(m)
|
||||
1 0 0 : IOX = 1 : O-MODE IOX = 2 : X-MODE, psi_pol_ant chi_pol_ant
|
||||
-equil- : filename EQDSK : filename.eqdsk max(character 16)
|
||||
0 0.001 : ipsinorm =0/1 [psi normalized (1) or not (0) in EQDSK], sspl spline coeff psi
|
||||
1 1 1 1 : factb, iscal=0/1/2 nustar=const/ngreenw=const/no_scal, factT factn scal.
|
||||
-prf- : filename profiles : filename.prf max(character*16)
|
||||
1.015 : psi plasma boundary
|
||||
-1 -1 11 : signum B_phi I_phi +1=counterclockwise , -1=clockwise from above, icocos (0 old case, 11 iter)
|
||||
8 4 4 : dens190 aln1,aln2 (10^19 m-3)
|
||||
15 0 2 4 : te0,dte0,alt1,alt2 (keV)
|
||||
2 : Zeff
|
||||
620 0 180 : rr0 zr0 a (cm)
|
||||
5.3 : b0 (T)
|
||||
1 3 2 : q0,qa alq
|
Loading…
Reference in New Issue
Block a user