📅  最后修改于: 2020-11-05 04:30:51             🧑  作者: Mango
SciPy常数软件包提供了广泛的常数,这些常数可在常规科学领域中使用。
scipy.constants包提供了各种常量。我们必须导入所需的常数,然后根据需要使用它们。让我们看看如何导入和使用这些常量。
首先,让我们通过考虑以下示例来比较“ pi”值。
#Import pi constant from both the packages
from scipy.constants import pi
from math import pi
print("sciPy - pi = %.16f"%scipy.constants.pi)
print("math - pi = %.16f"%math.pi)
上面的程序将生成以下输出。
sciPy - pi = 3.1415926535897931
math - pi = 3.1415926535897931
下表简要描述了各种常量。
Sr. No. | Constant | Description |
---|---|---|
1 | pi | pi |
2 | golden | Golden Ratio |
下表列出了最常用的物理常数。
Sr. No. | Constant & Description |
---|---|
1 |
c Speed of light in vacuum |
2 |
speed_of_light Speed of light in vacuum |
3 |
h Planck constant |
4 |
Planck Planck constant h |
5 |
G Newton’s gravitational constant |
6 |
e Elementary charge |
7 |
R Molar gas constant |
8 |
Avogadro Avogadro constant |
9 |
k Boltzmann constant |
10 |
electron_mass(OR) m_e Electronic mass |
11 |
proton_mass (OR) m_p Proton mass |
12 |
neutron_mass(OR)m_n Neutron mass |
下表列出了国际单位制。
Sr. No. | Unit | Value |
---|---|---|
1 | milli | 0.001 |
2 | micro | 1e-06 |
3 | kilo | 1000 |
这些单位的范围从yotta,zetta,exa,peta,tera……kilo,hector,…nano,pico等到zepto。
下表列出了SciPy中使用的其他重要常量。
Sr. No. | Unit | Value |
---|---|---|
1 | gram | 0.001 kg |
2 | atomic mass | Atomic mass constant |
3 | degree | Degree in radians |
4 | minute | One minute in seconds |
5 | day | One day in seconds |
6 | inch | One inch in meters |
7 | micron | One micron in meters |
8 | light_year | One light-year in meters |
9 | atm | Standard atmosphere in pascals |
10 | acre | One acre in square meters |
11 | liter | One liter in cubic meters |
12 | gallon | One gallon in cubic meters |
13 | kmh | Kilometers per hour in meters per seconds |
14 | degree_Fahrenheit | One Fahrenheit in kelvins |
15 | eV | One electron volt in joules |
16 | hp | One horsepower in watts |
17 | dyn | One dyne in newtons |
18 | lambda2nu | Convert wavelength to optical frequency |
记住所有这些都有些困难。使用scipy.constants.find()方法可以轻松获得用于哪个函数的键。让我们考虑以下示例。
import scipy.constants
res = scipy.constants.physical_constants["alpha particle mass"]
print res
上面的程序将生成以下输出。
[
'alpha particle mass',
'alpha particle mass energy equivalent',
'alpha particle mass energy equivalent in MeV',
'alpha particle mass in u',
'electron to alpha particle mass ratio'
]
此方法返回键列表,如果关键字不匹配,则不返回任何值。