C++, C++11/C++14

Posts, notes, resources on C++, C++11/C++14.

Table of Contents

C++11 timing code execution

cf. Solarian programmer gave an excellent write up in C++11 timing code performance

C++11/14 version – the classic algorithm of binary search, using C++11/14 vector library

I implemented the classic algorithm of binary search using C++11/14 vector(s) (library) in vectors_binarysearch.cpp, inside the folder ../Cpp14 of my CompPhys github repository


C++ Tutorial – Functors(Function Objects) – 2016

My implementation of the examples above for functors here on github:


C++ templates, class templates and how to put them into header files; Useful links related to splitting up header files for declaration, split to .cpp files for definitions

While I already wrote about it in the README.md of my github repository folder Cpp, for CompPhysUseful links related to splitting up header files for declaration, split to .cpp files for definitions, github repo CompPhys, folder cpp, I had to look it up again, and so I’ll reiterate that material here.

, had an excellent article detailing how understandably confusing it is to split up templates to header files for C++.  The examples and options are comprehensive and crystal-clear.

Gives the reason why.


Texture Object API

struct cudaResourceDesc resDesc

struct myStruct myVariable;

struct Leopard leopard;
leopard.base.animal.weight = 44;

Struct declaration

Google search
struct inherit copy from another struct declare c c++


Typesafe inheritance in C

Difference between ‘struct’ and ‘typedef struct’ in C++?

Google search
typedef struct


typedef struct vs struct definitions [duplicate]

Google search terms

how to declare an instance of a struct C++

Proper way to initialize C++ structs


Abstract Algebra

I reviewed a little about rings and polynomial rings over this past weekend and I wanted to try to collect the resources I come across here. My aim for abstract algebra is to apply to (of course) topological field theory AND (unprecedentedly) to aerospace engineering, namely combustion CFD (computational fluid dynamics).

Cornell Math 4320 Solutions (probably more “around” this link

Using Sage Math for Abstract Algebra, especially in conjunction with jupyter notebooks, should be the way forward in the 21st century, and from there, digging deeper into various C/C++ libraries. The jupyter notebook I keep is in my qSApoly github repository:


Givaro – C++ library for arithmetic and algebraic computations




Fedora package for givaro, givaro.


P.S. I just enabled Markdown for wordpress and so I’m giving wordpress another shot with Markdown, but otherwise, I find myself updating my github and writing there much more frequently because of their excellent and superior version control, terminal commands, and web interface, displaying automatically pdfs, markdown code, etc.

I was reviewing Electric propulsion which led me to review Electromagnetism, in view of differential geometry, and its covariant formulation.

All of Maxwell’s equations are contained in the following 2 statements:

$dF = 0$
$dF = 4\pi **J$ (cgs) or $dF = **J$ (SI).

Here is a reprint of my jupyter notebook on my github repository Propulsion (you’ll need Sage Math and sagemanifolds) EMsage.ipynb where I show with the Minkowski metric that you recover the usual form of Maxwell’s equations, and give the differential form formulation of the Lorentz Force. This is usually shown “by hand” in textbooks, but I show it with Sage Math and sagemanifolds (stop doing tedious calculations by hand!). I want to encourage people to try their own metric beyond the Minkowski metric and make calculations for Electromagnetism in different spacetimes.


Running Sage Math and sagemanifolds with jupyter notebooks tip: First, I’ve found that compiling from the github source the development Sage Math version (see my notes on this under the “Computers” section of my wordpress blog) works with sagemanifolds and either installing sagemanifolds into the binary that you unpack out (the click, download, double click), “breaks” Sage and so that it doesn’t run. Also, following the Sage Math instructions on their website for building from the source didn’t work for me (!!!???).

As a tip on how to run this jupyter notebook and have sagemanifolds available, you’d want to be in the working directory you desire (e.g. Propulsion/EM). But yet your Sage Math build is somewhere else (e.g. /home/topolo/Public/sage). Do this out of the working directory you’re currently working out of:
/home/topolo/Public/sage/sage -n jupyter

For the rationale, or the math, and how the math corresponds directly to the Sage Math code here, you’re going to want to look at Gravity_Notes_grande.pdf in my Gravite repository, and in there, the $\mathbb{R}^3$ section, because I define the charts and atlases for Euclidean space $\mathbb{R}^3$ as a smooth manifold.

M = Manifold(4,'M',r'M')
cart_ch = M.chart('t x y z')
U = M.open_subset('U',coord_def={cart_ch: (cart_ch[1]<0, cart_ch[2]!=0)})
cart_ch_U = cart_ch.restrict(U)
sph_ch = U.chart(r'tsp:(-oo,oo):t_{sp} rh:(0,+oo):\rho th:(0,pi):\theta ph:(0,2*pi):\phi')
tsph, rh,th,ph = [sph_ch[i[0]] for i in M.index_generator(1)]
transit_sph_to_cart = sph_ch.transition_map(cart_ch_U, 
Sphnorm = sqrt(sum([cart_ch_U[i]**2 for i in range(1,4)]))
transit_sph_to_cart.set_inverse( cart_ch[0], Sphnorm, 
                                atan2(sqrt( sum([ cart_ch_U[i]**2 for i in range(1,3)])),cart_ch_U[3]),
cyl_ch = U.chart(r'tcy:(-oo,oo):t_{cy} r:(0,+oo) phi:(0,2*pi):\phi zc')
tcy, r,phi,zc = [cyl_ch[i[0]] for i in M.index_generator(1)]
transit_cyl_to_cart = cyl_ch.transition_map(cart_ch_U, [tcy,r*cos(phi),r*sin(phi),zc])
transit_cyl_to_cart.set_inverse(cart_ch_U[0], sqrt(cart_ch_U[1]**2+cart_ch_U[2]**2), 
                                    atan2( cart_ch_U[2],cart_ch_U[1]), cart_ch_U[3])

Note the mostly positive (-+++) convention I use for the Minkowski metric.

g = M.riemannian_metric('g')
g[0,0] = -1 
for i in range(1,4): g[i,i] = 1

Electric Field

def make_E(ch):
    make_E = make_E(ch)
    make_E creates a time-INDEPENDENT electric field as a 1-form

    ch = sagemanifold chart
    Ecomplst = []
    for i in range(1,4):
        Earglst = ['E'+str(i),] + list(ch[1:])
        Ecomplst.append( function(Earglst[0])(*Earglst[1:]) )
    Ecomplst = [0,]+Ecomplst
    E = ch.domain().diff_form(1)
    E[ch.frame(),:,ch] = Ecomplst
    return E

def make_Et(ch):
    make_Et = make_Et(ch)
    make_Et creates a time-DEPENDENT electric field as a 1-form

    ch = sagemanifold chart
    Ecomplst = []
    for i in range(1,4):
        Earglst = ['E'+str(i),] + list(ch[:])
        Ecomplst.append( function(Earglst[0])(*Earglst[1:]) )
    Ecomplst = [0,]+Ecomplst
    E = ch.domain().diff_form(1)
    E[ch.frame(),:,ch] = Ecomplst
    return E

Examples of using make_E, make_Et and displaying the results

print make_E(cart_ch).display()
E1(x, y, z) dx + E2(x, y, z) dy + E3(x, y, z) dz

E1(tsp, rh, th, ph) drh + E2(tsp, rh, th, ph) dth + E3(tsp, rh, th, ph) dph

Magnetic Field

Programming note: make_B and make_Bt

import itertools
def make_B(ch):
    make_B = make_B(ch)
    make_B creates a time-INDEPENDENT magnetic field as a 2-form

    ch = sagemanifold chart
    B = ch.domain().diff_form(2)
    farglst = list(ch[1:]) # function argument list, e.g. (x,y,z)

    B[ch.frame(),1,2,ch] = function('B_12')(*farglst)
    B[ch.frame(),2,3,ch] = function('B_23')(*farglst)
    B[ch.frame(),3,1,ch] = function('B_31')(*farglst)

    return B

def make_Bt(ch):
    make_Bt = make_Bt(ch)
    make_Bt creates a time-DEPENDENT electric field as a 2-form

    ch = sagemanifold chart
    B = ch.domain().diff_form(2)
    farglst = list(ch[:]) # function argument list, e.g. (x,y,z)

    B[ch.frame(),1,2,ch] = function('B_12')(*farglst)
    B[ch.frame(),2,3,ch] = function('B_23')(*farglst)
    B[ch.frame(),3,1,ch] = function('B_31')(*farglst)

    return B
print make_Bt(cart_ch).display()
B_12(t, x, y, z) dx/\dy - B_31(t, x, y, z) dx/\dz + B_23(t, x, y, z) dy/\dz

B_12(r, phi, zc) dr/\dphi - B_31(r, phi, zc) dr/\dzc + B_23(r, phi, zc) dphi/\dzc

Notice that the orientation is correct (with the right hand rule).

Electromagnetic field 2-form

EM_F = make_Bt(cart_ch) + make_Et(cart_ch).wedge(cart_ch.coframe()[0] )
-E1(t, x, y, z) dt/\dx - E2(t, x, y, z) dt/\dy - E3(t, x, y, z) dt/\dz + B_12(t, x, y, z) dx/\dy - B_31(t, x, y, z) dx/\dz + B_23(t, x, y, z) dy/\dz
[                0   -E1(t, x, y, z)   -E2(t, x, y, z)   -E3(t, x, y, z)]
[   E1(t, x, y, z)                 0  B_12(t, x, y, z) -B_31(t, x, y, z)]
[   E2(t, x, y, z) -B_12(t, x, y, z)                 0  B_23(t, x, y, z)]
[   E3(t, x, y, z)  B_31(t, x, y, z) -B_23(t, x, y, z)                 0]
latex(EM_F.exterior_der()[:]); # delete the semi-colon ; and you can get the LaTeX code-I suppress it

$ dF = \left[\left[\left[0, 0, 0, 0\right], \left[0, 0, \frac{\partial\,B_{12}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial y} + \frac{\partial\,E_{2}}{\partial x}, -\frac{\partial\,B_{31}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial z} + \frac{\partial\,E_{3}}{\partial x}\right], \left[0, -\frac{\partial\,B_{12}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial y} – \frac{\partial\,E_{2}}{\partial x}, 0, \frac{\partial\,B_{23}}{\partial {t}} – \frac{\partial\,E_{2}}{\partial z} + \frac{\partial\,E_{3}}{\partial y}\right], \left[0, \frac{\partial\,B_{31}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial z} – \frac{\partial\,E_{3}}{\partial x}, -\frac{\partial\,B_{23}}{\partial {t}} + \frac{\partial\,E_{2}}{\partial z} – \frac{\partial\,E_{3}}{\partial y}, 0\right]\right], \left[\left[0, 0, -\frac{\partial\,B_{12}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial y} – \frac{\partial\,E_{2}}{\partial x}, \frac{\partial\,B_{31}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial z} – \frac{\partial\,E_{3}}{\partial x}\right], \left[0, 0, 0, 0\right], \left[\frac{\partial\,B_{12}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial y} + \frac{\partial\,E_{2}}{\partial x}, 0, 0, \frac{\partial\,B_{12}}{\partial z} + \frac{\partial\,B_{23}}{\partial x} + \frac{\partial\,B_{31}}{\partial y}\right], \left[-\frac{\partial\,B_{31}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial z} + \frac{\partial\,E_{3}}{\partial x}, 0, -\frac{\partial\,B_{12}}{\partial z} – \frac{\partial\,B_{23}}{\partial x} – \frac{\partial\,B_{31}}{\partial y}, 0\right]\right], \left[\left[0, \frac{\partial\,B_{12}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial y} + \frac{\partial\,E_{2}}{\partial x}, 0, -\frac{\partial\,B_{23}}{\partial {t}} + \frac{\partial\,E_{2}}{\partial z} – \frac{\partial\,E_{3}}{\partial y}\right], \left[-\frac{\partial\,B_{12}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial y} – \frac{\partial\,E_{2}}{\partial x}, 0, 0, -\frac{\partial\,B_{12}}{\partial z} – \frac{\partial\,B_{23}}{\partial x} – \frac{\partial\,B_{31}}{\partial y}\right], \left[0, 0, 0, 0\right], \left[\frac{\partial\,B_{23}}{\partial {t}} – \frac{\partial\,E_{2}}{\partial z} + \frac{\partial\,E_{3}}{\partial y}, \frac{\partial\,B_{12}}{\partial z} + \frac{\partial\,B_{23}}{\partial x} + \frac{\partial\,B_{31}}{\partial y}, 0, 0\right]\right], \left[\left[0, -\frac{\partial\,B_{31}}{\partial {t}} – \frac{\partial\,E_{1}}{\partial z} + \frac{\partial\,E_{3}}{\partial x}, \frac{\partial\,B_{23}}{\partial {t}} – \frac{\partial\,E_{2}}{\partial z} + \frac{\partial\,E_{3}}{\partial y}, 0\right], \left[\frac{\partial\,B_{31}}{\partial {t}} + \frac{\partial\,E_{1}}{\partial z} – \frac{\partial\,E_{3}}{\partial x}, 0, \frac{\partial\,B_{12}}{\partial z} + \frac{\partial\,B_{23}}{\partial x} + \frac{\partial\,B_{31}}{\partial y}, 0\right], \left[-\frac{\partial\,B_{23}}{\partial {t}} + \frac{\partial\,E_{2}}{\partial z} – \frac{\partial\,E_{3}}{\partial y}, -\frac{\partial\,B_{12}}{\partial z} – \frac{\partial\,B_{23}}{\partial x} – \frac{\partial\,B_{31}}{\partial y}, 0, 0\right], \left[0, 0, 0, 0\right]\right]\right] = 0 $

[                  0  I*B_23(t, x, y, z)  I*B_31(t, x, y, z)  I*B_12(t, x, y, z)]
[-I*B_23(t, x, y, z)                   0    I*E3(t, x, y, z)   -I*E2(t, x, y, z)]
[-I*B_31(t, x, y, z)   -I*E3(t, x, y, z)                   0    I*E1(t, x, y, z)]
[-I*B_12(t, x, y, z)    I*E2(t, x, y, z)   -I*E1(t, x, y, z)                   0]
[-1  0  0  0]
[ 0  1  0  0]
[ 0  0  1  0]
[ 0  0  0  1]

$dF$ (for $dF = 4 \pi * J$)

[[[0, 0, 0, 0],
   I*d(B_23)/dy - I*d(B_31)/dx + I*d(E3)/dt,
   -I*d(B_12)/dx + I*d(B_23)/dz - I*d(E2)/dt],
   -I*d(B_23)/dy + I*d(B_31)/dx - I*d(E3)/dt,
   -I*d(B_12)/dy + I*d(B_31)/dz + I*d(E1)/dt],
   I*d(B_12)/dx - I*d(B_23)/dz + I*d(E2)/dt,
   I*d(B_12)/dy - I*d(B_31)/dz - I*d(E1)/dt,
   -I*d(B_23)/dy + I*d(B_31)/dx - I*d(E3)/dt,
   I*d(B_12)/dx - I*d(B_23)/dz + I*d(E2)/dt],
  [0, 0, 0, 0],
  [I*d(B_23)/dy - I*d(B_31)/dx + I*d(E3)/dt,
   I*d(E1)/dx + I*d(E2)/dy + I*d(E3)/dz],
  [-I*d(B_12)/dx + I*d(B_23)/dz - I*d(E2)/dt,
   -I*d(E1)/dx - I*d(E2)/dy - I*d(E3)/dz,
   I*d(B_23)/dy - I*d(B_31)/dx + I*d(E3)/dt,
   I*d(B_12)/dy - I*d(B_31)/dz - I*d(E1)/dt],
  [-I*d(B_23)/dy + I*d(B_31)/dx - I*d(E3)/dt,
   -I*d(E1)/dx - I*d(E2)/dy - I*d(E3)/dz],
  [0, 0, 0, 0],
  [-I*d(B_12)/dy + I*d(B_31)/dz + I*d(E1)/dt,
   I*d(E1)/dx + I*d(E2)/dy + I*d(E3)/dz,
   -I*d(B_12)/dx + I*d(B_23)/dz - I*d(E2)/dt,
   -I*d(B_12)/dy + I*d(B_31)/dz + I*d(E1)/dt,
  [I*d(B_12)/dx - I*d(B_23)/dz + I*d(E2)/dt,
   I*d(E1)/dx + I*d(E2)/dy + I*d(E3)/dz,
  [I*d(B_12)/dy - I*d(B_31)/dz - I*d(E1)/dt,
   -I*d(E1)/dx - I*d(E2)/dy - I*d(E3)/dz,
  [0, 0, 0, 0]]]
latex( EM_F.hodge_dual(g).exterior_der()[:] ); # delete the semi-colon ; and you can get the LaTeX code-I suppress it

$\left[\left[\left[0, 0, 0, 0\right], \left[0, 0, i \, \frac{\partial\,B_{23}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial x} + i \, \frac{\partial\,E_{3}}{\partial {t}}, -i \, \frac{\partial\,B_{12}}{\partial x} + i \, \frac{\partial\,B_{23}}{\partial z} – i \, \frac{\partial\,E_{2}}{\partial {t}}\right], \left[0, -i \, \frac{\partial\,B_{23}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial x} – i \, \frac{\partial\,E_{3}}{\partial {t}}, 0, -i \, \frac{\partial\,B_{12}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial z} + i \, \frac{\partial\,E_{1}}{\partial {t}}\right], \left[0, i \, \frac{\partial\,B_{12}}{\partial x} – i \, \frac{\partial\,B_{23}}{\partial z} + i \, \frac{\partial\,E_{2}}{\partial {t}}, i \, \frac{\partial\,B_{12}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial z} – i \, \frac{\partial\,E_{1}}{\partial {t}}, 0\right]\right], \left[\left[0, 0, -i \, \frac{\partial\,B_{23}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial x} – i \, \frac{\partial\,E_{3}}{\partial {t}}, i \, \frac{\partial\,B_{12}}{\partial x} – i \, \frac{\partial\,B_{23}}{\partial z} + i \, \frac{\partial\,E_{2}}{\partial {t}}\right], \left[0, 0, 0, 0\right], \left[i \, \frac{\partial\,B_{23}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial x} + i \, \frac{\partial\,E_{3}}{\partial {t}}, 0, 0, i \, \frac{\partial\,E_{1}}{\partial x} + i \, \frac{\partial\,E_{2}}{\partial y} + i \, \frac{\partial\,E_{3}}{\partial z}\right], \left[-i \, \frac{\partial\,B_{12}}{\partial x} + i \, \frac{\partial\,B_{23}}{\partial z} – i \, \frac{\partial\,E_{2}}{\partial {t}}, 0, -i \, \frac{\partial\,E_{1}}{\partial x} – i \, \frac{\partial\,E_{2}}{\partial y} – i \, \frac{\partial\,E_{3}}{\partial z}, 0\right]\right], \left[\left[0, i \, \frac{\partial\,B_{23}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial x} + i \, \frac{\partial\,E_{3}}{\partial {t}}, 0, i \, \frac{\partial\,B_{12}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial z} – i \, \frac{\partial\,E_{1}}{\partial {t}}\right], \left[-i \, \frac{\partial\,B_{23}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial x} – i \, \frac{\partial\,E_{3}}{\partial {t}}, 0, 0, -i \, \frac{\partial\,E_{1}}{\partial x} – i \, \frac{\partial\,E_{2}}{\partial y} – i \, \frac{\partial\,E_{3}}{\partial z}\right], \left[0, 0, 0, 0\right], \left[-i \, \frac{\partial\,B_{12}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial z} + i \, \frac{\partial\,E_{1}}{\partial {t}}, i \, \frac{\partial\,E_{1}}{\partial x} + i \, \frac{\partial\,E_{2}}{\partial y} + i \, \frac{\partial\,E_{3}}{\partial z}, 0, 0\right]\right], \left[\left[0, -i \, \frac{\partial\,B_{12}}{\partial x} + i \, \frac{\partial\,B_{23}}{\partial z} – i \, \frac{\partial\,E_{2}}{\partial {t}}, -i \, \frac{\partial\,B_{12}}{\partial y} + i \, \frac{\partial\,B_{31}}{\partial z} + i \, \frac{\partial\,E_{1}}{\partial {t}}, 0\right], \left[i \, \frac{\partial\,B_{12}}{\partial x} – i \, \frac{\partial\,B_{23}}{\partial z} + i \, \frac{\partial\,E_{2}}{\partial {t}}, 0, i \, \frac{\partial\,E_{1}}{\partial x} + i \, \frac{\partial\,E_{2}}{\partial y} + i \, \frac{\partial\,E_{3}}{\partial z}, 0\right], \left[i \, \frac{\partial\,B_{12}}{\partial y} – i \, \frac{\partial\,B_{31}}{\partial z} – i \, \frac{\partial\,E_{1}}{\partial {t}}, -i \, \frac{\partial\,E_{1}}{\partial x} – i \, \frac{\partial\,E_{2}}{\partial y} – i \, \frac{\partial\,E_{3}}{\partial z}, 0, 0\right], \left[0, 0, 0, 0\right]\right]\right]$

[d(E1)/dx + d(E2)/dy + d(E3)/dz,
 -d(B_12)/dy + d(B_31)/dz + d(E1)/dt,
 d(B_12)/dx - d(B_23)/dz + d(E2)/dt,
 d(B_23)/dy - d(B_31)/dx + d(E3)/dt]
# delete the semi-colon ; and you can get the LaTeX code-I suppress it
\left[\frac{\partial\,E_{1}}{\partial x} + \frac{\partial\,E_{2}}{\partial y} + \frac{\partial\,E_{3}}{\partial z}, -\frac{\partial\,B_{12}}{\partial y} + \frac{\partial\,B_{31}}{\partial z} + \frac{\partial\,E_{1}}{\partial {t}}, \frac{\partial\,B_{12}}{\partial x} - \frac{\partial\,B_{23}}{\partial z} + \frac{\partial\,E_{2}}{\partial {t}}, \frac{\partial\,B_{23}}{\partial y} - \frac{\partial\,B_{31}}{\partial x} + \frac{\partial\,E_{3}}{\partial {t}}\right]

$\left[\frac{\partial\,E_{1}}{\partial x} + \frac{\partial\,E_{2}}{\partial y} + \frac{\partial\,E_{3}}{\partial z}, -\frac{\partial\,B_{12}}{\partial y} + \frac{\partial\,B_{31}}{\partial z} + \frac{\partial\,E_{1}}{\partial {t}}, \frac{\partial\,B_{12}}{\partial x} – \frac{\partial\,B_{23}}{\partial z} + \frac{\partial\,E_{2}}{\partial {t}}, \frac{\partial\,B_{23}}{\partial y} – \frac{\partial\,B_{31}}{\partial x} + \frac{\partial\,E_{3}}{\partial {t}}\right]$

Current 1-form, Current conservation, and the other side (Right-Hand Side (RHS)) of $d*F$

def make_J(ch):
    make_J = make_J(ch)
    make_J creates a time-INDEPENDENT current as a 1-form

    ch = sagemanifold chart
    Jcomplst = []
    for i in range(1,4):
        Jarglst = ['j'+str(i),] + list(ch[1:])
        Jcomplst.append( function(Jarglst[0])(*Jarglst[1:]) )
    Jcomplst = [-function('rho')(*list(ch[1:])),] +Jcomplst
    J = ch.domain().diff_form(1)
    J[ch.frame(),:,ch] = Jcomplst
    return J

def make_Jt(ch):
    make_Jt = make_Jt(ch)
    make_Jt creates a time-DEPENDENT current as a 1-form

    ch = sagemanifold chart
    Jcomplst = []
    for i in range(1,4):
        Jarglst = ['j'+str(i),] + list(ch[:])
        Jcomplst.append( function(Jarglst[0])(*Jarglst[1:]) )
    Jcomplst = [-function('rho')(*list(ch[:])),]+Jcomplst
    J = ch.domain().diff_form(1)
    J[ch.frame(),:,ch] = Jcomplst
    return J

print make_Jt(cart_ch).display() # these are examples of displaying the 4-current as 1-form in 
                                    # Cartesian and cylindrical coordinates
-rho(t, x, y, z) dt + j1(t, x, y, z) dx + j2(t, x, y, z) dy + j3(t, x, y, z) dz

-rho(tcy, r, phi, zc) dtcy + j1(tcy, r, phi, zc) dr + j2(tcy, r, phi, zc) dphi + j3(tcy, r, phi, zc) dzc
rho(t, x, y, z) dt - j1(t, x, y, z) dx - j2(t, x, y, z) dy - j3(t, x, y, z) dz

So here, I had successfully shown that $dF = **J$ or $dF = 4\pi ** J$ (in cgs units), thus recovering Gauss’s law and Ampere’s law.

latex( make_Jt(cart_ch).hodge_dual(g).hodge_dual(g)[:]);
# delete the semi-colon ; and you can get the LaTeX code-I suppress it

$\boxed{ \left[\frac{\partial\,E_{1}}{\partial x} + \frac{\partial\,E_{2}}{\partial y} + \frac{\partial\,E_{3}}{\partial z}, -\frac{\partial\,B_{12}}{\partial y} + \frac{\partial\,B_{31}}{\partial z} + \frac{\partial\,E_{1}}{\partial {t}}, \frac{\partial\,B_{12}}{\partial x} – \frac{\partial\,B_{23}}{\partial z} + \frac{\partial\,E_{2}}{\partial {t}}, \frac{\partial\,B_{23}}{\partial y} – \frac{\partial\,B_{31}}{\partial x} + \frac{\partial\,E_{3}}{\partial {t}}\right] = \left[\rho\left({t}, x, y, z\right), -j_{1}\left({t}, x, y, z\right), -j_{2}\left({t}, x, y, z\right), -j_{3}\left({t}, x, y, z\right)\right] }$

Current conservation is easily calculated, $dJ=0$:

M --&gt; R
(t, x, y, z) |--&gt; d(j1)/dx + d(j2)/dy + d(j3)/dz + d(rho)/dt

Lorentz Force

def make_beta(ch):
    make_beta = make_beta(ch)
    make_beta creates a time-INDEPENDENT velocity field

    ch = sagemanifold chart
    betacomplst = []
    for i in range(1,4):
        betaarglst = ['beta'+str(i),] + list(ch[1:])
        betacomplst.append( function(betaarglst[0])(*betaarglst[1:]) )
    betacomplst = [1,]+betacomplst
    beta = ch.domain().vector_field()
    beta[ch.frame(),:,ch] = betacomplst
    return beta

def make_betat(ch):
    make_betat = make_betat(ch)
    make_betat creates a time-DEPENDENT velocity field

    ch = sagemanifold chart
    betacomplst = []
    for i in range(1,4):
        betaarglst = ['beta'+str(i),] + list(ch[:])
        betacomplst.append( function(betaarglst[0])(*betaarglst[1:]) )
    betacomplst = [1,]+betacomplst
    beta = ch.domain().vector_field()
    beta[ch.frame(),:,ch] = betacomplst
    return beta
d/dt + beta1(x, y, z) d/dx + beta2(x, y, z) d/dy + beta3(x, y, z) d/dz

For interior products, you’re going to have to dig into how sagemanifolds implements Tensor products, tensor contractions, and the use of index notation, as sagemanifolds doesn’t have a “stand-alone” interior product function. From my EuclideanManifold.py implementation in sagemanifolds, look at my curl function (def curl) as a template for implementing interior products.

betaeg = make_betat(cart_ch)
Beg = make_Bt(cart_ch)
(-B_12(t, x, y, z)*beta2(t, x, y, z) + B_31(t, x, y, z)*beta3(t, x, y, z)) dx + (B_12(t, x, y, z)*beta1(t, x, y, z) - B_23(t, x, y, z)*beta3(t, x, y, z)) dy + (-B_31(t, x, y, z)*beta1(t, x, y, z) + B_23(t, x, y, z)*beta2(t, x, y, z)) dz

So we now have a prescription on how to implement both the interior product and the curl of 2 “vectors” –
if you want this:

$-i_{\mathbf{\beta}} B$ which is the differential form version of $\mathbf{\beta} \times B$ (curl), then do this in sagemanifolds:


q = var('q',"real") # define a single charge variable in Sage Math
LorentzForce1form =  make_Et(cart_ch) - make_beta(cart_ch)['^i']*make_Bt(cart_ch)['_ij']

EY : 20160530 I have a question; is there a good way for Sage Math variables such as q in this case (var) to “play with” sagemanifolds tensors? For instance, I obtain this when I multiply a sagemanifolds 1-form by a Sage Math variable (var) q:

q * LorentzForce1form

TypeError                                 Traceback (most recent call last)

 in ()
----&gt; 1 q * LorentzForce1form

/home/topolo/Public/sage/src/sage/structure/element.pyx in sage.structure.element.ModuleElement.__mul__ (/home/topolo/Public/sage/src/build/cythonized/sage/structure/element.c:12191)()
   1369         if have_same_parent_c(left, right):
   1370             raise TypeError(arith_error_message(left, right, mul))
-&gt; 1371         return coercion_model.bin_op(left, right, mul)
   1373     def __imul__(left, right):

/home/topolo/Public/sage/src/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op (/home/topolo/Public/sage/src/build/cythonized/sage/structure/coerce.c:9915)()
   1077         # We should really include the underlying error.
   1078         # This causes so much headache.
-&gt; 1079         raise TypeError(arith_error_message(x,y,op))
   1081     cpdef canonical_coercion(self, x, y):

TypeError: unsupported operand parent(s) for '*': '' and 'Free module /\^1(M) of 1-forms on the 4-dimensional differentiable manifold M'
1-form on the 4-dimensional differentiable manifold M

Nevertheless, for $q=1$, then the 1-form version of the Lorentz Force $F$ is given by the following, and keep in mind that we integrate 1-forms, we don’t integrate vectors (because it goes back to how we transport vectors along a curve, and 1-forms either abscond, circumvent, this problem or is the most natural way to do integration on manifolds):

latex( LorentzForce1form.display() );

$F = \left( B_{12}\left({t}, x, y, z\right) \beta_{2}\left(x, y, z\right) – B_{31}\left({t}, x, y, z\right) \beta_{3}\left(x, y, z\right) + E_{1}\left({t}, x, y, z\right) \right) \mathrm{d} x + \left( -B_{12}\left({t}, x, y, z\right) \beta_{1}\left(x, y, z\right) + B_{23}\left({t}, x, y, z\right) \beta_{3}\left(x, y, z\right) + E_{2}\left({t}, x, y, z\right) \right) \mathrm{d} y + \left( B_{31}\left({t}, x, y, z\right) \beta_{1}\left(x, y, z\right) – B_{23}\left({t}, x, y, z\right) \beta_{2}\left(x, y, z\right) + E_{3}\left({t}, x, y, z\right) \right) \mathrm{d} z$

<br />

Fedora 23 workstation (Linux)+NVIDIA GeForce GTX 980 Ti: my experience, log of what I do (and find out)


Learn from my mistakes. Getting to this screen in Fedora 23 (Linux) is a mini-nightmare.



Table of Contents

I most recently took delivery of a Titan workstation computer (thank you Titan Workstation computers!, the Titan X199: here is some of the configuration:

  • Processor:Intel Xeon E5-1650 v3 Haswell 3.5GHz (3.8 GHz Turbo Boost) 140W 15MB L3 Cache 6 Core
  • Motherboard:MSI X99A SLI PLUS LGA 2011-v3 Intel X99 SATA 6GB/s USB 3.1 USB3.0 ATX Intel Motherboard
  • Memory:32GB (8x4GB)288-Pin DDR4 2133 (PC4-17000) Desktop Memory
  • Power:650W – Deepcool 650W ATX12V SLI Ready CrossFire Ready 80 PLUS GOLD Certified Active PFC Power Supply
  • Video Card 1: NVIDIA GeForce GTX 980 Ti 6GB 384-Bit DDR5 GDDR5 Video Card

First, I wanted to get a workstation to try out some CFD computations, parallelized to the processor(s) and GPU (hence the NVIDIA GeForce GTX 980 Ti, $649.99!), and some Deep Learning/Machine Learning computations, again parallelized out to the GPU. With the NVIDIA, I wanted to learn CUDA. Also, I wanted to build from source Sage Math (it requires a whopping 6 GB of hard drive space) and needed wanted a more capable computer to deal with building Sage Math all the time. Third, I wanted a workstation dedicated to Linux because a lot of the scientific/numerical computation programs work better/install or compile or make “better” in Linux, and I went with Fedora Linux, after doing a Google Search and reading about, more or less, “best linux distro for scientific/numerical computation (e.g. quora).

By the way, I am interested in CFD, Deep Learning/Machine Learning computations, and computational physics, and hence this new workstation, solely because I am currently “seeking opportunities in propulsion development” (i.e. I really want to work in the new companies for commercial space industry, SpaceX, Virgin Galactic, Blue Origin) and am trying to develop my skills (set) to help out in that area.

Coming back to this wordpress post, this post will be continuously updated (just like my other posts on TQFT, General Relativity, Propulsion (for aerospace stuff), and Computers; I wanted to focus on 4 main topics and collect all my writings into 4 blog posts, 1 for each topic, because I wanted to try to allow for deeper insight, than to fire off a cursory blog post, spamming followers; for instance the Computers post is a running log of various tips on programming, software, installation; Gravity has the stuff or links to, including links to my github repo, of what I pick up on GR), and it’ll link back to the Computers because this is my experience dealing with computers. So you can always easily navigate to this post from my simple menu with only 4 topics: TQFT, Gravity, Propulsion, Computers. PS. I wish wordpress had a github-like way of doing version control on blog posts and how you could Publish or push blog posts and media files from the command line, instead of the browser. I’m finding my github repositories way more easy (and fun) to update, either from the command line or browser.

Now, I was/am a sole Mac OS X/iOS user (I find myself losing my memory of how to use Windows as I haven’t used Windows in a long time; I used to edit my Windows key registry for fun) and switching to Fedora Linux so far has been a huge learning curve. I’m going to go ahead and write on tips, hints, advice, and things that I’ve learned even if they might be rudimentary or too simply (or silly) to advanced users because they were not simple to me (and hopefully to others)!

Oh no Fedora! Something has gone wrong; A problem has occurred (with Nvidia drm, rpm and nouveau drivers with a new Fedora kernel); panic, and how I recovered my system

Don't let this happen to your distro.
Learn from my experience: don’t let this happen to you and your Fedora 23 Workstation distro.

I had Fedora 23 Workstation (Linux) up and running and with the fresh install, I first installed the NVIDIA proprietary drivers but simply following the instructions off their official website and the driver itself.

Much later in the day, Fedora asked me to upgrade, via the Software program in Activities, and I did that with dnf system upgrade.

Now when I turn on the computer, it can’t go into X i.e. the GUI and it flickers sometimes:


Taking a look at the built-in EFI boot(er) (I tried and tried again and again to reinstall off a Live USB disk, but it didn’t work because it went straight to this built-in EFI),


Fedora 4.2.3 23 is the original kernel; Fedora 4.4.8 is the offending kernel( right after it installed and restart automatically, fedora’s X graphics environment doesn’t work anymore). Either 3 options can’t load the graphics environment and I’m not sure how to check what driver or package install was bad and remove , configure and try to run again. In either of the 3 options I keep getting this until I ctrl alt f2

Also, I was receiving error messages when I booted up and couldn’t get into my X11 X (graphical) windowing environment; I was stuck at the low-resolution command line.

From my Xorg.0.log, it said

fedora linux Nvidia Failed to initialize the Nvidia kernel module please see the Nvidia system's kernel log for additional error messages and consult the NVIDIA README for details

No devices detected

Fatal server error:
no screens found(EE)

The symbol (EE) is where errors occurred in the boot up.

What happened to me has happened with other people when they use (or, in a kernel update, was switched over to) nouveau drivers (open-source, I think?) for their NVIDIA GTX video card.

Nvidia driver causes boot hang when upgrading to Fedora 23

and also

Nvidia drivers not loading correctly on Fedora 23. However, I would not follow the advice given in, for downgrading X11, nor given in that stackexchange question, respectively.


Instead, what worked for me following, to the letter, the If not true then false Fedora 23/22/21 nVidia Drivers Install Guide. This guide worked for me for reinstalling proprietary NVIDIA drivers after a conflicting kernel upgrade, accidental installing of the nouveau or nvidia-drm drivers. Go there.

I also end up back at the official NVIDIA Linux-64 bit drivers page, especially their Additional Information subpage for instructions on how to install their proprietary drivers; what helped me install the first time, and then reinstall their driver, is this page. Also, keep in mind that you can uninstall using the same command

sh ./NVIDIA-Linux-x86_64-346.35.run --uninstall

but with the uninstall flag (look it up, I forgot the exact syntax of the uninstall command).

Before those steps mentioned above, I I’ll try removing the kernel that was the last major change (it said need to install and restart upgrade and restart led to Oh no screen of death)

From that page, I did the following commands:
rpm -qa | grep ^kernel

You want to be sure that you’re not removing the current kernel you’re running:
uname -r

Finally, the remove:
sudo yum remove kernel-4.4.8-300.fc23.x86_64 kernel-headers-4.4.8-300.fc23.x86_64 kernel-devel-4.4.8-300.fc23.x86_64 kernel-core- kernel-modules-4.4.8-300.fc23.x86_64

Then I uninstalled (from the command line) and reinstalled (following the if not True then False guide) the NVidia drivers.

Wrap up

Finally, you’d want to things like Display video card driver version.

lspci | grep VGA

So in conclusion, my advice from my experience, and of almost losing my X11, X, startX, graphical windowing environment is to

  • Be extremely careful about doing a dnf or yum system upgrade or kernel upgrade, and watch out what dependencies get installed when you do install a new program
  • If you run into trouble, check dnf history to see what steps to (manually) undo
  • In my case, I had to uninstall the new, offending kernel off the built-in EFI boot(er), following http://www.labtestproject.com/using_linux/remove_fedora_kernel.html
  • Uninstall and reinstall the proprietary Linux driver; just follow what it says.

Make a USB (live) boot disk of your distro

Whoops, the NVIDIA GTX 980 Ti did not like that last Fedora 23 upgrade and I have no idea which, in the logs, is what Fedora 23 didn’t like, and so my GUI or X (startX) isn’t starting. Unfortunately, the only thing left to do is to reinstall from a Live USB boot disk.

I did this to find out where my USB disk is on my Mac OS X:

diskutil list

I made a note of which /dev/diskn number (1,2,or 3, etc. where n is, e.g. /dev/disk2) and which number (e.g. it said #2: SANDISKCRUZ and SANDISKCRUZ is the name that I named the disk when I formatted the USB stick, and so #2 it is).

After downloading the 64-bit iso I needed for Fedora, I did, e.g.

sudo dd if=Fedora_Live-Workstation-x86_64-23-10.iso of=/dev/rdisk2s2

I read that adding the ‘r’ in ‘rdisk2s2’ speeds things up.

This process took about 86 minutes on a MacBook Pro, Late-2013 (!!!). To check the status I did Ctrl-T and it gave me records in, records out, and total bytes transferred. I tried pkill and sending a signal with kill but couldn’t work that out.

cf. How to Copy an ISO to a USB Drive from Mac OS X with dd (super useful article/link); is ‘dd’ command taking too long?, Show progress of dd command (clarified many things; his experience on using dd)

Also, keep in mind the official Fedora documentation for making a Live USB:


Off to try to reinstall with this USB disk…

…And it didn’t help. I discovered on my own that Titan workstation computers keep Fedora 23 Workstation linux on the built-in EFI (EFI is like the new bootloader, newer than BIOS). No matter how many times I try to boot off the USB disk by changing the boot order or disabling the SATA disk drive, or any disk drive, the workstation directly boots to the built-in EFI boot loader, for the Fedora 23 Workstation. Aaaaaaaaaaaaaaahhhh. AAAArggggg.

See the above section, Oh no Fedora! Something has gone wrong; A problem has occurred (with Nvidia drm, rpm and nouveau drivers with a new Fedora kernel; panic, and how I recovered my system, to see how I manually, from the command line, recovered my X (graphical) environment.

Installation of NVIDIA CUDA on Fedora 23 Workstation (Linux)

See also my github repository MLgrabbag, the README.md file, for the latest update, as well.

Installation of NVIDIA’s CUDA Toolkit on a Fedora 23 Workstation was nontrivial; part of the reason is that it appears that 7.5 is the latest version of the CUDA Toolkit (as of 20150512), and 7.5 only supports (for sure) Fedora 21. And, this 7.5 version supports (out of the box) C compiler gcc up to version 4.* and not gcc 5. But there’s no reason why the later versions, Fedora 23 as opposed to Fedora 21, gcc 5 vs. gcc 4.*, cannot be used (because I got CUDA to work on my setup, including samples). But I found that I had to make some nontrivial symbolic linking (ln).

I wanted to install CUDA for Udacity’s Intro to Parallel Programming, and in particular, in the very first lesson or video, Intro to the Class, for instructions on running CUDA locally, only the links to the official NVIDIA documentation were given, in particular for Linux,


But one only needs to do a Google search and read some forum posts that installing CUDA, Windows, Mac, or Linux, is highly nontrivial.

I’ll point out how I did it, and refer to the links that helped me (sometimes you simply follow, to the letter, the instructions there) and other links in which you should follow the instructions, but modify to suit your (my) system, and what NOT to do (from my experience).

Gist, short summary, steps to do (without full details), to just get CUDA to work (no graphics)

My install procedure assumes you are using the latest proprietary NVIDIA Accelerated Graphics Drivers for Linux. I removed and/or blacklisted any other open-source versions of nvidia drivers, and in particular blacklisted nouveau. See my blog post for details and description.

  1. Download the latest CUDA Toolkit (appears to be 7.5 as of 20160512). For my setup, I clicked on the boxes Linux for Operation System, x86_64 for Architecture, Fedora for Distribution, 21 for Version (only one there), runfile (local) for Installer Type (it was the first option that appeared). Then I modified the instructions on their webpage:
    1. Run `sudo sh cuda_7.5.18_linux.run`
    2. Follow the command-line prompts.
    3. Instead, I did

      $ sudo sh cuda_7.5.18_linux.run --override

      with the --override flag to use gcc 5 so I did not have to downgrade to gcc 4.*.

      Here is how I selected my options at the command-line prompts (and part of the result):

      $ sudo sh cuda_7.5.18_linux.run --override

      Do you accept the previously read EULA? (accept/decline/quit): accept
      You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: yes
      Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 352.39? ((y)es/(n)o/(q)uit): n
      Install the CUDA 7.5 Toolkit? ((y)es/(n)o/(q)uit): y
      Enter Toolkit Location [ default is /usr/local/cuda-7.5 ]:
      Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
      Install the CUDA 7.5 Samples? ((y)es/(n)o/(q)uit): y
      Enter CUDA Samples Location [ default is /home/[yournamehere] ]: /home/[yournamehere]/Public
      Installing the CUDA Toolkit in /usr/local/cuda-7.5 ...
      Missing recommended library: libGLU.so
      Missing recommended library: libX11.so
      Missing recommended library: libXi.so
      Missing recommended library: libXmu.so

      Installing the CUDA Samples in /home/[yournamehere]/ ...
      Copying samples to /home/propdev/Public/NVIDIA_CUDA-7.5_Samples now...
      Finished copying samples.

      Again, Fedora 23 was not a supported configuration, but I wished to continue. I had already installed NVIDIA Accelerated Graphics Driver for Linux (that’s how I was seeing my X graphical environment) but it was a later version 361.* and I did not want to uninstall it and then reinstall, which was recommended by other webpages (I had already gone through the mini-nightmare of reinstalling these drivers before, which can trash your X11 environment that you depend on for a functioning GUI).

    4. Continuing, this was also printed out by CUDA’s installer:

      Installing the CUDA Samples in /home/propdev/Public ...
      Copying samples to /home/propdev/Public/NVIDIA_CUDA-7.5_Samples now...
      Finished copying samples.

      = Summary =

      Driver: Not Selected
      Toolkit: Installed in /usr/local/cuda-7.5
      Samples: Installed in /home/[yournamehere]/Public, but missing recommended libraries

      Please make sure that
      - PATH includes /usr/local/cuda-7.5/bin
      - LD_LIBRARY_PATH includes /usr/local/cuda-7.5/lib64, or, add /usr/local/cuda-7.5/lib64 to /etc/ld.so.conf and run ldconfig as root

      To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-7.5/bin
      To uninstall the NVIDIA Driver, run nvidia-uninstall

      Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-7.5/doc/pdf for detailed information on setting up CUDA.

      ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 352.00 is required for CUDA 7.5 functionality to work.
      To install the driver using this installer, run the following command, replacing with the name of this run file:
      sudo .run -silent -driver

      Logfile is /tmp/cuda_install_7123.log

      For “ PATH includes /usr/local/cuda-7.5 ” I do

      $ export PATH=/usr/local/cuda-7.5/bin:$PATH

      as suggested by Chapter 6 of CUDA_Getting_Started_Linux.pdf

      Dealing with the LD_LIBRARY_PATH, I did this: I created a new text file (open up your favorite text editor) in /etc/ld.so.conf.d called cuda.conf, e.g. I used emacs:

      sudo emacs cuda.conf

      and I pasted in the directory


      (since my setup is 64-bit) into this text file. I did this because my /etc/ld.so.conf file includes files from /etc/ld.so.conf.d, i.e. it says

      include ld.so.conf.d/*.conf

      Make sure this change for `LD_LIBRARY_PATH` is made by running the command


      as root.

      I check the status of this “linking” to PATH and LD_LIBRARY_PATH with the echo command, each time I reboot, or log back in, or start a new Terminal window:

      echo $PATH
      echo $LD_LIBRARY_PATH

    5. Patch the host_config.h header file

      cf. [nstall NVIDIA CUDA on Fedora 22 with gcc 5.1 and CUDA incompatible with my gcc version.

      To use gcc 5 instead of gcc 4.*, I needed to patch the host_config.h header file because I kept receiving errors. What worked for me was doing this to the file – original version:

      #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)

      #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

      #endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */

      Commented-out version (these 3 lines)

      // #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)

      // #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!

      // #endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */

      Afterwards, I did not have any problems with c compiler gcc incompatibility (yet).

    6. At this point CUDA runs without problems if no graphics capabilities are needed. For instance, as a sanity check, I ran, from the installed samples with CUDA, I made `deviceQuery` and ran it:

      $ cd ~/NVIDIA_CUDA-7.5_Samples/1_Utilities/deviceQuery
      $ make -j12
      $ ./deviceQuery

      And then if your output looks something like this, then success!

      ./deviceQuery Starting...

      CUDA Device Query (Runtime API) version (CUDART static linking)

      Detected 1 CUDA Capable device(s)

      Device 0: "GeForce GTX 980 Ti"
      CUDA Driver Version / Runtime Version 8.0 / 7.5
      CUDA Capability Major/Minor version number: 5.2
      Total amount of global memory: 6143 MBytes (6441730048 bytes)
      (22) Multiprocessors, (128) CUDA Cores/MP: 2816 CUDA Cores
      GPU Max Clock rate: 1076 MHz (1.08 GHz)
      Memory Clock rate: 3505 Mhz
      Memory Bus Width: 384-bit
      L2 Cache Size: 3145728 bytes
      Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
      Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
      Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
      Total amount of constant memory: 65536 bytes
      Total amount of shared memory per block: 49152 bytes
      Total number of registers available per block: 65536
      Warp size: 32
      Maximum number of threads per multiprocessor: 2048
      Maximum number of threads per block: 1024
      Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
      Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
      Maximum memory pitch: 2147483647 bytes
      Texture alignment: 512 bytes
      Concurrent copy and kernel execution: Yes with 2 copy engine(s)
      Run time limit on kernels: Yes
      Integrated GPU sharing Host Memory: No
      Support host page-locked memory mapping: Yes
      Alignment requirement for Surfaces: Yes
      Device has ECC support: Disabled
      Device supports Unified Addressing (UVA): Yes
      Device PCI Domain ID / Bus ID / location ID: 0 / 3 / 0
      Compute Mode:

      deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 7.5, NumDevs = 1, Device0 = GeForce GTX 980 Ti
      Result = PASS

    7. Getting the other samples to run, getting CUDA to have graphics capabilities, soft symbolic linking to the existing libraries.

      The flow or general procedure I ended up having to do was to use `locate` to find the relevant `*.so.*` or `*.h` file for the missing library or missing header, respectively, and then making soft symbolic links to them with the `ln -s` command. I found that some of the samples have different configurations for in which directory the graphical libraries are (GL, GLU, X11, glut, etc.) than other samples in the samples included by NVIDIA.

    To be continued, and see my github repo MLgrabbag, the README.md file, for the latest update (html code is a pain compared to markdown and I don’t want to download anymore programs to convert markdown to html (I’m already doing a lot of installing already)).

    Sage Math: Installing programs on Fedora 23 (Linux)

    First, I tried this, following Sage Math install from source. I followed the steps until, at Step-by-Step installation procedure, General procedure, 4. Read the README.txt I read README.md
    I use emacs so I did emacs README.md where sage-7.1 is; in README.md, in section More Detailed Instructions to Build from Source, I did
    export MAKE="make -j14"
    because my processor has 12 (I find that out by the following:
    cf. http://www.binarytides.com/linux-cpu-information/

    $ less /proc/cpuinfo
    $ cat /proc/cpuinfo | grep processor | wc -l
    and then I use more than 14 jobs for 12 processors. It took about 25-30 minutes.

    However, it failed to build, again and again, even for libraries I successfully installed through Anaconda conda (from Continuum) such as git-2.6. and matplotlib. So now I am trying to follow the instructions I received from Eric Gourgoulhon (LUTH) gave me for building Sage Math from the git develop version, which I had already accounted for in my Computers post, under Starting or beginning developing (i.e. contributing code) to a major open-source project, in this case, Sage Math.

    If you’re getting errors when building from github Sage Math using my and Gourgoulhon’s instructions,

    Check the errors you’re receiving and the suggested log files. In the “root” directory of sage directory with the source src, there is a logs/pkgs directory with all the logs of installed or failed packages, and in my particular case, flask_babel-0.9.log failed. Reading the log,it was a “Download Error!” So it was probably a problem with my internet connection (I’ve had problems with Time Warner Cable as a service provider for service interruptions and I cannot recommend TWC).

    Try your make again, but be sure not to overwrite the previously successful package build by typing at the command prompt of the main sage directory


    cf. http://hpc.wm.edu/SciClone/documentation/software/math/sage-5.1/html/en/installation/source.html

    Also, I was able to build from the pre-built Linux binaries:

    In my experience, either following the instructions I and Eric Gourgoulhon gives, as stated in my “Computers” blog post, to build straight from the git development version, and pre-built binary, in Mac OS X and Fedora Linux, is the way to go for installing Sage Math – building from source instructions in Sage Math haven’t worked for me.

    TeXLive Install for LaTeX

    This was straightforward. I did this:
    yum install texlive-scheme-full

    cf. How to fully install Latex in fedora?

    Good intentions; bad advice i.e. DON’T follow these commands carelessly in Fedora 23 (Linux)

    You may be (at least I certainly was) in a rush to fix something and so you are furiously doing Google searches and searching forum posts and trying any kind of command(s) to fix the problem. But here, I collect commands NOT to do (casually).


    dnf -y upgrade

    Don’t do dnf upgrade casually. This is because NVIDIA’s proprietary drivers may have conflict with the latest kernel. This has happened with others.

    You don’t need to downgrade X11!!!

    I found that I didn’t need to downgrade my X11 as advised in the article NVIDIA – Incompatible with Fedora 23 Xorg – and a Workaround.., as the latest NVIDIA drivers did just fine.

    How not to replace nouveau drivers in Fedora 23

    cf. HOWTO: Install NVIDIA driver on Fedora – replacing Nouveau

    I wouldn’t do it this way (and it didn’t work for me, in the crucial step #4 of theirs, to blacklist nouveau in /etc/modprobe.d with the commands

    echo 'blacklist nouveau' >> /etc/modprobe.d/disable-nouveau.conf
    echo 'nouveau modeset=0' >> /etc/modprobe.d/disable-nouveau.conf

    Instead, what worked for me, again, as previously linked and written about above, is to following, to the letter, the If !1 0 Fedora 23/22/21 nVidia Drivers Install Guide.

    While on that note, advice in the fedoraforum post, entitled
    [SOLVED] Oh no! Something has gone wrong didn’t help me. I was thinking of trying to do a reinstall of Fedora into the built-in EFI, but this post, how to install Fedora 11 in EFI shell and GPT partition? didn’t help.

    I had the same problem as described here (with a similar log), in FC22: nvidia kernel module loads, but X can’t initialize GPU, but the fix the member StefanJ proposed didn’t help in my situation.

    Number of “cores” on Fedora 23 (Linux)? In Linux, they’re called cpus or processors

    grep processor /proc/cpuinfo

    cat /proc/cpuinfo | less

    Also, other system information:

    cat /proc/meminfo | less

    cf. http://www.cyberciti.biz/faq/linux-display-cpu-information-number-of-cpus-and-their-speed/

    getting error “Can’t create transaction lock” with rpm

    getting error “Can’t create transaction lock” with rpm


    “Try running your command as root. It worked for me.” –phathutshezo

Gravity – Gravité

Table of Contents

Notes on General Relativity (GR) and Gravity – includes notes on the Central Lectures given by Dr. Frederic P. Schuller for the WE Heraeus International Winter School on Gravity and Light

Notes (LaTeX format) on General Relativity (GR) and Gravity – includes notes on the Central Lectures given by Dr. Frederic P. Schuller for the WE Heraeus International Winter School on Gravity and Light; link to github, will be the most up-to-date and permanent

Notes (LaTeX format) on General Relativity (GR) and Gravity – includes notes on the Central Lectures given by Dr. Frederic P. Schuller for the WE Heraeus International Winter School on Gravity and Light; link to github, will be the most up-to-date and permanent

Notes (pdf format) on General Relativity (GR) and Gravity – includes notes on the Central Lectures given by Dr. Frederic P. Schuller for the WE Heraeus International Winter School on Gravity and Light; link to github, will be the most up-to-date and permanent

Lecture # Lecture name Lecture link Tutorial # Tutorial name Tutorial video link Tutorial sheet (pdf)
3 Lecture 3: Multilinear Algebra (International Winter School on Gravity and Light 2015) https://youtu.be/mbv3T15nWq0 3 Tutorial 3: Multilinear Algebra (International Winter School on Gravity and Light 2015) https://youtu.be/5oeWX3NUhMA tensors_neu.pdf

NOT Updated: NOTES ON GENERAL RELATIVITY (GR) AND GRAVITY in wide, “grande” format; includes notes on the Central Lectures given by Dr. Frederic P. Schuller for the WE Heraeus International Winter School on Gravity and Light from wordpress NOT UPDATED

gravite github repository

github.io page for Gravite

github repository for Gravite

Euclidean space as a Manifold – R^2,R^3,R^n

Using SageManifolds, Euclidean space, R^2, R^3, and R^n, is implemented as a manifold.

Rn.sage – Euclidean spaces as manifolds using sagemanifolds


  • R^2,R^3,R^n as a manifold, with a chart atlas
sage: load(‘‘Rn.sage’’)  
sage: R2eg = R2() 
sage: R3eg = R3() 
sage: R4 = Rn(4) 
sage: R2eg.M.atlas()
[Chart (R2, (x, y)), Chart (U, (x, y)), Chart (U, (r, ph))]
sage: R3eg.M.atlas()
[Chart (R3, (x, y, z)),
 Chart (U, (x, y, z)),
 Chart (U, (rh, th, ph)),
 Chart (U, (r, phi, zc))]
sage: R4.M.atlas()
[Chart (R4, (x1, x2, x3, x4)),
 Chart (U, (x1, x2, x3, x4)),
 Chart (U, (rh, th1, th2, ph)),
 Chart (U, (r, the1, phi, z))]
  • (carefully) define a spherical coordinate and cylindrical coordinate chart on Euclidean spaces, e.g.
sage: R2eg.transit_sph_to_cart.display() 
x = r*cos(ph)
y = r*sin(ph)
sage: R3eg.transit_sph_to_cart.display() 
x = rh*cos(ph)*sin(th)
y = rh*sin(ph)*sin(th)
z = rh*cos(th)
sage: R3eg.transit_cyl_to_cart.display() 
x = r*cos(phi)
y = r*sin(phi)
z = zc
sage: R4.transit_sph_to_cart.display() 
x1 = rh*cos(ph)*sin(th1)*sin(th2)
x2 = rh*sin(ph)*sin(th1)*sin(th2)
x3 = rh*cos(th2)*sin(th1)
x4 = rh*cos(th1)
  • calculate the Jacobian!
sage: to_orthonormal2 , e2, Jacobians2 = R2eg.make_orthon_frames(R2eg.sph_ch) 
sage: Jacobians2[0].inverse()[:,R2eg.sph_ch]
[ cos(ph) -r*sin(ph)]
[ sin(ph) r*cos(ph)]
sage: to_orthonormal3sph, e3sph, Jacobians3sph = R3eg.make_orthon_frames(R3eg.sph_ch) 
sage: to_orthonormal3cyl, e3cyl, Jacobians3cyl = R3eg.make_orthon_frames(R3eg.cyl_ch) 
sage: Jacobians3sph[0].inverse()[:,R3eg.sph_ch]
[ cos(ph)*sin(th) rh*cos(ph)*cos(th) -rh*sin(ph)*sin(th)]
[ sin(ph)*sin(th) rh*cos(th)*sin(ph) rh*cos(ph)*sin(th) ]
[ cos(th)         -rh*sin(th)        0                  ]
sage: Jacobians3cyl[0].inverse()[:,R3eg.cyl_ch]
[ cos(phi) -r*sin(phi) 0]
[ sin(phi) r*cos(phi) 0] 
[ 0 0 1]
  • equip the Euclidean space manifold with a metric g and calculate the metric automatically:
sage: R2eg.equip_metric() 
sage: R3eg.equip_metric() 
sage: R4.equip_metric()

sage: R2eg.g.display(R2eg.sph_ch.frame(),R2eg.sph_ch)
g = dr*dr + r^2 dph*dph
sage: R3eg.g.display(R3eg.sph_ch.frame(),R3eg.sph_ch)
g = drh*drh + rh^2 dth*dth + rh^2*sin(th)^2 dph*dph
sage: R3eg.g.display(R3eg.cyl_ch.frame(),R3eg.cyl_ch)
g = dr*dr + r^2 dphi*dphi + dzc*dzc
sage: R4.g.display(R4.sph_ch.frame(),R4.sph_ch)
g = drh*drh + rh^2 dth1*dth1 + rh^2*sin(th1)^2 dth2*dth2 + rh^2*sin(th1)^2*sin(th2)^2 dph*dph
sage: R4.g.display(R4.cyl_ch.frame(),R4.cyl_ch)
g = dr*dr + r^2 dthe1*dthe1 + r^2*sin(the1)^2 dphi*dphi + dz*dz
  • Calculate the so-called orthonormal non-coordinate basis vectors in terms of the (local) coordinate basis vectors, showing clearly and distinctively the difference between the two (concepts)
sage: e2[1].display( R2eg.sph_ch.frame(), R2eg.sph_ch)
e_1 = d/dr
sage: e2[2].display( R2eg.sph_ch.frame(), R2eg.sph_ch)
e_2 = 1/r d/dph
sage: for i in range(1,3+1):                                                         
    e3sph[i].display( R3eg.sph_ch.frame(), R3eg.sph_ch )
e_1 = d/drh
e_2 = 1/rh d/dth
e_3 = 1/(rh*sin(th)) d/dph
sage: for i in range(1,3+1):
    e3cyl[i].display( R3eg.cyl_ch.frame(), R3eg.cyl_ch )
e_1 = d/dr
e_2 = 1/r d/dphi
e_3 = d/dzc


I’m on the physics stackexchange!

profile for ernestyalumni2014 at Physics Stack Exchange, Q&A for active researchers, academics and students of physics


I will place all the links and blog posts related to computers here.

Table of Contents

Commands I continue to use over and over again on Fedora 23 Workstation Linux

THEANO, tensorflow:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
THEANO_FLAGS='mode=FAST_RUN,device=gpu,floatX=float32' python gpu_test.py

for CuDNN:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
THEANO_FLAGS='mode=FAST_RUN,device=gpu,floatX=float32' jupyter notebook

In general:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64

echo _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev | c++filt

nvidia-smi -l 1 : constantly monitor your GPU every second until Ctrl-C

nvidia-smi -l 1

-l,   –loop=               Probe until Ctrl+C at specified second interval.
1 (seconds)


nvidia-smi -h

is useful for getting help information.

Also, take a look at


for every which way to use nvidia-smi to get information about your Nvidia card (!!!).

20 Command Line Tools to Monitor Linux Performance

netstat -a | more  
netstat --help
# -a is for display all sockets; the default is connected, the connected sockets
netstat | more



20160620 – what I wrote in my journal to myself

I lost a lot of files in the local CompPhys repository because of a hard git reset locally. Be careful with cancelling git commits and git resets hard.

Be careful with internet advice on hard git resets.

Here is the dump of what files.

Github from Terminal

I was looking up how on Google for best practices on using github to share a LaTeX file so that collaborators, co-authors, and/or student and thesis mentor could work on the same file together. These links then led me to learn how to use git i.e. github from my Terminal on Mac OSX which I didn’t know how to do before (because I, at least, found the github help pages for this byzantine).

I had made a repository in github from a web browser which was essentially fill out webforms/(text) boxes, and point and click through menus. But I hadn’t connected to it via Terminal.

ShareLaTeX Blog Collaborating with LaTeX and git

Commands that I used from this page:
$ cd my-project
$ git init
$ git add project.tex
$ git commit -m “My first commit”

At this point, I received this error message:

[master (root-commit) 05d5bef] filename.tex updated
Committer: Firstname Lastname
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
$ git config --global --edit
After doing this, you may fix the identity used for this commit with:
$ git commit --amend --reset-author
1 file changed, 2601 insertions(+)
create mode 100644 filename.tex

I also used

$ git log
$ git remote add origin git@github.com:username/my-project.git
$ git push origin master

Now, doing

$ git config --global --edit

Sent me to the vi editor. I didn’t know vi so I used this webpage for vi commands:
Basic vi commands

This webpage was instructive,
Melody Kramer and Greg Boone – How to use GitHub and the terminal: a guide

I only used the following commands from there:
git remote -v
Now doing

$ git push origin master

led to
The authenticity of host 'github.com (' can't be established.
RSA key fingerprint is lettersnumbers.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,nnn.nn.nnn.nnn’ (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried the following:

$ git config --global user.name “username”
$ git config --global user.name “emailaddress@email.com"
$ git remote add upstream http://github.com/username/repo_name.git
$ git push origin master
Warning: Permanently added the RSA host key for IP address ‘nnn.nn.nnn.nnn’ to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

$ git push origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

which led me to these very useful pages:

This page, Error: Permission denied,
addressed directly the error.

Generating SSH keys

This page was very useful because I had to generate my first SSH key.

$ ls -al ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
$ pbcopy < ~/.ssh/id_rsa.pub
$ ssh -T git@github.com

Finally, the desired result is thus:
git push origin master
Warning: Permanently added the RSA host key for IP address 'nnn.nn.nnn.nnn' to the list of known hosts.
Identity added: /Users/username/.ssh/id_rsa ((null))
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 1.11 KiB | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
To git@github.com:username/reponame.git
numbersletters..numbersletters master -> master

Finally, with github on terminal setup, we can do the following:

Add a file to a github repo

$ git add hypergeo.sage
$ git commit -m “file.sage added"
[master a2cd1b4] file.sage added
1 file changed, 49 insertions(+)
create mode 100644 file.sage
$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.12 KiB | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:username/reponame.git
2b414a7..a2cd1b4 master -> master
Branch master set up to track remote branch master from origin.

-u flag stands for upstream, to “make changes to the ‘main’ github repo”

Change the main (text) editor used for github

As shown in this stackexchange question,

$ git config --global core.editor "name-of-your-editor"

Further tips or commands to use from railsgirls

Again, to reiterate, the main commands (that I use) to add files and to add a file (along with its changes) are the following:

$ git add file.sage
$ git commit -m “file.sage added"
$ git push -u origin master
# -u flag stands for upstream, to “make changes to the ‘main’ github repo”

Clone an EXISTING repository into your local harddrive

Follow the instructions under “Clone a repo on your computer” cf. Melody Kramer and Greg Boone – How to use GitHub and the terminal: a guide:

  1. Copy url (use https (recommended))
  2. git clone https://github.com/username/reponame.git

“Fork”ing in github: what is it? (It’s making your own copy (at that instant in time) of an existing repository and then having it under your github name

This webpage, Forking, fetching, pushing, pulling had an excellent explanation (otherwise, to the beginner, these funky names “fork”, “push”, “pull” are arcane, disorienting, or just a big WTF).

Example of Usage: I wanted to “fork”, i.e. make a copy of, the Udacity CS344 Intro to Parallel Programming github repo, with all its Lessons Code Snippets and Problem Sets, into a local copy on my hard drive, and also share my changes on my github. So I followed that webpage, Forking, fetching, pushing, pulling and went to the original repository page, pressed the Fork button, and cloned on my local computer, as usual.

Starting or beginning developing (i.e. contributing code) to a major open-source project, in this case, Sage Math

Say you wanted to contribute to a major open-source project; in this case Sage Math.

Summary of necessary commands

From Eric Gourgoulhon of sagemanifolds with my addition.

  1. Get the latest development version of Sage by the following:

    git clone git://github.com/sagemath/sage.git
    cd sage
    git checkout -b develop
    git pull origin develop
    MAKE='make -j8' make # adapt -j8 to the number of cores on your computer
    You can check that everything works by:
    ./sage # open Sage in console mode
    ./sage -n # open Sage notebook
    ./sage -n jupyter # open Sage in Jupyter notebook
  2. Merge the latest development version of SageManifolds into the above version of Sage:

    git checkout -b my_project # put your stuff in a new branch, based on develop
    git remote add trac git://trac.sagemath.org/sage.git -t master
    git remote set-url --push trac git@trac.sagemath.org:sage.git
    git pull trac public/manifolds/diff_manif_metrics
    ./sage -b
  3. You are ready to add your own code by editing/adding source files in


    Each time you make a modification, you must run

    ./sage -b

    before running sage.
  4. Once you are ready, push everything to SageMath Trac via
    git commit -a -m "My changes..."
    git push trac HEAD:public/manifolds/project_name

    replacing “project_name” by a more specific name.
  5. Open a ticket on trac and add the branch

    in the “Branch” field on the ticket description.

My experience; further explanations


I found myself in a situation where I had files installed from using sagemanifolds and I wanted to update my git local version. git fetch didn’t work because of files it had to remove locally. I did git reset --hard origin/develop (which I do not recommend to do lightly), then git pull origin develop.

I had to do MAKE='make -j12' make and then MAKE='make -j12' SAGE_KEEP_BUILT_SPKGS='yes' make many times, and then SAGE_KEEP_BUILT_SPKGS='yes' make and then SAGE_KEEP_BUILT_SPKGS='yes' make doc-clean to finish the installation and have everything work. For some reason, the installation kept stopping.

In my experience, without the previous instructions above, I wouldn’t have been able to contribute to the Sage Math code as soon as I did, because I didn’t understand the Sage Math developer page and instructions.

But I wanted to “develop” or contribute code to a major open-source project (this case, Sage Math!). I had no idea how to do it. But the previous commands helped tremendously. Here’s what I did.

You’ll need your own SSH keys.

First, check for existing SSH keys.

$ ls -al ~/.ssh
ls: /Users/melocaluser/.ssh: No such file or directory

So ssh keys need to be generated. Thus
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter file in which to save the key (/Users/melocaluser/.ssh/id_rsa):

Press Enter (I pressed Enter).

Created directory '/Users/melocaluser/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

(I entered a password/passphrase.)

Your identification has been saved in /Users/melocaluser/.ssh/id_rsa.
Your public key has been saved in /Users/melocaluser/.ssh/id_rsa.pub.
The key fingerprint is:
SAA252:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 mygithubname@somedomain.com

The key's randomart image is:
+---[RSA 2296]----+
| |
| |
|a . . |
| . w . |
| . ..o S |
| o ...= + |
| o oo.X + o |
|. .ooEo&.=. |
| o&C=%C. |

Adding a new SSH key to the ssh-agent

$(ssh-agent -s)"
Agent pid 915

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /Users/mylocalusername/.ssh/id_rsa:
Identity added: /Users/mylocalusername/.ssh/id_rsa (/Users/mylocalusername/.ssh/id_rsa)

Add a new SSH key to your GitHub account
Copy the SSH key to your clipboard.

pbcopy < ~/.ssh/id_rsa.pub

Then, Settings and SSH keys, starting from the top-right profile pic.

Then, following this:
Manually Linking your Public Key to your Trac Account
and add the SSH keys to your Sage developer account.

git clone https://github.com/sagemath/sage.git

Cloning into 'sage'...
remote: Counting objects: 368910, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 368910 (delta 0), reused 0 (delta 0), pack-reused 368895
Receiving objects: 100% (368910/368910), 117.60 MiB | 1.58 MiB/s, done.
Resolving deltas: 100% (275159/275159), done.
Checking connectivity... done.

$ cd sage
$ git checkout -b develop
Switched to a new branch ‘develop’

$ git pull origin develop
From https://github.com/sagemath/sage
* branch develop -> FETCH_HEAD
Updating 1961f94..d941d8d
VERSION.txt | 2 +-
build/pkgs/configure/checksums.ini | 6 +-

You’ll have to check how many cores are on your computer before running make

$ sysctl -n hw.ncpu

If you receive this message running MAKE on a Mac OS X, it means that you haven’t installed your Xcode Command-Line tools. You should install the Xcode Command-Line tools, in general.

$ MAKE='make -j4' make

The directory that should contain system headers does not exist:
make[6]: *** [stmp-fixinc] Error 1
rm gcc.pod
make[5]: *** [all-stage1-gcc] Error 2
make[4]: *** [stage1-bubble] Error 2
make[3]: *** [all] Error 2

real 2m55.577s
user 6m55.597s
sys 1m20.139s

Error installing package gcc-4.9.3.p1

Please email sage-devel (http://groups.google.com/group/sage-devel)
explaining the problem and including the relevant part of the log file
Describe your computer, operating system, etc.
If you want to try to fix the problem yourself, don’t just cd to
/Users/mylocalusername/Public/sage/local/var/tmp/sage/build/gcc-4.9.3.p1 and type ‘make’ or whatever is appropriate.
Instead, the following commands setup all environment variables
correctly and load a subshell for you to debug the error:
(cd ‘/Users/mylocalusername/Public/sage/local/var/tmp/sage/build/gcc-4.9.3.p1’ && ‘/Users/mylocalusername/Public/sage/sage’ –sh)
When you are done debugging, you can type “exit” to leave the subshell.

make[2]: *** [/Users/mylocalusername/Public/sage/local/var/lib/sage/installed/gcc-4.9.3.p1] Error 1
make[1]: *** [all-toolchain] Error 2

real 8m22.766s
user 11m42.504s
sys 3m38.274s

Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of ‘make all’):

  • package: gcc-4.9.3.p1
    log file: /Users/mylocalusername/Public/sage/logs/pkgs/gcc-4.9.3.p1.log
    build directory: /Users/mylocalusername/Public/sage/local/var/tmp/sage/build/gcc-4.9.3.p1

The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run ‘make’ again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to ‘yes’ to prevent this.

make: *** [all] Error 1

Installing Xcode command line tools

$ xcode-select --install


$ MAKE='make -j4' make

MAKE, on a 2013 MacBook Pro, took me 2.5 hours. Be aware of this time and you needing to be there to periodically check that the make process is running and that your power doesn’t shut off and that the hard drive doesn’t go to sleep.

You can check that everything works by:

./sage # open Sage in console mode
/sage -n # open Sage notebook
./sage - n jupyter # open Sage in Jupiter notebook

It’s important to add so-called “Untracked files”, files that aren’t in the original github repository, by this command.

git add

For instance, running

$ git commit -a -m "Added an import because Manifold is needed; not sure if it is the correct statement"
On branch Gravite
Untracked files:

nothing added to commit but untracked files present
$ git status
On branch Gravite
Untracked files:
(use "git add ..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)

So with this explanation from git-scm, these commands were successful in adding my Untracked file I wanted to add to the repository:

$ git add src/sage/manifolds/differentiable/Rn.py
$ git commit -a -m "Added an import because Manifold is needed; not sure if it is the correct statement"
[Gravite 06cd77b] Added an import because Manifold is needed; not sure if it is the correct statement
Committer: firstname lastname
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

git config --global --edit

After doing this, you may fix the identity used for this commit with:

git commit –amend –reset-author

1 file changed, 430 insertions(+)
create mode 100644 src/sage/manifolds/differentiable/Rn.py

So you’re going to have to change your git config in a vi editor.

$ git config --global --edit


$ git commit --amend --reset-author
[Gravite f3db410] Added an import because Manifold is needed; not sure if it is the correct statement
1 file changed, 430 insertions(+)
create mode 100644 src/sage/manifolds/differentiable/Rn.py

The rest of the commands follow from above:

Troubleshooting installation of Sagemanifolds onto Sage Math for Mac OS X

I have OS X El Capitan 10.11.4 installed on both a Mid 2011 13-inch MacBook Air and Late 2013 13-inch MacBook Pro Retina. Xcode and Xcode Command Line Tools are both installed and updated. I have also used Homebrew (PS these are good, fast tips on using brew), via brew upgrade python and brew upgrade gcc to update my Python (in order to possibly address the problem of not having my Python development headers installed and having a brew-installed gcc which is separate from Xcode gcc, as a precompiled gcc.

I’ve double-clicked and installed sage-7.1-OSX_10.11.3-x86_64.app.dmg choosing the Intel option (I’ve made this mistake before of choosing the PowerPC option on the Sage Math page, and wondering why it doesn’t install; thanks Bejger and Gourgoulhon) by dragging and dropping into Applications. Note that I’ve also tried sage-7.2.beta0-OSX_10.11.4-x86_64.app.dmg, but obtained the same errors.

I downloaded the sm-install script and moved it into the folder with the sage executable, e.g. /Applications/SageMath-7.2.beta0.app/Contents/Resources/sage. I made sure gsed was installed by typing gsed at the command prompt.

I ran bash sm-install in the directory with the sage executable and sm-install.sh script and obtained the following error, after it copied

sage/* files into build/lib.macosx-10.9-x86_64-2.7/sage/*,

and then as it sought to
Executing 435 commands (using 1 thread)
[ 1/435] creating build/temp.macosx-10.9-x86_64-2.7/Applications
, and it goes into gcc compiling; and stops at number 8:

[ 8/435] gcc -fno-strict-aliasing -I/Users/buildslave-sage/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidma/local/var/tmp/sage/build/python2-2.7.10.p1/include -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/local/lib/python2.7/site-packages/cysignals -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/local/include -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/local/include/python2.7 -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/local/lib/python2.7/site-packages/numpy/core/include -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src/sage/ext -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src/build/cythonized -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src/build/cythonized/sage/ext -I/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/local/include/python2.7 -c /Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src/build/cythonized/sage/calculus/riemann.c -o build/temp.macosx-10.9-x86_64-2.7/Applications/SageMath-7.2.beta0.app/Contents/Resources/sage/src/build/cythonized/sage/calculus/riemann.o -fno-strict-aliasing -w
error: command 'gcc' failed with exit status 1
make: *** [sage] Error 1

In Sage Math now, instead of the function Manifold giving the Topological Manifold only version, it now yields the following ImportError:

ImportError: No module named structure

For right now, I have been using Sage Math 6.8 with Sagemanifolds 0.9 installed and a source (src) compiled version of Sage Math 7.1 developers’ beta obtained from github.


How to start Anaconda Navigator

It is also possible to launch it from a terminal or command prompt with the command anaconda-navigator.

  • Mac OS X pip install tip – I’m on a user account with no admin privileges; here’s how I install stuff from pip and run on THIS user account

    I do

pip install –user theano

for example, when I’m on a user account and I want to install on this user account from Mac OS X, but it doesn’t have administrator account.  It’ll be able to import, i.e. I can do import theano at the Python interpreter, on this user account.  No sudo or admin account needed.

Again, it’s

pip install –user <modulename>

cf. How to use pip after the OS X El Capitan upgrade?

Also, I did

pip install –user –upgrade pip

because it was about time.

I also needed pymonad so I did

pip install –user pymonad


SU2 : open-source CFD

Installation – Simple Build from github source

First, git clone.

Then I followed in the instructions in this link for a Simple Build.

This was my build summary:

Build Configuration Summary:

Source code location: /Users/majkypernstejnskych/Public/SU2
Install location: /Users/majkypernstejnskych/Public/SU2build/SU2
Version: 4.1.1
C++ Compiler: g++
C Compiler: gcc
Preprocessor flags:
Compiler flags: -g -O2
Linker flags:
MPI support: no
Metis support: no
Parmetis support: no
TecIO support: no
CGNS support: no
HDF5 support: no
SZIP support: no
ZLIB support: no
Mutation++ support: no
Jsoncpp support: no
LAPACK support: no
Datatype support:
double yes
complex no
codi_reverse no
codi_forward no

External includes:
External libs:

Build SU2_CFD: yes
Build SU2_DOT: yes
Build SU2_MSH: yes
Build SU2_DEF: yes
Build SU2_SOL: yes
Build SU2_GEO: yes

I receive this hint:

Please be sure to add the $SU2_HOME and $SU2_RUN environment variables,
and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN.

Based on the input to this configuration, add these lines to your .bashrc file:

export SU2_RUN="/Users/majkypernstejnskych/Public/SU2build/SU2/bin"
export SU2_HOME="/Users/majkypernstejnskych/Public/SU2"
export PATH=$PATH:$SU2_RUN

I’m not familiar with changing my .bashrc or changing my path environment, and so I’m blogging about it here.

init and Python packaging (cf. Dave Forgac)

First, Dave Forgac’s 2015 PyOhio talk on Python Packaging from Init to Deploy gives a very lucid and understandable (grokkable?) introductory talk on the latest, best practices on (lazy) automating init and Python packaging.

Here’s Dave Forgac’s twitter page.


Following Dave Forgac’s talk, when he actually gets into the code, after his very lucid and descriptive introduction, by minute 20:15, I pip installed the following:

pip install wheel
pip install twine
pip install tox

wheel creates new wheel format. twine for secure uploading to PyPI.
tox is a test runner.

Dealing with boilerplate: cookiecutter

pip install cookiecutter

Going to this page, I found suggested templates to “cookiecut” from in Available Cookiecutters. I wanted a minimal template, so I was pondering the use of these 2 templates, cookiecutter-pypackage-minimal: A minimal Python package template and cookiecutter-pipproject: Minimal package for pip-installable projects. I went with the latter for now, though the former looks intriguing as well.

Then I did this:

cookiecutter https://github.com/wdm0006/cookiecutter-pipproject.git

whence after filling out the names for my project, cookiecutter created locally in a subdirectory of my working directory a project template/boilerplate.

Working with cookiecutter-pipproject.git – “filling in the blanks”

Take a look at the files in this boilerplate template.

  • Dealing with installation requirements: This is completely handled by the requirements.txt file. Open it up in your favorite text editor (I use emacs) and type in each package your Python program requires (that you imported in with import). Press enter for each, so a new line is created. For example, here’s what I did for my project on Combustion chambers:


    This is my requirements.txt file.
  • LICENSE.md As Dave Forgac said, having a license is important, even if you don’t care about its ownership, because others can’t work or include it without any license at all. I went to choosealicense.com and copied the license I chose (MIT) and copied and pasted the text into LICENSE.md.

Miscellaneous links I found useful while googling around for “best practices python init init.py”:

Freeing up disk space on a Mac e.g. I’ve deleted everything off of Photos AND turned off iCloud Photo Library, but my disk space is still gone!

Today (20160318), I moved photos and videos I had on my iPhone 6 into Photos app by turning on, in Photos, Preferences-> iCloud, iCloud Photo Library box to check in on. Then my photos and vidoes were automatically downloaded from the iPhone 6, which had iCloud Photo Library turned on already. Then I was able to export all my photos and videos onto my external hard drive, because the Mac that I use, a MacBook Air, is 5 years old already and doesn’t have much free space available. I was able to grab 7 gbs of photos and videos off my iPhone 6, through iCloud, and onto my Photos app. And then I did File->Export->Export Unmodified Original and then saved appropriately in the New Folder I wanted on my external hard drive.

I saw that during the process, my disk space usage fluctuated from 7 gbs to 20 gbs (using up all my disk space, and thus Startup Disk gave me a warning).

After I grabbed the photos, and especially the 7 gb video off my iPhone 6 that I wanted (it was a lecture from school), I really wanted to turn off iCloud Photo Library on this Mac as it can’t really handle it with its cramped disk drive. I turned off the iCloud Photo Library option in Preferences of Photos app, deleted the photos, made an irrecoverable delete in the Recently Deleted folder (i.e. cleared out my Recently Deleted folder), and yet those 7 gb of disk space was not freed up from before.

I opened up Disk Utility (LaunchPad->Other->Disk Utility) and saw that “Other” was taking up alot more space than usual. I tried to look up on how to figure out what the breakdown of “Other” was, but it wasn’t very helpful cf. What Is Other Storage on Mac OS X and How to Remove It?; OS X: What is “other” space in About This Mac?.

Then I tried deleting my Photos Library (with Photos app closed). It appears that the so-called “Reference Library” can be moved around and doesn’t even have to be local: How to use external and referenced libraries with Photos for OS X. That didn’t help in recovering the majority of 7 gb. However, when I started up Photos on my Mac again, it prompted me to rebuild from my iPhoto Library the Photos Library (that was missing), and it did so, and that Photos Library took up 200 mb now, instead of 520 mb, which is a Photos Library where I deleted all my photos and videos!

To pinpoint where on my disk drive is all this “Other” files, this page with its commands proved useful:
OS X Yosemite: Increase disk space

and the commands, in Finder

Go -> Home
or press Shift-Command -H
File -> Find
, or press Command –F.

These commands allowed me to search on Finder depending on a huge list of attributes. I knew that the only modifications to my Mac was today, and so I searched by “Date Modified” and within 1 day. Taking a look at the file listing, I found what stuck out, what was “unusually” (subjective, you’ll have to do your own digging and judging) modified today, which was the file directory


And in that folder, I found my missing 10 gb, cached, and from Date Modified, Date Created, I knew that these were exactly the temporary files created during the process I described above, as I was doing nothing else with my computers and iOS devices.

I’m always wary of deleting over even modifying files in a Users Library, so I highly recommend caution in proceeding. Otherwise, I deleted the cached files (which had no file suffix endings and appears to be a computer-generated string of alphanumeric characters), after reading this post Safe to Delete Keynote Cache under /Library/Container/com.apple.iWork.Keynote/Data/Library/Caches

Other people had the same problem to with iCloud, iCloud Photo Library, and Photos app on a Mac:

Cloudd is consuming my harddisk constanly, http://forums.macrumors.com/threads/huge-40gb-cloudkit-cache.1791879/

Jupyter notebooks: Jupyter notebooks on wordpress; Jupyter notebooks on github

This link was useful in helping me to get a Jupyter notebook onto wordpress:
cf. Blogging in wordpress with ipython (jupyter) notebooks

Now, I am trying out Jupyter notebooks, to add to my workflow, as a way to quickly present and “put out there” my work coming out of Python and Sage Math. I looked into Jupyter notebooks because I noticed the sagemanifold guys, Michał Bejger and Eric Gourgoulhon use Jupyter notebooks. I decided on Jupyter notebooks because it was open-source, can export to html and pdf, and had Sage Math 7.1 support.

P.S. I can’t change the css anymore on wordpress.com ever since they made it a feature that you have to pay for, so I am skipping Step 3 of this link, Blogging in wordpress with ipython (jupyter) notebooks. And I am finding that wordpress.com isn’t rendering the tag. I am scrapping the idea of Jupyter notebooks on wordpress and going with github directly.

For example, my Jupyter notebook renders elegantly on github:

Presentations and Finitely Presented Groups

and github makes it easy to update off Terminal than wordpress.com.

C++, C++11/C++14

I add the important command of displaying matplotlib plots in jupyter notebooks:

%matplotlib inline

“Ten minutes to pandas” tutorial took me more than 10 minutes (about hour or more?). I like the interactivity of jupyter notebooks.

Links to help video, screen capture on Fedora Linux, and how to speed up video, for a time lapse video, on Fedora Linux


How to make a screencast using Vlc?



Change capture mode to DESKTOP

Change Options to 25 f/s

Choose CONVERT option instead of play option

In the Convert window add the destination file via the BROWSE button then name the file TEST.MPG (VLC does require the extension so the file becomes TEST.MPG rather than just TEST)

Change the PROFILE to VIDEO – H.264 + AAC (TS)

Click the setting button and change the VIDEO CODEC options to:

BITRATE 1200kb/s

FRAME RATE 25.00 fps

Click SAVE

Choose the DEINTERLACE option



ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2[a]" -map "[v]" -map "[a]" -c:v libx264 -c:a aac output.mp4


Notes, Solutions

Propulsion.pdf on wordpress.com

Propulsion.tex LaTeX file on github

Propulsion.py Main, accompanying Python script as a “playground” on github for Propulsion.pdf

FluidMechanics.pdf on wordpress.com

FluidMechanics.tex LaTeX file on github

<!– thermo.pdf on wordpress.com –>

thermo.pdf on github repository Propulsion

thermo.tex LaTeX file on github

thermo.py Main, accompanying Python script as a “playground” on github for thermo.pdf

Liquid-Vapor Equilibrium; Clausius-Clapeyron relation and Antoine Equation from NIST Chemistry Webbook

LiquidVaporEq.py, in github repository ernestyalumni:Propulsion: Web-scrape directly the National Institute of Standards and Technology (NIST) Chemistry Webbook for the Phase change data, and “clean” or format the data into the Antoine Equation and Clausius-Clapeyron relation.

Uses only the packages Requests, BeautifulSoup, sympy.

You’ll be able to make plots of the Antoine Equation and Clausius-Clapeyron relation like this, in this case for methane, CH_4 :


CANTERA Object-Oriented Software for Reacting Flows – This is a “Powerpoint” presentation of Cantera with lucid diagrams that makes understanding the “structure” of Cantera – just note that it’s about 10 years old and some of the syntax has changed. It also has a slide showing the author’s benchmark kinetics performance vs. Chemkin II for Constant P, H Problem with Sensitivity Analysis showing

  • Chemkin II taking ~170 sec while
  • Cantera taking ~40 sec(!!!)

PRF_171.cti added in cantera_stuff directory: .cti Cantera file for n-heptane, along with its Chemical Kinetics (!!!)

cf. Oku Nyong posted this file in his question on Autoignition of Heptane in RCM. I posted this same file on my github Propulsion/cantera_stuff/

Installing Cantera (on Mac OS X, El Capitan)

While hanging out at my alma mater, I did notice that some of my peers had difficulties installing Cantera. I’ll try to remember the steps I took for a successful install.

First, go to this page and follow its instructions. Now, I already have Xcode installed, and also digitally signed its license at the prompt. I also already installed homebrew via that ruby script.

What I had needed to do was this:

brew tap homebrew/science
brew update
brew install python icons sundials

homebrew made the installation of those above easy. I also ran this command at the command prompt of Terminal:

pip install python numpy

and it checked my python and numpy installation out (whether it needed an upgrade or not).

Then on one Mac, (2014 13” MacBook Pro, Mac OS X El Capitan), I successfully installed Cantera with brew

brew install cantera

on another Mac, (2011 MacBook Air), I successfully installed Cantera with MacPorts (i.e. port)

sudo port install cantera

and so either way should work.

The folder cantera_stuff in the repository Propulsion contains examples (of usage) and implementations (in Python) of Cantera that I use for calculations for liquid rocket propulsion.

First, I provide the Python version of the Matlab tutorial .m files in the Cantera Matlab Toolbox (compare that page with the github folder cantera_stuff page):

(cantera) Tutorials

  • tut1.py
  • tut2.py
  • tut3.py
  • tut4.py
  • tut5.py
  • tut6.py
  • tut7.py

(cantera) Examples

  • equil.py

My own (EY’s) Cantera Examples

  • LOXmeth_eq.py

LOXmeth_eq.py calculates, as a function of oxidizer/fuel O/F mass ratio, the adiabatic flame temperature, equilibrium molecular composition, mean molecular weight, ratio of specific heats, and characteristic velocity, of the combustion of oxidizer oxygen (O2) and methane (CH3). This function is further generalized (called equil_general) to make other species be the oxidizer and fuel, such as dinitrogen tetraoxide (N2O4) and hydrazine (N2H4).

Cantera’s examples in github

Let me also highlight the Python examples already in the github repository for Cantera, which is apparently in the folder Cython. Note that, as of right now, I couldn’t find these examples in my MacPorts install of Cantera.

In cython/cantera/examples are the folders

  • kinetics
  • multiphase
  • onedim
  • reactors
  • surface_chemistry
  • thermo
  • transport


sound_speed.py and isentropic.py

Simple Droplet Model

Simple Fuel Droplet model for combustion in ambient molecular oxygen (as the oxidizer), based on Chapter 10 of Turns’ An Introduction to Combustion (2011).


I was able to make these plots:


JANAF tables

PyPDFOCR API Reference (version 0.8.2)

pypdfocr – Installation is nontrivial(!!!)

pip install pypdfocr

External Dependencies

PyPDFOCR relies on the following (free) programs being installed:

You do this by the following (on a Mac OS X):

brew install tesseract
brew install ghostscript
brew install poppler
brew install imagemagick

Otherwise, I received errors as the following, where I didn’t install Poppler:

/bin/sh: pdfimages: command not found
WARNING: Could not execute pdfimages to calculate DPI (try installing xpdf or poppler?), so defaulting to 300dpi

Example usage

pypdfocr JANAFC01-05.pdf


I’ll put a new blog post, here, Electromagnetism for my exploration of electromagnetism and its application to electric propulsion, as I was reviewing EM, at its deepest, theoretical, levels, in thinking about propulsion.