Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Polar mass moment of inertia - diagonalize matrix

Hi

New to FS but not to OnShape.

I tried to write a FS to get the polar MMI of a part, since most of what we design is axisymmetric, the only term in the diagonal matrix not equal to the other two is the polar MMI. However when the part's axis of revolution is not X, Y or Z, then I need to diagonalize the matrix first.

I found the svd function, where matrix.s seems to contain what I need. However I dont understand how to do it and the debug tool is not very helpful... can you help me adjust the code? Thanks

<div><i>FeatureScript 2260;</i></div><div><i>import(path : "onshape/std/common.fs", version : "2260.0");</i></div><div><br></div><div><i>annotation { "Property Function Name" : "computePMMI" }</i></div><div><i>export const computePMMI = defineComputedPartProperty(function(context is Context, part is Query, definition is map) returns ValueWithUnits // (or string or number or boolean)</i></div><div><i>&nbsp; &nbsp; // definition is an empty map and reserved for future use</i></div><div><i>&nbsp; &nbsp; {</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; // Compute and return the property value, using the context and parameters</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; var massProperties = evApproximateMassProperties(context, {</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entities" : part,</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "density" : 7850 * kilogram / meter ^ 3</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</i></div><div><br></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; var MMIArray = [get(massProperties.inertia, 0, 0), get(massProperties.inertia, 1, 1), get(massProperties.inertia, 2, 2)];</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; //set output value to 0 if none of below comparisons is true</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; var MMIOutput = 0*kilogram*meter^2;</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; //If a part is axisymmetric the two MMI will be equal. The one not equal will be the polar MMI. If no equal couple is found, then the part is not axisymmetric</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; if (tolerantEquals(MMIArray[0],MMIArray[1]))</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; {</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MMIOutput=MMIArray[2];</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; }</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; if (tolerantEquals(MMIArray[0],MMIArray[2]))</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; {</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MMIOutput=MMIArray[1];</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; }</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; if (tolerantEquals(MMIArray[1],MMIArray[2]))</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; {</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MMIOutput=MMIArray[0];</i></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; }</i></div><div><br></div><div><i>&nbsp; &nbsp; &nbsp; &nbsp; return MMIOutput;</i></div><div><i>&nbsp; &nbsp; });</i></div>


See document https://sulzer.onshape.com/documents/b8a5032af290a31e1e6b7f07/w/3f9461911330a70bea798aa7/e/4e7d51cf481630a9996b4587?renderMode=0&rightPanel=customTablePanel&uiState=65cd90d67996d964c6f5618c

Answers

  • nicolas_lagas_Sulzernicolas_lagas_Sulzer Member Posts: 5 PRO
    Or maybe is there a way to get the principals directly?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    I'm not sure about the MMI specifics, but if you need to diagonalize a symmetric matrix, the svd function will do that.  The only issue is that the returned inertia matrix from evApproximateMassProperties is a MatrixWithUnits, which the svd won't take, so you'll need to call svd(massProperties.inertia / (kilogram/meter^2)).s to get the diagonal matrix
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.