#!/bin/sh # update_input input.lpi input.lpi.save path="$(dirname $0)" # neuer Wert: # okey -> Name des Schlüssels # obam -> Name des neuen Wertes # olin -> einzufügende Zeile # obnam -> Name des darüberliegenden Wertes okey[0]="lramp" onam[0]="form" olin[0]="form = 0 # 0 = linear; 1 = exponential" obnam[0]="length" okey[1]="lramp" onam[1]="length" olin[1]="length = 0 # cells in the linear ramp region (form=0) or scalelength" obnam[1]="------------------------------------------------------------------------------------------" okey[2]="lramp" onam[2]="length2" olin[2]="length2 = 100 # lefter scale length (form=2)" obnam[2]="form" okey[3]="lramp" onam[3]="cutoff" olin[3]="cutoff = -1 # max ramplength (<0 <=> disabled)" obnam[3]="length2" okey[4]="lramp" onam[4]="gluepos" olin[4]="gluepos = 250 # glue-point between the two exp-functions (form=2) ... length of the righter exp-ramp" obnam[4]="cutoff" okey[5]="rramp" onam[5]="length" olin[5]="length = 0 # cells in the linear ramp region (form=0) or scalelength" obnam[5]="------------------------------------------------------------------------------------------" okey[6]="rramp" onam[6]="form" olin[6]="form = 0 # 0 = linear; 1 = exponential" obnam[6]="length" okey[7]="rramp" onam[7]="length2" olin[7]="length2 = 100 # righter scale length (form=2)" obnam[7]="form" okey[8]="rramp" onam[8]="cutoff" olin[8]="cutoff = -1 # max ramplength (<0 <=> disabled)" obnam[8]="length2" okey[9]="rramp" onam[9]="gluepos" olin[9]="gluepos = 250 # glue-point between the two exp-functions (form=2) ... length of the lefter exp-ramp" obnam[9]="cutoff" okey[10]="box" onam[10]="ux0" olin[10]="ux0 = 0.0 # initial momentum in x-direction" obnam[10]="n_ion_over_nc" okey[11]="etx" onam[11]="Q" olin[11]=" Q = 0 # thermal x-energy plots?" obnam[11]="------------------------------------------------------------------------------------------" okey[12]="etx" onam[12]="t_start" olin[12]=" t_start = 0 # start time in periods" obnam[12]="Q" okey[13]="etx" onam[13]="t_stop" olin[13]=" t_stop = 60 # stop time in periods" obnam[13]="t_start" okey[14]="etx" onam[14]="x_start" olin[14]=" x_start = 0 # left boundary in cells" obnam[14]="t_stop" okey[15]="etx" onam[15]="x_stop" olin[15]=" x_stop = 100000 # right boundary in cells" obnam[15]="x_start" okey[16]="ety" onam[16]="Q" olin[16]=" Q = 0 # thermal y-energy plots?" obnam[16]="------------------------------------------------------------------------------------------" okey[17]="ety" onam[17]="t_start" olin[17]=" t_start = 0 # start time in periods" obnam[17]="Q" okey[18]="ety" onam[18]="t_stop" olin[18]=" t_stop = 60 # stop time in periods" obnam[18]="t_start" okey[19]="ety" onam[19]="x_start" olin[19]=" x_start = 0 # left boundary in cells" obnam[19]="t_stop" okey[20]="ety" onam[20]="x_stop" olin[20]=" x_stop = 100000 # right boundary in cells" obnam[20]="x_start" okey[21]="etz" onam[21]="Q" olin[21]=" Q = 0 # thermal z-energy plots?" obnam[21]="------------------------------------------------------------------------------------------" okey[22]="etz" onam[22]="t_start" olin[22]=" t_start = 0 # start time in periods" obnam[22]="Q" okey[23]="etz" onam[23]="t_stop" olin[23]=" t_stop = 60 # stop time in periods" obnam[23]="t_start" okey[24]="etz" onam[24]="x_start" olin[24]=" x_start = 0 # left boundary in cells" obnam[24]="t_stop" okey[25]="etz" onam[25]="x_stop" olin[25]=" x_stop = 100000 # right boundary in cells" obnam[25]="x_start" okey[26]="lramp" onam[26]="middens" olin[26]="middens = 0.5 # density of the constant portion in the middle (form=3) in fractions of ni" obnam[26]="gluepos" okey[27]="rramp" onam[27]="middens" olin[27]="middens = 0.5 # density of the constant portion in the middle (form=3) in fractions of ni" obnam[27]="gluepos" for i in 0 1 do if [ ${i} -eq 0 ] then s="front" else s="rear" fi for j in 0 1 2 3 do okey[28+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+36*${i}+9*${j}]="amplitude" olin[28+36*${i}+9*${j}]="amplitude = 0 # dimensionless laser field amplitude" obnam[28+36*${i}+9*${j}]="Q" okey[28+1+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+1+36*${i}+9*${j}]="polarization" olin[28+1+36*${i}+9*${j}]="polarization = 2 # s=1, p=2, c=3" obnam[28+1+36*${i}+9*${j}]="amplitude" okey[28+2+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+2+36*${i}+9*${j}]="shape" olin[28+2+36*${i}+9*${j}]="shape = 3 # linear=1, sin=2, sin^2=3" obnam[28+2+36*${i}+9*${j}]="polarization" okey[28+3+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+3+36*${i}+9*${j}]="raise" olin[28+3+36*${i}+9*${j}]="raise = 15 # pulse raise/fall time in periods" obnam[28+3+36*${i}+9*${j}]="polarization" okey[28+4+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+4+36*${i}+9*${j}]="duration" olin[28+4+36*${i}+9*${j}]="duration = 30 # pulse duration in fundamental periods" obnam[28+4+36*${i}+9*${j}]="raise" okey[28+5+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+5+36*${i}+9*${j}]="delay" olin[28+5+36*${i}+9*${j}]="delay = 0 # propagation delay in cycles" obnam[28+5+36*${i}+9*${j}]="duration" okey[28+6+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+6+36*${i}+9*${j}]="phase" olin[28+6+36*${i}+9*${j}]="phase = 0 # propagation delay in cycles" obnam[28+6+36*${i}+9*${j}]="delay" okey[28+7+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+7+36*${i}+9*${j}]="chirp" olin[28+7+36*${i}+9*${j}]="chirp = 0 # linear chirp (dw/dt) in 2 pi T^-2" obnam[28+7+36*${i}+9*${j}]="phase" okey[28+8+36*${i}+9*${j}]="pulse_${s}_part_${j}" onam[28+8+36*${i}+9*${j}]="frequency" olin[28+8+36*${i}+9*${j}]="frequency = $[${j}+1] # frequency in fundamental frequencies" obnam[28+8+36*${i}+9*${j}]="chirp" done done # Neuer Schlüssel: # nkey -> Name des neuen Schlüssels # nakey -> Name des folgenden Schlüssels nkey[0]="&rramp" nakey[0]="&electrons" nkey[1]="&lramp" nakey[1]="&rramp" nkey[2]="&etz" nakey[2]="&edens" nkey[3]="&ety" nakey[3]="&etz" nkey[4]="&etx" nakey[4]="&ety" s="&pulse_rear" for i in 3 2 1 0 do nakey[$[8-${i}]]="$s" s="&pulse_front_part_${i}" nkey[$[8-${i}]]="$s" done s="&propagate" for i in 3 2 1 0 do nakey[$[12-${i}]]="$s" s="&pulse_rear_part_${i}" nkey[$[12-${i}]]="$s" done # umzuziehende Werte: # toky -> alter Schlüssel # tnky -> neuer Schlüssel # tonm -> alter Name # tnnm -> neuer Name # tnonm -> Name des über der neuen Position liegenden Wertes toky[0]="box" tnky[0]="lramp" tonm[0]="cells_ramp" tnnm[0]="length " tnonm[0]="------------------------------------------------------------------------------------------" toky[1]="box" tnky[1]="lramp" tonm[1]="cells_ramp_form" tnnm[1]="form " tnonm[1]="length" twarn[1]="For form=0 the ramp now starts (consistently with form>=1) at cells_left with maximal density! You need to subtract &lramp -> length manually from &box -> cells_left" toky[2]="box" tnky[2]="lramp" tonm[2]="cells_ramp2" tnnm[2]="length2 " tnonm[2]="form" toky[3]="box" tnky[3]="lramp" tonm[3]="cells_rampcut" tnnm[3]="cutoff " tnonm[3]="form" toky[4]="box" tnky[4]="lramp" tonm[4]="cells_gluepos" tnnm[4]="gluepos " tnonm[4]="cutoff" for i in 0 1 do if [ $i -eq 0 ] then s="front" else s="rear" fi j=0 for t in "delay" "duration" "raise" "shape" "polarization" "amplitude" do toky[5+16*${i}+${j}]="pulse_${s}" tnky[5+16*${i}+${j}]="pulse_${s}_part_0" tonm[5+16*${i}+${j}]="${t}" tnnm[5+16*${i}+${j}]="${t}" tnonm[5+16*${i}+${j}]="------------------------------------------------------------------------------------------" j=$[${j}+1] done toky[5+6+16*${i}]="pulse_${s}" tnky[5+6+16*${i}]="pulse_${s}_part_3" tonm[5+6+16*${i}]="seedfrequency" tnnm[5+6+16*${i}]="frequency" tnonm[5+6+16*${i}]="------------------------------------------------------------------------------------------" k=1 l=0 for j in "2" "3" "n" do for t in "delay" "phase" "amplitude" do toky[5+7+16*${i}+${l}]="pulse_${s}" tnky[5+7+16*${i}+${l}]="pulse_${s}_part_${k}" tonm[5+7+16*${i}+${l}]="${t}${j}" tnnm[5+7+16*${i}+${l}]="${t}" tnonm[5+7+16*${i}+${l}]="------------------------------------------------------------------------------------------" l=$[${l}+1] done k=$[${k}+1] done done t1=0 while [ -e "tmp$t1" ] do t1=$[$t1+1] done t2=$[$t1+1] t1="tmp"$t1 while [ -e "tmp$t2" ] do t2=$[$t2+1] done t2="tmp"$t2 cp $1 $t1 mv $1 $2 # einfügen neuer Schlüssel for i in {0..12} do if [ "$(grep -c "^${nkey[$i]}" $t1)" = "0" ] then alles=$(grep -c ".*" $t1) stelle=$[$(grep -n "^${nakey[$i]}" $t1 | tr ":" " " | awk '{print $1}')-1] head -n${stelle} $t1 > $t2 echo "${nkey[$i]}" >> $t2 echo "------------------------------------------------------------------------------------------" >> $t2 echo "" >> $t2 echo "" >> $t2 tail -n$[$alles-$stelle] $t1 >> $t2 rm $t1 mv $t2 $t1 fi echo -ne "." done # umziehen umzuziehender Werte for i in {0..36} do if [ "$(${path}/finde_wert $t1 ${tnky[$i]} ${tnnm[$i]})" = "0" ] && [ "$(${path}/finde_wert $t1 ${toky[$i]} ${tonm[$i]})" != "0" ] then alles=$(grep -c ".*" $t1) astelle=$(${path}/finde_wert $t1 ${toky[$i]} ${tonm[$i]}) nstelle=$(${path}/finde_wert $t1 ${tnky[$i]} ${tnonm[$i]}) zeile="$(head -n$astelle $t1 | tail -n1 | sed "s/${tonm[$i]}/${tnnm[$i]}/")" if [ $astelle -lt $nstelle ] then head -n$[${astelle}-1] $t1 > $t2 head -n${nstelle} $t1 | tail -n$[${nstelle}-${astelle}] >> $t2 echo "${zeile}" >> $t2 tail -n$[$alles-$nstelle] $t1 >> $t2 else head -n${nstelle} $t1 > $t2 echo "${zeile}" >> $t2 head -n$[${astelle}-1] $t1 | tail -n$[${astelle}-${nstelle}-1] >> $t2 tail -n$[$alles-$astelle] $t1 >> $t2 fi rm $t1 mv $t2 $t1 if [ "${twarn[$i]}" != "" ] then echo echo "Warning: ${twarn[$i]}" fi fi echo -ne "." done # einfügen neuer Werte for i in {0..99} do if [ "$(${path}/finde_wert $t1 ${okey[$i]} ${onam[$i]})" == "0" ] then alles=$(grep -c ".*" $t1) stelle=$(${path}/finde_wert $t1 ${okey[$i]} ${obnam[$i]}) head -n${stelle} $t1 > $t2 echo "${olin[$i]}" >> $t2 tail -n$[$alles-$stelle] $t1 >> $t2 rm $t1 mv $t2 $t1 fi echo -ne "." done # Ende auskommentieren alles=$(grep -c ".*" $t1) stelle=$(grep -n "^#\{0,1\}thermal velocity v/c vs. thermal energy" $t1 | sed "s/:.*$//" | tail -n1) head -n$[${stelle} - 1] $t1 > $t2 tail -n$[${alles} - ${stelle} + 1] $t1 | sed "s/^/#/" | sed "s/^##/#/" | sed "s/^#\/\//\/\//" | sed "s/^#$//" >> $t2 mv $t2 $t1 # =s ausrichten minpos=$( for s in $(grep "^[^#]*=" $t1 | sed "s/ *=.*$//" | sort -u | tr " " "_") do echo ${#s} done | sort -n | tail -n1) alles=$(grep -c ".*" $t1) i=1 while [ ${i} -le ${alles} ] do s="$(head -n${i} $t1 | tail -n1)" if [ $(echo "$s" | grep -c "^[^=#]*=") -eq 1 ] then t="$(echo "$s" | sed "s/ *=.*$//")" while [ ${#t} -lt ${minpos} ] do t="${t} " done echo "$t =$(echo "$s" | sed "s/^[^=]*=//")" >> $t2 else echo "$s" >> $t2 fi i=$[${i}+1] echo -ne "." done mv $t2 $t1 # #s ausrichten minpos=$( for s in $(grep "^[^#][^#]*#" $t1 | sed "s/ *#.*$//" | sort -u | tr " " "_") do echo ${#s} done | sort -n | tail -n1) alles=$(grep -c ".*" $t1) i=1 while [ ${i} -le ${alles} ] do s="$(head -n${i} $t1 | tail -n1)" if [ $(echo "$s" | grep -c "^[^#][^#]*#") -eq 1 ] then t="$(echo "$s" | sed "s/ *#.*$//")" while [ ${#t} -lt ${minpos} ] do t="${t} " done echo "$t #$(echo "$s" | sed "s/^[^#]*#//")" >> $t2 else echo "$s" >> $t2 fi i=$[${i}+1] echo -ne "." done echo mv $t2 $t1 mv $t1 $1