UnitSystem

class opstool.pre.UnitSystem(length='m', force='kn', time='sec')[source]

Bases: object

A class for unit conversion.

Parameters

length: str, default=”m”

Length unit base. Optional [“inch”, “ft”, “mm”, “cm”, “m”, “km”].

force: str, default=”kN”

Force unit base. Optional [“lb”(“lbf”), “kip”, “n”, “kn”, “mn”, “kgf”, “tonf”].

time: str, default=”sec”

Time unit base. Optional [“sec”].

Note

  • Mass and stress units can be automatically determined based on length and force units, optional mass units include [“mg”, “g”, “kg”, “ton”(“t”), “slug”], and optional stress units include [“pa”, “kpa”, “mpa”, “gpa”, “bar”, “psi”, “ksi”, “psf”, “ksf”].

  • You can enter any uppercase and lowercase forms, such as kn and kN, mpa and MPa are equivalent.

  • You can add a number (int) after the unit to indicate a power, such as m3 for m*m*m.

Methods

get_unit_ratio

print

Show all unit conversion coefficients with colorful output

Attributes

force

length

time

print()[source]

Show all unit conversion coefficients with colorful output