diff --git a/_unittest/test_28_Maxwell3D.py b/_unittest/test_28_Maxwell3D.py index cba49759cfc..03ba51bbbb6 100644 --- a/_unittest/test_28_Maxwell3D.py +++ b/_unittest/test_28_Maxwell3D.py @@ -916,3 +916,19 @@ def test_56_zero_tangential_h_field(self, add_app): assert m3d.assign_zero_tangential_h_field( box.top_face_z, ) + + def test_57_radiation(self): + self.aedtapp.insert_design("Radiation") + self.aedtapp.solution_type = SOLUTIONS.Maxwell3d.EddyCurrent + rect = self.aedtapp.modeler.create_rectangle(0, [0, 0, 0], [5, 5], matname="aluminum") + rect2 = self.aedtapp.modeler.create_rectangle(0, [15, 20, 0], [5, 5], matname="aluminum") + box = self.aedtapp.modeler.create_box([15, 20, 0], [5, 5, 5], matname="aluminum") + box2 = self.aedtapp.modeler.create_box([150, 20, 0], [50, 5, 10], matname="aluminum") + bound = self.aedtapp.assign_radiation([rect, rect2, box, box2.faces[0]]) + assert bound + bound2 = self.aedtapp.assign_radiation([rect, rect2, box, box2.faces[0]], "my_rad") + assert bound2 + bound3 = self.aedtapp.assign_radiation([rect, rect2, box, box2.faces[0]], "my_rad") + assert bound2.name != bound3.name + self.aedtapp.solution_type = SOLUTIONS.Maxwell3d.Transient + assert not self.aedtapp.assign_radiation([rect, rect2, box, box2.faces[0]]) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 67acc669ebe..499cae7b0bc 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1624,6 +1624,61 @@ def assign_current_density( self.logger.error("Current density can only be applied to Eddy current or magnetostatic solution types.") return False + @pyaedt_function_handler() + def assign_radiation(self, input_object, radiation_name=None): + """Assign radiation boundary to one or more objects. + + Radiation assignment can be calculated based upon the solver type. + Available solution type is: ``Eddy Current``. + + Parameters + ---------- + input_object : str, list + One or more objects to assign the radiation to. + radiation_name : str, optional + Name of the force. The default is ``None``, in which case the default + name is used. + + Returns + ------- + :class:`pyaedt.modules.Boundary.BoundaryObject` + Radiation objects. If the method fails to execute it returns ``False``. + + References + ---------- + + >>> oModule.Radiation + + Examples + -------- + + Assign radiation boundary to one box and one face: + + >>> box1 = m3d.modeler.create_box([0, 0, 0], [2, 10, 10]) + >>> box2 = m3d.modeler.create_box([10, 0, 0], [2, 10, 10]) + >>> m3d.assign_radiation([box1, box2.faces[0]], force_name="radiation_boundary") + """ + + if self.solution_type in ["EddyCurrent"]: + if not radiation_name: + radiation_name = generate_unique_name("Radiation") + elif radiation_name in self.modeler.get_boundaries_name(): + radiation_name = generate_unique_name(radiation_name) + + listobj = self.modeler.convert_to_selections(input_object, True) + props = {"Objects": [], "Faces": []} + for sel in listobj: + if isinstance(sel, str): + props["Objects"].append(sel) + elif isinstance(sel, int): + props["Faces"].append(sel) + bound = BoundaryObject(self, radiation_name, props, "Radiation") + if bound.create(): + self._boundaries[bound.name] = bound + return bound + self.logger.error("Excitation applicable only to Eddy current.") + return False + @pyaedt_function_handler() def enable_harmonic_force( self,