Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import stackup from dictionary #3685

Merged
merged 33 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6f3b815
edb intersection bug fix
svandenb-dev Jun 29, 2023
c9c9183
Merge remote-tracking branch 'origin/main'
svandenb-dev Jun 29, 2023
2c93929
Merge remote-tracking branch 'origin/main'
svandenb-dev Jun 30, 2023
13681b3
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 11, 2023
44b29bd
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 14, 2023
fa118ee
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 14, 2023
4f5170d
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 17, 2023
c532310
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 19, 2023
0ed1957
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 24, 2023
9c1f90f
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 26, 2023
b17e28d
Merge remote-tracking branch 'origin/main'
svandenb-dev Jul 27, 2023
0775a9f
Merge remote-tracking branch 'origin/main'
svandenb-dev Aug 21, 2023
8efa6e0
Merge remote-tracking branch 'origin/main'
svandenb-dev Aug 24, 2023
c32599f
Merge remote-tracking branch 'origin/main'
svandenb-dev Aug 28, 2023
64b538b
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 6, 2023
a4735a4
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 15, 2023
7ebf925
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 18, 2023
5a2c70b
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 21, 2023
38be8d7
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 21, 2023
d3cb775
Merge remote-tracking branch 'origin/main'
svandenb-dev Sep 22, 2023
5cf7d67
default convergence criteria on hfss sweep set to 0.5%
svandenb-dev Sep 25, 2023
27f0da2
default convergence criteria on hfss sweep set to 0.5%
svandenb-dev Sep 25, 2023
ccc2d6f
default convergence criteria on hfss sweep set to 0.5%
svandenb-dev Sep 26, 2023
a02bcac
dc short method
svandenb-dev Sep 27, 2023
235ad85
dc short method
svandenb-dev Sep 27, 2023
c24a5af
dc short method
svandenb-dev Sep 27, 2023
5356abf
doc string
svandenb-dev Sep 27, 2023
38ba698
fix
samomania21 Sep 30, 2023
bc1cc11
Merge branch 'adding_physically_connected_primitives' into import_sta…
samomania21 Sep 30, 2023
76e756c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2023
09ded7d
fix
samomania21 Sep 30, 2023
03a8a48
Merge branch 'main' into import_stackup_from_dictionary
hui-zhou-a Oct 2, 2023
a002123
Merge branch 'main' into import_stackup_from_dictionary
hui-zhou-a Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions _unittest/example_models/TEDB/stackup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"materials": {
"copper": {
"name": "copper",
"conductivity": 58000000.0
},
"fr4_epoxy": {
"name": "fr4_epoxy",
"loss_tangent": 0.02,
"permittivity": 4.4
},
"solder_mask": {
"name": "solder_mask",
"loss_tangent": 0.035,
"permittivity": 3.1
}
},
"layers": {
"TOP": {
"name": "TOP",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 5.000000000000004e-05
},
"D1": {
"name": "D1",
"type": "dielectric",
"material": "fr4_epoxy",
"thickness": 0.0001
},
"L2": {
"name": "L2",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 3.5000000000000004e-05
},
"D2": {
"name": "D2",
"type": "dielectric",
"material": "fr4_epoxy",
"thickness": 0.0001
},
"L3": {
"name": "L3",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 3.5000000000000004e-05
},
"D3": {
"name": "D3",
"type": "dielectric",
"material": "fr4_epoxy",
"thickness": 0.0001
},
"L4": {
"name": "L4",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 3.5000000000000004e-05
},
"D4": {
"name": "D4",
"type": "dielectric",
"material": "fr4_epoxy",
"thickness": 0.0001
},
"L5": {
"name": "L5",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 3.5000000000000004e-05
},
"D5": {
"name": "D5",
"type": "dielectric",
"material": "fr4_epoxy",
"thickness": 0.0001
},
"BOT": {
"name": "BOT",
"type": "signal",
"material": "copper",
"dielectric_fill": "copper",
"thickness": 5.000000000000004e-05
}
}
}
13 changes: 13 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os

# Setup paths for module imports
Expand Down Expand Up @@ -1840,6 +1841,18 @@ def test_125c_layer(self):
assert layer.material == "copper"
edbapp.close()

def test_125d_stackup(self):
fpath = os.path.join(local_path, "example_models", test_subfolder, "stackup.json")
stackup_json = json.load(open(fpath, "r"))

edbapp = Edb(edbversion=desktop_version)
edbapp.stackup.load(fpath)
edbapp.close()

edbapp = Edb(edbversion=desktop_version)
edbapp.stackup.load(stackup_json)
edbapp.close()

def test_126_comp_def(self):
source_path = os.path.join(local_path, "example_models", test_subfolder, "ANSYS-HSD_V1.aedb")
target_path = os.path.join(self.local_scratch.path, "test_0126.aedb")
Expand Down
69 changes: 44 additions & 25 deletions pyaedt/edb_core/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,40 +297,59 @@ def _json_format(self):

@pyaedt_function_handler()
def _load(self, input_dict):
default_material = {
"name": "default",
"conductivity": 0,
"loss_tangent": 0,
"magnetic_loss_tangent": 0,
"mass_density": 0,
"permittivity": 1,
"permeability": 1,
"poisson_ratio": 0,
"specific_heat": 0,
"thermal_conductivity": 0,
"youngs_modulus": 0,
"thermal_expansion_coefficient": 0,
"dielectric_model_frequency": None,
"dc_permittivity": None,
}
if input_dict:
self.conductivity = input_dict["conductivity"]
self.loss_tangent = input_dict["loss_tangent"]
self.magnetic_loss_tangent = input_dict["magnetic_loss_tangent"]
self.mass_density = input_dict["mass_density"]
self.permittivity = input_dict["permittivity"]
self.permeability = input_dict["permeability"]
self.poisson_ratio = input_dict["poisson_ratio"]
self.specific_heat = input_dict["specific_heat"]
self.thermal_conductivity = input_dict["thermal_conductivity"]
self.youngs_modulus = input_dict["youngs_modulus"]
self.thermal_expansion_coefficient = input_dict["thermal_expansion_coefficient"]
if input_dict["dielectric_model_frequency"] is not None:
for k, v in input_dict.items():
default_material[k] = v

self.conductivity = default_material["conductivity"]
self.loss_tangent = default_material["loss_tangent"]
self.magnetic_loss_tangent = default_material["magnetic_loss_tangent"]
self.mass_density = default_material["mass_density"]
self.permittivity = default_material["permittivity"]
self.permeability = default_material["permeability"]
self.poisson_ratio = default_material["poisson_ratio"]
self.specific_heat = default_material["specific_heat"]
self.thermal_conductivity = default_material["thermal_conductivity"]
self.youngs_modulus = default_material["youngs_modulus"]
self.thermal_expansion_coefficient = default_material["thermal_expansion_coefficient"]
if default_material["dielectric_model_frequency"] is not None: # pragma: no cover
if self._edb_material_def.GetDielectricMaterialModel():
model = self._edb_material_def.GetDielectricMaterialModel()
self.dielectric_model_frequency = input_dict["dielectric_model_frequency"]
self.loss_tangent_at_frequency = input_dict["loss_tangent_at_frequency"]
self.permittivity_at_frequency = input_dict["permittivity_at_frequency"]
if input_dict["dc_permittivity"] is not None:
self.dielectric_model_frequency = default_material["dielectric_model_frequency"]
self.loss_tangent_at_frequency = default_material["loss_tangent_at_frequency"]
self.permittivity_at_frequency = default_material["permittivity_at_frequency"]
if default_material["dc_permittivity"] is not None:
model.SetUseDCRelativePermitivity(True)
self.dc_permittivity = input_dict["dc_permittivity"]
self.dc_conductivity = input_dict["dc_conductivity"]
self.dc_permittivity = default_material["dc_permittivity"]
self.dc_conductivity = default_material["dc_conductivity"]
else:
if not self._pclass.add_djordjevicsarkar_material(
input_dict["name"],
input_dict["permittivity_at_frequency"],
input_dict["loss_tangent_at_frequency"],
input_dict["dielectric_model_frequency"],
input_dict["dc_permittivity"],
input_dict["dc_conductivity"],
default_material["name"],
default_material["permittivity_at_frequency"],
default_material["loss_tangent_at_frequency"],
default_material["dielectric_model_frequency"],
default_material["dc_permittivity"],
default_material["dc_conductivity"],
):
self._pclass._pedb.logger.warning(
'Cannot set DS model for material "{}". Check for realistic '
"values that define DS Model".format(input_dict["name"])
"values that define DS Model".format(default_material["name"])
)
else:
# To unset DS model if already assigned to the material in database
Expand Down
115 changes: 75 additions & 40 deletions pyaedt/edb_core/stackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,50 +1636,83 @@
temp_data = {name: area / outline_area * 100 for name, area in temp_data.items()}
return temp_data

@pyaedt_function_handler
def _import_dict(self, json_dict):
"""Import stackup from a dictionary."""
for k, v in json_dict.items():
if k == "materials":
for material in v.values():
self._pedb.materials._load_materials(material)
if k == "layers":
if len(list(v.values())) == len(list(self.stackup_layers.values())):
imported_layers_list = [l_dict["name"] for l_dict in list(v.values())]
layout_layer_list = list(self.stackup_layers.keys())
for layer_name in imported_layers_list:
layer_index = imported_layers_list.index(layer_name)
if layout_layer_list[layer_index] != layer_name:
self.stackup_layers[layout_layer_list[layer_index]].name = layer_name

Check warning on line 1653 in pyaedt/edb_core/stackup.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/edb_core/stackup.py#L1648-L1653

Added lines #L1648 - L1653 were not covered by tests
prev_layer = None
for layer_name, layer in v.items():
if layer["name"] not in self.stackup_layers:
default_layer = {
"name": "default",
"type": "signal",
"material": "copper",
"dielectric_fill": "fr4_epoxy",
"thickness": 3.5000000000000004e-05,
"etch_factor": 0.0,
"roughness_enabled": False,
"top_hallhuray_nodule_radius": 0.0,
"top_hallhuray_surface_ratio": 0.0,
"bottom_hallhuray_nodule_radius": 0.0,
"bottom_hallhuray_surface_ratio": 0.0,
"side_hallhuray_nodule_radius": 0.0,
"side_hallhuray_surface_ratio": 0.0,
"upper_elevation": 0.0,
"lower_elevation": 0.0,
"color": [242, 140, 102],
}

if not layer["type"] == "signal":
default_layer["color"] = [27, 110, 76]

for k, v in layer.items():
default_layer[k] = v

layer = default_layer

if not prev_layer:
self.add_layer(
layer_name,
method="add_on_top",
layer_type=layer["type"],
material=layer["material"],
fillMaterial=layer["dielectric_fill"],
thickness=layer["thickness"],
)
prev_layer = layer_name
else:
self.add_layer(
layer_name,
base_layer=layer_name,
method="insert_below",
layer_type=layer["type"],
material=layer["material"],
fillMaterial=layer["dielectric_fill"],
thickness=layer["thickness"],
)
prev_layer = layer_name
if layer_name in self.stackup_layers:
self.stackup_layers[layer["name"]]._load_layer(layer)
return True

@pyaedt_function_handler
def _import_json(self, file_path):
"""Import stackup from a json file."""
if file_path:
f = open(file_path)
json_dict = json.load(f) # pragma: no cover
for k, v in json_dict.items():
if k == "materials":
for material in v.values():
self._pedb.materials._load_materials(material)
if k == "layers":
if len(list(v.values())) == len(list(self.stackup_layers.values())):
imported_layers_list = [l_dict["name"] for l_dict in list(v.values())]
layout_layer_list = list(self.stackup_layers.keys())
for layer_name in imported_layers_list:
layer_index = imported_layers_list.index(layer_name)
if layout_layer_list[layer_index] != layer_name:
self.stackup_layers[layout_layer_list[layer_index]].name = layer_name
prev_layer = None
for layer_name, layer in v.items():
if layer["name"] not in self.stackup_layers:
if not prev_layer:
self.add_layer(
layer_name,
method="add_on_top",
layer_type=layer["type"],
material=layer["material"],
fillMaterial=layer["dielectric_fill"],
thickness=layer["thickness"],
)
prev_layer = layer_name
else:
self.add_layer(
layer_name,
base_layer=layer_name,
method="insert_below",
layer_type=layer["type"],
material=layer["material"],
fillMaterial=layer["dielectric_fill"],
thickness=layer["thickness"],
)
prev_layer = layer_name
if layer_name in self.stackup_layers:
self.stackup_layers[layer["name"]]._load_layer(layer)
return True
return self._import_dict(json_dict)

@pyaedt_function_handler
def _import_csv(self, file_path):
Expand Down Expand Up @@ -2092,7 +2125,9 @@
>>> edb.stackup.load("stackup.xml")
"""

if file_path.endswith(".csv"):
if isinstance(file_path, dict):
return self._import_dict(file_path)
elif file_path.endswith(".csv"):
return self._import_csv(file_path)
elif file_path.endswith(".json"):
return self._import_json(file_path)
Expand Down
Loading