From 733897453056a041b2f0759342245b65d6843046 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 12 Feb 2013 20:47:32 -0500 Subject: [PATCH] phase.gp: Add gnuplot script and rules to build a phase-space plot In phase.gp, I use a for loop to iterate over data block (in this case, each trajectory is in its own block). This gives you nice per-block colors, but means you'll have to update the loop if you change the number of energies you're looping over. --- Makefile | 13 ++++++++++++- phase.gp | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 phase.gp diff --git a/Makefile b/Makefile index 44e3fe2..89dac64 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,7 @@ $(CXX_PROGRAMS): % : $$($$(*)_OBJECTS) # gnuplot plot.gp # where plot.gp was a gnuplot script for plotting data generated by # RUN_PROGRAM. -run: error.png +run: error.png phase.png .SECONDEXPANSION: error-%.data: $(PROGRAMS) @@ -152,6 +152,17 @@ error-%.data: $(PROGRAMS) error.png: error.gp error-euler.data error-midpoint.data error-rk4.data gnuplot "$<" > "$@" +phase.data: + > "$@" + for E in 0.1 0.5 1 1.5 2 2.5 3 3.5 4 4.5 4.9 5 5.1 5.5; do \ + ./one_gaussian_bump --vx0-energy "$$E" >> "$@"; \ + echo >> "$@"; \ + echo >> "$@"; \ + done + +phase.png: phase.gp phase.data + gnuplot "$<" > "$@" + # Pattern rule for compiling object files from C++ source # There is an implicit rule for this in GNU make # http://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html diff --git a/phase.gp b/phase.gp new file mode 100644 index 0000000..7cc02aa --- /dev/null +++ b/phase.gp @@ -0,0 +1,12 @@ +set term png +set termoption enhanced +set title 'Phase space' +set xlabel 'x' +set ylabel 'v_x' +unset key +set yrange [-4.5:0.5] +k = -5 +b = 1 +V(r) = 0.5 * k * b**2 * exp(-r**2/b**2) +set style data lines +plot V(x) title 'V(r)', for [i=0:13] 'phase.data' index i using 2:4 -- 2.26.2