-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport_setup_ac.py
142 lines (114 loc) · 4.29 KB
/
import_setup_ac.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# # Import Setup AC
# This example shows how to import SIwave, HFSS setups for AC analysis. In this example, we are going to
#
# - Download an example board
# - Create a configuration file
# - add setups
# - Import the configuration file
# ### Import the required packages
# +
import json
from pathlib import Path
import tempfile
from ansys.aedt.core.downloads import download_file
from pyedb import Edb
AEDT_VERSION = "2025.1"
NG_MODE = False
# -
# Download the example PCB data.
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
file_edb = download_file(source="edb/ANSYS-HSD_V1.aedb", destination=temp_folder.name)
# ## Load example layout.
edbapp = Edb(file_edb, edbversion=AEDT_VERSION)
# ## Create an empty dictionary to host all configurations.
cfg = dict()
# ## Create an SIwave SYZ setup
# Keywords
#
# - **name**. Name of the setup.
# - **type**. Type of the analysis setup. Supported types are 'siwave_ac', 'siwave_dc', 'hfss'.
# - **pi_slider_position**. PI slider position. Supported values are from '0', '1', '2'. 0:speed, 1:balanced,
# 2:accuracy.
# - **freq_sweep**. List of frequency sweeps.
# - **name**. Name of the sweep.
# - **type**. Type of the sweep. Supported types are 'interpolation', 'discrete', 'broadband'.
# - **frequencies**. Frequency distribution.
# - **distribution**. Supported distributions are 'linear_count', 'linear_scale', 'log_scale'.
# - **start**. Start frequency. Example, 1e6, "1MHz".
# - **stop**. Stop frequency. Example, 1e9, "1GHz".
# - **increment**.
siwave_setup = {
"name": "siwave_1",
"type": "siwave_ac",
"pi_slider_position": 1,
"freq_sweep": [
{
"name": "Sweep1",
"type": "interpolation",
"frequencies": [{"distribution": "log_scale", "start": 1e6, "stop": 1e9, "increment": 20}],
}
],
}
# ## Create a HFSS setup
# Keywords
#
# - **name**. Name of the setup.
# - **type**. Type of the analysis setup. Supported types are 'siwave_ac', 'siwave_dc', 'hfss'.
# - **f_adapt**. Adaptive frequency.
# - **max_num_passes**. Maximum number of passes.
# - **max_mag_delta_s**. Convergence criteria delta S.
# - **mesh_operations**. Mesh operations.
# - **name**. Name of the mesh operation.
# - **type**. Type of the mesh operation. The supported types are 'base', 'length', 'skin_depth'.
# - **max_length**. Maximum length of elements.
# - **restrict_length**. Whether to restrict length of elements.
# - **refine_inside**. Whether to turn on refine inside objects.
# - **nets_layers_list**. {'layer_name':['net_name_1', 'net_name_2']}
# - **freq_sweep**. List of frequency sweeps.
# - **name**. Name of the sweep.
# - **type**. Type of the sweep. Supported types are 'interpolation', 'discrete', 'broadband'.
# - **frequencies**. Frequency distribution.
# - **distribution**. Supported distributions are 'linear_count', 'linear_scale', 'log_scale'.
# - **start**. Start frequency. Example, 1e6, "1MHz".
# - **stop**. Stop frequency. Example, 1e9, "1GHz".
# - **increment**.
hfss_setup = {
"name": "hfss_1",
"type": "hfss",
"f_adapt": "5GHz",
"max_num_passes": 10,
"max_mag_delta_s": 0.02,
"mesh_operations": [
{
"name": "mop_1",
"type": "length",
"max_length": "3mm",
"restrict_length": True,
"refine_inside": False,
"nets_layers_list": {"GND": ["1_Top", "16_Bottom"]},
}
],
"freq_sweep": [
{
"name": "Sweep1",
"type": "interpolation",
"frequencies": [{"distribution": "log_scale", "start": 1e6, "stop": 1e9, "increment": 20}],
}
],
}
# ## Add setups in configuration
cfg["setups"] = [siwave_setup, hfss_setup]
# ## Write configuration into as json file
file_json = Path(temp_folder.name) / "edb_configuration.json"
with open(file_json, "w") as f:
json.dump(cfg, f, indent=4, ensure_ascii=False)
# ## Import configuration into example layout
edbapp.configuration.load(config_file=file_json)
edbapp.configuration.run()
# ## Review
edbapp.setups
# ## Save and close Edb
# The temporary folder will be deleted once the execution of this script is finished. Replace **edbapp.save()** with
# **edbapp.save_as("C:/example.aedb")** to keep the example project.
edbapp.save()
edbapp.close()