Skip to content

Commit e86f48b

Browse files
committed
test #56 done
1 parent edf790b commit e86f48b

File tree

4 files changed

+66
-52
lines changed

4 files changed

+66
-52
lines changed

src/pyedb/grpc/edb_core/materials.py

+37-36
Original file line numberDiff line numberDiff line change
@@ -271,42 +271,43 @@ def set_multipole_debye_model(self):
271271
def set_djordjecvic_sarkar_model(self):
272272
super(Material, self.__class__).dielectric_material_model.__set__(self, GrpcDjordjecvicSarkarModel.create())
273273

274-
# def to_dict(self):
275-
# """Convert material into dictionary."""
276-
# test = self.__dict__()
277-
#
278-
# res = {"name": self.name}
279-
# res.update(self.model_dump())
280-
# return res
281-
#
282-
# def update(self, input_dict: dict):
283-
# if input_dict:
284-
# # Update attributes
285-
# for attribute in ATTRIBUTES:
286-
# if attribute in input_dict:
287-
# setattr(self, attribute, input_dict[attribute])
288-
# if "loss_tangent" in input_dict: # pragma: no cover
289-
# setattr(self, "loss_tangent", input_dict["loss_tangent"])
290-
#
291-
# # Update DS model
292-
# # NOTE: Contrary to before we don't test 'dielectric_model_frequency' only
293-
# if any(map(lambda attribute: input_dict.get(attribute, None) is not None, DC_ATTRIBUTES)):
294-
# if not self.__dc_model:
295-
# self.__dc_model = self.__edb_definition.DjordjecvicSarkarModel()
296-
# for attribute in DC_ATTRIBUTES:
297-
# if attribute in input_dict:
298-
# if attribute == "dc_permittivity" and input_dict[attribute] is not None:
299-
# self.__dc_model.SetUseDCRelativePermitivity(True)
300-
# setattr(self, attribute, input_dict[attribute])
301-
# self.__material_def.dielectric_material_model = self.__dc_model
302-
# # Unset DS model if it is already assigned to the material in the database
303-
# elif self.__dc_model:
304-
# self.__material_def.dielectric_material_model = GrpcValue(None)
305-
#
306-
# def __load_all_properties(self):
307-
# """Load all properties of the material."""
308-
# for property in self.__properties.model_dump().keys():
309-
# _ = getattr(self, property)
274+
def to_dict(self):
275+
"""Convert material into dictionary."""
276+
test = self.__dict__()
277+
278+
res = {"name": self.name}
279+
res.update(self.model_dump())
280+
return res
281+
282+
def update(self, input_dict: dict):
283+
if input_dict:
284+
# Update attributes
285+
for attribute in ATTRIBUTES:
286+
if attribute in input_dict:
287+
setattr(self, attribute, input_dict[attribute])
288+
if "loss_tangent" in input_dict: # pragma: no cover
289+
setattr(self, "loss_tangent", input_dict["loss_tangent"])
290+
291+
# Update DS model
292+
# NOTE: Contrary to before we don't test 'dielectric_model_frequency' only
293+
if any(map(lambda attribute: input_dict.get(attribute, None) is not None, DC_ATTRIBUTES)):
294+
# DC model does not exists anymore in Grpc
295+
if not self.__dc_model:
296+
self.__dc_model = GrpcDjordjecvicSarkarModel.create()
297+
for attribute in DC_ATTRIBUTES:
298+
if attribute in input_dict:
299+
if attribute == "dc_permittivity" and input_dict[attribute] is not None:
300+
self.__dc_model.SetUseDCRelativePermitivity(True)
301+
setattr(self, attribute, input_dict[attribute])
302+
self.__material_def.dielectric_material_model = self.__dc_model
303+
# Unset DS model if it is already assigned to the material in the database
304+
elif self.__dc_model:
305+
self.__material_def.dielectric_material_model = GrpcValue(None)
306+
307+
def __load_all_properties(self):
308+
"""Load all properties of the material."""
309+
for property in self.__properties.model_dump().keys():
310+
_ = getattr(self, property)
310311

311312

312313
class Materials(object):

tests/grpc/system/test_edb.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1135,15 +1135,15 @@ def test_create_padstack_instance(self, edb_examples):
11351135
def test_stackup_properties(self):
11361136
"""Evaluate stackup properties."""
11371137
# TODO check material init
1138-
# edb = Edb(edbversion=desktop_version, restart_rpc_server=True)
1139-
# edb.stackup.add_layer(layer_name="gnd", fillMaterial="air", thickness="10um")
1140-
# edb.stackup.add_layer(layer_name="diel1", fillMaterial="air", thickness="200um", base_layer="gnd")
1141-
# edb.stackup.add_layer(layer_name="sig1", fillMaterial="air", thickness="10um", base_layer="diel1")
1142-
# edb.stackup.add_layer(layer_name="diel2", fillMaterial="air", thickness="200um", base_layer="sig1")
1143-
# edb.stackup.add_layer(layer_name="sig3", fillMaterial="air", thickness="10um", base_layer="diel2")
1144-
# assert edb.stackup.thickness == 0.00043
1145-
# assert edb.stackup.num_layers == 5
1146-
# edb.close()
1138+
edb = Edb(edbversion=desktop_version, restart_rpc_server=True)
1139+
edb.stackup.add_layer(layer_name="gnd", fillMaterial="air", thickness="10um")
1140+
edb.stackup.add_layer(layer_name="diel1", fillMaterial="air", thickness="200um", base_layer="gnd")
1141+
edb.stackup.add_layer(layer_name="sig1", fillMaterial="air", thickness="10um", base_layer="diel1")
1142+
edb.stackup.add_layer(layer_name="diel2", fillMaterial="air", thickness="200um", base_layer="sig1")
1143+
edb.stackup.add_layer(layer_name="sig3", fillMaterial="air", thickness="10um", base_layer="diel2")
1144+
assert edb.stackup.thickness == 0.00043
1145+
assert edb.stackup.num_layers == 5
1146+
edb.close()
11471147
pass
11481148

11491149
def test_hfss_extent_info(self):

tests/grpc/system/test_edb_layout.py

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def init(self, local_scratch):
3232
pass
3333

3434
def test_find(self, edb_examples):
35+
# Done
3536
edbapp = edb_examples.get_si_verse()
3637
assert edbapp.layout.find_primitive(layer_name="Inner5(PWR2)")
3738
edbapp.close()

tests/grpc/system/test_edb_materials.py

+19-7
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,40 @@ def init(self, legacy_edb_app_without_material):
6565
self.edbapp = legacy_edb_app_without_material
6666
self.definition = self.edbapp.edb_api.definition
6767

68-
# Remove dummy material if it exist
69-
material_def = self.definition.MaterialDef.FindByName(self.edbapp.active_db, MATERIAL_NAME)
70-
if not material_def.IsNull():
71-
material_def.Delete()
68+
# Remove dummy material if it exists.
69+
from ansys.edb.core.definition.material_def import (
70+
MaterialDef as GrpcMaterialDef,
71+
)
72+
73+
material_def = GrpcMaterialDef.find_by_name(self.edbapp.active_db, MATERIAL_NAME)
74+
if not material_def.is_null:
75+
material_def.delete()
7276

7377
def test_material_name(self):
7478
"""Evaluate material properties."""
75-
material_def = self.definition.MaterialDef.Create(self.edbapp.active_db, MATERIAL_NAME)
79+
from ansys.edb.core.definition.material_def import (
80+
MaterialDef as GrpcMaterialDef,
81+
)
82+
83+
material_def = GrpcMaterialDef.create(self.edbapp.active_db, MATERIAL_NAME)
7684
material = Material(self.edbapp, material_def)
7785

7886
assert MATERIAL_NAME == material.name
7987

8088
def test_material_properties(self):
8189
"""Evaluate material properties."""
82-
material_def = self.definition.MaterialDef.Create(self.edbapp.active_db, MATERIAL_NAME)
90+
from ansys.edb.core.definition.material_def import (
91+
MaterialDef as GrpcMaterialDef,
92+
)
93+
94+
material_def = GrpcMaterialDef.create(self.edbapp.active_db, MATERIAL_NAME)
8395
material = Material(self.edbapp, material_def)
8496

8597
for property in PROPERTIES:
8698
for value in VALUES:
8799
setattr(material, property, value)
88100
assert float(value) == getattr(material, property)
89-
assert 12 == material.loss_tangent
101+
assert 12 == material.dielectric_loss_tangent
90102

91103
def test_material_dc_properties(self):
92104
"""Evaluate material DC properties."""

0 commit comments

Comments
 (0)