物理量#
物理量。
- class sympy.physics.units.quantities.Quantity(name, abbrev=None, latex_repr=None, pretty_unicode_repr=None, pretty_ascii_repr=None, mathml_presentation_repr=None, is_prefixed=False, **assumptions)[源代码]#
物理量:可以是度量单位,常量或通用量。
- property abbrev#
表示单元名称的符号。
如果已定义,则在缩写前面加上前缀符号。
- convert_to(other, unit_system='SI')[源代码]#
将该数量转换为另一个相同尺寸的数量。
实例
>>> from sympy.physics.units import speed_of_light, meter, second >>> speed_of_light speed_of_light >>> speed_of_light.convert_to(meter/second) 299792458*meter/second
>>> from sympy.physics.units import liter >>> liter.convert_to(meter**3) meter**3/1000
- property free_symbols#
从数量中返回免费符号。
- property is_prefixed#
Whether or not the quantity is prefixed. Eg. \(kilogram\) is prefixed, but \(gram\) is not.
- property scale_factor#
与标准单位相比的量的总大小。
数量换算#
几种简化包含单位对象的表达式的方法。
- sympy.physics.units.util.convert_to(expr, target_units, unit_system='SI')[源代码]#
转换
expr
所有的单位和数量都表示为target_units
,只要尺寸兼容。target_units
可以是单个单位/数量,也可以是单位/数量的集合。实例
>>> from sympy.physics.units import speed_of_light, meter, gram, second, day >>> from sympy.physics.units import mile, newton, kilogram, atomic_mass_constant >>> from sympy.physics.units import kilometer, centimeter >>> from sympy.physics.units import gravitational_constant, hbar >>> from sympy.physics.units import convert_to >>> convert_to(mile, kilometer) 25146*kilometer/15625 >>> convert_to(mile, kilometer).n() 1.609344*kilometer >>> convert_to(speed_of_light, meter/second) 299792458*meter/second >>> convert_to(day, second) 86400*second >>> 3*newton 3*newton >>> convert_to(3*newton, kilogram*meter/second**2) 3*kilogram*meter/second**2 >>> convert_to(atomic_mass_constant, gram) 1.660539060e-24*gram
转换成动车组:
>>> convert_to(speed_of_light, [meter, second]) 299792458*meter/second >>> convert_to(3*newton, [centimeter, gram, second]) 300000*centimeter*gram/second**2
转换为普朗克单位:
>>> convert_to(atomic_mass_constant, [gravitational_constant, speed_of_light, hbar]).n() 7.62963087839509e-20*hbar**0.5*speed_of_light**0.5/gravitational_constant**0.5