Wiki

Clone wiki

strupy / units

###Description This is module that define units SI system using in StruPy - it is based on Unum package.

Available units - ['GPa', 'J', 'MPa', 'N', 'Nm', 'Pa', 'cm', 'cm2', 'cm3', 'cm4', 'kN', 'kNm', 'kPa', 'kg', 'm', 'm2', 'm3', 'm4', 'mm', 'mm2', 'mm3', 'mm4', 's']


###Source code >>>


###Use examples

In [1]: import strupy.units as u

In [2]: a = 3*u.mm

In [3]: b = 10*u.mm

In [4]: c = a * b 

In [5]: c
Out[5]: 30.00 [mm2]

In [6]: c.asUnit(u.cm2)
Out[6]:  0.30 [cm2]

In [7]: F = 400 * u.kN

In [8]: A = 0.4*u.m * 390*u.mm

In [9]: A
Out[9]:  0.16 [m2]

In [10]: Sigma = F / A

In [11]: Sigma
Out[11]: 2564.10 [kN/m2]

In [12]: Sigma.asUnit(u.MPa)
Out[12]:  2.56 [MPa]

or you can import all units directly to your name space (but then name conflicts possible during your calculation)

In [1]: from strupy.units import *

In [2]: a = 20 * mm

In [3]: b = 30 * mm

In [4]: a * b
Out[4]: 600.00 [mm2] 

| up | | Home page |

Updated