TwinModel#
- class pytwin.TwinModel(model_filepath)#
Evaluates a twin model in a TWIN file created by Ansys Twin Builder.
After a twin model is initialized, it can be evaluated with two modes (step-by-step or batch). to make predictions. Parametric workflows are also supported.
- Parameters:
- model_filepath
str
File path to the TWIN file for the twin model.
- model_filepath
Examples
Create the twin model given the file path to the TWIN file. Initialize two parameters and two inputs of the twin model. Then, evaluate the two steps and retrieve the results in a dictionary.
>>> from pytwin import TwinModel >>> >>> twin_model = TwinModel(model_filepath='path_to_your_twin_model.twin') >>> >>> twin_model.initialize_evaluation(parameters={'param1': 1., 'param2': 2.}, inputs={'input1': 1., 'input2': 2.}) >>> outputs = dict() >>> outputs['Time'] = [twin_model.evaluation_time] >>> outputs['output1'] = [twin_model.outputs['output1']] >>> outputs['output2'] = [twin_model.outputs['output2']] >>> >>> twin_model.evaluate_step_by_step(step_size=0.1, inputs={'input1': 10., 'input2': 20.}) >>> outputs['Time'].append(twin_model.evaluation_time) >>> outputs['output1'].append(twin_model.outputs['output1']) >>> outputs['output2'].append(twin_model.outputs['output2']) >>> >>> twin_model.evaluate_step_by_step(step_size=0.1, inputs={'input1': 20., 'input2': 30.}) >>> outputs['Time'].append(twin_model.evaluation_time) >>> outputs['output1'].append(twin_model.outputs['output1']) >>> outputs['output2'].append(twin_model.outputs['output2'])
Methods
Cleanup object when user asks to close it.
TwinModel.evaluate_batch
(inputs_df[, ...])Evaluate the twin model with historical input values given in a data frame.
TwinModel.evaluate_step_by_step
(step_size[, ...])Evaluate the twin model at time instant t plus a step size given inputs at time instant t.
TwinModel.generate_points
(rom_name[, ...])Generate a points file either in memory or on disk, for the full domain or a specific part.
TwinModel.generate_snapshot
(rom_name[, ...])Generate a field snapshot based on current states of the Twin, either in memory or on disk, for the full field or a specific part.
TwinModel.generate_snapshot_batch
(...[, ...])Generate several field snapshots based on historical batch results of the Twin, either in memory or on disk, for the full field or a specific named selection.
TwinModel.get_available_view_names
(rom_name)Get a list of view names for a ROM (reduced order model) in the twin model.
TwinModel.get_field_input_names
(rom_name)Get the list of input fields names associated to the TBROM named rom_name
TwinModel.get_field_output_name
(rom_name)Get the output field name associated to the TBROM named rom_name
TwinModel.get_geometry_filepath
(rom_name)Get the geometry file associated with a ROM available in the twin model.
TwinModel.get_image_filepath
(rom_name, view_name)Get the image file that was created by the given ROM at the given time instant.
TwinModel.get_named_selections
(rom_name)Get the list of named selections associated to the TBROM named rom_name
TwinModel.get_rom_directory
(rom_name)Get the working directory path for a ROM in the twin model.
TwinModel.get_snapshot_filepath
(rom_name[, ...])Get the snapshot file that was created by the given ROM at the given time instant.
TwinModel.get_tbrom_output_field
(rom_name)Return the TBROM output field as a PyVista DataSet object, in the form of point cloud data.
Initialize evaluation of a twin model.
TwinModel.load_state
(model_id, evaluation_time)Load a state that has been saved by a twin model instantiated with the same TWIN file.
TwinModel.project_tbrom_on_mesh
(rom_name, ...)Project the field ROM data onto a targeted mesh, using the current states of the TwinModel.
Save the state of the twin model after its initialization and after step-by-step evaluation.
Attributes
Indicator for if the evaluation has been initialized.
Floating point number that is the current twin model evaluation time in seconds.
Model unique ID.
Floating point number that is the time at which the twin model has been initialized.
Dictionary with input values at the current evaluation time.
Floating point number that is the time at which the twin model has been instantiated.
Model directory (within the global working directory).
Filepath for the twin model that has been verified and loaded.
Path to the model log file that is used at twin runtime instantiation.
Path to the symbolic link to the model log file.
Model temporary directory (within the global working directory).
Model name.
Dictionary with output values at the current evaluation time.
Dictionary with parameter values at the current evaluation time.
Return number of TBROM contained in the Twin.
TBROM directory path.
Dictionary with TBROM model names included in the twin model and their corresponding 3D visualization capabilities.
List of available TBROM names.