| 1 |
% rungekuttasecond.mp |
| 2 |
% L. Nobre G. |
| 3 |
% 2008 |
| 4 |
|
| 5 |
input featpost3Dplus2D; |
| 6 |
|
| 7 |
verbatimtex |
| 8 |
\documentclass{article} |
| 9 |
\usepackage{beton} |
| 10 |
\usepackage{concmath} |
| 11 |
\usepackage{ccfonts} |
| 12 |
\begin{document} |
| 13 |
etex |
| 14 |
|
| 15 |
Spread := 30; |
| 16 |
f := (10,0,0); |
| 17 |
|
| 18 |
def vecfunc( expr posit )= |
| 19 |
( (0,1,Z(posit)-Y(posit)) ) |
| 20 |
enddef; |
| 21 |
|
| 22 |
beginfig(2); |
| 23 |
% cartaxes( 2.4, 2.4, 2.4 ); |
| 24 |
numeric grids, size, i, j, ijmax, diffstep, len, h; |
| 25 |
color actpos, one, two, aux, graycol, stap, midp, finp ; |
| 26 |
pair yaxp, oaxp, xaxp; |
| 27 |
graycol = 0.67white; |
| 28 |
h = 3; |
| 29 |
grids = 0.15; |
| 30 |
size = 0.14; |
| 31 |
diffstep = 0.0125; |
| 32 |
% len = 320; |
| 33 |
len = 240; |
| 34 |
ijmax = floor( 2.0/grids ); |
| 35 |
for j=-ijmax upto ijmax: |
| 36 |
for i=-ijmax upto ijmax: |
| 37 |
actpos := grids*(0,i,j); |
| 38 |
aux := 0.5*size*N( vecfunc( actpos ) ); |
| 39 |
one := actpos-aux; |
| 40 |
two := actpos+aux; |
| 41 |
draw rp(one)--rp(two) withcolor graycol; |
| 42 |
endfor; |
| 43 |
endfor; |
| 44 |
% stap = (0,-2,-1.05); |
| 45 |
% draw fieldlinepath( len, stap, diffstep, vecfunc ) withcolor blue; |
| 46 |
stap = (0,-1.5,-0.65); |
| 47 |
draw fieldlinepath( len, stap, diffstep, vecfunc ) withcolor blue; |
| 48 |
midp = stap + 0.5*h*vecfunc( stap ); |
| 49 |
finp = stap + h*vecfunc( midp ); |
| 50 |
draw rp(stap)--rp(midp); |
| 51 |
draw rp(stap)--rp(finp); |
| 52 |
% drawoptions( withcolor blue ); |
| 53 |
% draw fieldlinepath( len, (0,-2,-1.25), diffstep, vecfunc ); |
| 54 |
% draw fieldlinepath( len, (0,-2,-1.2), diffstep, vecfunc ); |
| 55 |
% draw fieldlinepath( len, (0,-2,-1.15), diffstep, vecfunc ); |
| 56 |
% draw fieldlinepath( len, (0,-2,-1.1), diffstep, vecfunc ); |
| 57 |
% draw fieldlinepath( len, (0,-2,-1.05), diffstep, vecfunc ); |
| 58 |
yaxp = rp((0,-2-grids,2+grids)); |
| 59 |
oaxp = rp((0,-2-grids,-2-grids)); |
| 60 |
xaxp = rp((0,2+grids,-2-grids)); |
| 61 |
drawdblarrow yaxp--oaxp--xaxp; |
| 62 |
label.bot(btex $x$ etex, xaxp ); |
| 63 |
label.lft(btex $y$ etex, yaxp ); |
| 64 |
dotlabel.bot(btex $x_0$ etex, rp((0,Y(stap),-2-grids)) ); |
| 65 |
dotlabel.lft(btex $y_0$ etex, rp((0,-2-grids,Z(stap))) ); |
| 66 |
dotlabel.bot(btex $x_0+\frac{h}{2}$ etex, rp((0,Y(midp),-2-grids)) ); |
| 67 |
dotlabel.lft(btex $y_0+\frac{h}{2}f_0$ etex, rp((0,-2-grids,Z(midp))) ); |
| 68 |
dotlabel.bot(btex $x_0+h$ etex, rp((0,Y(finp),-2-grids)) ); |
| 69 |
dotlabel.lft(btex $y_0+hf_{1/2}$ etex, rp((0,-2-grids,Z(finp))) ); |
| 70 |
endfig; |
| 71 |
|
| 72 |
numeric u, grids, i, j, thex, they, xmax, ymax, vertn, horin, rescal, size; |
| 73 |
pair actpos, direct, one, two; |
| 74 |
|
| 75 |
u := 0.5mm; |
| 76 |
vertn := 20; |
| 77 |
horin := 41; |
| 78 |
size := 3u; |
| 79 |
grids := 8u; |
| 80 |
ymax := 0.5*(vertn-1); |
| 81 |
xmax := 0.5*(horin-1); |
| 82 |
rescal := 0.15; |
| 83 |
|
| 84 |
beginfig(1); |
| 85 |
pickup pencircle scaled u; |
| 86 |
for i=-xmax upto xmax: |
| 87 |
for j=-ymax upto ymax: |
| 88 |
actpos:=grids*(i,j); |
| 89 |
thex:=i*rescal; |
| 90 |
they:=j*rescal; |
| 91 |
direct:=unitvector((1,they-thex)); |
| 92 |
one:=actpos-size*direct; |
| 93 |
two:=actpos+size*direct; |
| 94 |
draw one--two; |
| 95 |
endfor; |
| 96 |
endfor; |
| 97 |
endfig; |
| 98 |
|
| 99 |
verbatimtex |
| 100 |
\end{document} |
| 101 |
etex |
| 102 |
|
| 103 |
end; |