# target: clean - remove automatically generated files
clean:
- $(RM) -rf $(PROGRAMS) *.o $(RELEASE)*
+ $(RM) -rf $(PROGRAMS) *.o *.data *.png $(RELEASE)*
# target: dist - generate a tarball packaging the source
# Here, we move the source into a temporary release directory, tar the
# gnuplot plot.gp
# where plot.gp was a gnuplot script for plotting data generated by
# RUN_PROGRAM.
-run: $(PROGRAMS)
- ./$(RUN_PROGRAM)
+run: error.png
+
+.SECONDEXPANSION:
+error-%.data: $(PROGRAMS)
+ echo -e "# dt\terror" > "$@"
+ for dt in 0.00004 0.0002 0.001 0.005 0.025; do \
+ echo -en "$$dt\t" >> "$@"; \
+ ./one_gaussian_bump --time-step "$$dt" --$(@:error-%.data=%) | \
+ ./error_analysis >> "$@"; \
+ done
+
+error.png: error.gp error-euler.data error-midpoint.data error-rk4.data
+ gnuplot "$<" > "$@"
# Pattern rule for compiling object files from C++ source
# There is an implicit rule for this in GNU make
--- /dev/null
+set term png
+set title 'Error scaling'
+set xlabel 'dt'
+set ylabel 'relative error'
+set key left top
+set logscale x
+set logscale y
+set style data linespoints
+plot 'error-euler.data' title 'Euler', \
+ 'error-midpoint.data' title 'Midpoint', \
+ 'error-rk4.data' title '4th order Runge-Kutta'