Skip to content

Commit 7f74df3

Browse files
committed
improve docstrings
1 parent 4f199b9 commit 7f74df3

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

pyaedt/maxwell.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def apply_skew(
186186
props.update(arg_slice_table)
187187
return self.change_design_settings(props)
188188

189-
@pyaedt_function_handler()
190-
def set_core_losses(self, objects, value=False):
189+
@pyaedt_function_handler(value="core_loss_on_field")
190+
def set_core_losses(self, objects, core_loss_on_field=False):
191191
"""Whether to enable core losses for a set of objects.
192192
193193
For ``EddyCurrent`` and ``Transient`` solver designs, core losses calulcations
@@ -198,7 +198,7 @@ def set_core_losses(self, objects, value=False):
198198
----------
199199
objects : list, str
200200
List of object to apply core losses to.
201-
value : bool, optional
201+
core_loss_on_field : bool, optional
202202
Whether to enable ``Consider core loss effect on field`` for the given list. The default is
203203
``False``.
204204
@@ -217,13 +217,13 @@ def set_core_losses(self, objects, value=False):
217217
Set core losses in Maxwell 3D.
218218
219219
>>> from pyaedt import Maxwell3d
220-
>>> maxwell_3d = Maxwell3d()
221-
>>> maxwell_3d.set_core_losses(["PQ_Core_Bottom", "PQ_Core_Top"], True)
222-
220+
>>> m3d = Maxwell3d()
221+
>>> m3d.set_core_losses(objects=["PQ_Core_Bottom", "PQ_Core_Top"],core_loss_on_field=True)
222+
>>> m3d.release_desktop(True, True)
223223
"""
224224
if self.solution_type in ["EddyCurrent", "Transient"]:
225225
objects = self.modeler.convert_to_selections(objects, True)
226-
self.oboundary.SetCoreLoss(objects, value)
226+
self.oboundary.SetCoreLoss(objects, core_loss_on_field)
227227
return True
228228
else:
229229
raise Exception("Core losses is only available with `EddyCurrent` and `Transient` solutions.")
@@ -277,15 +277,16 @@ def assign_matrix(
277277
--------
278278
Set matrix in a Maxwell magnetostatic analysis.
279279
280+
>>> from pyaedt import Maxwell2d
280281
>>> m2d = Maxwell2d(solution_type="MagnetostaticXY",specified_version="2022.1",close_on_exit=True)
281282
>>> coil1 = m2d.modeler.create_rectangle([0, 1.5, 0], [8, 3], is_covered=True, name="Coil_1")
282283
>>> coil2 = m2d.modeler.create_rectangle([8.5, 1.5, 0], [8, 3], is_covered=True, name="Coil_2")
283284
>>> coil3 = m2d.modeler.create_rectangle([16, 1.5, 0], [8, 3], is_covered=True, name="Coil_3")
284285
>>> coil4 = m2d.modeler.create_rectangle([32, 1.5, 0], [8, 3], is_covered=True, name="Coil_4")
285-
>>> current1 = m2d.assign_current("Coil_1",amplitude=1,swap_direction=False,name="Current1")
286-
>>> current2 = m2d.assign_current("Coil_2",amplitude=1,swap_direction=True,name="Current2")
287-
>>> current3 = m2d.assign_current("Coil_3",amplitude=1,swap_direction=True,name="Current3")
288-
>>> current4 = m2d.assign_current("Coil_4",amplitude=1,swap_direction=True,name="Current4")
286+
>>> current1 = m2d.assign_current(objects="Coil_1",amplitude=1,swap_direction=False,name="Current1")
287+
>>> current2 = m2d.assign_current(objects="Coil_2",amplitude=1,swap_direction=True,name="Current2")
288+
>>> current3 = m2d.assign_current(objects="Coil_3",amplitude=1,swap_direction=True,name="Current3")
289+
>>> current4 = m2d.assign_current(objects="Coil_4",amplitude=1,swap_direction=True,name="Current4")
289290
>>> group_sources = {"Group1_Test": ["Current1", "Current3"], "Group2_Test": ["Current2", "Current4"]}
290291
>>> selection = ['Current1', 'Current2', 'Current3', 'Current4']
291292
>>> turns = [5, 1, 2, 3]
@@ -295,7 +296,7 @@ def assign_matrix(
295296
>>> m2d.assign_voltage(["Port1"],amplitude=1,name="1V")
296297
>>> m2d.assign_voltage(["Port2"],amplitude=0,name="0V")
297298
>>> m2d.assign_matrix(sources=['1V'], group_sources=['0V'], matrix_name="Matrix1")
298-
299+
>>> m2d.release_desktop(True, True)
299300
"""
300301

301302
sources = self.modeler.convert_to_selections(sources, True)
@@ -634,9 +635,10 @@ def setup_y_connection(self, windings=None):
634635
This creates one ``YConnection`` group containing these three phases.
635636
636637
>>> from pyaedt import Maxwell2d
637-
>>> aedtapp = Maxwell2d("Motor_EM_R2019R3.aedt")
638-
>>> aedtapp.set_active_design("Basis_Model_For_Test")
639-
>>> aedtapp.setup_y_connection(["PhaseA", "PhaseB", "PhaseC"])
638+
>>> m2d = Maxwell2d("Motor_EM_R2019R3.aedt")
639+
>>> m2d.set_active_design("Basis_Model_For_Test")
640+
>>> m2d.setup_y_connection(["PhaseA", "PhaseB", "PhaseC"])
641+
>>> m2d.release_desktop(True, True)
640642
"""
641643

642644
if self.solution_type not in ["Transient"]:
@@ -689,9 +691,10 @@ def assign_current(self, objects, amplitude=1, phase="0deg", solid=True, swap_di
689691
--------
690692
691693
>>> from pyaedt import Maxwell3d
692-
>>> app = pyaedt.Maxwell3d(solution_type="ElectroDCConduction")
693-
>>> cylinder= app.modeler.create_cylinder("X", [0,0,0],10, 100, 250)
694-
>>> current = app.assign_current(cylinder.top_face_x.id,amplitude="2mA")
694+
>>> m3d = Maxwell3d(solution_type="ElectroDCConduction")
695+
>>> cylinder= m3d.modeler.create_cylinder("X", [0,0,0],10, 100, 250)
696+
>>> current = m3d.assign_current(cylinder.top_face_x.id,amplitude="2mA")
697+
>>> m3d.release_desktop(True, True)
695698
"""
696699

697700
if isinstance(amplitude, (int, float)):
@@ -1244,6 +1247,8 @@ def assign_force(self, objects, coordinate_system="Global", is_virtual=True, for
12441247
12451248
Assign virtual force to a magnetic object:
12461249
1250+
>>> from pyaedt import Maxwell3d
1251+
>>> m3d = Maxwell3d()
12471252
>>> iron_object = m3d.modeler.create_box([0, 0, 0], [2, 10, 10], name="iron")
12481253
>>> magnet_object = m3d.modeler.create_box([10, 0, 0], [2, 10, 10], name="magnet")
12491254
>>> m3d.assign_material(iron_object, "iron")
@@ -1257,6 +1262,7 @@ def assign_force(self, objects, coordinate_system="Global", is_virtual=True, for
12571262
>>> m3d.assign_material(conductor1, "copper")
12581263
>>> m3d.assign_material(conductor2, "copper")
12591264
>>> m3d.assign_force("conductor1",is_virtual=False,force_name="force_copper") # conductor, use Lorentz force
1265+
>>> m3d.release_desktop(True, True)
12601266
"""
12611267
if self.solution_type not in ["ACConduction", "DCConduction"]:
12621268
objects = self.modeler.convert_to_selections(objects, True)
@@ -1989,9 +1995,9 @@ def create_setup(self, setup_name="MySetupAuto", setup_type=None, **kwargs):
19891995
Examples
19901996
--------
19911997
>>> from pyaedt import Maxwell3d
1992-
>>> app = Maxwell3d()
1998+
>>> m3d = Maxwell3d()
19931999
>>> app.create_setup(setup_name="My_Setup",setup_type="EddyCurrent",MaximumPasses=10,PercentError=2)
1994-
2000+
>>> m3d.release_desktop(True, True)
19952001
"""
19962002
if setup_type is None:
19972003
setup_type = self.design_solutions.default_setup
@@ -2074,13 +2080,13 @@ class Maxwell3d(Maxwell, FieldAnalysis3D, object):
20742080
project, which is named ``mymaxwell.aedt``.
20752081
20762082
>>> from pyaedt import Maxwell3d
2077-
>>> aedtapp = Maxwell3d("mymaxwell.aedt")
2083+
>>> m3d = Maxwell3d("mymaxwell.aedt")
20782084
PyAEDT INFO: Added design ...
20792085
2080-
Create an instance of Maxwell 3D using the 2023 R2 release and open
2086+
Create an instance of Maxwell 3D using the 2024 R1 release and open
20812087
the specified project, which is named ``mymaxwell2.aedt``.
20822088
2083-
>>> aedtapp = Maxwell3d(specified_version="2023.2", projectname="mymaxwell2.aedt")
2089+
>>> m3d = Maxwell3d(specified_version="2024.1", project_name="mymaxwell2.aedt")
20842090
PyAEDT INFO: Added design ...
20852091
20862092
"""
@@ -2832,18 +2838,18 @@ class Maxwell2d(Maxwell, FieldAnalysis3D, object):
28322838
not exist.
28332839
28342840
>>> from pyaedt import Maxwell2d
2835-
>>> aedtapp = Maxwell2d()
2841+
>>> m2d = Maxwell2d()
28362842
28372843
Create an instance of Maxwell 2D and link to a project named
2838-
``projectname``. If this project does not exist, create one with
2844+
``project_name``. If this project does not exist, create one with
28392845
this name.
28402846
2841-
>>> aedtapp = Maxwell2d(projectname)
2847+
>>> m2d = Maxwell2d(project_name)
28422848
28432849
Create an instance of Maxwell 2D and link to a design named
2844-
``designname`` in a project named ``projectname``.
2850+
``design_name`` in a project named ``project_name``.
28452851
2846-
>>> aedtapp = Maxwell2d(projectname,designame)
2852+
>>> m2d = Maxwell2d(project_name,design_name)
28472853
28482854
"""
28492855

0 commit comments

Comments
 (0)