Friday, September 22, 2017

Scattering - RCS calculation with NEC2

Would you like to know the scattering Radar Cross Section (RCS) of your RC or UAV quadcopter toy?  If you are a Real, Card Carrying Geek, then of course you would...

The Boeing RAH-66 Was Designed for Low RCS

I have done some more work on this problem and decided to revisit this article, so if you think you have seen it before, keep reading. 

Search Radar

Two types of radar need to be considered. Long range over the horizon radar is used to tell whether there is an aircraft and where it is heading. Short range targeting radar is used to track an aircraft and direct an anti-aircraft gun or missile.

Targeting radar typically operates at about 10 GHz in the X-band. It needs to be put onto the target, either visually with an Optical Putter On, or with a long range search radar. A 10 GHz radar with 30 mm wave length requires wire segments of 3 mm, which results in an enormous number of segments, which is beyond the modelling abilities of a desktop computer.

However, before one can activate the targeting radar, one first has to find the aircraft with a much lower frequency search radar and after that, one only has a few minutes or seconds, to do something about it. 

A long range UHF search radar typically operates at about 300 MHz. The wave length of 1000 mm requires larger elements of 100 mm, which is within the modelling abilities of a desktop computer.

The Radar Cross Section (RCS) gives an idea of how big an object appears to be to a search Radar. The result is in square meters.  For comparison, a B52 bomber has a RCS of about 100 m2, while a F16 is about 1.5 m2 and a modern stealth aircraft is below 0.001 m2.  These values are usually only bragged about in the forward direction and may be much worse from the side.

The smaller the RCS of the aircraft, the shorter the detection range will be and the less time the operators will have to react.  To be really stealthy and almost impossible to detect, the RCS needs to be very small and the idea is to shape the aircraft body such that radar waves will not be reflected back to the radar, but rather somewhere else.  To further improve the RCS, radar absorbent paint is applied to the edges, but if the shape is bad, then no amount of absorbent paint will help.

Free EMI/RFI Analysis Software

Until this year (2018) calculation of the RCS of an aircraft was difficult to do for a hobbyist, since the Free analysis tools left something to be desired.  However, I experimented with this problem over the past 5 years or so and the Free tools finally caught up and any radio ham can now play with this.

Therefore, before you waste money on a super expensive commercial tool from Ansys, Altair HyperWorks or others, do try the Free software first, as described below, since it may be more than good enough for what you need to do.  Also note that the Free NEC2 is more capable than the Student editions of the commercial tools.

Here is some background information on the Lawrence Livermore National Laboratory Numerical Electromagnetic Code (NEC), which is a method of moments type of successive approximation program needed to do the modelling:

The Free NEC2 program is normally used for the design of antennas by radio hams, but there is a duality between an antenna radiation pattern and a scattering pattern.  Whether an antenna is excited with a voltage in the middle, or excited by an incident plane wave, it results in the same thing.

However, when a plane wave is used to irradiate a complex body, then the resulting calculations can diverge if the elements are not small enough.  The polygon edges should be in the order of 1/10th of the radar wavelength (or less), otherwise the resulting pattern will look like a hedgehog on a LSD trip. 

NEC2 Manual Part 1, Page 76 

To calculate scattering of a plane wave, you need to make an electrical model of the aircraft.  Part 3 of the NEC2 manual contains an example for calculation of the RCS of a stick model of an aircraft.  This looks absurdly simple, but there is method in the madness, since in many cases a stick model is good enough.  An old fashioned aircraft such as a B52 bomber with a cylindrical, conductive body (alluminium or carbon fibre composite) can be well enough approximated by simple thick wires.

A Trippy Hedgehog

If you want a better estimate, then you should take a CAD model of the aircraft and convert that into a surface mesh of polygons.  This can be done with the FreeCAD and Meshlab programs, and then you need to convert the result into a format that your method of moments antenna modelling tool can read.

The file conversion to a NEC2 program, I addressed with a little Bash script, that takes an ASCII text STL file as input and creates a huge stack of tens of thousands of NEC2 punch cards, which one can then execute on a 1970s era mainframe computer in a museum, or on a modern laptop computer.


For best results, you need a recent version of Linux with the latest versions of the required tools.  I used Ubuntu Linux 18.04 LTS, which you can get here:

Once you have that up and running in a virtual machine or on a dedicated host, you need some analysis software:
$ sudo apt install FreeCAD meshlab nec2c xnecview xnec2c

That is everything you need.  This Free software can save you more than $100,000!

Sticks and Stones

To understand the problem better, read the examples at the back of the NEC2 manual part 2 about scattering.  Here is a NEC2 stick model of a small aircraft for RCS calculation with xnec2c:

CM An approximation of a small aircraft Radar Cross Section
CM AV dimensions:
CM The AV fuselage is about 3086 mm long and 680 mm high at the centre.
CM First approximation is a wire of 3086 mm, 340 mm radius.
CM Second approximation is a tapered wire 3086 long x 340 mm radius at hub,
CM tapering to 50 mm radius at the ends.
CM The Gain is the scattering cross section in square wavelengths (sigma/lambda^2.
CM Long range surveillance radar:
CM Fequency = 300 MHz:
CM Wave length = 1 m
CM 1/10th wave length = 100 mm
CM Patch/Wire segment sizes:
CM Length: 3086 mm / 100 mm = 31 sections
CM Height: 680 mm / 100 mm = 7 sections
CM Tail: 2048 mm /100 mm = 21 sections
CM Nose: 1038 mm / 100 mm = 10 sections
CM Radius at hub = 340 mm
CM Taper radius at nose/tail: 50 mm
CM Single wire:
CM GW 1,31,0,0,0,3.086,0,0,.340
CM Two tapered wire segments:
CM GW 1,21,0,0,0,2.048,0,0,0
CM GC 0,0,1,.050,.340
CM GW 2,10,2.048,0,0,3.086,0,0,0
CM GC 0,0,1,.340,.050
CM Excite:
CM EX 1,1,1,0,0
CM EX 1,1,1,0,90,30,-90
CM Radiation Pattern examples for xnec2c:
CM RP 0,72,72,0,0,0,5,5,0,0,0
CM RP 0,90,90,0,0,0,4,4,0,0,0
GW 1,21,0,0,0,2.048,0,0,0
GC 0,0,1,.050,.340
GW 2,10,2.048,0,0,3.086,0,0,0
GC 0,0,1,.340,.050
FR 0,1,0,0,300
EX 1,1,1,0,0
RP 0,90,90,0,0,0,4,4,0,0,0

You can run the above with Cocoanec on a Macintosh to get some idea about the scattering of a search Radar at the horizon.

Scattering of a Stick Model Aircraft

This model uses fat wire segments for the body, tapered towards the nose and tail, to make it a little more realistic.  The tail planes, wings and landing gear can be handled similarly, but there is diminishing returns - when you add the smaller features, the RCS doesn't change by much, since they are so much smaller than the main fuselage and wings.  This is about what an old B52 scattering pattern will look like.

Convert dBsm to RCS Sigma

The results from NEC2 is in decibel per square meter.  To convert that to plain old square meters, you need to do a little calculation:
   RCS Sigma = 10^(dB/10)

CAD Solid Model to Polygonal Surface Mesh

A CAD model STP file can be converted into a surface mesh with FreeCAD, but the default settings result in an enormous number (millions) of triangles.  To be able to process the data on a general purpose computer, you need to reduce that to a few thousand elements.

An enormous bomber such as the TU160, is 56 meters long.  Processing a full size surface model of this plane would require a very large computer.  The Sukhoi on the left however, is more doable.

TU160 Sweep Wing Bomber

The method of moments calculates the interaction between all edges, with the result that the computer memory requirements scale geometrically by the cube of the number of elements.  To process 50,000 triangles will require a hefty super computer.  So you have to scale the problem down to fit your computer.

An old laptop computer with a couple GB of RAM can handle 3000 to 5000 triangles, while a newer Macbook Pro with 8 GB RAM can handle 10,000 triangles.  This is why the old F117 stealth fighter was a faceted design.  Lockheed engineers had to design the aircraft shape to fit the abilities of their computers, which resulted in the infamous Hopeless Diamond shape (a pun on the large Hope Diamond).

Open your aircraft CAD model tu160.stp file with FreeCAD, click Edit Select All, click File Export As and select a STL mesh file tu160.stl.  The resulting mesh file will be in binary STL file format, with millions of polygons, which is impossible to handle on a small computer - Meshlab to the rescue.

TU160 Triangle Mesh

Open the STL file with Meshlab and remesh it to a much smaller number of polygons - 3000 to 10,000 is practical, while only 1000 polygons will likely result in a hedgehog graph.
  • Select 'File', 'Import Mesh' and select tu160.stl.
  • Click the 'Wireframe' widget on the tool bar to see the mesh.
  • Use the mouse scroll wheel to zoom in/out.
  • Use the mouse button and drag it to rotate the model.
  • Select 'Filters' click 'Remeshing, Simplification and Reconstruction'.
  • Select 'Quadratic Edge Collapse Decimation'.
  • Set 'Target number of faces' = 10000 and click 'Apply'.
Confirm that the model still looks the same, with much bigger triangles.  For the TU160 1/10th scale model above I used 10,000 triangles.

Be sure to export the file in STL ASCII TEXT format:
  • Select 'File', 'Export Mesh' file name tu160-10k.stl and deselect 'Binary Encoding', then click 'OK'.
Now, you should have something that can be processed on a garden variety computer - or a 1970s mainframe!

Convert the STL file to a NEC2 Program

The stl2nec script below, parses a surface mesh STL ASCII file and converts each triangle into a NEC surface patch triangle.  This is a straight forward conversion that requires no mathematics.  It simply reads the xyz co-ordinates of each corner and prints it again into a different format.

#! /bin/bash
echo Convert a CATIA STL mesh Triangle file to a NEC2 Surface Patch file
echo Usage: stl2nec inputfile outputfile
echo Example: stl2nec canopy.stl
# Configuration:
# None
# solid CATIA STL
#  facet normal  0.000000e+000  2.623846e-002 -9.996557e-001
#    outer loop
#      vertex -7.888865e+002  1.000000e+000 -1.510123e+002
#      vertex -8.452780e+002  1.000000e+000 -1.510123e+002
#      vertex -7.888881e+002  1.104642e+000 -1.510096e+002
#    endloop
#  endfacet
#  ...
#  facet normal  0.000000e+000  0.000000e+000 -9.999999e-001
#    outer loop
#      vertex -8.452780e+002  1.000000e+000 -1.510123e+002
#      vertex -7.888865e+002 -1.000000e+000 -1.510123e+002
#      vertex -8.452780e+002 -1.000000e+000 -1.510123e+002
#    endloop
#  endfacet
# endsolid CATIA STL
# The normal vector can be ignored
# Each triangle is defined by three x, y, z vertices
# The STL file is assumed to be in mm and is scaled to m with a GS card
# NEC Text File Format:
# The original Fortran NEC used punch cards with strict columnar data
# It is now done with lines in a text file
# A text line can use either spaces or commas as field delimeters
# Empty fields are padded with a zero
# The end of the line need not be padded with zeros
# Floating point numbers need to be in exponential format with decimal points
# Bash doesn't do exponential arithmetic (use bc), but the printf function can output it
# The locale settings in the printf statements below ensure use of decimal points
# Parameter Error check:
if [ "$#" -ne 2 ]
  echo ERROR: Missing filename parameters
  echo Example: stl2nec canopy.stl
  exit 1

# File Names:
if [ -e "$1" ]
    echo "Input file $1"
    export mesh="$1"
    export nec="$2"
    echo ERROR: No input file found
    echo Example: stl2nec canopy.stl
    exit 1
# The above should catch most fat finger issues

# Mesh file parse states:
# solid, facet, outer, vert1, vert2, vert3, endloop, endfacet, endsolid
export state="solid"
export vert1="0"
export vert2="0"
export vert3="0"
export errmax=100000
# NEC file data:
export wire="1"
export segments="1"
# Create the header of the NEC2 file
echo "CM NEC2 Card Stack Produced by s2n"
echo "CM NEC2 Card Stack Produced by s2n">"$nec"
echo "CE"
echo "CE">>"$nec"
# Read lines from the mesh file
while [[ $end_of_mesh_file == 0 ]]
  read -r meshline
  # the last exit status is the
  # flag of the end of file
  echo "$meshline"
  data=($(echo $meshline | tr -d '\r' ))
  if [ "${data[0]}" == "endsolid" ]
    #echo "state: $state"
  if [ "$state" == "solid" ]
    #echo "state: $state"
    if [ "${data[0]}" == "facet" ]
  elif [ "$state" == "facet" ]
    #echo "state: $state"
    if [ "${data[0]}" == "outer" ]
  elif [ "$state" == "outer" ]
    #echo "state: $state"
    if [ "${data[0]}" == "vertex" ]
      #echo "state: $state"
      #echo "vx1: ${data[1]}"
      #echo "vy1: ${data[2]}"
      #echo "vz1: ${data[3]}"
  elif [ "$state" == "vert2" ]
    #echo "state: $state"
    if [ "${data[0]}" == "vertex" ]
      #echo "vx2: ${data[1]}"
      #echo "vy2: ${data[2]}"
      #echo "vz2: ${data[3]}"
  elif [ "$state" == "vert3" ]
    #echo "state: $state"
    if [ "${data[0]}" == "vertex" ]
      #echo "vx3: ${data[1]}"
      #echo "vy3: ${data[2]}"
      #echo "vz3: ${data[3]}"
      # NEC2 Triangular Surface Patch Card
      LC_NUMERIC="en_US.UTF-8" printf "SP 0 2 %.8E %.8E %.8E %.8E %.8E %.8E \n"\
        $vx1 $vy1 $vz1 $vx2 $vy2 $vz2
      LC_NUMERIC="en_US.UTF-8" printf "SP 0 2 %.8E %.8E %.8E %.8E %.8E %.8E \n" \
        $vx1 $vy1 $vz1 $vx2 $vy2 $vz2 >>"$nec"
      LC_NUMERIC="en_US.UTF-8" printf "SC 0 2 %.8E %.8E %.8E \n" \
        $vx3 $vy3 $vz3
      LC_NUMERIC="en_US.UTF-8" printf "SC 0 2 %.8E %.8E %.8E \n" \
        $vx3 $vy3 $vz3 >>"$nec"
done < "$mesh"
# Create footer of NEC2 file
# Scale everything from mm to m
echo "GS 0 0 .001"
echo "GS 0 0 .001">>"$nec"
echo "GE"
echo "GE">>"$nec"
echo "FR 0 1 0 0 300"
echo "FR 0 1 0 0 300">>"$nec"
echo "EX 1 1 1 0 0"
echo "EX 1 1 1 0 0">>"$nec"
echo "RP 0 90 90 0 0 0 4 4 0 0 0"
echo "RP 0 90 90 0 0 0 4 4 0 0 0">>"$nec"
echo "EN"
echo "EN">>"$nec"
echo "Finis!"

Save the above script as stl2nec and make it executable with chmod 754 stl2nec and Bob's your Uncle.

You can run it like this:
$ stl2nec tu160-10k.stl

Process The NEC2 Program

The NEC2 and NEC4 programs still use command files that resemble a stack of punch cards, but doing things in a text file is rather easier than feeding thousands upon thousands of cards into a hopper.  I actually learned programming in FORTRAN on a Sperry-Univac with punch cards, which probably explains why I have no problem working with these old fashioned tools, but it may feel a bit wonky to a youngster - Now get off my lawn, eh...

You can use either nec2c to process the data and use xnecview to graph it, or you can use xnec2c which is all in one.  The result is the same.  Processing 3000 triangles takes a few minutes, while processing 10,000 triangles will take several hours, so you got to be patient.

Here we go:
$ xnec2c tu160-10k.stl

From this example, you can see that the RCS is much less in the forward direction than to the sides, while it is enormous from below, but the below RCS doesn't matter - it is only the direction to the horizon that matters for search radar.

One can also see that the pattern is not very good - some of the triangles are too big for the wavelength.  This means one either has to scale the model down in size, or reduce the radio frequency of the incident plane wave, or change the mesh to regular sized polygons with Meshlab Filters, Remeshing, Uniform mesh resampling.

Remember that:
RCS Sigma = 10^(dB/10)
Therefore the 1/10th scale model (5.6 meters long) TU160 example has a RCS of 9 dBsm = 8 square meters in the forward direction.  That makes sense, considering the huge wings and the engine air intakes.

NEC On A High Performance Cluster

Using a laptop computer, you should be able to work with aircraft up to about 3 meter wing span.  Larger than that, will require a more hefty system.

The xnec2c program has an option to specify the number of processing cores.  So if you ever wanted an excuse to build a Beowulf Cluster of Linux machines, this is one!

Alternatively, you would need to make a faceted aircraft design such as the Lockheed F117 Nighthawk, to reduce the computational requirements.


NEC2 harks back to the days when everything on earth was made of metal.   At present, most things are made of composite plastics, which are dielectrics.  NEC2 does have the load (LD) card which allows you to specify a lossy wire which goes some way to simulating a dielectric, but for a more accurate calculation with dielectrics, you need NEC4 or similar newer program.

Common composites such as carbon fibre cloth reacts much the same as metal if it was vacuum compressed and baked in an autoclave to make a maximum strength type of sheet.  The NEC scattering result of a common CFC aircraft shell should be within 1/2 a dB of the actual.

However, if carbon nanotubes, graphite, ferrite or other metal powders is arranged in a composite specifically to absorb radar emissions, then it is a different matter.  For this case, you need a better analysis program that can handle dielectric sheets, such as FECO or WIPL-D, but then we are probably not in the hobbyist/radio ham space anymore!

Other Notable Radio Ham Antenna Analysis Programs 

NEC2, NEC4, 4Nec2, MiniNEC and similar well known programs are what most radio amateurs can afford.  NEC4 costs about $2500.  However, the grand daddy of them all is still available for free.

Prof J.H. Richmond pioneered the Method of Moments analysis back in 1966 and he released a Thin Wire program in 1974, which was one of the better precursors of NEC.  In those days, a fast computer could handle about 50 wire elements (and I complain about struggling with 10,000!).  The original FORTRAN Thin Wire program is available on the Walnut Creek CDROM ISO file which you can still find with Google.

The Thin Wire program was subsequently improved by Jerry McCormack and became the ASAP program which you can get from Ray L. Cross: for free.  ASAP is available as multiple precompiled executables that can handle up to 20,000 segments.  The strong point of ASAP is the ability to handle dielectrics.  With this program, you could model a submarine LF antenna that is insulated and immersed in sea water!

GEMACS was free up to version 3.5, then it was rewritten and became export controlled.  Most other ancient programs disappeared due to bit rot.  I looked high and low for old copies of GEMACS, but could not find any - it would probably be very limited anyway.  The modern version of GEMACS is quite reasonably priced at about $12500 and is available in multiple versions for use on anything from PCs to super computers.  IMHO this program leaves all others in the dust, both for ability and price.


Thank you to Neoklis Kyriazis for translating NEC2 to C.

Have fun!


No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.