fib-international / structuralcodes

A Python library for structural engineering calculations
https://fib-international.github.io/structuralcodes/
Apache License 2.0
108 stars 22 forks source link

fix: use also relative tolerance when checking calculated Iyz #191

Closed mortenengen closed 1 month ago

mortenengen commented 1 month ago

In our calculation of the cross moment Iyz for generic sections, we raise a RuntimeError if the two ways of calculating the moment does not result in values that are close enough. In the current version we check only the absolute value of these results, but this is too strict if the section has a value of the cross moment significantly different from zero.

This is an attempt to liberalize the check by introducing a relative check in addition by using the math.isclose function. The absolute tolerance used in isclose is rather liberal, but the value is kept equal to the existing implementation.

Although beyond the scope of the PR, I have also changed math.sin and math.cos to the numpy versions of the functions to have a cleaner import block.