An Electromagnetic Simulation Environment

An Electromagnetic Simulation Environment Eric Jones, Balaji Krishnapuram, John Pormann, John Board, Larry Carin [email protected], Enthought, Inc. A...
Author: Lucas Riley
1 downloads 1 Views 87KB Size
An Electromagnetic Simulation Environment Eric Jones, Balaji Krishnapuram, John Pormann, John Board, Larry Carin [email protected], Enthought, Inc. Austin, Tx, 78744. [email protected], Center for Applied Remote Sensing, Duke University, Durham, NC, 27708.

Abstract We present a general purpose simulator that includes electromagnetic scattering tools for buried targets and standard signal processing functionality. Additional modules for genetic or gradient optimization, parallel processing, and multi-aspect target detection via Hidden Markov Models are also available. The entire library is completely scriptable for customization and web enabled for publishing results on the internet. It is also extensible so that users can add modules that address their specific need. The tool runs on both Unix and Windows platforms and includes graphic modules for plotting results and images as well as three-dimensional visualization capabilities for displaying target meshes, currents, and scattered fields. Electromagnetic scattering is calculated via either the Method of Moments (MoM) for arbitrarily shaped three-dimensional perfectly electric conducting (PECs) or dielectric targets above or embedded within a lossy half space. The code uses the combined-field integral equations with the rigorous half-space dyadic Green’s function computed via the method of complex images. The simulator offers coarsely parallel capabilities for distributing individual frequencies across a cluster of workstations with near linear speedup.

Introduction Any simulation engine, regardless of discipline, built for long term use should have the following characteristics: 1. 2. 3. 4.

Accurate for its specified domain, Documented, Modular, and Scriptable.

Efficiency is also important, but as long as the engine is “efficient enough” in both time and memory to solve a given problem, the listed traits carry far more weight because they save practitioners time, a commodity much more valuable than CPU cycles. There are other concerns such as testability, usability, etc., but they are secondary and, in many Enabling Technology for Simulation Science V, Alex F. Sisti, Dawn A. Trevisani, Editors, Proceedings of SPIE Vol. 4367 (2001) © 2001 SPIE. · 0277-786X/01/$15.00

137

cases, often addressed if the above four are well met. The benefits of accuracy and documentation are rather obvious. Users must have confidence in results from the engine as well as information on how to use it. Modularity implies the engine can be joined with other modules to form larger applications, and scripting offers access to the internals of the engine allowing users to write scripts that both control and extend the simulators capabilities. These last two, modularity and scriptability are closely related and are discussed together under the topic of scripting. Scripting is important for several reasons. From the developer’s perspective, scripting helps narrow the project’s scope and shrink the managed code base. Electromagnetics experts can focus on developing the simulation engine, relying on modules developed by experts in other areas for pre/post processing, visualization, etc. Users also benefit. Developers can never fully anticipate practitioner’s needs. Scripting affords users the ability to extend and customize the engine to their particular problem. This paper focuses on transforming an accurate, but stand-alone, Fortran 90 electromagnetics scattering code into a scriptable, self documenting tool. Python, an interactive programming language, serves as the scripting language allowing the simulator to leverage the wealth of mathematic, visualization, parallelization, and web tools already available for this powerful open-source language. The result is an interactive simulation environment that provides pre and post processing capabilities as well.

Electromagnetics Scattering Code The electromagnetics scattering code has been developed for calculating the radar signature of buried land mines and unexploded ordinances, or vehicles over soil. It is based on the method-of-moments and is capable of modeling arbitrarily shaped threedimensional, perfectly electric conducting (PECs) or dielectric targets above or embedded within a lossy half space. The code uses the combined-field integral equations with the rigorous half-space dyadic Green’s function computed via the method of complex images for this purpose. The theoretical underpinnings of this and its companion code based on the Multi Level Fast Multiple Algorithm (MLFMA) are well discussed and their accuracy validated in the literature [1-5].

Python Python[6] is an interpreted programming language that allows you to do almost anything possible with a compiled language (C/C++/Fortran) without requiring all the complexity. It does remarkably well at spanning the space of general programming and mathematical programming tasks. Python also excels as a glue language to patch together legacy Fortran/C codes that make up the bulk of existing scientific algorithms. These traits, along with its open-source development model, make it an ideal choice as a scripting language for scientific computing. Python earned it stripes on the Internet powering popular sights such as Yahoo! and

138

Proc. SPIE Vol. 4367

WebMD. This web heritage results in a large number of modules that simplify the "webification" of scientific computing. Support for FTP, HTTP, email, and XML are part of Python’s standard library. For scientific applications, bindings to advanced visualization tools such as the Visualization Tool Kit [7] and OpenGL are available as well as bindings to many of the generic and fast scientific libraries such as the standard FFTPACK and LAPACK libraries available at netlib [8]. In addition, we have developed modules for genetic and gradient optimization as well as hidden Markov models. As an example of how these tools can be merged, a short script less than a page long can: (1) run a multi-frequency electromagnetics simulation in parallel on a beowulf cluster (2) graph the results, (3) place the graph on a web page, (4) send the web page to a web server via FTP, and (5) e-mail interested users with a link to the web page, notifying them that the simulation is finished. Because Python is interactive, it also serves as an environment for running simulation in a fashion similar to Matlab. The following illustrates an example of importing the electromagnetics module, em, and creating a frequency independent material object for use in a simulation: >>> import em >>> epsilon_r = 4.8 >>> mu_r = 1 >>> epoxy_glass = em.constant_material(epsilon_r, ... mu_r) >>> epoxy_glass.eps() 4.2499e-11 Python loads modules, such as em, dynamically at run-time allowing for interactive debugging. For example, if em was found to have a bug, the developer could edit and reload the module without having to restart the interpreter. This speeds the debugging process significantly. Further, users can derive new objects from those within the em module to customize the objects’ behavior to the users’ needs. Python has several features that ease the learning curve for users new to the em module. If a user is unsure of the what methods and classes are available from the em module, its possible to discover these at run time using the dir() function. Further, Python implements documentation strings, or doc-strings. Doc-strings are source code comments that are exposed at run-time and provide users insight into the purpose and calling conventions of functions and classes. The following code fragment from a source file illustrates the concept.

Proc. SPIE Vol. 4367

139

# from module em.py class constant_material: ””” contant_material(epsilon,mu) – define a frequency independent material with the given relative permittivity and permeability. ””” It is straight forward to write a help() function that prints these strings at the command line offering an built-in help tool facility. # List all functions and classes in the em. >>> dir(em) [ ...,‘layered_media', 'lu_solver', ’constant_material', 'mom', ...] # Pick an object and find out more about it. >>> help(em.contant_material) contant_material(epsilon,mu) – define a frequency independent material with the given relative permittivity and permeability. Doc-strings have the added benefit that they help keep documentation synchronized with changes to the underlying source code. When developers change a function they are more likely to change the doc-strings of the function than they are of searching out and editing a separate manual.

Wrapping the code Standard modules are written directly in the Python language, but extension modules can also be written in C. This is useful when particular algorithms need to be written in a compiled language for speed or when interfacing with legacy code. While the distinction between standard and extension modules is transparent to the user, extension modules do require extra work from the developer. Fortunately, there are code generation tools that handle most of the work required to wrap C or Fortran functions automatically. f2py [9] is such a tool for Fortran codes and worked well in wrapping the necessary functions from the MoM simulator. It was only necessary to wrap the portions of the code concerned with generating the impedance matrix, the driving vector, and scattered field calculations. Much of the supporting code dealing with linear algebra and Fourier transforms was not used because equivalent capabilities already exist in Python. In addition, routines for parsing input and generating output files were not necessary in the interactive environment. As a result, adding scripting capabilities to the simulator has a smaller code base and requires less maintenance than the stand-alone application.

Examples

140

Proc. SPIE Vol. 4367

This section provides several examples of interactive sessions with the simulator. The first calculates the monostatic radar cross section of a buried sphere at multiple frequencies. The individual frequencies are executed in parallel across a beowulf cluster. Because the parallelism is coarse grained, it scales well, offering a speed-up of 98% on 32 node clusters even for small targets. Due to Python’s cross-platform support, the code runs equally well on Windows or Linux platforms, although parallel execution is currently only supported on Linux. >>> import em # grab a pre-defined mesh >>> sphere = em.standard_mesh.small_sphere() # bury the mesh .15 meters under ground. >>> sphere.offset( (0, 0, -.15) ) # define the materials properties of the halfspace. >>> material_list = [em.air, em.yuma_soil] >>> environment = em.layered_media[material_list] # create a MoM solver based on the mesh & environment >>> solver = em.mom(sphere, environment) # define frequencies and incidence angles [theta,phi] >>> freq = range( 100e6, 200e6, 5e6) >>> angle = [[1.57, 0]] # import info about our beowulf cluster (named herd). >>> import herd # run a parallel solve for the rcs of the sphere. >>> results = em.monostatic.parallel_rcs(solver, freq, ... angles, herd.cluster) These commands can also be written as a script so that it is not necessary to re-enter the commands for repeated sphere simulations. The second example illustrates the visualization capabilities of the simulator. The following lines of code create an interactive three-dimensional view of a T72 tank mesh for simulations up to 450 MHz. Figure 1. >>> tank = em.standard_mesh.T72_450() >>> tank.view() Finally, Figure 2 offers an example web interface to the simulator that allows users to upload a mesh and execute multi-frequency simulations in parallel across a beowulf cluster. Typically, simulations are long running, so users are sent an e-mail containing links to their results when the simulation finishes. Because of Python’s standard support for web applications, the development of the web interface is straight forward.

Proc. SPIE Vol. 4367

141

Conclusion We have demonstrated the conversion of existing stand-alone electromagnetic simulation engines to a scriptable Python module. This enables its use in interactive environments and web applications. This ongoing project currently supports the MoM portion of the solver discussed in [1-5] as well as visualization and post processing modules for multiaspect target recognition using hidden Markov models. The companion MLFMA algorithm is being added for extended capabilities. Modules for SAR image formation and processing are also under development.

References [1] N. Geng, A. Sullivan and L. Carin, “Fast multipole method for scattering from a arbitrary PEC target above or below a lossy half space,” Microwave and Optical Tech. Letts., June 20, 1999. [2] J. He, T. Yu, N. Geng and L. Carin, “Method-of-moments analysis of electromagnetic scattering from a general three-dimensional dielectric target embedded in a multilayered medium,” Radio Science, vol. 35, pp. 305-313, Mar.-Apr. 2000. [3] N. Geng, A. Sullivan and L. Carin, “Multi-level fast-multipole algorithm for scattering from conducting targets above or embedded in a lossy half space,” IEEE Trans. Geoscience Remote Sensing, vol. 38, pp. 1567-1579, July 2000. [4] N. Geng, A. Sullivan and L. Carin, “Fast multipole method analysis of scattering from a three-dimensional target in a half-space environment,” accepted for publication in IEEE Trans. Antennas Propagat. [5] J. He, A. Sullivan and L. Carin, “Multi-level fast multipole algorithm for threedimensional dielectric targets in the vicinity of a lossy half space”, Microwave and Optical Tech. Letters, April 20, 2001 [6] M. Lutz, Programming Python 2nd Ed., O’Reilly, Sebastopol, CA, 2001. [7] W. Schroeder, K. Martin, B. Lorensen, The Visualization Toolkit, Prentice Hall, New Jersey, 1998. [8] www.netlib.org. [9] P. Peterson, J. Martins, J. Alonso, “Fortran to Python Interface Generator with an Application to Aerospace Engineering,” 9th Annual Python Conference, Long Beach, Ca, March, 2001.

142

Proc. SPIE Vol. 4367

Figure 1: View of a T72 tank mesh offered by the mesh.view command. The image is interactive, allowing the user to spin, pan, and zoom the image using the mouse.

Figure 2: Web interface for calculating monostatic radar cross section of a user supplied mesh. For long running tasks, user is e-mailed when the claculations are finished.

Proc. SPIE Vol. 4367

143

Suggest Documents