Physique

Mini Table of Contents

  • Create or refresh data files
  • Using Physique from a working directory not containing Physique itself
  • NIST Fundamental Constants
  • NIST Official Conversions (to metric)
  • Webscraping example: JPL Solar System Dynamics (JPL SSD) - Planets and Pluto

Create or refresh data files

Create or refresh data files (if using Physique for the first time, do this first!) by running this script in the root directory of the project (i.e. ./Physique/):

python3 ./Scripts/Refresh.py

For instance, you would leave this current directory, change to the directory above (or wherever it really is) for the root directory of the project, and type the above command in the command line.

Alternatively, do it in Python here:


In [1]:
import os
print(os.getcwd())


/home/topolo/PropD/Propulsion

In [2]:
os.chdir(os.getcwd() + "/Physique/") # change current working directory

In [3]:
print(os.getcwd())


/home/topolo/PropD/Propulsion/Physique

In [4]:
%run -i ./Scripts/Refresh.py # this is the main, important, command to run

In [5]:
import Physique

In [6]:
import sys

In [7]:
sys.executable # Check which Python you are running in case you have ImportError's


Out[7]:
'/usr/bin/python3'

In [8]:
print(dir(Physique))


['BraeunigStandardAtmosphere', 'Conversions', 'FahrenheitCelsiusConversion', 'FundamentalPhysicalConstants', 'KelvinCelsiusConversion', 'Physique', 'PlanetaryFacts', 'Source', 'T_C', 'T_F', 'T_K', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

NIST Fundamental Constants


In [8]:
from Physique import FundamentalPhysicalConstants as FPC

In [11]:
print(FPC.columns)


Index(['Quantity', 'Value', 'Uncertainty', 'Unit'], dtype='object')

In [12]:
print(FPC)


                                          Quantity              Value  \
0                 {220} lattice spacing of silicon    1.920155714E-10   
1               alpha particle-electron mass ratio      7294.29954136   
2                              alpha particle mass    6.644657230E-27   
3            alpha particle mass energy equivalent    5.971920097E-10   
4     alpha particle mass energy equivalent in MeV        3727.379378   
5                         alpha particle mass in u     4.001506179127   
6                        alpha particle molar mass  0.004001506179127   
7                 alpha particle-proton mass ratio      3.97259968907   
8                                    Angstrom star     1.00001495E-10   
9                             atomic mass constant    1.660539040E-27   
10          atomic mass constant energy equivalent    1.492418062E-10   
11   atomic mass constant energy equivalent in MeV        931.4940954   
12     atomic mass unit-electron volt relationship        931494095.4   
13           atomic mass unit-hartree relationship       34231776.902   
14             atomic mass unit-hertz relationship   2.2523427206E+23   
15     atomic mass unit-inverse meter relationship   7.5130066166E+14   
16             atomic mass unit-joule relationship    1.492418062E-10   
17            atomic mass unit-kelvin relationship     1.08095438E+13   
18          atomic mass unit-kilogram relationship    1.660539040E-27   
19          atomic unit of 1st hyperpolarizability    3.206361329E-53   
20          atomic unit of 2nd hyperpolarizability    6.235380085E-65   
21                           atomic unit of action    1.054571800E-34   
22                           atomic unit of charge   1.6021766208E-19   
23                   atomic unit of charge density   1.0812023770E+12   
24                          atomic unit of current     0.006623618183   
25             atomic unit of electric dipole mom.    8.478353552E-30   
26                   atomic unit of electric field    5.142206707E+11   
27          atomic unit of electric field gradient    9.717362356E+21   
28          atomic unit of electric polarizability   1.6487772731E-41   
29               atomic unit of electric potential        27.21138602   
..                                             ...                ...   
305                        standard-state pressure             100000   
306                      Stefan-Boltzmann constant        5.670367E-8   
307                         tau Compton wavelength        6.97787E-16   
308               tau Compton wavelength over 2 pi        1.11056E-16   
309                        tau-electron mass ratio            3477.15   
310                                       tau mass        3.16747E-27   
311                     tau mass energy equivalent        2.84678E-10   
312              tau mass energy equivalent in MeV            1776.82   
313                                  tau mass in u            1.90749   
314                                 tau molar mass         0.00190749   
315                            tau-muon mass ratio            16.8167   
316                         tau-neutron mass ratio            1.89111   
317                          tau-proton mass ratio            1.89372   
318                          Thomson cross section   6.6524587158E-29   
319                     triton-electron mass ratio      5496.92153588   
320                                triton g factor        5.957924920   
321                               triton mag. mom.    1.504609503E-26   
322        triton mag. mom. to Bohr magneton ratio    0.0016223936616   
323     triton mag. mom. to nuclear magneton ratio        2.978962460   
324                                    triton mass    5.007356665E-27   
325                  triton mass energy equivalent    4.500387735E-10   
326           triton mass energy equivalent in MeV        2808.921112   
327                               triton mass in u      3.01550071632   
328                              triton molar mass   0.00301550071632   
329                       triton-proton mass ratio      2.99371703348   
330                       unified atomic mass unit    1.660539040E-27   
331                          von Klitzing constant      25812.8074555   
332                              weak mixing angle             0.2223   
333       Wien frequency displacement law constant      5.8789238E+10   
334      Wien wavelength displacement law constant       0.0028977729   

    Uncertainty          Unit  
0       3.2E-18             m  
1        2.4E-7                
2       8.2E-35            kg  
3       7.3E-18             J  
4      0.000023           MeV  
5       6.3E-11             u  
6       6.3E-14     kg mol^-1  
7       3.6E-10                
8       9.0E-17             m  
9       2.0E-35            kg  
10      1.8E-18             J  
11    0.0000057           MeV  
12          5.7            eV  
13        0.016           E_h  
14      1.0E+14            Hz  
15       3.4E+5          m^-1  
16      1.8E-18             J  
17       6.2E+6             K  
18      2.0E-35            kg  
19      2.0E-61  C^3 m^3 J^-2  
20      7.7E-73  C^4 m^4 J^-3  
21      1.3E-42           J s  
22      9.8E-28             C  
23       6.7E+3        C m^-3  
24      4.1E-11             A  
25      5.2E-38           C m  
26       3.2E+3        V m^-1  
27      6.0E+13        V m^-2  
28      1.1E-50  C^2 m^2 J^-1  
29       1.7E-7             V  
..          ...           ...  
305        None            Pa  
306     1.3E-13   W m^-2 K^-4  
307     6.3E-20             m  
308     1.0E-20             m  
309        0.31                
310     2.9E-31            kg  
311     2.6E-14             J  
312        0.16           MeV  
313     0.00017             u  
314      1.7E-7     kg mol^-1  
315      0.0015                
316     0.00017                
317     0.00017                
318     9.1E-38           m^2  
319      2.6E-7                
320      2.8E-8                
321     1.2E-34        J T^-1  
322     7.6E-12                
323      1.4E-8                
324     6.2E-35            kg  
325     5.5E-18             J  
326    0.000017           MeV  
327     1.1E-10             u  
328     1.1E-13     kg mol^-1  
329     2.2E-10                
330     2.0E-35            kg  
331   0.0000059           ohm  
332      0.0021                
333      3.4E+4       Hz K^-1  
334      1.7E-9           m K  

[335 rows x 4 columns]

Find a Fundamental Constant you are interested in using the usual panda modules


In [13]:
g_0pd = FPC[FPC["Quantity"].str.contains("gravity") ] 
# standard acceleration of gravity as a panda DataFrame
print(g_0pd)


                             Quantity    Value Uncertainty    Unit
303  standard acceleration of gravity  9.80665        None  m s^-2

In [18]:
g_0 = g_0pd["Value"].values[0]
print(type(g_0))
print(g_0)


<class 'decimal.Decimal'>
9.80665

In [21]:
# access the values you're interested in 
print(g_0pd.Quantity)
print(g_0pd.Value.get_values()[0]) 
print(g_0pd.Unit.get_values()[0])


303    standard acceleration of gravity
Name: Quantity, dtype: object
9.80665
m s^-2

In [22]:
# you can also grab just the 1 entry from this DataFrame using the .loc module
FPC[FPC["Quantity"].str.contains("Boltzmann")].loc[49,:]


Out[22]:
Quantity       Boltzmann constant
Value              1.38064852E-23
Uncertainty               7.9E-30
Unit                       J K^-1
Name: 49, dtype: object

In [23]:
g_0pd.loc[303,:]


Out[23]:
Quantity       standard acceleration of gravity
Value                                   9.80665
Uncertainty                                None
Unit                                     m s^-2
Name: 303, dtype: object

NIST Official Conversions (to metric)

This is the pandas DataFrame containing all the NIST Official Conversions to SI.


In [24]:
from Physique import Conversions

In [25]:
print(Conversions.columns)


Index(['Toconvertfrom', 'to', 'Multiplyby'], dtype='object')

From the list of columns, search for the quantity you desired by trying out different search terms: e.g. I'm reading Huzel and Huang's Modern Engineering for Design of Liquid-Propellant Rocket Engines and I want to know how to convert from

  • lb (pound or pound-force) for thrust into force in Newton (N)
  • psia (pounds per square inch absolute) for (chamber) pressure into pressure in Pascal (Pa)

We can try to look up the U.S. or Imperial units from the Toconvertfrom column.


In [27]:
Conversions[Conversions['Toconvertfrom'].str.contains("pound-force ")]


Out[27]:
Toconvertfrom to Multiplyby
175 foot pound-force (ft · lbf) joule (J) 1.355818
176 foot pound-force per hour (ft · lbf/h) watt (W) 0.0003766161
177 foot pound-force per minute (ft · lbf/min) watt (W) 0.02259697
178 foot pound-force per second (ft · lbf/s) watt (W) 1.355818
340 pound-force (lbf) 23 newton (N) 4.448222
341 pound-force foot (lbf · ft) newton meter (N · m) 1.355818
342 pound-force foot per inch (lbf · ft/in) newton meter per meter (N · m/m) 53.37866
343 pound-force inch (lbf · in) newton meter (N · m) 0.1129848
344 pound-force inch per inch (lbf · in/in) newton meter per meter (N · m/m) 4.448222
345 pound-force per foot (lbf/ft) newton per meter (N/m) 14.59390
346 pound-force per inch (lbf/in) newton per meter (N/m) 175.1268
347 pound-force per pound (lbf/lb) (thrust to mass... newton per kilogram (N/kg) 9.80665
348 pound-force per square foot (lbf/ft2) pascal (Pa) 47.88026
349 pound-force per square inch (psi) (lbf/in2) pascal (Pa) 6894.757
350 pound-force per square inch (psi) (lbf/in2) kilopascal (kPa) 6.894757
351 pound-force second per square foot (lbf · s/ft2) pascal second (Pa · s) 47.88026
352 pound-force second per square inch (lbf · s/in2) pascal second (Pa · s) 6894.757
372 psi (pound-force per square inch) (lbf/in2) pascal (Pa) 6894.757
373 psi (pound-force per square inch) (lbf/in2) kilopascal (kPa) 6.894757

Or we can look up the SI unit we want to convert to.


In [29]:
Conversions[Conversions['to'].str.contains("newton ")]


Out[29]:
Toconvertfrom to Multiplyby
137 dyne (dyn) newton (N) 0.000010
138 dyne centimeter (dyn · cm) newton meter (N · m) 1.0E-7
238 kilogram-force (kgf) newton (N) 9.80665
239 kilogram-force meter (kgf · m) newton meter (N · m) 9.80665
247 kilopond (kilogram-force) (kp) newton (N) 9.80665
250 kip (1 kip= 1000 lbf) newton (N) 4448.222
251 kip (1 kip= 1000 lbf) kilonewton (kN) 4.448222
300 ounce (avoirdupois)-force (ozf) newton (N) 0.2780139
301 ounce (avoirdupois)-force inch (ozf · in) newton meter (N · m) 0.007061552
302 ounce (avoirdupois)-force inch (ozf · in) millinewton meter (mN · m) 7.061552
336 poundal newton (N) 0.1382550
340 pound-force (lbf) 23 newton (N) 4.448222
341 pound-force foot (lbf · ft) newton meter (N · m) 1.355818
342 pound-force foot per inch (lbf · ft/in) newton meter per meter (N · m/m) 53.37866
343 pound-force inch (lbf · in) newton meter (N · m) 0.1129848
344 pound-force inch per inch (lbf · in/in) newton meter per meter (N · m/m) 4.448222
345 pound-force per foot (lbf/ft) newton per meter (N/m) 14.59390
346 pound-force per inch (lbf/in) newton per meter (N/m) 175.1268
347 pound-force per pound (lbf/lb) (thrust to mass... newton per kilogram (N/kg) 9.80665
423 ton-force (2000 lbf) newton (N) 8896.443
424 ton-force (2000 lbf) kilonewton (kN) 8.896443

Look at what you want and see the index; it happens to be 340 in this example.


In [30]:
lbf2N = Conversions.loc[340,:];
print(lbf2N)


Toconvertfrom    pound-force (lbf) 23
to                         newton (N)
Multiplyby                   4.448222
Name: 340, dtype: object

Then the attributes can accessed by the column names.


In [31]:
print(lbf2N.Toconvertfrom)
print(lbf2N.to)
print(lbf2N.Multiplyby)


pound-force (lbf) 23
newton (N)
4.448222

So for example, the reusable SSME delivers a vacuum thrust of 470000 lb or


In [32]:
print(470000 * lbf2N.Multiplyby, lbf2N.to)


2090664.340000 newton (N)

To obtain the conversion for pressure in psia, which we search for with "psi"


In [33]:
Conversions[Conversions['Toconvertfrom'].str.match("psi")]


Out[33]:
Toconvertfrom to Multiplyby
372 psi (pound-force per square inch) (lbf/in2) pascal (Pa) 6894.757
373 psi (pound-force per square inch) (lbf/in2) kilopascal (kPa) 6.894757

So for a chamber pressure of 3028 psia for the SSME,


In [35]:
psi2Pa = Conversions.loc[372,:]
print(3028 * psi2Pa.Multiplyby, psi2Pa.to)


20877324.196 pascal (Pa)

Also, get the conversion for atmospheres (atm):


In [36]:
Conversions[Conversions['Toconvertfrom'].str.match("atm")]


Out[36]:
Toconvertfrom to Multiplyby
15 atmosphere, standard (atm) pascal (Pa) 101325
16 atmosphere, standard (atm) kilopascal (kPa) 101.325
17 atmosphere, technical (at) 8 pascal (Pa) 98066.5
18 atmosphere, technical (at) 8 kilopascal (kPa) 98.0665

In [37]:
atm2Pa = Conversions.loc[15,:]

In [38]:
print(3028 * psi2Pa.Multiplyby / atm2Pa.Multiplyby, atm2Pa.Toconvertfrom)


206.0431699580557611645694547 atmosphere, standard (atm)

In [ ]: