API — pyLatticeDesignDesign¶
Core modules¶
pyLatticeDesign.lattice
¶
Classes:
| Name | Description |
|---|---|
Point |
Represents a point in 3D space with additional attributes for simulation. |
Cell |
Class representing a cell in the lattice structure. |
Beam |
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, |
Lattice |
Class to generate lattice structures with various parameters and properties. |
Functions:
| Name | Description |
|---|---|
function_penalization_Lzone |
Calculate the penalization length based on radii and angle. |
_validate_inputs_lattice |
Validate inputs for the lattice constructor. |
open_lattice_parameters |
Open a JSON file containing lattice parameters. |
get_grad_settings |
Generate gradient settings based on the provided rule, direction, and parameters. |
grad_material_setting |
Define gradient material settings. |
grad_settings_constant |
Generate constant gradient settings (i.e., all values = 1.0). |
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Point
¶
Represents a point in 3D space with additional attributes for simulation.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a point object. |
destroy |
Remove all references to this point from connected beams and cells. |
move_to |
Move the point to new coordinates. |
tag_point |
Generate standardized tags for the point based on its position. |
is_identical_to |
Check if this point is identical to another point, modulo the cell size (periodicity). |
is_on_boundary |
Get boolean that give information of boundary node |
distance_to |
Calculate the distance to another point. |
set_local_tag |
Set the local tag for a specific cell containing the point. |
add_cell_belonging |
Add a cell to the list of cells containing this point. |
initialize_reaction_force |
Reset the reaction force vector to zero. |
initialize_displacement |
Reset displacement values to zero for all DOF. |
set_applied_force |
Assign applied force to the point. |
set_reaction_force |
Assign reaction force to the point. |
fix_DOF |
Fix specific degrees of freedom for the point. |
calculate_point_energy |
Calculate the internal energy of the point. |
Attributes:
| Name | Type | Description |
|---|---|---|
coordinates |
Tuple[float, float, float]
|
Retrieve the current position of the point. |
data |
List[float]
|
Retrieve point data for exporting. |
deformed_coordinates |
Tuple[float, float, float]
|
Retrieve the deformed position of the point. |
coordinates
property
¶
Retrieve the current position of the point.
Tuple[float, float, float]: (x, y, z) coordinates of the point.
data
property
¶
Retrieve point data for exporting.
List[float]: [index, x, y, z] of the point.
deformed_coordinates
property
¶
Retrieve the deformed position of the point.
Tuple[float, float, float]: (x, y, z) coordinates including displacements.
__init__(x, y, z, cell_belongings, node_uncertainty_SD=0.0)
¶
Parameters¶
x : float X-coordinate of the point.
float
Y-coordinate of the point.
float
Z-coordinate of the point.
List[Cell]
List of cells that contain this point.
float, optional
Standard deviation for node position uncertainty (default is 0.0).
Raises¶
ValueError If coordinates are not numeric or if node_uncertainty_SD is negative.
destroy()
¶
Remove all references to this point from connected beams and cells.
move_to(xNew, yNew, zNew)
¶
Move the point to new coordinates.
Parameters¶
xNew : float New x-coordinate.
float
New y-coordinate.
float
New z-coordinate.
tag_point(boundary_box_domain)
¶
is_identical_to(other, cell_size)
¶
is_on_boundary(boundary_box_lattice)
¶
distance_to(other)
¶
set_local_tag(cell_index, local_tag)
¶
Set the local tag for a specific cell containing the point.
Parameters:¶
cell_index : int Index of the cell. local_tag : int Local tag to assign to the point for the specified cell.
add_cell_belonging(cell)
¶
initialize_reaction_force()
¶
Reset the reaction force vector to zero.
initialize_displacement()
¶
Reset displacement values to zero for all DOF.
set_applied_force(appliedForce, DOF)
¶
Assign applied force to the point.
Parameters¶
appliedForce : List[float] Applied force values for each DOF.
list[int]
List of DOF to assign (0: x, 1: y, 2: z, 3: Rx, 4: Ry, 5: Rz).
set_reaction_force(reactionForce)
¶
Assign reaction force to the point.
Parameters¶
reactionForce : List[float] Reaction force values for each DOF.
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
Beam
¶
Bases: object
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, and the cells it belongs to.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Beam object representing a beam element. |
destroy |
Delete the beam and clean up references in points and cells. |
get_length |
Calculate the length of the beam. |
get_volume |
Calculate the volume of the beam in case of a circular section. |
is_identical_to |
Check if this beam is identical to another beam. |
add_cell_belonging |
Add a cell to the beam’s belongings if not already present. |
get_angle_between_beams |
Calculates the angle between two beams |
get_point_on_beam_at_distance |
Calculate the coordinates of a point on the beam at a specific distance from an endpoint. |
is_point_on_beam |
Check if a given node lies on the beam. |
set_angle |
Assign angle and radius data to one of the beam’s endpoints. |
get_length_mod |
Calculate the modification length for the penalization method. |
set_beam_mod |
Set the beam as modified. |
unset_beam_mod |
Unset the beam as modified. |
change_beam_radius |
Change the radius of the beam. |
Attributes:
| Name | Type | Description |
|---|---|---|
data |
List[int]
|
Property to retrieve beam data for exporting. |
data
property
¶
Property to retrieve beam data for exporting.
List[int]: [beam_index, point1_index, point2_index, beam_type].
__init__(point1, point2, radius, material, type_beam, cell_belongings)
¶
Parameters:¶
point1 : Point The first endpoint of the beam.
Point
The second endpoint of the beam.
float
The radius of the beam.
int
The material index of the beam.
int
Reference to the geometry type of the beam in case of multiple geometries.
Cell or list of Cell
The cell(s) to which the beam belongs.
destroy()
¶
Delete the beam and clean up references in points and cells. This method removes the beam from its associated cells and points.
get_length()
¶
Calculate the length of the beam.
float: Length of the beam.
get_volume(section_type='circular')
¶
Calculate the volume of the beam in case of a circular section.
Parameters:¶
sectionType : str The type of the beam section. Currently only “circular” is supported.
float: Volume of the beam.
is_identical_to(other, tol=1e-09)
¶
Check if this beam is identical to another beam.
Parameters¶
other : Beam The other beam to compare with. tol : float Tolerance for floating-point comparisons.
add_cell_belonging(cell)
¶
Add a cell to the beam’s belongings if not already present.
Parameters:¶
cell : Cell The cell to add to the beam’s belongings.
get_angle_between_beams(other, periodicity)
¶
get_point_on_beam_at_distance(distance, start_point)
¶
Calculate the coordinates of a point on the beam at a specific distance from an endpoint.
Parameters:¶
distance : float The distance from the specified endpoint along the beam.
int
The index of the starting point (1 or 2) from which the distance is measured
List[float]: Coordinates [x, y, z] of the calculated point.
ValueError: If the point index is not 1 or 2.
is_point_on_beam(node)
¶
Check if a given node lies on the beam.
Parameters:¶
node : Point The node to check.
bool: True if the node lies on the beam, False otherwise.
set_angle(radius, angle, point)
¶
Assign angle and radius data to one of the beam’s endpoints.
Parameters:¶
radius : float Radius at the point.
float
Angle at the point in degrees.
Point
The point (endpoint) of the beam to which the data is assigned.
get_length_mod()
¶
Calculate the modification length for the penalization method.
Tuple[float, float]: Length modifications for point1 and point2.
set_beam_mod()
¶
Set the beam as modified.
unset_beam_mod()
¶
Unset the beam as modified.
Lattice
¶
Bases: object
Class to generate lattice structures with various parameters and properties.
Methods:
| Name | Description |
|---|---|
__init__ |
Constructor from a JSON file to create a lattice object. |
open_pickle_lattice |
Load a lattice pickle and (optionally) upcast it to the caller’s class (e.g., LatticeSim). |
__eq__ |
Compare two Lattice objects based on the radii of each cell. |
get_number_cells |
Get number of cells in the lattice |
get_number_beams |
Get number of beams in the lattice |
get_number_nodes |
Get number of nodes in the lattice |
extract_parameters_from_json |
Extract lattice parameters from a JSON file and set the corresponding attributes. |
get_lattice_boundary_box |
Get the boundary box of the lattice |
define_lattice_dimensions |
Computes extremum values of coordinates in the lattice. |
get_relative_density |
Get mean relative density of all cells in lattice |
get_beam_radius_min_max |
Get the maximum and minimum radii of the lattice |
define_gradient |
Define gradient settings for radii, dimensions, and materials based on provided properties. |
generate_lattice |
Generate cells in the lattice structure based on cell size, number of cells, geometry types, and radii. |
cut_beam_with_mesh_trimmer |
Cut beams in the lattice using the mesh trimmer. |
apply_symmetry |
Apply symmetry to the lattice by mirroring cells across a specified plane. |
delete_beams_under_radius_threshold |
Delete beams with radii under a certain threshold |
set_tag_classification |
Define tag list classification. |
define_size_lattice |
Computes the size of the lattice along each direction. |
is_not_in_erased_region |
Check if the cell is not in the erased region or inside the mesh. |
define_beam_node_index |
Define index at each beam and node |
define_cell_index |
Define index at each cell |
define_node_local_tags |
Define inside cell boundary tag for all boundary nodes |
define_cell_neighbours |
Neighbour assignment using integer grid indices + optional periodic wrap. |
define_connected_beams_for_all_nodes |
Populate |
define_angles_between_beams |
Compute, for each beam, the penalization-optimal angle at its two endpoints |
refresh_cells_memberships |
Public helper to refresh all cells’ beams/points from the current global state. |
remove_cell |
Removes a cell from the lattice |
find_minimum_beam_length |
Find minimum beam length |
get_tag_list |
Get the tag for all unique points in the lattice. |
get_tag_list_boundary |
Get the tag for boundary points in the lattice. |
apply_tag_all_point |
Assign a tag to all nodes in the lattice structure. |
get_cell_occupancy_matrix |
Build a 3D matrix storing Cell objects (or None) at each (i, j, k). |
get_cells_at_index |
Get all cells at a specific index along a specified axis. |
get_relative_boundary_box |
Get the relative boundary box of a cell in the lattice. |
get_name_lattice |
Determine the name_lattice of the lattice |
check_hybrid_collision |
Check if beam in hybrid configuration is cut by a point in the geometry |
are_cells_identical |
Check if all cells in the lattice are identical. |
change_beam_radius |
Change beam radius for all beams in the lattice |
change_beam_radius_depending_type |
Change radii of beam for specific type_beam |
find_point_on_lattice_surface |
Find points on the surface of the lattice |
get_cells_on_surfaces |
Return the list of Cell objects matching ordered extrema constraints like [“Xmin”], [“Xmin”,”Zmax”], etc. |
print_statistics_lattice |
Print statistics about the lattice |
delete_orphan_points |
Delete points that are not connected to any beam in the lattice. |
merge_degree2_nodes |
Fusion of nodes with exactly 2 connected beams. |
delete_unconnected_beams |
Delete beams that are “leaf” beams, i.e. connected to at least one node of degree 1 or 0. |
generate_mesh_lattice_Gmsh |
Generate a 2D mesh representation of the lattice structure using GMSH. |
get_volume_mesh |
Compute the exact CAD volume (OCC ‘mass’ with unit density) of the current model |
get_relative_density_mesh |
Compute relative density = V_solid / V_domain using exact CAD volumes. |
generate_mesh_lattice_rough |
Generate a mesh of the lattice structure with Pyrough library. |
__init__(name_file, mesh_trimmer=None, verbose=0)
¶
Parameters:¶
name_file: str Name of the JSON file containing lattice parameters.
MeshTrimmer, optional
MeshTrimmer object to trim the lattice.
int, optional
Verbosity level for logging.
open_pickle_lattice(file_name='LatticeObject', sim_config=None)
classmethod
¶
Load a lattice pickle and (optionally) upcast it to the caller’s class (e.g., LatticeSim).
If the target class defines _post_load_init, it will be invoked after loading.
__eq__(other)
¶
Compare two Lattice objects based on the radii of each cell. Returns True if they have the same number of cells and identical radii values.
get_number_cells()
¶
Get number of cells in the lattice
get_number_beams()
¶
Get number of beams in the lattice
get_number_nodes()
¶
Get number of nodes in the lattice
extract_parameters_from_json(name_file)
¶
Extract lattice parameters from a JSON file and set the corresponding attributes.
Parameters:¶
name_file: str Name of the JSON file containing lattice parameters.
get_lattice_boundary_box()
¶
Get the boundary box of the lattice
define_lattice_dimensions()
¶
Computes extremum values of coordinates in the lattice.
Return:¶
lattice_dimension_dict: dict Dictionary containing min and max values for x, y, z coordinates.
get_relative_density()
¶
Get mean relative density of all cells in lattice Simple average of cell relative densities
Returns:¶
meanRelDens: float Mean relative density of the lattice
get_beam_radius_min_max()
¶
Get the maximum and minimum radii of the lattice
Returns:¶
radMax: float Maximum radii of the lattice
float
Minimum radii of the lattice
define_gradient(grad_radius_property, grad_dim_property, grad_mat_property)
¶
Define gradient settings for radii, dimensions, and materials based on provided properties.
Parameters:¶
grad_radius_property: list Properties defining the gradient for radii.
list
Properties defining the gradient for cell dimensions.
list
Properties defining the gradient for material settings.
generate_lattice()
¶
Generate cells in the lattice structure based on cell size, number of cells, geometry types, and radii. Gradient information and erased regions are also considered during cell generation.
cut_beam_with_mesh_trimmer()
¶
Cut beams in the lattice using the mesh trimmer.
apply_symmetry(symmetry_plane=None, reference_point=None)
¶
Apply symmetry to the lattice by mirroring cells across a specified plane.
Parameters:¶
symmetry_plane: str, optional Plane of symmetry (‘XY’, ‘XZ’, ‘YZ’, ‘X’, ‘Y’, or ‘Z’). If None, uses self.symmetry_lattice[‘sym_plane’].
tuple of float, optional
Reference point for the symmetry operation (x_ref, y_ref, z_ref). If None, uses self.symmetry_lattice[‘sym_point’].
delete_beams_under_radius_threshold(threshold=0.01)
¶
Delete beams with radii under a certain threshold
Parameters:¶
threshold: float Threshold value for beam radii
set_tag_classification()
¶
Define tag list classification.
define_size_lattice()
¶
Computes the size of the lattice along each direction.
is_not_in_erased_region(start_cell_pos)
¶
define_beam_node_index()
¶
Define index at each beam and node
define_cell_index()
¶
Define index at each cell
define_node_local_tags()
¶
Define inside cell boundary tag for all boundary nodes
define_cell_neighbours()
¶
Neighbour assignment using integer grid indices + optional periodic wrap.
define_connected_beams_for_all_nodes(merge_tol=1e-09)
¶
Populate Point.connected_beams for all nodes.
Optionally merges connectivity for coincident/periodic nodes via a spatial hash.
Parameters¶
merge_tol : float Quantization used to bucket nearly-identical coordinates (and periodic wraps).
define_angles_between_beams()
¶
Compute, for each beam, the penalization-optimal angle at its two endpoints
using node-level connectivity (Point.connected_beams). Assumes
define_connected_beams_for_all_nodes() has been called.
refresh_cells_memberships()
¶
Public helper to refresh all cells’ beams/points from the current global state.
remove_cell(index)
¶
find_minimum_beam_length()
¶
get_tag_list()
¶
Get the tag for all unique points in the lattice.
get_tag_list_boundary()
¶
Get the tag for boundary points in the lattice.
apply_tag_all_point()
¶
Assign a tag to all nodes in the lattice structure. Tags are assigned relative to either the global bounding box or a local (cell-relative) bounding box if erased parts are used.
get_cell_occupancy_matrix()
¶
Build a 3D matrix storing Cell objects (or None) at each (i, j, k).
Returns¶
occupancy_matrix : np.ndarray, shape (num_cells_x, num_cells_y, num_cells_z), dtype=object occupancy_matrix[i, j, k] is the Cell at that grid position, or None if empty.
get_cells_at_index(axis, index)
¶
Get all cells at a specific index along a specified axis.
Parameters:¶
axis: str Axis to query (‘x’, ‘y’, or ‘z’).
int
Index along the specified axis.
get_relative_boundary_box(cell)
¶
Get the relative boundary box of a cell in the lattice. It corresponds to the minimum and maximum dimension of the lattice for each axis with cell continuity. Useful for structures with erased parts or periodic boundaries.
Parameters:¶
cell: Cell object The cell for which the boundary box is computed.
get_name_lattice()
¶
check_hybrid_collision()
¶
Check if beam in hybrid configuration is cut by a point in the geometry Change the beam configuration of collisionned beams
are_cells_identical()
¶
Check if all cells in the lattice are identical.
change_beam_radius(radius_list)
¶
Change beam radius for all beams in the lattice radius_list must have the same length as the number of different beam types in cells
Take care if penalization is activated, the radius of penalized beams will be modified with the penalization coefficient but the length of the modified beam will not be changed (Use reset_cell_with_new_radii instead if you want to have clean cells for simulation)
Parameters:¶
radius_list: list of float List of new radii for each beam type
change_beam_radius_depending_type(typeToChange, newRadius)
¶
Change radii of beam for specific type_beam
Parameters:¶
typeToChange: int Type of beam to change newRadius: float New radii of beam
find_point_on_lattice_surface(surfaceNames, surface_cells=None)
¶
Find points on the surface of the lattice
Parameters:¶
surfaceNames: list[str] List of surfaces to find points on (e.g., [“Xmin”, “Xmax”, “Ymin”])
list[str], optional
List of surfaces to find points on cells (e.g., [“Xmin”, “Xmax”, “Ymin”]). If None, use surfaceNames.
Returns:¶
pointSet: set of point objects Set of points found on the specified surfaces
get_cells_on_surfaces(surfaces)
¶
Return the list of Cell objects matching ordered extrema constraints like [“Xmin”], [“Xmin”,”Zmax”], etc. Filtering is iterative: e.g., first keep all cells at X minimum, then among those keep Z maximum.
Parameters¶
surfaces : list[str] Each item is one of {“Xmin”,”Xmax”,”Ymin”,”Ymax”,”Zmin”,”Zmax”} (case-insensitive).
Returns¶
list List of Cell objects (possibly multiple if several share the same extreme index).
print_statistics_lattice()
¶
Print statistics about the lattice
delete_orphan_points()
¶
Delete points that are not connected to any beam in the lattice.
merge_degree2_nodes(colinear_only=True, radius_strategy='inherit', type_strategy='inherit', material_strategy='inherit', iterative=True, max_passes=10)
¶
Fusion of nodes with exactly 2 connected beams. The two beams must be colinear (if colinear_only=True) and the node must be between the two beam endpoints. The two beams are replaced by a single beam connecting the two distant endpoints.
Parameters:¶
colinear_only : bool If True, only merge if the two beams are colinear.
str
Strategy for determining the radius of the new beam: “inherit” (default) - if both beams have the same radius, use it; otherwise use b1’s radius. “max” - use the maximum radius of the two beams. “min” - use the minimum radius of the two beams. “avg” - use the average radius of the two beams.
str
Strategy for determining the type of the new beam: “inherit” (default) - if both beams have the same type, use it; otherwise use b1’s type. “max” - use the maximum type of the two beams. “min” - use the minimum type of the two beams. “avg” - use the average type of the two beams (rounded).
str
Strategy for determining the material of the new beam: “inherit” (default) - if both beams have the same material, use it; otherwise use b1’s material. “max” - use the maximum material of the two beams. “min” - use the minimum material of the two beams. “avg” - use the average material of the two beams (rounded).
bool
If True, repeat the merging process until no more merges are possible or max_passes is reached.
int
Maximum number of passes if iterative is True.
Returns:¶
total_merged : int Total number of nodes merged.
delete_unconnected_beams(protect_fixed=True, protect_loaded=True, also_delete_orphan_nodes=True)
¶
Delete beams that are “leaf” beams, i.e. connected to at least one node of degree 1 or 0.
Parameters:¶
protect_fixed: bool If True, do not delete beams connected to fixed nodes.
bool
If True, do not delete beams connected to loaded nodes.
bool
If True, delete nodes that become orphaned after beam removal.
Returns:¶
tuple[int, int] Number of beams removed and number of nodes removed.
generate_mesh_lattice_Gmsh(cut_mesh_at_boundary=False, mesh_refinement=1, name_mesh='Lattice', save_mesh=False, save_STL=True, volume_computation=False, only_volume=False, only_relative_density=False, cell_index=None)
¶
Generate a 2D mesh representation of the lattice structure using GMSH. Generating 3D mesh for simulation is not currently supported, but will be in the future.
Parameters:¶
cut_mesh_at_boundary: bool If True, the mesh will be cut at the boundary of the lattice.
float
Refinement factor for the mesh (higher values lead to finer meshes).
str
Name of the mesh to be generated.
bool
If True, the mesh will be saved to a file.
bool
If True, the mesh will be saved in STL format.
bool
If True, the volume of the mesh will be computed and printed.
bool
If True, only the volume of the mesh will be computed and returned.
bool
If True, only the relative density of the mesh will be computed and returned.
int | None
If provided, only the specified cell will be meshed.
get_volume_mesh(entities_3d=None, synchronize=True, return_details=False)
¶
Compute the exact CAD volume (OCC ‘mass’ with unit density) of the current model without requiring any meshing.
Parameters¶
entities_3d : list[(int,int)] | None Optional list of 3D OCC entities (pairs (dim=3, tag)). If None, all 3D entities in the current model are used.
bool
If True, call gmsh.model.occ.synchronize() before querying mass properties. Set to False only if you’ve already synchronized after your boolean ops.
bool
If True, return a dict with ‘total’ and ‘per_entity’ (list of (tag, volume)).
Returns¶
float | dict Total volume if return_details is False, else a dict:
get_relative_density_mesh(solids_3d=None, domain_volume=None)
¶
Compute relative density = V_solid / V_domain using exact CAD volumes.
If domain_volume is None, the domain is taken as the axis-aligned box defined by (x_min..x_max) × (y_min..y_max) × (z_min..z_max).
generate_mesh_lattice_rough(name_file_rough_parameters, name_stl_out, print_volume=True, save_mesh=True, cut_mesh_at_boundary=False, refine_mesh=True)
¶
Generate a mesh of the lattice structure with Pyrough library.
Parameters:¶
name_file_rough_parameters: str Name of the file containing roughness parameters for Pyrough. name_stl_out: str Name of the output STL file. print_volume: bool If True, print the volume of the generated mesh. save_mesh: bool If True, save the generated mesh to the specified path. cut_mesh_at_boundary: bool If True, cut the mesh at the boundary of the lattice. refine_mesh: bool If True, refine the generated mesh using Pyrough’s refinement function.
function_penalization_Lzone(radius, angle)
¶
Calculate the penalization length based on radii and angle.
Parameters:¶
radius: float Radius of the beam.
float
Angle in degrees.
float: Length of the penalization zone.
_validate_inputs_lattice(cell_size_x, cell_size_y, cell_size_z, num_cells_x, num_cells_y, num_cells_z, geom_types, radii, grad_radius_property, grad_dim_property, grad_mat_property, uncertainty_node, eraser_blocks)
¶
Validate inputs for the lattice constructor.
open_lattice_parameters(file_name)
¶
Open a JSON file containing lattice parameters.
Parameters:¶
file_name: str Name of the JSON file containing lattice parameters.
get_grad_settings(num_cells_x, num_cells_y, num_cells_z, grad_properties)
¶
Generate gradient settings based on the provided rule, direction, and parameters.
Parameters:¶
num_cells_x : int Number of cells in the x-direction.
int
Number of cells in the y-direction.
int
Number of cells in the z-direction.
list[Rule, Direction, Parameters]
All types of properties for gradient definition.
Return:¶
gradientData: list[list[float]] Generated gradient settings (list of lists).
grad_material_setting(numCellsX, numCellsY, numCellsZ, gradMatProperty)
¶
grad_settings_constant(num_cells_x, num_cells_y, num_cells_z, material_gradient=False)
¶
Generate constant gradient settings (i.e., all values = 1.0).
Parameters:¶
num_cells_x : int Number of cells in the x-direction.
int
Number of cells in the y-direction.
int
Number of cells in the z-direction.
bool
If True, return a 3D list for material gradient; otherwise, return a flat list.
Returns:¶
list[list[float]]: A list of [1.0, 1.0, 1.0] repeated for the total number of cells.
pyLatticeDesign.cell
¶
Classes:
| Name | Description |
|---|---|
Beam |
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, |
Point |
Represents a point in 3D space with additional attributes for simulation. |
Cell |
Class representing a cell in the lattice structure. |
Functions:
| Name | Description |
|---|---|
function_penalization_Lzone |
Calculate the penalization length based on radii and angle. |
_validate_inputs_cell |
Validate inputs for the cell class constructor. |
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Beam
¶
Bases: object
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, and the cells it belongs to.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Beam object representing a beam element. |
destroy |
Delete the beam and clean up references in points and cells. |
get_length |
Calculate the length of the beam. |
get_volume |
Calculate the volume of the beam in case of a circular section. |
is_identical_to |
Check if this beam is identical to another beam. |
add_cell_belonging |
Add a cell to the beam’s belongings if not already present. |
get_angle_between_beams |
Calculates the angle between two beams |
get_point_on_beam_at_distance |
Calculate the coordinates of a point on the beam at a specific distance from an endpoint. |
is_point_on_beam |
Check if a given node lies on the beam. |
set_angle |
Assign angle and radius data to one of the beam’s endpoints. |
get_length_mod |
Calculate the modification length for the penalization method. |
set_beam_mod |
Set the beam as modified. |
unset_beam_mod |
Unset the beam as modified. |
change_beam_radius |
Change the radius of the beam. |
Attributes:
| Name | Type | Description |
|---|---|---|
data |
List[int]
|
Property to retrieve beam data for exporting. |
data
property
¶
Property to retrieve beam data for exporting.
List[int]: [beam_index, point1_index, point2_index, beam_type].
__init__(point1, point2, radius, material, type_beam, cell_belongings)
¶
Parameters:¶
point1 : Point The first endpoint of the beam.
Point
The second endpoint of the beam.
float
The radius of the beam.
int
The material index of the beam.
int
Reference to the geometry type of the beam in case of multiple geometries.
Cell or list of Cell
The cell(s) to which the beam belongs.
destroy()
¶
Delete the beam and clean up references in points and cells. This method removes the beam from its associated cells and points.
get_length()
¶
Calculate the length of the beam.
float: Length of the beam.
get_volume(section_type='circular')
¶
Calculate the volume of the beam in case of a circular section.
Parameters:¶
sectionType : str The type of the beam section. Currently only “circular” is supported.
float: Volume of the beam.
is_identical_to(other, tol=1e-09)
¶
Check if this beam is identical to another beam.
Parameters¶
other : Beam The other beam to compare with. tol : float Tolerance for floating-point comparisons.
add_cell_belonging(cell)
¶
Add a cell to the beam’s belongings if not already present.
Parameters:¶
cell : Cell The cell to add to the beam’s belongings.
get_angle_between_beams(other, periodicity)
¶
get_point_on_beam_at_distance(distance, start_point)
¶
Calculate the coordinates of a point on the beam at a specific distance from an endpoint.
Parameters:¶
distance : float The distance from the specified endpoint along the beam.
int
The index of the starting point (1 or 2) from which the distance is measured
List[float]: Coordinates [x, y, z] of the calculated point.
ValueError: If the point index is not 1 or 2.
is_point_on_beam(node)
¶
Check if a given node lies on the beam.
Parameters:¶
node : Point The node to check.
bool: True if the node lies on the beam, False otherwise.
set_angle(radius, angle, point)
¶
Assign angle and radius data to one of the beam’s endpoints.
Parameters:¶
radius : float Radius at the point.
float
Angle at the point in degrees.
Point
The point (endpoint) of the beam to which the data is assigned.
get_length_mod()
¶
Calculate the modification length for the penalization method.
Tuple[float, float]: Length modifications for point1 and point2.
set_beam_mod()
¶
Set the beam as modified.
unset_beam_mod()
¶
Unset the beam as modified.
Point
¶
Represents a point in 3D space with additional attributes for simulation.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a point object. |
destroy |
Remove all references to this point from connected beams and cells. |
move_to |
Move the point to new coordinates. |
tag_point |
Generate standardized tags for the point based on its position. |
is_identical_to |
Check if this point is identical to another point, modulo the cell size (periodicity). |
is_on_boundary |
Get boolean that give information of boundary node |
distance_to |
Calculate the distance to another point. |
set_local_tag |
Set the local tag for a specific cell containing the point. |
add_cell_belonging |
Add a cell to the list of cells containing this point. |
initialize_reaction_force |
Reset the reaction force vector to zero. |
initialize_displacement |
Reset displacement values to zero for all DOF. |
set_applied_force |
Assign applied force to the point. |
set_reaction_force |
Assign reaction force to the point. |
fix_DOF |
Fix specific degrees of freedom for the point. |
calculate_point_energy |
Calculate the internal energy of the point. |
Attributes:
| Name | Type | Description |
|---|---|---|
coordinates |
Tuple[float, float, float]
|
Retrieve the current position of the point. |
data |
List[float]
|
Retrieve point data for exporting. |
deformed_coordinates |
Tuple[float, float, float]
|
Retrieve the deformed position of the point. |
coordinates
property
¶
Retrieve the current position of the point.
Tuple[float, float, float]: (x, y, z) coordinates of the point.
data
property
¶
Retrieve point data for exporting.
List[float]: [index, x, y, z] of the point.
deformed_coordinates
property
¶
Retrieve the deformed position of the point.
Tuple[float, float, float]: (x, y, z) coordinates including displacements.
__init__(x, y, z, cell_belongings, node_uncertainty_SD=0.0)
¶
Parameters¶
x : float X-coordinate of the point.
float
Y-coordinate of the point.
float
Z-coordinate of the point.
List[Cell]
List of cells that contain this point.
float, optional
Standard deviation for node position uncertainty (default is 0.0).
Raises¶
ValueError If coordinates are not numeric or if node_uncertainty_SD is negative.
destroy()
¶
Remove all references to this point from connected beams and cells.
move_to(xNew, yNew, zNew)
¶
Move the point to new coordinates.
Parameters¶
xNew : float New x-coordinate.
float
New y-coordinate.
float
New z-coordinate.
tag_point(boundary_box_domain)
¶
is_identical_to(other, cell_size)
¶
is_on_boundary(boundary_box_lattice)
¶
distance_to(other)
¶
set_local_tag(cell_index, local_tag)
¶
Set the local tag for a specific cell containing the point.
Parameters:¶
cell_index : int Index of the cell. local_tag : int Local tag to assign to the point for the specified cell.
add_cell_belonging(cell)
¶
initialize_reaction_force()
¶
Reset the reaction force vector to zero.
initialize_displacement()
¶
Reset displacement values to zero for all DOF.
set_applied_force(appliedForce, DOF)
¶
Assign applied force to the point.
Parameters¶
appliedForce : List[float] Applied force values for each DOF.
list[int]
List of DOF to assign (0: x, 1: y, 2: z, 3: Rx, 4: Ry, 5: Rz).
set_reaction_force(reactionForce)
¶
Assign reaction force to the point.
Parameters¶
reactionForce : List[float] Reaction force values for each DOF.
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
function_penalization_Lzone(radius, angle)
¶
Calculate the penalization length based on radii and angle.
Parameters:¶
radius: float Radius of the beam.
float
Angle in degrees.
float: Length of the penalization zone.
_validate_inputs_cell(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node, _verbose)
¶
Validate inputs for the cell class constructor.
pyLatticeDesign.beam
¶
Classes:
| Name | Description |
|---|---|
Cell |
Class representing a cell in the lattice structure. |
Point |
Represents a point in 3D space with additional attributes for simulation. |
Beam |
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, |
Functions:
| Name | Description |
|---|---|
function_penalization_Lzone |
Calculate the penalization length based on radii and angle. |
_discard |
|
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
Point
¶
Represents a point in 3D space with additional attributes for simulation.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a point object. |
destroy |
Remove all references to this point from connected beams and cells. |
move_to |
Move the point to new coordinates. |
tag_point |
Generate standardized tags for the point based on its position. |
is_identical_to |
Check if this point is identical to another point, modulo the cell size (periodicity). |
is_on_boundary |
Get boolean that give information of boundary node |
distance_to |
Calculate the distance to another point. |
set_local_tag |
Set the local tag for a specific cell containing the point. |
add_cell_belonging |
Add a cell to the list of cells containing this point. |
initialize_reaction_force |
Reset the reaction force vector to zero. |
initialize_displacement |
Reset displacement values to zero for all DOF. |
set_applied_force |
Assign applied force to the point. |
set_reaction_force |
Assign reaction force to the point. |
fix_DOF |
Fix specific degrees of freedom for the point. |
calculate_point_energy |
Calculate the internal energy of the point. |
Attributes:
| Name | Type | Description |
|---|---|---|
coordinates |
Tuple[float, float, float]
|
Retrieve the current position of the point. |
data |
List[float]
|
Retrieve point data for exporting. |
deformed_coordinates |
Tuple[float, float, float]
|
Retrieve the deformed position of the point. |
coordinates
property
¶
Retrieve the current position of the point.
Tuple[float, float, float]: (x, y, z) coordinates of the point.
data
property
¶
Retrieve point data for exporting.
List[float]: [index, x, y, z] of the point.
deformed_coordinates
property
¶
Retrieve the deformed position of the point.
Tuple[float, float, float]: (x, y, z) coordinates including displacements.
__init__(x, y, z, cell_belongings, node_uncertainty_SD=0.0)
¶
Parameters¶
x : float X-coordinate of the point.
float
Y-coordinate of the point.
float
Z-coordinate of the point.
List[Cell]
List of cells that contain this point.
float, optional
Standard deviation for node position uncertainty (default is 0.0).
Raises¶
ValueError If coordinates are not numeric or if node_uncertainty_SD is negative.
destroy()
¶
Remove all references to this point from connected beams and cells.
move_to(xNew, yNew, zNew)
¶
Move the point to new coordinates.
Parameters¶
xNew : float New x-coordinate.
float
New y-coordinate.
float
New z-coordinate.
tag_point(boundary_box_domain)
¶
is_identical_to(other, cell_size)
¶
is_on_boundary(boundary_box_lattice)
¶
distance_to(other)
¶
set_local_tag(cell_index, local_tag)
¶
Set the local tag for a specific cell containing the point.
Parameters:¶
cell_index : int Index of the cell. local_tag : int Local tag to assign to the point for the specified cell.
add_cell_belonging(cell)
¶
initialize_reaction_force()
¶
Reset the reaction force vector to zero.
initialize_displacement()
¶
Reset displacement values to zero for all DOF.
set_applied_force(appliedForce, DOF)
¶
Assign applied force to the point.
Parameters¶
appliedForce : List[float] Applied force values for each DOF.
list[int]
List of DOF to assign (0: x, 1: y, 2: z, 3: Rx, 4: Ry, 5: Rz).
set_reaction_force(reactionForce)
¶
Assign reaction force to the point.
Parameters¶
reactionForce : List[float] Reaction force values for each DOF.
Beam
¶
Bases: object
Class Beam represents a beam element defined by two endpoints (Point objects), a radius, material index, type, and the cells it belongs to.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Beam object representing a beam element. |
destroy |
Delete the beam and clean up references in points and cells. |
get_length |
Calculate the length of the beam. |
get_volume |
Calculate the volume of the beam in case of a circular section. |
is_identical_to |
Check if this beam is identical to another beam. |
add_cell_belonging |
Add a cell to the beam’s belongings if not already present. |
get_angle_between_beams |
Calculates the angle between two beams |
get_point_on_beam_at_distance |
Calculate the coordinates of a point on the beam at a specific distance from an endpoint. |
is_point_on_beam |
Check if a given node lies on the beam. |
set_angle |
Assign angle and radius data to one of the beam’s endpoints. |
get_length_mod |
Calculate the modification length for the penalization method. |
set_beam_mod |
Set the beam as modified. |
unset_beam_mod |
Unset the beam as modified. |
change_beam_radius |
Change the radius of the beam. |
Attributes:
| Name | Type | Description |
|---|---|---|
data |
List[int]
|
Property to retrieve beam data for exporting. |
data
property
¶
Property to retrieve beam data for exporting.
List[int]: [beam_index, point1_index, point2_index, beam_type].
__init__(point1, point2, radius, material, type_beam, cell_belongings)
¶
Parameters:¶
point1 : Point The first endpoint of the beam.
Point
The second endpoint of the beam.
float
The radius of the beam.
int
The material index of the beam.
int
Reference to the geometry type of the beam in case of multiple geometries.
Cell or list of Cell
The cell(s) to which the beam belongs.
destroy()
¶
Delete the beam and clean up references in points and cells. This method removes the beam from its associated cells and points.
get_length()
¶
Calculate the length of the beam.
float: Length of the beam.
get_volume(section_type='circular')
¶
Calculate the volume of the beam in case of a circular section.
Parameters:¶
sectionType : str The type of the beam section. Currently only “circular” is supported.
float: Volume of the beam.
is_identical_to(other, tol=1e-09)
¶
Check if this beam is identical to another beam.
Parameters¶
other : Beam The other beam to compare with. tol : float Tolerance for floating-point comparisons.
add_cell_belonging(cell)
¶
Add a cell to the beam’s belongings if not already present.
Parameters:¶
cell : Cell The cell to add to the beam’s belongings.
get_angle_between_beams(other, periodicity)
¶
get_point_on_beam_at_distance(distance, start_point)
¶
Calculate the coordinates of a point on the beam at a specific distance from an endpoint.
Parameters:¶
distance : float The distance from the specified endpoint along the beam.
int
The index of the starting point (1 or 2) from which the distance is measured
List[float]: Coordinates [x, y, z] of the calculated point.
ValueError: If the point index is not 1 or 2.
is_point_on_beam(node)
¶
Check if a given node lies on the beam.
Parameters:¶
node : Point The node to check.
bool: True if the node lies on the beam, False otherwise.
set_angle(radius, angle, point)
¶
Assign angle and radius data to one of the beam’s endpoints.
Parameters:¶
radius : float Radius at the point.
float
Angle at the point in degrees.
Point
The point (endpoint) of the beam to which the data is assigned.
get_length_mod()
¶
Calculate the modification length for the penalization method.
Tuple[float, float]: Length modifications for point1 and point2.
set_beam_mod()
¶
Set the beam as modified.
unset_beam_mod()
¶
Unset the beam as modified.
function_penalization_Lzone(radius, angle)
¶
Calculate the penalization length based on radii and angle.
Parameters:¶
radius: float Radius of the beam.
float
Angle in degrees.
float: Length of the penalization zone.
_discard(container, item)
¶
pyLatticeDesign.point
¶
Classes:
| Name | Description |
|---|---|
Cell |
Class representing a cell in the lattice structure. |
Point |
Represents a point in 3D space with additional attributes for simulation. |
Functions:
| Name | Description |
|---|---|
_discard |
|
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
Point
¶
Represents a point in 3D space with additional attributes for simulation.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a point object. |
destroy |
Remove all references to this point from connected beams and cells. |
move_to |
Move the point to new coordinates. |
tag_point |
Generate standardized tags for the point based on its position. |
is_identical_to |
Check if this point is identical to another point, modulo the cell size (periodicity). |
is_on_boundary |
Get boolean that give information of boundary node |
distance_to |
Calculate the distance to another point. |
set_local_tag |
Set the local tag for a specific cell containing the point. |
add_cell_belonging |
Add a cell to the list of cells containing this point. |
initialize_reaction_force |
Reset the reaction force vector to zero. |
initialize_displacement |
Reset displacement values to zero for all DOF. |
set_applied_force |
Assign applied force to the point. |
set_reaction_force |
Assign reaction force to the point. |
fix_DOF |
Fix specific degrees of freedom for the point. |
calculate_point_energy |
Calculate the internal energy of the point. |
Attributes:
| Name | Type | Description |
|---|---|---|
coordinates |
Tuple[float, float, float]
|
Retrieve the current position of the point. |
data |
List[float]
|
Retrieve point data for exporting. |
deformed_coordinates |
Tuple[float, float, float]
|
Retrieve the deformed position of the point. |
coordinates
property
¶
Retrieve the current position of the point.
Tuple[float, float, float]: (x, y, z) coordinates of the point.
data
property
¶
Retrieve point data for exporting.
List[float]: [index, x, y, z] of the point.
deformed_coordinates
property
¶
Retrieve the deformed position of the point.
Tuple[float, float, float]: (x, y, z) coordinates including displacements.
__init__(x, y, z, cell_belongings, node_uncertainty_SD=0.0)
¶
Parameters¶
x : float X-coordinate of the point.
float
Y-coordinate of the point.
float
Z-coordinate of the point.
List[Cell]
List of cells that contain this point.
float, optional
Standard deviation for node position uncertainty (default is 0.0).
Raises¶
ValueError If coordinates are not numeric or if node_uncertainty_SD is negative.
destroy()
¶
Remove all references to this point from connected beams and cells.
move_to(xNew, yNew, zNew)
¶
Move the point to new coordinates.
Parameters¶
xNew : float New x-coordinate.
float
New y-coordinate.
float
New z-coordinate.
tag_point(boundary_box_domain)
¶
is_identical_to(other, cell_size)
¶
is_on_boundary(boundary_box_lattice)
¶
distance_to(other)
¶
set_local_tag(cell_index, local_tag)
¶
Set the local tag for a specific cell containing the point.
Parameters:¶
cell_index : int Index of the cell. local_tag : int Local tag to assign to the point for the specified cell.
add_cell_belonging(cell)
¶
initialize_reaction_force()
¶
Reset the reaction force vector to zero.
initialize_displacement()
¶
Reset displacement values to zero for all DOF.
set_applied_force(appliedForce, DOF)
¶
Assign applied force to the point.
Parameters¶
appliedForce : List[float] Applied force values for each DOF.
list[int]
List of DOF to assign (0: x, 1: y, 2: z, 3: Rx, 4: Ry, 5: Rz).
set_reaction_force(reactionForce)
¶
Assign reaction force to the point.
Parameters¶
reactionForce : List[float] Reaction force values for each DOF.
_discard(container, item)
¶
Utilities¶
pyLatticeDesign.utils
¶
Functions:
| Name | Description |
|---|---|
_validate_inputs_lattice |
Validate inputs for the lattice constructor. |
_validate_inputs_cell |
Validate inputs for the cell class constructor. |
open_lattice_parameters |
Open a JSON file containing lattice parameters. |
save_lattice_object |
Save ONLY the base |
save_JSON_to_Grasshopper |
Save the current lattice object to JSON files for Grasshopper compatibility, separating by cells. |
function_penalization_Lzone |
Calculate the penalization length based on radii and angle. |
_prepare_lattice_plot_data |
|
_get_beam_color |
|
get_boundary_condition_color |
Generate a color based on the fixed DOFs using a bitmask approach. |
plot_coordinate_system |
Plot a 3D coordinate system with arrows representing the X, Y, and Z axes. |
_discard |
|
_validate_inputs_lattice(cell_size_x, cell_size_y, cell_size_z, num_cells_x, num_cells_y, num_cells_z, geom_types, radii, grad_radius_property, grad_dim_property, grad_mat_property, uncertainty_node, eraser_blocks)
¶
Validate inputs for the lattice constructor.
_validate_inputs_cell(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node, _verbose)
¶
Validate inputs for the cell class constructor.
open_lattice_parameters(file_name)
¶
Open a JSON file containing lattice parameters.
Parameters:¶
file_name: str Name of the JSON file containing lattice parameters.
save_lattice_object(lattice, file_name='LatticeObject')
¶
Save ONLY the base Lattice state to a pickle, even if lattice is an instance
of a subclass (e.g., LatticeSim/LatticeOpti) carrying non-picklable fields.
Important: converts internal sets (beams/nodes and per-cell containers) to lists
before pickling to avoid hashing during unpickling. A marker _pickle_format
is stored so the loader can restore sets later.
Note: this function does NOT save the full state of subclasses, only the base
Lattice attributes. (TO UPDATE if needed)
Parameters:¶
lattice: Lattice Lattice object to save.
str
Name of the pickle file to save.
save_JSON_to_Grasshopper(lattice, nameLattice='LatticeObject', multipleParts=1)
¶
Save the current lattice object to JSON files for Grasshopper compatibility, separating by cells.
Parameters:¶
lattice: Lattice Lattice object to save.
str
Name of the lattice file to save.
int, optional (default: 1)
Number of parts to save.
function_penalization_Lzone(radius, angle)
¶
Calculate the penalization length based on radii and angle.
Parameters:¶
radius: float Radius of the beam.
float
Angle in degrees.
float: Length of the penalization zone.
_prepare_lattice_plot_data(beam, deformedForm=False)
¶
_get_beam_color(beam, color_palette, beamColor, idxColor, cells, nbRadiusBins=5)
¶
get_boundary_condition_color(fixed_DOF)
¶
Generate a color based on the fixed DOFs using a bitmask approach.
plot_coordinate_system(ax)
¶
Plot a 3D coordinate system with arrows representing the X, Y, and Z axes.
_discard(container, item)
¶
pyLatticeDesign.gradient_properties
¶
Gradient properties module.
Functions:
| Name | Description |
|---|---|
grad_settings_constant |
Generate constant gradient settings (i.e., all values = 1.0). |
get_grad_settings |
Generate gradient settings based on the provided rule, direction, and parameters. |
grad_material_setting |
Define gradient material settings. |
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
grad_settings_constant(num_cells_x, num_cells_y, num_cells_z, material_gradient=False)
¶
Generate constant gradient settings (i.e., all values = 1.0).
Parameters:¶
num_cells_x : int Number of cells in the x-direction.
int
Number of cells in the y-direction.
int
Number of cells in the z-direction.
bool
If True, return a 3D list for material gradient; otherwise, return a flat list.
Returns:¶
list[list[float]]: A list of [1.0, 1.0, 1.0] repeated for the total number of cells.
get_grad_settings(num_cells_x, num_cells_y, num_cells_z, grad_properties)
¶
Generate gradient settings based on the provided rule, direction, and parameters.
Parameters:¶
num_cells_x : int Number of cells in the x-direction.
int
Number of cells in the y-direction.
int
Number of cells in the z-direction.
list[Rule, Direction, Parameters]
All types of properties for gradient definition.
Return:¶
gradientData: list[list[float]] Generated gradient settings (list of lists).
grad_material_setting(numCellsX, numCellsY, numCellsZ, gradMatProperty)
¶
pyLatticeDesign.design_transformation
¶
List of functions to transform the lattice structure in different ways.
These functions can be used to modify the lattice geometry, such as attracting points, curving the lattice, applying cylindrical transformations, and fitting to surfaces.
Classes:
| Name | Description |
|---|---|
Point |
Represents a point in 3D space with additional attributes for simulation. |
Functions:
| Name | Description |
|---|---|
attractor_lattice |
Attract lattice to a specific point |
curveLattice |
Curve the lattice structure around a given center. |
cylindrical_transform |
Apply cylindrical transformation to the lattice structure. |
moveToCylinderForm |
Move the lattice to a cylindrical form. |
fitToSurface |
Adjust the lattice nodes to follow a surface defined by an equation. |
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Point
¶
Represents a point in 3D space with additional attributes for simulation.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a point object. |
destroy |
Remove all references to this point from connected beams and cells. |
move_to |
Move the point to new coordinates. |
tag_point |
Generate standardized tags for the point based on its position. |
is_identical_to |
Check if this point is identical to another point, modulo the cell size (periodicity). |
is_on_boundary |
Get boolean that give information of boundary node |
distance_to |
Calculate the distance to another point. |
set_local_tag |
Set the local tag for a specific cell containing the point. |
add_cell_belonging |
Add a cell to the list of cells containing this point. |
initialize_reaction_force |
Reset the reaction force vector to zero. |
initialize_displacement |
Reset displacement values to zero for all DOF. |
set_applied_force |
Assign applied force to the point. |
set_reaction_force |
Assign reaction force to the point. |
fix_DOF |
Fix specific degrees of freedom for the point. |
calculate_point_energy |
Calculate the internal energy of the point. |
Attributes:
| Name | Type | Description |
|---|---|---|
coordinates |
Tuple[float, float, float]
|
Retrieve the current position of the point. |
data |
List[float]
|
Retrieve point data for exporting. |
deformed_coordinates |
Tuple[float, float, float]
|
Retrieve the deformed position of the point. |
coordinates
property
¶
Retrieve the current position of the point.
Tuple[float, float, float]: (x, y, z) coordinates of the point.
data
property
¶
Retrieve point data for exporting.
List[float]: [index, x, y, z] of the point.
deformed_coordinates
property
¶
Retrieve the deformed position of the point.
Tuple[float, float, float]: (x, y, z) coordinates including displacements.
__init__(x, y, z, cell_belongings, node_uncertainty_SD=0.0)
¶
Parameters¶
x : float X-coordinate of the point.
float
Y-coordinate of the point.
float
Z-coordinate of the point.
List[Cell]
List of cells that contain this point.
float, optional
Standard deviation for node position uncertainty (default is 0.0).
Raises¶
ValueError If coordinates are not numeric or if node_uncertainty_SD is negative.
destroy()
¶
Remove all references to this point from connected beams and cells.
move_to(xNew, yNew, zNew)
¶
Move the point to new coordinates.
Parameters¶
xNew : float New x-coordinate.
float
New y-coordinate.
float
New z-coordinate.
tag_point(boundary_box_domain)
¶
is_identical_to(other, cell_size)
¶
is_on_boundary(boundary_box_lattice)
¶
distance_to(other)
¶
set_local_tag(cell_index, local_tag)
¶
Set the local tag for a specific cell containing the point.
Parameters:¶
cell_index : int Index of the cell. local_tag : int Local tag to assign to the point for the specified cell.
add_cell_belonging(cell)
¶
initialize_reaction_force()
¶
Reset the reaction force vector to zero.
initialize_displacement()
¶
Reset displacement values to zero for all DOF.
set_applied_force(appliedForce, DOF)
¶
Assign applied force to the point.
Parameters¶
appliedForce : List[float] Applied force values for each DOF.
list[int]
List of DOF to assign (0: x, 1: y, 2: z, 3: Rx, 4: Ry, 5: Rz).
set_reaction_force(reactionForce)
¶
Assign reaction force to the point.
Parameters¶
reactionForce : List[float] Reaction force values for each DOF.
attractor_lattice(lattice, PointAttractorList=None, alpha=0.5, inverse=False)
¶
Attract lattice to a specific point
Parameters:¶
PointAttractor: list of float in dim 3 Coordinates of the attractor point (default: None)
float
Coefficient of attraction (default: 0.5)
bool
If True, points farther away are attracted less (default: False)
curveLattice(lattice, center_x, center_y, center_z, curvature_strength=0.1)
¶
Curve the lattice structure around a given center.
Parameters:¶
center_x: float The x-coordinate of the center of the curvature.
float
The y-coordinate of the center of the curvature.
float
The z-coordinate of the center of the curvature.
float (default: 0.1)
The strength of the curvature applied to the lattice. Positive values curve upwards, negative values curve downwards.
cylindrical_transform(lattice, radius)
¶
Apply cylindrical transformation to the lattice structure. To create stent structures, 1 cell in the X direction is required and you can choose any number of cells in the Y and Z direction.
Parameters:¶
radii: float radii of the cylinder.
moveToCylinderForm(lattice, radius)
¶
fitToSurface(lattice, equation, mode='z', params=None)
¶
Adjust the lattice nodes to follow a surface defined by an equation.
Parameters:¶
equation : callable Function representing the surface. For example, a lambda function or a normal function. Example: lambda x, y: x2 + y2 (for a paraboloid).
str
Adjustment mode: - “z”: Adjust nodes on a surface (z = f(x, y)). - “z_plan”: Adjust nodes on a plan (z = f(x, y)) without changing the z-coordinate.
dict
Additional parameters for the equation or mode (e.g., radii, angle, etc.).
pyLatticeDesign.materials
¶
Classes:
| Name | Description |
|---|---|
MatProperties |
A class to represent the properties of a material loaded from a file. |
MatProperties
¶
A class to represent the properties of a material loaded from a file.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the MatProperties object by loading data from a file. |
load_material |
Loads material properties from a JSON file. |
pyLatticeDesign.plotting_lattice
¶
Classes:
| Name | Description |
|---|---|
Lattice |
Class to generate lattice structures with various parameters and properties. |
Cell |
Class representing a cell in the lattice structure. |
LatticePlotting |
Class for visualizing lattice structures in 3D. |
Functions:
| Name | Description |
|---|---|
_get_beam_color |
|
_prepare_lattice_plot_data |
|
plot_coordinate_system |
Plot a 3D coordinate system with arrows representing the X, Y, and Z axes. |
get_boundary_condition_color |
Generate a color based on the fixed DOFs using a bitmask approach. |
Lattice
¶
Bases: object
Class to generate lattice structures with various parameters and properties.
Methods:
| Name | Description |
|---|---|
__init__ |
Constructor from a JSON file to create a lattice object. |
open_pickle_lattice |
Load a lattice pickle and (optionally) upcast it to the caller’s class (e.g., LatticeSim). |
__eq__ |
Compare two Lattice objects based on the radii of each cell. |
get_number_cells |
Get number of cells in the lattice |
get_number_beams |
Get number of beams in the lattice |
get_number_nodes |
Get number of nodes in the lattice |
extract_parameters_from_json |
Extract lattice parameters from a JSON file and set the corresponding attributes. |
get_lattice_boundary_box |
Get the boundary box of the lattice |
define_lattice_dimensions |
Computes extremum values of coordinates in the lattice. |
get_relative_density |
Get mean relative density of all cells in lattice |
get_beam_radius_min_max |
Get the maximum and minimum radii of the lattice |
define_gradient |
Define gradient settings for radii, dimensions, and materials based on provided properties. |
generate_lattice |
Generate cells in the lattice structure based on cell size, number of cells, geometry types, and radii. |
cut_beam_with_mesh_trimmer |
Cut beams in the lattice using the mesh trimmer. |
apply_symmetry |
Apply symmetry to the lattice by mirroring cells across a specified plane. |
delete_beams_under_radius_threshold |
Delete beams with radii under a certain threshold |
set_tag_classification |
Define tag list classification. |
define_size_lattice |
Computes the size of the lattice along each direction. |
is_not_in_erased_region |
Check if the cell is not in the erased region or inside the mesh. |
define_beam_node_index |
Define index at each beam and node |
define_cell_index |
Define index at each cell |
define_node_local_tags |
Define inside cell boundary tag for all boundary nodes |
define_cell_neighbours |
Neighbour assignment using integer grid indices + optional periodic wrap. |
define_connected_beams_for_all_nodes |
Populate |
define_angles_between_beams |
Compute, for each beam, the penalization-optimal angle at its two endpoints |
refresh_cells_memberships |
Public helper to refresh all cells’ beams/points from the current global state. |
remove_cell |
Removes a cell from the lattice |
find_minimum_beam_length |
Find minimum beam length |
get_tag_list |
Get the tag for all unique points in the lattice. |
get_tag_list_boundary |
Get the tag for boundary points in the lattice. |
apply_tag_all_point |
Assign a tag to all nodes in the lattice structure. |
get_cell_occupancy_matrix |
Build a 3D matrix storing Cell objects (or None) at each (i, j, k). |
get_cells_at_index |
Get all cells at a specific index along a specified axis. |
get_relative_boundary_box |
Get the relative boundary box of a cell in the lattice. |
get_name_lattice |
Determine the name_lattice of the lattice |
check_hybrid_collision |
Check if beam in hybrid configuration is cut by a point in the geometry |
are_cells_identical |
Check if all cells in the lattice are identical. |
change_beam_radius |
Change beam radius for all beams in the lattice |
change_beam_radius_depending_type |
Change radii of beam for specific type_beam |
find_point_on_lattice_surface |
Find points on the surface of the lattice |
get_cells_on_surfaces |
Return the list of Cell objects matching ordered extrema constraints like [“Xmin”], [“Xmin”,”Zmax”], etc. |
print_statistics_lattice |
Print statistics about the lattice |
delete_orphan_points |
Delete points that are not connected to any beam in the lattice. |
merge_degree2_nodes |
Fusion of nodes with exactly 2 connected beams. |
delete_unconnected_beams |
Delete beams that are “leaf” beams, i.e. connected to at least one node of degree 1 or 0. |
generate_mesh_lattice_Gmsh |
Generate a 2D mesh representation of the lattice structure using GMSH. |
get_volume_mesh |
Compute the exact CAD volume (OCC ‘mass’ with unit density) of the current model |
get_relative_density_mesh |
Compute relative density = V_solid / V_domain using exact CAD volumes. |
generate_mesh_lattice_rough |
Generate a mesh of the lattice structure with Pyrough library. |
__init__(name_file, mesh_trimmer=None, verbose=0)
¶
Parameters:¶
name_file: str Name of the JSON file containing lattice parameters.
MeshTrimmer, optional
MeshTrimmer object to trim the lattice.
int, optional
Verbosity level for logging.
open_pickle_lattice(file_name='LatticeObject', sim_config=None)
classmethod
¶
Load a lattice pickle and (optionally) upcast it to the caller’s class (e.g., LatticeSim).
If the target class defines _post_load_init, it will be invoked after loading.
__eq__(other)
¶
Compare two Lattice objects based on the radii of each cell. Returns True if they have the same number of cells and identical radii values.
get_number_cells()
¶
Get number of cells in the lattice
get_number_beams()
¶
Get number of beams in the lattice
get_number_nodes()
¶
Get number of nodes in the lattice
extract_parameters_from_json(name_file)
¶
Extract lattice parameters from a JSON file and set the corresponding attributes.
Parameters:¶
name_file: str Name of the JSON file containing lattice parameters.
get_lattice_boundary_box()
¶
Get the boundary box of the lattice
define_lattice_dimensions()
¶
Computes extremum values of coordinates in the lattice.
Return:¶
lattice_dimension_dict: dict Dictionary containing min and max values for x, y, z coordinates.
get_relative_density()
¶
Get mean relative density of all cells in lattice Simple average of cell relative densities
Returns:¶
meanRelDens: float Mean relative density of the lattice
get_beam_radius_min_max()
¶
Get the maximum and minimum radii of the lattice
Returns:¶
radMax: float Maximum radii of the lattice
float
Minimum radii of the lattice
define_gradient(grad_radius_property, grad_dim_property, grad_mat_property)
¶
Define gradient settings for radii, dimensions, and materials based on provided properties.
Parameters:¶
grad_radius_property: list Properties defining the gradient for radii.
list
Properties defining the gradient for cell dimensions.
list
Properties defining the gradient for material settings.
generate_lattice()
¶
Generate cells in the lattice structure based on cell size, number of cells, geometry types, and radii. Gradient information and erased regions are also considered during cell generation.
cut_beam_with_mesh_trimmer()
¶
Cut beams in the lattice using the mesh trimmer.
apply_symmetry(symmetry_plane=None, reference_point=None)
¶
Apply symmetry to the lattice by mirroring cells across a specified plane.
Parameters:¶
symmetry_plane: str, optional Plane of symmetry (‘XY’, ‘XZ’, ‘YZ’, ‘X’, ‘Y’, or ‘Z’). If None, uses self.symmetry_lattice[‘sym_plane’].
tuple of float, optional
Reference point for the symmetry operation (x_ref, y_ref, z_ref). If None, uses self.symmetry_lattice[‘sym_point’].
delete_beams_under_radius_threshold(threshold=0.01)
¶
Delete beams with radii under a certain threshold
Parameters:¶
threshold: float Threshold value for beam radii
set_tag_classification()
¶
Define tag list classification.
define_size_lattice()
¶
Computes the size of the lattice along each direction.
is_not_in_erased_region(start_cell_pos)
¶
define_beam_node_index()
¶
Define index at each beam and node
define_cell_index()
¶
Define index at each cell
define_node_local_tags()
¶
Define inside cell boundary tag for all boundary nodes
define_cell_neighbours()
¶
Neighbour assignment using integer grid indices + optional periodic wrap.
define_connected_beams_for_all_nodes(merge_tol=1e-09)
¶
Populate Point.connected_beams for all nodes.
Optionally merges connectivity for coincident/periodic nodes via a spatial hash.
Parameters¶
merge_tol : float Quantization used to bucket nearly-identical coordinates (and periodic wraps).
define_angles_between_beams()
¶
Compute, for each beam, the penalization-optimal angle at its two endpoints
using node-level connectivity (Point.connected_beams). Assumes
define_connected_beams_for_all_nodes() has been called.
refresh_cells_memberships()
¶
Public helper to refresh all cells’ beams/points from the current global state.
remove_cell(index)
¶
find_minimum_beam_length()
¶
get_tag_list()
¶
Get the tag for all unique points in the lattice.
get_tag_list_boundary()
¶
Get the tag for boundary points in the lattice.
apply_tag_all_point()
¶
Assign a tag to all nodes in the lattice structure. Tags are assigned relative to either the global bounding box or a local (cell-relative) bounding box if erased parts are used.
get_cell_occupancy_matrix()
¶
Build a 3D matrix storing Cell objects (or None) at each (i, j, k).
Returns¶
occupancy_matrix : np.ndarray, shape (num_cells_x, num_cells_y, num_cells_z), dtype=object occupancy_matrix[i, j, k] is the Cell at that grid position, or None if empty.
get_cells_at_index(axis, index)
¶
Get all cells at a specific index along a specified axis.
Parameters:¶
axis: str Axis to query (‘x’, ‘y’, or ‘z’).
int
Index along the specified axis.
get_relative_boundary_box(cell)
¶
Get the relative boundary box of a cell in the lattice. It corresponds to the minimum and maximum dimension of the lattice for each axis with cell continuity. Useful for structures with erased parts or periodic boundaries.
Parameters:¶
cell: Cell object The cell for which the boundary box is computed.
get_name_lattice()
¶
check_hybrid_collision()
¶
Check if beam in hybrid configuration is cut by a point in the geometry Change the beam configuration of collisionned beams
are_cells_identical()
¶
Check if all cells in the lattice are identical.
change_beam_radius(radius_list)
¶
Change beam radius for all beams in the lattice radius_list must have the same length as the number of different beam types in cells
Take care if penalization is activated, the radius of penalized beams will be modified with the penalization coefficient but the length of the modified beam will not be changed (Use reset_cell_with_new_radii instead if you want to have clean cells for simulation)
Parameters:¶
radius_list: list of float List of new radii for each beam type
change_beam_radius_depending_type(typeToChange, newRadius)
¶
Change radii of beam for specific type_beam
Parameters:¶
typeToChange: int Type of beam to change newRadius: float New radii of beam
find_point_on_lattice_surface(surfaceNames, surface_cells=None)
¶
Find points on the surface of the lattice
Parameters:¶
surfaceNames: list[str] List of surfaces to find points on (e.g., [“Xmin”, “Xmax”, “Ymin”])
list[str], optional
List of surfaces to find points on cells (e.g., [“Xmin”, “Xmax”, “Ymin”]). If None, use surfaceNames.
Returns:¶
pointSet: set of point objects Set of points found on the specified surfaces
get_cells_on_surfaces(surfaces)
¶
Return the list of Cell objects matching ordered extrema constraints like [“Xmin”], [“Xmin”,”Zmax”], etc. Filtering is iterative: e.g., first keep all cells at X minimum, then among those keep Z maximum.
Parameters¶
surfaces : list[str] Each item is one of {“Xmin”,”Xmax”,”Ymin”,”Ymax”,”Zmin”,”Zmax”} (case-insensitive).
Returns¶
list List of Cell objects (possibly multiple if several share the same extreme index).
print_statistics_lattice()
¶
Print statistics about the lattice
delete_orphan_points()
¶
Delete points that are not connected to any beam in the lattice.
merge_degree2_nodes(colinear_only=True, radius_strategy='inherit', type_strategy='inherit', material_strategy='inherit', iterative=True, max_passes=10)
¶
Fusion of nodes with exactly 2 connected beams. The two beams must be colinear (if colinear_only=True) and the node must be between the two beam endpoints. The two beams are replaced by a single beam connecting the two distant endpoints.
Parameters:¶
colinear_only : bool If True, only merge if the two beams are colinear.
str
Strategy for determining the radius of the new beam: “inherit” (default) - if both beams have the same radius, use it; otherwise use b1’s radius. “max” - use the maximum radius of the two beams. “min” - use the minimum radius of the two beams. “avg” - use the average radius of the two beams.
str
Strategy for determining the type of the new beam: “inherit” (default) - if both beams have the same type, use it; otherwise use b1’s type. “max” - use the maximum type of the two beams. “min” - use the minimum type of the two beams. “avg” - use the average type of the two beams (rounded).
str
Strategy for determining the material of the new beam: “inherit” (default) - if both beams have the same material, use it; otherwise use b1’s material. “max” - use the maximum material of the two beams. “min” - use the minimum material of the two beams. “avg” - use the average material of the two beams (rounded).
bool
If True, repeat the merging process until no more merges are possible or max_passes is reached.
int
Maximum number of passes if iterative is True.
Returns:¶
total_merged : int Total number of nodes merged.
delete_unconnected_beams(protect_fixed=True, protect_loaded=True, also_delete_orphan_nodes=True)
¶
Delete beams that are “leaf” beams, i.e. connected to at least one node of degree 1 or 0.
Parameters:¶
protect_fixed: bool If True, do not delete beams connected to fixed nodes.
bool
If True, do not delete beams connected to loaded nodes.
bool
If True, delete nodes that become orphaned after beam removal.
Returns:¶
tuple[int, int] Number of beams removed and number of nodes removed.
generate_mesh_lattice_Gmsh(cut_mesh_at_boundary=False, mesh_refinement=1, name_mesh='Lattice', save_mesh=False, save_STL=True, volume_computation=False, only_volume=False, only_relative_density=False, cell_index=None)
¶
Generate a 2D mesh representation of the lattice structure using GMSH. Generating 3D mesh for simulation is not currently supported, but will be in the future.
Parameters:¶
cut_mesh_at_boundary: bool If True, the mesh will be cut at the boundary of the lattice.
float
Refinement factor for the mesh (higher values lead to finer meshes).
str
Name of the mesh to be generated.
bool
If True, the mesh will be saved to a file.
bool
If True, the mesh will be saved in STL format.
bool
If True, the volume of the mesh will be computed and printed.
bool
If True, only the volume of the mesh will be computed and returned.
bool
If True, only the relative density of the mesh will be computed and returned.
int | None
If provided, only the specified cell will be meshed.
get_volume_mesh(entities_3d=None, synchronize=True, return_details=False)
¶
Compute the exact CAD volume (OCC ‘mass’ with unit density) of the current model without requiring any meshing.
Parameters¶
entities_3d : list[(int,int)] | None Optional list of 3D OCC entities (pairs (dim=3, tag)). If None, all 3D entities in the current model are used.
bool
If True, call gmsh.model.occ.synchronize() before querying mass properties. Set to False only if you’ve already synchronized after your boolean ops.
bool
If True, return a dict with ‘total’ and ‘per_entity’ (list of (tag, volume)).
Returns¶
float | dict Total volume if return_details is False, else a dict:
get_relative_density_mesh(solids_3d=None, domain_volume=None)
¶
Compute relative density = V_solid / V_domain using exact CAD volumes.
If domain_volume is None, the domain is taken as the axis-aligned box defined by (x_min..x_max) × (y_min..y_max) × (z_min..z_max).
generate_mesh_lattice_rough(name_file_rough_parameters, name_stl_out, print_volume=True, save_mesh=True, cut_mesh_at_boundary=False, refine_mesh=True)
¶
Generate a mesh of the lattice structure with Pyrough library.
Parameters:¶
name_file_rough_parameters: str Name of the file containing roughness parameters for Pyrough. name_stl_out: str Name of the output STL file. print_volume: bool If True, print the volume of the generated mesh. save_mesh: bool If True, save the generated mesh to the specified path. cut_mesh_at_boundary: bool If True, cut the mesh at the boundary of the lattice. refine_mesh: bool If True, refine the generated mesh using Pyrough’s refinement function.
Cell
¶
Bases: object
Class representing a cell in the lattice structure.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Cell with its dimensions and position |
dispose |
Dispose of the cell by detaching beams and points, and cleaning up references. |
generate_cell_properties |
Generate cell properties including beams and nodes. |
generate_beams |
Generate beams and nodes using a given lattice type_beam and parameters. |
get_beam_material |
Get the material of the beam based on the material gradient. |
get_radius |
Calculate and return the beam radii |
def_cell_size |
Calculate and return the cell size |
def_cell_center |
Calculate the center point of the cell |
get_point_on_surface |
Get the points on the surface specified in the global reference frame. |
remove_beam |
Removing beam from cell |
remove_point |
Removing point from cell |
add_beam |
Adding beam to cell |
add_point |
Adding point to cell |
add_cell_neighbour |
Add a neighbour cell in a structured dict format. |
get_all_cell_neighbours |
Get all neighbour cells in a flat list. |
refresh_from_global |
Rebuild self.beams_cell and self.points_cell from the current lattice state. |
define_node_order_to_simulate |
Define a deterministic order for boundary nodes to ensure consistent simulation results. |
set_reaction_force_on_nodes |
Set reaction force on each boundary node in the established local order. |
get_displacement_at_nodes |
Return displacement vectors ordered consistently with the provided local list/dict of Points. |
set_displacement_at_boundary_nodes |
Set displacement at nodes. |
build_coupling_operator |
Build the coupling operator B using the deterministic local boundary-node order. |
build_local_preconditioner |
Build the local preconditioner matrix B^T * S * B |
get_number_boundary_nodes |
Get the number of unique boundary nodes in the cell. |
get_internal_energy |
Get cell internal energy from all boundary points |
get_displacement_data |
Build and return displacement data on cell for dataset generation |
get_number_nodes_at_boundary |
Get the number of nodes at the boundary |
change_beam_radius |
WARNING: BEAM MOD IS NOT WORKING |
get_relative_density_kriging |
Get the relative density of the cell using kriging model |
get_relative_density_gradient |
Get the gradient of the relative density |
get_relative_density_gradient_kriging |
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_relative_density_gradient_kriging_exact |
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained |
get_RGBcolor_depending_of_radius |
Get the RGB color of the cell depending on the radii. |
print_data |
Print the data of the cell for debugging purposes. |
get_translation_rigid_body |
Get the translation of the rigid body |
get_rotation_rigid_body |
Get the rotation matrix of the rigid body using SVD. |
Attributes:
| Name | Type | Description |
|---|---|---|
volume |
Calculate the volume of the cell. |
|
relative_density |
float
|
Calculate the relative density of the cell based on the volume of beams and the cell volume. |
volume_each_geom |
ndarray
|
Get the volume of the cell separated by geometry type_beam. |
boundary_box |
list
|
Get the boundary box of the cell |
boundary_edges |
list[tuple[tuple[float, float, float], tuple[float, float, float]]]
|
Return the 12 edge segments of the cell’s axis-aligned bounding box |
corner_coordinates |
list
|
Get the corner coordinates of the cell. |
volume
property
¶
Calculate the volume of the cell.
relative_density
property
¶
Calculate the relative density of the cell based on the volume of beams and the cell volume.
volume_each_geom
property
¶
Get the volume of the cell separated by geometry type_beam.
boundary_box
property
¶
boundary_edges
property
¶
Return the 12 edge segments of the cell’s axis-aligned bounding box as pairs of 3D points ((x,y,z), (x,y,z)).
corner_coordinates
property
¶
Get the corner coordinates of the cell.
Returns:¶
list of tuples List of (x, y, z) coordinates of the corner points.
__init__(pos, initial_size, coordinate, geom_types, radii, grad_radius, grad_dim, grad_mat, uncertainty_node=0.0, _verbose=0, beams_already_defined=None, nodes_already_defined=None)
¶
Parameters:¶
pos: list Position of the cell in the lattice
list
Initial size of the cell
list
Coordinates of the cell minimum corner in the lattice
list[str]
Type of lattice geometry
float
Base radii of the beam
list
Gradient of the radii
list
Gradient of the dimensions
list
Gradient of the material
float
Standard deviation for adding uncertainty to node coordinates. Defaults to 0.0.
bool
If True, prints additional information during initialization. Defaults to False.
set
Set of beams already defined in the lattice to avoid duplication. Defaults to None.
set
Set of nodes already defined in the lattice to avoid duplication. Defaults to None.
dispose()
¶
Dispose of the cell by detaching beams and points, and cleaning up references.
generate_cell_properties(initial_cell_size, beams_already_defined=None, nodes_already_defined=None)
¶
Generate cell properties including beams and nodes.
Parameters:¶
initialCellSize: list Initial size of the cell without modification
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
generate_beams(latticeType, beamRadius, beamType=0, beams_already_defined=None, nodes_already_defined=None)
¶
Generate beams and nodes using a given lattice type_beam and parameters.
Parameters:¶
latticeType: str Type of lattice structure (e.g., ‘BCC’, ‘Hybrid1’, etc.)
float
Radius of the beam
int
Type index of the beam
set
Set of beams already defined in the lattice to avoid duplication
set
Set of nodes already defined in the lattice to avoid duplication
get_beam_material()
¶
Get the material of the beam based on the material gradient.
get_radius(base_radius)
¶
def_cell_size(initial_cell_size)
¶
def_cell_center()
¶
Calculate the center point of the cell
get_point_on_surface(surfaceName)
¶
Get the points on the surface specified in the global reference frame.
Parameters:¶
surfaceName: str Name of the surface. Choose from ‘Xmin’, ‘Xmax’, ‘Ymin’, ‘Ymax’, ‘Zmin’, ‘Zmax’, ‘Xmid’, ‘Ymid’, ‘Zmid’. If ‘Xmid’, ‘Ymid’, or ‘Zmid’ is specified, it returns the points at the bottom of the cell
Returns:¶
list List of points on the specified surface.
remove_beam(beam_to_delete)
¶
Removing beam from cell
Parameters:¶
beam_to_delete: Beam or Iterable[Beam] Beam or list of beams to remove from the cell
remove_point(point_to_delete)
¶
Removing point from cell
Parameters:¶
point_to_delete: Point or Iterable[Point] Point or list of points to remove from the cell
add_beam(beam_to_add)
¶
Adding beam to cell
Parameters:¶
beam_to_add: Beam or Iterable[Beam] Beam or list of beams to add to the cell
add_point(point_to_add)
¶
Adding point to cell
Parameters:¶
point_to_add: Point or Iterable[Point] Point or list of points to add to the cell
add_cell_neighbour(direction, sign, neighbour_cell)
¶
Add a neighbour cell in a structured dict format.
Parameters¶
direction : str One of “x”, “y”, “z” sign : str Either “positif” or “negatif” neighbour_cell : Cell Neighbour cell to add
get_all_cell_neighbours()
¶
refresh_from_global(all_beams)
¶
Rebuild self.beams_cell and self.points_cell from the current lattice state. Keeps only beams that still declare this cell as a belonging, and derives points from those beams.
define_node_order_to_simulate(face_priority=None, tol=1e-09)
¶
Define a deterministic order for boundary nodes to ensure consistent simulation results.
Parameters:¶
face_priority: Optional[List[str]] List defining the priority order of faces to assign nodes to when they lie on multiple faces. Default is [“Xmin”, “Xmax”, “Ymin”, “Ymax”, “Zmin”, “Zmax”].
float
Tolerance for determining if a point lies on a face. Default is 1e-9.
set_reaction_force_on_nodes(reactionForce)
¶
Set reaction force on each boundary node in the established local order.
Parameters:¶
reactionForce: list List of reaction force vectors corresponding to each boundary node.
get_displacement_at_nodes(nodeList)
¶
set_displacement_at_boundary_nodes(displacementArray)
¶
Set displacement at nodes.
Parameters:¶
displacementArray: list or array-like Flattened array of displacement values.
build_coupling_operator(nb_free_DOF)
¶
Build the coupling operator B using the deterministic local boundary-node order.
Parameters:¶
nb_free_DOF: int Total number of free degrees of freedom in the global system.
build_local_preconditioner(schur_mean=None)
¶
Build the local preconditioner matrix B^T * S * B
Parameters:¶
schur_mean: array-like or None Schur complement matrix to use. If None, uses self.schur_complement.
get_number_boundary_nodes()
¶
Get the number of unique boundary nodes in the cell.
get_internal_energy()
¶
Get cell internal energy from all boundary points
get_displacement_data()
¶
Build and return displacement data on cell for dataset generation
get_number_nodes_at_boundary()
¶
change_beam_radius(new_radius)
¶
WARNING: BEAM MOD IS NOT WORKING Change beam radii in the cell
Parameters:¶
newRadius: list beam radii wanted to assign
get_relative_density_kriging(kriging_model)
¶
Get the relative density of the cell using kriging model
Parameters:¶
krigingModel: Kriging Kriging model to use for prediction
get_relative_density_gradient(relative_density_poly_deriv)
¶
get_relative_density_gradient_kriging(model, geometries_types)
¶
Finite difference gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel. Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
get_relative_density_gradient_kriging_exact(model, geometries_types)
¶
Exact gradient of the relative density (predictive mean) w.r.t. the radii using the trained Pipeline(StandardScaler -> GaussianProcessRegressor) with Constant*RBF kernel.
Returns an array of size len(geometries_types) where entries for geometries not present in the cell are 0.
Parameters:¶
model: Pipeline Trained kriging model
list
List of geometry types in the trained kriging model
get_RGBcolor_depending_of_radius()
¶
Get the RGB color of the cell depending on the radii.
print_data()
¶
Print the data of the cell for debugging purposes.
get_translation_rigid_body()
¶
Get the translation of the rigid body
get_rotation_rigid_body()
¶
Get the rotation matrix of the rigid body using SVD.
LatticePlotting
¶
Class for visualizing lattice structures in 3D.
Methods:
| Name | Description |
|---|---|
init_figure |
Initialize the 3D figure for plotting. |
visualize_lattice |
Visualizes the lattice in 3D using matplotlib. |
visualize_lattice_voxels |
Visualizes the lattice in voxel mode. |
visual_cell_zone_blocker |
Visualize the lattice with erased parts |
plot_radius_distribution |
Plot the radii distribution of beams in the lattice. |
subplot_lattice_hybrid_geometries |
Create subplots for each geometry in a hybrid lattice structure. |
init_figure()
¶
Initialize the 3D figure for plotting.
visualize_lattice(lattice_object, beam_color_type='radii', deformed_form=False, file_save_path=None, cell_index=False, node_index=False, domain_decomposition_simulation_plotting=False, enable_system_coordinates=True, enable_boundary_conditions=False, camera_position=None, plotting=True)
¶
Visualizes the lattice in 3D using matplotlib.
Parameters:¶
lattice_object: Lattice The lattice object to visualize.
str, optional (default: “radii”)
Color scheme for beams. Options: - “radii” or “radius”: Color by radii. - “material”: Color by material. - “type”: Color by type_beam.
bool, optional (default: False)
If True, use deformed node positions.
str, optional
If provided, save the plot with this file path.
bool, optional (default: False)
If True, plot cell indices.
bool, optional (default: False)
If True, plot node indices.
bool, optional (default: False)
If True, indicates that the lattice is part of a domain decomposition simulation.
bool, optional (default: True)
If True, plot the coordinate system axes.
bool, optional (default: False)
If True, visualize boundary conditions on nodes.
Tuple[float, float], optional
If provided, set the camera position for the 3D plot as (elevation, azimuth).
bool, optional (default: True)
If True, display the plot after creation.
visualize_lattice_voxels(lattice_object, beam_color_type='material', explode_voxel=0.0, cell_index=False, enable_system_coordinates=True, camera_position=None, file_save_path=None, plotting=True)
¶
Visualizes the lattice in voxel mode.
Parameters:¶
lattice_object: Lattice The lattice object to visualize.
str, optional (default: “Material”)
Color scheme for voxels. Options: - “Material”: Color by material. - “Type”: Color by type_beam. - “radii”: Color by radii.
float, optional (default: 0.0)
Amount to offset voxels for better visibility.
bool, optional (default: False)
If True, plot cell indices.
bool, optional (default: False)
If True, color voxels based on a gradient of their radii.
bool, optional (default: True)
If True, plot the coordinate system axes.
Tuple[float, float], optional
If provided, set the camera position for the 3D plot as (elevation, azimuth).
str, optional
If provided, save the plot with this file path.
bool, optional (default: True)
If True, display the plot after creation.
visual_cell_zone_blocker(lattice, erasedParts)
¶
Visualize the lattice with erased parts
Parameters:¶
eraser_blocks: list of tuple List of erased parts with (x_start, y_start, z_start, x_dim, y_dim
plot_radius_distribution(lattice_object, nb_radius_bins=5)
staticmethod
¶
Plot the radii distribution of beams in the lattice.
Parameters:¶
lattice_object: Lattice The lattice object containing the cells and beams.
int, optional (default: 5)
Number of bins to use for the histogram.
subplot_lattice_hybrid_geometries(lattice, explode_voxel=0.0)
¶
Create subplots for each geometry in a hybrid lattice structure.
_get_beam_color(beam, color_palette, beamColor, idxColor, cells, nbRadiusBins=5)
¶
_prepare_lattice_plot_data(beam, deformedForm=False)
¶
plot_coordinate_system(ax)
¶
Plot a 3D coordinate system with arrows representing the X, Y, and Z axes.
get_boundary_condition_color(fixed_DOF)
¶
Generate a color based on the fixed DOFs using a bitmask approach.
pyLatticeDesign.timing
¶
Classes:
| Name | Description |
|---|---|
Timing |
General-purpose timing & call-graph collector. |
Functions:
| Name | Description |
|---|---|
_dd_float |
|
Attributes:
| Name | Type | Description |
|---|---|---|
timing |
|
timing = Timing()
module-attribute
¶
Timing
¶
General-purpose timing & call-graph collector.
Methods:
| Name | Description |
|---|---|
category |
Decorator to tag functions with a category (e.g., ‘sim’, ‘mesh’, ‘io’). |
timeit |
Decorator to time execution and populate timings + call graph. |
summary |
Print a filtered, aligned summary with truncated names. |
category(label)
¶
Decorator to tag functions with a category (e.g., ‘sim’, ‘mesh’, ‘io’). Use together with @timeit to enable grouped summaries.
timeit(func)
¶
Decorator to time execution and populate timings + call graph.
summary(classes=None, name_pattern=None, max_depth=None, min_total=0.0, top_n=None, print_children=True, name_width=40, group_by_category=False)
¶
Print a filtered, aligned summary with truncated names.
Parameters¶
classes : Optional[Iterable[str]] If provided, only include functions whose qualified names start with one of these class names.
Optional[str]
If provided, only include functions whose qualified names match this regex pattern.
Optional[int]
If provided, only include functions up to this depth in the call graph.
float
Minimum total time (in seconds) to include a function in the report.
Optional[int]
If provided, only include the top N functions by total time.
bool
If True, print child functions under each parent in the call graph.
int
Maximum width for function names; longer names will be truncated with an ellipsis.
bool
If True, group functions by their assigned category (using the @category decorator).