-
Notifications
You must be signed in to change notification settings - Fork 9
Feature strut lattice #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Use scipy Rotation object instead of euler angles array
* boolean operations with vtk are too poorly managed, and could not make cadquery's toVtkPolyData method work * also update __init__
* setup strut_number and strut_heights for fixed implemented lattice and for custom lattice created by user * implement input checks
for predefined lattice classes
due to an unknown issue when meshing struts that intersect two opposing faces of the boundary cube
Minor adjustments to ensure correct density calculation for the strut lattice when the cell size exceeds 1
|
|
||
| computed_radius = root_scalar( | ||
| lambda radius: float(calc_density(radius)) - self.density, | ||
| bracket=[10e-4, 1.0 * self.cell_size], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a comment explaining what are you trying to do here may be helpful for maintenance and readability, also putting the magic number 10e-4 in a variable with a self explanatory name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments have been added to explain the computed_radius
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10e-4 the magic number may indicate a tolerance ? If it does it would be worthy to store it un a variable with that name. Same applies for 1.0 * self.cell_size
|
|
||
| computed_radius = root_scalar( | ||
| lambda radius: float(calc_density(radius)) - self.density, | ||
| bracket=[10e-4, 1.0 * self.cell_size], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments have been added to explain the computed_radius
| def _generate_strut_vertex_pairs(self) -> npt.NDArray[np.int64]: | ||
| tree = KDTree(self.base_vertices) | ||
| pairs = set() | ||
| tolerance = 1e-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tolerance could be a named constant ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tolerance value could be passed as parameter ? Or be added as a member of the abstract class AbstractLattice ? If it is required for each of the derived classes ? @ylgrst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have passed it to UPPER_CASE but as for extracting the constant, I am not sure whether to make it a class constant for AbstractLattice (because not all daughter classes use the constant) or general constant in the abstract_lattice.py file that I can then import when needed in the right daughter classes.
For now i have chosen this second option, what do you think would be the best practice?
| def _generate_strut_vertex_pairs(self) -> npt.NDArray[np.int64]: | ||
| tree = KDTree(self.base_vertices) | ||
| pairs = set() | ||
| tolerance = 1e-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tolerance = 1e-5 could be a named constant?
|
|
||
| def _generate_strut_vertex_pairs(self) -> npt.NDArray[np.int64]: | ||
| tree = KDTree(self.base_vertices) | ||
| tolerance = 1e-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tolerance = 1e-5 could be a named constant?
| def _generate_strut_vertex_pairs(self) -> npt.NDArray[np.int64]: | ||
| """Generate index pairs representing the struts in the truncated octahedron.""" | ||
| tree = KDTree(self.base_vertices) | ||
| tolerance = 1e-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tolerance = 1e-5 could be a named constant?
ricardo0115
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! , this PR includes a flexible API to generate Strut Lattice structures.
|
|
||
| computed_radius = root_scalar( | ||
| lambda radius: float(calc_density(radius)) - self.density, | ||
| bracket=[10e-4, 1.0 * self.cell_size], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10e-4 the magic number may indicate a tolerance ? If it does it would be worthy to store it un a variable with that name. Same applies for 1.0 * self.cell_size
| def _generate_strut_vertex_pairs(self) -> npt.NDArray[np.int64]: | ||
| tree = KDTree(self.base_vertices) | ||
| pairs = set() | ||
| tolerance = 1e-5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tolerance value could be passed as parameter ? Or be added as a member of the abstract class AbstractLattice ? If it is required for each of the derived classes ? @ylgrst
Description
This branch adds strut-based lattice to Microgen. 12 pre-set lattice have been implemented:
BodyCenteredCubicFaceCenteredCubicCubicOctahedronCuboctahedronDiamondOctetTrussRhombicCuboctahedronRhombicDodecahedronTruncatedCubeTruncatedCuboctahedron(aka Kelvin lattice)TruncatedOctahedronAn
AbstractLatticeclass has also been implemented to let the user define their own strut-based lattice, by providing the coordinates of the lattice's vertices, and the pairs of vertex indices forming the strutsExamples
Examples have been added:
examples/Lattices/preset_lattice.pyplots the 12 preset lattice listed before.examples/Lattices/custom_lattice.pyillustrates how a user can define their own strut-based lattice, here an auxetic lattice based on this paper.Tests
Tests are written in
test_lattice.pyusing data fromtest_lattice_utils.py. This data basically corresponds to the expected vertices, strut centers and cartesian orientation coordinates. This ensures_compute_vertices,_compute_strut_centers,_compute_strut_directionswork as expected.