COGConstraint (hwx.inspire)#

class COGConstraint(ents, **kwds)#

Bases: BoundaryCondition

Create the Center of Gravity Constraint (COG) of supplied parts.

Use the Center of Gravity Constraint (COG) to apply, reposition, and set upper and lower bounds for a center of gravity constraint. COG constraints are used to limit the position of the center of gravity while running a topology optimization.

Attribute Table#

Name

Type

bounds

property

position

property

Example

from hwx import inspire
from hwx.common.math import Matrix44, Vector

model = inspire.openTutorialFile("Structures/Quadcopter.stmod")
model.autoColorParts()

cog = inspire.COGConstraint(model.parts)
print("COG Constraint is placed at {}".format(cog.location))
print("COG Constraint bounds are {}".format(cog.bounds))

# change position
cog.position = Matrix44(origin=cog.location + Vector(0.015, 0.015, 0.015))
print(f"After changing position, COG Constraint is placed at {cog.location}")

# change bounds
cog.bounds = [0.2, -0.15] * 3
print(f"After changing bounds, COG Constraint bounds are {cog.bounds}")

# disable upper bound in X Axis, Y Axis and Z Axis
# check property editor to see the change
cog.bounds = [0.2, None] * 3
property position#

A Matrix44 of X, Y and Z directions of COG and the current position, defaults to math.Matrix44(origin=getCenterOfGravity(ents))

property bounds#

A list of the lower and upper bound values in X, Y and Z directions for COG during optimization, defaults to [-0.1, 0.1, -0.1, 0.1, -0.1, 0.1]. If None is specified in a position (e.g. [None, -0.1, None, None, None, None]) then this direction is inactive.