Building a model#

Note

Building a model with PySimAI is still experimental and subject to API changes.

Rebuilding a model using the last configuration of a project is supported for models created after v0.1.5 (April 15, 2024).

SimAI allows you to build AI models using past simulation data. This first step to building such models is to upload your simulation data into a global pool of training data instances. Then, you assign the imported data to different Project instances, which you will eventually configure in order to build your AI model.

Create a project and upload data#

  1. Create a SimAIClient instance:

    import ansys.simai.core
    
    simai = ansys.simai.core.SimAIClient()
    

    You are prompted for your credentials.

    If desired, you can create an instance using a configuration file. For more information, see Client configuration.

  2. Create a TrainingData instance and upload your simulation data into it:

    td = simai.training_data.create("my-first-data")
    td.upload_folder("/path/to/folder/where/files/are/stored")
    
  3. Create a project:

    project = simai.projects.create("my-first-project")
    
  4. Associate the created training data with the created project:

    td.add_to_project(project)
    

Your project is created and your simulation data is associated with it. You can now configure and build your AI model.

Configure and build the model#

  1. Import the modules related to model building:

    from ansys.simai.core.data.model_configuration import (
         DomainOfAnalysis,
         ModelConfiguration,
         ModelInput,
         ModelOutput,
    )
    
  2. Set the inputs (ModelInput) and outputs (ModelOutput) of the model:

    model_input = ModelInput(surface=["wallShearStress"], boundary_conditions=["Vx"])
    
    model_output = ModelOutput(surface=["alpha.water"], volume=["p", "p_rgh"])
    
  3. Set the Global Coefficients:

    global_coefficients = [('min("alpha.water")', "minalpha")]
    
  4. Set the Domain of Analysis of the model using the DomainOfAnalysis instance:

    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),
    )
    
  5. Configure the model using the ModelConfiguration instance:

    mdl_conf = ModelConfiguration(
         project=project,                             # project of the model configuration
         build_preset="debug",                        # duration of the build
         continuous=False,                            # continuous training or not
         input=model_input,                           # model input
         output=model_output,                         # model output
         global_coefficients=global_coefficients,     # Global Coefficients
         domain_of_analysis=doa                       # Domain of Analysis
    )
    
  6. Verify if the project meets the requirements for training and launch a build:

    if project.is_trainable():
         new_model = simai.models.build(mdl_conf)
    

Your AI model is configured and building.

Learn more#

For more information on the actions available to you, see TrainingData, TrainingDataParts, Projects, Model configuration, and Models