|
| 1 | +# # HFSS 3D Layout: Power Integrity Analysis |
| 2 | +# This example shows how to use the electronics database (EDB) for power integrity analysis. The |
| 3 | +# EDB will be loaded into HFSS 3D Layout for analysis and post-processing. |
| 4 | +# - Set up EDB |
| 5 | +# - Assign S-parameter model to components |
| 6 | +# - Create pin groups |
| 7 | +# - Create ports |
| 8 | +# - Create SIwave SYZ anaylsis |
| 9 | +# - Create cutout |
| 10 | +# - Import EDB into HFSS 3D Layout |
| 11 | +# - Analyze |
| 12 | +# - Plot $Z_{11}$ |
| 13 | + |
| 14 | +# ## Preparation |
| 15 | +# Import the required packages |
| 16 | + |
| 17 | +# + |
| 18 | +import os |
| 19 | +import json |
| 20 | +import tempfile |
| 21 | +import time |
| 22 | +from pyaedt import Edb |
| 23 | +from pyaedt import Hfss3dLayout |
| 24 | +from pyaedt.downloads import download_file |
| 25 | +try: |
| 26 | + from ansys.pyaedt.examples.constants import AEDT_VERSION |
| 27 | +except: |
| 28 | + AEDT_VERSION = "2024.1" |
| 29 | + |
| 30 | +NG_MODE = True |
| 31 | + |
| 32 | +# - |
| 33 | + |
| 34 | +# Download the example PCB data. |
| 35 | + |
| 36 | +temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") |
| 37 | +aedb = download_file( |
| 38 | + source="edb/ANSYS-HSD_V1.aedb", destination=temp_folder.name |
| 39 | +) |
| 40 | +download_file( |
| 41 | + source="touchstone", name="GRM32_DC0V_25degC_series.s2p", destination=temp_folder.name |
| 42 | +) |
| 43 | + |
| 44 | +# ## Create a configuration file |
| 45 | +# In this example, we are going to use a configuration file to set up the layout for analysis. |
| 46 | +# ### Initialize a dictionary |
| 47 | +# Create an empty dictionary to host all configurations. |
| 48 | + |
| 49 | +cfg = dict() |
| 50 | + |
| 51 | +# In this example, we are going to assign S-parameter models to capacitors. |
| 52 | +# The first step is to use the "general" key to specify where the S-parameter files can be found. |
| 53 | + |
| 54 | +cfg["general"] = { |
| 55 | + "s_parameter_library": os.path.join(temp_folder.name, "touchstone") |
| 56 | +} |
| 57 | + |
| 58 | +# ## Assign model to capactitors. |
| 59 | +# In this example, the model "GRM32_DC0V_25degC_series.s2p" is assigned to capacitors C3 and C4, which share the same component part number. |
| 60 | +# When "apply_to_all" is ``True``, all components having the part number "CAPC3216X180X20ML20" will be assigned the S-parameter model. |
| 61 | + |
| 62 | +cfg["s_parameters"] = [ |
| 63 | + { |
| 64 | + "name": "GRM32_DC0V_25degC_series", |
| 65 | + "component_definition": "CAPC0603X33X15LL03T05", |
| 66 | + "file_path": "GRM32_DC0V_25degC_series.s2p", |
| 67 | + "apply_to_all": False, |
| 68 | + "components": ["C110", "C206"], |
| 69 | + "reference_net": "GND", |
| 70 | + "reference_net_per_component": { |
| 71 | + "C110": "GND" |
| 72 | + } |
| 73 | + } |
| 74 | +] |
| 75 | + |
| 76 | +# ## Create pin groups. |
| 77 | +# In this example, the listed pins on component U2 are combined into two pin groups. |
| 78 | +# Pins can be grouped explicitly by the pin name or pin groups can be assigned by net name using the "net" key as shown here: |
| 79 | + |
| 80 | +cfg["pin_groups"] = [ |
| 81 | + { |
| 82 | + "name": "PIN_GROUP_1", |
| 83 | + "reference_designator": "U1", |
| 84 | + "pins": ["AD14", "AD15", "AD16", "AD17"] |
| 85 | + }, |
| 86 | + { |
| 87 | + "name": "PIN_GROUP_2", |
| 88 | + "reference_designator": "U1", |
| 89 | + "net": "GND" |
| 90 | + } |
| 91 | +] |
| 92 | + |
| 93 | +# ## Create ports |
| 94 | +# Create a circuit port between the two pin groups just created. |
| 95 | + |
| 96 | +cfg["ports"] = [ |
| 97 | + { |
| 98 | + "name": "port1", |
| 99 | + "reference_designator": "U1", |
| 100 | + "type": "circuit", |
| 101 | + "positive_terminal": { |
| 102 | + "pin_group": "PIN_GROUP_1" |
| 103 | + }, |
| 104 | + "negative_terminal": { |
| 105 | + "pin_group": "PIN_GROUP_2" |
| 106 | + } |
| 107 | + } |
| 108 | +] |
| 109 | + |
| 110 | +# ## Create SIwave SYZ analysis setup |
| 111 | +# Both SIwave and HFSS can be used to run an analysis in the 3D Layout user interface. |
| 112 | + |
| 113 | +cfg["setups"] = [ |
| 114 | + { |
| 115 | + "name": "siwave_syz", |
| 116 | + "type": "siwave_syz", |
| 117 | + "pi_slider_position": 1, |
| 118 | + "freq_sweep": [ |
| 119 | + { |
| 120 | + "name": "Sweep1", |
| 121 | + "type": "Interpolation", |
| 122 | + "frequencies": [ |
| 123 | + { |
| 124 | + "distribution": "log scale", |
| 125 | + "start": 1e6, |
| 126 | + "stop": 1e9, |
| 127 | + "samples": 20 |
| 128 | + } |
| 129 | + ] |
| 130 | + } |
| 131 | + ] |
| 132 | + } |
| 133 | +] |
| 134 | + |
| 135 | +# ## Cutout |
| 136 | +# The following assignments will define the region of the PCB to be cut out for analysis. |
| 137 | + |
| 138 | +cfg["operations"] = { |
| 139 | + "cutout": { |
| 140 | + "signal_list": ["1V0"], |
| 141 | + "reference_list": ["GND"], |
| 142 | + "extent_type": "ConvexHull", |
| 143 | + "expansion_size": 0.002, |
| 144 | + "use_round_corner": False, |
| 145 | + "output_aedb_path": "", |
| 146 | + "open_cutout_at_end": True, |
| 147 | + "use_pyaedt_cutout": True, |
| 148 | + "number_of_threads": 4, |
| 149 | + "use_pyaedt_extent_computing": True, |
| 150 | + "extent_defeature": 0, |
| 151 | + "remove_single_pin_components": False, |
| 152 | + "custom_extent": "", |
| 153 | + "custom_extent_units": "mm", |
| 154 | + "include_partial_instances": False, |
| 155 | + "keep_voids": True, |
| 156 | + "check_terminals": False, |
| 157 | + "include_pingroups": False, |
| 158 | + "expansion_factor": 0, |
| 159 | + "maximum_iterations": 10, |
| 160 | + "preserve_components_with_model": False, |
| 161 | + "simple_pad_check": True, |
| 162 | + "keep_lines_as_path": False |
| 163 | + } |
| 164 | +} |
| 165 | + |
| 166 | +# ## Save the configuration |
| 167 | +# |
| 168 | +# The configuration file can be saved in JSON format and applied to layout data using the EDB. |
| 169 | + |
| 170 | +pi_json = os.path.join(temp_folder.name, "pi.json") |
| 171 | +with open(pi_json, "w") as f: |
| 172 | + json.dump(cfg, f, indent=4, ensure_ascii=False) |
| 173 | + |
| 174 | +# ## Load configuration into EDB |
| 175 | + |
| 176 | +# Load configuration from JSON |
| 177 | + |
| 178 | +edbapp = Edb(aedb, edbversion=AEDT_VERSION) |
| 179 | +edbapp.configuration.load(config_file=pi_json) |
| 180 | +edbapp.configuration.run() |
| 181 | +edbapp.save() |
| 182 | +edbapp.close() |
| 183 | + |
| 184 | +# The configured EDB file is saved in a temp folder. |
| 185 | + |
| 186 | +print(temp_folder.name) |
| 187 | + |
| 188 | +# ## Analyze in HFSS 3D Layout |
| 189 | + |
| 190 | +# ### Load edb into HFSS 3D Layout. |
| 191 | + |
| 192 | +h3d = Hfss3dLayout( |
| 193 | + aedb, |
| 194 | + specified_version=AEDT_VERSION, |
| 195 | + non_graphical=NG_MODE, |
| 196 | + new_desktop_session=True |
| 197 | +) |
| 198 | + |
| 199 | +# ### Analyze |
| 200 | + |
| 201 | +h3d.analyze() |
| 202 | + |
| 203 | +# ### Plot impedance |
| 204 | + |
| 205 | +solutions = h3d.post.get_solution_data(expressions='Z(port1,port1)') |
| 206 | +solutions.plot() |
| 207 | + |
| 208 | +# ## Shut Down Electronics Desktop |
| 209 | + |
| 210 | +h3d.close_desktop() |
| 211 | + |
| 212 | +# All project files are saved in the folder ``temp_file.dir``. If you've run this example as a Jupyter notbook you |
| 213 | +# can retrieve those project files. The following cell removes all temporary files, including the project folder. |
| 214 | + |
| 215 | +# ## Cleanup |
| 216 | +# |
| 217 | +# All project files are saved in the folder ``temp_file.dir``. If you've run this example as a Jupyter notbook you |
| 218 | +# can retrieve those project files. The following cell removes all temporary files, including the project folder. |
| 219 | + |
| 220 | +time.sleep(3) |
| 221 | +temp_folder.cleanup() |
0 commit comments