登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
程序
>
菜鸟求助高手牛人帮助FORTRAN调试
发帖
回复
4781
阅读
0
回复
[
求助
]
菜鸟求助高手牛人帮助FORTRAN调试
离线
假酒鬼真醉
UID :73463
注册:
2011-03-09
登录:
2013-08-12
发帖:
636
等级:
积极交流五级
0楼
发表于: 2011-04-20 16:13:17
代码是朱国瑞著,刘盛纲译的《开放谐振腔的时域分析》书中的代码,用的Micosoft developer studio
{:@MBA34
菜鸟原因,没有跑通
(v/mKG yg
跪求那位高手指点
*HC[LM
附代码 感激啊!!!!!!!!!!!!
N"',
program cavity
H]I^?+)9
!
fS@V`"O6
! ***********************************************
&PE/\_xD_
! this program calculates the resonant frequency, diffraction/ohmic q,
fC4#b?Q
! and field profile of the te mode of an axisymmetric, open-end cavity.
. W7ZpV
!
#saK8; tp
! the cavity structure is formed of multiple section of uniform and
W'98ues%
! linearly tapered waveguides with resistive walls. By assumption, the
8?yRa{'"
! radius of the (circular cross-section) cavity structure is either
ox|K2A
! constant or a slowly varying function of the axial position z.
S`w_q=-^8
! the end section (on the left or right) is either a propagating or
=P}BAJ
! a cut-off waveguide of uniform cross-section and resistivity.
OCX>LK!K
!
EdH;P\c
! a single te(m,n) mode is assumed throughout the structure.
6cQ)*,Q
!
EdC^L`::
! theory and algorithm are described in lecture notes "time domain
UgqfO(
! analysis of open cavity" (by k.. r. chu).
}Cs.Hm0P
!
j:Y1
! note: comment statements in the main program beginning with ccc
4Y'Kjx
! call for action by the user.
9e aqq
!
Q|$?d4La8
! date of first version: 1985
j Z6]G{
! date of this version: February 20, 1993
^Fop/\E
! ***************************************************************************
:Qc[>:N
!
o)B`K."
implicit real(a, b, d-h, j-z), complex(c)
%)t9b@c!}
! in the main program and subprogram cbc , difeq, radius, rho, and
]QqT.z%B
! closs, all variables beginning with I are integers, and all variables
jIvSjlm I
! beginning with c are complex numbers.
7RpAsLH=
dimension axmn(9,8), cw(20)
e6 &-f
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
*X%dg$VcV
dimension az(3001),arw(3001),arho(3001),afamp(3001),afphse(3001)
-O~V4004
common/const/ci,pi,realc
u*h+c8|zI
common/ckt/zmark,rwl,rwr,rhol,rhor,izmark,izstep
J$+K't5BZ
common/mode/wr,wi,fr0,fi0,xmn,im
kO)+%'L!8
common/diag/az,arw,arho,afamp,afphse,idiag,icont
HxE`"/~.7k
external cbc
Hyn* O)q!
data axmn/&
)8,) &F
3.832e0,1.841e0,3.054e0,4.201e0,5.318e0,6.416e0,&
",O}{z
7.501e0,8.578e0,9.647e0,&
SWq5=h
7.016e0,5.331e0,6.706e0,8.015e0,9.282e0,10.250e0,&
g %e"K nU
15.268e0,16.529e0,17.774e0,&
6he (v
13.324e0,11.706e0,13.170e0,14.586e0,15.964e0,17.313e0,&
^7p>p8
18.637e0,19.942e0,21.229e0,&
L/+KY_b:*
16.471e0,14.864e0,16.348e0,17.789e0,19.196e0,20.576e0,&
?7eD<|
21.932e0,23.268e0,24.587e0,&
NA/hs/ '
19.616e0,18.016e0,19.513e0,20.973e0,22.401e0,23.804e0,&
s{Wj&.)M
25.184e0,26.545e0,27.889e0,&
=Rw-@*#l
22.760e0,21.164e0,22.672e0,24.145e0,25.590e0,27.010e0,&
P}2waJe
28.410e0,29.791e0,31.155e0,&
N!=$6`d
25.904e0,24.311e0,25.826e0,27.310e0,28.768e0,30.203e0,&
Fv!KLw@
31.618e0,33.015e0,34.397e0/
E0lro+'lS
! axmn(im+1, in) is the nth root of jm'(x)=0 up to im=8 and in =8.
@lO(QpdG
!
n[f<]4<
! universal constants
o$XJSz|6
ci=cmplx(0.0,1.0)
{y\5 9
pi=3.1415926
RZL:k;}5
realc=2.99792e10
MYk%p'
!!! give plot instruction (1:plot, no plot)
Q>QES-.l
iplot=1
Q($.s=&l;
!!! specify no of points on the z-axis to be used to mark the positions
l2.Lh<G
! of the left/right boundaries and the junctions between sections.
`A0trC3
izmark=5
jmkVolz
! cavity dimension arrays zmark rwl, and rwr specified below are to be
w(6(Fze
! passed to the subprograms through the common block, the array
6@X j
! elements
aP`[O]8j
! must be in unit of cm..!
S-Z s
! zmark is a z-coordinate array to mark, from left to right, the positions
Jx-dWfe
! of the left boundary (zmark(1)), the junctions between sections
+\D?H.P
! (zmark(2),… ,zmark(izmark-1)), and the right boundary (zmark(zmark)).
=7l'3z8
!
4k6,pt"
! zmark(1) must be located within the left end section and zmark(izmark)
4Yx\U
! must be located within the right end section. The end section (on the left or right)
QPZ|C{Ce
! is assumed to be either a progagating or a cut-off
lk[BS*
! waveguide of uniform cross-section and resistivity.
FV];od&c
! in theory., lengths of the uniform end section so not affect the results.
S!J wF&EW
! in practice, set the length of the cut-off end section(if any)sufficiently short
wF\5 X
! to avoid numerical difficulties due to the exponential
7j//x Tr}a
! growth or attenuation of f with z.
No(p:Snbo
!
dH[T nqJn
! rwl(i) is the wall radius immediately to the left of z=zmark(i).
j~#nJI5]
! rwr(i) is the wall radius immediately to the right of z=zmark(i).
PKK18E}{%^
! wall radius between zmark(i) and zmark(i+1) will be linearly
O9/7?"l"
! interpolated between rwr(i) and rwl(i+1) by function radius(z).
[W*xPXr*
!!! specify cavity dimension arrays zmark, rwl, and rwr in cm.
;Q{~jT
r=0.9
lDU@Q(V#}<
r1=0.5
"'9[c"Iz
r2=1.1
==^9_a^
l=11.7
I `I+7~t
l1=3.0
M[}aQWT$v
l2=5.0
Y5&mJp\G
theta=10.0
(Z)F6sZ`8
zmark(1)=0.0
W&'[Xj
zmark(2)=zmark(1)+l1
?E2$
zmark(3)=zmark(2)+l
C%LXGMt
zmark(4)=zmark(3)+(r2-r)/tan(theta*pi/180.0)
<<iwJ U%:
zmark(5)=zmark(4)+l2
2sXNVo8`w"
rwl(1)=r1
@TqqF:c7
rwr(1)=r1
&}."sGK
rwl(2)=r1
E4;@P']`
rwr(2)=r
id=:J7!QU
rwl(3)=r
pf%B
rwr(3)=r
>I&'Rj&Mc
rwl(4)=r2
5;4bZ3e,0
rwr(4)=r2
e^ ZxU/e
rwl(5)=r2
JsY|Fv
rwr(5)=r2
\[CPI`yQe
! wall resistivity arrays rhol and rhor specified below are to be
4],*y`& g
! passed to the subprograms through the common block. Array elements
AzlZe\V?)~
! must be in mks unit of ohm-m(1 ohm-m = 100*ohm-m)
g/_j"Nn
! (example: resistivity of copper at room temperature=1.72e-8 ohm-m)
WKDa]({k%
!
->q^$#e
! rhol(i) is the wall resistivity immediately to the left of z=zmark(i).
R>#BJ^>=
! rhor(i) is the wall resistivity immediately to the right of z=zmark(i).
mAZfo53
! wall resistivity between zmark(i) and zark(i+1) by function rho(z).
&40# _>W7
!
_ !r]**
!!! specify wall resistivity arrays rhol and rhor in ohm-m.
PQJI~u9te}
rhomks=1.72e-8
qHtonJc
rhomks=0.0
R4x!b`:i
rhol(1)=rhomks
n72+X
rhor(1)=rhomks
EsK.g/d
rhol(2)=rhomks
,+mH1#-3
rhor(2)=rhomks
6|HxBC#4
rhol(3)=rhomks
{OBV+}#
rhor(3)=rhomks
?ZS/`P0}[
rhol(4)=rhomks
L &nqlH@+~
rhor(4)=rhomks
6.(L8.jv
rhol(5)=rhomks
!\(j[d#
rhor(5)=rhomks
9% wVE]
!
\(g/::|
! write cavity dimensions and resistivity
+Dwq>3AH
write(* ,2)r, r1, r2, l, l1, l2, theta
^v+3qm@,
2 format (/'cavity dimensions(length in cm ):',/'r=',1pe10.3,',r1=',1pe10.3,',r2=',1pe10.3,',11=',1pe10.3,',12=',1pe10.3,',theta=',1pe10.3,'degree')
'ai3f
write(*,3) izmark
4eh~/o&h
3 format(/'cavity dimension arrays: (izmark=',i4,')')
R/BW$4/E
do 50 i=1,izmark, 6
-,Y[`(q
if(izmark.ge.(i+5))imax=i+5
$sa5aUg }
if(izmark.lt.(i+5))imax=izmark
f*tKj.P
write(*,4) (zmark(ii), ii=i,imax)
K|Kc.
4 format(/' zmark(cm)=',6(1pe10.3,','))
1Bl;.8he.)
write(*, 5) (rwl(ii), ii=i,imax)
%k8H'w\
5 format(/' rwl(cm)=',6(1pe10.3,','))
.9'bi#:Cw
write(*, 6) (rwr(ii), ii=i,imax)
MjrI0@R
6 format(/' rwr(cm)=',6(1pe10.3,','))
Zp'q;h_
50 continue
R8(Bt73
write(*, 7) izmark
UU;U,q
7 format(/' wall resisitivity arrays: (izmark=', i4,')')
G-#]|)
do 60 i=1, izmark, 6
c1>:|D7w
if (izmark.ge.(i+5)) imax=i+5
>$ok3-tuU
if (izmark.lt.(i+5))imax=izmark
WNo",Vc
write(*, 8) (zmark(ii), ii=i,imax)
a"Q> K7K
8 format(/' zmark(cm)=',6(1pe10.3,','))
~REP@!\r^
write(*, 9) (rhol(ii), ii=i,imax)
=j&qat
9 format(/' rhol(ohm-m)=',6(1pe10.3,','))
)o[Jxu'
write(*, 10) (rhor(ii), ii=i,imax)
5k]xi)%
10 format(' rhor(ohm-m)=',6(1pe10.3,','))
]?"1FSu-8r
60 continue
>x0)
!!! specify no of steps for z-integration.
/'<Qk'
! (for a new problem, always check convergence with respect to izstep).
zc4l{+3
izstep=1000
%'`L+y
!!! specify m and n of te(m,n,l) mode
b>_eD-
im=1
CG397Y^
in=1
N{<9Njmm
xmn=axmn(im+1,in)
873'=m&
9~Ve}NB#z&
!!! guess resonant frequency and q of the 1-th axial mode
fx#Krr@
do 100 ilmode=1,3
M tD{/.D>
wguess=realc*sqrt((ilmode*pi/l)**2+(xmn/r)**2)
-Rcl(Q}LZ
qguess=500
x4 .Y&Wq#
cw(1)=wguess*cmplx(1.0,-0.5/qguess)
+`_Km5=
! the complex angular frequencies (denoted by cw(1) )of the axial modes have been formulated to
-s5>GwZt
! be the roots of the equation chc(cw)=0.cw(1)
FcI ZG _
! defined above is a guessed value for the root corresponding to the
T:?01?m
! desired axial mode.it is to be supplied to subroutine muller as a
}u9wD08x
! starting value for the search of the correct root.
?K9zTas@
! if the guess value is off by too much, muller may return the complex
zh60b{
! angular frequency of a different axial mode which has a value closer
Qi?xx')
! to the guess value.
.CY;-
! after a root has been returned by muller, it is important to check the
rfwX:R6,g
! f(amplitude)-vs-z plot to count its number of peaks and hence the actual
{%PgR){qR
! axial mode number represented by the root.
S)L(~N1
! although a single call to muller can in principle yield multiple roots,
-q6d&D'B+
! it seems to be numerically easier for muller to find only one root per
IJ zPWs5W:
! call when the equation is of complicated form. the need to provide a
2z+-vT%
! guessed root is an advantage of the root finding algorithm, because it
XxeyGs^%9
! serves as a control as to which root muller will search for.
RX6s[uQ
!!! specify (arbitrarilly) the real and imaginary parts of at the left
9&VfbrBM
! boundary (i.e. at z=zmark(1))
wB0Ke
fr0=1.0e-4
WJJwhr
fi0=0.0
x |0@T ?
! calculate resonant frequency and q
)Co&(;zf
ep1=1.0-6
y%NZ(Y,v
ep2=ep1
4Y!_tZ>
iroot=1
WN`|5"?$
imaxit=50
_4lhwKYU
icont=0
KvtX>3#qM
idiag=0
uu`G<n
call muller(0,iroot,cw,imaxit,ep1,ep2,cbc,.false.)
E3`&W8
idiag=1
V 'e_gH
value=cabs(cbc(cw(1)))
_1EWmHZ?
! muller is called to solve equation cbc(cw)=0 for the complex root cw,
DI,8y"!5
! 'idiag' is an instruction for diagnostics. if (and only if) idiag=1,
cE SSSH!m
! function cbc will store the profiles of wall radius, resistivity, and
J*}Qnl +
! rf field, and pass them through the common block to the main program
Sn~h[s_(
! for plotting
hO H DXc"
! 'icont' monitor the no of times that function cbc is called for root
){S/h<4m
! searching ('icont' goes up by one upon each call to cbc).
ZBcT@hxm
! 'value' monitors the accuracy of the root returned by muller.
W{js9$oJ
wr=cw(1)
GDBxciv
wi=-ci*cw(1)
^`< %Pk
fhz=wr/2.0/pi
j$Unw
q=-wr/(2.0*wi)
6O9?":3;
!
_`LQnRp(
!!! calculate the ratio of q to qref
+GDT@,/
lamda=realc/fhz
+w(>UBy-
qref=4.0*pi*(1/lamda)**2/float(ilmode)
x}(p\Efx
qratio=q/qref
n)6mfoe
! find rwmax, rhomax, and fmax
}_GI%+t
rwmax=arw(1)
aNxq_pRb
rhomax=arho(1)
1,pg7L8H
fmax=afamp(1)
Z<M?_<3
do 70 iz=1, izstep
tuWJj^
if(arw(iz+1).gt.rwmax)rwmax=arw(iz+1)
3<vw#]yL
if(arho(iz+1).gt.rhomax)rhomax=arho(iz+1)
!y 7SCz g
if(afamp(iz+1).gt.fmax)fmax=afamp(iz+1)
SIr^\iiOB
70 continue
d4[mR~XXT
! plot cavity shape, wall resistivity, and rf field profile
>ngP\&\
if (iplot.ne.1) go to 72
hDAxX=FM
call sscale(zmark(1), zmark(izmark),0.0,rwmax)
%"{jNC?
call splot (az, zrw, izstep+1,'rr rw(cm) vs z(cm)$')
QT[yw6Z
if(rhomax.eq.0.0) go to 71
o n+:{ad
call sscale(zmark(1), zmark(izmark),0.0,rhomax)
s J~WzQ
call splot(az,arho,izstep+1,'** rho(ohm-m) vs z(cm)$')
6Q}WX[| tQ
71 continue
IN#Z(FMVC
call sscale(zmark(1), zmark(izmark),0.0,fmax)
v==]v2-
call splot (az, afamp, izstep+1,'ff amplitude of f vs z(cm)$')
cZd{K[fuK
call sscale(zmark(1), zmark(izmark),-pi,pi)
8&2W^f5
call splot (az, afamp, izstep+1,'pp phase of f vs z(cm)$')
^9wQl!e ob
72 continue
+,$ SZ O]
! write results
WK)2/$7@
write(*, 11) im, in, xmn, fr0, fi0, izstep, ep1
XZ1oV?Z4
11 format(/'mode: im=',i3,',in=', i3,', xmn=',1pe11.4/&
IP3%'2}-
' (f specified at left boundary=',1pe9.2,',', 1pe9.2,&
`zmjiC
',izstep', i6,',ep1=',1pe8.1,')')
r)Dln5F
write(* ,12)wr, wi, icont, value, fhz,q, qratio
[\ALT8vC?m
12 format('wr=',1pe11.4,'rad/sec, wi=',1pe11.4,'/sec(',i4,',',1pe9.2,')'/&
SZ )AO8&
i4,',',1pe9.2,')'/&
nPh|rW=
'freq=',1pe11.4,'hz, q=',1pe11.4,'(q/qref=',1pe9.2,')')
fH6mv0
write (*,13)
p#DJow
13 format('************************************************************')
+PfXc?VU
100 continue
6OOdVS3\J
stop
!T3b]0z
end
0'Y'K6hG`
!******************************************************************
|y}iOI
function cbc(cw)
$CgR~D2G
implicit real (a, b, d-h, j-z), complex (c)
.*_uXQ
dimension y(20), dy(20), q(20)
kEr;p{5
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
[<H'JsJl
dimension az(3001), arw(3001), arho(3001), afamp(3001), afphse(3001)
1NI%J B
common/const/ci, pi, realc
,ag:w<km
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark,izstep
)~CnDk}^R
common/mode/wr, wi, fr0, fi0, xmn, im
. v L4@_
common/diag/az, arw, arho, afamp, afphse, idiag, icont
<1xs ya[e
external difeq
pjVF^gv,*
wr=cw
[ _Nw5_
wi=-ci*cw
D<SLv,Y
! cw is pass to fuction cbc when cbc is called by subroutine muller
6r3.%V.&
! or by the main program
IA&NMf;{
! wr and wi are passed by function cbc to other subprogram through the
[8OQ5}do/
!common block.
I&lb5'6D
!
@}[yC['
! initialize rf field array y at left boundary
&Bfgvws;
z1=zmark(1)
zFpM\{`[g
rw=radius(z1)
5:W5@e{
if((wr/realc)**2.ge.xmn**2/rw**2) go to 11
m(6SiV=D9
ckapa = csqrt (ckapa2)
(s?Rbd
kapar = ckapa
.{}=!>U2
kapai = -ci*ckapa
Fu;\t 0
y(1) = fr0
{~u#.(
y(2) = fi0
{@tqeu%IM
y(3) = kapar*y(1)-kapar*y(2)
0%f}w0]:
y(4) = kapar*y(1)+kapar*y(2)
dd&n>A3O=
y(5) = z1
dvLO #o{
go to 12
Z&w/JP?
11 ckz2 = (cw/realc)**2-xmn**2*closs(z1)/rw**2
52H'aHO1
ckz = csqrt(ckz2)
o{n)w6P{R,
kzr = ckz
Sh(W s2b7
kzi = -ci*ckz
ln~;Osb
y(1) = fr0
$22_>OsA
y(2) = fi0
LFHzd@Y7"
y(3) = kzr*y(1)+kzi*y(1)
qY^@^)b[
y(4) = -kzr*y(1)+kzi*y(2)
yR|Beno
y(5) = z1
g$P <`.
12 continue
aUVJ\;V
! store radius, resistivity, and rf field at left boundary.
piv/QP-X
az(1) = z1
:#I7);ol
arw = radius(z1)
l]wjH5mz=i
arho(1) = rho(1)
Q(gc(bJV
afamp(1) = sqrt(y(1)**2+y(2)**2)
5&QDZnsl
afphse(1) = atan2(y(2), y(1))
^xZ o.P
! integrate differential equation for rf field array y from left boundary
V% PeZ.Xv
! to right boundary
g4"0:^/
do 10 i=1,5
&R7N^*He
10 q(i) = 0.0
Hvj1R.I/
l=zmark(izmark)-z1
%hnv go:^g
delz = l/float(izstep)
Q3OGU} F
do 100 iz = 1,izstep
S>y(3E]I
! advance rf field array y by one step.
8:QnxrODP
call rkint (difeq, y, dy, q, 1, 5, delz)
zVL"$ )
if (idiag.ne.1) go to 99
,-[e{=Cz
!store radius, resistivity, and rf field as functions of z.
vy&< O
! (arrays az, arw, arho, afamp, and afpfse are passed to the main program
=iZj&B X
! through the common block).
J/ !Mt
z = y(5)
g82_KUkB
az(iz+1) = z
h'D-e5i
arw(iz+1) = radius(z)
Nd] w I|>
arho(iz+1) = rho(z)
G,]%dZHe
afamp(iz+1) = sqrt(y(1)**2+y(2)**2)
[@RJ2q$
afphse(iz+1) = atan2(y(2), y(1))
S="teH[
99 continue
: U:>X6f
100 continue
f5p:o}U*
! calculate cbc(cw)
7=e!k-G
fr = y(1)
6&Al9+$
fi = y(2)
^P| K2at
fpr = y(3)
WhU-^`[*
fpi = y(4)
.PHz
cf = cmplx(fr, fi)
1+0DTqWz
cfp = cmplx(fpr, fpi)
sb^%eUU])
zf = y(5)
Aqp$JM >
rwf = radius(zf)
<XAW-m9SC
if((wr/realc)**2.le.xmn**2/rwf**2) go to 202
aOWfu^&H:
ckz2 = (cw/realc)**2-xmn**2*closs(zf)/rwf**2
C~PoC'"q
ckz = csqrt(ckz2)
0w24lVR.
cbc = cfp-ci*ckz*cf
;WG6|QgV?-
go to 201
D6wg^'Q:
202 continue
s1/:Ts[3i
ckapa2 = xmn**2*closs(zf)/rwf**2-(cw/realc)**2
LEJ8 .z6$
ckapa = csqrt(ckapa2)
XX])B%*
cbc = cfp+ckapa*cf
VUD ?iv7
201 continue
h%0hryGB
icont= icont+1
2wKW17wj,
return
`EjPy>kM
end
D%k`udz<
! *************************************************************************
/`)>W :
subroutine difeq(y,dy,ieqfst,ieqlst)
=%UX"K`
! this subroutine is called by subroutine rkint to calculate the
_h7qS
! derivatives of rf field array y (define as array dy). Subroutine
GLIe8T*ht
! rkint is called by function cbc to integrate the differential
~ R:=zGDV
! equations for the rf field array
`tZ-8f
implicit real (a, b, d-h, j-z), complex(c)
(sHvoE^q-
dimension y(20), dy(20)
vi:IO
common/const/ci, pi, realc
J#L"kz
common/mode/wr, wi, fr0, fi0, xmn, im
ag~4m5n*~
cw = cmplx(wr, wi)
NjL^FqA[
z = y(5)
L(Ffa(i
rw = radius(z)
<m7T`5+
ckz2 = (cw/realc)**2-xmn**2*closs(z)/rw**2
c(tX761qz
kz2r = ckz2
NE'4atQ|
kz2i = -ci*ckz2
hrt]Qn&
dy(1) = y(3)
x<-n}VK\
dy(2) = y(4)
K.{:H4_
dy(3) =-kz2r*y(1)+kz2i*y(2)
spV E'"^
dy(4) =-kz2i*y(1)-kz2r*y(2)
{Al}a`da
dy(5) = 1.0
:^Ouv1!e1
return
TAl#V7PF}
end
hj8S#
!********************************************
B > sTM
function radius(z)
/N'|Vs,X
! radius(z) is the wall radius at position z.
'I tsu~fza
implicit real (a, b, d-h, j-z), complex(c)
uk\-"dS
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
v]tNJ=aI
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark, izstep
4z$}e-
imax = izmark-1
==i:*
do 100 i = 1, imax
O_n) 2t(c?
if(z.ge.zmark(i).and.z.le.zmark(i+1))&
9)Jc'd|
radius = rwr(i)+(rwl(i+1)-rwr(i))*(z-zmark(i))/&
@aX$}
(zmark(i+1)-zmark(i))
oK! W<#
100 continue
ls<7Qe"a
! default value
H$j`75#u?-
if (z.lt. zmark(1)) radius = rwl(1)
^9 g+\W
if (z.gt. zmark(izmark)) radius = rwr(izmark)
'W>Zr}:
return
S@N:Cj
end
P%- @AmO^_
!****************************************************
h9B^U?<wT
function rho(z)
[nBdq"K
! rho(z) is the wall resistivity at position z.
ELlTR/NW
implicit real (a, b, d-h, j-z), complex (c)
%#^)hX,+Q
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
!oDX+hd,%>
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark, izstep
0i4X,oHjG
imax = izmark-1
6N^sUc0s
do 100 i = 1, imax
b<N962 q$q
if(z.ge.zmark(i).and.z.le.zmark(i+1))&
c,\!<4
rho = rhor(i)+(rhol(i+1)-rhor(i))*(z-zmark(i))/&
+}u{{
(zmark(i+1)-zmark(i))
Ki"o0u
100 continue
IQz:DJ
! default value
<o\2-fWvY
if (z.lt. zmark(1)) rho = rhol(1)
6tKm'`^z4
if (z.gt. zmark(izmark)) rho = rhor(izmark)
qg(rG5kD@
return
h)vRvfcmY
end
I`O)I&KH
!**********************************************************
e=]>TeqG0
function closs(z)
JDIQpO"Qji
! closs(z) is a factor to account for wall losses of the te(m, n) mode
|6mDooTy
! at position z. closs(z) = 1.0 for zero wall resistivity.
:Ur=}@Dj
implicit real (a, b, d-h, j-z), complex(c)
pu"`*NL
common/const/ci, pi, realc
XehpW}2\
common/mode/wr, wi, fr0, fi0, xmn, im
~BSE8M+r
cw = cmplx(wr, wi)
v@8=u4
delta = sqrt(realc**2*rho(z)/(2.0*pi*wr*9.0e9))
QnWM<6xK"
rw = radius(z)
D m|_;iO,
wcmn = xmn*realc/rw
`(RQh@H
cdum1 = (1.0+ci)*delta/rw
U!0 Qf7D
cdum2 = (float (im**2)/(xmn**2-float(im**2)))*(cw/wcmn)**2
kCq]#e~wq
closs = 1.0-cdum1*(1.0+cdum2)
;T6x$e
return
mM&*_#( 6
end
%dyE F8)
!********************************************************************
"HuV'
subroutine rkint (derivy, y, dy, q, neqflst, dx)
[ NSsT>C
real y(neqlst), dy(neqlst), q(neqlst)
2`-y zm
real a(4),b(4),c(4)
D~< 3
real dx, t
:n4X>YL)
external derivy
NvZ )zE
data a /0.5e0,0.29289322e0,1.7071068e0,0.16666667e0/,
w# t[sI"IT
1 b /2.0e0,1.0e0,1.0e0,2.0e0/,
x@@U&.1_A
2 c /0.5e0,0.29289322e0,1.7071068e0,0.5e0/
RuW62QSq
do 1 j = 1, 4
|#r[{2sS
call derivy (y, dy, neqfst, neqlst)
NVTNjDF%s
do 2 i = neqfst, neqlst
c]y"5;V8
t = a(j)*(dy(i)-b(j)*q(i))
.>K):|Opv
y(i) = y(i)+dx*t
u)DhkF|
q(i) = q(i)+3.0e0*t-c(j)*dy(i)
+&w=*IAKZ
2 continue
-\.'WZo`
1 continue
GCf3'u
return
~m]sJpW<"
end
ZW]Q|vPh4U
!*******************************************************
}Z|uLXaz
subroutine muller (kn, n, rts, maxit, ep1, ep2, fn, fnreal)
6 +:Tv2
implicit complex(a-h,o-z)
~}c`r 4
complex num, lambda
|CC(`<\R
real ep1, ep2, eps1, eps2
OYWW<N+R2
real abso
QTN _Z#'
external fn
*acN/Ca1
real aimag
UHtxzp =[
logical fnreal
!_EaF`oh(
dimension rts(6)
Bhy:" r%#
aimag(x) = (0.e0, -1.e0)*x
Y[A`r0
!
NbD"O8dL~E
! this subroutine taken from elementary numerical analysis:
Llf |fayq
! an algorithmic approach
7*7Z&1*3
! by: conte and de boor
*mc]Oa
! algorithm 2.11 - muller's method
S<hj6A
!
y11/:|
! initialization.
s[V$fvW
eps1 = amax1(ep1, 1.e-12)
&*I\~;1
eps2 = amax1(ep2, 1.e-20)
nbnbG0r:
ibeg = kn+1
:?Xd&u0){
iend = kn+n
V7zF5=w
!
=ZsM[wd
do 100 i = ibeg, iend
$uA?c& e
kount = 0
3lyk/',
! compute first three estimates for root as,
H?dmNwkPY
! rts(i)+0.5, rts(i) - 0.5, rts(i)
M>mk=-l
abso = cabs(rts(i))
x,sMa*vd
if (abso) 11, 12, 11
P(_wT:8C?
11 firsss = rts(i)/100.0e0
[w%MECTe
go to 13
VtR?/+8X
12 firsss = cmplx(1.0e0, 0.0e0)
@$5GxIw<l
13 continue
uc% &g
secdd = firsss/100.0e0
"%c\i-&t
1 h = .5e0*firsss
%f{1u5+5
rt = rts(i) + h
I[~EQ{Iz
assign 10 to nn
Y4%Bx8
go to 70
T;eA<,H
10 delfpr = frtdef
{[~ !6&2(k
rt = rts(i) - h
6\MJvg\;
assign 20 to nn
mulK(mp
go to 70
}`oe<|
20 frtprv = frtdef
`ym@U(;N
delfpr = frtprv - delfpr
z2m%L0
rt = rts(i)
cT8`l!RD<
assign 30 to nn
t|gEMDGa3
go to 70
sckyG
30 assign 80 to nn
_]"5]c&*3
Lambda = -0.5
>uok\sX
! computer next estimate for root
$c-h'o
40 delf = frtdef - frtprv
%$b)l?!
dfprlm = delfpr*lambda
|(gq:O
num = - frtdef*(1.0+lambda)*2
KzQ\A!qG
g = (1.0+lambda*2)*delf-lambda*dfprlm
)`RF2Y-A7
sqr = g*g+2.0*num*lambda*(delf-dfprlm)
}w \["r
if(fnreal.and.real(sqr).lt. 0.0) sqr = 0.0
oKIry 8'^N
sqr = csqrt(sqr)
E^.y$d~ dS
den = g + sqr
Hev S}L
if (real(g)*real(sqr) + aimag(g)*aimag(sqr).lt.0.0)
>K{/ Jx&
* den = g - sqr
kIAWI;H{
if (cabs (den).eq. 0.0) den = 1.0
Y$%/H"1bk
lambda = num / den
AsRS7V
frtprv = frtdef
RVFQ!0 C
delfpr = delf
H61,pr>
h = h *lambda
r( _9_%[
rt = rt + h
q16RPqfT
if ( kount.gt. maxit ) write (*,1492)
+\FTR
1492 format('lack of convergence in muller')
XE_|H1&j
if ( kount.gt.maxit ) go to 100
f-9&n4=H
!
rpsq.n
70 kount = kount + 1
ckqU2ETpD}
frt = fn ( rt)
Y[AL!h
frtdef = frt
`;7^@ k
if (i.lt.2) go to 75
m6BIQ(l
!
O a_2J#~$
do 71 j = 2, i
Zho d %n3
den = rt - rts(j-1)
r5b5 `f4
if (cabs (den).lt.eps2) go to 79
]Dm'J%P0}
71 frtdef = frtdef / den
}5H3DavW
75 go to nn, (10, 20, 30, 80)
&zsaVm8
79 rts(i) = rt + secdd
q$EicH}k8
go to 1
*p;Fwj]
! check for convergence.
'`q&UPg]
80 if ( cabs (h).lt. eps1*cabs(rt)) go to 100
"5mdq-h(
if (amax1 (cabs (frt), cabs(frtdef)).lt.eps2) go to 100
fF208A7U I
!
l`L}*Q- 5
! check for divergence
aOq>Ra{T
if (cabs (frtdef).lt.10.0 * cabs (frtprv)) go to 40
=J0X{Ovn4z
h = h / 2.0
A KO#$OJE
rt = rt - h
`A@{})+
go to 70
r;`6ML[5Vx
100 rts(i) = rt
)%q]?@kB
return
^l#Z*0@><~
end
#vi `2F
!**********************************************************
=`5Xx(
subroutine bplot(x, y, npt, tit)
@O}%sjC1
character char, charr, tit(4), title(101), arr(51, 101)
,?GEL>F
character v, h, puls, b, etit
8LP L4l
dimension x(1), y(1), xx(101)
LL5n{#)N
logical terr
+'abAST t
character * 80 teor
nB ?$W4
data v, h, plus, b /'!', '-','+',''/,etit/'$'/, nc/0/
nDnSVrvd-i
data teor/'-error- title must be, ((1-101) characters long) and
^Bw2y&nN
1(terminated by $)'/
M,Q(7z?#5
nscale = 0
\|Pp%U [
if (npt.eq.0) go to 30
B$aA=+<S
if(nc.ne.0) go to 20
Z(p kj
nc = 1
eK\1cs
call mxmn (x, npt, n1x,n0x)
?[Od.
call mxmn (y, npt, n1y,n0y)
Vx@JP93|
call quan (x(nlx), x(n0x), xmax, xmin)
Hm|8ydNs
call quan (y(nly), y(n0y), ymax, ymin)
#%U5,[<a8
go to 13
'c 0]8Y4
entry bscale (x0, x1, y0, y1)
u8pJjn;
nscale = 1
'rJkxU{
nc = 1
!/G2vF"
xmax = x1
WjxOM\?#
xmin = x0
<syMrXk)R(
ymax = y1
7/lXy3B4
ymin = y0
vn@9Sqk
13 dx = (xmax - xmin)*.01
cq`v8
rdx = 1.0/dx
1u&}Lq(
dy = (ymax - ymin)*.02
F}P+3IaE
rdy = 1.0/dy
'~RP+
do 15 n = 1, 101, 20
ahNpHTPa
xx(n) = xmin + (n-1)*dx
MtC \kTW
15 if (abs(xx(n)).le. .001*abs((xmax - xmin)))xx(n) = 0.0
^)Xl7d|m+
do 50 i = 1, 51
g$s"x r`:
charr = b
dEU+\NY
if(mod(i-1, 5).eq. 0) charr = h
42aYM!
do 55 j = 1,101
53d8AJ_@X
char = charr
!|{T>yy
if(mode(j-1,10).ne. 0) go to 55
)CQ'kHT<e
char = v
+]-~UsM
if(charr.ne.b)char = plus
Xc;W9e(U
55 arr(i,j)=char
Hc1S:RW
50 continue
yTWP1
if(nscale.eq.l) return
i-)OY,
20 do 16 n =1,npt
K'.aQ&2
nx = (x(n) - xmin)*rdx + 1.5
fOEw]B#@
ny = (ymax - y(n))*rdy + 1.5
DjK:)
if(nx .lt. 1)go to 16
g+oSbC
if(ny .lt. 1)go to 16
=Jfo=`da
if(ny .gt. 51)go to 16
~=~|@K
if(nx .gt. 101)go to 16
b: UTq 7^
arr(ny, nx) = tit(1)
A+*M<W
16 continue
6@?4z Rkz
30 if(tit(2).eq. b.and. tit(3).eq. b .and. tit(4).eq. b) return
k3::5&
terr = .false
F@Qzh
do 70 i = 2,102
ZI4[v>
ntit = i - 1
:@zz5MB5@
if(tit(i+4).eq.etit) go to 75
(K"U# Zn
70 continue
]6NpHDip1
terr = .ture
v'(p."g
ntit = 73
'`Eb].s*
75 mspc = (101 - ntit)/2
_NQMi4 V(
nspc = mspc + ntit + 1
].=&^0cg
do 80 i = 1,101
4$LVl
title(i) = b
A L|F Bd
if(i. le. mspc. or. i. ge. nspc)go to 80
t<5$85Y~
title(i) = tit(i-mspc+4)
OnE#8*8
if(terr)title(i) = teor(i-mspc:i-mspc)
?zW4|0
80 continue
SW|{)L,
nc = 0
?yop#tjCbY
write(*, 1) title
[+EmV >Y
1 format (1h 1,///,15x, 101a1)
m,KG}KX
do 17 ny = 1,51
iIFM 5CT
if(mod(ny-1, 5).ne. 0)go to 65
m[6?v;w
ay = ymax-(ny-1)*dy
<&:OSd:%
if(abs(ay).le. .001*abs((ymax-ymin)))ay = 0.0
{fe[$KQ
write(*, 9) ay,(arr(ny,n)n = 1,101)
.}Va~[0j
go to 17
b6sj/V8
65 write (*, 10) (arr(ny,n),n = 1,101)
`,|"rn#S
17 continue
5hwe ul>S
9 format (1pe14.4,1x, 101a1)
ssGp:{]v/
10 format(15x, 101a1)
hw/:
write(*,12) (xx(n), n = 1,101,20)
(27bNKr
12 format(1p6e20.4)
mm(Ff >O
return
$'FPsoH
end
,83%18b
!***********************************************************
`R@1Sc<*|
subroutine splot(x, y, npt, tit)
$'#hCs
character char, charr, tit(4), title(101), arr(51, 101)
F}p)Q$0
character v, h, puls, b, etit
qScc~i Oq
dimension x(1), y(1), xx(101)
t]LOBy-Kv
logical terr
Vx$ ?)&
character * 80 teor
CN4Q++{
data v, h, plus, b /'!', '-','+',''/,etit/'$'/, nc/0/
JGl0 (i*|
date teor/'-error- title must be, ((1-nxap) characters long) and
IzPnbnS}
1 (terminated by $)'/
c:(Xkzj
nscale = 0
%O]]La
if (npt.eq.0) go to 30
k I
if(nc.ne.0) go to 20
(/TYET_H
nc = 1
8,unq3
call mxmn (x, npt, n1x,n0x)
J{fTx@?(
call mxmn (y, npt, n1y,n0y)
[w&B>z=g$
call quan (x(nlx), x(n0x), xmax, xmin)
yf7p,_E/
call quan (y(nly), y(n0y), ymax, ymin)
Lky<L96
go to 13
.d{@`^dh1]
!
!Au'WJfE
entry sscale(x0, x1,y0, y1)
#[$^M:X.
nxr = 10
JmL{&
nxp = 6
UXpF$=
nyr = 5
ASA ]7qyO
nyp = 4
.!|\Y!]^r
nxap = nxr*nxp+1
?:DeOBAb
nyap = nyr*nyp+1
D@@J7
nscale = 1
z2'3P{#s
nc = 1
c'#w 8V
xmax = x1
r ]JV!'R
xm ..
6 axe
l*eJa38
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
发帖
回复