diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index df94d669b..e9037f916 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -32,6 +32,14 @@ on: required: true type: string default: '' + generate_pdf: + description: "Whether to build the PDF doc" + type: string + default: 'True' + debug: + description: "Debug verbose mode" + type: string + default: 'True' # Can be called manually workflow_dispatch: inputs: @@ -60,6 +68,10 @@ on: required: false type: string default: '' + generate_pdf: + description: "Whether to build the PDF doc" + type: string + default: 'True' env: PACKAGE_NAME: ansys-dpf-post @@ -169,21 +181,23 @@ jobs: - name: "Upload Documentation Build log" uses: actions/upload-artifact@v3.1.0 with: - name: doc-${{inputs.PACKAGE_NAME}}-log + name: doc-${{env.PACKAGE_NAME}}-log path: docs/*.txt - if: inputs.debug == 'false' + if: always() - name: "Zip HTML Documentation" - uses: vimtor/action-zip@v1 + uses: vimtor/action-zip@v1.1 with: files: docs/build/html - dest: HTML-doc-${{inputs.PACKAGE_NAME}}.zip + dest: HTML-doc-${{env.PACKAGE_NAME}}.zip + if: always() - name: "Upload HTML Documentation" uses: actions/upload-artifact@v3 with: - name: HTML-doc-${{inputs.PACKAGE_NAME}} - path: HTML-doc-${{inputs.PACKAGE_NAME}}.zip + name: HTML-doc-${{env.PACKAGE_NAME}} + path: HTML-doc-${{env.PACKAGE_NAME}}.zip + if: always() - name: "Find PDF Documentation" shell: bash @@ -197,18 +211,18 @@ jobs: echo "Found PDF doc: ${files[0]}" - name: "Zip PDF Documentation" - uses: vimtor/action-zip@v1 + uses: vimtor/action-zip@v1.1 if: ${{ inputs.generate_pdf == 'true' }} with: files: docs/build/latex/${{ steps.pdf.outputs.PDF_file }} - dest: PDF-doc-${{inputs.PACKAGE_NAME}}.zip + dest: PDF-doc-${{env.PACKAGE_NAME}}.zip - name: "Upload PDF Documentation" uses: actions/upload-artifact@v3.1.0 if: inputs.generate_pdf == 'true' with: - name: PDF-doc-${{inputs.PACKAGE_NAME}} - path: PDF-doc-${{inputs.PACKAGE_NAME}}.zip + name: PDF-doc-${{env.PACKAGE_NAME}} + path: PDF-doc-${{env.PACKAGE_NAME}}.zip - name: "Kill all servers" uses: pyansys/pydpf-actions/kill-dpf-servers@v2.3 diff --git a/README.md b/README.md index 139ebf04e..5af9f977b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DPF-Post - Ansys Data Post-Processing Framework +# PyDPF-Post - Ansys Data Post-Processing Framework [![PyAnsys](https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC)](https://docs.pyansys.com/) [![Python](https://img.shields.io/pypi/pyversions/ansys-dpf-post?logo=pypi)](https://pypi.org/project/ansys-dpf-post/) [![pypi](https://badge.fury.io/py/ansys-dpf-post.svg?logo=python&logoColor=white)](https://pypi.org/project/ansys-dpf-post) @@ -17,15 +17,13 @@ be found by visiting [PyDPF-Core GitHub](https://github.com/pyansys/pydpf-core). Use ``ansys-dpf-core`` for building more advanced and customized workflows using Ansys DPF. - ## Documentation -Visit the [DPF-Post Documentation](https://postdocs.pyansys.com) for a +Visit the [PyDPF-Post Documentation](https://postdocs.pyansys.com) for a detailed description of the package, or see the [Examples Gallery](https://postdocs.pyansys.com/examples/index.html) for more detailed examples. - ## Installation Install this repository with: @@ -42,11 +40,10 @@ cd pydpf-post pip install . --user ``` - ## Brief Demo -Provided you have ANSYS 2023 R1 installed, a DPF server will start -automatically once you start using pyDPF-Post. +Provided you have ANSYS 2023 R1 installed, a DPF server starts +automatically once you start using PyDPF-Post. Loading a simulation to extract and post-process results: ```pycon @@ -56,6 +53,7 @@ Loading a simulation to extract and post-process results: >>> displacement = simulation.displacement() >>> print(displacement) ``` +```pycon results U set_id 3 node comp @@ -66,7 +64,7 @@ Loading a simulation to extract and post-process results: Y 1.44e-03 Z 5.31e-06 ... - +``` ```pycon >>> displacement.plot() ``` @@ -89,7 +87,6 @@ tools: ``` ![Example Stress plot Crankshaft](https://github.com/pyansys/dpf-post/raw/master/docs/source/images/crankshaft_stress.png) - ## License ``PyDPF-Post`` is licensed under the MIT license. For more information, see the diff --git a/docs/source/conf.py b/docs/source/conf.py index 7b35750de..5f6dda440 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -217,7 +217,7 @@ ( master_doc, "PyDPF-Post.tex", - "PyAnsys DPF-Post Documentation", + "PyAnsys PyDPF-Post Documentation", author, "manual", ), @@ -228,7 +228,9 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "PyDPF-Post", "PyAnsys DPF-Post Documentation", [author], 1)] +man_pages = [ + (master_doc, "PyDPF-Post", "PyAnsys PyDPF-Post Documentation", [author], 1) +] # -- Options for Texinfo output ---------------------------------------------- @@ -240,7 +242,7 @@ ( master_doc, "PyDPF-Post", - "PyAnsys DPF-Post Documentation", + "PyAnsys PyDPF-Post Documentation", author, "pyansys", "", diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 6b25076a2..bcde0176e 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -25,7 +25,7 @@ development mode, run: Post issues ----------- -Use the `PyDPF-Post Issues `_ +Use the `PyDPF-Post Issues `_ page to submit questions, report bugs, and request new features. To reach the PyAnsys support team, email `pyansys.support@ansys.com `_. @@ -33,5 +33,5 @@ To reach the PyAnsys support team, email `pyansys.support@ansys.com _. +`PyDPF Documentation `_. diff --git a/docs/source/getting_started/index.rst b/docs/source/getting_started/index.rst index 31c3e01a6..2c166e145 100755 --- a/docs/source/getting_started/index.rst +++ b/docs/source/getting_started/index.rst @@ -6,8 +6,11 @@ Getting started To use the PyDPF-Post API, you must have PyDPF-Core installed. Because you need to use a native DPF server, you must also have a local installation of Ansys 2021 R1 -or later. For more information on getting a licensed copy of Ansys, visit the +or later or of the standalone DPF Server. +For more information on getting a licensed copy of Ansys, visit the `Ansys website `_. +For more information on getting the standalone DPF Server, visit the +`PyDPF-Core documentation `_. .. toctree:: diff --git a/docs/source/getting_started/install.rst b/docs/source/getting_started/install.rst index 47bff99d5..44dcdf6d9 100644 --- a/docs/source/getting_started/install.rst +++ b/docs/source/getting_started/install.rst @@ -50,7 +50,7 @@ and unzip it to the same local directory before running the preceding command ag Install in development mode --------------------------- -If you want to edit and potentially contribute to DPF-Post, +If you want to edit and potentially contribute to PyDPF-Post, clone the repository and install it using ``pip`` with the ``-e`` development flag: @@ -66,5 +66,5 @@ Run the following Python code to verify your PyDPF-Post installation: from ansys.dpf import post from ansys.dpf.post import examples - solution = post.load_solution(examples.simple_bar) - print(solution) + simulation = post.load_simulation(examples.simple_bar) + print(simulation) diff --git a/docs/source/images/crankshaft_stress_xx.png b/docs/source/images/crankshaft_stress_xx.png new file mode 100644 index 000000000..7be8c44f5 Binary files /dev/null and b/docs/source/images/crankshaft_stress_xx.png differ diff --git a/docs/source/index.rst b/docs/source/index.rst index df03f3d1b..6b27b5210 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,15 +10,15 @@ The Python `ansys-dpf-post` package provides a high level, physics oriented API Loading a simulation (defined by its result files) allows you to extract simulation metadata as well as results and apply postprocessing operations on it. -This module leverages the PyDPF-Core project's ``ansys-dpf-core`` package and can -be found by visiting [PyDPF-Core GitHub](https://github.com/pyansys/pydpf-core). +This module leverages the PyDPF-Core project's ``ansys-dpf-core`` package which can +be found by visiting `PyDPF-Core GitHub `_. Use ``ansys-dpf-core`` for building more advanced and customized workflows using Ansys DPF. Brief demo ~~~~~~~~~~ -Provided you have ANSYS 2023 R1 installed, a DPF server will start +Provided you have Ansys 2023 R1 installed, a DPF server starts automatically once you start using PyDPF-Post. Loading a simulation for a MAPDL result file to extract and post-process results: @@ -87,7 +87,7 @@ Key features PyDPF-Post is based on DPF, whose data framework localizes loading and postprocessing on the DPF server, enabling rapid postprocessing workflows -because they are written in C and FORTRAN. Because DPF-Post presents results +because they are written in C and FORTRAN. Because PyDPF-Post presents results in a Pythonic manner, you can rapidly develop simple or complex postprocessing scripts. diff --git a/docs/source/user_guide/accessing_file_metadata.rst b/docs/source/user_guide/accessing_file_metadata.rst index 89f647c65..6b55c9b22 100644 --- a/docs/source/user_guide/accessing_file_metadata.rst +++ b/docs/source/user_guide/accessing_file_metadata.rst @@ -4,7 +4,7 @@ Browse result metadata ********************** -In addition to the :class:`DpfSolution ` +In addition to the :class:`Simulation ` object being the entry point for browsing the contents of a result file, it provides important metadata, such as the analysis type and the available results. @@ -12,59 +12,85 @@ Here is how you browse result metadata: .. code:: python - Instantiate the solution object + Instantiate the simulation object >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution(examples.multishells_rst) + >>> simulation = post.load_simulation(examples.multishells_rst) Browse result metadata - >>> result_info = solution.get_result_info() - >>> print(result_info) + >>> print(simulation) + Static Mechanical Simulation. + + + Data Sources + ------------------------------ + DPF DataSources: + Result files: + result key: rst and path: d:\ansysdev\sandbox\pydpf-core\src\ansys\dpf\core\examples\model_with_ns.rst + Secondary files: + + + DPF Model + ------------------------------ Static analysis - Unit system: Metric (m, kg, N, s, V, A) - Physics Type: Mecanic + Unit system: MKS: m, kg, N, s, V, A, degC + Physics Type: Mechanical Available results: - - displacement - - force - - stress - - volume - - energy_stiffness_matrix - - hourglass_energy - - thermal_dissipation_energy - - kinetic_energy - - co_energy - - incremental_energy - - strain - - temperature - - -DPF-Post supports four different analysis types: + - displacement: Nodal Displacement + - reaction_force: Nodal Force + - stress: ElementalNodal Stress + - elemental_volume: Elemental Volume + - stiffness_matrix_energy: Elemental Energy-stiffness matrix + - artificial_hourglass_energy: Elemental Hourglass Energy + - thermal_dissipation_energy: Elemental thermal dissipation energy + - kinetic_energy: Elemental Kinetic Energy + - co_energy: Elemental co-energy + - incremental_energy: Elemental incremental energy + - elastic_strain: ElementalNodal Strain + - structural_temperature: ElementalNodal Temperature + ------------------------------ + DPF Meshed Region: + 7079 nodes + 4220 elements + Unit: m + With solid (3D) elements, shell (2D) elements, shell (3D) elements + ------------------------------ + DPF Time/Freq Support: + Number of sets: 1 + Cumulative Time (s) LoadStep Substep + 1 1.000000 1 1 + + +PyDPF-Post supports four different analysis types for mechanical results: * Static analysis * Modal analysis * Harmonic analysis * Transient analysis +The legacy Solution object also supports thermal and electrical results. + Mesh ---- -From the ``Solution`` object, you can also access the mesh: +From the ``Simulation`` object, you can also access the mesh: .. code:: python - Instantiate the solution object + Instantiate the simulation object >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution(examples.multishells_rst) + >>> simulation = post.load_simulation(examples.multishells_rst) Access the mesh - >>> mesh = solution.mesh + >>> mesh = simulation.mesh >>> print(mesh) - Meshed Region - 7079 nodes - 4220 elements - Unit: m + DPF Mesh: + 7079 nodes + 4220 elements + Unit: m + With solid (3D) elements, shell (2D) elements, shell (3D) elements diff --git a/docs/source/user_guide/accessing_results.rst b/docs/source/user_guide/accessing_results.rst index eea304f44..791abc428 100644 --- a/docs/source/user_guide/accessing_results.rst +++ b/docs/source/user_guide/accessing_results.rst @@ -5,48 +5,45 @@ Access results ************** In addition to being the entry point for browsing the contents of a -result file, the :class:`Solution ` -object provides access to the results themselves. The results are contained -in :class:`Result ` objects, which can -be returned from dedicated methods. +result file, the :class:`Simulation ` +object provides access to the results themselves. You can query results +using dedicated methods. Here is how you get the ``displacement`` result: .. code:: python - Instantiate the solution object + Instantiate the simulation object >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution(examples.multishells_rst) + >>> simulation = post.load_simulation(examples.multishells_rst) - Instantiate the displacement result object + Extract the displacement data as a DataFrame object - >>> displacement = solution.displacement() + >>> displacement = simulation.displacement() >>> # stress, elastic_strain (...) can also be called. - See the following list for the result objects that can be - instantiated. + See the following list for the results that can be + extracted. You can use *keyword arguments* to further specify other options, -including the result type, scope, and time. For detailed examples, +including the components, scope, and time. For detailed examples, see :ref:`ref_result_keywords`. -DPF-Post supports two types of result files: +PyDPF-Post supports two types of result files: * Structural (RST) -* Thermal/electric (RTH) +* Thermal/electric (RTH) (with the legacy *load_solution()* method only) -Once loaded into a :class:`Solution ` -object, a result file offers a variety of :class:`Result ` -objects, depending on its type. - -You should request only ``Result`` objects that are available in a result file. -To determine which ``Result`` objects are available, see :ref:`user_guide_accessing_file_metadata`. +You should only request results available in the result file. +To determine which results are available, see :ref:`user_guide_accessing_file_metadata`. Structural result files ======================= +This section details how to access structural results using the legacy ``Solution`` object. + After loading a ``Solution`` object from a structural analysis result (RST) file, you can query these ``Result`` objects: @@ -262,6 +259,8 @@ information, see :ref:`user_guide_accessing_file_metadata`. Thermal/electric result files ============================= +This section details how to access thermal/electric results using the legacy ``Solution`` object. + After loading a ``Solution`` object from a thermal/electric analysis result file (RTH), you can query these ``Result`` objects: diff --git a/docs/source/user_guide/extending_to_core.rst b/docs/source/user_guide/extending_to_core.rst index a0eb777af..a3cc90487 100644 --- a/docs/source/user_guide/extending_to_core.rst +++ b/docs/source/user_guide/extending_to_core.rst @@ -1,28 +1,28 @@ .. _user_guide_extending_to_core: -********************** -Use DPF-Core operators -********************** +************************ +Use PyDPF-Core operators +************************ -DPF-Post is based on DPF-Core, but it is streamlined for postprocessing. -Because DPF-Post works hand-in-hand with DPF-Core, you can use the powerful, +PyDPF-Post is based on PyDPF-Core, but it is streamlined for postprocessing. +Because PyDPF-Post works hand-in-hand with PyDPF-Core, you can use the powerful, scalable `operators `_ -in DPF-Core to facilitate data manipulation and more general data transformations. +of PyDPF-Core to facilitate data manipulation and more general data transformations. -DPF-Core can access data from Ansys solver result files as well as from -third-party file formats. With DPF-Core, you can assemble complex workflows +PyDPF-Core can access data from Ansys solver result files as well as from +third-party file formats. With PyDPF-Core, you can assemble complex workflows from simpler building blocks by chaining them together with operators. The data in DPF is represented by physics-agnostic mathematical quantities described in a self-sufficient entity called a :class:`Field `. -To show the range of DPF-Core and DPF-Post capabilities, the following -examples show they work together. +To show the range of PyDPF-Core and PyDPF-Post capabilities, the following +examples show how they work together. Export to VTK file ------------------ -This code shows how to export a fields container to a VTK file: +This code shows how to export a fields container to a VTK file using the legacy PyDPF-Post API: .. code:: python @@ -67,7 +67,7 @@ Export to HDF5 file ------------------- This code shows how to export the same fields container -to an HDF5 file: +to an HDF5 file with the legacy PyDPF-Post API: .. code:: python diff --git a/docs/source/user_guide/index.rst b/docs/source/user_guide/index.rst index 05461d248..4c5166dfc 100644 --- a/docs/source/user_guide/index.rst +++ b/docs/source/user_guide/index.rst @@ -4,10 +4,10 @@ User guide ========== -DPF-Post provides a Python interface to DPF that is streamlined for +PyDPF-Post provides a Python interface to DPF that is streamlined for postprocessing. -The following content explains the conceptual model of DPF-Post and +The following content explains the conceptual model of PyDPF-Post and typical usage. .. toctree:: diff --git a/docs/source/user_guide/plotting.rst b/docs/source/user_guide/plotting.rst index 2fc58acc9..2eab1cd58 100644 --- a/docs/source/user_guide/plotting.rst +++ b/docs/source/user_guide/plotting.rst @@ -4,15 +4,15 @@ Plot results ************ -DPF-Post provides functionality for plotting results. Here is a summary of +PyDPF-Post provides functionality for plotting results. Here is a summary of the steps: -#. Load the :class:`DpfSolution ` object +#. Load the :class:`Simulation ` object with the result file. -#. Request a :class:`Result ` object and +#. Request a :class:`DataFrame ` object to obtain the scalar field of interest. -#. Use the :func:`plot_contour ` - method to render it. +#. Use the plotting methods of the :class:`DataFrame ` object + to render it. Subsequent sections provide some plotting examples. @@ -27,37 +27,41 @@ You can plot the total deformation (norm of the displacement vector field) with: >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution(examples.multishells_rst) + >>> simulation = post.load_simulation(examples.download_crankshaft()) - Instantiate a displacement result object + Instantiate a DataFrame object containing the displacement norm data - >>> displacement = solution.displacement() - >>> norm = displacement.norm # this is the result data (data container) + >>> displacement_norm = simulation.displacement(norm=True) - Plot the result data + Plot the data and save the image - >>> norm.plot_contour() + >>> displacement_norm.plot(screenshot="crankshaft_disp.png") +.. figure:: ./images/crankshaft_disp.png + :width: 300pt Normal stresses --------------- -You can plot the normal x-component of stress with: +Plotting of raw data at Gauss points is not available yet. +You can however plot data averaged at nodes or elements. +You can plot the nodal xx-component of stress with: .. code:: python - Instantiate the solution object + Instantiate the simulation object >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution(examples.multishells_rst) + >>> simulation = post.load_simulation(examples.download_crankshaft()) - Instantiate a stress result object + Extract the XX stress data - >>> stress = solution.stress() - >>> s_xx = stress.xx # this is the result data (data container) + >>> stress_xx = simulation.stress_nodal(components=["XX"]) - Plot the result data + Plot the data and save the image - >>> s_xx.plot_contour() + >>> stress_xx.plot(screenshot="crankshaft_stress_xx.png") +.. figure:: ./images/crankshaft_stress_xx.png + :width: 300pt diff --git a/docs/source/user_guide/post_processing.rst b/docs/source/user_guide/post_processing.rst index 5bf2fc45e..3849b4dac 100644 --- a/docs/source/user_guide/post_processing.rst +++ b/docs/source/user_guide/post_processing.rst @@ -4,8 +4,8 @@ Load the result file ******************** -The :class:`DpfSolution ` object is -a central element of DPF-Post. This object is the entry point for browsing +The :class:`Simulation ` object is +a central element of PyDPF-Post. This object is the entry point for browsing the contents of a result file. **On Windows** @@ -16,7 +16,7 @@ You can load the result file with: >>> from ansys.dpf import post >>> from ansys.dpf.post import examples - >>> solution = post.load_solution('C:/Users/user/file.rst') + >>> simulation = post.load_simulation('C:/Users/user/file.rst') **On Linux** @@ -24,9 +24,9 @@ You can load the result file with: .. code:: python - >>> solution = post.load_solution('/home/user/file.rst') + >>> simulation = post.load_simulation('/home/user/file.rst') For a more detailed example on interacting with the -:class:`DpfSolution ` object, +:class:`Simulation ` object, see :ref:`ref_basics`. diff --git a/docs/source/user_guide/troubleshooting.rst b/docs/source/user_guide/troubleshooting.rst index e9ee4bd2b..17b11b5e1 100644 --- a/docs/source/user_guide/troubleshooting.rst +++ b/docs/source/user_guide/troubleshooting.rst @@ -6,14 +6,35 @@ Troubleshooting This section explains how to resolve the most common issues encountered with PyDPF-Post. It also includes suggestions for improving scripts. +Auto-completion +~~~~~~~~~~~~~~~ +Depending on your scripting environment, auto-completion might not work correctly when using the +``load_simulation()`` method. This method is intended as a helper which can detect automatically +the physics type and analysis type. To get auto-completion to work in all circumstances, instantiate + the right :ref:`Simulation DataFrame: and mesh_index.location == locations.elemental_nodal ): raise NotImplementedError( - f"Element selection on a DataFrame with elemental nodal results " - f"is not yet supported" + "Element selection on a DataFrame with elemental nodal results " + "is not yet supported" ) if out is not None: @@ -526,7 +531,7 @@ def treat_elemental_nodal(treat_lines, pos, n_comp, n_ent, n_lines): for k in list(range(num_mesh_entities_to_ask)): try: values_list = field.get_entity_data(k).tolist() - except Exception as e: + except Exception: values_list = [[None] * len(comp_values)] num_entities = len(values_list) if isinstance(values_list[0], list): @@ -570,7 +575,7 @@ def treat_elemental_nodal(treat_lines, pos, n_comp, n_ent, n_lines): values_list = field.get_entity_data_by_id( entity_id ).tolist() - except Exception as e: + except Exception: values_list = [[None] * len(comp_values)] num_entities = len(values_list) num_components = len(values_list[0]) @@ -618,11 +623,11 @@ def treat_elemental_nodal(treat_lines, pos, n_comp, n_ent, n_lines): # print(to_append) # print(len(to_append)) # print(len(lines)) - for i in range(len(lines)): + for i, _ in enumerate(lines): lines[i] = lines[i] + to_append[i] if truncated_columns: - for i in range(len(lines)): + for i, _ in enumerate(lines): lines[i] = lines[i] + truncated_str if truncated: @@ -638,7 +643,7 @@ def __repr__(self): """Representation of the DataFrame.""" return f"DataFrame" - def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[Plotter, None]: + def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None]: """Plot the result. Parameters @@ -662,8 +667,6 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[Plotter, None]: The interactive plotter object used for plotting. """ - from ansys.dpf.core.plotter import DpfPlotter as Plotter - if kwargs != {}: axis_kwargs, kwargs = self._filter_arguments(arguments=kwargs) # Construct the associated label_space @@ -719,7 +722,7 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[Plotter, None]: fc = merge_solids_shell_op.eval() fields = fc.get_fields(label_space=label_space) - plotter = Plotter(**kwargs) + plotter = DpfPlotter(**kwargs) # for field in fields: if len(fields) > 1: warnings.warn( @@ -769,7 +772,7 @@ def animate( warnings.warn( UserWarning( "Displacement result unavailable, " - f"unable to animate on the deformed mesh." + "unable to animate on the deformed mesh." ) ) else: diff --git a/src/ansys/dpf/post/examples/__init__.py b/src/ansys/dpf/post/examples/__init__.py index b8b97bf1d..f2566aa54 100644 --- a/src/ansys/dpf/post/examples/__init__.py +++ b/src/ansys/dpf/post/examples/__init__.py @@ -1,4 +1,13 @@ -"""DPF-Post example files.""" +"""PyDPF-Post example files. + +Examples +-------- +This module module exposes PyDPF-Core functionalities. + +See `here `_ +for a description of the PyDPF-Core ``example`` API. + +""" import os # alias files used by the core diff --git a/src/ansys/dpf/post/harmonic_mechanical_simulation.py b/src/ansys/dpf/post/harmonic_mechanical_simulation.py index 8a304f6d7..a71b5eea6 100644 --- a/src/ansys/dpf/post/harmonic_mechanical_simulation.py +++ b/src/ansys/dpf/post/harmonic_mechanical_simulation.py @@ -1,4 +1,9 @@ -"""Module containing the ``HarmonicMechanicalSimulation`` class.""" +"""Module containing the ``HarmonicMechanicalSimulation`` class. + +HarmonicMechanicalSimulation +---------------------------- + +""" from typing import List, Tuple, Union import warnings diff --git a/src/ansys/dpf/post/index.py b/src/ansys/dpf/post/index.py index 777ab7639..7808e906c 100644 --- a/src/ansys/dpf/post/index.py +++ b/src/ansys/dpf/post/index.py @@ -1,4 +1,9 @@ -"""Module containing the ``Index`` class.""" +"""Module containing the ``Index`` class and sub-classes. + +Index +----- + +""" from abc import ABC from typing import List, Union import weakref @@ -279,7 +284,7 @@ def __init__( # self._labels = [] # self._label_names = None # self._result_names = None - for i, index in enumerate(self._indexes): + for _, index in enumerate(self._indexes): setattr(self, index.name, index) # @property diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index 548ea0518..cda75cc66 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -1,4 +1,9 @@ -"""Module containing the ``Mesh`` class.""" +"""Module containing the ``Mesh`` class. + +Mesh +---- + +""" from typing import List from ansys.dpf.core import MeshedRegion diff --git a/src/ansys/dpf/post/misc.py b/src/ansys/dpf/post/misc.py index a13dbbf3c..b63fe6a85 100644 --- a/src/ansys/dpf/post/misc.py +++ b/src/ansys/dpf/post/misc.py @@ -1,4 +1,9 @@ -"""Miscellaneous and report module.""" +"""Miscellaneous and report module. + +Misc +---- + +""" from scooby import Report as ScoobyReport diff --git a/src/ansys/dpf/post/modal_mechanical_simulation.py b/src/ansys/dpf/post/modal_mechanical_simulation.py index 800359823..941b5f849 100644 --- a/src/ansys/dpf/post/modal_mechanical_simulation.py +++ b/src/ansys/dpf/post/modal_mechanical_simulation.py @@ -1,4 +1,9 @@ -"""Module containing the ``ModalMechanicalSimulation`` class.""" +"""Module containing the ``ModalMechanicalSimulation`` class. + +ModalMechanicalSimulation +------------------------- + +""" from typing import List, Union from ansys.dpf import core diff --git a/src/ansys/dpf/post/post_utility.py b/src/ansys/dpf/post/post_utility.py index 60b3f5243..596cdf387 100644 --- a/src/ansys/dpf/post/post_utility.py +++ b/src/ansys/dpf/post/post_utility.py @@ -1,6 +1,9 @@ """Module containing the method to instantiate the result object. -This module is used for the initialization of DPF-Post objects. +Post-utility +------------ + +This module is used for the initialization of PyDPF-Post objects. """ from typing import TypeVar, Union import warnings diff --git a/src/ansys/dpf/post/selection.py b/src/ansys/dpf/post/selection.py index 18bf06cef..5b1bee584 100644 --- a/src/ansys/dpf/post/selection.py +++ b/src/ansys/dpf/post/selection.py @@ -145,7 +145,7 @@ def _evaluate_on(self, simulation: Simulation) -> Union[Scoping, None]: Parameters ---------- simulation: - DPF-Post Simulation to evaluate the time/freq selection on. + Simulation object to evaluate the time/freq selection on. Returns ------- diff --git a/src/ansys/dpf/post/simulation.py b/src/ansys/dpf/post/simulation.py index 1ef04af5e..a90325b23 100644 --- a/src/ansys/dpf/post/simulation.py +++ b/src/ansys/dpf/post/simulation.py @@ -1,4 +1,9 @@ -"""Module containing the ``Simulation`` class.""" +"""Module containing the ``Simulation`` class. + +Simulation +---------- + +""" from abc import ABC from enum import Enum from os import PathLike @@ -622,7 +627,7 @@ def _build_selection( elif times is not None: # Check input if isinstance(times, list): - if any([not (type(t) in [float, int]) for t in times]): + if any([not isinstance(t, (float, int)) for t in times]): raise ValueError("Argument times must contain numeric values only.") elif isinstance(times, float) or isinstance(times, int): times = [times] diff --git a/src/ansys/dpf/post/static_mechanical_simulation.py b/src/ansys/dpf/post/static_mechanical_simulation.py index 7c934c393..3d4b62d3f 100644 --- a/src/ansys/dpf/post/static_mechanical_simulation.py +++ b/src/ansys/dpf/post/static_mechanical_simulation.py @@ -1,4 +1,9 @@ -"""Module containing the ``StaticMechanicalSimulation`` class.""" +"""Module containing the ``StaticMechanicalSimulation`` class. + +StaticMechanicalSimulation +-------------------------- + +""" from typing import List, Tuple, Union from ansys.dpf import core diff --git a/src/ansys/dpf/post/transient_mechanical_simulation.py b/src/ansys/dpf/post/transient_mechanical_simulation.py index fb681e31c..4b87cef7b 100644 --- a/src/ansys/dpf/post/transient_mechanical_simulation.py +++ b/src/ansys/dpf/post/transient_mechanical_simulation.py @@ -1,4 +1,9 @@ -"""Module containing the ``TransientMechanicalSimulation`` class.""" +"""Module containing the ``TransientMechanicalSimulation`` class. + +TransientMechanicalSimulation +----------------------------- + +""" from typing import List, Tuple, Union from ansys.dpf import core as dpf diff --git a/tests/test_load_simulation.py b/tests/test_load_simulation.py index db1b93df7..54b2a234d 100644 --- a/tests/test_load_simulation.py +++ b/tests/test_load_simulation.py @@ -15,7 +15,7 @@ def test_load_simulation_static_mechanical(simple_bar, complex_model): data_sources=complex_model, simulation_type=AvailableSimulationTypes.static_mechanical, ) - assert type(simulation) == StaticMechanicalSimulation + assert isinstance(simulation, StaticMechanicalSimulation) def test_load_simulation_transient_mechanical(plate_msup, complex_model): @@ -25,7 +25,7 @@ def test_load_simulation_transient_mechanical(plate_msup, complex_model): data_sources=complex_model, simulation_type=AvailableSimulationTypes.transient_mechanical, ) - assert type(simulation) == TransientMechanicalSimulation + assert isinstance(simulation, TransientMechanicalSimulation) def test_load_simulation_modal_mechanical(modalallkindofcomplexity, complex_model): @@ -35,7 +35,7 @@ def test_load_simulation_modal_mechanical(modalallkindofcomplexity, complex_mode data_sources=complex_model, simulation_type=AvailableSimulationTypes.transient_mechanical, ) - assert type(simulation) == TransientMechanicalSimulation + assert isinstance(simulation, TransientMechanicalSimulation) def test_load_simulation_harmonic_mechanical(complex_model, simple_bar): @@ -45,7 +45,7 @@ def test_load_simulation_harmonic_mechanical(complex_model, simple_bar): data_sources=simple_bar, simulation_type=AvailableSimulationTypes.harmonic_mechanical, ) - assert type(simulation) == HarmonicMechanicalSimulation + assert isinstance(simulation, HarmonicMechanicalSimulation) def test_load_simulation_raise_simulation_type(simple_bar):