Skip to main content

A Python library for synthesis and analysis of high frequency component (currently only microstrip transmission lines), providing accurate models and convenient tools for PCB and RF design.

Project description

hfsynpy

A modern Python package for high-frequency (HF) microstrip synthesis and analysis, inspired by the models used in KiCad. This library provides accurate, user-friendly tools for PCB and RF design, supporting both synthesis (width/length for target impedance and angle) and analysis (impedance, losses, phase shift for given geometry).

See the full documentation for all parameters, advanced usage, and API details.


Features

  • Synthesize microstrip width for a target impedance and electrical angle (input in degrees)
  • Analyze microstrip properties for a given width and physical length (input in meters)
  • Returns all results as well-documented dataclasses
  • Outputs attenuation per meter (dB/m), effective permittivity, skin depth, and more
  • Computes and returns phase shift (angle in degrees) for a given length
  • No external dependencies required
  • Well-documented, pip-installable, and tested

Installation

pip install hfsynpy

Quick Start

Synthesize Microstrip for Target Impedance and Angle

from hfsynpy import synthesize_microstrip

result = synthesize_microstrip(
    eps_r=3.66,        # Relative permittivity
    tand=0.0037,       # Loss tangent
    h=1.524e-3,        # Substrate height (1.524 mm)
    t=35e-6,           # Copper thickness (35 um)
    rough=0e-6,        # Surface roughness (0 um)
    sigma=1 / (1.72e-8), # Copper conductivity (5.814e7 S/m)
    mur=1.0,           # Relative permeability (substrate)
    murc=1.0,          # Relative permeability (conductor)
    frequency=2.45e9,  # Frequency (2.45 GHz)
    z0_target=50.0,    # Target impedance (ohms)
    ang_l_target=30.0, # Target angle for length synthesis (degrees)
)
print(f"Synthesized width: {result.width * 1e3:.4f} mm")
print(f"Physical length: {result.length * 1e3:.4f} mm")

Analyze Microstrip for Given Width and Length

from hfsynpy import analyze_microstrip

result = analyze_microstrip(
    width=0.79e-3,     # Trace width (0.79 mm)
    eps_r=3.66,
    tand=0.0037,
    h=1.524e-3,
    t=35e-6,
    rough=0e-6,
    sigma=1 / (1.72e-8),
    mur=1.0,
    murc=1.0,
    frequency=2.45e9,
    length=50e-3,      # Physical length (50 mm)
)
print(f"Characteristic impedance: {result.Z0_0:.4f} ohms")
print(f"Angle shift: {result.angle_deg:.4f} degrees")

API Overview

synthesize_microstrip(...)

  • Synthesize width for target impedance and angle (degrees)
  • Returns: MicrostripSynthesisResult dataclass

analyze_microstrip(...)

  • Analyze for given width and length (meters)
  • Returns: MicrostripAnalysisResult dataclass (includes angle_deg if length is given)

License

This project is licensed under the GNU General Public License v2 or later (GPL-2.0-or-later). See the LICENSE file for details.


Attribution

This package is part of a Python translation of KiCad's C++ source code.

Original C++ code:

Python translation and modifications:

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


For bug reports, feature requests, or contributions, please use the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hfsynpy-0.1.1.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hfsynpy-0.1.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file hfsynpy-0.1.1.tar.gz.

File metadata

  • Download URL: hfsynpy-0.1.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for hfsynpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 796a66a203aa00d21694f8f2d3b1b3e3ad43ee14831c6887e4b7ed472bd78ca5
MD5 e7d2ae3d02ac30196a610aeff342981d
BLAKE2b-256 bc6e46d0b07838b9930d6e873e1a78ebddb9d825793b77ceed9456cf02c9f1d4

See more details on using hashes here.

File details

Details for the file hfsynpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hfsynpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for hfsynpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2e551f301e70f2ec544b82fa2a0739a0c4a864f0be01e904d908be235a6712c
MD5 83fb87c4c5bda0daf5346488f8049701
BLAKE2b-256 cd3601d7c96fdd151ddc1d8da9c9ce12a4f326315ec7d6d5c0bb55267034ce8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page