Files
sps-chapter/figure/numerics/Formfactor2.gp
T
Patrick Kilian bda457c52c Fix figure 4
by using a gnuplot multiplot
2022-04-29 21:54:49 -06:00

76 lines
1.9 KiB
Gnuplot
Executable File

#!/usr/bin/gnuplot
S_cic(x) = abs(x) < 0.5 ? 1 : 0
S_tsc(x) = abs(x) < 1 ? 1 - abs(x) : 0
S_pqs(x) = abs(x) < 0.5 ? 0.75 - x**2 : abs(x) < 1.5 ? (2*abs(x) - 3)**2 / 8: 0
S_pcs(x) = abs(x) < 1 ? 2/3. + x**2 * (abs(x)/2 - 1) : abs(x) < 2 ? (2 - abs(x))**3/6 : 0
W_cic(x) = S_tsc(x)
W_tsc(x) = S_pqs(x)
W_pqs(x) = S_pcs(x)
set terminal pngcairo color enhanced size 1280,960 font "Arial,20"
set output "Formfactor.png"
set size square
set multiplot layout 2,3 rowsfirst
set macros
TMARGIN = "set tmargin at screen 0.95; set bmargin at screen 0.60"
BMARGIN = "set tmargin at screen 0.40; set bmargin at screen 0.05"
LMARGIN = "set lmargin at screen 0.08; set rmargin at screen 0.28"
CMARGIN = "set lmargin at screen 0.39; set rmargin at screen 0.59"
RMARGIN = "set lmargin at screen 0.70; set rmargin at screen 0.90"
set samples 10000
set xtics offset 0,0.5
set xlabel "x / Δx" offset 0,1
set ylabel "S(x)"
set format y "%1.1f"
set title "Cloud in Cell\n" offset 0,-1
@LMARGIN; @TMARGIN;
plot[-2.5:2.5][0:1.2] S_cic(x) with line lc rgb "black" notitle
set ylabel ""
unset ylabel
set title "Triangular Shaped\n Cloud" offset 0,-1
@CMARGIN; @TMARGIN;
plot[-2.5:2.5][0:1.2] S_tsc(x) with line lc rgb "black" notitle
set title "Piecewise Quadratic\n Shape" offset 0,-1
@RMARGIN; @TMARGIN;
plot[-2.5:2.5][0:1.2] S_pqs(x) with line lc rgb "black" notitle
set samples 1000
set isosamples 1367
#set isosamples 3000
set format y '%g'
set format cb "% 1.1f"
set ytics 0.2
set ylabel "y / Δx"
set palette gray negative
set pm3d map
set ytics 1.0
set cbtics 0.2
set title "Cloud in Cell\n" offset 0,0
@LMARGIN; @BMARGIN;
splot [-2.5:2.5][-2.5:2.5] W_cic(x)*W_cic(y) notitle
set ylabel ""
unset ylabel
set title "Triangular Shaped\n Cloud" offset 0,0
@CMARGIN; @BMARGIN;
splot [-2.5:2.5][-2.5:2.5] W_tsc(x)*W_tsc(y) notitle
set cblabel "W(x) ⋅ W(y)"
set title "Piecewise Quadratic\n Shape" offset 0,0
@RMARGIN; @BMARGIN;
splot [-2.5:2.5][-2.5:2.5] W_pqs(x)*W_pqs(y) notitle