Mads B
Mads B

Reputation: 65

Problem getting volume of assembly in Abaqus by python script

I need to find the volume of a shell model in Abaqus by python scripting before analysis, hence before the .odb file is available.

I know this is possible in CAE by the Query tool with Mass properties. This should also be possible by scripting with getMassProperties()['volume'] (e.g. mdb.models['Model'].rootAssembly.getMassProperties()['volume']). However, this is the problem, since this does not work properly.

If I just use getMassProperties() in the command window I get the following result:

>>> mdb.models['MainModel'].rootAssembly.getMassProperties()
{'volume': None, 'massFromMassPerUnitSurfaceArea': None, 'area': 11975.8517821263, 'volumeCentroid': (None, None, None), 'warnings': (ZERO_DENSITY, MISSING_SECTION_DEFINITION), 'momentOfInertia': (None, None, None, None, None, None), 'centerOfMass': (None, None, None), 'mass': None, 'areaCentroid': (-1.16289328510922e-16, -2.06018531309507, 37.4999999999999)}

Hence no volume is found.

However, if I first use the Query tool and Mass properties in CAE, and find the volume to 0.00286 (see image), then the above scripting works (the value is somehow stored). Query tool to find volume

After use of the Query tool, then the result is

>>> mdb.models['MainModel'].rootAssembly.getMassProperties()
{'volume': 0.063598067897832, 'massFromMassPerUnitSurfaceArea': None, 'area': 11975.8517821263, 'volumeCentroid': (0.0, -2.01943926098974, 37.5), 'warnings': (MISSING_DENSITY, ZERO_DENSITY, MISSING_SECTION_DEFINITION), 'momentOfInertia': (None, None, None, None, None, None), 'centerOfMass': (None, None, None), 'mass': None, 'areaCentroid': (1.02383557403908e-16, -2.06018531309506, 37.4999999999999)}

hence, now the volume is available!!!

The problem is, that the getMassProperties() only works after user interaction in CAE, hence it is not suitable for use in a python script without user interaction.

How can the above problem be solved? Or how can the volume be found by another scripting solution?

(The shown model is a simple example, however the actual model has advanced geometry, hence the volume is not straight forward to compute by simple math).

Thank you in advance.

Upvotes: 0

Views: 970

Answers (1)

yanfeng39
yanfeng39

Reputation: 26

You need to add the following:

assembly=mdb.models[modelName].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=assembly)

before:

weight=assembly.getMassProperties()['mass']

Upvotes: 1

Related Questions