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

# Synthesize width for target Z0 using the functional API
syn_result = synthesize_microstrip(
    eps_r=3.66,  # Relative permittivity (3.66)
    tand=0.0037,  # Loss tangent (0.0037)
    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, 1.0)
    murc=1.0,  # Relative permeability (conductor, 1.0)
    frequency=2.45e9,  # Frequency (2.45 GHz)
    z0_target=50.0,  # Target impedance (50 ohms)
    ang_l_target=30.0,  # Target angle for length synthesis (degrees)
)
print("Synthesis result:")
print(f"Synthesized width: {syn_result.width * 1e3:.4f} mm")
print(f"Effective permittivity: {syn_result.epsilon_eff:.4f}")
print(f"Skin depth: {syn_result.skin_depth * 1e6:.4f} um")
print(f"Conductor attenuation: {syn_result.atten_cond:.4f} dB/m")
print(f"Dielectric attenuation: {syn_result.atten_diel:.4f} dB/m")
print(f"Physical length: {syn_result.length * 1e3:.4f} mm")

Analyze Microstrip for Given Width and Length

from hfsynpy import analyze_microstrip

# Analyze for a specific width using the functional API
ana_result = analyze_microstrip(
    width=0.79e-3,  # 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,  # 50 mm
)
print("\nAnalysis result:")
print(f"Characteristic impedance: {ana_result.Z0_0:.4f} ohms")
print(f"Effective permittivity: {ana_result.epsilon_eff:.4f}")
print(f"Skin depth: {ana_result.skin_depth * 1e6:.4f} um")
print(f"Conductor attenuation: {ana_result.atten_cond:.4f} dB/m")
print(f"Dielectric attenuation: {ana_result.atten_diel:.4f} dB/m")
print(f"Angle shift: {ana_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.3.tar.gz (17.7 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.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hfsynpy-0.1.3.tar.gz
  • Upload date:
  • Size: 17.7 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.3.tar.gz
Algorithm Hash digest
SHA256 471f98178698dfd18ece358cc402692a6d5005f8084c4bcda070deb90ddcc786
MD5 ac2997dbc3f5c7cf7ffee269d3b5347d
BLAKE2b-256 38c00c3ff3137695d05e5c691bdf13f2b3ef9956638c3871e3b6dad216c16c1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hfsynpy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa46b29d63d10b96b8e426414c0e6da725bc24859e5d64854f9c502264981b41
MD5 9534523f6da69dcd6951860d4f4e0696
BLAKE2b-256 0d0eabf48e75142c2179cc3b0a8a03d65bac044b10c136ed32dc1bb8f23f187e

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