-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose arguments for cyclic result queries (#336)
* Fix typos in 02-modal-extract-sub-results.py * Fix incoherent part in 02-modal-extract-sub-results.py * Expose read_cyclic pin for ModalMechanicalSimulation.displacement * Add 06-cyclic-results.py (WIP) * Proposition with boolean arguments "expand_sectors" and "merge_stages" * Refactor to accept 'expand_cyclic' keyword, True by default (read_cyclic=3), with False (read_cyclic=1). Can take a list of int, or a list of lists of int (multi-stage) to specify sector numbers to expand. * Expose phase_angle_cyclic argument, connected to pin 19 (phi) * Treat multi-stage case for plotting, improve label_space print in plot title * Fix typehinting * Fix typehinting * Improve typehinting * Refactor into Simulation._treat_cyclic, propagate to all result APIs for Static, Modal and Harmonic * Improve coverage * Improve coverage * Improve coverage * Improve Dataframe output for norm * Improve Dataframe output for single comp result * Improve Dataframe output for equivalent result * Working 06-cyclic-results.py * First working 07-multi-stage-cyclic-results.py * Fix bug when title argument is given to plot * Fix step "Set licensing if necessary" in CI and CI_release for retro tests * Fix ANSYS_VERSION for "upload test results" step of retro in ci.yml and ci_release.yml * Print empty dataframes * Update examples * Updates from comments * Updates from comments * Fix "Extract elemental nodal" -> "Extract" as location can be changed * Fix "Von Mises" -> "von Mises" * Remove Pandas from requirements_test.txt * Force one-based indexing for sectors in cyclic * Force one-based indexing for sectors in cyclic * Force one-based indexing for sectors in cyclic * Add dosctring examples to ModalMechanicalSimulation.displacement
- Loading branch information
Showing
16 changed files
with
2,530 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
.. _ref_cyclic_results_example: | ||
Extract cyclic results | ||
====================== | ||
In this script, a modal analysis with cyclic symmetry is processed to show | ||
how to expand the mesh and results. | ||
""" | ||
|
||
############################################################################### | ||
# Perform required imports | ||
# ------------------------ | ||
# This example uses a supplied file that you can | ||
# get by importing the DPF ``examples`` package. | ||
|
||
from ansys.dpf import post | ||
from ansys.dpf.post import examples | ||
|
||
############################################################################### | ||
# Get ``Simulation`` object | ||
# ------------------------- | ||
# Get the ``Simulation`` object that allows access to the result. The ``Simulation`` | ||
# object must be instantiated with the path for the result file. For example, | ||
# ``"C:/Users/user/my_result.rst"`` on Windows or ``"/home/user/my_result.rst"`` | ||
# on Linux. | ||
|
||
example_path = examples.find_simple_cyclic() | ||
simulation = post.ModalMechanicalSimulation(example_path) | ||
|
||
# print the simulation to get an overview of what's available | ||
print(simulation) | ||
|
||
############################################################################# | ||
# Extract expanded displacement norm | ||
# ---------------------------------- | ||
|
||
displacement_norm = simulation.displacement( | ||
norm=True, | ||
expand_cyclic=True, | ||
) | ||
print(displacement_norm) | ||
displacement_norm.plot() | ||
|
||
############################################################################# | ||
# Extract equivalent von Mises nodal stress expanded on the first four sectors | ||
# ---------------------------------------------------------------------------- | ||
|
||
stress_vm_sectors_1_2_3_4 = simulation.stress_eqv_von_mises_nodal( | ||
expand_cyclic=[1, 2, 3, 4], | ||
) | ||
print(stress_vm_sectors_1_2_3_4) | ||
stress_vm_sectors_1_2_3_4.plot() | ||
|
||
############################################################################# | ||
# Extract equivalent von Mises nodal stress without expansion | ||
# ----------------------------------------------------------- | ||
|
||
stress_vm_sector_1 = simulation.stress_eqv_von_mises_nodal( | ||
expand_cyclic=False, | ||
) | ||
print(stress_vm_sector_1) | ||
stress_vm_sector_1.plot() |
72 changes: 72 additions & 0 deletions
72
examples/01-Detailed-Examples/07-multi-stage-cyclic-results.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
""" | ||
.. _ref_multi-stage_cyclic_results_example: | ||
Extract multi-stage cyclic results | ||
================================== | ||
In this script, a multi-stage modal analysis with cyclic symmetry is processed to show | ||
how to expand the mesh and results. | ||
""" | ||
|
||
############################################################################### | ||
# Perform required imports | ||
# ------------------------ | ||
# This example uses a supplied file that you can | ||
# get by importing the DPF ``examples`` package. | ||
|
||
from ansys.dpf import post | ||
from ansys.dpf.post import examples | ||
|
||
############################################################################### | ||
# Get ``Simulation`` object | ||
# ------------------------- | ||
# Get the ``Simulation`` object that allows access to the result. The ``Simulation`` | ||
# object must be instantiated with the path for the result file. For example, | ||
# ``"C:/Users/user/my_result.rst"`` on Windows or ``"/home/user/my_result.rst"`` | ||
# on Linux. | ||
|
||
example_path = examples.download_multi_stage_cyclic_result() | ||
simulation = post.ModalMechanicalSimulation(example_path) | ||
|
||
# print the simulation to get an overview of what's available | ||
print(simulation) | ||
|
||
############################################################################# | ||
# Extract expanded displacement norm | ||
# ---------------------------------- | ||
|
||
displacement_norm = simulation.displacement( | ||
norm=True, | ||
expand_cyclic=True, | ||
) | ||
print(displacement_norm) | ||
displacement_norm.plot() | ||
|
||
############################################################################# | ||
# Extract equivalent von Mises nodal stress without expansion | ||
# ----------------------------------------------------------- | ||
|
||
stress_vm_sector_1_both_stages = simulation.stress_eqv_von_mises_nodal( | ||
expand_cyclic=False, | ||
) | ||
print(stress_vm_sector_1_both_stages) | ||
stress_vm_sector_1_both_stages.plot() | ||
|
||
############################################################################# | ||
# Extract equivalent von Mises nodal stress expanded on the first four sectors of the first stage | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
stress_vm_sectors_1_2_3_4_first_stage = simulation.stress_eqv_von_mises_nodal( | ||
expand_cyclic=[1, 2, 3, 4], | ||
) | ||
print(stress_vm_sectors_1_2_3_4_first_stage) | ||
stress_vm_sectors_1_2_3_4_first_stage.plot() | ||
|
||
############################################################################# | ||
# Extract equivalent von Mises nodal stress expanded on the first two sectors of both stages | ||
# ------------------------------------------------------------------------------------------ | ||
|
||
stress_vm_sectors_1_2_both_stages = simulation.stress_eqv_von_mises_nodal( | ||
expand_cyclic=[[1, 2], [1, 2]], | ||
) | ||
print(stress_vm_sectors_1_2_both_stages) | ||
stress_vm_sectors_1_2_both_stages.plot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.