.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/00-basic/04-ptrace_pathline.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_00-basic_04-ptrace_pathline.py: .. _ptrace_pathline: Pathline (transient streamline) Creation ======================================== Utilize EnSight Particle Trace for Pathline (transient streamline). Create a Pathline and Animate it. .. GENERATED FROM PYTHON SOURCE LINES 13-17 Start an EnSight session ------------------------ Launch and connect to an instance of EnSight. This example uses a local EnSight installation. .. GENERATED FROM PYTHON SOURCE LINES 17-26 .. code-block:: Python from ansys.pyensight.core import LocalLauncher session = LocalLauncher().start() # Setup shortcuts for long winded calls. eocore = session.ensight.objs.core eonums = session.ensight.objs.enums eoutil = session.ensight.utils .. GENERATED FROM PYTHON SOURCE LINES 27-33 Load a dataset -------------- Load Flow2D dataset included in the EnSight installation set the timestep to the minimum timestep and render. .. image:: /_static/04_pathline_0.png .. GENERATED FROM PYTHON SOURCE LINES 33-41 .. code-block:: Python session.load_data(f"{session.cei_home}/ensight{session.cei_suffix}/data/flow2d/flow2d.case") varname = eocore.VARIABLES["VITESSE"][0] eocore.PARTS.set_attr("COLORBYPALETTE", varname) session.ensight.objs.core.TIMESTEP = session.ensight.objs.core.TIMESTEP_LIMITS[0] session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 42-52 Create a clip plane ------------------- Create a clip through the domain, at X = 0.75. We first call up the default clip part, set attributes, and then create the clip MESHPLANE sets the type of clip (e.g. X, Y, Z, R, T, Z, etc) TOOL sets the tool to create the clip from. VALUE is the location of the clip. DOMAIN controls intersection vs inside vs outside etc. Parent Part is named 'Part by All Elements' .. GENERATED FROM PYTHON SOURCE LINES 52-64 .. code-block:: Python clip = eocore.DEFAULTPARTS[session.ensight.PART_CLIP_PLANE] parent_parts = eocore.PARTS["Part by All Elements"][0] attrs = [] attrs.append(["MESHPLANE", eonums.MESH_SLICE_X]) attrs.append(["TOOL", eonums.CT_XYZ]) attrs.append(["VALUE", 0.75]) attrs.append(["DOMAIN", eonums.CLIP_DOMAIN_INTER]) clip = clip.createpart(name="X_Clip", sources=[parent_parts], attributes=attrs) .. GENERATED FROM PYTHON SOURCE LINES 65-73 Create a Pathline Trace Emitting from the Clip Part --------------------------------------------------------- Using the 2D parts as the parent (model is 2d), with the "from Part" as the emission type "VITESSE" as the vector, and 25 points along the Clip line as emitter locations. We also setup to first emit the Pathlines at time = 4 seconds. and Emit NEW pathlines ever 20 seconds after that. (They will follow NEW path) .. image:: /_static/04_pathline_1.png .. GENERATED FROM PYTHON SOURCE LINES 73-91 .. code-block:: Python emitter_part = clip parent_parts = eoutil.parts.select_parts_by_dimension(2) npts = 25 # number of emitters vector_var = varname # Vector variable to use pathline_part = eoutil.parts.create_particle_trace_from_parts( "Pathline", vector_var, parts=emitter_part, num_points=npts, source_parts=parent_parts, pathlines=True, emit_time=4.0, delta_time=20.0, ) session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 92-97 Change Visual Attributes ---------------------------------------------------------- Modify the attributes of the pathlines and animate over time .. image:: /_static/04_pathline_2.png .. GENERATED FROM PYTHON SOURCE LINES 97-103 .. code-block:: Python pathline_part.REPRESENTATION = eonums.TRACE_TUBE pathline_part.WIDTHSCALEFACTOR = 0.012 session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 104-114 Animate the Pathlines ---------------------------------------------------------- Turn OFF the pathline lines visibility (to see the animate under) Turn ON the animate pathlines. Change to Sphere representation, size, and adjust speed and length. .. video:: ../../_static/04_pathline_3.mp4 :width: 640 :height: 360 .. GENERATED FROM PYTHON SOURCE LINES 114-122 .. code-block:: Python pathline_part.VISIBLE = False pathline_part.ANIMATE = True eocore.HEADTYPE = eonums.ATRACE_HEAD_SPHERE eocore.HEADSCALE = 0.3 session.ensight.solution_time.play_forward() session.show("animation", width=800, height=600, fps=15) .. GENERATED FROM PYTHON SOURCE LINES 123-124 Close the session .. GENERATED FROM PYTHON SOURCE LINES 124-127 .. code-block:: Python # sphinx_gallery_thumbnail_path = '_static/04_pathline_2.png' session.close() .. _sphx_glr_download__examples_00-basic_04-ptrace_pathline.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04-ptrace_pathline.ipynb <04-ptrace_pathline.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04-ptrace_pathline.py <04-ptrace_pathline.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 04-ptrace_pathline.zip <04-ptrace_pathline.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_