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.0.tar.gz (17.0 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.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hfsynpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c486ffa5db176f6a35b385d84ca2279d693eab2aa87c6f602d947824daa92ea6
MD5 e72012a82705ffaa76a9e2f2b6a69751
BLAKE2b-256 5d39d6fd63a9a6ed2ac3b3333fc7957bacb8719858d1712d14236a97d8c37db2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hfsynpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72ef9ed58703abeb654fa4aed261dcd5821954e4d6ffbbf0a9b8a71c54326ad3
MD5 47b9e1e5799132129e79edc388dd3a53
BLAKE2b-256 4234ce04e6291e6f3badb10fd2a13796e433574b207cb699ea42cc82f9e8ccfc

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