Scipy 简明教程
SciPy - Constants
SciPy 常量包提供了广泛的常量,可用于一般科学领域。
SciPy constants package provides a wide range of constants, which are used in the general scientific area.
SciPy Constants Package
scipy.constants package 提供各种常量。我们必须导入所需的常量,并根据要求使用。让我们看看如何导入和使用这些常量变量。
The scipy.constants package provides various constants. We have to import the required constant and use them as per the requirement. Let us see how these constant variables are imported and used.
首先,让我们考虑以下示例,比较“pi”值。
To start with, let us compare the ‘pi’ value by considering the following example.
#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)
上述程序将生成以下输出。
The above program will generate the following output.
sciPy - pi = 3.1415926535897931
math - pi = 3.1415926535897931
List of Constants Available
下表简要介绍了各种常量。
The following tables describe in brief the various constants.
Physical Constants
下表列出了最常用的物理常量。
The following table lists the most commonly used physical constants.
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 |
Units
下表列出了国际单位制。
The following table has the list of SI units.
Sr. No. |
Unit |
Value |
1 |
milli |
0.001 |
2 |
micro |
1e-06 |
3 |
kilo |
1000 |
这些单位的范围从尧、泽、艾、拍、太……千、百……纳、皮……到泽普托。
These units range from yotta, zetta, exa, peta, tera ……kilo, hector, …nano, pico, … to zepto.
Other Important Constants
下表列出了 SciPy 中使用的其他重要常量。
The following table lists other important constants used in 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() 方法。让我们考虑以下示例。
Remembering all of these are a bit tough. The easy way to get which key is for which function is with the scipy.constants.find() method. Let us consider the following example.
import scipy.constants
res = scipy.constants.physical_constants["alpha particle mass"]
print res
上述程序将生成以下输出。
The above program will generate the following output.
[
'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'
]
此方法返回键的列表,否则如果关键字不匹配,则返回空。
This method returns the list of keys, else nothing if the keyword does not match.