-
Notifications
You must be signed in to change notification settings - Fork 142
chore: (migrated PR #4009) docs: static rom training data generation example #4011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
|
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.py
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
doc/source/examples/extended_examples/static_rom/static_rom_data_generation.rst
Outdated
Show resolved
Hide resolved
PipKat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor edits based mostly on writing to the Google developer documentation style guide.
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: