### Download Utilities Setup Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/utils/download_utilities.html Sets up the user data path for downloading examples. It prioritizes the PYDYNA_USER_DATA environment variable, falling back to appdirs.user_data_dir or a temporary directory if appdirs is not installed. ```python # Copyright (C) 2023 - 2026 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # # Permission is hereby granted, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. """Module provides example download utilities backed by ``ansys-tools-common``.""" import os from ansys.tools.common.example_download import download_manager # noqa: F401 try: import appdirs [docs] USER_DATA_PATH = os.getenv("PYDYNA_USER_DATA", appdirs.user_data_dir(appname="pydyna", appauthor=False)) except ModuleNotFoundError: # If appdirs is not installed, then try with tempfile. # NOTE: This only occurs for ADO ARM Test runs import tempfile USER_NAME = os.getenv("USERNAME", os.getenv("USER", "pydyna")) USER_DATA_PATH = os.getenv("PYDYNA_USER_DATA", os.path.join(tempfile.gettempdir(), USER_NAME)) [docs] EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") __all__ = ["download_manager", "EXAMPLES_PATH", "USER_DATA_PATH"] ``` -------------------------------- ### CLI Usage Examples Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/__main__/index.html Demonstrates how to use the PyDyna CLI for agent-related tasks, including environment setup, copying files, and printing instructions. ```APIDOC ## CLI Usage ```bash python -m ansys.dyna.core agent --env cursor python -m ansys.dyna.core agent --env vscode --copy python -m ansys.dyna.core agent --env vscode --pointer python -m ansys.dyna.core agent --print ``` ``` -------------------------------- ### Get First Keyword Example Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/lib/keyword_collection.html Demonstrates retrieving the first keyword from a collection, such as 'deck.sections'. ```python first_section = deck.sections.first() ``` -------------------------------- ### Dyna Solver Execution Example Source: https://dyna.docs.pyansys.com/version/stable/examples/John_Reid_Pendulum/plot_john_reid_pendulum.html This example shows how to initiate the LS-DYNA solver with specific memory allocation. It also includes license checkout information. ```shell > i=pendulum.k memory=20m Messages file /ansys_inc/v252/licensingclient/language/en-us/ansysli_msgs.xml does not exist. [license/info] Successfully checked out 1 of "dyna_solver_core". [license/info] --> Checkout ID: 35215acbec47-root-13-000003 (days left: 246) [license/info] --> Customer ID: 0 [license/info] Successfully started "LSDYNA (Core-based License)". ``` -------------------------------- ### Install PyDYNA in User Mode Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/installation.rst.txt Install the PyDYNA client package for general use. ```bash python -m pip install ansys-dyna-core ``` -------------------------------- ### PyDyna CLI Usage Examples Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Examples demonstrating how to use the PyDyna CLI for agent interactions, including environment selection, copying, and pointer usage. ```bash python -m ansys.dyna.core agent --env cursor ``` ```bash python -m ansys.dyna.core agent --env vscode --copy ``` ```bash python -m ansys.dyna.core agent --env vscode --pointer ``` ```bash python -m ansys.dyna.core agent --print ``` -------------------------------- ### Get Agent Instructions File Path Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Constructs and returns the file path to the agent instructions markdown file within the installed package. ```python def get_instructions_path() -> Path: """Get path to agent instructions file.""" return get_package_dir() / "AGENT.md" ``` -------------------------------- ### Install PyDYNA in User Mode Source: https://dyna.docs.pyansys.com/version/stable/getting-started/installation.html Install the PyDYNA core package for general use. This is the standard installation method for most users. ```bash python -m pip install ansys-dyna-core ``` -------------------------------- ### Install PyDyna Agent Instructions Source: https://dyna.docs.pyansys.com/version/stable/getting-started/agents.html Run this command in your project directory to install agent instructions for AI coding assistants. Ensure PyDyna is installed and you have an active AI assistant. ```bash python -m ansys.dyna.core agent --copy ``` -------------------------------- ### Install PyDYNA in Offline Mode (Linux) Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/installation.rst.txt Install PyDYNA using a wheelhouse archive on a machine without internet access. This example is for Linux with Python 3.9. ```bash unzip ansys-dyna-core-v0.3.dev0-wheelhouse-Linux-3.9.zip -d wheelhouse pip install ansys-dyna-core -f wheelhouse --no-index --upgrade --ignore-installed ``` -------------------------------- ### CLI Usage Examples Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Examples of how to use the PyDyna CLI for agent-related tasks. ```APIDOC ## CLI Usage This module provides a command-line interface for PyDyna agent functionalities. ### Usage Examples: - `python -m ansys.dyna.core agent --env cursor` - `python -m ansys.dyna.core agent --env vscode --copy` - `python -m ansys.dyna.core agent --env vscode --pointer` - `python -m ansys.dyna.core agent --print` ``` -------------------------------- ### Install PyDyna Agent Instructions (Generic) Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt Run this command in your project directory to install generic agent instructions that work with any AI tool capable of reading local documentation. ```bash python -m ansys.dyna.core agent --copy ``` -------------------------------- ### Initialize and Filter Keywords Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/keyword_collection/KeywordCollection.rst.txt Initialize a KeywordCollection with existing keywords and filter them by subtype. This example demonstrates how to get all 'SHELL' keywords and iterate through them. ```python collection = KeywordCollection(deck.keywords) shells = collection.by_subtype("SHELL") for kwd in shells: print(kwd.secid) first_shell = shells.first() all_shells = shells.to_list() ``` -------------------------------- ### PyDyna Agent Manifest JSON Example Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt This JSON structure represents the `.agent/manifest.json` file, which tracks installed instruction sets from all packages in a workspace. It includes package namespace, installation mode, entry file locations, and installation timestamp. ```json { "version": "1.0", "packages": [ { "namespace": "ansys.dyna.core", "ecosystem": "pypi", "package_name": "ansys-dyna-core", "mode": "copy", "entry_file": "ansys.dyna.core.md", "extended_docs": ["ansys.dyna.core/deck.md", "ansys.dyna.core/keywords.md"], "installed_at": "2026-02-12T10:30:00Z" } ] } ``` -------------------------------- ### Example Usage of KeywordCardVisitor Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/lib/visitors/keyword_card_visitor.html Demonstrates how to create a subclass of KeywordCardVisitor to count plain cards within a keyword. This example shows the basic structure for implementing custom traversal logic. ```python class CardCounter(KeywordCardVisitor): def __init__(self): self.count = 0 def visit_card(self, card): self.count += 1 counter = CardCounter() counter.visit_keyword(my_keyword) print(f"Plain cards: {counter.count}") ``` -------------------------------- ### Install Agent Instructions for VS Code (GitHub Copilot) Source: https://dyna.docs.pyansys.com/version/stable/getting-started/agents.html Use this command to install agent instructions specifically for GitHub Copilot within VS Code. This ensures optimal integration with the AI assistant. ```bash python -m ansys.dyna.core agent --env vscode --copy ``` -------------------------------- ### Example: Counting Cards with KeywordCardVisitor Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/visitors/keyword_card_visitor/KeywordCardVisitor.rst.txt This example demonstrates how to subclass KeywordCardVisitor to count the number of plain cards within a keyword. It overrides the visit_card method to increment a counter for each card encountered. ```python class CardCounter(KeywordCardVisitor): def __init__(self): self.count = 0 def visit_card(self, card): self.count += 1 >>> counter = CardCounter() >>> counter.visit_keyword(my_keyword) >>> print(f"Plain cards: {counter.count}") ``` -------------------------------- ### Install PyDyna Agent Instructions for VS Code (GitHub Copilot) Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt Install agent instructions specifically for VS Code and GitHub Copilot. This command ensures compatibility with Copilot's requirements. ```bash python -m ansys.dyna.core agent --env vscode --copy ``` -------------------------------- ### Get Instructions Path Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Obtains the file path for the agent instructions within the installed PyDyna package. Use this to directly access the instructions file. ```python get_instructions_path() ``` -------------------------------- ### Install Agent Instructions for Cursor Source: https://dyna.docs.pyansys.com/version/stable/getting-started/agents.html Install agent instructions tailored for the Cursor AI coding assistant. This command optimizes the integration for Cursor's features. ```bash python -m ansys.dyna.core agent --env cursor --copy ``` -------------------------------- ### Clone and Install PyDYNA in Development Mode Source: https://dyna.docs.pyansys.com/version/stable/_sources/contributing.rst.txt Clone the PyDYNA repository and install it in editable mode for development. Ensure pip is up-to-date before installation. ```bash git clone https://github.com/ansys/pydyna cd pydyna python -m pip install --upgrade pip pip install -e . ``` -------------------------------- ### Get Package Directory Path Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Retrieves the installation directory of the PyDyna core package, which contains agent instructions. ```python def get_package_dir() -> Path: """Get the package directory containing agent instructions.""" return Path(__file__).parent ``` -------------------------------- ### Materialize Collection to List Example Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/lib/keyword_collection.html Shows how to convert the entire 'deck.sections' collection into a list. ```python all_sections = deck.sections.to_list() ``` -------------------------------- ### Get Runner for Local Solver Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/run/local_solver.html Instantiates the appropriate runner (Docker, Windows, or Linux) based on the containerization option and operating system. Raises an exception if Docker is requested but not installed. ```python runner = get_runner(container='docker') # or runner = get_runner() ``` -------------------------------- ### Clone and Install PyDYNA in Developer Mode Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/installation.rst.txt Clone the PyDYNA repository and install it in editable mode to allow for source code modifications. ```bash git clone https://github.com/ansys/pydyna cd pyDyna pip install -e . ``` -------------------------------- ### Install PyDyna Agent Instructions for Claude Code Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt Install agent instructions for Claude Code. This command prepares the instructions to be used with Claude's AI capabilities. ```bash python -m ansys.dyna.core agent --env claude --copy ``` -------------------------------- ### Get All Parts Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Retrieves all part keywords from the deck and converts them into a list. ```python parts = deck.parts.to_list() ``` -------------------------------- ### get_instructions_path Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Get the file path for the agent instructions. ```APIDOC ## get_instructions_path ### Description Get path to agent instructions file. ### Returns - `pathlib.Path`: The path to the agent instructions file. ``` -------------------------------- ### Install PyDyna Agent Instructions for Cursor Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt Install agent instructions tailored for the Cursor AI coding assistant. This command configures the instructions for Cursor's specific format. ```bash python -m ansys.dyna.core agent --env cursor --copy ``` -------------------------------- ### Clone and Install PyDYNA in Developer Mode Source: https://dyna.docs.pyansys.com/version/stable/getting-started/installation.html Clone the PyDYNA repository and install it in developer mode. This allows for source code modifications and contributions. ```bash git clone https://github.com/ansys/pydyna cd pyDyna pip install -e . ``` -------------------------------- ### Install Agent Instructions for Claude Code Source: https://dyna.docs.pyansys.com/version/stable/getting-started/agents.html Install agent instructions specifically for Claude Code. This command configures the instructions for seamless use with Claude's AI capabilities. ```bash python -m ansys.dyna.core agent --env claude --copy ``` -------------------------------- ### Verify PyDyna Agent Installation Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt This Python command verifies the installation of PyDyna agent instructions by printing the AGENT_INSTRUCTIONS attribute. The subsequent bash command lists the contents of the `.agent/` directory to confirm file creation. ```python import ansys.dyna.core; print(ansys.dyna.core.AGENT_INSTRUCTIONS) ``` ```bash ls -la .agent/ ``` -------------------------------- ### main Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Entry point for the PyDyna CLI. ```APIDOC ## main ### Description Entry point for the PyDyna CLI. ``` -------------------------------- ### Get All Registered Validators Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/validation_mixin/ValidationMixin.rst.txt Retrieve a list of all currently registered validators. This can be useful for inspecting the validation setup. ```python validators = deck.get_validators() ``` -------------------------------- ### Prepare and Run LS-DYNA Solver Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/run/local_solver.html Prepares the input file and working directory, then runs the LS-DYNA solver. It handles containerized execution and environment variable setup. ```python wdir, input_file = __prepare(input, **kwargs) if "container" not in kwargs: container = os.environ.get("PYDYNA_RUN_CONTAINER", None) if container != None: kwargs["container"] = container if "container_env" not in kwargs: kwargs["container_env"] = dict( (k, os.environ[k]) for k in ("LSTC_LICENSE", "ANSYSLI_SERVERS", "ANSYSLMD_LICENSE_FILE") ) if "stream" not in kwargs: stream = os.environ.get("PYDYNA_RUN_STREAM", None) if stream != None: kwargs["stream"] = bool(int(stream)) runner = get_runner(**kwargs) runner.set_input(input_file, wdir) result = runner.run() if container != None and kwargs.get("stream", True) is False: return result return wdir ``` -------------------------------- ### Get Package Directory Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Retrieves the installation directory of the PyDyna package, which contains agent instructions. This function is essential for accessing package-specific resources. ```python get_package_dir() ``` -------------------------------- ### Initialize and Use KeywordCollection Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/keyword_collection/KeywordCollection.html Demonstrates initializing a KeywordCollection and performing basic operations like filtering by subtype and retrieving keywords. ```python >>> collection = KeywordCollection(deck.keywords) >>> shells = collection.by_subtype("SHELL") >>> for kwd in shells: ... print(kwd.secid) >>> first_shell = shells.first() >>> all_shells = shells.to_list() ``` -------------------------------- ### Get Plate Displacement from DPF Source: https://dyna.docs.pyansys.com/version/stable/_sources/examples/Optimization/Plate_Thickness_Optimization.rst.txt Initializes DPF DataSources to retrieve plate displacement results. This function is a starting point for post-processing LS-DYNA results. ```Python def get_plate_displacement(directory): ds = dpf.DataSources() ``` -------------------------------- ### Get Instructions Content Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Reads and returns the content of the agent instructions file from the installed PyDyna package. This function is useful for programmatically accessing instruction details. ```python get_instructions_content() ``` -------------------------------- ### Get PyDyna Agent Instructions Path Source: https://dyna.docs.pyansys.com/version/stable/_sources/getting-started/agents.rst.txt Use this Python code to retrieve the installation path of the PyDyna AI agent instructions. This is useful for tools that support Python introspection. ```python import ansys.dyna.core print(ansys.dyna.core.AGENT_INSTRUCTIONS) ``` -------------------------------- ### Get PyDyna AI Instruction Path Source: https://dyna.docs.pyansys.com/version/stable/getting-started/agents.html This Python code snippet retrieves and prints the file path to the installed AI instructions for PyDyna. This is useful for tools that support Python introspection. ```python import ansys.dyna.core print(ansys.dyna.core.AGENT_INSTRUCTIONS) ``` -------------------------------- ### Example Usage of KeywordCardVisitor Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/visitors/keyword_card_visitor/KeywordCardVisitor.html Demonstrates how to create a custom visitor by subclassing KeywordCardVisitor and overriding the visit_card method to count the number of plain cards encountered during traversal. ```python >>> class CardCounter(KeywordCardVisitor): ... def __init__(self): ... self.count = 0 ... def visit_card(self, card): ... self.count += 1 >>> counter = CardCounter() >>> counter.visit_keyword(my_keyword) >>> print(f"Plain cards: {counter.count}") ``` -------------------------------- ### Example of Pre-commit Hook Execution Source: https://dyna.docs.pyansys.com/version/stable/_sources/contributing.rst.txt Illustrates the output of pre-commit hooks after a commit, showing which checks passed. ```bash $ pre-commit install $ git commit -am "added my cool feature" black....................................................................Passed blacken-docs.............................................................Passed codespell................................................................Passed flake8...................................................................Passed isort....................................................................Passed check for merge conflicts................................................Passed debug statements (python)................................................Passed Validate GitHub Workflows................................................Passed ``` -------------------------------- ### Get Total Keyword Count Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/deck/Deck.html Get the total number of keywords in the deck, including strings and encrypted keywords. ```python >>> num_keywords = len(deck) ``` -------------------------------- ### Main entry point for PyDyna CLI Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Sets up the argument parser for the PyDyna CLI, defining the 'agent' subcommand and its options for managing AI assistant instructions. ```python def main() -> int: """Main entry point for CLI.""" parser = argparse.ArgumentParser( prog="python -m ansys.dyna.core", description="PyDyna CLI utilities", ) subparsers = parser.add_subparsers(dest="command") # agent subcommand agent_parser = subparsers.add_parser( "agent", help="Install agent instructions for AI assistants", ) ``` -------------------------------- ### IncludeWdInitialBlank Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/include.rst.txt This keyword is used to include WD initial blank information. ```APIDOC ## IncludeWdInitialBlank ### Description This keyword is used to include WD initial blank information. ### Module `ansys.dyna.core.keywords.keyword_classes.auto.include_wd_initial_blank` ``` -------------------------------- ### Create Deck and Keywords Source: https://dyna.docs.pyansys.com/version/stable/_downloads/65ead00e2959f095eb490243a8a0e379/Plate_Thickness_Optimization.ipynb Initializes a Deck object to hold all keywords and prepares for appending individual keywords. ```python deck = Deck() keywords = kwd.Keywords(deck) ``` -------------------------------- ### InterfaceBlanksizeInitialAdaptive Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/interface.rst.txt Documentation for the InterfaceBlanksizeInitialAdaptive module, concerning initial adaptive blank size interfaces. ```APIDOC ## InterfaceBlanksizeInitialAdaptive ### Description This section details the `InterfaceBlanksizeInitialAdaptive` module, used for interfaces related to initial adaptive blank size settings. ### Module `ansys.dyna.core.keywords.keyword_classes.auto.interface_blanksize_initial_adaptive` ### Members This module contains various members related to initial adaptive blank size interfaces. Refer to the module's documentation for specific details. ``` -------------------------------- ### Get Number of Keywords Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Get the total number of keywords in the deck, including strings and encrypted keywords. This provides a quick count of all entries in the deck. ```python num_keywords = len(deck) ``` -------------------------------- ### run Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/run/local_solver.html Runs the LS-DYNA solver locally. This method handles the preparation of the input file, setting up the environment (including containerization if specified), and executing the solver. It returns the working directory of the run, or the solver's stdout if streaming is disabled and a container is used. ```APIDOC ## run ### Description Runs the LS-DYNA solver locally. This method handles the preparation of the input file, setting up the environment (including containerization if specified), and executing the solver. It returns the working directory of the run, or the solver's stdout if streaming is disabled and a container is used. ### Parameters - **input** (str or Path) - Path to the input file or a string containing the input file content. - **working_directory** (str, optional) - Working directory for the solver. Defaults to the directory of the input file or a temporary directory. - **container** (str, optional) - Docker container image to use for running LS-DYNA. - **container_env** (dict(), optional) - Environment variables to pass into the Docker container. - **stream** (bool, optional) - If True, streams the solver's stdout to Python's stdout during the solve. Defaults to True. - **activate_case** (bool, optional) - If provided, appends the CASE command line for *CASE keywords support. - **case_ids** (list[int] or None, optional) - If provided, appends CASE or CASE=... to the LS-DYNA command line for *CASE support. ### Returns - **result** (str) - The working directory where the solver is launched. If `stream` is `False` and `container` is set, returns the stdout of the run. ### Example ```python from ansys.dyna.core.run import local_solver # Example usage with a file input working_dir = local_solver.run("path/to/your/input.k") # Example usage with container and streaming disabled working_dir = local_solver.run("path/to/your/input.k", container="my-dyna-container", stream=False) ``` ``` -------------------------------- ### Run Pre-commit Hooks for Code Styling Source: https://dyna.docs.pyansys.com/version/stable/_sources/contributing.rst.txt Install pre-commit and run all configured style checks on your files. This ensures code adheres to PEP8 standards. ```bash pip install pre-commit pre-commit run --all-files ``` -------------------------------- ### Main Entry Point Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/__main__/index.html The main function to execute the CLI application. ```APIDOC main() -> int ``` -------------------------------- ### LS-DYNA Execution Details Source: https://dyna.docs.pyansys.com/version/stable/_sources/examples/Taylor_Bar/plot_taylor_bar.rst.txt This section provides details about the LS-DYNA execution, including the command line options used, input file information, and memory allocation. ```text Executing with ANSYS license Command line options: i=input.k memory=20m Input file: input.k The native file format : 64-bit small endian Memory size from command line: 20000000 ``` -------------------------------- ### Loading Deck with Legacy InitialStressShell Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/keywords/keyword_classes/manual/initial_stress_shell_version_0_9_1/InitialStressShellLegacy.rst.txt Demonstrates how to load a deck while overriding the default INITIAL_STRESS_SHELL keyword with the legacy `InitialStressShellLegacy` class. This is useful when working with older deck files or specific version requirements. ```python from ansys.dyna.core.lib.deck import Deck from ansys.dyna.core.lib.import_handler import ImportContext from ansys.dyna.core.keywords.keyword_classes.manual.initial_stress_shell_version_0_9_1 import \ InitialStressShellLegacy deck = Deck() context = ImportContext( deck=deck, keyword_overrides={"*INITIAL_STRESS_SHELL": InitialStressShellLegacy}, ) deck.loads(data, context=context) ``` -------------------------------- ### Install Pre-commit Hook for Automatic Style Checks Source: https://dyna.docs.pyansys.com/version/stable/_sources/contributing.rst.txt Install pre-commit as a Git hook to automatically run style checks before each commit. This prevents pushing code that fails style validation. ```bash pre-commit install ``` -------------------------------- ### InterfaceBlanksizeInitialTrim Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/interface.rst.txt Documentation for the InterfaceBlanksizeInitialTrim module, focusing on initial trim blank size interfaces. ```APIDOC ## InterfaceBlanksizeInitialTrim ### Description This section details the `InterfaceBlanksizeInitialTrim` module, which handles interfaces for initial trim blank size configurations. ### Module `ansys.dyna.core.keywords.keyword_classes.auto.interface_blanksize_initial_trim` ### Members This module contains various members related to initial trim blank size interfaces. Refer to the module's documentation for specific details. ``` -------------------------------- ### Execute Deck Creation and Plotting Source: https://dyna.docs.pyansys.com/version/stable/examples/John_Reid_Pipe/plot_john_pipe.html Copies the downloaded mesh file to the run directory, writes the LS-DYNA deck using the `write_deck` function, and then plots the generated deck. ```python shutil.copy(mesh_file, os.path.join(rundir.name, mesh_file_name)) deck = write_deck(os.path.join(rundir.name, dynafile)) deck.plot(cwd=rundir.name, show_edges=True) ``` -------------------------------- ### Get Linked Keywords - KeywordBase Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/keyword_base/KeywordBase.html Retrieve keywords referenced by the current keyword. You can filter by link type and control the traversal depth. Use `level=-1` to get the full dependency tree. ```python >>> mat = deck.keywords[0] # A material keyword with curve references >>> curves = mat.get_links(LinkType.DEFINE_CURVE) >>> all_links = mat.get_links() # Get all referenced keywords >>> # Get full dependency tree >>> all_deps = mat.get_links(level=-1) ``` -------------------------------- ### Copy All Instructions Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Copies all agent instruction files to the specified workspace, ensuring that links within the instructions are functional in the new location. It returns the main file path and a list of extended documentation paths. ```python copy_all_instructions(workspace, mode='copy') ``` -------------------------------- ### Run Dyna Solver and Post-processing Source: https://dyna.docs.pyansys.com/version/stable/_downloads/8a52a6625e0c9d74e3f2db2bdd6b0a2f/plot_john_reid_pendulum.ipynb Execute the Dyna solver with the specified dynafile and working directory, followed by running the post-processing step. ```python filepath = run_dyna(dynafile, working_directory=rundir.name) run_post(rundir.name) ``` -------------------------------- ### get_instructions_content Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Read and return the content of the agent instructions file. ```APIDOC ## get_instructions_content ### Description Read the agent instructions from installed package. ### Returns - `str`: The content of the agent instructions file. ``` -------------------------------- ### TableCardGroup.table Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/table_card_group/TableCardGroup.html Gets the table as a pandas DataFrame. ```APIDOC ## TableCardGroup.table ### Description Get the table as a pandas DataFrame. ### Property table ### Type pandas.DataFrame ``` -------------------------------- ### solid_array Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/deck_plotter/index.html Get the solid array from the DataFrame. ```APIDOC ## solid_array(solids) ### Description Get the solid array from the DataFrame. ### Method ```python solid_array(solids) ``` ### Parameters #### Path Parameters - **solids** (object) - Description for solids ### Returns object: The solid array. ``` -------------------------------- ### Loading Deck with Legacy MAT_295 Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/keywords/keyword_classes/manual/mat_295_version_0_9_1/Mat295Legacy.rst.txt Demonstrates how to load a deck with specific legacy keyword implementations, including `Mat295Legacy` and `MatAnisotropicHyperelasticLegacy`, by using keyword overrides during `ImportContext` initialization. This is useful when compatibility with older versions or specific legacy features is required. ```python from ansys.dyna.core.lib.deck import Deck from ansys.dyna.core.lib.import_handler import ImportContext from ansys.dyna.core.keywords.keyword_classes.manual.mat_295_version_0_9_1 import ( Mat295Legacy, MatAnisotropicHyperelasticLegacy, ) deck = Deck() context = ImportContext( deck=deck, keyword_overrides={ "*MAT_ANISOTROPIC_HYPERELASTIC": MatAnisotropicHyperelasticLegacy, "*MAT_295": Mat295Legacy, }, ) deck.loads(data, context=context) ``` -------------------------------- ### get_kwds_by_type() Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Get all keywords for a given type. ```APIDOC ## get_kwds_by_type(str_type: str) -> Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase] ### Description Get all keywords for a given type. ### Method `get_kwds_by_type(str_type: str)` ### Parameters #### Required Parameters - **str_type** (str) - Keyword type. ### Returns - **Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase]**: .. ### Examples Get all ``*SECTION_*`` keywords in the deck. >>> deck.get_kwds_by_type("SECTION") ``` -------------------------------- ### Generate README from Manifest Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Generates a README.md file for the agent directory based on the provided manifest. It lists installed packages with their details and includes usage and dependency scanning instructions. ```python from pathlib import Path def generate_readme(agent_dir: Path, manifest: dict) -> None: """Generate README.md from manifest.""" packages = manifest.get("packages", []) lines = [ "# Agent Instructions", "", "This directory contains agent instructions from installed packages.", "Agents can read these files for context about how to use the packages.", "", "## Installed Packages", "", ] if packages: lines.append("| Namespace | Ecosystem | Package | Entry File |") lines.append("|-----------|-----------|---------|------------|") for pkg in packages: namespace = pkg.get("namespace", "?") ecosystem = pkg.get("ecosystem", "?") package_name = pkg.get("package_name", "?") entry_file = pkg.get("entry_file", "?") lines.append(f"| `{namespace}` | {ecosystem} | {package_name} | [{entry_file}]({entry_file}) |") lines.append("") else: lines.append("*No packages installed yet.*") lines.append("") lines.extend( [ "## Usage", "", "Each package provides its own installation command. For Python packages with", "agent instructions, you can typically run:", "", "```bash", "python -m agent --copy", "```", "", "## Scanning Dependencies", "", "To install agent instructions from all packages in your requirements:", "", "```bash", "# Future: python -m agent_instructions scan requirements.txt", "# For now, run each package's agent command individually", "```", "", "---", "*Auto-generated manifest. Regenerate by running package agent commands.", "", ] ) readme_file = agent_dir / "README.md" readme_file.write_text("\n".join(lines), encoding="utf-8") ``` -------------------------------- ### first Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/keyword_collection/KeywordCollection.rst.txt Get the first keyword in the collection. ```APIDOC ## Method: first ### Description Get the first keyword in the collection. ### Returns Optional[KeywordBase] - The first keyword, or None if the collection is empty. ### Examples ```python first_section = deck.sections.first() ``` ``` -------------------------------- ### DualcesePartSurface Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/dualcese.rst.txt Documentation for the DualcesePartSurface module. ```APIDOC ## DualcesePartSurface .. automodule:: ansys.dyna.core.keywords.keyword_classes.auto.dualcese_part_surface :members: ``` -------------------------------- ### loads() Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Load all keywords from the keyword file as a string. ```APIDOC ## loads(value: str, context: Optional[ansys.dyna.core.lib.import_handler.ImportContext] = None) ### Description Load all keywords from the keyword file as a string. When adding all keywords from the file, this method overwrites the title and user comment, if any. ### Method `loads(value: str, context: Optional[ansys.dyna.core.lib.import_handler.ImportContext] = None)` ### Parameters #### Required Parameters - **value** (str) - .. #### Optional Parameters - **context** (Optional[ansys.dyna.core.lib.import_handler.ImportContext]) - the context ### Returns - **ansys.dyna.keywords.lib.deck_loader.DeckLoaderResult**: .. ``` -------------------------------- ### shell_facet_array Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/lib/deck_plotter/index.html Get the shell facet array from the DataFrame. ```APIDOC ## shell_facet_array() ### Description Get the shell facet array from the DataFrame. ### Method ```python shell_facet_array() ``` ### Returns numpy.array: The shell facet array. ``` -------------------------------- ### get_current_uri() Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/parameters/ParameterSet.rst.txt Get the current URI path as a string. ```APIDOC ## get_current_uri() ### Description Get the current URI path as a string. ### Returns - :class:`python:str`: The current URI path joined with '/'. ``` -------------------------------- ### get_kwds_by_full_type() Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Get all keywords for a given full type. ```APIDOC ## get_kwds_by_full_type(str_type: str, str_subtype: str) -> Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase] ### Description Get all keywords for a given full type. ### Method `get_kwds_by_full_type(str_type: str, str_subtype: str)` ### Parameters #### Required Parameters - **str_type** (str) - Keyword type. - **str_subtype** (str) - Keyword subtype or prefix of subtype. Matches keywords where the subkeyword starts with this value. ### Returns - **Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase]**: .. ### Examples Get all ``*SECTION_SHELL`` keyword instances in the deck. >>> deck.get_kwds_by_full_type("SECTION", "SHELL") Get all ``*SET_NODE*`` keyword instances (matches NODE, NODE_LIST, NODE_LIST_TITLE, etc). >>> deck.get_kwds_by_full_type("SET", "NODE") ``` -------------------------------- ### copy_all_instructions Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Copy all agent instruction files to the specified workspace, ensuring links are working. ```APIDOC ## copy_all_instructions ### Description Copy all agent instruction files to workspace with working links. ### Parameters - `workspace` (pathlib.Path): The target workspace directory. - `mode` (str, optional): The mode of copying. Defaults to 'copy'. ### Returns - `tuple[pathlib.Path, list[str]]`: A tuple containing the main file path and a list of relative paths to extended documentation files. ``` -------------------------------- ### Title Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/keywords/keyword_classes/manual/mat_295_version_0_9_1/Mat295Legacy.rst.txt Get or set the Additional title line. ```APIDOC ## title ### Description Get or set the Additional title line ### Type Optional[str] ``` -------------------------------- ### Copy Agent Instructions Source: https://dyna.docs.pyansys.com/version/stable/_modules/ansys/dyna/core/__main__.html Copies all agent instruction files to a specified workspace, rewriting links and updating the manifest. Use this to create a self-contained copy of agent documentation. ```python copy_all_instructions(workspace: Path, mode: str = "copy") -> tuple[Path, list[str]]: """Copy all agent instruction files to workspace with working links. Returns ------- tuple[Path, list[str]] Main file path and list of extended doc relative paths. """ agent_dir = workspace / ".agent" agent_dir.mkdir(parents=True, exist_ok=True) # Main file with rewritten links main_content = get_instructions_content() main_content = rewrite_links_for_copy(main_content, PACKAGE_NAMESPACE) main_file = agent_dir / f"{PACKAGE_NAMESPACE}.md" main_file.write_text(main_content, encoding="utf-8") # Extended docs extended_dir = agent_dir / PACKAGE_NAMESPACE extended_dir.mkdir(parents=True, exist_ok=True) source_dir = get_extended_docs_dir() extended_docs = [] if source_dir.exists(): for src_file in source_dir.glob("*.md"): dst_file = extended_dir / src_file.name shutil.copy2(src_file, dst_file) extended_docs.append(f"{PACKAGE_NAMESPACE}/{src_file.name}") # Update manifest manifest = load_manifest(agent_dir) manifest = update_manifest_entry( manifest=manifest, namespace=PACKAGE_NAMESPACE, ecosystem=PACKAGE_ECOSYSTEM, package_name=PACKAGE_NAME, entry_file=f"{PACKAGE_NAMESPACE}.md", extended_docs=extended_docs, mode=mode, source_path=str(get_instructions_path()), ) save_manifest(agent_dir, manifest) generate_readme(agent_dir, manifest) return main_file, extended_docs ``` -------------------------------- ### get_extended_docs_dir Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Get the directory for extended agent documentation. ```APIDOC ## get_extended_docs_dir ### Description Get path to extended agent documentation directory. ### Returns - `pathlib.Path`: The path to the extended documentation directory. ``` -------------------------------- ### DualceseReactionRateIg Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/dualcese.rst.txt Documentation for the DualceseReactionRateIg module. ```APIDOC ## DualceseReactionRateIg .. automodule:: ansys.dyna.core.keywords.keyword_classes.auto.dualcese_reaction_rate_ig :members: ``` -------------------------------- ### ansys.dyna.core.__version__ Source: https://dyna.docs.pyansys.com/version/stable/api/ansys/dyna/core/index.html Access the installed version of the Ansys Dyna library. ```APIDOC ## Get Version ### Description Retrieves the current version of the Ansys Dyna library. ### Method Attribute Access ### Endpoint N/A (Python attribute) ### Parameters None ### Request Example ```python import ansys.dyna version = ansys.dyna.core.__version__ print(f"Ansys Dyna version: {version}") ``` ### Response #### Success Response - **version** (str) - The version string of the installed library. ``` -------------------------------- ### Load Manifest Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Loads the manifest.json file from the specified agent directory. If the file does not exist, it returns an empty dictionary, providing a default manifest. ```python load_manifest(agent_dir) ``` -------------------------------- ### get_pyvista Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck_plotter/index.rst.txt Imports the PyVista library, raising an exception if it is not installed. ```APIDOC ## get_pyvista ### Description Method to import pyvista, raising an exception if not installed. ### Returns * :obj:`pyvista` - The imported PyVista module if available. ``` -------------------------------- ### dumps() Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Get the keyword file representation of all keywords as a string. ```APIDOC ## dumps() ### Description Get the keyword file representation of all keywords as a string. ### Method `dumps()` ### Returns - **str**: Keyword file representation of all keywords as a string. ``` -------------------------------- ### InitialPwpDepth Source: https://dyna.docs.pyansys.com/version/stable/_sources/_autosummary/initial.rst.txt Represents the initial PWP depth keyword. ```APIDOC ## InitialPwpDepth ### Description Represents the initial PWP depth keyword. ### Module `ansys.dyna.core.keywords.keyword_classes.auto.initial_pwp_depth` ``` -------------------------------- ### TableCard.format Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/table_card/TableCard.rst.txt Gets or sets the format type of the table card. ```APIDOC ## TableCard.format ### Description Format type of the table card. ### Property Type ansys.dyna.core.lib.format_type.format_type ``` -------------------------------- ### Loading Deck with Legacy InitialStrainShell Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/keywords/keyword_classes/manual/initial_strain_shell_version_0_9_1/InitialStrainShellLegacy.rst.txt Demonstrates how to load a deck with the legacy `InitialStrainShellLegacy` class by overriding the default keyword behavior. This is necessary to use the deprecated version. ```python from ansys.dyna.core.lib.deck import Deck from ansys.dyna.core.lib.import_handler import ImportContext from ansys.dyna.core.keywords.keyword_classes.manual.initial_strain_shell_version_0_9_1 import ( InitialStrainShellLegacy, ) deck = Deck() context = ImportContext( deck=deck, keyword_overrides={"*INITIAL_STRAIN_SHELL": InitialStrainShellLegacy}, ) deck.loads(data, context=context) ``` -------------------------------- ### Format Management Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/keyword_base/KeywordBase.rst.txt Allows getting or setting the format for the keyword. ```APIDOC ## Property: format ### Description Get or set the format for this keyword. ### Type ansys.dyna.core.lib.format_type.format_type ``` -------------------------------- ### Deck Initialization and Properties Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/lib/deck/Deck.rst.txt Initialize a Deck object and access its core properties like title, comment header, and format. ```APIDOC ## Deck Properties ### Description Provides access to the title, comment header, and format of the keyword database. ### Properties - **title** (Optional[str]) - Title of the keyword database. - **comment_header** (Optional[str]) - Comment header of the keyword database. - **format** (ansys.dyna.core.lib.format_type.format_type) - Format type of the deck. ``` -------------------------------- ### get_package_dir Source: https://dyna.docs.pyansys.com/version/stable/_sources/api/ansys/dyna/core/__main__/index.rst.txt Get the directory where the PyDyna agent instructions are located. ```APIDOC ## get_package_dir ### Description Get the package directory containing agent instructions. ### Returns - `pathlib.Path`: The path to the package directory. ```