GLoad (hwx.inspire)#

class GLoad(location, direction, magnitude=None, **kwds)#

Bases: BoundaryCondition

BoundaryCondition object storing g-load direction and magnitude.

Absence of a GLoad object in a LoadCase signifies no g-load. GLoads are used to simulate a model undergoing acceleration, which imparts a force on all of the parts in the model.

Attribute Table#

Name

Type

magnitude

Double

Example

from hwx import inspire
# Start with an empty model
model = inspire.newModel()
# Alternatively, you can get an existing model
# model = inspire.getModel()

block = model.createSolidBlock(x=1,y=1,z=1)
# Make the block transparent
block.SetTransparency(0.9)

# apply gload
gLoad = inspire.GLoad(location=(0.5, 0.0, 0.5), direction=(0.0, 1.0, 0.0), 
magnitude= 10, loadCase='current')

print("Some GLoad values:")
print("Location:", gLoad.location)
print("Direction:", gLoad.direction)
print("Magnitude:", gLoad.magnitude)

# modify some pressure attributes
gLoad.location = block.location
gLoad.direction = (0.0, 0.0, 1.0)
gLoad.SetMagnitude(50.0, "MKS")

print("GLoad values after modification:")
print("Location:", gLoad.location)
print("Direction:", gLoad.direction)
print("Magnitude:", gLoad.magnitude)

# How to make the gLoad parametric
# Add a model variable for gLoad magnitude
model.variables.add(name="gLoadMagnitude", type='Acceleration', expression=10)
# Assign the variable to the gLoad magnitude
gLoad.magnidute = "gLoadMagnitude"

# How to modify the gLoad magnitude variable
model.variables.update(name="gLoadMagnitude", expression=20)
# How to change the gLoad magnitude with a string with units
gLoad.magnitude = "20 m/s2"

# How to query the existing gLoads from the model
existing_gLoads = model.getChildren(type='GLoad')
print("Existing gLoads in the model:")

for gLoad in existing_gLoads:
    print(f"	GLoad at {gLoad.location}, direction: {gLoad.direction}, "
    f"magnitude: {gLoad.GetMagnitude()}")
# How to query the gLoad by its name
gLoad_by_name = model.getChild(type='GLoad', name='GLoad 1')

if gLoad_by_name:
    print("Queried gLoad by name:") 
    print(f"	GLoad at {gLoad_by_name.location}, direction: {gLoad_by_name.direction}, "
    f"magnitude: {gLoad_by_name.GetMagnitude()}")

inspire.orientView(direction="isometric")
property magnitude#

The magnitude of the GLoad.