In [1]:
import sympy
In [2]:
import os, sys
Get the current directory:
In [3]:
currentdir = os.getcwd(); currentdir
Out[3]:
In [4]:
sys.path.append(currentdir)
sys.path.append('/home/topolo/PropD/Propulsion') # you are going to type in manually the parent directory of the
# current directory, i.e. the directory "above" the current directory, in absolute path form
In [5]:
import Physique
In [9]:
from Physique import FundConst
g_0pd = FundConst[ FundConst["Quantity"].str.contains("gravity") ]
g_0pd
Out[9]:
In [7]:
g_0pd.Value.get_values()
Out[7]:
electric constant, electric (vacuum) permittivity $\epsilon_0$
In [18]:
epsilon_0pd = FundConst[ FundConst['Quantity'].str.contains('electric constant')]
epsilon_0pd
Out[18]:
In [24]:
1./(4. * sympy.pi.n() * epsilon_0pd.Value)
Out[24]:
In [14]:
from Physique import conv as convDF
convDF.columns
Out[14]:
In [37]:
convDF[convDF['to'].str.contains("coulomb ")]
esu_to_Cpd = convDF[convDF['Toconvertfrom'].str.contains("statcoulomb")]
esu_to_Cpd
Out[37]:
In [43]:
convDF[convDF['Toconvertfrom'].str.contains("dyne ")]
dyne_to_Npd = convDF.loc[137,:]
dyne_to_Npd
Out[43]:
In [15]:
convDF[convDF['Toconvertfrom'].str.contains("farad")]
Out[15]:
The (sympy documentation for the differential geometry module)[http://docs.sympy.org/dev/modules/diffgeom.html] is poor: there wasn't any explanation that connects that mathematics and physics to the commands - this could be attributed to the medium, in that it's difficult to display LaTeX with the code, but with jupyter notebooks, this could be alleviated.
In [59]:
from sympy import symbols, sin, cos, pi, Function
from sympy.diffgeom import Differential, Manifold, Patch, CoordSystem, WedgeProduct
t, r, phi, z = symbols('t, r, phi, z')
M = Manifold('M',4)
Mchart = Patch('P',M)
Cart = CoordSystem('Cart',Mchart)
cylin = CoordSystem('cylin',Mchart)
In [60]:
cylin.connect_to(Cart,[t,r,phi,z],[t,r*cos(phi),r*sin(phi),z])
cylin.jacobian(Cart,[t,r,phi,z])
Out[60]:
Define the Electric Field 1-form.
In [61]:
E_1 = Function('E_1'); E_2 = Function('E_2'); E_3 = Function('E_3')
E_1Cart = E_1(*Cart.coord_functions()); E_2Cart = E_2(*Cart.coord_functions()); E_3Cart = E_3(*Cart.coord_functions())
EformCart = E_1Cart*Cart.base_oneforms()[1]+E_2Cart*Cart.base_oneforms()[2]+E_3Cart*Cart.base_oneforms()[3]
Define the magnetic field 2-form.
In [62]:
B_12 = Function('B_12'); B_23 = Function('B_23'); B_31 = Function('B_31')
B_12Cart = B_12(*Cart.coord_functions()); B_23Cart = B_23(*Cart.coord_functions());
B_31Cart = B_31(*Cart.coord_functions());
In [63]:
BformCart = B_12Cart*WedgeProduct(Cart.base_oneform(1), Cart.base_oneform(2)) + B_23Cart*WedgeProduct(Cart.base_oneform(2), Cart.base_oneform(3)) + B_31Cart*WedgeProduct(Cart.base_oneform(3), Cart.base_oneform(1))
In [64]:
BformCart
Out[64]:
In [65]:
F2formCart = BformCart + WedgeProduct(EformCart,Cart.base_oneform(0))
In [68]:
# dir(Differential(F2formCart))
In [46]:
sympy.sin( sympy.pi/4) == sympy.cos(sympy.pi/4)
Out[46]:
In [ ]: