Allsolve SDK API Reference
allsolve SDK 0.1.6-beta
allsolve.import_project
Contains a PoC of a convenience import format parser.
import_project
def import_project(file_or_data: str | dict, project_to_modify: Project | None = None) -> Project
Import a project from a file or a dictionary.
Takes a file in YAML or JSON format, an example with all supported fields etc. is given in example/import_geom/project-format.yaml.
Arguments:
file_or_data
- The path to the file to import or a dictionary.project_to_modify
- The project to modify. If not provided, a new project is created.
Returns:
The imported project object.
allsolve.material
MaterialProperty Objects
class MaterialProperty()
MaterialProperty is a base class for managing material properties.
Material Objects
class Material()
Material is a class for managing materials in a project.
create
@classmethoddef create(cls, name: str, color: str, description: str | None = None, properties: List[MaterialProperty.PhysicalProperty] = [], target_region: Region | None = None, abbreviation: str | None = None, project_id: str | None = None) -> Self
Create a new material.
get
@classmethoddef get(cls, material_id: str, project_id: str | None = None) -> Self
Get a material by its ID.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all materials in a project.
id
@property@prevent_deleteddef id() -> str
Get the ID of the material.
name
@property@prevent_deleteddef name() -> str
Get the name of the material.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the material. Use save() to commit the change.
description
@property@prevent_deleteddef description() -> str | None
Get the description of the material.
description
@description.setter@prevent_deleteddef description(description: str) -> None
Set the description of the material. Use save() to commit the change.
color
@property@prevent_deleteddef color() -> str
Get the color of the material.
color
@color.setter@prevent_deleteddef color(color: str) -> None
Set the color of the material. Use save() to commit the change.
target
@property@prevent_deleteddef target() -> str | None
Get the target of the material.
target
@target.setter@prevent_deleteddef target(target: str) -> None
Set the target of the material. Use save() to commit the change.
properties
@property@prevent_deleteddef properties() -> List[rawapi.PhysicalProperty]
Get the properties of the material.
properties
@properties.setter@prevent_deleteddef properties(properties: List[rawapi.PhysicalProperty]) -> None
Set the properties of the material. Use save() to commit the change.
abbreviation
@property@prevent_deleteddef abbreviation() -> str | None
Get the abbreviation of the material.
abbreviation
@abbreviation.setter@prevent_deleteddef abbreviation(abbreviation: str) -> None
Set the abbreviation of the material. Use save() to commit the change.
delete
@prevent_deleteddef delete() -> None
Delete the material.
save
@prevent_deleteddef save() -> None
Explicitly save the changes to the cloud made by
setting properties name
, description
, color
, and properties
.
allsolve.token
allsolve.util
NotInitializedError Objects
class NotInitializedError(Exception)
Exception for when a class or data is not initialized.
DeletedError Objects
class DeletedError(Exception)
Exception for when an object is deleted.
NotProjectAPIKeyError Objects
class NotProjectAPIKeyError(Exception)
Exception for when a project API key is not set.
allsolve.job
Job Objects
class Job()
Job for a project.
Jobs are created when a geometry or a mesh is processed, or when a simulation is run.
id
@propertydef id() -> str
Get the job ID
get_status
def get_status() -> str | None
Get the current status of the job.
Returns:
The status of the job.
refresh_status
def refresh_status(delay_s: float = DEFAULT_DELAY_S) -> str | None
Refresh the status of the job from the server.
Arguments:
delay_s
- Optional time to wait before refreshing the status
Returns:
The status of the job.
is_running
def is_running(refresh_delay_s: float | None = None) -> bool
Check if the job is still running.
Arguments:
refresh_delay_s
- Optional time to wait before checking the status
Returns:
True if the job is still running, False otherwise.
get_logs
def get_logs(limit: int = 100) -> List[str]
Get log messages, starting from where we left off previously
Arguments:
limit
- Optional maximum number of logs to retrieve
Returns:
A list of log messages.
print_new_loglines
def print_new_loglines(file: TextIO = sys.stdout, limit: int = 100) -> None
Print new log lines to the specified output
Arguments:
file
- Optional file to print the logs to.limit
- Optional maximum number of logs to retrieve and print.
get_status_reason
def get_status_reason() -> str | None
Get the reason for the current job status, if available
Returns:
The reason for the current job status, if available.
allsolve.region
RegionOperation Objects
class RegionOperation(Enum)
Enum for the RegionOperation.
Region Objects
class Region()
Region of a geometry.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all regions in the project.
Arguments:
project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
A list of Region objects.
create
@classmethoddef create(cls, name: str, entity_type: rawapi.EntityType, entity_tags: List[int], region_rule: rawapi.RegionRule | None = None, project_id: str | None = None) -> Self
Create a region in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.entity_tags
- The tags of the entity.region_rule
- Optional region rule of the region.project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
The created region.
id
@property@prevent_deleteddef id() -> str
Get the ID of the region.
name
@property@prevent_deleteddef name() -> str
Get the name of the region.
entity_tags
@property@prevent_deleteddef entity_tags() -> List[int]
Get the entity tags of the region.
entity_type
@property@prevent_deleteddef entity_type() -> rawapi.EntityType
Get the entity type of the region.
delete
@prevent_deleteddef delete() -> None
Delete the region.
KeyValueAttributePath Objects
class KeyValueAttributePath(rawapi.AttributePath)
KeyValueAttributePath.
RegionRule Objects
class RegionRule(Region)
RegionRule.
create
@classmethoddef create(cls, name: str, entity_type: rawapi.EntityType, attribute_path: rawapi.AttributePath | None = None, bounding_box: rawapi.ExpressionBoundingBox | None = None, min_size: rawapi.ExpressionVector | None = None, max_size: rawapi.ExpressionVector | None = None, project_id: str | None = None) -> Self
Create a region rule in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.attribute_path
- The attribute path of the region.bounding_box
- The bounding box of the region.min_size
- The minimum size of the region.max_size
- The maximum size of the region.project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
The created region rule.
ComputedRegion Objects
class ComputedRegion(Region)
ComputedRegion.
create
@classmethoddef create(cls, name: str, entity_type: rawapi.EntityType, operation: rawapi.RegionRuleOperation, source_region_ids: List[str], project_id: str | None = None) -> Self
Create a computed region in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.operation
- The operation to perform on the source regions.source_region_ids
- The IDs of the source regions.project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
The created computed region.
allsolve.simulation.simulation
CPU Objects
class CPU(Enum)
Enum for the type of CPU.
Runtime Objects
class Runtime()
Runtime for a simulation.
Script Objects
class Script()
Script for a simulation.
SolverMode Objects
class SolverMode()
Solver mode for a simulation.
Simulation Objects
class Simulation()
Simulation of a project.
get
@classmethoddef get(cls, simulation_id: str, project_id: str | None = None) -> Self
Get a simulation by its ID.
Arguments:
simulation_id
- The ID of the simulation.project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
The simulation.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all simulations in the given project.
Arguments:
project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
A list of simulations.
copy_simulation
@classmethoddef copy_simulation(cls, simulation_id: str, project_id: str | None = None) -> Self
Make a copy of the given simulation identified by its ID. Useful for creating simulations from a template.
Arguments:
simulation_id
- The id of the source simulation.project_id
- The id of the project where the source and target simulation exist. If project API key is used, this is optional.
Returns:
The copied simulation.
create
@classmethoddef create(cls, name: str, description: str, max_run_time_minutes: int, solver_mode: rawapi.DistributedSolverMode, mesh_id: str | None = None, variable_overrides_id: str | None = None, project_id: str | None = None) -> Self
Create a new simulation in the given project.
Arguments:
name
- The name of the new simulation.description
- The description of the new simulation.max_run_time_minutes
- The maximum run time of the simulation.solver_mode
- The solver mode of the simulation.mesh_id
- The ID of the mesh to use in the simulation.variable_overrides_id
- The optional ID of the VariableOverrides to use in the simulation.project_id
- The id of the project where the new simulation should be created. If project API key is used, this is optional.
Returns:
The created simulation.
id
@property@prevent_deleteddef id() -> str
Get the ID of the simulation.
name
@property@prevent_deleteddef name() -> str
Get the name of the simulation.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the simulation.
description
@property@prevent_deleteddef description() -> str | None
Get the description of the simulation.
description
@description.setter@prevent_deleteddef description(description: str) -> None
Set the description of the simulation.
mesh_id
@property@prevent_deleteddef mesh_id() -> str | None
Get the ID of the mesh used in the simulation.
mesh_id
@mesh_id.setter@prevent_deleteddef mesh_id(mesh_id: str) -> None
Set the ID of the mesh used in the simulation.
max_run_time_minutes
@property@prevent_deleteddef max_run_time_minutes() -> int
Get the maximum run time of the simulation.
max_run_time_minutes
@max_run_time_minutes.setter@prevent_deleteddef max_run_time_minutes(max_run_time_minutes: int) -> None
Set the maximum run time of the simulation.
solver_mode
@property@prevent_deleteddef solver_mode() -> rawapi.DistributedSolverMode
Get the solver mode of the simulation.
solver_mode
@solver_mode.setter@prevent_deleteddef solver_mode(solver_mode: rawapi.DistributedSolverMode) -> None
Set the solver mode of the simulation.
node_count
@property@prevent_deleteddef node_count() -> int | None
Get the number of nodes used in the simulation.
node_type
@property@prevent_deleteddef node_type() -> CPU
Get the type of nodes used in the simulation.
shared_files
@property@prevent_deleteddef shared_files() -> List[rawapi.InputFile]
Get the shared files used in the simulation.
files
@property@prevent_deleteddef files() -> List[rawapi.InputFile]
Get the files used in the simulation.
variable_overrides
@property@prevent_deleteddef variable_overrides() -> VariableOverrides | None
Get the variable overrides of the simulation.
variable_overrides
@variable_overrides.setter@prevent_deleteddef variable_overrides(variable_overrides: VariableOverrides | None) -> None
Set the variable overrides of the simulation.
set_scripts
@prevent_deleteddef set_scripts(scripts: List[Script]) -> None
Set the scripts used in the simulation.
refresh_status
@prevent_deleteddef refresh_status(delay_s: float = 1) -> str | None
Refresh the status of the processing of the simulation.
Arguments:
delay_s
- Optional delay in seconds between checking the status of the simulation.
Returns:
The status of the processing of the simulation.
get_status
@prevent_deleteddef get_status() -> str | None
Get the status of the processing of the simulation.
Returns:
The status of the processing of the simulation.
is_running
@prevent_deleteddef is_running(refresh_delay_s: float | None = None) -> bool
Check if the processing of the simulation is running.
Arguments:
refresh_delay_s
- Optional delay in seconds between checking the status of the simulation.
Returns:
True if the simulation is running, False otherwise.
get_status_reason
@prevent_deleteddef get_status_reason() -> str | None
Get the status reason of the simulation.
Returns:
The status reason of the simulation.
get_logs
@prevent_deleteddef get_logs(limit: int = 100) -> List[str]
Get the logs of the simulation.
Arguments:
limit
- Optional maximum number of logs to return.
Returns:
The logs of the simulation.
print_new_loglines
@prevent_deleteddef print_new_loglines(file: TextIO = sys.stdout, limit: int = 100) -> None
Print the new log lines of the simulation.
Arguments:
file
- Optional file to print the logs to.limit
- Optional maximum number of logs to print.
set_runtime
@prevent_deleteddef set_runtime(runtime: Runtime) -> None
Set the runtime of the simulation.
save
@prevent_deleteddef save() -> None
Explictly save the changes to the cloud made by set_runtime
method
or setting properties name
, description
, mesh_id
, max_run_time_minutes
, solver_mode
and variable_overrides
.
Otherwise the changes are saved automatically when start()
is called.
set_shared_files
@prevent_deleteddef set_shared_files(handles: List[rawapi.InputFile]) -> None
Takes a list of project shared file handles and marks them to be used with this simulation. To remove files, remove them from the list and set again.
Arguments:
handles
- List of project shared file handles to use in the simulation
add_file
@prevent_deleteddef add_file(filepath: str) -> rawapi.InputFile
Add the file in the given path to the project as shared file
Arguments:
filepath
- path to a file in the local system. If used in a simulation, it is available with its basename.
Returns:
The shared file handle.
add_json_file
@prevent_deleteddef add_json_file(name: str, content: dict) -> rawapi.InputFile
Add shared file to the project with the given dictionary serialized into JSON as content.
Arguments:
name
- The name for the file during the simulationcontent
- dictionary containing your data
Returns:
The shared file handle.
start
@prevent_deleteddef start() -> None
Start the simulation.
abort
@prevent_deleteddef abort() -> None
Abort the simulation.
get_output_csv
@prevent_deleteddef get_output_csv(delimiter=",", refresh: bool = False) -> str
Get the output of the simulation in CSV format.
Arguments:
delimiter
- The delimiter to use in the CSV file.refresh
- Whether to refresh the output data.
Returns:
String containing the output of the simulation in CSV format.
get_output_data
@prevent_deleteddef get_output_data(refresh: bool = True) -> SimulationOutputData
Returns the output data of the simulation.
Arguments:
refresh
- Whether to refresh the output data.
Returns:
allsolve.sim.SimulationOutputData object
get_output_values
@prevent_deleteddef get_output_values(sweep_index: int = 0, refresh: bool = False) -> dict
Get the output values of the simulation.
Arguments:
sweep_index
- The index of the sweep.refresh
- Whether to refresh the output values.
Returns:
The output values of the simulation.
save_output_field
@prevent_deleteddef save_output_field(name: str, sweep_index: int = 0, step_index: int | None = None, output_dir: str = "./") -> None
Save the output field of the simulation.
Arguments:
name
- The name of the field to save.sweep_index
- The index of the sweep.step_index
- The index of the step or None.output_dir
- The directory to save the field to.
save_output_mesh
@prevent_deleteddef save_output_mesh(name: str, sweep_index: int = 0, step_index: int | None = None, output_dir: str = "./") -> None
Save the output mesh of the simulation.
Arguments:
name
- The name of the mesh to save.sweep_index
- The index of the sweep.step_index
- The index of the step or None.output_dir
- The directory to save the mesh to.
save_output_files
@prevent_deleteddef save_output_files(filenames: List[str], output_dir: str = "./") -> None
Save the output files of the simulation.
Arguments:
filenames
- The names of the files to save.output_dir
- The directory to save the files to.
copy
@prevent_deleteddef copy() -> Self
Make a copy of the simulation. Useful for creating simulations from a template.
Returns:
The copied simulation.
delete
@prevent_deleteddef delete() -> None
Delete the simulation from the project. After deletion, the Simulation
object cannot be used and should be discarded.
allsolve.simulation
allsolve.simulation.simulation_output_data
allsolve.mesh
ExtrusionLayerDefinition Objects
class ExtrusionLayerDefinition()
A layer definition for SlantedExtrusion, PathExtrusion and FlattenAndRebuildExtrusion.
Arguments:
relative_height
- The relative height of the layer.sublayer_count
- The number of sublayers in the layer.
MeshRefinement Objects
class MeshRefinement()
A refinement for a mesh.
Arguments:
region
- The region to refine.max_size
- The maximum size of the refinement.
SlantedExtrusion Objects
class SlantedExtrusion()
A slanted extrusion for a mesh.
Arguments:
volumes
- The volumes to extrude.from_surfaces
- The surfaces to extrude from.to_surfaces
- The surfaces to extrude to.layers
- The layers of the extrusion.quadrangles
- Whether to use quadrangles for the extrusion.
PathExtrusion Objects
class PathExtrusion()
A path extrusion for a mesh.
Arguments:
volumes
- The volumes to extrude.from_surfaces
- The surfaces to extrude from.to_surfaces
- The surfaces to extrude to.layers
- The layers of the extrusion.quadrangles
- Whether to use quadrangles for the extrusion.
FlattenAndRebuildExtrusion Objects
class FlattenAndRebuildExtrusion()
A flatten and rebuild extrusion for a mesh.
Arguments:
volumes
- The volumes to extrude.layers
- The layers of the extrusion.quadrangles
- Whether to use quadrangles for the extrusion.direction_vector
- The direction vector for the extrusion.
MeshExtrusion Objects
class MeshExtrusion()
A simple extrusion for a mesh.
Arguments:
regions
- The regions to extrude.sub_layer_counts
- The number of sublayers for each layer.extrusion_overlap_mode
- The overlap mode for the extrusion.type
- The type of extrusion.
MeshQuality Objects
class MeshQuality(Enum)
Enum for the quality of a mesh.
MeshSettings Objects
class MeshSettings()
Container for settings that can be configured when creating a mesh.
Mesh Objects
class Mesh()
Mesh of a project geometry.
create
@classmethoddef create(cls, project_id: str, mesh_settings: MeshSettings | None = None) -> Self
Create a new mesh in the project.
Arguments:
project_id
- The ID of the project to create the mesh in.mesh_settings
- Optional settings for the mesh.
Returns:
The created mesh.
get
@classmethoddef get(cls, mesh_id: str, project_id: str | None = None) -> Self
Get a mesh by its ID.
Arguments:
mesh_id
- The ID of the mesh.project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
The mesh.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all meshes in the project.
Arguments:
project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
A list of Mesh objects.
id
@property@prevent_deleteddef id() -> str
Get the ID of the mesh.
name
@property@prevent_deleteddef name() -> str
Get the name of the mesh.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the mesh. Use save() to commit the change.
quality
@property@prevent_deleteddef quality() -> MeshQuality
Get the quality of the mesh.
quality
@quality.setter@prevent_deleteddef quality(quality: MeshQuality) -> None
Set the quality of the mesh. Use save() to commit the change.
node_type
@property@prevent_deleteddef node_type() -> str | None
Get the node type of the mesh.
node_type
@node_type.setter@prevent_deleteddef node_type(node_type: str) -> None
Set the node type of the mesh. Use save() to commit the change.
max_run_time_minutes
@property@prevent_deleteddef max_run_time_minutes() -> int
Get the maximum run time of the mesh.
max_run_time_minutes
@max_run_time_minutes.setter@prevent_deleteddef max_run_time_minutes(max_run_time_minutes: int) -> None
Set the maximum run time of the mesh. Use save() to commit the change.
use_mesh_refiner
@property@prevent_deleteddef use_mesh_refiner() -> bool
Get whether the mesh uses the mesh refiner.
use_mesh_refiner
@use_mesh_refiner.setter@prevent_deleteddef use_mesh_refiner(use_mesh_refiner: bool) -> None
Set whether the mesh uses the mesh refiner. Use save() to commit the change.
mesh_size_min
@property@prevent_deleteddef mesh_size_min() -> float | None
Get the minimum mesh size of the mesh.
mesh_size_min
@mesh_size_min.setter@prevent_deleteddef mesh_size_min(mesh_size_min: float) -> None
Set the minimum mesh size of the mesh. Use save() to commit the change.
mesh_size_max
@property@prevent_deleteddef mesh_size_max() -> float | None
Get the maximum mesh size of the mesh.
mesh_size_max
@mesh_size_max.setter@prevent_deleteddef mesh_size_max(mesh_size_max: float) -> None
Set the maximum mesh size of the mesh. Use save() to commit the change.
scale_factor
@property@prevent_deleteddef scale_factor() -> float | None
Get the scale factor of the mesh.
scale_factor
@scale_factor.setter@prevent_deleteddef scale_factor(scale_factor: float) -> None
Set the scale factor of the mesh. Use save() to commit the change.
curvature_enhancement
@property@prevent_deleteddef curvature_enhancement() -> float | None
Get the curvature enhancement of the mesh.
curvature_enhancement
@curvature_enhancement.setter@prevent_deleteddef curvature_enhancement(curvature_enhancement: float) -> None
Set the curvature enhancement of the mesh. Use save() to commit the change.
curved_mesh
@property@prevent_deleteddef curved_mesh() -> bool
Get whether the mesh is curved.
curved_mesh
@curved_mesh.setter@prevent_deleteddef curved_mesh(curved_mesh: bool) -> None
Set whether the mesh is curved. Use save() to commit the change.
target_width_to_height_ratio
@property@prevent_deleteddef target_width_to_height_ratio() -> float | None
Get the target width to height ratio of the mesh.
target_width_to_height_ratio
@target_width_to_height_ratio.setter@prevent_deleteddef target_width_to_height_ratio(target_width_to_height_ratio: float) -> None
Set the target width to height ratio of the mesh. Use save() to commit the change.
refinements
@property@prevent_deleteddef refinements() -> List[MeshRefinement] | None
Get the refinements of the mesh.
refinements
@refinements.setter@prevent_deleteddef refinements(refinements: List[MeshRefinement]) -> None
Set the refinements of the mesh. Use save() to commit the change.
extrusion
@property@prevent_deleteddef extrusion() -> MeshExtrusion | None
Get the extrusion of the mesh.
extrusion
@extrusion.setter@prevent_deleteddef extrusion(extrusion: MeshExtrusion) -> None
Set the extrusion of the mesh. Use save() to commit the change.
slanted_extrusions
@property@prevent_deleteddef slanted_extrusions() -> List[SlantedExtrusion] | None
Get the extrusions of the mesh.
set_slanted_extrusions
@slanted_extrusions.setter@prevent_deleteddef set_slanted_extrusions( slanted_extrusions: List[SlantedExtrusion] | None) -> None
Set the slanted extrusions of the mesh. Use save() to commit the change.
path_extrusions
@property@prevent_deleteddef path_extrusions() -> List[PathExtrusion] | None
Get the path extrusions of the mesh.
set_path_extrusions
@path_extrusions.setter@prevent_deleteddef set_path_extrusions(path_extrusions: List[PathExtrusion] | None) -> None
Set the path extrusions of the mesh. Use save() to commit the change.
flatten_and_rebuild_extrusions
@property@prevent_deleteddef flatten_and_rebuild_extrusions() -> List[FlattenAndRebuildExtrusion] | None
Get the flatten and rebuild extrusions of the mesh.
set_flatten_and_rebuild_extrusions
@flatten_and_rebuild_extrusions.setter@prevent_deleteddef set_flatten_and_rebuild_extrusions( flatten_and_rebuild_extrusions: List[FlattenAndRebuildExtrusion] | None) -> None
Set the flatten and rebuild extrusions of the mesh. Use save() to commit the change.
variable_overrides
@property@prevent_deleteddef variable_overrides() -> List[VariableOverrides] | None
Get the variable overrides of the mesh.
variable_overrides
@variable_overrides.setter@prevent_deleteddef variable_overrides( variable_overrides: List[VariableOverrides] | None) -> None
Set the variable overrides of the mesh. Use save() to commit the change.
save
@prevent_deleteddef save() -> None
Explicitly save the changes to the cloud made by
setting properties name
, quality
, node_type
, max_run_time_minutes
,
mesh_size_min
, mesh_size_max
, scale_factor
, curvature_enhancement
,
curved_mesh
, refinements
and variable_overrides
.
start
@prevent_deleteddef start(variable_overrides_id: str | None = None) -> None
Start processing the mesh.
Arguments:
variable_overrides_id
- Optional VariableOverrides id to use for the mesh.
run
@prevent_deleteddef run(variable_overrides_id: str | None = None, print_logs: bool = False, refresh_delay_s: float = 1) -> None
Process the mesh and returns when the processing is complete.
Arguments:
variable_overrides_id
- Optional VariableOverrides id to use for the mesh.print_logs
- If True, print logs to the console.refresh_delay_s
- Optional delay in seconds between checking the status of the job.
abort
@prevent_deleteddef abort() -> None
Abort the processing of the mesh.
get_status
@prevent_deleteddef get_status() -> str | None
Get the status of the processing of the mesh.
Returns:
The status of the processing of the mesh.
is_running
@prevent_deleteddef is_running(refresh_delay_s: float | None = None) -> bool
Check if the processing of the mesh is running.
Arguments:
refresh_delay_s
- Optional delay in seconds between checking the status of the job.
Returns:
True if the processing of the mesh is running, False otherwise.
refresh_status
@prevent_deleteddef refresh_status(delay_s: float = 1) -> str | None
Refresh the status of the processing of the mesh.
Arguments:
delay_s
- Optional delay in seconds between checking the status of the job.
Returns:
The status of the processing of the mesh.
get_logs
@prevent_deleteddef get_logs(limit: int = 100) -> List[str]
Get the logs of the processing of the mesh.
Arguments:
limit
- Optional maximum number of logs to return.
Returns:
The logs of the processing of the mesh.
print_new_loglines
@prevent_deleteddef print_new_loglines(file: TextIO = sys.stdout, limit: int = 100) -> None
Print the new log lines of the processing of the mesh.
Arguments:
file
- Optional file to print the logs to.limit
- Optional maximum number of logs to print.
delete
@prevent_deleteddef delete() -> None
Delete the mesh from the project.
copy
@prevent_deleteddef copy(name: str | None = None) -> Self
Copy the mesh.
Arguments:
name
- Optional name of the new mesh.
Returns:
The copied mesh.
save_mesh_file
@prevent_deleteddef save_mesh_file(output_dir: str = "./", filename: str = "mesh.msh", variable_overrides_id: str | None = None) -> None
Save the mesh file to a file on local file system.
By default, the mesh file is saved to the current working directory as
mesh.msh
.
Arguments:
output_dir
- The optional directory to save the mesh file to.filename
- The optional filename to save the mesh file to.variable_overrides_id
- The optional variable overrides id to use for the mesh.
allsolve.api
is_setup
def is_setup() -> bool
Check if the Allsolve API client has been initialized.
setup
def setup(api_key: str, api_secret: str, host="http://localhost:3001")
Initialize the Allsolve API client and perform authentication.
Arguments:
api_key
- The API key.api_secret
- The API secret.host
- The host to use.
Raises:
Can raise exception if the authentication request to the Allsolve API fails.
allsolve.file
delete_file
def delete_file(handle: rawapi.InputFile, project_id: str | None = None) -> None
Delete a file from the project.
Arguments:
handle
- The handle of the file to delete.project_id
- The project ID. Can be omitted when using a project API key.
allsolve.geometry
GDSUnit Objects
class GDSUnit()
GDSUnit describes a unit in GDS2 file.
value
@propertydef value() -> str | None
Get the value of the GDS unit.
value
@value.setterdef value(value: str | None) -> None
Set the value of the GDS unit.
GDSAbsoluteLayer Objects
class GDSAbsoluteLayer()
GDSAbsoluteLayer describes a layer in GDS2 file with thickness and absolute z0.
name
@propertydef name() -> str
Get the name of the layer.
name
@name.setterdef name(value: str) -> None
Set the name of the layer.
absolute_z0
@propertydef absolute_z0() -> GDSUnit
Get the absolute z0 of the layer.
absolute_z0
@absolute_z0.setterdef absolute_z0(value: GDSUnit) -> None
Set the absolute z0 of the layer.
disabled
@propertydef disabled() -> bool
Get the disabled state of the layer.
disabled
@disabled.setterdef disabled(value: bool) -> None
Set the disabled state of the layer.
GDSStackedLayer Objects
class GDSStackedLayer()
GDSStackedLayer describes a layer in GDS2 file with thickness. Z0 is calculated from previous layers.
name
@propertydef name() -> str
Get the name of the layer.
name
@name.setterdef name(value: str) -> None
Set the name of the layer.
thickness
@propertydef thickness() -> GDSUnit
Get the thickness of the layer.
thickness
@thickness.setterdef thickness(value: GDSUnit) -> None
Set the thickness of the layer.
disabled
@propertydef disabled() -> bool
Get the disabled state of the layer.
disabled
@disabled.setterdef disabled(value: bool) -> None
Set the disabled state of the layer.
GDS2ImportConfig Objects
class GDS2ImportConfig()
GDS2ImportConfig holds parameters for importing a geometry from a GDS2 file. Configuration requires an unit and layers defined in absolute or/and stacked order. Each layer should have thickness and a name as defined in the GDS2 file. Absolute layers should have also absolute z0.
unit
@propertydef unit() -> GeometryUnit
Get the unit of the GDSImportConfig.
GeometryElement Objects
class GeometryElement()
GeometryElement is a base class for importing a geometry to a project.
ImportGeometry Objects
class ImportGeometry()
ImportGeometry is a base class for importing a geometry to a project from a file.
ImportStep Objects
class ImportStep(ImportGeometry)
ImportStep is a class for importing a STEP file to a project.
ImportIges Objects
class ImportIges(ImportGeometry)
ImportIges is a class for importing an IGES file to a project.
ImportBrep Objects
class ImportBrep(ImportGeometry)
ImportBrep is a class for importing a BREP file to a project.
ImportSat Objects
class ImportSat(ImportGeometry)
ImportSat is a class for importing a SAT file to a project.
ImportMsh Objects
class ImportMsh(ImportGeometry)
ImportMsh is a class for importing a MSH file to a project.
ImportNas Objects
class ImportNas(ImportGeometry)
ImportNas is a class for importing a NAS file to a project.
ImportGds2 Objects
class ImportGds2(ImportGeometry)
ImportGds2 is a class for importing a GDS2 file to a project.
Geometry Objects
class Geometry()
Geometry for a project.
create
@classmethoddef create(cls, geometry_imports: List[GeometryElement.ImportGeometry], project_id: str) -> Self
Create a new geometry element in the given project. Uploads the geometry file to the project.
Arguments:
geometry_imports
- A list of geometry import objects. Currently only one geometry import per project is supported.project_id
- The id of the project where the new geometry element should be created.
Returns:
The created geometry element.
get
@classmethoddef get(cls, project_id: str) -> List[Self]
Get list of Geometry objects in the given project. Currently only one Geometry per project is supported.
Arguments:
project_id
- The ID of the project. Can be omitted if project API key is used.
Returns:
A list of Geometry objects.
delete_geometry
@classmethoddef delete_geometry(cls: type[Self], project_id: str) -> None
Delete the geometry from the project.
id
@property@prevent_deleteddef id() -> str
Get the ID of the geometry element.
name
@property@prevent_deleteddef name() -> str
Get the name of the geometry element.
file_uploaded_at
@property@prevent_deleteddef file_uploaded_at() -> datetime | None
Get the time the geometry file was uploaded.
start
@prevent_deleteddef start() -> None
Start processing the imported geometry file.
run
@prevent_deleteddef run(print_logs: bool = False, refresh_delay_s: float = 1) -> None
Processes the imported geometry file and returns when the processing is complete.
Arguments:
print_logs
- If True, print logs to the console.refresh_delay_s
- Optional delay in seconds between checking the status of the job.
abort
@prevent_deleteddef abort() -> None
Abort the processing of the geometry file.
get_status
@prevent_deleteddef get_status() -> str | None
Get the status of the processing of the geometry file.
Returns:
The status of the processing of the geometry file.
is_running
@prevent_deleteddef is_running(refresh_delay_s: float | None = None) -> bool
Check if the processing of the geometry file is running.
Arguments:
refresh_delay_s
- Optional delay in seconds between checking the status of the job.
Returns:
True if the processing of the geometry file is running, False otherwise.
refresh_status
@prevent_deleteddef refresh_status(delay_s: float = 1) -> str | None
Refresh the status of the processing of the geometry file.
Arguments:
delay_s
- Optional delay in seconds between checking the status of the job.
Returns:
The status of the processing of the geometry file.
get_logs
@prevent_deleteddef get_logs(limit: int = 100) -> List[str]
Get the logs of the processing of the imported geometry file.
Arguments:
limit
- Optional maximum number of logs to return.
Returns:
A list of log messages.
print_new_loglines
@prevent_deleteddef print_new_loglines(file: TextIO = sys.stdout, limit: int = 100) -> None
Print the new log lines of the processing of the imported geometry file.
Arguments:
file
- Optional file to print the logs to.limit
- Optional maximum number of logs to print.
delete
@prevent_deleteddef delete() -> None
Delete the geometry from the project.
allsolve.expression
SharedExpression Objects
class SharedExpression()
SharedExpression is for managing shared expressions.
The “Shared” means that they are stored in the system so that they can referred to in other places using their identifier.
create
@classmethoddef create(cls, name: str, expression_type: ExpressionType = ExpressionType.EXPRESSION, description: str = "", expression: Optional[str | float | int] = None, args: Optional[List[ExpressionArg] | List[rawapi.SharedExpressionArg]] = None, values: Optional[List[Union[float, int]]] = None, project_id: str | None = None) -> Self
Create a new shared expression.
get
@classmethoddef get(cls, expr_id: str, project_id: str | None = None) -> Self
Get a shared expression by its ID.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all shared expressions in a project.
id
@property@prevent_deleteddef id() -> str
Get the ID of the shared expression.
name
@property@prevent_deleteddef name() -> str
Get the name of the shared expression.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the shared expression. Use save() to commit the change.
description
@property@prevent_deleteddef description() -> str
Get the description of the shared expression.
description
@description.setter@prevent_deleteddef description(description: str) -> None
Set the description of the shared expression. Use save() to commit the change.
type
@property@prevent_deleteddef type() -> rawapi.SharedExpressionType
Get the type of the shared expression.
type
@type.setter@prevent_deleteddef type(expression_type: rawapi.SharedExpressionType) -> None
Set the type of the shared expression. Use save() to commit the change.
origin
@property@prevent_deleteddef origin() -> Optional[str]
Get the origin (original shared expression ID if this is a copy).
origin
@origin.setter@prevent_deleteddef origin(origin: Optional[str]) -> None
Set the origin of the shared expression. Use save() to commit the change.
args
@property@prevent_deleteddef args() -> Optional[List[rawapi.SharedExpressionArg]]
Get the arguments of the shared expression.
args
@args.setter@prevent_deleteddef args(args: Optional[List[rawapi.SharedExpressionArg]]) -> None
Set the arguments of the shared expression. Use save() to commit the change.
expression
@property@prevent_deleteddef expression() -> Optional[str]
Get the expression string.
expression
@expression.setter@prevent_deleteddef expression(expression: Optional[str]) -> None
Set the expression string. Use save() to commit the change.
values
@property@prevent_deleteddef values() -> Optional[List[Union[float, int]]]
Get the values of the shared expression.
values
@values.setter@prevent_deleteddef values(values: Optional[List[Union[float, int]]]) -> None
Set the values of the shared expression. Use save() to commit the change.
delete
@prevent_deleteddef delete() -> None
Delete the shared expression.
save
@prevent_deleteddef save() -> None
Explicitly save the changes to the cloud made by
setting properties like name
, description
, type
, expression
, args
, origin
and values
.
allsolve.project
ProjectType Objects
class ProjectType(Enum)
Enum for the type of project.
GeometryPipelineVersion Objects
class GeometryPipelineVersion(Enum)
Enum for the version of the geometry pipeline.
Project Objects
class Project()
A project in the AllSolve.
from_token
@classmethoddef from_token(cls) -> Self
Get the project associated with the project API key.
Returns:
The project associated with the project API key.
Raises:
NotProjectAPIKeyError
- If not authenticated with a project API key.
get
@classmethoddef get(cls, project_id: str) -> Self
Get a project using the project ID.
Arguments:
project_id
- The ID of the project to get.
Returns:
The project with the given ID.
get_all
@classmethoddef get_all(cls) -> List[Self]
Get all projects.
Returns:
A list of projects that the authentication has access to.
create
@classmethoddef create( cls, name: str, description: str, organization_write_access: bool | None = None, labels: List[str] | None = None, type: ProjectType = ProjectType.NORMAL, geometry_pipeline_version: GeometryPipelineVersion = GeometryPipelineVersion .V1) -> Self
Create a new project.
Arguments:
name
- The name of the project.description
- The description of the project.organization_write_access
- Optional boolean whether the organization has write access to the project.labels
- Optional list of labels for the project.type
- OptionalProjectType
. Default isProjectType.NORMAL
. UseProjectType.SCRIPT_ONLY
for projects that do not have geometry.geometry_pipeline_version
- Optional GeometryPipelineVersion. Default is V1.
Returns:
The created project.
id
@property@prevent_deleteddef id() -> str
Get the ID of the project.
name
@property@prevent_deleteddef name() -> str
Get the name of the project.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the project.
description
@property@prevent_deleteddef description() -> str
Get the description of the project.
description
@description.setter@prevent_deleteddef description(description: str) -> None
Set the description of the project.
readonly
@property@prevent_deleteddef readonly() -> bool
Get whether the project is read-only.
labels
@property@prevent_deleteddef labels() -> List[str]
Get the labels of the project.
script_only
@property@prevent_deleteddef script_only() -> bool
Get whether the project is script-only.
geometry_pipeline_version
@property@prevent_deleteddef geometry_pipeline_version() -> GeometryPipelineVersion
Get the geometry pipeline version of the project.
get_geometry
@prevent_deleteddef get_geometry() -> List[Geometry]
Get geometry elements in the project. Currently only one geometry element per project is supported.
Returns:
A list of geometry elements in the project.
import_step
@prevent_deleteddef import_step(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_iges
@prevent_deleteddef import_iges(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_brep
@prevent_deleteddef import_brep(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_sat
@prevent_deleteddef import_sat(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_msh
@prevent_deleteddef import_msh(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_nas
@prevent_deleteddef import_nas(filepath: str) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local system
Returns:
The created geometry.
import_gds2
@prevent_deleteddef import_gds2(filepath: str, config: GDS2ImportConfig) -> Geometry
Import the geometry file in the given path to the project.
Arguments:
filepath
- path to a file in the local systemconfig
- configuration for the GDS import.
Returns:
The created geometry.
add_shared_file
@prevent_deleteddef add_shared_file(filepath: str) -> rawapi.InputFile
Add the file in the given path to the project as shared file
Arguments:
filepath
- path to a file in the local system. If used in a simulation, it is available with its basename.
Returns:
A handle to the created file.
add_shared_json_file
@prevent_deleteddef add_shared_json_file(name: str, content: dict) -> rawapi.InputFile
Add shared file to the project with the given dictionary serialized into JSON as content.
Arguments:
name
- The name for the file during the simulationcontent
- The content of the file
Returns:
A handle to the created file.
get_files
@prevent_deleteddef get_files() -> List[rawapi.InputFile]
Get all files in the project.
Returns:
A list of files in the project.
get_meshes
@prevent_deleteddef get_meshes() -> List[Mesh]
Get all meshes in the project.
Returns:
A list of meshes in the project.
create_mesh
@prevent_deleteddef create_mesh(mesh_settings: MeshSettings) -> Mesh
Create a new mesh in the project.
Arguments:
mesh_settings
- The settings for the mesh.
Returns:
The created mesh.
get_simulation
@prevent_deleteddef get_simulation(simulation_id: str) -> Simulation
Get a simulation using the simulation ID.
Arguments:
simulation_id
- The ID of the simulation to get.
Returns:
The simulation with the given ID.
get_simulations
@prevent_deleteddef get_simulations() -> List[Simulation]
Get all simulations in the project.
Returns:
A list of simulations in the project.
copy_simulation
@prevent_deleteddef copy_simulation(simulation_id: str) -> Simulation
Create a copy of a simulation in the project.
Arguments:
simulation_id
- The ID of the simulation to copy.
Returns:
The copied simulation.
get_regions
@prevent_deleteddef get_regions() -> List[Region]
Get all regions in the project.
Returns:
A list of regions in the project.
create_region_basic
@prevent_deleteddef create_region_basic(name: str, entity_type: rawapi.EntityType, entity_tags: List[int]) -> Region
Create a basic region in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.entity_tags
- The tags of the entity.
Returns:
The created region.
create_region_computed
@prevent_deleteddef create_region_computed(name: str, entity_type: rawapi.EntityType, operation: RegionOperation, source_region_ids: List[str]) -> ComputedRegion
Create a computed region in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.operation
- The operation to perform on the source regions.source_region_ids
- The IDs of the source regions.
Returns:
The created computed region.
create_region_rule
@prevent_deleteddef create_region_rule( name: str, entity_type: rawapi.EntityType, attribute_path: rawapi.AttributePath | None = None, bounding_box: rawapi.ExpressionBoundingBox | None = None, min_size: rawapi.ExpressionVector | None = None, max_size: rawapi.ExpressionVector | None = None) -> Region
Create a region rule in the project.
Arguments:
name
- The name of the region.entity_type
- The type of the entity.attribute_path
- The attribute path to use for the region.bounding_box
- The bounding box to use for the region.min_size
- The minimum size to use for the region.max_size
- The maximum size to use for the region.
Returns:
The created region rule.
create_variable
@prevent_deleteddef create_variable(name: str, expression: str, description: str = "") -> SharedExpression
Create an expression in the project.
create_function
@prevent_deleteddef create_function(name: str, args: List[str], expression: str, description: str = "") -> SharedExpression
Create a function in the project.
create_interpolated_function
@prevent_deleteddef create_interpolated_function(name: str, args: List[Tuple[str, List[float]]], values: List[float], description: str = "") -> SharedExpression
Create an interpolated function in the project.
Arguments:
name
- The name of the interpolated function.args
- The arguments of the interpolated function.values
- The values of the interpolated function.
Returns:
The created interpolated function.
create_variable_overrides
@prevent_deleteddef create_variable_overrides( name: str, overrides: List[Tuple[SharedExpression, str | float | int | List[str | float | int]]]) -> VariableOverrides
Create a VariableOverrides in the project. It can be used to override a value of a single or multiple variables, or to create a sweep over variables.
Arguments:
name
- The name of the set of variable overrides.overrides
- A list of variable overrides. The first element of the tuple is the variable to override and the second is the new value for the variable.
Returns:
The created variable overrides.
get_variable_overrides
@prevent_deleteddef get_variable_overrides() -> List[VariableOverrides]
Get all variable overrides in the project.
get_materials
@prevent_deleteddef get_materials() -> List[Material]
Get all materials in the project.
Returns:
A list of materials in the project.
save
@prevent_deleteddef save() -> None
Explictly save the changes to the cloud made by
setting properties name
and description
.
delete
@prevent_deleteddef delete() -> None
Delete the project.
copy
@prevent_deleteddef copy(with_results: bool = False, name: str | None = None, wait_for_completion: bool = True) -> Self
Copies the project and returns the copied project.
Arguments:
with_results
- If True then files of the original project are copied to the new project.name
- The name of the new project.wait_for_completion
- If True, the copied project is returned after the copy job is completed. If False, get_copy_job() should be used to check the status of the copy job.
Returns:
The copied project.
get_copy_job
@prevent_deleteddef get_copy_job() -> Job | None
Get the copy job for the project. The copy job exists only if the project was copied from another project with results.
Returns:
The copy job for the project.
allsolve.override
VariableOverrides Objects
class VariableOverrides()
VariableOverrides is for managing variable overrides. It can be used to override a value of a single or multiple variables in a project, or to create a sweep over variables.
create
@classmethoddef create(cls, name: str, overrides: List[Tuple[SharedExpression, str | float | int | List[str | float | int]]], override_type: rawapi.SharedExpressionOverrideType = rawapi. SharedExpressionOverrideType.SWEEP, project_id: str | None = None) -> Self
Create a new VariableOverrides.
Arguments:
name
- The name of the set of variable overrides.overrides
- A list of overrides of the VariableOverrides. The first element of the tuple is the variable to override and the second is the new value for the variable.override_type
- The type of the VariableOverrides. Normal or Sweep.project_id
- The ID of the project.
Returns:
The created VariableOverrides.
get
@classmethoddef get(cls, variable_overrides_id: str, project_id: str | None = None) -> Self
Get a VariableOverrides by its ID.
get_all
@classmethoddef get_all(cls, project_id: str | None = None) -> List[Self]
Get all VariableOverrides in a project.
id
@property@prevent_deleteddef id() -> str
Get the ID of the VariableOverrides.
name
@property@prevent_deleteddef name() -> str
Get the name of the VariableOverrides.
name
@name.setter@prevent_deleteddef name(name: str) -> None
Set the name of the VariableOverrides.
type
@property@prevent_deleteddef type() -> rawapi.SharedExpressionOverrideType
Get the type of the VariableOverrides.
overrides
@property@prevent_deleteddef overrides() -> List[Tuple[SharedExpression, str]]
Get the overrides of the VariableOverrides. The list is a copy of the overrides in the VariableOverrides. It the list is modified, use overrides setter to save the change. The list is a list of tuples, where the first element is the variable and the second is the new value for the variable.
overrides
@overrides.setter@prevent_deleteddef overrides( overrides: List[Tuple[SharedExpression, str | float | int | List[str | float | int]]]) -> None
Set the overrides of the VariableOverrides.
delete
@prevent_deleteddef delete() -> None
Delete the VariableOverrides.