Skip to content

Commit

Permalink
ADD Maxwell assign radiation (#3765)
Browse files Browse the repository at this point in the history
* ADD Maxwell assign radiation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add UT and docstring
Move to Maxwell because it is working in 2D and 3D

* Update _unittest/test_28_Maxwell3D.py

* Fix UT

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Samuel Lopez <[email protected]>
Co-authored-by: Samuel Lopez <[email protected]>
  • Loading branch information
4 people authored Oct 24, 2023
1 parent 72c2ddb commit 78eabf9
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
16 changes: 16 additions & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
55 changes: 55 additions & 0 deletions pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 78eabf9

Please sign in to comment.