Metadata-Version: 2.1
Name: pyemfield
Version: 0.1.2
Summary: A Python library for HFSS antenna radiation pattern analysis and gain optimization
Home-page: https://github.com/linmingchih/pyemfield
Author: Lin, Ming Chih
Author-email: mingchih.lin8@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.18.0
Requires-Dist: scipy>=1.4.0
Requires-Dist: matplotlib>=3.1.0
Requires-Dist: pyaedt>=0.10.1

# pyemf: Python Antenna Radiation Analysis and Optimization Library

`pyemf` is a Python library designed for antenna radiation pattern analysis and gain optimization. The package leverages SciPy, NumPy, Matplotlib, and ANSYS HFSS (via `pyaedt`) to automate high-frequency structure simulations, process electromagnetic data, and visualize results.

## Key Features
- **Gain Calculation and Optimization**: Provides methods to calculate antenna gain with multiple optimization options, including exhaustive, heuristic, and SciPy-based optimizations.
- **Radiated Power Density and Cumulative Distribution**: Calculates and visualizes cumulative distribution functions (CDFs) for radiation characteristics.
- **Custom Radiation Pattern and Gain Distribution Plots**: Offers multiple plotting functions to visualize radiated power density, gain, and other related data.
- **Integration with HFSS**: Automates the export of far-field data from HFSS simulations for further analysis and optimization.

## Installation

You can install the package using `pip`:

```bash
pip install pyemf
```

> **Note**: Ensure that `pyaedt` and ANSYS HFSS are installed to fully utilize all functionalities in this package.

## Dependencies
This package requires the following libraries:
- `numpy`
- `scipy`
- `matplotlib`
- `pyaedt`

## Quick Start

### 1. Basic Usage Example

The following example demonstrates how to use `pyemf` to calculate and visualize antenna gain:

```python
from pyemf import Ffd, Beam, Plane, hfss_design

# Initialize HFSS design and export FFD files
hd = hfss_design()
folder = "path_to_ffd_folder"
hd.export_ffds(folder, 'Setup1 : Sweep', '30.0GHz')

# Load FFD files
ffds = get_ffds(folder)

# Create a Beam object and optimize gain
beam = Beam({ffd_obj: (1, 0) for ffd_obj in ffds.values()})
optimized_beam = beam.optimize_gain(40, 60)

# Visualize the gain contour plot
optimized_beam.plot_realized_gain_contour()
```

### 2. Create a Custom Plane and Plot Cumulative Distribution

```python
# Set up multiple beams and create a Plane
plane = create_plane("MyPlane", beam, [(0, 0), (90, 90)], fast=True)
plane.plot_rGain_cdf()
plane.plot_eirp_cdf()
```

## Module Overview

### Modules and Classes
- **`Ffd`**: Manages far-field data, including setting `Etheta` and `Ephi`, and calculates radiated power density.
- **`Cdf`**: Handles cumulative distribution function (CDF) calculations and plotting.
- **`Beam`**: Represents a single antenna beam, with support for various gain optimization methods.
- **`Plane`**: Represents a plane of multiple beams, providing distribution plots and cumulative distributions for gain and radiated power density.
- **`hfss_design`**: Interacts with ANSYS HFSS to export far-field data and set source excitations.

### Key Methods and Functionalities

- **Gain Calculation**: Methods such as `optimize_gain_exhaustive`, `optimize_gain_heuristic`, and `optimize_gain` offer different approaches to optimizing antenna gain.
- **Plotting**: Functions like `plot_realized_gain_contour`, `plot_rGain_cdf`, and `plot_eirp_cdf` help visualize antenna gain and radiation patterns effectively.
- **HFSS Integration**: The `hfss_design` class facilitates automatic far-field data export and the application of different beams for analysis.

## Version Information

- **Version**: 0.1.0
- **Author**: Ming Chih Lin
- **License**: MIT License

## Contact
If you have any questions or feedback, feel free to reach out:
- **Email**: mingchih.lin8@gmail.com
- **GitHub**: [pyemf Repository](https://github.com/linmingchih/pyemf)

## License
This project is licensed under the MIT License. For more details, see the [LICENSE](https://opensource.org/licenses/MIT) file.

