blob: 1d3cab3a66fe0a038715e94335e65b832bb55a9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
%% $Id: pst-magneticfield.pro 346 2010-06-11 06:12:08Z herbert $
%%
%% This is file `pst-magneticfield.pro',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-magneticfield.tex'
%% Jürgen Gilg
%% Manuel Luque
%% Herbert Voss
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `pst-magneticfield' is a PSTricks package to draw fields of Helmholtz coils
%%
%% version 0.02 / 2010-06-11 Herbert Voss <hvoss _at_ tug.org>
%%
%
/tx@MFieldDict 60 dict def
tx@MFieldDict begin
%
% helper functions
/setpixel { 1 0 360 arc fill } bind def
%
/fleche {
gsave
x2 y2 moveto
y2 y1 sub x2 x1 sub atan rotate % 1 1 scale
% -1 CLW mul 2 CLW mul rlineto
% 7 CLW mul -2 CLW mul rlineto
% -7 CLW mul -2 CLW mul rlineto
1 CLW mul 2 CLW mul rlineto
-7 CLW mul -2 CLW mul rlineto
7 CLW mul -2 CLW mul rlineto
closepath
fill
grestore
} def
%
/Calcul_B_Spires {
/Bx 0 def
/By 0 def
1 1 NombreSpires { % on calcule le champ resultant de toutes les spires
/iS ED % numero de la spire
/yi yA iS 1 sub inter mul sub def % position de la spire
/Bx0 {
/arz {1 Radius xP add dup mul yP yi add dup mul add sqrt div} def
yP yi add xP div arz mul
EllipticK neg
Radius dup mul xP dup mul add yP yi add dup mul add
Radius xP sub dup mul yP yi add dup mul add div
EllipticE mul
add
mul
} def
/By0 {
/arz {1 Radius xP add dup mul yP yi add dup mul add sqrt div} def
arz
EllipticK
Radius dup mul xP dup mul sub yP yi add dup mul sub
Radius xP sub dup mul yP yi add dup mul add div
EllipticE mul
add
mul
} def
AntiHelmholtz { iS 2 eq {/Bx0 Bx0 neg def /By0 By0 neg def} if } if
/Bx Bx Bx0 add def
/By By By0 add def
} for
} def
/EllipticKE{
/K {2 Radius xP mul sqrt mul arz mul} def
/m1 {1 K dup mul sub} def
/m2 {m1 dup mul} def
/m3 {m2 m1 mul} def
/m4 {m2 dup mul} def
/m_1 {1 m1 div} def
/EllipticK {
0.5
0.12498593597 m1 mul add
0.06880248576 m2 mul add
0.03328355376 m3 mul add
0.00441787012 m4 mul add
m_1 ln mul
1.38629436112 add
0.09666344259 m1 mul add
0.03590092383 m2 mul add
0.03742563713 m3 mul add
0.01451196212 m4 mul add
} def
/EllipticE {
0.24998368310 m1 mul
0.09200180037 m2 mul add
0.04069697526 m3 mul add
0.00526449639 m4 mul add
m_1 ln mul
1 add
0.44325141463 m1 mul add
0.062606012206 m2 mul add
0.04757383546 m3 mul add
0.01736506451 m4 mul add
} def
Calcul_B_Spires
% au point Pi
/xPi xP def
/yPi yP def
/NormeB Bx dup mul By dup mul add sqrt def
/dX Bx NormeB div Pas mul def
/dXi dX def
/dY By NormeB div Pas mul def
/dYi dY def
/xCi xPi dX add def
/yCi yPi dY add def
/xP xCi def
/yP yCi def
Calcul_B_Spires
% au point C
/NormeB Bx dup mul By dup mul add sqrt def
/dX Bx NormeB div Pas mul def
/dY By NormeB div Pas mul def
/yP yPi dY dYi add 2 div add def
} def
%
%0 0 translate
%
/setValues { % on stack +1 or -1
/yfactor ED /xfactor ED
Ligne_Champ dup length 1 sub 1.5 div cvi get aload pop
yfactor 0 gt {
/y2 exch yfactor mul def
/x2 exch xfactor mul def
}{
/y1 exch yfactor mul def
/x1 exch xfactor mul def
} ifelse
Ligne_Champ dup length 1 sub 1.5 div cvi 1 add get aload pop
yfactor 0 gt {
/y1 exch yfactor mul def
/x1 exch xfactor mul def
}{
/y2 exch yfactor mul def
/x2 exch xfactor mul def
} ifelse
} def
%
/Lignes_Champ {
/Ligne_Champ [
NbrePoints {%
EllipticKE
[ xP yP yUnit mul exch xUnit mul exch ]
trace 1 eq {By 0 lt Bx 0 lt and {exit} if} if
AntiHelmholtz not { xP xMax ge yP yMax ge or {exit} if } if
} repeat
] def
%
Ligne_Champ 0 get aload pop moveto % xP yP
1 1 Ligne_Champ length 1 sub {
/iCompteur exch def
Ligne_Champ iCompteur get aload pop lineto
} for
stroke
% les flèches (xP,yP)
1 1 setValues
nCount 0 eq {/yAxe1 y1 def /yAxe2 y2 def} if
fleche
%
Ligne_Champ 0 get aload pop neg moveto % xP -yP
1 1 Ligne_Champ length 1 sub {
/iCompteur ED
Ligne_Champ iCompteur get aload pop neg lineto
} for
stroke
trace 1 eq {
% (xP,-yP)
1 -1 setValues
fleche
} if
Ligne_Champ 0 get aload pop exch neg exch moveto % -xP yP
1 1 Ligne_Champ length 1 sub {
/iCompteur ED
Ligne_Champ iCompteur get aload pop exch neg exch lineto
} for
stroke
% (-xP,yP)
-1 1 setValues
fleche
Ligne_Champ 0 get aload pop exch neg exch neg moveto % -xP -yP
1 1 Ligne_Champ length 1 sub {
/iCompteur ED
Ligne_Champ iCompteur get aload pop exch neg exch neg lineto
} for
stroke
trace 1 eq {
% (-xP,-yP)
-1 -1 setValues
fleche
} if
} def
%
/MagneticField {
StreamDensityPlot {
/Bmax 0 def
/Pas PasB def
% recherche du Bmax
AntiHelmholtz {
Radius 0.1 sub 0.1 Radius 1.5 mul {
/xP exch def
0 0.1 yMax {
/yP exch def
EllipticKE
NormeB Bmax gt {/Bmax NormeB def} if
} for
}for
}{
0.01 0.1 Radius 0.1 sub {
/xP exch def
0 0.1 yMax {
/yP exch def
EllipticKE
NormeB Bmax gt {/Bmax NormeB def} if
} for
}for
} ifelse
%/xP 0.001 def
%/yP 0 def
%EllipticKE
%/Bmax NormeB def
/StepPixel
1 Unit div store
gsave
0.009 StepPixel xMax {
/xPos ED
/xP xPos def
0.009 StepPixel yMax {
/yPos ED
/yP yPos def
EllipticKE
/HB NormeB Bmax div store
Setgray { /HB HB 25 mul round 25 div def } if % 25 niveaux de gris
xPos xUnit mul yPos yUnit mul
Setgray { HB setgray setpixel }{ HB 0.7 1 sethsbcolor setpixel } ifelse
xPos xUnit mul neg yPos yUnit mul
Setgray { HB setgray }{ HB 0.7 1 sethsbcolor } ifelse setpixel
xPos xUnit mul neg yPos yUnit mul neg
Setgray { HB setgray }{ HB 0.7 1 sethsbcolor } ifelse setpixel
xPos xUnit mul yPos yUnit mul neg
Setgray { HB setgray }{ HB 0.7 1 sethsbcolor } ifelse setpixel
} for
}for
grestore
} if
% lignes de champ de l'ensemble de la bobine
/trace 1 def
/nCount 0 def
% 0.1 Radius mul StepLines Radius mul 0.9 Radius mul {
StepLines StepLines Radius 1.5 StepLines mul sub {
/NbrePoints NbrePointsB def
/xStart ED
/yStart 0 def
/Pas PasB def
/xP xStart def
/yP yStart Pas sub def
Lignes_Champ
/nCount nCount 1 add def
} for
AntiHelmholtz not {
% l'axe oriente de la bobine
0 yMin yUnit mul moveto
0 yMax yUnit mul lineto
stroke
/x1 0 def
/y1 yAxe1 def
/y2 yAxe2 def
/x2 0 def
fleche
%/x1 0 def
/y1 yAxe2 neg def
/y2 yAxe1 neg def
%/x2 0 def
fleche } if
% quelques lignes de champ autour de chaque spire
/trace 0 def
/increment 0.25 Radius mul def
AntiHelmholtz { /Pas PasS def /NbrePoints NbrePointsS def } if
nS { % nS lignes
0 1 TS length 1 sub {
/nTemp ED
/iS TS nTemp get def % numero de la spire en partant du haut
iS 0 eq { /iS 1 def } if % iS ne peut pas = 0
iS NombreSpires gt { /iS NombreSpires def } if % iS ne peut pas > nbre spires
/yi yA iS 1 sub inter mul sub def % position du centre de la spire
AntiHelmholtz not { /NbrePoints NbrePointsS def /Pas PasS def } if
/xStart Radius increment add def
/yStart yi def
/xP xStart def
/yP yStart Pas sub def
Lignes_Champ
} for
AntiHelmholtz { /NbrePoints NbrePoints 750 add def } if
/increment increment 0.2 Radius mul add def
} repeat
} def % /MagneticField
end
%%
|