[Tutor] error help

Geoframer geoframer at gmail.com
Sat Oct 7 23:53:39 CEST 2006


The main problem from what i can tell is that the number of '(' and ')' you
use in declarations (and maybe even functions) are not correct.

Take for instance :

u0prime  = beta*(sqrt(d**2 +(h +length1)**2) - h +length1))

You open 3 '(' and close 4 ')' .

The problem is not the little test code at the end (as you illustrated
yourself by moving it up and getting a different error).
The "Token Error: EOF in multi-line statement" usually means you made an
error using too many or too little ()'s.

I suggest carefully re-examining your code and check if everything is
entered correctly using the right amount of ()'s ;-)

Hope this helps some.

Ciao - Geofram

On 10/7/06, Chris Smith <mc_anjo at tamu.edu> wrote:
>
> I'm writing a numerical program for an assignment at school. So the code
> of my program isn't too long I've coded the formulas, which are rather
> long, as funcions. However when I try to run my program I keep getting
> one of two errors. The first happens when I do a test run of my code
> with the test portion of the code at the bottom. It keeps popping up an
> error message that says that my import statement is spaced incorrectly.
> It's not supposed to be indented at all and I can't figure out why it's
> popping up at all. If I try moving the test portion of the code up to
> the top it gives me "Token Error: EOF in multi-line statement". I don't
> understand this one because I try to have the last line be the one with
> the return statement of my last function and when the error happens it
> adds a line to my code and the error pops up.
>
> Can anyone tell me why I'm having these error or what I can do to get
> around them?
>
> Chris Smith
>
>
> #Functions for Numerical Program
> #----------------------------------
> ### The sine and cosine integrals are taken from Abramowitz and Stegun.
> ### Only use the first 6 terms of the summation in the sine and cosine
> ### integrals.
>
>
> def Si(x):
>     sine_integral = x - x**3/18. + x**5/600. - x**7/35280. \
>                     + x**9/3265920. + x**11/439084800.
>     return sine_integral
>
> def Ci(x):
>     # Euler's constant
>     Euler_const = 0.5772156649
>
>     cosine_integral = Euler_const + log(x) - x**2/4. + x**4/96. \
>                       - x**6/4320. + x**8/322560. + x**10/36288000
>     return cosine_integral
>
>
> def Mutual_impedance(length1, length2, stagger, d):
>     """
>     Mutual impedance formulas for Parallel in Echelon Configuration
>     The formulas are taken from a paper by Howard King, "Mutual Impedance
>     of Unequal Length Antennas in Echelon"
>
>     NOTE: all measurements should be entered in wavelengths
>     """
>
>     # stagger (this is the vertical separation between antenna centers)
>     # d (this is the horizontal separation between the antennas)
>     # length1 and length2 (this is the half length of the antennas)
>
>     # vertical separation between center of antenna 1 and bottom of
> antenna 2
>     h = stagger - length2
>
>     # wave propagation constant and eta
>     beta = 2*pi
>
>     # formulas to put into mutual impedance equation
>     u0       = beta*(sqrt(d**2 +(h -length1)**2) +(h -length1))
>     v0       = beta*(sqrt(d**2 +(h -length1)**2) -(h -length1))
>     u0prime  = beta*(sqrt(d**2 +(h +length1)**2) - h +length1))
>     v0prime  = beta*(sqrt(d**2 +(h +length1)**2) +(h +length1))
>     u1       = beta*(sqrt(d**2 +(h -length1 +length2)**2) +(h -length1
> +length2))
>     v1       = beta*(sqrt(d**2 +(h -length1 +length2)**2) - h -length1
> +length2))
>     u2       = beta*(sqrt(d**2 +(h +length1 +length2)**2) -(h +length1
> +length2))
>     v2       = beta*(sqrt(d**2 +(h +length1 +length2)**2) +(h +length1
> +length2))
>     u3       = beta*(sqrt(d**2 +(h -length1 +2*length2)**2) +(h -length1
> +2*length2))
>     v3       = beta*(sqrt(d**2 +(h -length1 +2*length2)**2) -(h -length1
> +2*length2))
>     u4       = beta*(sqrt(d**2 +(h +length1 +2*length2)**2) -(h +length1
> +2*length2))
>     v4       = beta*(sqrt(d**2 +(h +length1 +2*length2)**2) +(h +length1
> +2*length2))
>     w1       = beta*(sqrt(d**2 +h**2) -h)
>     y1       = beta*(sqrt(d**2 +h**2) +h)
>     w2       = beta*(sqrt(d**2 +(h +length2)**2) -(h +length2))
>     y2       = beta*(sqrt(d**2 +(h +length2)**2) +(h +length2))
>     w3       = beta*(sqrt(d**2 +(h +2*length2)**2) -(h +2*length2))
>     y3       = beta*(sqrt(d**2 +(h +2*length2)**2) +(h +2*length2))
>
>     R12 = 15*(cos(beta*(length1 - h))*(Ci(u0) +Ci(v0) -Ci(u1) -Ci(v1)) \
>               +sin(beta*(length1 - h))*(-Si(u0) +Si(v0) +Si(u1) -Si(v1)) \
>               +cos(beta*(length1 + h))*(Ci(u0prime) +Ci(v0prime) -Ci(u2)
> -Ci(v2)) \
>               +sin(beta*(length1 +h))*(-Si(u0prime) +Si(v0prime) +Si(u2)
> -Si(v2)) \
>               +cos(beta*(length1 -2*length2 -h))*(-Ci(u1) -Ci(v1) +Ci(u3)
> +Ci(v3)) \
>               +sin(beta*(length1 -2*length2 -h))*(Si(u1) -Si(v1) -Si(u3)
> +Si(v3)) \
>               +cos(beta*(length1 +2*length2 +h))*(-Ci(u2) -Ci(v2) +Ci(u4)
> +Ci(v4)) \
>               +sin(beta*(length1 +2*length2 +h))*(Si(u2) -Si(v2) -Si(u4)
> +Si(v4)) \
>               +2*cos(beta*length1)*cos(beta*h)*(-Ci(w1) -Ci(y1) +Ci(w2)
> +Ci(y2)) \
>               +2*cos(beta*length1)*sin(beta*h)*(Si(w1) -Si(y1) -Si(w2)
> +Si(y2)) \
>               +2*cos(beta*length1)*cos(beta*(2*length2 +h))*(Ci(w2)
> +Ci(y2) -Ci(w3) -Ci(y3)) \
>               +2*cos(beta*length1)*sin(beta*h*(2*length2 +h))*(-Si(w2)
> +Si(y2) -Si(w3) +Si(y3)))
>
>     X12 = 15*(cos(beta*(length1 - h))*(-Si(u0) -Si(v0) +Si(u1) +Si(v1)) \
>               +sin(beta*(length1 - h))*(-Ci(u0) +Ci(v0) +Ci(u1) -Ci(v1)) \
>               +cos(beta*(length1 + h))*(-Si(u0prime) -Si(v0prime) +Si(u2)
> +Si(v2)) \
>               +sin(beta*(length1 +h))*(-Ci(u0prime) +Ci(v0prime) +Ci(u2)
> -Ci(v2)) \
>               +cos(beta*(length1 -2*length2 -h))*(Si(u1) +Si(v1) -Si(u3)
> -Si(v3)) \
>               +sin(beta*(length1 -2*length2 -h))*(Ci(u1) -Ci(v1) -Ci(u3)
> +Ci(v3)) \
>               +cos(beta*(length1 +2*length2 +h))*(Si(u2) +Si(v2) -Si(u4)
> -Si(v4)) \
>               +sin(beta*(length1 +2*length2 +h))*(Ci(u2) -Ci(v2) -Ci(u4)
> +Ci(v4)) \
>               +2*cos(beta*length1)*cos(beta*h)*(Si(w1) +Si(y1) -Si(w2)
> -Si(y2)) \
>               +2*cos(beta*length1)*sin(beta*h)*(Ci(w1) -Ci(y1) -Ci(w2)
> +Ci(y2)) \
>               +2*cos(beta*length1)*cos(beta*(2*length2 +h))*(-Si(w2)
> -Si(y2) +Si(w3) +Si(y3)) \
>               +2*cos(beta*length1)*sin(beta*h*(2*length2 +h))*(-Ci(w2)
> +Ci(y2) -Ci(w3) +Ci(y3)))
>
>     mut_imp = complex(R12, X12)
>     return mut_imp
>
> from math import *
> length1 = 0.45
> length2 = 0.65
> stagger = 0.1
> d = 0.2
>
> impedance = Mutual_impedance(length1, length2, stagger, d)
> print impedance
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061007/c94bb8bd/attachment.htm 


More information about the Tutor mailing list