chore: (migrated PR #4009) docs: static rom training data generation example - #4011
Merged
Conversation
Contributor
Reviewer's GuideThis PR integrates a new extended-doc example that demonstrates how to generate static ROM training data with PyMAPDL, DPF, and PyTwin by adding a Python export script and its corresponding RST guide, and updating documentation configuration and indices accordingly. File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
10 tasks
Contributor
There was a problem hiding this comment.
Hey @germa89 - I've reviewed your changes - here's some feedback:
- In get_scoping(), you call op.outputs.mesh_scoping() twice—capture the first output in a variable and reuse it to avoid rerunning the operator and ensure consistency.
- The conditional block in export_static_ROM_variation for handling 'displacement' vs 'stress' is hardcoded; consider refactoring this into a mapping or helper function so it’s easier to add new result types in the future.
- Wrap the launch_mapdl() and download_example_data() calls in try/except to provide clearer error messages and clean up resources if the MAPDL session fails to start or the download fails.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In get_scoping(), you call op.outputs.mesh_scoping() twice—capture the first output in a variable and reuse it to avoid rerunning the operator and ensure consistency.
- The conditional block in export_static_ROM_variation for handling 'displacement' vs 'stress' is hardcoded; consider refactoring this into a mapping or helper function so it’s easier to add new result types in the future.
- Wrap the launch_mapdl() and download_example_data() calls in try/except to provide clearer error messages and clean up resources if the MAPDL session fails to start or the download fails.
## Individual Comments
### Comment 1
<location> `doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py:117` </location>
<code_context>
+ take_mid_nodes=True,
+ )
+ # Get output data
+ connected_nodes_scoping = op.outputs.mesh_scoping()
+ # Compress the list to only keep unique IDs
+ connected_nodes_scoping.ids = sorted(list(set(op.outputs.mesh_scoping().ids)))
+ return connected_nodes_scoping
+
</code_context>
<issue_to_address>
Reuse the mesh_scoping output instead of calling it twice
Reuse the previously assigned `connected_nodes_scoping.ids` instead of calling `op.outputs.mesh_scoping()` again to avoid redundancy and improve code clarity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
# Get output data
connected_nodes_scoping = op.outputs.mesh_scoping()
# Compress the list to only keep unique IDs
connected_nodes_scoping.ids = sorted(list(set(op.outputs.mesh_scoping().ids)))
return connected_nodes_scoping
=======
# Get output data
connected_nodes_scoping = op.outputs.mesh_scoping()
# Compress the list to only keep unique IDs
connected_nodes_scoping.ids = sorted(list(set(connected_nodes_scoping.ids)))
return connected_nodes_scoping
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst:205` </location>
<code_context>
+
+Modifying result scoping
+------------------------
+The script exports results on all nodes that are connected to elements. This does not account for
+nodes that are connected to elements, but do not have results associated with them. For example
+MPC184 pilot nodes would not usually have a stress result. The script also does not allow scoping
+component.
</code_context>
<issue_to_address>
Awkward phrasing: 'does not allow scoping component' should be 'does not allow component scoping'.
Rephrase as 'does not allow component scoping' for clarity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
MPC184 pilot nodes would not usually have a stress result. The script also does not allow scoping
component.
=======
MPC184 pilot nodes would not usually have a stress result. The script also does not allow component scoping.
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Hey @germa89 - I've reviewed your changes - here's some feedback:
- In conf.py, rename the intersphinx key from “pytwin” to something like “ansys-pytwin” to keep it consistent with your other
ansys-*mapping names. - The
static_rom_data_generation.pyscript is quite large—consider extracting common utility functions into a separate module or splitting into smaller sections to make the example easier to navigate. - Add a brief prerequisites section in the RST example (e.g. required package installs and versions) so users know they must have PyTwin and DPF set up before running the script.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In conf.py, rename the intersphinx key from “pytwin” to something like “ansys-pytwin” to keep it consistent with your other `ansys-*` mapping names.
- The `static_rom_data_generation.py` script is quite large—consider extracting common utility functions into a separate module or splitting into smaller sections to make the example easier to navigate.
- Add a brief prerequisites section in the RST example (e.g. required package installs and versions) so users know they must have PyTwin and DPF set up before running the script.
## Individual Comments
### Comment 1
<location> `doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py:295` </location>
<code_context>
+
+def run():
+ # Define a folder for output.
+ rom_folder = Path(tempfile.gettempdir()).joinpath("ansys_pymadl_Static_ROM")
+ mapdl_results = run_mapdl_variations()
+ export_static_ROM_data(mapdl_results, rom_folder)
</code_context>
<issue_to_address>
Typo in output folder name
Please rename the folder to `ansys_pymapdl_Static_ROM` for consistency.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
def run():
# Define a folder for output.
rom_folder = Path(tempfile.gettempdir()).joinpath("ansys_pymadl_Static_ROM")
mapdl_results = run_mapdl_variations()
export_static_ROM_data(mapdl_results, rom_folder)
print(f"ROM data exported to: {rom_folder}")
=======
def run():
# Define a folder for output.
rom_folder = Path(tempfile.gettempdir()).joinpath("ansys_pymapdl_Static_ROM")
mapdl_results = run_mapdl_variations()
export_static_ROM_data(mapdl_results, rom_folder)
print(f"ROM data exported to: {rom_folder}")
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py:228` </location>
<code_context>
+ """
+ for idx, (rst_path, parameters) in enumerate(mapdl_results):
+ # Load the results to DPF and create scoping.
+ model = dpf.Model(rst_path)
+ scoping = get_scoping(model)
+
</code_context>
<issue_to_address>
Release or close DPF model resources
To prevent increased memory usage, ensure each DPF model is released or closed after use, either via a context manager or by explicitly calling the appropriate method.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
for idx, (rst_path, parameters) in enumerate(mapdl_results):
# Load the results to DPF and create scoping.
model = dpf.Model(rst_path)
scoping = get_scoping(model)
=======
for idx, (rst_path, parameters) in enumerate(mapdl_results):
# Load the results to DPF and create scoping.
with dpf.Model(rst_path) as model:
scoping = get_scoping(model)
>>>>>>> REPLACE
</suggested_fix>
### Comment 3
<location> `doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst:205` </location>
<code_context>
+
+Modifying result scoping
+------------------------
+The script exports results on all nodes that are connected to elements. This does not account for
+nodes that are connected to elements, but do not have results associated with them. For example
+MPC184 pilot nodes would not usually have a stress result. The script also does not allow scoping
+component.
</code_context>
<issue_to_address>
Grammar: 'does not allow scoping component' should be 'does not allow component scoping'.
Rephrase as 'does not allow component scoping' for improved clarity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
MPC184 pilot nodes would not usually have a stress result. The script also does not allow scoping
component.
=======
MPC184 pilot nodes would not usually have a stress result. The script also does not allow component scoping.
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
reviewed
Jun 16, 2025
PipKat
approved these changes
Jun 16, 2025
PipKat
left a comment
Member
There was a problem hiding this comment.
Minor edits based mostly on writing to the Google developer documentation style guide.
Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com>
Contributor
Collaborator
Author
10 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a mirror pull request created from docs: static rom training data generation example to allow the code to access PyMAPDL CICD secrets.
Check the original PR made by @${originalPR.user.login} for more details.
Closes #4009
docs: static rom training data generation example
Description
Add an example showing how PyMAPDL and PyDPF can be use to export training data to be used to create a Static Reduced Order model in Ansys Twin Builder.
Issue linked
None.
Checklist
draftif it is not ready to be reviewed yet.feat: adding new MAPDL command)Summary by Sourcery
Add a new documentation example demonstrating how to generate static reduced-order model (ROM) training data with PyMAPDL, DPF, and PyTwin for use in Ansys Twin Builder
Documentation:
Summary by Sourcery
Add a new documentation example demonstrating how to export static ROM training data using PyMAPDL, DPF, and PyTwin for Ansys Twin Builder and update relevant docs configuration and indexes.
Documentation: