### Install and Run Tox Source: https://github.com/ansys/pysimai/blob/main/README.rst Install tox with tox-uv and then run tox to verify the development installation. This ensures all project integrity checks pass. ```shell uv tool install tox --with tox-uv ``` ```shell tox ``` -------------------------------- ### TOML Configuration Example Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/config_file.rst Define basic client configuration parameters, including organization and credentials, in a TOML file. Ensure the TOML file is correctly formatted. ```toml [default] organization = "company" [default.credentials] username = "user@company.com" password = "hunter12" totp_enabled = true ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/ansys/pysimai/blob/main/README.rst Install pre-commit and set up the git hooks to automatically run style checks before committing. This helps maintain code quality. ```bash uv tool install pre-commit && pre-commit install ``` -------------------------------- ### Install PySimAI Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/installation.rst Use this command to install or upgrade PySimAI. Ensure you have Python 3.9 or later. ```bash pip install ansys-simai-core --upgrade ``` -------------------------------- ### Install PySimAI for Users Source: https://github.com/ansys/pysimai/blob/main/README.rst Install the latest version of pip before installing PySimAI. This command installs the core package. ```bash python -m pip install -U pip ``` ```bash python -m pip install ansys-simai-core ``` -------------------------------- ### Sequential Prediction and Postprocessing Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/best_practices.rst This example demonstrates a sequential approach where data is accessed immediately after each computation, causing the client to wait for completion. This is less efficient for multiple requests. ```python import ansys.simai.core as asc simai_client = asc.from_config() speeds = [5.9, 5.10, 5.11] for geom in simai_client.geometries.list(): for vx in speeds: # Run prediction pred = geom.run_prediction(Vx=vx) # Request global coefficients postprocessing # Because you are accessing the data, you must wait for the computation to finish coeffs = pred.post.global_coefficients().data # do something with the data print(coeffs) ``` -------------------------------- ### Efficient Prediction and Postprocessing Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/best_practices.rst This example shows a more efficient method by initiating all predictions and postprocessing requests first, then waiting for all to complete using `simai_client.wait()`. Data is processed only after all computations are finished. ```python import ansys.simai.core as asc simai_client = asc.from_config() speeds = [5.9, 5.10, 5.11] predictions = [] for geom in simai_client.geometries.list(): for vx in speeds: # Run prediction pred = geom.run_prediction(Vx=vx) # Request global coefficients postprocessing # Because you are not accessing the data, you are not blocked pred.post.global_coefficients() predictions.append(pred) simai_client.wait() # Wait for all objects requested locally to be complete for pred in predictions: # do something with the data print(pred.post.global_coefficients().data) ``` -------------------------------- ### TOML Configuration with Profiles Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/config_file.rst Configure multiple profiles within a single TOML file for different SimAIClient setups. Each profile can specify unique settings like organization and workspace. ```toml [default] organization = "company" workspace = "my-usual-workspace" [alternative] organization = "company" workspace = "some-other-workspace" project = "red herring" ``` -------------------------------- ### Handle Detail Level Input Errors Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/automorphing/configure_automorphing.rst These text examples show error messages that may occur if the 'detail_level' is too low or too high for the geometry and bounding box configuration. ```text InputValueError: The size of box 'box_id' is too small for the chosen detail level. The minimum detail level is 'min_detail_level'. ``` ```text InputValueError: The number of points to be deformed in the geometry ('nb_point') and this detail level ('current_detail_level') might lead to Out of Memory. The maximum detail level is 'max_detail_level'. ``` -------------------------------- ### Process Exported CSV Data from ZIP Archive Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Read CSV data from a ZIP archive exported from global coefficients. This example shows how to use Python's zipfile and csv modules, and also demonstrates integration with pandas. ```python import zipfile import csv from io import TextIOWrapper data = selection.post.global_coefficients().export("csv.zip").in_memory() with zipfile.ZipFile(data) as archive: csv_data = csv.reader(TextIOWrapper(archive.open("Global_Coeffs.csv"))) # or with pandas: import pandas as pd df_geom = pd.read_csv(archive.open("Geometries.csv")) ``` -------------------------------- ### Build and Publish Package with uv Source: https://github.com/ansys/pysimai/blob/main/README.rst Use uv commands to build the package for distribution or to publish it to a repository. ```bash uv build ``` ```bash uv publish ``` -------------------------------- ### Build Documentation with Sphinx Source: https://github.com/ansys/pysimai/blob/main/README.rst Build the project documentation using Sphinx and open the generated HTML file. This command is useful for previewing documentation changes locally. ```bash uv run make -C doc/ html && open doc/html/index.html ``` -------------------------------- ### Build Documentation with Tox Source: https://github.com/ansys/pysimai/blob/main/README.rst Use tox to build documentation and open the output. This is the recommended method for checking documentation integrity. ```bash tox -e doc && open .tox/doc_out/index.html ``` -------------------------------- ### Create Training Data and Upload Folder Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Create a TrainingData instance and upload simulation data from a specified folder. This prepares data for project association. ```python td = simai.training_data.create("my-first-data") td.upload_folder("/path/to/folder/where/files/are/stored") ``` -------------------------------- ### Initialize SimAI Client Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Instantiate the SimAIClient to interact with the PySimAI service. You will be prompted for credentials upon execution. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient() ``` -------------------------------- ### Create a Project Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Create a new project instance within SimAI. This project will be used to organize simulation data and configure AI models. ```python project = simai.projects.create("my-first-project") ``` -------------------------------- ### Create SimAIClient from Default Config Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/config_file.rst Instantiate the SimAIClient using the default configuration file path. The client automatically searches for the configuration in standard locations. ```python import ansys.simai.core as asc simai_client = asc.from_config() ``` -------------------------------- ### Create SimAIClient Instance Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst Instantiate the SimAIClient by providing the organization name. Missing parameters will prompt user input. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient(organization="my-company") ``` -------------------------------- ### Authenticate SimAIClient with Credentials Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst Configure the SimAIClient with username and password for authentication. If credentials are not provided, the user will be prompted. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient( organization="company", credentials={ # neither of these are required, but if they are missing you will be # prompted to input them "username": "user@company.com", "password": "hunter12", }, ) ``` -------------------------------- ### Create SimAIClient from Specific Config Path Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/config_file.rst Instantiate the SimAIClient by providing a specific path to the configuration file. This allows you to manage configurations outside of default locations. ```python simai_client = asc.from_config(path="/path/to/my/config") ``` -------------------------------- ### Load SimAIClient with a Specific Profile Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/config_file.rst Instantiate the SimAIClient using a named profile from the configuration file. This is useful when you have multiple distinct configurations defined. ```python simai_client = asc.from_config(profile="alternative") ``` -------------------------------- ### Build the AI Model Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Check if the project is trainable and then initiate the AI model build process using the configured ModelConfiguration. This requires the project to meet training requirements. ```python if project.is_trainable(): new_model = simai.models.build(mdl_conf) ``` -------------------------------- ### Configure the AI Model Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Create a ModelConfiguration instance, specifying project details, build preset, input/output definitions, global coefficients, and domain of analysis. ```python mdl_conf = ModelConfiguration( project=project, # project of the model configuration build_preset="debug", # duration of the build build_on_top=False, # build on top of previous model input=model_input, # model input output=model_output, # model output global_coefficients=global_coefficients, # Global Coefficients domain_of_analysis=doa # Domain of Analysis ) ``` -------------------------------- ### Run Lint and Test Tasks with Poe Source: https://github.com/ansys/pysimai/blob/main/README.rst Alternatively, use uv and poethepoet to run development tasks like linting and testing. This provides a convenient way to manage common development workflows. ```shell uv tool install poethepoet ``` ```shell uv run poe lint ``` ```shell uv run poe test ``` ```shell uv run poe doc ``` -------------------------------- ### Import Model Building Modules Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Import necessary classes for defining model configurations, including domain of analysis, inputs, and outputs. ```python from ansys.simai.core.data.model_configuration import ( DomainOfAnalysis, ModelConfiguration, ModelInput, ModelOutput, ) ``` -------------------------------- ### Download Binary Post-processing Results (VTU) Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Loop through a selection's post-processing results for volume VTU files and download each one individually. ```python for vtu in selection.post.volume_vtu(): vtu.data.download(f"/path/to/vtu_{vtu.id}") ``` -------------------------------- ### Creating and Running Predictions with Selections Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Demonstrates how to create a Selection by combining Geometries and Scalars, and then run predictions for all combinations within the selection. ```APIDOC ## Create and Run Predictions ### Description This snippet shows how to instantiate a `Selection` object with a list of geometries and scalars, and then trigger the execution of predictions for all generated points. ### Method ```python from ansys.simai.core.data.selections import Selection geometries = simai.geometries.list()[:4] scalars = [dict(Vx=vx) for vx in [12.2, 12.4, 12.6]] selection = Selection(geometries, scalars) # Run all predictions selection.run_predictions() all_predictions = selection.predictions ``` ### Parameters - `geometries` (list): A list of `Geometry` instances. - `scalars` (list): A list of dictionaries, where each dictionary represents scalar values for a point. ### Returns - `selection` (Selection): The created Selection object. - `all_predictions` (list): A list of all generated `Prediction` instances after running `run_predictions()`. ``` -------------------------------- ### Create and Use a Selection Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/data_exploration.rst Create a selection by combining geometries and scalars, then run predictions, compute global coefficients, and retrieve results. ```python import ansys.simai.core as asc from ansys.simai.core.data.selections import Selection simai_client = asc.from_config() geometries = simai_client.geometries.list()[:4] scalars = [dict(Vx=vx) for vx in [12.2, 12.4, 12.6]] selection = Selection(geometries, scalars) # run all predictions selection.run_predictions() # compute all global coefficients selection.post.global_coefficients() # get all results all_selection_coefficients = [ global_coefficients.data for global_coefficients in selection.post.global_coefficients() ] ``` -------------------------------- ### Associate Training Data with Project Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Link the previously created training data to the specified project. This step is crucial before configuring the AI model. ```python td.add_to_project(project) ``` -------------------------------- ### PostProcessingDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Manages the directory of available postprocessing objects. Use the `info` method to check availability. ```APIDOC ## PostProcessingDirectory ### Description Provides access to and information about available postprocessing objects. ### Methods - `info()`: Returns information about available postprocessing objects. ``` -------------------------------- ### LegacyOptimizationDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Represents a directory for managing legacy optimization objects. ```APIDOC ## Class: LegacyOptimizationDirectory() ### Description Provides methods for managing legacy optimization objects within a directory. ### Members (Members are not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### TrainingDataPartDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/training_data_parts.rst Represents a directory containing training data parts. Provides methods for managing and accessing these parts. ```APIDOC ## TrainingDataPartDirectory ### Description Represents a directory containing training data parts. Provides methods for managing and accessing these parts. ### Methods * **__init__(self, path: str)**: Initializes the directory with a given path. * **add_part(self, part: TrainingDataPart)**: Adds a TrainingDataPart to the directory. * **get_part(self, part_name: str)**: Retrieves a TrainingDataPart by its name. * **list_parts(self)**: Returns a list of all TrainingDataPart names in the directory. * **remove_part(self, part_name: str)**: Removes a TrainingDataPart from the directory. ``` -------------------------------- ### ProjectDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/projects.rst The ProjectDirectory class provides methods for managing and listing projects. ```APIDOC ## ProjectDirectory ### Description Provides methods for managing and listing projects. ### Class `ansys.simai.core.data.projects.ProjectDirectory` ### Members (Details of members are not provided in the source text, but typically include methods for listing, creating, or deleting projects.) ``` -------------------------------- ### SimAIClient Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/client.rst The SimAIClient class serves as the main entry point for interacting with the SimAI API. It encapsulates authentication, session management, and provides access to various SimAI functionalities. ```APIDOC class SimAIClient """Client for the SimAI service. This class provides methods for interacting with the SimAI API, including authentication, project management, and simulation execution. """ # Methods are documented here as they are defined in the source. ``` -------------------------------- ### OptimizationDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Represents a directory for managing optimization objects. ```APIDOC ## Class: OptimizationDirectory() ### Description Provides methods for managing optimization objects within a directory. ### Members (Members are inherited and not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### Clone PySimAI Repository Source: https://github.com/ansys/pysimai/blob/main/README.rst Clone the PySimAI repository to begin development. Ensure Python is added to your system's Path if you are on Windows. ```bash git clone https://github.com/ansys/pysimai ``` -------------------------------- ### TrainingDataDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/training_data.rst Provides methods for managing training data directories, including uploading data. ```APIDOC ## TrainingDataDirectory() ### Description Represents a directory for training data. ### Methods #### upload_folder() ##### Description Uploads data from a specified folder to be used as training data. This is the recommended method for standard workflows. ##### Parameters * **folder_path** (str) - Required - The path to the folder containing the training data. ##### Returns * A TrainingData object representing the uploaded data. ``` -------------------------------- ### Configure SimAIClient with Offline Token in TOML Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst Configure SimAIClient using a TOML file, specifying organization, offline token, and disabling interactive mode for non-interactive authentication. ```toml [default] organization = "my-company" offline_token = "your-offline-token-here" interactive = false ``` -------------------------------- ### Accessing and Exporting Postprocessing Results Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Illustrates how to access postprocessing results through the `selection.post` namespace and export them in various formats like XLSX and CSV. ```APIDOC ## Postprocessing Operations ### Description This section covers how to perform postprocessing operations on a selection, such as calculating global coefficients or surface evolution, and how to export these results. ### Methods #### Global Coefficients ```python # Get global coefficients coeffs = selection.post.global_coefficients() # Access the results results_data = coeffs.data ``` #### Surface Evolution and Export ```python # Calculate surface evolution and export to XLSX selection.post.surface_evolution(axis="x", delta=13.5).export("xlsx").download( "/path/to/file.xlsx" ) # Export global coefficients to a ZIP file containing CSVs data = selection.post.global_coefficients().export("csv.zip").in_memory() # Example of reading CSV data from the ZIP archive import zipfile import csv from io import TextIOWrapper with zipfile.ZipFile(data) as archive: csv_data = csv.reader(TextIOWrapper(archive.open("Global_Coeffs.csv"))) # Process csv_data # Example using pandas import pandas as pd df_geom = pd.read_csv(archive.open("Geometries.csv")) ``` #### Downloading Binary Postprocessing Results ```python # Download VTU files for volume postprocessing for vtu in selection.post.volume_vtu(): vtu.data.download(f"/path/to/vtu_{vtu.id}") ``` ### Parameters - `axis` (str): The axis for surface evolution calculation. - `delta` (float): The delta value for surface evolution calculation. - `format` (str): The export format (e.g., "xlsx", "csv.zip"). - `path` (str): The file path for downloading results. ### Returns - `coeffs` (SelectionPostProcessingsMethods): An object representing postprocessing results. - `data` (bytes): Binary data of the exported results. - `vtu` (DownloadableResult): An object representing a downloadable VTU file. ``` -------------------------------- ### ModelConfiguration Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/models.rst Defines the properties for building a SimAI model, including inputs, outputs, coefficients, and domain. ```APIDOC class ModelConfiguration() (Details of ModelConfiguration properties and methods) ``` -------------------------------- ### IsTrainableInfo Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/projects.rst Provides information about whether a project is trainable, excluding specific members. ```APIDOC ## IsTrainableInfo ### Description Provides information about whether a project is trainable. ### Class `ansys.simai.core.data.projects.IsTrainableInfo` ### Members (Members are available, but `is_trainable` and `reason` are excluded from documentation.) ``` -------------------------------- ### Export Surface Evolution Data from Selection Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Export surface evolution data for a selection to an XLSX file and download it. For CSV exports, a ZIP file is generated. ```python selection.post.surface_evolution(axis="x", delta=13.5).export("xlsx").download( "/path/to/file.xlsx" ) ``` -------------------------------- ### ContinuousLearningCapabilities Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/projects.rst Represents the continuous learning capabilities of a project. ```APIDOC ## ContinuousLearningCapabilities ### Description Represents the continuous learning capabilities of a project. ### Class `ansys.simai.core.data.projects.ContinuousLearningCapabilities` ### Members (Details of members are not provided in the source text.) ``` -------------------------------- ### TrainingCapabilities Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/projects.rst Represents the training capabilities of a project. ```APIDOC ## TrainingCapabilities ### Description Represents the training capabilities of a project. ### Class `ansys.simai.core.data.projects.TrainingCapabilities` ### Members (Details of members are not provided in the source text.) ``` -------------------------------- ### Build GeomAI Model Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/models.rst Use the `build_model` method from `GeomAIProject` to create a new GeomAI model. ```APIDOC ## Build GeomAI Model ### Description To build a GeomAI model, you should use the `build_model` method available on an instance of `GeomAIProject`. ### Method Signature `GeomAIProject.build_model(config: GeomAIModelConfiguration)` ### Parameters - **config** (`GeomAIModelConfiguration`): The configuration object specifying the parameters for the new GeomAI model. ``` -------------------------------- ### ModelDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/models.rst Represents a directory for managing SimAI models. It provides methods for building and interacting with models. ```APIDOC class ModelDirectory() Members: build(): Launches a build for a SimAI model using a ModelConfiguration. Exclude Members: get ``` -------------------------------- ### LegacyOptimization Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Represents a single legacy optimization model. ```APIDOC ## Class: LegacyOptimization() ### Description Represents a model for a legacy optimization process. ### Inherited Members (Members are inherited from base classes and not explicitly listed here, refer to the source for details.) ### Members (Members are not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### Run Pytest with uv Source: https://github.com/ansys/pysimai/blob/main/README.rst Use uv to run pytest for development. This command executes tests and provides verbose output. ```shell uv run pytest -xlv ``` -------------------------------- ### TrainingDataPart Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/training_data_parts.rst Represents a single file that is part of a larger TrainingData instance. Provides access to the file's content and metadata. ```APIDOC ## TrainingDataPart ### Description Represents a single file that is part of a larger TrainingData instance. Provides access to the file's content and metadata. ### Methods * **__init__(self, file_path: str, metadata: dict = None)**: Initializes the part with its file path and optional metadata. * **get_content(self)**: Returns the content of the training data part. * **get_metadata(self)**: Returns the metadata associated with the training data part. * **set_metadata(self, key: str, value: any)**: Sets a metadata key-value pair. * **save(self)**: Saves any changes made to the training data part. ``` -------------------------------- ### GeomAITrainingDataPart Model Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/training_data_parts.rst This section details the GeomAITrainingDataPart class, representing a single file within a training data instance. Direct interaction is not recommended. ```APIDOC ## GeomAITrainingDataPart ### Description Represents a singular file that is part of a GeomAITrainingData instance. ### Class `GeomAITrainingDataPart()` ### Methods (Members are inherited and detailed in the source documentation) ``` -------------------------------- ### GeomAIProjectDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/projects.rst Represents a directory of GeomAI projects. ```APIDOC ## GeomAIProjectDirectory ### Description Represents a directory of GeomAI projects. This class provides methods for managing and accessing projects within the GeomAI system. ### Class `ansys.simai.core.data.geomai.projects.GeomAIProjectDirectory` ### Methods (Members are documented in the source class) ``` -------------------------------- ### ModelConfiguration Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/model_configuration.rst Defines the overall configuration for a model, including its inputs, outputs, and other settings. ```APIDOC ## ModelConfiguration() ### Description Defines the overall configuration for a model, including its inputs, outputs, and other settings. This object is used to train a model. ### Parameters This class does not explicitly list parameters in the source. Refer to the class definition for available attributes and methods. ``` -------------------------------- ### Project Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/projects.rst The Project class represents a specific project, which is a selection of training data used to train a model. It inherits members from a base class. ```APIDOC ## Project ### Description Represents a specific project, which is a selection of training data used to train a model. ### Class `ansys.simai.core.data.projects.Project` ### Inherited Members (The source indicates inherited members are available, but does not list them.) ``` -------------------------------- ### Generate Offline Token and Manage Consents Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/current_user.rst Use this snippet to generate an offline token for the current user and manage their consents by listing or revoking them. Ensure the SimAI client is initialized from configuration. ```python import ansys.simai.core as asc simai_client = asc.from_config() # Generate an offline token token = simai_client.me.generate_offline_token() # List all consents consents = simai_client.me.consents.list() # Revoke a specific consent simai_client.me.consents.revoke("sdk") ``` -------------------------------- ### Tox Environments for Development Tasks Source: https://github.com/ansys/pysimai/blob/main/README.rst Utilize tox environments to automate common development tasks. These environments ensure isolated testing and quality checks. ```bash tox -e style ``` ```bash tox -e py ``` ```bash tox -e py-coverage ``` ```bash tox -e doc ``` -------------------------------- ### GeomAITrainingDataDirectory Class Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/training_data.rst Provides directory-level operations for GeomAITrainingData. ```APIDOC ## GeomAITrainingDataDirectory() ### Description Initializes a GeomAITrainingDataDirectory object. ### Parameters None ### Returns A GeomAITrainingDataDirectory object. ``` -------------------------------- ### PostProcessing Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Base class for all postprocessing objects. Inherits common functionalities. ```APIDOC ## PostProcessing() ### Description Represents a generic postprocessing object. This is a base class and typically used through its derived classes. ### Inherited Members Includes members from `PostProcessing`. ``` -------------------------------- ### Model Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/models.rst Represents a SimAI model. This class inherits properties and methods from its parent classes. ```APIDOC class Model() Inherited Members: (Details of inherited members) ``` -------------------------------- ### PostProcessInput Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/model_configuration.rst Defines the input parameters for post-processing steps. ```APIDOC ## PostProcessInput() ### Description Defines the input parameters for post-processing steps. ### Parameters This class does not explicitly list parameters in the source. Refer to the class definition for available attributes and methods. ``` -------------------------------- ### Configure Part Morphing Constraints Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/automorphing/configure_automorphing.rst Use 'part_morphing' to define constraints for specific geometry parts. 'part_ids' identifies the parts, and 'continuity_constraint' (0-1) enforces interface smoothness. ```Python from ansys.simai.core.data.optimizations import OptimizationPartMorphingSchema part_morphing = OptimizationPartMorphingSchema( part_ids=[1, 2], continuity_constraint=0.8 ) ``` -------------------------------- ### GeomAIWorkspaceDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/workspaces.rst Represents a directory or collection of GeomAI workspaces. ```APIDOC ## GeomAIWorkspaceDirectory() ### Description Provides access to a directory of GeomAI workspaces. This class likely allows listing, retrieving, or managing available workspaces. ### Method (Not specified, assumed to be a class instantiation) ### Endpoint (Not applicable for SDK methods) ### Parameters (Parameters not explicitly detailed in the source) ### Request Example ```python # Assuming GeomAIWorkspaceDirectory is importable workspace_dir = GeomAIWorkspaceDirectory() ``` ### Response (Response details not explicitly detailed in the source) ``` -------------------------------- ### GeomAITrainingDataPart Directory Operations Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/training_data_parts.rst This section covers the directory-related operations for GeomAITrainingDataPart. Note that direct interaction with parts is discouraged in favor of using higher-level methods. ```APIDOC ## GeomAITrainingDataPartDirectory ### Description Provides directory-level operations for GeomAITrainingDataParts. ### Class `GeomAITrainingDataPartDirectory()` ### Methods (Members are inherited and detailed in the source documentation) ``` -------------------------------- ### ModelInput Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/model_configuration.rst Defines the input parameters for the model. ```APIDOC ## ModelInput() ### Description Defines the input parameters for the model. ### Parameters This class does not explicitly list parameters in the source. Refer to the class definition for available attributes and methods. ``` -------------------------------- ### Define Model Inputs and Outputs Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Specify the input and output variables for the AI model. Inputs can include surface and scalar data, while outputs can be surface or volume data. ```python model_input = ModelInput(surface=["wallShearStress"], scalars=["Vx"]) model_output = ModelOutput(surface=["alpha.water"], volume=["p", "p_rgh"]) ``` -------------------------------- ### GeomAIPredictionConfiguration Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/predictions.rst Configuration model for GeomAI predictions. ```APIDOC ## GeomAIPredictionConfiguration ### Description This model defines the configuration parameters for GeomAI predictions. ### Fields * **model_name** (string) - Required - The name of the prediction model. * **version** (string) - Optional - The version of the prediction model. * **parameters** (dict) - Optional - Additional parameters for the prediction. ``` -------------------------------- ### GeometryDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geometries.rst Represents a directory of geometries, providing methods to manage and access them. ```APIDOC ## GeometryDirectory() ### Description Manages a collection of geometries within the SimAI platform. ### Class GeometryDirectory ``` -------------------------------- ### Run Prediction on Geometry Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/predictions.rst Use this snippet to initiate a prediction on a geometry object. The arguments for the prediction, such as 'Vx' for velocity, are model-dependent. ```python # Run a prediction on a given geometry with the specified velocity. velocity = 10.0 prediction = geometry.run_prediction(Vx=velocity) ``` -------------------------------- ### Set HTTPS Proxy in SimAIClient Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/proxy.rst Manually set the HTTPS proxy when creating a SimAIClient instance. This overrides system proxy configurations. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient(https_proxy="http://company_proxy:3128") ``` -------------------------------- ### Optimization Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Represents a single optimization model. ```APIDOC ## Class: Optimization() ### Description Represents a model for an optimization process. ### Inherited Members (Members are inherited from base classes and not explicitly listed here, refer to the source for details.) ### Members (Members are not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### CustomVolumePointCloud Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents custom volume point cloud data as a postprocessing result. ```APIDOC ## CustomVolumePointCloud() ### Description Represents custom volume data in a point cloud format, available as a postprocessing result. ``` -------------------------------- ### SurfaceVTP Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents surface data in VTP format as a postprocessing result. ```APIDOC ## SurfaceVTP() ### Description Represents surface data in the Visualization Toolkit PolyData (VTP) format, accessible as a postprocessing result. ``` -------------------------------- ### SurfaceEvolution Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents surface evolution data as a postprocessing result. ```APIDOC ## SurfaceEvolution() ### Description Represents data related to the evolution of surfaces, accessible as a postprocessing result. ### Inherited Members Includes members from `PostProcessing`. ``` -------------------------------- ### Sweep Geometries for Local Optimization Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/data_exploration.rst Use the geometry.sweep method to find geometries with metadata closest to a candidate geometry, useful for local optimization or gradient descent. ```python geometry = simai.geometries.list()[0] neighbour_geometries = geometry.sweep(swept_metadata=["height", "length"]) # with which a selection can be built: selection = Selection(neighbour_geometries, [dict(Vx=13.4)]) ``` -------------------------------- ### Define Domain of Analysis Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/pysimai_ug/building_a_model.rst Configure the domain of analysis for the model, specifying relative ranges for length, width, and height. ```python doa = DomainOfAnalysis( length=("relative_to_min", 15.321, 183.847), width=("relative_to_min", 1.034, 12.414), height=("relative_to_min", 2.046, 24.555), ) ``` -------------------------------- ### LegacyOptimizationResult Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Represents the result of a legacy optimization. ```APIDOC ## Class: LegacyOptimizationResult() ### Description Represents the outcome and data associated with a legacy optimization run. ### Members (Members are not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### Set Current Workspace Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/workspaces.rst Configures the SimAIClient to use a specific workspace. This method is essential for directing client operations to the intended workspace context. ```APIDOC ## set_current_workspace ### Description Sets the current workspace for the SimAIClient. ### Method `SimAIClient.set_current_workspace()` ### Parameters This method does not take any explicit parameters in its signature as presented, but it operates on the client's internal state to select a workspace. ### Usage ```python client.set_current_workspace(workspace_name) ``` ### Notes Refer to the `WorkspaceDirectory` and `Workspace` classes for details on available workspaces and their properties. ``` -------------------------------- ### GeomAIModelConfiguration Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/models.rst Defines the configuration parameters for a GeomAI model. ```APIDOC ## GeomAIModelConfiguration ### Description Defines the configuration parameters for a GeomAI model. This Pydantic model specifies the structure and types of configuration settings required for model creation and operation. ``` -------------------------------- ### Configure TLS CA Bundle in TOML Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/proxy.rst Specify the TLS CA bundle path in the configuration file to resolve SSL certificate verification errors when using a proxy. This is an alternative to setting the REQUESTS_CA_BUNDLE environment variable. ```toml [default] organization = "company" tls_ca_bundle = "/home/username/Documents/my_company_proxy_ca_bundle.pem" ``` -------------------------------- ### Create a Selection in PySimAI Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Create a Selection by combining Geometry instances with Scalars. This forms a collection of Points for potential Prediction instances. ```python from ansys.simai.core.data.selections import Selection geometries = simai.geometries.list()[:4] scalars = [dict(Vx=vx) for vx in [12.2, 12.4, 12.6]] selection = Selection(geometries, scalars) ``` -------------------------------- ### TrainingData Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/training_data.rst Represents a collection of training data parts for model training. ```APIDOC ## TrainingData() ### Description A collection of TrainingDataPart instances representing a simulation for model training. ### Methods (Inherited methods from base class are available) ``` -------------------------------- ### GeomAIClient Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/client.rst The GeomAIClient class provides access to GeomAI functionalities. It is typically accessed through the nested GeomAI client inside SimAI. ```APIDOC ## GeomAIClient ### Description The GeomAIClient class is the main entry point for GeomAI functionalities within the SimAI library. It is designed to be instantiated and used to perform various GeomAI-related operations. ### Instantiation ```python from ansys.simai.core.data.geomai import GeomAIClient # Instantiate the GeomAIClient client = GeomAIClient() ``` ### Methods This class provides the following methods: * **`__init__()`**: Initializes the GeomAIClient. * **`__repr__()`**: Returns a string representation of the GeomAIClient instance. * **`__str__()`**: Returns a string representation of the GeomAIClient instance. (Note: Specific method signatures and detailed descriptions for other members are not provided in the source text and are omitted here.) ``` -------------------------------- ### Run Prediction Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/predictions.rst This method runs a SimAI-powered prediction on a given geometry. The arguments required, such as 'Vx' for velocity, are dependent on the specific model being used. ```APIDOC ## Run Prediction ### Description Runs a SimAI-powered prediction on a given geometry with specified parameters. ### Method `run_prediction` ### Parameters * **Vx** (float) - Required - Velocity parameter for the prediction. ### Request Example ```python velocity = 10.0 prediction = geometry.run_prediction(Vx=velocity) ``` ### Response * **Prediction** - An object representing the numerical prediction with geometry and scalars. ``` -------------------------------- ### Define Maximum Displacement for Bounding Boxes Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/automorphing/configure_automorphing.rst When using the 'max_displacement' parameter, list values in the same order as the bounding boxes. Ensure units correspond to geometry coordinates. ```Python bounding_boxes = [[0,1,0,2,0,4],[10,2,10,4,10,5]] max_displacement = [0.002, 0.001] ``` -------------------------------- ### ModelOutput Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/model_configuration.rst Defines the output parameters of the model. ```APIDOC ## ModelOutput() ### Description Defines the output parameters of the model. ### Parameters This class does not explicitly list parameters in the source. Refer to the class definition for available attributes and methods. ``` -------------------------------- ### DownloadableResult Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Helper class for managing downloadable results. ```APIDOC ## DownloadableResult() ### Description A helper class that provides functionality for managing and downloading results. ### Members (Members are documented within the source but not detailed here as they represent internal structure.) ``` -------------------------------- ### OptimizationPartMorphingSchema Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/optimizations.rst Schema for defining part morphing within optimizations. ```APIDOC ## Class: OptimizationPartMorphingSchema() ### Description Defines the schema for part morphing configurations in optimizations. ### Members (Members are not explicitly listed here, refer to the source for details.) ``` -------------------------------- ### GeomAIModelDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/models.rst Represents a directory of GeomAI models. Use this to manage collections of models. ```APIDOC ## GeomAIModelDirectory() ### Description Represents a directory of GeomAI models. Use this to manage collections of models. ### Methods - `__init__()`: Initializes a GeomAIModelDirectory. - `add(model)`: Adds a GeomAIModel to the directory. - `get(model_id)`: Retrieves a GeomAIModel by its ID. - `list()`: Lists all GeomAIModels in the directory. - `remove(model_id)`: Removes a GeomAIModel by its ID. ``` -------------------------------- ### List Consents Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/current_user.rst Retrieves a list of all consents granted by the current user. ```APIDOC ## List Consents ### Description Lists all consents granted by the current user. ### Method `consents.list()` ### Endpoint N/A (SDK method) ### Parameters None ### Request Example ```python consents = simai_client.me.consents.list() ``` ### Response - **consents** (list) - A list of consent objects. ``` -------------------------------- ### GeomAITrainingData Class Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/training_data.rst Represents a collection of geometric training data parts. It supports .vtp and .stl file formats and requires watertight, manifold, and non-self-intersecting geometry. ```APIDOC ## GeomAITrainingData() ### Description Initializes a GeomAITrainingData object, which is a collection of GeomAITrainingDataPart instances. ### Parameters None ### Returns A GeomAITrainingData object. ``` -------------------------------- ### Run Predictions for a Selection Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Execute all pending predictions for a given selection. Access all generated predictions after execution. ```python # run all predictions selection.run_predictions() all_predictions = selection.predictions ``` -------------------------------- ### Manage Consents with SimAIClient Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst List all active consents and revoke a specific consent using the SimAIClient. Revoking a consent invalidates associated offline tokens. ```python # List all consents consents = simai_client.me.consents.list() for consent in consents: print(f"Client: {consent.client_id}, Created: {consent.created_date}") # Revoke a specific consent (invalidates associated offline tokens) simai_client.me.consents.revoke("sdk") ``` -------------------------------- ### ProcessGlobalCoefficientDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/global_coefficients_requests.rst Represents a class for processing global coefficients within a directory. It likely handles multiple coefficient definitions or related files. ```APIDOC ## ProcessGlobalCoefficientDirectory ### Description This class is designed to handle global coefficients within a directory context, potentially managing multiple coefficient definitions or batch processing. ### Usage ```python # Example usage (assuming necessary imports and setup) # coefficient_directory = ProcessGlobalCoefficientDirectory() # ... methods for directory-based processing ... ``` ### Methods (Details of methods available via `:members:` directive in source) ``` -------------------------------- ### SurfaceVTPTDLocation Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents surface data in VTP format with T/D location information as a postprocessing result. ```APIDOC ## SurfaceVTPTDLocation() ### Description Represents surface data in VTP format, including Time/Data location information, as a postprocessing result. ``` -------------------------------- ### GeomAIProject Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/projects.rst Represents a single GeomAI project, which is a selection of training data. ```APIDOC ## GeomAIProject ### Description Represents a GeomAI project, which is a selection of training data used to train a model. This class allows interaction with individual project data and configurations. ### Class `ansys.simai.core.data.geomai.projects.GeomAIProject` ### Methods (Members are documented in the source class, including inherited members) ``` -------------------------------- ### Slice Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents slice data as a postprocessing result. ```APIDOC ## Slice() ### Description Represents data extracted from a slice, available as a postprocessing result. ``` -------------------------------- ### GeomAIPredictionDirectory Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geomai/predictions.rst Provides methods for managing GeomAI prediction directories. ```APIDOC ## GeomAIPredictionDirectory() ### Description This class provides methods for managing GeomAI prediction directories. ### Methods * `__init__()`: Initializes the GeomAIPredictionDirectory. * `list()`: Lists available prediction directories. * `get(id)`: Retrieves a specific prediction directory by its ID. * `create(name)`: Creates a new prediction directory. * `delete(id)`: Deletes a prediction directory by its ID. ``` -------------------------------- ### Generate Offline Token Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst Generate a long-lived offline token using an authenticated SimAIClient. Store this token securely as it grants full account access. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient(organization="my-company") token = simai_client.me.generate_offline_token() print(f"Store this token securely: {token}") ``` -------------------------------- ### Authenticate SimAIClient with Offline Token Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/configuration_guide/configuration.rst Use an offline token for non-interactive authentication by providing it during client instantiation along with `interactive=False`. This is ideal for server-side scripts and automated workflows. ```python import ansys.simai.core as asc simai_client = asc.SimAIClient( organization="my-company", offline_token="your-offline-token-here", interactive=False, ) ``` -------------------------------- ### Access Global Coefficients from Selection Post-processing Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/selections.rst Retrieve global coefficients for a selection. The results are stored in the 'data' attribute. ```python coeffs = selection.post.global_coefficients() coeffs.data # is a list of results of each post-processings. ``` -------------------------------- ### VolumeVTU Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents volume data in VTU format as a postprocessing result. ```APIDOC ## VolumeVTU() ### Description Represents volume data in the Visualization Toolkit Unstructured Grid (VTU) format, accessible as a postprocessing result. ``` -------------------------------- ### Generate Offline Token Source: https://github.com/ansys/pysimai/blob/main/doc/source/user_guide/automorphing/configure_automorphing.rst Generate an offline token to allow the server to authenticate on your behalf for server-side optimization. This token is valid for 30 days. ```Python offline_token = simai_client.me.generate_offline_token() ``` -------------------------------- ### PredictionPostProcessings Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Namespace for nested prediction-related postprocessing operations. ```APIDOC ## PredictionPostProcessings() ### Description Provides access to postprocessing operations specifically related to predictions. This acts as a nested namespace. ### Members (Members are documented within the source but not detailed here as they represent internal structure.) ``` -------------------------------- ### GlobalCoefficients Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/post_processings.rst Represents global coefficients as a postprocessing result. ```APIDOC ## GlobalCoefficients() ### Description Represents global coefficients that can be accessed as a postprocessing result. ### Inherited Members Includes members from `PostProcessing`. ``` -------------------------------- ### DomainOfAnalysis Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/model_configuration.rst Defines the domain of analysis for the model. ```APIDOC ## DomainOfAnalysis() ### Description Defines the domain of analysis for the model. ### Parameters This class does not explicitly list parameters in the source. Refer to the class definition for available attributes and methods. ``` -------------------------------- ### Geometry Source: https://github.com/ansys/pysimai/blob/main/doc/source/api_reference/geometries.rst Represents a single 3D geometry model and its associated metadata. ```APIDOC ## Geometry() ### Description Represents a 3D model and its associated metadata managed by the SimAI platform. ### Class Geometry ### Inherited Members This class inherits members from its parent class. ```