MbdLoads (hwx.inspire.motion)#
- class MbdLoads(part, analysis=None)#
Bases:
list
Loads (forces, torques, accelerations) from an MbdAnalysis that are applied to a part (parts if in a Rigid Group or ground) at specified time steps.
The forces will sum to 0 at each time step. They are used to create load cases for Inspire FE Optimize & Analyze.
- Generate loads for part using the current MbdAnalysis
loads = MbdLoads (part)
- Filter loads to contain peak force time steps between 1 and 10 seconds
peaks = loads.timeSlice(1, 10).peaks ()
- Add in every 5 time steps
loads = loads[::5] + peaks
- Generate load cases, write to csv
loads.createLoadCases () loads.writeCsv (‘test.csv’)
# Name
Type
frames
property
times
property
# Name
Description
analyzePart
(self, sumAtRegion=False, params={}, runOptions={})Run an OptiStructAnalysis using loads.
copy
(self, items=None)Create a copy of self containing the passed items
countLoadCases
(self, **kwds)How many load cases will be created
createLoadCases
(self, deactivateRest=False, **kwds)Create inspire LoadCases out of the load data.
evenlySpaced
(self, numSamples, includeBounds=True)Returns a filtered set of loads.
filter
(self, filter)Filter time steps using filter function
getChannels
(self, load, components)Get run data for a load at every timeStep
getObjectLoads
(analysis=None, forDrawing=True)optimizePart
(self, sumAtRegion=False, params={}, runOptions={})Run a TopologyOptimization using loads.
peaks
(self, peaksPerComp=5, components=’FX FY FZ FM TX TY TZ TM’, forceThreshold=1e-05, torqueThreshold=0.001)Returns a filtered set of loads. For each joint, ‘peaksPerComp’ peaks
timeSlice
(self, start=None, end=None)Get all time steps between a start and end time inclusive
writeCsv
(self, file, wrtDesignPos=False)Write loads to csv file
Example
from hwx import inspire from hwx.inspire import motion import tempfile model = inspire.openTutorialFile("Motion/M01_FourBar.stmod") analysis = motion.MbdAnalysis() analysis.analyze(end=1, dtout=1/5) # Generate loads for part using the current MbdAnalysis # Loads are all the forces/torques on a specific part part = model.getChild('Link Single Slot') loads = motion.MbdLoads(part, analysis) # Filter loads to contain peak force in time steps between 1 and 10 seconds peaks = loads.timeSlice(1, 10).peaks(peaksPerComp=1, components="FM") print("Peak Force FM is at time = {}, at frame = {}".format( peaks[0].time, peaks[0].frame)) for key, vals in peaks[0].loads.items(): print("For '{}' -> Loads are: ".format(key)) print(vals) # Generate load cases, write to csv print("There will be generated {} load cases".format(loads.countLoadCases())) # Create Forces, Torques, Accelerations at each time step loads.createLoadCases() # write load cases in a csv file = tempfile.gettempdir()+'/test.csv' loads.writeCsv(file) with open(file) as f: print(f.read())
- createLoadCases(deactivateRest=False, **kwds)#
Create inspire LoadCases out of the load data.
- countLoadCases(**kwds)#
How many load cases will be created so we can warn the user if there are a lot
- writeCsv(file, wrtDesignPos=False)#
Write loads to csv file
- wrtDesignPos Means force / torque directions will be transformed to the
parts model position.
- analyzePart(sumAtRegion=False, params={}, runOptions={})#
Run an OptiStructAnalysis using loads.
- Parameters:
sumAtRegion (bool) – use a Summed at Contact Region representation of the contact forces instead of the individual contact forces themselves.
params (dict) – See OptiStructAnalysis.Params.
runOptions (dict) – See OptiStructAnalysis.RunOptions.
- Returns:
The synthesis with results.
- Return type:
- optimizePart(sumAtRegion=False, params={}, runOptions={})#
Run a TopologyOptimization using loads.
- Parameters:
sumAtRegion (bool) – use a Summed at Contact Region representation of the contact forces instead of the individual contact forces themselves.
params (dict) – See TopologyOptimization.Params.
runOptions (dict) – See TopologyOptimization.RunOptions.
- Returns:
The synthesis with results.
- Return type:
- getChannels(load, components)#
Get run data for a load at every timeStep
- filter(filter)#
Filter time steps using filter function
- evenlySpaced(numSamples, includeBounds=True)#
Returns a filtered set of loads. Try to evenly space the output steps There should not be any contact frames
includeBounds == False will give evenly spaced time steps, but may or not not include the start/end time
includeBounds == True will include the start/end time but loads will not not be exactly evenly if the numSamples does not divide evenly into the number of timeSteps. In this case we try to get as evenly spaced as possible
- peaks(peaksPerComp=5, components='FX FY FZ FM TX TY TZ TM', forceThreshold=1e-05, torqueThreshold=0.001)#
Returns a filtered set of loads. For each joint, ‘peaksPerComp’ peaks are gathered per requested component. The consolidated list of these values are returned removing duplicates.
The values at the start and end times are considered peaks since they might be a min/max value.
Peaks whose absolute value is < forceThreshold / torqueThreshold (in base units) are ignored
- timeSlice(start=None, end=None)#
Get all time steps between a start and end time inclusive
- copy(items=None)#
Create a copy of self containing the passed items