Skip to content

Commit bf6bed1

Browse files
hui-zhou-apre-commit-ci[bot]svandenb-dev
authored
FEAT: update materials from syslib (#1065)
* materials.py * MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: svandenb-dev <[email protected]> * minor fix --------- Co-authored-by: ring630 <@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: svandenb-dev <[email protected]>
1 parent 86e3b69 commit bf6bed1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/pyedb/dotnet/edb_core/materials.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,3 +1043,18 @@ def read_syslib_material(self, material_name):
10431043

10441044
self.__edb.logger.error(f"Material {material_name} does not exist in syslib AMAT file.")
10451045
return res
1046+
1047+
def update_materials_from_sys_library(self, update_all: bool = True, material_name: Union[str, list] = None):
1048+
"""Update material properties from syslib AMAT file."""
1049+
amat_file = os.path.join(self.__edb.base_path, "syslib", "Materials.amat")
1050+
materials_dict = self.read_materials(amat_file)
1051+
if update_all:
1052+
for name, obj in self.materials.items():
1053+
if name in materials_dict:
1054+
obj.update(materials_dict[name])
1055+
self.__edb.logger.info(f"Material {name} is updated from syslibrary.")
1056+
else:
1057+
material_names = material_name if isinstance(material_name, list) else [material_name]
1058+
for name in material_names:
1059+
self.materials[name].update(materials_dict[name])
1060+
self.__edb.logger.info(f"Material {name} is updated from syslibrary.")

tests/legacy/system/test_edb_materials.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,12 @@ def test_materials_load_dielectric_material(self):
346346
assert 0.00045 == material.loss_tangent
347347
assert 0.00045 == material.dielectric_loss_tangent
348348
assert 12 == material.permittivity
349+
350+
def test_update_materials_from_syslib(self, edb_examples):
351+
edbapp = edb_examples.get_si_verse()
352+
edbapp.materials.update_materials_from_sys_library(False, "copper")
353+
assert edbapp.materials["copper"].thermal_conductivity == 400
354+
edbapp.materials["FR4_epoxy"].thermal_conductivity = 1
355+
edbapp.materials.update_materials_from_sys_library()
356+
edbapp.materials["FR4_epoxy"].thermal_conductivity = 0.294
357+
edbapp.close()

0 commit comments

Comments
 (0)