[SciPy-dev] some interesting routines in Python SOMNEC program

Rob rob at pythonemproject.com
Wed Feb 13 17:35:05 CST 2002


Hi Eric,  I may try out the Bessel and Hankel functions.  The SOMNEC
program runs for 190sec on my 1.8Ghz P4 at work, 800sec on my 1Ghz P3
laptop :)  I haven't profiled it yet, but there is little to vectorize
in the program, other than some array copying loops.  Of course the
FORTRAN version executes instantly.

The SOMNEC port was my first step at trying to get the
Sommerfield-Norton type real ground in my ASAP-Python wire antenna
simulator.   Now I also have some NEC-2 routines ported to Python which
are involved in the S-N ground calculations, but its going to take me a
long time to figure all of this out.  It may be that what I am trying to
do is impossible.

For now I am going to stick with straight Python/Numpy.  Later once I
figure out how everything works, I can try to integrate SciPy routines
and other stuff..

Rob. 

eric wrote:
> 
> Hey Rob,
> 
> So based on Travis O's comments and some simplification, the following are drop
> in replacements for somnec.BESSEL and somnec.HANKEL.  Please note they aren't
> vectorized though, so don't pass them an array (you don't in your code I don't
> believe).
> 
>     from scipy import *
>     _sign = array((1,-1),typecode=Complex)
>     def bessel(z):
>         return scipy.special.jv([0,1],z)._sign
> 
>     def hankel(z):
>         return scipy.special.hankel1([0,1],z)*_sign
> 
> I know your purpose for the conversions is as much educational (for you and
> others) as it is for development, so I'm sure you want to keep the Python
> versions around -- there is just no need to convert them back to C unless you
> just want to, because scipy already has them wrapped.
> 
> My cursory survey didn't reveal where I should try and plug in integrate.quad,
> so I didn't try.  The comments say your using "Shank's" algorithm to speed up
> convergence.  SciPy may not have that currently.  Do you have a feel if it is
> one we should add, or does it handle the same sorts of problems as quad?
> 
> eric
> 
> ----- Original Message -----
> From: "Rob" <rob at pythonemproject.com>
> To: <scipy-dev at scipy.net>
> Sent: Wednesday, February 13, 2002 1:00 PM
> Subject: [SciPy-dev] some interesting routines in Python SOMNEC program
> 
> > I've just finished a Python port of the NEC2 SOMNEC routine.  I had a
> > real headache resolving overlapping GO TO statements, but as far as I
> > can tell it works.  Please feel free to plagarize any of the routines,
> > including the Variable Width Romberg Integration.  Its chock full of
> > neat stuff, and begs to be rewritten in C.  (no not f2c, that becomes
> > unintelligible :)
> >
> > Rob.
> > --
> > The Numeric Python EM Project
> >
> > www.pythonemproject.com
> > _______________________________________________
> > Scipy-dev mailing list
> > Scipy-dev at scipy.net
> > http://www.scipy.net/mailman/listinfo/scipy-dev
> >

-- 
The Numeric Python EM Project

www.pythonemproject.com



More information about the Scipy-dev mailing list