@@ -271,42 +271,43 @@ def set_multipole_debye_model(self):
271
271
def set_djordjecvic_sarkar_model (self ):
272
272
super (Material , self .__class__ ).dielectric_material_model .__set__ (self , GrpcDjordjecvicSarkarModel .create ())
273
273
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 )
310
311
311
312
312
313
class Materials (object ):
0 commit comments