12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

62 chapter 3gnuplot> set terminal epslatexgnuplot> set terminal PostScriptgnuplot> set output "Laplace.ps"gnuplot> splot ‘Laplace.dat’ w lgnuplot> set terminal x11gnuplot> set title ‘Potential V(x,y) vs x,y’gnuplot> set xlabel ‘x Position’gnuplot> set ylabel ‘y Position’gnuplot> set zlabel ‘V(x,y)’; replotgnuplot> helpgnuplot> set nosurfacegnuplot> set view 0, 0, 1gnuplot> replotgnuplot> quitOutput in Encapsulated PostScript for LaTeXOutput in PostScript format for printingPlot output to be sent to file Laplace.psPlot again, output to fileTo see output on screen againTitle graphLabel x axisLabel y axisLabel z axis and replotTell me moreDo not draw surface; leave contoursLook down directly onto baseDraw plot again; may want to write to fileGet out of Gnuplot3.4.4 Gnuplot Vector FieldsEven though it is simpler to compute a scalar potential than a vector field, vectorfields often occur in nature. In Chapter 17, “PDEs for Electrostatics & Heat Flow,”we show how to compute the electrostatic potential U(x, y) on an x + y grid of spacing∆. Since the field is the negative gradient of the potential, E = − ⃗ ∇U(x, y), andsince we solve for the potential on a grid, it is simple to use the central-differenceapproximation for the derivative (Chapter 7 “Differentiation & Searching”) todetermine E:E x ≃E y ≃U(x +∆,y) − U(x − ∆,y)2∆U(x, y +∆)− U(x, y − ∆)2∆= U i+1,j − U i−1,j, (3.1)2∆= U i,j+1 − U i,j−1. (3.2)2∆Gnuplot contains the vectors style for plotting vector fields as arrows of varyinglengths and directions (Figure 3.9).> plot ‘Laplace_field.dat’ using 1:2:3:4 with vectors Vector plotHere Laplace_field.data is the data file of (x, y, Ex, Ey) values, the explicit columnsto plot are indicated, and additional information can be provided to control arrowtypes. What Gnuplot actually plots are vectors from (x, y) to (x +∆x, y +∆y),where you input a data file with each line containing the (x, y, ∆x, ∆y) values.Thousands of tiny arrows are not very illuminating (Figure 3.9 left), nor are overlappingarrows. The solution is to plot fewer points and larger arrows. On the rightin Figure 3.9 we plot every fifth point normalized to unit length via∆x = E xN ,∆y = E yN ,N = √E 2 x + E 2 y. (3.3)−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 62

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!