.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\02-HFSS\Flex_CPWG.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_02-HFSS_Flex_CPWG.py: HFSS: flex cable CPWG --------------------- This example shows how you can use PyAEDT to create a flex cable CPWG (coplanar waveguide with ground). .. GENERATED FROM PYTHON SOURCE LINES 8-11 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: default import os from math import radians, sin, cos, sqrt import pyaedt .. GENERATED FROM PYTHON SOURCE LINES 17-21 Set non-graphical mode ~~~~~~~~~~~~~~~~~~~~~~ Set non-graphical mode. You can set ``non_graphical`` either to ``True`` or ``False``. .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: default non_graphical = False .. GENERATED FROM PYTHON SOURCE LINES 25-28 Launch AEDT ~~~~~~~~~~~ Launch AEDT 2023 R2 in graphical mode. .. GENERATED FROM PYTHON SOURCE LINES 28-39 .. code-block:: default hfss = pyaedt.Hfss(specified_version="2023.2", solution_type="DrivenTerminal", new_desktop_session=True, non_graphical=non_graphical) hfss.change_material_override(True) hfss.change_automatically_use_causal_materials(True) hfss.create_open_region("100GHz") hfss.modeler.model_units = "mil" hfss.mesh.assign_initial_mesh_from_slider(applycurvilinear=True) .. rst-class:: sphx-glr-script-out .. code-block:: none Initializing new desktop! True .. GENERATED FROM PYTHON SOURCE LINES 40-43 Create variables ~~~~~~~~~~~~~~~~ Create input variables for creating the flex cable CPWG. .. GENERATED FROM PYTHON SOURCE LINES 43-56 .. code-block:: default total_length = 300 theta = 120 r = 100 width = 3 height = 0.1 spacing = 1.53 gnd_width = 10 gnd_thickness = 2 xt = (total_length - r * radians(theta)) / 2 .. GENERATED FROM PYTHON SOURCE LINES 57-61 Create bend ~~~~~~~~~~~ Create the bend. The ``create_bending`` method creates a list of points for the bend based on the curvature radius and extension. .. GENERATED FROM PYTHON SOURCE LINES 61-78 .. code-block:: default def create_bending(radius, extension=0): position_list = [(-xt, 0, -radius), (0, 0, -radius)] for i in [radians(i) for i in range(theta)] + [radians(theta + 0.000000001)]: position_list.append((radius * sin(i), 0, -radius * cos(i))) x1, y1, z1 = position_list[-1] x0, y0, z0 = position_list[-2] scale = (xt + extension) / sqrt((x1 - x0) ** 2 + (z1 - z0) ** 2) x, y, z = (x1 - x0) * scale + x0, 0, (z1 - z0) * scale + z0 position_list[-1] = (x, y, z) return position_list .. GENERATED FROM PYTHON SOURCE LINES 79-82 Draw signal line ~~~~~~~~~~~~~~~~ Draw a signal line to create a bent signal wire. .. GENERATED FROM PYTHON SOURCE LINES 82-92 .. code-block:: default position_list = create_bending(r, 1) line = hfss.modeler.create_polyline( position_list=position_list, xsection_type="Rectangle", xsection_width=height, xsection_height=width, matname="copper", ) .. GENERATED FROM PYTHON SOURCE LINES 93-96 Draw ground line ~~~~~~~~~~~~~~~~ Draw a ground line to create two bent ground wires. .. GENERATED FROM PYTHON SOURCE LINES 96-108 .. code-block:: default gnd_r = [(x, spacing + width / 2 + gnd_width / 2, z) for x, y, z in position_list] gnd_l = [(x, -y, z) for x, y, z in gnd_r] gnd_objs = [] for gnd in [gnd_r, gnd_l]: x = hfss.modeler.create_polyline( position_list=gnd, xsection_type="Rectangle", xsection_width=height, xsection_height=gnd_width, matname="copper" ) x.color = (255, 0, 0) gnd_objs.append(x) .. GENERATED FROM PYTHON SOURCE LINES 109-112 Draw dielectric ~~~~~~~~~~~~~~~ Draw a dielectric to create a dielectric cable. .. GENERATED FROM PYTHON SOURCE LINES 112-123 .. code-block:: default position_list = create_bending(r + (height + gnd_thickness) / 2) fr4 = hfss.modeler.create_polyline( position_list=position_list, xsection_type="Rectangle", xsection_width=gnd_thickness, xsection_height=width + 2 * spacing + 2 * gnd_width, matname="FR4_epoxy", ) .. GENERATED FROM PYTHON SOURCE LINES 124-127 Create bottom metals ~~~~~~~~~~~~~~~~~~~~ Create the bottom metals. .. GENERATED FROM PYTHON SOURCE LINES 127-138 .. code-block:: default position_list = create_bending(r + height + gnd_thickness, 1) bot = hfss.modeler.create_polyline( position_list=position_list, xsection_type="Rectangle", xsection_width=height, xsection_height=width + 2 * spacing + 2 * gnd_width, matname="copper", ) .. GENERATED FROM PYTHON SOURCE LINES 139-142 Create port interfaces ~~~~~~~~~~~~~~~~~~~~~~ Create port interfaces (PEC enclosures). .. GENERATED FROM PYTHON SOURCE LINES 142-166 .. code-block:: default port_faces = [] for face, blockname in zip([fr4.top_face_z, fr4.bottom_face_x], ["b1", "b2"]): xc, yc, zc = face.center positions = [i.position for i in face.vertices] port_sheet_list = [((x - xc) * 10 + xc, (y - yc) + yc, (z - zc) * 10 + zc) for x, y, z in positions] s = hfss.modeler.create_polyline(port_sheet_list, close_surface=True, cover_surface=True) center = [round(i, 6) for i in s.faces[0].center] port_block = hfss.modeler.thicken_sheet(s.name, -5) port_block.name = blockname for f in port_block.faces: if [round(i, 6) for i in f.center] == center: port_faces.append(f) port_block.material_name = "PEC" for i in [line, bot] + gnd_objs: i.subtract([port_block], True) print(port_faces) .. rst-class:: sphx-glr-script-out .. code-block:: none [7391] [7391, 7586] .. GENERATED FROM PYTHON SOURCE LINES 167-170 Create boundary condition ~~~~~~~~~~~~~~~~~~~~~~~~~ Creates a Perfect E boundary condition. .. GENERATED FROM PYTHON SOURCE LINES 170-177 .. code-block:: default boundary = [] for face in [fr4.top_face_y, fr4.bottom_face_y]: s = hfss.modeler.create_object_from_face(face) boundary.append(s) hfss.assign_perfecte_to_sheets(s) .. GENERATED FROM PYTHON SOURCE LINES 178-181 Create ports ~~~~~~~~~~~~ Creates ports. .. GENERATED FROM PYTHON SOURCE LINES 181-187 .. code-block:: default for s, port_name in zip(port_faces, ["1", "2"]): reference = [i.name for i in gnd_objs + boundary + [bot]] + ["b1", "b2"] hfss.wave_port(s.id, name=port_name, reference=reference) .. GENERATED FROM PYTHON SOURCE LINES 188-191 Create setup and sweep ~~~~~~~~~~~~~~~~~~~~~~ Create the setup and sweep. .. GENERATED FROM PYTHON SOURCE LINES 191-207 .. code-block:: default setup = hfss.create_setup("setup1") setup["Frequency"] = "2GHz" setup.props["MaximumPasses"] = 10 setup.props["MinimumConvergedPasses"] = 2 hfss.create_linear_count_sweep( setupname="setup1", unit="GHz", freqstart=1e-1, freqstop=4, num_of_freq_points=101, sweepname="sweep1", save_fields=False, sweep_type="Interpolating", ) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 208-211 Plot model ~~~~~~~~~~ Plot the model. .. GENERATED FROM PYTHON SOURCE LINES 211-219 .. code-block:: default my_plot = hfss.plot(show=False, plot_air_objects=False) my_plot.show_axes = False my_plot.show_grid = False my_plot.plot( os.path.join(hfss.working_directory, "Image.jpg"), ) .. image-sg:: /examples/02-HFSS/images/sphx_glr_Flex_CPWG_001.png :alt: Flex CPWG :srcset: /examples/02-HFSS/images/sphx_glr_Flex_CPWG_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none True .. GENERATED FROM PYTHON SOURCE LINES 220-224 Analyze and release ~~~~~~~~~~~~~~~~~~~~ Uncomment the ``hfss.analyze`` command if you want to analyze the model and release AEDT. .. GENERATED FROM PYTHON SOURCE LINES 224-226 .. code-block:: default hfss.release_desktop() .. rst-class:: sphx-glr-script-out .. code-block:: none True .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 58.990 seconds) .. _sphx_glr_download_examples_02-HFSS_Flex_CPWG.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Flex_CPWG.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Flex_CPWG.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_