登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
程序
>
菜鸟求助高手牛人帮助FORTRAN调试
发帖
回复
4782
阅读
0
回复
[
求助
]
菜鸟求助高手牛人帮助FORTRAN调试
离线
假酒鬼真醉
UID :73463
注册:
2011-03-09
登录:
2013-08-12
发帖:
636
等级:
积极交流五级
0楼
发表于: 2011-04-20 16:13:17
代码是朱国瑞著,刘盛纲译的《开放谐振腔的时域分析》书中的代码,用的Micosoft developer studio
Mg.xGST
菜鸟原因,没有跑通
%,rUN+vW
跪求那位高手指点
+Io[o6*
附代码 感激啊!!!!!!!!!!!!
,z1X{
program cavity
)o'&f"/
!
uE~? 2G
! ***********************************************
j+:q:6 =
! this program calculates the resonant frequency, diffraction/ohmic q,
-r_/b
! and field profile of the te mode of an axisymmetric, open-end cavity.
d%Zt]1$
!
B Mh949;
! the cavity structure is formed of multiple section of uniform and
Qo{Ez^q@J
! linearly tapered waveguides with resistive walls. By assumption, the
v\#69J5.>)
! radius of the (circular cross-section) cavity structure is either
j_E$C.XU{g
! constant or a slowly varying function of the axial position z.
pHlw&8(f"
! the end section (on the left or right) is either a propagating or
@ oE [!
! a cut-off waveguide of uniform cross-section and resistivity.
m'$]lf;*
!
Y@._dliM
! a single te(m,n) mode is assumed throughout the structure.
" 1YARGu
!
(!Q^.C_m
! theory and algorithm are described in lecture notes "time domain
. gK*Jpmx
! analysis of open cavity" (by k.. r. chu).
:qi"I;=6
!
x68$?CD
! note: comment statements in the main program beginning with ccc
y; Up@.IG
! call for action by the user.
F>,kKR-
!
)p7WU?&I
! date of first version: 1985
$u`y
! date of this version: February 20, 1993
]<mXf~zg
! ***************************************************************************
X8Px
!
|q5R5mQ
implicit real(a, b, d-h, j-z), complex(c)
Kw}-<y
! in the main program and subprogram cbc , difeq, radius, rho, and
q9w6 6R
! closs, all variables beginning with I are integers, and all variables
9u/ "bj
! beginning with c are complex numbers.
Bry\"V"'g
dimension axmn(9,8), cw(20)
KTd,^h
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
fr8:L!9
dimension az(3001),arw(3001),arho(3001),afamp(3001),afphse(3001)
K oPTY^
common/const/ci,pi,realc
]R/VE"-
common/ckt/zmark,rwl,rwr,rhol,rhor,izmark,izstep
O0#wM-M
common/mode/wr,wi,fr0,fi0,xmn,im
QfJ?'*
common/diag/az,arw,arho,afamp,afphse,idiag,icont
[G^ir
external cbc
wn[q?|1
data axmn/&
XCO{}wU)>
3.832e0,1.841e0,3.054e0,4.201e0,5.318e0,6.416e0,&
b>AFhj :
7.501e0,8.578e0,9.647e0,&
0jO]+B I1
7.016e0,5.331e0,6.706e0,8.015e0,9.282e0,10.250e0,&
Mt)`hR+2
15.268e0,16.529e0,17.774e0,&
xt@zP)6G
13.324e0,11.706e0,13.170e0,14.586e0,15.964e0,17.313e0,&
+5Yc/Qp
18.637e0,19.942e0,21.229e0,&
~HD:Y7
16.471e0,14.864e0,16.348e0,17.789e0,19.196e0,20.576e0,&
QT /TZ:
21.932e0,23.268e0,24.587e0,&
;w@PnY
19.616e0,18.016e0,19.513e0,20.973e0,22.401e0,23.804e0,&
_>B0q|]j4'
25.184e0,26.545e0,27.889e0,&
4flyV -
22.760e0,21.164e0,22.672e0,24.145e0,25.590e0,27.010e0,&
w+bQpIPM
28.410e0,29.791e0,31.155e0,&
CF3Z`xD
25.904e0,24.311e0,25.826e0,27.310e0,28.768e0,30.203e0,&
E~xK1x"
31.618e0,33.015e0,34.397e0/
HONrt|c
! axmn(im+1, in) is the nth root of jm'(x)=0 up to im=8 and in =8.
bS_!KU
!
KFBo1^9N
! universal constants
@a) x^d
ci=cmplx(0.0,1.0)
%zQME6WELz
pi=3.1415926
'/kSUvd
realc=2.99792e10
/j!?qID
!!! give plot instruction (1:plot, no plot)
KK`P<^8J
iplot=1
IC>OxYg*
!!! specify no of points on the z-axis to be used to mark the positions
{~ ZSqd
! of the left/right boundaries and the junctions between sections.
MNO T<(
izmark=5
P]-d(N}/H
! cavity dimension arrays zmark rwl, and rwr specified below are to be
Me[T=Tt`@w
! passed to the subprograms through the common block, the array
RG-pN()
! elements
W'6~`t
! must be in unit of cm..!
PhF3' ">
! zmark is a z-coordinate array to mark, from left to right, the positions
ipnvw4+
! of the left boundary (zmark(1)), the junctions between sections
&*RJh'o|N(
! (zmark(2),… ,zmark(izmark-1)), and the right boundary (zmark(zmark)).
?c0OrvM
!
ncf=S(G+
! zmark(1) must be located within the left end section and zmark(izmark)
_, /m
! must be located within the right end section. The end section (on the left or right)
)nyud$9w'
! is assumed to be either a progagating or a cut-off
Z3Os9X9p
! waveguide of uniform cross-section and resistivity.
6,)!\1k
! in theory., lengths of the uniform end section so not affect the results.
i /R8Gb
! in practice, set the length of the cut-off end section(if any)sufficiently short
oqHI`Tu
! to avoid numerical difficulties due to the exponential
M%+l21&
! growth or attenuation of f with z.
b5_(Fv
!
Mh>H5l.1i
! rwl(i) is the wall radius immediately to the left of z=zmark(i).
utKtxLX"
! rwr(i) is the wall radius immediately to the right of z=zmark(i).
(L_txd4
! wall radius between zmark(i) and zmark(i+1) will be linearly
0l !%}E
! interpolated between rwr(i) and rwl(i+1) by function radius(z).
!EuU @+
!!! specify cavity dimension arrays zmark, rwl, and rwr in cm.
7yxZe4~|#
r=0.9
}Og zSnR
r1=0.5
di}YHMTx
r2=1.1
&}31q`
l=11.7
4UmTA_& Io
l1=3.0
f sAgXv
l2=5.0
\2)a.2mAz
theta=10.0
oHdss;q
zmark(1)=0.0
S#dkJu]]#
zmark(2)=zmark(1)+l1
4A.ZMH
zmark(3)=zmark(2)+l
1iEZ9J?
zmark(4)=zmark(3)+(r2-r)/tan(theta*pi/180.0)
fQc2K|V
zmark(5)=zmark(4)+l2
)h&s.k
rwl(1)=r1
T;X8T
rwr(1)=r1
@$z/=g sy
rwl(2)=r1
$A,fO~
rwr(2)=r
C72?vAc,F
rwl(3)=r
W+V#z8K
rwr(3)=r
Xjc{={@p3
rwl(4)=r2
{X<mr~
rwr(4)=r2
\^vf`-uG
rwl(5)=r2
<@ D`16%&
rwr(5)=r2
M@fUZh
! wall resistivity arrays rhol and rhor specified below are to be
y-O# +{7
! passed to the subprograms through the common block. Array elements
*IUw$|Z6z)
! must be in mks unit of ohm-m(1 ohm-m = 100*ohm-m)
12v5*G[X
! (example: resistivity of copper at room temperature=1.72e-8 ohm-m)
fg"@qE-;
!
!fr /WxJ
! rhol(i) is the wall resistivity immediately to the left of z=zmark(i).
1BUdl=o>S
! rhor(i) is the wall resistivity immediately to the right of z=zmark(i).
z|[#6X6tT
! wall resistivity between zmark(i) and zark(i+1) by function rho(z).
,$@nbS{Q]
!
gsd9QW
!!! specify wall resistivity arrays rhol and rhor in ohm-m.
j7=I!<w V
rhomks=1.72e-8
5*~Mv<#
rhomks=0.0
\]=qGMwFs
rhol(1)=rhomks
|^Nz/PN
rhor(1)=rhomks
-~ytk=
rhol(2)=rhomks
V`?2g_4N
rhor(2)=rhomks
<T{2a\i 4f
rhol(3)=rhomks
$Z(fPKRN/
rhor(3)=rhomks
q/~U[.C
rhol(4)=rhomks
jC>l<d_
rhor(4)=rhomks
[RG&1~
rhol(5)=rhomks
betN-n-
rhor(5)=rhomks
1$oVcDLl
!
| iEhe
! write cavity dimensions and resistivity
5f2ah4 g
write(* ,2)r, r1, r2, l, l1, l2, theta
]C^D5(t/cd
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')
~(kIr?^
write(*,3) izmark
}q9;..oL
3 format(/'cavity dimension arrays: (izmark=',i4,')')
!4d6wp"
do 50 i=1,izmark, 6
p% ESp&
if(izmark.ge.(i+5))imax=i+5
4&;.>{:;
if(izmark.lt.(i+5))imax=izmark
BFmYbK
write(*,4) (zmark(ii), ii=i,imax)
vUl5%r2O4
4 format(/' zmark(cm)=',6(1pe10.3,','))
"f\2/4EIl
write(*, 5) (rwl(ii), ii=i,imax)
dP[l$/
5 format(/' rwl(cm)=',6(1pe10.3,','))
JViglO1\
write(*, 6) (rwr(ii), ii=i,imax)
2)]C'
6 format(/' rwr(cm)=',6(1pe10.3,','))
6r"uDV #0
50 continue
B MU@J
write(*, 7) izmark
A,D67G<v`
7 format(/' wall resisitivity arrays: (izmark=', i4,')')
k .? aq
do 60 i=1, izmark, 6
+N1oOcPC>C
if (izmark.ge.(i+5)) imax=i+5
Vzf{gr?
if (izmark.lt.(i+5))imax=izmark
y]QG;
write(*, 8) (zmark(ii), ii=i,imax)
{Buoo~
8 format(/' zmark(cm)=',6(1pe10.3,','))
CL%?K<um
write(*, 9) (rhol(ii), ii=i,imax)
9{@ #tx
9 format(/' rhol(ohm-m)=',6(1pe10.3,','))
6+"P$Ed#i
write(*, 10) (rhor(ii), ii=i,imax)
=t1.j=oC
10 format(' rhor(ohm-m)=',6(1pe10.3,','))
LcCb[r
60 continue
^p(t*%LM
!!! specify no of steps for z-integration.
e:}8|e~T
! (for a new problem, always check convergence with respect to izstep).
X_|W#IM*+
izstep=1000
#+Z3!VS
!!! specify m and n of te(m,n,l) mode
^Cb7R/R3
im=1
$+P9@Q$
in=1
K_j$iHqLF
xmn=axmn(im+1,in)
e&Z}struE
yo*c& >
!!! guess resonant frequency and q of the 1-th axial mode
bf2R15|t5`
do 100 ilmode=1,3
qCK)FOU
wguess=realc*sqrt((ilmode*pi/l)**2+(xmn/r)**2)
v<iMlOEt
qguess=500
Q#xeu
cw(1)=wguess*cmplx(1.0,-0.5/qguess)
oZ95 )'L,
! the complex angular frequencies (denoted by cw(1) )of the axial modes have been formulated to
% INRds
! be the roots of the equation chc(cw)=0.cw(1)
H6?ZE
! defined above is a guessed value for the root corresponding to the
a*JM2^,HO
! desired axial mode.it is to be supplied to subroutine muller as a
9], ;i7c
! starting value for the search of the correct root.
RbX!^v<0f6
! if the guess value is off by too much, muller may return the complex
h+F@apUS
! angular frequency of a different axial mode which has a value closer
;;'b;,/
! to the guess value.
}T%;G /W
! after a root has been returned by muller, it is important to check the
-}|GkTM
! f(amplitude)-vs-z plot to count its number of peaks and hence the actual
I$0JAy
! axial mode number represented by the root.
n's3!HQY[
! although a single call to muller can in principle yield multiple roots,
^c{}G<U^
! it seems to be numerically easier for muller to find only one root per
rm2"pfs
! call when the equation is of complicated form. the need to provide a
I7b(fc-r
! guessed root is an advantage of the root finding algorithm, because it
Jhu<^pjs
! serves as a control as to which root muller will search for.
qQN&uBQ[
!!! specify (arbitrarilly) the real and imaginary parts of at the left
@!6eRp>Z
! boundary (i.e. at z=zmark(1))
~d6_
fr0=1.0e-4
>kOc a
fi0=0.0
)BNm~sP
! calculate resonant frequency and q
BX$t |t;!m
ep1=1.0-6
6W$ #`N>
ep2=ep1
EJY[M
iroot=1
{V%ZOdg9
imaxit=50
v<bq1QG
icont=0
m&o}qzC'y
idiag=0
@ fm\ H
call muller(0,iroot,cw,imaxit,ep1,ep2,cbc,.false.)
8[5%l7's
idiag=1
w] LN(o:
value=cabs(cbc(cw(1)))
q]q(zUtU
! muller is called to solve equation cbc(cw)=0 for the complex root cw,
*>%34m93
! 'idiag' is an instruction for diagnostics. if (and only if) idiag=1,
<b"ynoM.A
! function cbc will store the profiles of wall radius, resistivity, and
!J!zi
! rf field, and pass them through the common block to the main program
TuY{c%qQ:
! for plotting
2pFOC;tl
! 'icont' monitor the no of times that function cbc is called for root
hkSpG{;7
! searching ('icont' goes up by one upon each call to cbc).
h-h U=I8
! 'value' monitors the accuracy of the root returned by muller.
ElAJR4'{*i
wr=cw(1)
0(#HMBE8
wi=-ci*cw(1)
U~Aw=h5SD
fhz=wr/2.0/pi
Kv"e\ E
q=-wr/(2.0*wi)
o+{}O_r
!
R-]QU`c
!!! calculate the ratio of q to qref
ep<A d
lamda=realc/fhz
Nk=F.fp|/
qref=4.0*pi*(1/lamda)**2/float(ilmode)
2{c ;ELq
qratio=q/qref
Qfo'w%px
! find rwmax, rhomax, and fmax
k9UmTvX
rwmax=arw(1)
;>[).fX>/
rhomax=arho(1)
HRi~TZ?\
fmax=afamp(1)
lGqwB,K$z4
do 70 iz=1, izstep
jzV*V<
if(arw(iz+1).gt.rwmax)rwmax=arw(iz+1)
[^ck;4q
if(arho(iz+1).gt.rhomax)rhomax=arho(iz+1)
VA.jt}YGE
if(afamp(iz+1).gt.fmax)fmax=afamp(iz+1)
d}tn/Eu?B
70 continue
g.aNITjP
! plot cavity shape, wall resistivity, and rf field profile
^T"9ZBkb
if (iplot.ne.1) go to 72
Pa2HFy2
call sscale(zmark(1), zmark(izmark),0.0,rwmax)
wqBGJ
call splot (az, zrw, izstep+1,'rr rw(cm) vs z(cm)$')
WpC@nz?
if(rhomax.eq.0.0) go to 71
XP5q4BM
call sscale(zmark(1), zmark(izmark),0.0,rhomax)
%Bmi3 =Rr
call splot(az,arho,izstep+1,'** rho(ohm-m) vs z(cm)$')
@8C^[fDL
71 continue
0X+Jj/-ge
call sscale(zmark(1), zmark(izmark),0.0,fmax)
(u85$_C
call splot (az, afamp, izstep+1,'ff amplitude of f vs z(cm)$')
=N01!?{
call sscale(zmark(1), zmark(izmark),-pi,pi)
_v4TyJ
call splot (az, afamp, izstep+1,'pp phase of f vs z(cm)$')
kbBD+*
72 continue
8h9t8?
! write results
,$5;
write(*, 11) im, in, xmn, fr0, fi0, izstep, ep1
*JGm
11 format(/'mode: im=',i3,',in=', i3,', xmn=',1pe11.4/&
evsH>hE^
' (f specified at left boundary=',1pe9.2,',', 1pe9.2,&
=]oBBokV
',izstep', i6,',ep1=',1pe8.1,')')
_dppUUm
write(* ,12)wr, wi, icont, value, fhz,q, qratio
Pgf$GXE
12 format('wr=',1pe11.4,'rad/sec, wi=',1pe11.4,'/sec(',i4,',',1pe9.2,')'/&
ba|x?kz
i4,',',1pe9.2,')'/&
a{Y:hrd:Z
'freq=',1pe11.4,'hz, q=',1pe11.4,'(q/qref=',1pe9.2,')')
jo=XxA
write (*,13)
!Jb?rSJ.h
13 format('************************************************************')
&Th/Qv}[
100 continue
Mo &Ia6^
stop
DU$]e1
end
:Oo
!******************************************************************
,^O**k9F
function cbc(cw)
7;KmJ}$
implicit real (a, b, d-h, j-z), complex (c)
R?1;'pvpa[
dimension y(20), dy(20), q(20)
1JgnuBX"
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
mB;W9[
dimension az(3001), arw(3001), arho(3001), afamp(3001), afphse(3001)
<oV _EZ
common/const/ci, pi, realc
liFNJd`|o+
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark,izstep
: Ey
common/mode/wr, wi, fr0, fi0, xmn, im
Nt67Ye3;
common/diag/az, arw, arho, afamp, afphse, idiag, icont
NFY,$
external difeq
KXcG;b[7n
wr=cw
ttLChL
wi=-ci*cw
-Qo`UL.}
! cw is pass to fuction cbc when cbc is called by subroutine muller
@Qd6a:-6
! or by the main program
hF+YZU]rT
! wr and wi are passed by function cbc to other subprogram through the
\l_RyMi
!common block.
gj\r>~S
!
KJ,{w?p~ )
! initialize rf field array y at left boundary
'1ff| c!x9
z1=zmark(1)
h0Acpd2
rw=radius(z1)
L':;Vv~-
if((wr/realc)**2.ge.xmn**2/rw**2) go to 11
EiI3$y3;
ckapa = csqrt (ckapa2)
s['F?GWg
kapar = ckapa
e`4OlM]
kapai = -ci*ckapa
jnt0,y A
y(1) = fr0
9C[3w[G~C
y(2) = fi0
_]1dm)%
y(3) = kapar*y(1)-kapar*y(2)
QpS0iUG
y(4) = kapar*y(1)+kapar*y(2)
fS-#dJC";`
y(5) = z1
s\#kqw\x
go to 12
C2AP
11 ckz2 = (cw/realc)**2-xmn**2*closs(z1)/rw**2
9%oLv25{)
ckz = csqrt(ckz2)
8~:qn@Z|E
kzr = ckz
X"J79?5
kzi = -ci*ckz
Po&gr@e.V
y(1) = fr0
g6Qzkvw)
y(2) = fi0
)HS|pS:
y(3) = kzr*y(1)+kzi*y(1)
wGd8q xa
y(4) = -kzr*y(1)+kzi*y(2)
t ?28s/?
y(5) = z1
!OPK?7
12 continue
$q DH
! store radius, resistivity, and rf field at left boundary.
Gw!jYnU
az(1) = z1
?YXl.yj
arw = radius(z1)
~t<BZu
arho(1) = rho(1)
;W?e@ Lgxk
afamp(1) = sqrt(y(1)**2+y(2)**2)
!#3#}R.$Fl
afphse(1) = atan2(y(2), y(1))
"My \&0-
! integrate differential equation for rf field array y from left boundary
NeCTEe|V
! to right boundary
WXNJc
do 10 i=1,5
6h}f^eJ:K,
10 q(i) = 0.0
ma~WJ0LM\
l=zmark(izmark)-z1
^O#,%>1J
delz = l/float(izstep)
gTW(2?xYf
do 100 iz = 1,izstep
CeR4's7
! advance rf field array y by one step.
#$K\:V+ 4
call rkint (difeq, y, dy, q, 1, 5, delz)
eN>=x40
if (idiag.ne.1) go to 99
.zlUN0oe
!store radius, resistivity, and rf field as functions of z.
qOZe\<.V<
! (arrays az, arw, arho, afamp, and afpfse are passed to the main program
E~2}rK+#)
! through the common block).
j !&g:{ e
z = y(5)
rv;w`f
az(iz+1) = z
9g"a`a?c
arw(iz+1) = radius(z)
ub}t3#
arho(iz+1) = rho(z)
p}R)qz-=5U
afamp(iz+1) = sqrt(y(1)**2+y(2)**2)
[rU8%
afphse(iz+1) = atan2(y(2), y(1))
KL sTgo|J
99 continue
Hh$D:ZO
100 continue
*`ji2+4Sjw
! calculate cbc(cw)
.pu]21m=
fr = y(1)
Mh>^~;
fi = y(2)
fbNVmjb$)
fpr = y(3)
:b^tu8E
fpi = y(4)
r4Pm i
cf = cmplx(fr, fi)
oQ8W0`bZa
cfp = cmplx(fpr, fpi)
7 -gt V#
zf = y(5)
..'^1IOA
rwf = radius(zf)
p8[Z/]p
if((wr/realc)**2.le.xmn**2/rwf**2) go to 202
n0@e%=H)I
ckz2 = (cw/realc)**2-xmn**2*closs(zf)/rwf**2
T*J]e|aF
ckz = csqrt(ckz2)
nEQw6q~je
cbc = cfp-ci*ckz*cf
nXb;&n%
go to 201
}_3<Q\j
202 continue
Wh(V?!^@5
ckapa2 = xmn**2*closs(zf)/rwf**2-(cw/realc)**2
GpN tvo~
ckapa = csqrt(ckapa2)
.2!'6;K
cbc = cfp+ckapa*cf
"J, ErnM
201 continue
r@"Vbq%
icont= icont+1
Jnb>u*7,
return
(J\"\#/d
end
Z?G-~3]e
! *************************************************************************
xlqRW"
subroutine difeq(y,dy,ieqfst,ieqlst)
d '4c?vC
! this subroutine is called by subroutine rkint to calculate the
?*tpW75hR[
! derivatives of rf field array y (define as array dy). Subroutine
P et0yH
! rkint is called by function cbc to integrate the differential
PS`v3|d}}}
! equations for the rf field array
e}(ws~.
implicit real (a, b, d-h, j-z), complex(c)
bCdEItcD
dimension y(20), dy(20)
Pf]6'?kQ
common/const/ci, pi, realc
+MGEO+
common/mode/wr, wi, fr0, fi0, xmn, im
|6"zIHvtc
cw = cmplx(wr, wi)
)]n:y M
z = y(5)
7tUl$H;I/R
rw = radius(z)
m-5Dbx!j
ckz2 = (cw/realc)**2-xmn**2*closs(z)/rw**2
ZR6KE_
kz2r = ckz2
3Q~ng2Wv%
kz2i = -ci*ckz2
P`Anf_
dy(1) = y(3)
ss236&
dy(2) = y(4)
tE9%;8;H
dy(3) =-kz2r*y(1)+kz2i*y(2)
t 4{{5U'\
dy(4) =-kz2i*y(1)-kz2r*y(2)
9FX'Uw s
dy(5) = 1.0
@/`b:sv&*
return
Z99%uI3
end
p/cVQ
!********************************************
%z`bu2
function radius(z)
HMS9_#[kE
! radius(z) is the wall radius at position z.
:I+%v
implicit real (a, b, d-h, j-z), complex(c)
N#6&t8;kTC
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
bxc#bl3
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark, izstep
L 2Os\
imax = izmark-1
. AWRe1?
do 100 i = 1, imax
^B1Q";# B^
if(z.ge.zmark(i).and.z.le.zmark(i+1))&
?%iAkV
radius = rwr(i)+(rwl(i+1)-rwr(i))*(z-zmark(i))/&
oslrv7EK
(zmark(i+1)-zmark(i))
c3`X19'%fM
100 continue
,l#V eC
! default value
(VWTYG7
if (z.lt. zmark(1)) radius = rwl(1)
EbY%:jR
if (z.gt. zmark(izmark)) radius = rwr(izmark)
Av_1cvR:
return
(JL{X`gs#
end
xQm!
!****************************************************
$0AN5 |`g\
function rho(z)
y_Bmd
! rho(z) is the wall resistivity at position z.
*'QD!Tc
implicit real (a, b, d-h, j-z), complex (c)
"So+
dimension zmark(100), rwl(100), rwr(100), rhol(100), rhor(100)
gK9@-e
common/ckt/zmark, rwl, rwr, rhol, rhor, izmark, izstep
#Ji&.T^U/
imax = izmark-1
7 H.2]X
do 100 i = 1, imax
D5]T.8kX(7
if(z.ge.zmark(i).and.z.le.zmark(i+1))&
+K; X$kB
rho = rhor(i)+(rhol(i+1)-rhor(i))*(z-zmark(i))/&
Z[FSy-;"
(zmark(i+1)-zmark(i))
)4D |sN
100 continue
*t3fbD
! default value
2J|Wbey
if (z.lt. zmark(1)) rho = rhol(1)
ZvkO#j
if (z.gt. zmark(izmark)) rho = rhor(izmark)
]p `#KVW
return
/$%apci8
end
UCa(3p^V_
!**********************************************************
2Af1-z^^K
function closs(z)
'eLO#1Ipf
! closs(z) is a factor to account for wall losses of the te(m, n) mode
wx>BNlT@?
! at position z. closs(z) = 1.0 for zero wall resistivity.
=Mc*~[D/
implicit real (a, b, d-h, j-z), complex(c)
ES(b#BlrP/
common/const/ci, pi, realc
Wepa;
common/mode/wr, wi, fr0, fi0, xmn, im
WDP$w(M
cw = cmplx(wr, wi)
C^2Tql
delta = sqrt(realc**2*rho(z)/(2.0*pi*wr*9.0e9))
[_^K}\/+
rw = radius(z)
#:v|/2
wcmn = xmn*realc/rw
vc^qpOk
cdum1 = (1.0+ci)*delta/rw
y7u"a)T
cdum2 = (float (im**2)/(xmn**2-float(im**2)))*(cw/wcmn)**2
2Rc#{A
closs = 1.0-cdum1*(1.0+cdum2)
|/Ggsfmby
return
{qp XzxV
end
>TeTa l
!********************************************************************
f*0[[J0]
subroutine rkint (derivy, y, dy, q, neqflst, dx)
}{n[_:[7
real y(neqlst), dy(neqlst), q(neqlst)
';^VdR]fk
real a(4),b(4),c(4)
dK#:io[Nz
real dx, t
?N~rms e
external derivy
T5=3 jPQ
data a /0.5e0,0.29289322e0,1.7071068e0,0.16666667e0/,
}~:`9PV)Z%
1 b /2.0e0,1.0e0,1.0e0,2.0e0/,
,*+F*:o(m
2 c /0.5e0,0.29289322e0,1.7071068e0,0.5e0/
0%<Fc9#
do 1 j = 1, 4
ry*b"SO
call derivy (y, dy, neqfst, neqlst)
'hf#Q9W5
do 2 i = neqfst, neqlst
(ye1t96
t = a(j)*(dy(i)-b(j)*q(i))
<2fZYt vt
y(i) = y(i)+dx*t
P@`@?kMU
q(i) = q(i)+3.0e0*t-c(j)*dy(i)
VEkv JX.
2 continue
?.LS_e_0
1 continue
Ww{bh-nyq
return
N41)?-7F
end
p[!&D}&6h
!*******************************************************
] L"jt8E
subroutine muller (kn, n, rts, maxit, ep1, ep2, fn, fnreal)
[GyW1-p33w
implicit complex(a-h,o-z)
N8@Fj!Zi
complex num, lambda
%u,H2*
real ep1, ep2, eps1, eps2
X"z^4?Aj+
real abso
U,gg@!1GJo
external fn
Q=)$
real aimag
k^w!|%a[
logical fnreal
MXh0 a@*]
dimension rts(6)
rFh!&_
aimag(x) = (0.e0, -1.e0)*x
`%ZM(9T
!
dAh&Z:86\
! this subroutine taken from elementary numerical analysis:
D. fPHq
! an algorithmic approach
%|*tL7
! by: conte and de boor
_s[ohMlh
! algorithm 2.11 - muller's method
.D(H@3qA@
!
B36_OH
! initialization.
': 87.8$
eps1 = amax1(ep1, 1.e-12)
Rp^kD ,*
eps2 = amax1(ep2, 1.e-20)
hbl:~O&a/
ibeg = kn+1
]]Sz|6 P
iend = kn+n
D{x'k2=
!
bX Q*d_]WT
do 100 i = ibeg, iend
IE+{W~y\
kount = 0
V8@VR`!'
! compute first three estimates for root as,
,6=j'j1#a
! rts(i)+0.5, rts(i) - 0.5, rts(i)
c$Z3P%aP'V
abso = cabs(rts(i))
eGkB#.+J!
if (abso) 11, 12, 11
ve49m%NQ
11 firsss = rts(i)/100.0e0
66(|3D X
go to 13
J/mLmSx
12 firsss = cmplx(1.0e0, 0.0e0)
l~b# Y&
13 continue
7?9QlUO
secdd = firsss/100.0e0
-y|>#`T/
1 h = .5e0*firsss
)"/.2S;
rt = rts(i) + h
4@AY~"dq
assign 10 to nn
;.Zgt8/.
go to 70
r5M {*
10 delfpr = frtdef
$M5iU@A
rt = rts(i) - h
r7+"i9
assign 20 to nn
J: vq)G\F
go to 70
w &1_k:Z&
20 frtprv = frtdef
{ 0RwjPYp
delfpr = frtprv - delfpr
Y``50{7
rt = rts(i)
WWhAm{m
assign 30 to nn
]$oo1ssZ1
go to 70
K|%.mcs4
30 assign 80 to nn
s;Q0
Lambda = -0.5
vMu6u .e
! computer next estimate for root
O{R)0&
40 delf = frtdef - frtprv
&b'IYoe
dfprlm = delfpr*lambda
t6DgWKT6
num = - frtdef*(1.0+lambda)*2
(HbA?Aja
g = (1.0+lambda*2)*delf-lambda*dfprlm
% CV@FdB
sqr = g*g+2.0*num*lambda*(delf-dfprlm)
w<#/ngI2
if(fnreal.and.real(sqr).lt. 0.0) sqr = 0.0
BCMQ^hP}t
sqr = csqrt(sqr)
OyH>N/
den = g + sqr
uH="l.u
if (real(g)*real(sqr) + aimag(g)*aimag(sqr).lt.0.0)
"yJFb=Xdq
* den = g - sqr
$9YAq/#Q
if (cabs (den).eq. 0.0) den = 1.0
f^Sl(^f
lambda = num / den
&OQ37(<_
frtprv = frtdef
$ @g\wz
delfpr = delf
^ >JAl<k
h = h *lambda
p{X?_ F
rt = rt + h
@`xR1pXQ
if ( kount.gt. maxit ) write (*,1492)
*eL&fC
1492 format('lack of convergence in muller')
v7gs $'Q
if ( kount.gt.maxit ) go to 100
PvF3a`&r
!
bWWZGl9
70 kount = kount + 1
f@yInIzRJ
frt = fn ( rt)
v+Mi"ZAd
frtdef = frt
vX1 8 ]
if (i.lt.2) go to 75
L|ZxB7xk
!
OIJNOu I
do 71 j = 2, i
1[p6v4qO{
den = rt - rts(j-1)
"'U+T:S
if (cabs (den).lt.eps2) go to 79
ywQ[>itMa
71 frtdef = frtdef / den
/|Z_Dy
75 go to nn, (10, 20, 30, 80)
7IkNS
79 rts(i) = rt + secdd
Vl'Gi44)3"
go to 1
3N c#6VI
! check for convergence.
O/Cwm;&t
80 if ( cabs (h).lt. eps1*cabs(rt)) go to 100
lt08 E2p9
if (amax1 (cabs (frt), cabs(frtdef)).lt.eps2) go to 100
D=1:-aLP7
!
xKl\:}Ytp
! check for divergence
tf[)Q:|
if (cabs (frtdef).lt.10.0 * cabs (frtprv)) go to 40
VJbsM1y M
h = h / 2.0
uaghB,i'n
rt = rt - h
uJ-Q]yQ
go to 70
K93L-K^J
100 rts(i) = rt
y/i{6P2`,D
return
U/}YpLgdD
end
>vQ8~*xd
!**********************************************************
$-Iui0h
subroutine bplot(x, y, npt, tit)
?, B4
character char, charr, tit(4), title(101), arr(51, 101)
xnP@h
character v, h, puls, b, etit
+*uaB
dimension x(1), y(1), xx(101)
USd7gOq(
logical terr
M5 \flE2
character * 80 teor
)hG4,0hv&
data v, h, plus, b /'!', '-','+',''/,etit/'$'/, nc/0/
5<U:Yy
data teor/'-error- title must be, ((1-101) characters long) and
Hq$&rNnq\
1(terminated by $)'/
T,@s.v
nscale = 0
Rax]svc
if (npt.eq.0) go to 30
4}4 cA\B:n
if(nc.ne.0) go to 20
fVf @Ngvu
nc = 1
+xNV1bM
call mxmn (x, npt, n1x,n0x)
R*0]*\C z
call mxmn (y, npt, n1y,n0y)
sbv2*fno5
call quan (x(nlx), x(n0x), xmax, xmin)
~'1gX`o:
call quan (y(nly), y(n0y), ymax, ymin)
#No3}O;"g
go to 13
IVSOSl|
entry bscale (x0, x1, y0, y1)
~(*2:9*0
nscale = 1
%9v l
nc = 1
4j|IG/m
xmax = x1
8ShIn@|32
xmin = x0
Sf*1Z~P|
ymax = y1
q7z`oK5
ymin = y0
q"(b}3
13 dx = (xmax - xmin)*.01
,="hI:*<
rdx = 1.0/dx
\!LIqqX
dy = (ymax - ymin)*.02
mqj]=Fq*
rdy = 1.0/dy
B@w/wH
do 15 n = 1, 101, 20
iq^F?$gFk
xx(n) = xmin + (n-1)*dx
2ieyU5q7#
15 if (abs(xx(n)).le. .001*abs((xmax - xmin)))xx(n) = 0.0
+~(SeTY
do 50 i = 1, 51
r)S:-wP
charr = b
f8e :J#jbS
if(mod(i-1, 5).eq. 0) charr = h
hk+8s\%-
do 55 j = 1,101
;gGq\c
char = charr
\uPyvA=
if(mode(j-1,10).ne. 0) go to 55
4SVIdSA
char = v
8;Zz25*
if(charr.ne.b)char = plus
OEw#;l4 C
55 arr(i,j)=char
?}RPnf
50 continue
Znw3P|>B
if(nscale.eq.l) return
ylm #Xa
20 do 16 n =1,npt
8Sxk[`qx\K
nx = (x(n) - xmin)*rdx + 1.5
tn{YIp
ny = (ymax - y(n))*rdy + 1.5
unKPqc%q=n
if(nx .lt. 1)go to 16
U7#C. Z
if(ny .lt. 1)go to 16
"?%2`*\
if(ny .gt. 51)go to 16
ff&jR71E
if(nx .gt. 101)go to 16
hsB3zqotF
arr(ny, nx) = tit(1)
{x{~%)-
16 continue
W{m_yEOf
30 if(tit(2).eq. b.and. tit(3).eq. b .and. tit(4).eq. b) return
R_^0Un([
terr = .false
C19}Y4r:
do 70 i = 2,102
| |"W=E
ntit = i - 1
) >te|@}o
if(tit(i+4).eq.etit) go to 75
<@Z`<T6
70 continue
-w"$[XP
terr = .ture
}1 ,\*)5
ntit = 73
ui RO,B}z
75 mspc = (101 - ntit)/2
n&l(aRoyx
nspc = mspc + ntit + 1
`L LS|S]
do 80 i = 1,101
qCkC 2Fy(
title(i) = b
2cEvsvw>
if(i. le. mspc. or. i. ge. nspc)go to 80
Gg e X
title(i) = tit(i-mspc+4)
RDfvD|}VN
if(terr)title(i) = teor(i-mspc:i-mspc)
Ptm=c6H('
80 continue
@r&*Qsf|
nc = 0
t!-\:8n
write(*, 1) title
40%fOu,u`
1 format (1h 1,///,15x, 101a1)
iC{(vL0P+
do 17 ny = 1,51
dBw7l}
if(mod(ny-1, 5).ne. 0)go to 65
KFgq3snH
ay = ymax-(ny-1)*dy
6(=B`Z}a
if(abs(ay).le. .001*abs((ymax-ymin)))ay = 0.0
?;VsA>PV
write(*, 9) ay,(arr(ny,n)n = 1,101)
=MU(!`
go to 17
!\VzX
65 write (*, 10) (arr(ny,n),n = 1,101)
OxQ 5P;O
17 continue
Vy=P*
9 format (1pe14.4,1x, 101a1)
&@K6;T
10 format(15x, 101a1)
E+ctiVL
write(*,12) (xx(n), n = 1,101,20)
d.|*sZ&3p
12 format(1p6e20.4)
!RP0W
return
7KesfH?
end
,wf:Fr
!***********************************************************
IClw3^\l
subroutine splot(x, y, npt, tit)
X1HEeJ|
character char, charr, tit(4), title(101), arr(51, 101)
qj9[mBkP"
character v, h, puls, b, etit
[tT_ z<e`
dimension x(1), y(1), xx(101)
L{&>,ww
logical terr
oam$9 q
character * 80 teor
R_D&"&
data v, h, plus, b /'!', '-','+',''/,etit/'$'/, nc/0/
tD*k
date teor/'-error- title must be, ((1-nxap) characters long) and
5@DCo
1 (terminated by $)'/
:i4AkBNK
nscale = 0
X J`*dgJ
if (npt.eq.0) go to 30
$K.DLqDt
if(nc.ne.0) go to 20
5dGfO:Dy_
nc = 1
+ -uQ] ^n
call mxmn (x, npt, n1x,n0x)
9a[1s|>w-
call mxmn (y, npt, n1y,n0y)
\ZM5J
call quan (x(nlx), x(n0x), xmax, xmin)
15@2h
call quan (y(nly), y(n0y), ymax, ymin)
)DmydyQ'
go to 13
;>uB$8<_7
!
egK~w8`W%
entry sscale(x0, x1,y0, y1)
4E2#krE%
nxr = 10
#SKC>MGz
nxp = 6
7t+d+sQ-l
nyr = 5
ClY`2
nyp = 4
K@<*m!%<2
nxap = nxr*nxp+1
n}b{u@$
nyap = nyr*nyp+1
c2t`i
nscale = 1
NE.h/+4
nc = 1
uh2 Fr
xmax = x1
#.rkvoB0N
xm ..
uH?dy55Y
g$ HL::
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
发帖
回复