Optimization#
Directory#
- class OptimizationDirectory#
Provides a collection of methods related to optimizations.
This class is accessed through
client.optimizations.Example
import ansys.simai.core as asc simai_client = asc.from_config() simai_client.optimizations.run_non_parametric(...)
- get(optimization_id: str) Optimization#
Get a specific optimization object from the server.
- Parameters:
optimization_id (str) – ID of the optimization.
- Returns:
- Return type:
- run_non_parametric(geometry: Geometry | str, bounding_boxes: List[List[float]], n_iters: int, symmetries: List[Literal['x', 'y', 'z', 'X', 'Y', 'Z']] | None = None, axial_symmetry: Literal['x', 'y', 'z'] | None = None, scalars: Dict[str, float] | None = None, minimize: List[str] | None = None, maximize: List[str] | None = None, max_displacement: List[float] | None = None, show_progress: bool = False, boundary_conditions: Dict[str, float] | None = None) OptimizationResult#
Run an optimization loop to generate geometries, server-side, using automorphing. Automorphing is a non-parametric deformation of a surface geometry.
- Parameters:
geometry (Geometry | str) – Required. The object (Geometry) or the ID (str) of the baseline geometry on which to perform the non-parametric optimization and that has already been used to build an AI model. The optimization will run in the same workspace as the model.
bounding_boxes (List[List[float]]) –
Required. The list of the bounds of the different boxes that will define the absolute locations of the geometry to optimize. It is a list of lists, and each sub-list must have exactly six items with the following expected order:
[x_min, x_max, y_min, y_max, z_min, z_max].Example format:
[ [box1_xmin, box1_xmax, box1_ymin, box1_ymax, box1_zmin, box1_zmax], [box2_xmin, box2_xmax, box2_ymin, box2_ymax, box2_zmin, box2_zmax], ... ]
n_iters (int) – Required. The number of optimization iterations. This number must be a strictly positive integer. It will define the number of automorphed geometries uploaded to the SimAI workspace.
symmetries (List[Literal['x', 'y', 'z', 'X', 'Y', 'Z']] | None) –
Optional. The list of symmetry axes, axes being x, y, and z, defining a plane around which the geometry is mirrored.
The planar symmetry is applied to all the
bounding_boxesdefined.symmetriesandaxial_symmetryare mutually exclusive parameters.
axial_symmetry (Literal['x', 'y', 'z'] | None) –
Optional. The axis, defined by a scalar, along which axial symmetry is applied. For the deformation to be axially symmetrical:
The center of the bounding box must coincide with the targeted central axis.
The mesh should be axially symmetrical in the bounding box.
The
axial_symmetryis applied to all thebounding_boxesdefined.symmetriesandaxial_symmetryare mutually exclusive parameters.
scalars (Dict[str, float] | None) – Optional. The values of the scalars to perform the optimization at. The values must correspond to existing scalars already defined in your SimAI workspace.
minimize (List[str] | None) – Required if no
maximizeparameter is defined. A list of one global coefficient to minimize. This global coefficient must correspond to one of the existing coefficients defined in your model configuration.Required if no
minimizeparameter is defined. A list of one global coefficient to maximize. This global coefficient must correspond to one of the existing coefficients defined in your model configuration.Note
minimizeandmaximizeare mutually exclusive objectives; define only one.The defined objective must be computed from the surface fields because mesh nodes must be involved.
max_displacement (List[float] | None) –
Optional. User-defined constraint on the maximum allowable deformation of the initial mesh in non-parametric optimization. It is specified as a list (
max_displacement) matching the number of bounding boxes (bounding_boxes).For example, for two bounding boxes:
bounding_boxes = [[0,1,0,2,0,4],[10,2,10,4,10,5]]max_displacement = [0.002, 0.001]
Each value limits the displacement within the corresponding bounding box, using the same metric as the bounding box coordinates.
show_progress (bool) – Optional. Whether to print progress bar on stdout. It is updated each time a new iteration is completed.
boundary_conditions (Dict[str, float] | None) – Optional. (Deprecated) The values of the boundary conditions to perform the optimization at. The values must correspond to existing boundary conditions already defined in your SimAI workspace.
Example
import ansys.simai.core as asc simai_client = asc.from_config(workspace="optimization-workspace") geometry = simai_client.geometries.list()[0] simai_client.optimizations.run_non_parametric( geometry, bounding_boxes=[[0, 1, 0, 1, 0, 1]], scalars={"VelocityX": 10.5}, symmetries=["y"], n_iters=10, minimize=["TotalForceX"], show_progress=True, )
- Returns:
An object containing the results of the optimization.
- Return type:
Model#
- class Optimization#
Provides the local representation of an optimization definition object.
- wait(timeout: float | None = None) bool#
Wait for all jobs concerning the object to either finish or fail.
- 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 OptimizationResult#
Result for a non-parametric optimization.
- property optimization: Optimization#
Optimization object of the optimization run.