ansys / pyaedt

AEDT Python Client Package
https://aedt.docs.pyansys.com
MIT License
207 stars 128 forks source link

Cannot assign lumped port using hfss.lumped_port #5400

Open Iyury1 opened 4 days ago

Iyury1 commented 4 days ago

Before submitting the issue

Description of the bug

PyAEDT INFO: Python version 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] PyAEDT INFO: PyAEDT version 0.11.3.

https://aedt.docs.pyansys.com/version/stable/API/_autosummary/ansys.aedt.core.hfss.Hfss.lumped_port.html

I am trying to create a lumped port for a microstrip antenna that consists of a patch antenna rectangle located above a ground plane rectangle.

The function hfss.lumped_port does not appear to be working correctly. When I try to define the port between two rectangles, I keep getting the error "PyAEDT ERROR: List of coordinates is not set correctly."

The lumped_port function doesnt appear to accept any coordinates as arguments. I am also confused by this function because when I assign a port in the UI, I typically would create a rectangle as a port face and define the origin and sizes for that rectangle, then i would assign the lumped port to that port rectangle. The lumped_port function seems like it doesn't operate on any port face rectangle, and only requires the adjacent conductors as arguments?

Additionally, I tried directly copying the example in the API reference

Which results in two errors:

PyAEDT ERROR: hfss.lumped_port("BoxLumped1","BoxLumped2",hfss.AxisDir.XNeg,50,"LumpedPort",True,False) PyAEDT ERROR: Unsupported operand type(s) for divmod(): 'str' and 'int' on get_mid_points_on_dir PyAEDT ERROR: Last Electronics Desktop Message - [error] unsupported operand type(s) for divmod(): 'str' and 'int' on get_mid_points_on_dir

PyAEDT ERROR: hfss.lumped_port("BoxLumped1","BoxLumped2",hfss.AxisDir.XNeg,50,"LumpedPort",True,False) PyAEDT ERROR: Cannot unpack non-iterable bool object on lumped_port PyAEDT ERROR: Last Electronics Desktop Message - [error] cannot unpack non-iterable bool object on lumped_port

I also noticed that the documentation for this function says "Create a waveport taking the closest edges of two objects." This is not very encouraging because the function is supposed to create a lumped port, not a wave port. Does this lumped_port function even work at all?

Steps To Reproduce

Here is the code to produce this error: "PyAEDT ERROR: List of coordinates is not set correctly."

        hfss.modeler.primitives.create_rectangle(
            orientation="XY",
            origin=[stack_width/2 - patch_width/2, stack_length/2 - patch_length/2, substrate1_thickness],
            sizes=[patch_width, patch_length],
            angle=0,
            name="PatchAntenna"
        )

    ground_plane = hfss.modeler.primitives.create_rectangle(
        orientation="XY",
        origin=[0, 0, 0],
        sizes=[stack_width, stack_length],
        name="GroundPlane",
    )
    hfss.lumped_port(
        assignment="PatchAntenna",
        reference="GroundPlane",
        integration_line=[0, 1, 0],
        impedance=50,
        name="LumpedPort",
        renormalize=True,
        deembed=False
    )

Here is the code from the API Reference that results in the errors: "PyAEDT ERROR: hfss.lumped_port("BoxLumped1","BoxLumped2",hfss.AxisDir.XNeg,50,"LumpedPort",True,False) PyAEDT ERROR: Unsupported operand type(s) for divmod(): 'str' and 'int' on get_mid_points_on_dir PyAEDT ERROR: Last Electronics Desktop Message - [error] unsupported operand type(s) for divmod(): 'str' and 'int' on get_mid_points_on_dir

PyAEDT ERROR: hfss.lumped_port("BoxLumped1","BoxLumped2",hfss.AxisDir.XNeg,50,"LumpedPort",True,False) PyAEDT ERROR: Cannot unpack non-iterable bool object on lumped_port PyAEDT ERROR: Last Electronics Desktop Message - [error] cannot unpack non-iterable bool object on lumped_port "

box1 = hfss.modeler.create_box([0, 0, 50],[10, 10, 5],"BoxLumped1","copper")
box2 = hfss.modeler.create_box([0, 0, 60],[10, 10, 5],"BoxLumped2","copper")
hfss.lumped_port("BoxLumped1","BoxLumped2",hfss.AxisDir.XNeg,50,"LumpedPort",True,False)

Which Operating System are you using?

Windows

Which Python version are you using?

3.12

Installed packages

annotated-types==0.7.0 ansys-pythonnet==3.1.0rc4 attrs==24.2.0 certifi==2024.8.30 cffi==1.17.1 charset-normalizer==3.4.0 click==8.1.7 click-plugins==1.1.1 cligj==0.7.2 clr-loader==0.2.6 colorama==0.4.6 contourpy==1.3.0 cycler==0.12.1 defusedxml==0.7.1 et_xmlfile==2.0.0 fast_simplification==0.1.7 fiona==1.10.1 fonttools==4.54.1 fpdf2==2.8.1 geopandas==0.14.4 idna==3.10 imageio==2.36.0 joblib==1.4.2 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 kiwisolver==1.4.7 markdown-it-py==3.0.0 matplotlib==3.9.2 mdurl==0.1.2 meshio==5.3.5 networkx==3.3 numpy==1.26.4 openpyxl==3.1.5 osmnx==1.9.4 packaging==24.2 pandas==2.2.3 pillow==11.0.0 platformdirs==4.3.6 plumbum==1.9.0 pooch==1.8.2 psutil==6.1.0 pyaedt==0.11.3 pycparser==2.22 pydantic==2.9.2 pydantic_core==2.23.4 pyedb==0.31.0 Pygments==2.18.0 pyparsing==3.2.0 pyproj==3.7.0 python-dateutil==2.9.0.post0 pytz==2024.2 pyvista==0.44.1 pywin32==308 PyYAML==6.0.2 referencing==0.35.1 requests==2.32.3 rich==13.9.4 rpds-py==0.21.0 rpyc==6.0.1 Rtree==1.3.0 scikit-learn==1.5.2 scikit-rf==1.3.0 scipy==1.14.1 scooby==0.10.0 shapely==2.0.6 six==1.16.0 SRTM.py==0.3.7 threadpoolctl==3.5.0 toml==0.10.2 typing_extensions==4.12.2 tzdata==2024.2 urllib3==2.2.3 utm==0.7.0 vtk==9.3.1

Iyury1 commented 4 days ago

Ok after reading the API reference a bit more closely and looking at this issue https://github.com/ansys/pyaedt/issues/4438

I realize that I am not providing enough points in my integration line.

I am still confused about how this lumped_port function creates a port, and how ports work in general.

AFAIK a port needs to be defined adjacent to two conductors, but according to tutorials I have seen, the port itself is also a rectangle. So my understanding is that I need to associate three objects with the port:

Can someone tell me if the "assignment" and "reference" parameters refer to the two conductors that the port is adjacent to? In that case will lumped_port() create the port face automatically?

Or is my understanding incorrect?