matthuszagh / pyems

High-level python interface to OpenEMS with automatic mesh generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Apply CSTransform when Creating a Microstrip (TypeError: unsupported operand type(s) for -: 'list' and 'list')

biergaizi opened this issue · comments

I was trying to simulate a Y-junction and I need a microstrip segment rotated by 45 degrees. Thus, I attempted to use the CSTransform argument in the class Microstrip(). Unfortunately it doesn't seem to work. Is it a bug or am I misusing this parameter? I looked at all the demos but none demonstrated its uses.

Here's the reproducer.

#!/usr/bin/env python3

import numpy as np
from pyems.pcb import common_pcbs
from CSXCAD.CSTransform import CSTransform
from pyems.simulation import Simulation
from pyems.structure import (
    PCB,
    Microstrip,
)
from pyems.coordinate import Axis

unit = 1e-3
freq = np.arange(0, 18e9, 1e7)
sim = Simulation(freq=freq, unit=unit)
pcb_prop = common_pcbs["oshpark4"]
pcb_len = 10
pcb_width = 5

pcb = PCB(
    sim=sim,
    pcb_prop=pcb_prop,
    length=pcb_len,
    width=pcb_width,
    layers=range(3),
    omit_copper=[0],
)

# Create a dummy CSTransform object, without even doing anything.
tr = CSTransform()

microstrip1 = Microstrip(
    pcb=pcb,
    position=(0, 0),
    length=1,
    width=1,
    transform=tr,
    propagation_axis=Axis("x"),
    trace_layer=0,
    gnd_layer=1,
)

Running this demo triggers the following exceptions.

Traceback (most recent call last):
  File "/home/user/code/pyems/examples/experiments/microstrip_transform.py", line 31, in <module>
    microstrip1 = Microstrip(
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 959, in __init__
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 998, in construct
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/structure.py", line 1046, in _construct_trace
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/csxcad.py", line 144, in construct_box
  File "/home/user/.local/lib/python3.9/site-packages/pyems-0.1.0-py3.9.egg/pyems/coordinate.py", line 623, in origin_start
TypeError: unsupported operand type(s) for -: 'list' and 'list'

Any hints will be greatly appreciated.

Thanks for reporting, this is indeed a bug. It should be fixed as of bd57c6f.