Postprocessings#
Directory#
- class PostProcessingDirectory(client: ansys.simai.core.client.SimAIClient)#
- delete(post_processing: PostProcessing | str)#
- Delete a postprocessing. - Parameters:
- post_processing (PostProcessing | str) – ID or - modelof the postprocessing.
 
 - get(id: str) PostProcessing#
- Get a specific postprocessing object from the server. - Parameters:
- id (str) – ID of the postprocessing. 
- Returns:
- PostProcessingwith the given ID if it exists.
- Raises:
- NotFoundError – No postprocessing with the given ID exists. 
- Return type:
 
 - list(post_processing_type: Type[PostProcessing] | None = None, prediction: Prediction | str | None = None, workspace: Workspace | str | None = None) List[PostProcessing]#
- List the postprocessings in the current workspace or associated with a prediction. - Optionally you can choose to list only postprocessings of a specific type. For the name of the available postprocessings, see Available postprocessings. - Parameters:
- post_processing_type (Type[PostProcessing] | None) – Type of postprocessing to list. 
- prediction (Prediction | str | None) – ID or - modelof a prediction. If a value is specified, only postprocessings associated with this prediction are returned.
- workspace (Workspace | str | None) – ID or - modelof a workspace. If a value is specified, only postprocessings associated with this workspace are returned.
 
- Raises:
- NotFoundError – Postprocessing type, prediction ID or workspace ID are incorrect. 
- InvalidArguments – If both prediction and workspace are specified. 
- InvalidClientStateError – Neither prediction nor workspace are defined, default workspace is not set. 
 
 - Example - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] post_processings = simai.post_processings.list( ansys.simai.core.SurfaceEvolution, prediction.id ) 
 - run(post_processing_type: str | Type[PostProcessing], prediction: Prediction | str, parameters: Dict[str, Any] | None = None, **kwargs) PostProcessing#
- Run a postprocessing on a prediction. - For the name and the parameters expected by the postprocessings, see Available postprocessings and Nested prediction namespace. Note that the case of the class names must be respected. - Parameters:
- post_processing_type (str | Type[PostProcessing]) – Type of postprocessing to run as a string or as the class itself. 
- prediction (Prediction | str) – ID or - modelof the prediction to run the postprocessing for.
- parameters (Dict[str, Any] | None) – Parameters to apply to the postprocessing, if needed. Alternatively, parameters can be passed as kwargs. 
- **kwargs – Unpacked parameters for the postprocessing. 
 
 - Examples - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] simai.post_processings.run( ansys.simai.core.Slice, prediction, {"axis": "x", "coordinate": 50} ) - Using kwargs: - simai.post_processings.run(ansys.simai.core.Slice, prediction, axis="x", coordinate=50) 
 - property info: List[Dict[str, Any]]#
- Dictionary containing information about the available postprocessings and their parameters. - Example - from pprint import pprint import ansys.simai.core simai = ansys.simai.core.from_config() post_processing_info = simai.post_processings.info pprint(post_processing_info) 
 
Model#
- class PostProcessing#
- Provides the local representation of a - PostProcessingobject.- This is an abstract class. Depending on the postprocessing, a different implementation is returned. For more information, see Available postprocessings. - delete()#
- Delete the postprocessing and its result data. - Raises:
- NotFoundError – If the postprocessing has already been deleted. 
 
 - wait(timeout: float | None = None) bool#
- Wait for all jobs concerning the object to either finish or fail. 
 - abstract property data#
- Get the data generated by the postprocessing. - The return type may vary depending on the postprocessing. It can be a dictionary or, if the data is binary, a - DownloadableResultobject, which provides helpers to download the data into a file or in memory.
 - property failure_reason#
- Optional message giving the causes for why the creation of the object failed. - See also 
 - property has_failed#
- Boolean indicating if the creation of the object failed. - See also 
 - property is_pending#
- Boolean indicating if the object is still in creation. The value becomes - Falseonce object creation is either successful or has failed.- See also 
 - property is_ready#
- Boolean indicating if the object has finished creating without error. - See also 
 - property prediction: Prediction#
- Parent prediction. - The parent prediction is queried if it is not already known by the current SimAPI client session. - See also - prediction_id: Get the parent prediction’s ID without query.
 
 - property prediction_id: str#
- Parent prediction’s ID. - See also - prediction: Get the parent prediction.
 
 
Nested prediction namespace#
- class PredictionPostProcessings#
- Acts as the namespace inside - Predictionobjects.- This class allows you to analyze the results of a prediction. - It can be accessed from any prediction object through its - postproperty:- Example - sim = simai.predictions.get("<prediction_id>") # Run the global coefficients coefs = sim.post.global_coefficients() - custom_volume_point_cloud(run: bool = True) CustomVolumePointCloud | None#
- Compute or get the result of a predicted volume depending on the geometry’s point cloud. - This is a non-blocking method. It returns the - CustomVolumePointCloudobject without waiting. This object may not have data right away if the computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method. Subsequent calls do not relaunch it. - Parameters:
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
- Returns:
- CustomVolumePointCloudobject that allows downloading the binary data.
- Return type:
- CustomVolumePointCloud | None 
 - Examples - Run and download a custom volume point cloud - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] prediction.geometry.upload_point_cloud("/data/my-point-cloud.vtp") custom_volume = prediction.post.custom_volume_point_cloud().data.download( "/tmp/simai.vtp" ) 
 - global_coefficients(run: bool = True) GlobalCoefficients | None#
- Compute or get the global coefficients of the prediction. - This is a non-blocking method. It returns the - GlobalCoefficientsobject without waiting. This object may not have data right away if the computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- Computation is launched only on first call of this method. Subsequent calls do not relaunch it. - Parameters:
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
- Returns:
- GlobalCoefficientsobject that eventually contains the global coefficients with its pressure and velocity components. Returns- Noneif- run=Falseand the postprocessing does not exist.
- Return type:
- GlobalCoefficients | None 
 
 - list(post_processing_type: Type[PostProcessing] | None = None) List[PostProcessing]#
- List the postprocessings associated with the prediction. 
 - slice(axis: str, coordinate: float, format: str = 'png', run: bool = True) Slice | None#
- Compute or get a slice for specific plane parameters. - This is a non-blocking method. It returns the - Sliceobject without waiting. This object may not have data right away if computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method with a specific set of parameters. Subsequent calls with the same parameters do not relaunch it. - The slice is in the NPZ format. - Parameters:
- axis (str) – Axis to slice. 
- coordinate (float) – Coordinate along the given axis to slice at. 
- format (str) – Format of the output. The default is - 'png'. Options are- 'png'and- 'vtp'.
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
 
- Returns:
- Sliceobject that allows downloading the binary data. Returns- Noneif- run=Falseand the postprocessing does not exist.
- Return type:
- Slice | None 
 - Example - Make a slice and open it in a new window using the Pillow library. - import ansys.simai.core from PIL import Image simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] slice_data = prediction.post.slice("x", 50).data.in_memory() slice = Image.open(slice_data) slice.show() 
 - surface_evolution(axis: str, delta: float, run: bool = True) SurfaceEvolution | None#
- Compute or get the SurfaceEvolution for specific parameters. - This is a non-blocking method. It returns the - SurfaceEvolutionobject without waiting. This object may not have data right away if computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method with a specific set of parameters. Subsequent calls with the same parameters do not relaunch it. - Parameters:
- axis (str) – Axis to compute the surface evolution for. 
- delta (float) – Increment of the abscissa in meters. 
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
 
- Returns:
- SurfaceEvolutionthat allows access to the values. Returns- Noneif- run=Falseand the postprocessing does not exist.
- Return type:
- SurfaceEvolution | None 
 
 - surface_vtp(run: bool = True) SurfaceVTP | None#
- Compute or get the result of the prediction’s surface in VTP format. - This method associates all data with cells; if a variable is originally associated with points in the sample, it would be now associated with cells. - It is a non-blocking method. It returns the - PostProcessingVTPobject without waiting. This object may not have data right away if the computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method. Subsequent calls do not relaunch it. - Parameters:
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
- Returns:
- SurfaceVTPobject that allows downloading the binary data. Returns- Noneif- run=Falseand the postprocessing does not exist.
- Return type:
- SurfaceVTP | None 
 - Examples - Run and download a surface VTP with data associated with cells. - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] surface_vtp = prediction.post.surface_vtp().data.download("/tmp/simai.vtp") - Run a surface VTP with data association on cells, and open a plot using PyVista. - import ansys.simai.core import pyvista import tempfile simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] surface_vtp_data = prediction.post.surface_vtp().data # I don't want to save the file locally but pyvista doesn't read file-objects # Using temporary file as a workaround but a real path can be used instead with tempfile.NamedTemporaryFile(suffix=".vtp") as temp_vtp_file: surface_vtp_data.download(temp_vtp_file.name) surface_vtp = pyvista.read(temp_vtp_file.name) surface_vtp.plot() 
 - surface_vtp_td_location(run: bool = True) SurfaceVTPTDLocation | None#
- Compute or get the result of the prediction’s surface in VTP format . - This method keeps the original data association as they are in the sample. - It is a non-blocking method. It returns the - PostProcessingVTPobject without waiting. This object may not have data right away if the computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method. Subsequent calls do not relaunch it. - Parameters:
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
- Returns:
- SurfaceVTPTDLocationobject that allows downloading the binary data. Returns- Noneif- run=Falseand the postprocessing does not exist.
- Return type:
- SurfaceVTPTDLocation | None 
 - Examples - Run and download a surface VTP with the original data association. - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] surface_vtp = prediction.post.surface_vtp_td_location().data.download("/tmp/simai.vtp") - Run a surface VTP with the original data association, and open a plot using PyVista. - import ansys.simai.core import pyvista import tempfile simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] surface_vtp_data = prediction.post.surface_vtp_td_location().data # I don't want to save the file locally but pyvista doesn't read file-objects # Using temporary file as a workaround but a real path can be used instead with tempfile.NamedTemporaryFile(suffix=".vtp") as temp_vtp_file: surface_vtp_data.download(temp_vtp_file.name) surface_vtp = pyvista.read(temp_vtp_file.name) surface_vtp.plot() 
 - volume_vtu(run: bool = True) VolumeVTU | None#
- Compute or get the result of the prediction’s volume in VTU format. - This is a non-blocking method. It returns the - PostProcessingVTUobject without waiting. This object may not have data right away if the computation is still in progress. Data is filled asynchronously once the computation is finished. The state of computation can be monitored with the- is_readyflag or waited upon with the- wait()method.- The computation is launched only on first call of this method. Subsequent calls do not relaunch it. - Parameters:
- run (bool) – Boolean indicating whether to compute or get the postprocessing. The default is - True. If- False, the postprocessing is not computed, and- Noneis returned if it does not exist yet.
- Returns:
- VolumeVTUobject that allows downloading the binary data.
- Return type:
- VolumeVTU | None 
 - Examples - Run and download a volume VTU - import ansys.simai.core simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] volume_vtu = prediction.post.volume_vtu().data.download("/tmp/simai.vtu") - Run a volume VTU and open a plot using PyVista. - import ansys.simai.core import pyvista import tempfile simai = ansys.simai.core.from_config() prediction = simai.predictions.list()[0] volume_vtu_data = prediction.post.volume_vtu().data # I don't want to save the file locally but pyvista doesn't read file-objects # Using temporary file as a workaround but a real path can be used instead with tempfile.NamedTemporaryFile(suffix=".vtu") as temp_vtu_file: volume_vtu_data.download(temp_vtu_file.name) volume_vtu = pyvista.read(temp_vtu_file.name) volume_vtu.plot() 
 
Available postprocessings#
Note
Depending on the capabilities of your model, some of these objects may not
be available in your workspace. You can use the
info() method
to see which ones are available.
- class GlobalCoefficients#
- Provides the representation of the global coefficients of a prediction. - The data attribute contains a dictionary representing the global coefficients with its pressure and velocity components. - This class is generated through the - PredictionPostProcessings.global_coefficients()method.- export(format: str | None = 'json') DownloadableResult#
- Export the postprocessing results in the desired format. - Accessing this property blocks until the data is ready. - Parameters:
- format (str | None) – Format to export the data in. The default is - 'json'. Options are- 'csv.zip',- 'json', and- 'xlsx'. Note that the- 'csv.zip'option exports a ZIP file containing multiple CSV sheets.
- Returns:
- DownloadableResultobject for downloading the exported data into a file or access it in memory.
- Return type:
 
 - wait(timeout: float | None = None) bool#
- Wait for all jobs concerning the object to either finish or fail. 
 - property data: Dict[str, List]#
- Dictionary containing the global coefficients, including pressure and velocity components. - Accessing this property blocks until the data is ready. 
 - property failure_reason#
- Optional message giving the causes for why the creation of the object failed. - See also 
 - property has_failed#
- Boolean indicating if the creation of the object failed. - See also 
 - property is_pending#
- Boolean indicating if the object is still in creation. The value becomes - Falseonce object creation is either successful or has failed.- See also 
 - property is_ready#
- Boolean indicating if the object has finished creating without error. - See also 
 
- class SurfaceEvolution#
- Provides the representation of the - SurfaceEvolutionobject.- This class is generated through - PredictionPostProcessings.surface_evolution()- as_dict() Dict[str, Any]#
- Download the SurfaceEvolution JSON data and load it as a Python dictionary. - Accessing this help method blocks until the data is ready. 
 - export(format: str | None = 'json') DownloadableResult#
- Export the postprocessing results in the desired format. - Accessing this property blocks until the data is ready. - Parameters:
- format (str | None) – Format to export the data in. The default is - 'json'. Options are- 'csv.zip',- 'json', and- 'xlsx'. Note that the- 'csv.zip'option exports a ZIP file containing multiple CSV sheets.
- Returns:
- DownloadableResultobject for downloading the exported data into a file or access it in memory.
- Return type:
 
 - wait(timeout: float | None = None) bool#
- Wait for all jobs concerning the object to either finish or fail. 
 - property data: DownloadableResult#
- DownloadableResultobject that allows access to the- SurfaceEvolutionJSON data, both directly in memory any by downloading it into a file.- Accessing this property blocks until the data is ready. 
 - property failure_reason#
- Optional message giving the causes for why the creation of the object failed. - See also 
 - property has_failed#
- Boolean indicating if the creation of the object failed. - See also 
 - property is_pending#
- Boolean indicating if the object is still in creation. The value becomes - Falseonce object creation is either successful or has failed.- See also 
 - property is_ready#
- Boolean indicating if the object has finished creating without error. - See also 
 
- class Slice#
- Provides a representation of a slice from the prediction in PNG or VTP format. - This class is generated through the - PredictionPostProcessings.slice()method.- property data: DownloadableResult#
- DownloadableResultobject that allows access to slice data, both directly in memory and by downloading it into a file.- Accessing this property blocks until the data is ready. - Returns:
 
 
- class SurfaceVTP#
- Exports the surface of the prediction in VTP format associating all data with cells. - This class is generated through the - surface_vtp()method.
- class SurfaceVTPTDLocation#
- Exports the surface of the prediction in VTP format keeping the original data association. - This class is generated through the - surface_vtp_td_location()method.
- class VolumeVTU#
- Provides for exporting the volume of the prediction in VTU format. - This class is generated through the - PredictionPostProcessings.volume_vtu()method.
- class CustomVolumePointCloud#
- Provides a representation of a CustomVolumePointCloud post-processing. - This class is generated through the - custom_volume_point_cloud()method.- property data: DownloadableResult#
- DownloadableResultobject that allows access to the custom volume VTP either directly in memory or by download it into a file.- Accessing this property blocks until the data is ready 
 
Helpers#
- class DownloadableResult#
- Provides the object representing a result data for a postprocessing in binary format. - download(file: BinaryIO | RawIOBase | BufferedIOBase | Path | str | PathLike) None#
- Download the postprocessing data to the specified file or path. 
 - in_memory() BytesIO#
- Load the postprocessing data in memory. - Returns:
- io.BytesIOobject containing the postprocessing data.
- Return type:
 
 
 
    