Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into abrombo-master-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Nov 21, 2019
2 parents d802096 + 552600e commit 018bb9f
Show file tree
Hide file tree
Showing 30 changed files with 466 additions and 349 deletions.
Empty file modified doc/galgebra.tex
100755 → 100644
Empty file.
Empty file modified doc/python/BACCAB.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/BACCAB.py
100755 → 100644
Empty file.
Empty file modified doc/python/Dirac.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/Dirac.py
100755 → 100644
Empty file.
Empty file modified doc/python/Dop.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/Dop.py
100755 → 100644
Empty file.
Empty file modified doc/python/EMWaves.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/EMWaves.py
100755 → 100644
Empty file.
Empty file modified doc/python/LinearTrans.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/LinearTrans.py
100755 → 100644
Empty file.
Empty file modified doc/python/Ltrans.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/Ltrans.py
100755 → 100644
Empty file.
Empty file modified doc/python/Ltrans.tex
100755 → 100644
Empty file.
Empty file modified doc/python/LtransInst.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/LtransInst.py
100755 → 100644
Empty file.
Empty file modified doc/python/ReciprocalBasis.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/ReciprocalBasis.py
100755 → 100644
Empty file.
Empty file modified doc/python/SphericalCoordinates.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/SphericalCoordinates.py
100755 → 100644
Empty file.
Empty file modified doc/python/TensorDef.py
100755 → 100644
Empty file.
Empty file modified doc/python/diffops.pdf
100755 → 100644
Empty file.
Empty file modified doc/python/submanifold.py
100755 → 100644
Empty file.
Empty file modified doc/python/submanifold1.pdf
100755 → 100644
Empty file.
Empty file modified galgebra/__init__.py
100755 → 100644
Empty file.
500 changes: 303 additions & 197 deletions galgebra/ga.py

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions galgebra/lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def format(mat_fmt=False):
Lt.mat_fmt = mat_fmt
return

def __init__(self, *kargs, **kwargs):
def __init__(self, *args, **kwargs):
"""
Except for the spinor representation the linear transformation
is stored as a dictionary with basis vector keys and vector
Expand All @@ -157,7 +157,7 @@ def __init__(self, *kargs, **kwargs):

kwargs = metric.test_init_slots(Lt.init_slots, **kwargs)

mat_rep = kargs[0]
mat_rep = args[0]
ga = kwargs['ga']
self.fct_flg = kwargs['f']
self.mode = kwargs['mode'] # General g, s, or a transformation
Expand Down Expand Up @@ -281,7 +281,7 @@ def __add__(self, LT):
self_add_LT = copy(self.lt_dict)
for key in list(LT.lt_dict.keys()):
if key in self_add_LT:
self_add_LT[key] = metric.Collect(self_add_LT[key] + LT.lt_dict[key], self.Ga.basis)
self_add_LT[key] = metric.collect(self_add_LT[key] + LT.lt_dict[key], self.Ga.basis)
else:
self_add_LT[key] = LT.lt_dict[key]
return(Lt(self_add_LT, ga=self.Ga))
Expand All @@ -294,7 +294,7 @@ def __sub__(self, LT):
self_add_LT = copy(self.lt_dict)
for key in list(LT.lt_dict.keys()):
if key in self_add_LT:
self_add_LT[key] = metric.Collect(self_add_LT[key] - LT.lt_dict[key], self.Ga.basis)
self_add_LT[key] = metric.collect(self_add_LT[key] - LT.lt_dict[key], self.Ga.basis)
else:
self_add_LT[key] = -LT.lt_dict[key]
return(Lt(self_add_LT, ga=self.Ga))
Expand All @@ -309,7 +309,7 @@ def __mul__(self, LT):
for base in LT.lt_dict:
self_mul_LT[base] = self(LT(base, obj=True), obj=True)
for key in self_mul_LT:
self_mul_LT[key] = metric.Collect(expand(self_mul_LT[key]),self.Ga.basis)
self_mul_LT[key] = metric.collect(expand(self_mul_LT[key]),self.Ga.basis)
return(Lt(self_mul_LT, ga=self.Ga))
else:
self_mul_LT = {}
Expand Down Expand Up @@ -488,7 +488,7 @@ def matrix(self):
class Mlt(object):
"""
A multilinear transformation (mlt) is a multilinear multivector function of
a list of vectors (*kargs) F(v_1,...,v_r) where for any argument slot
a list of vectors (*args) F(v_1,...,v_r) where for any argument slot
j we have (a is a scalar and u_j a vector)
F(v_1,...,a*v_j,...,v_r) = a*F(v_1,...,v_j,...,v_r)
F(v_1,...,v_j+u_j,...,v_r) = F(v_1,...,v_j,...,v_r) + F(v_1,...,u_j,...,v_r).
Expand Down Expand Up @@ -729,7 +729,7 @@ def __init__(self, f, Ga, args, fct=False):
self.fvalue += coef * a_prod
else:
if isinstance(f, types.FunctionType): # Tensor defined by general multi-linear function
args, _kargs, _kwargs, _defaults = inspect.getargspec(f)
args, _varargs, _kwargs, _defaults = inspect.getargspec(f)
self.nargs = len(args)
self.f = f
Mlt.increment_slots(self.nargs, Ga)
Expand All @@ -747,14 +747,14 @@ def __str__(self):
Printer = printer.GaPrinter
return Printer().doprint(self)

def __call__(self, *kargs):
if len(kargs) == 0:
def __call__(self, *args):
if len(args) == 0:
return self.fvalue
if self.f is not None:
return self.f(*kargs)
return self.f(*args)
else:
sub_lst = []
for (x, ai) in zip(kargs, self.Ga.pdiffs):
for (x, ai) in zip(args, self.Ga.pdiffs):
for (r_base, aij) in zip(self.Ga.r_basis_mv, ai):
sub_lst.append((aij, (r_base | x).scalar()))
return self.fvalue.subs(sub_lst,simultaneous=True)
Expand Down
112 changes: 69 additions & 43 deletions galgebra/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,26 @@ def linear_expand(expr, mode=True):
else:
return list(zip(coefs, bases))

def Collect(A, nc_lst):
def collect(A, nc_list):
"""
A is a linear combination of noncommutative symbols with scalar
expressions as coefficients. Collect takes the terms containing
the noncommutative symbols in nc_list and sums them so no elements
of nc_list appear more than once in the sum. Collect combines all
coefficients of a given element of nc_lst into a single coefficient.
Parameters
-----------
A :
a linear combination of noncommutative symbols with scalar
expressions as coefficients
nc_list :
noncommutative symbols in A to combine
Returns
-------
sympy.Basic
A sum of the terms containing the noncommutative symbols in `nc_list` such that no elements
of `nc_list` appear more than once in the sum. All coefficients of a given element of `nc_list`
are combined into a single coefficient.
"""
(coefs,bases) = linear_expand(A)
C = S(0)
for x in nc_lst:
for x in nc_list:
if x in bases:
i = bases.index(x)
C += coefs[i]*x
Expand Down Expand Up @@ -229,33 +238,56 @@ def applymv(mv):


class Metric(object):

"""
Data Variables -
g[,]: metric tensor (sympy matrix)
g_inv[,]: inverse of metric tensor (sympy matirx)
norm: normalized diagonal metric tensor (list of sympy numbers)
coords[]: coordinate variables (list of sympy symbols)
is_ortho: True if basis is orthogonal (bool)
connect_flg: True if connection is non-zero (bool)
basis[]: basis vector symbols (list of non-commutative sympy variables)
r_symbols[]: reciprocal basis vector symbols (list of non-commutative sympy variables)
n: dimension of vector space/manifold (integer)
n_range: list of basis indices
de[][]: derivatives of basis functions. Two dimensional list. First
entry is differentiating coordiate. Second entry is basis
vector. Quantities are linear combinations of basis vector
symbols.
sig: Signature of metric (p,q) where n = p+q. If metric tensor
is numerical and orthogonal it is calculated. Otherwise the
following inputs are used -
input signature Type
"e" (n,0) Euclidean
"m+" (n-1,1) Minkowski (One negative square)
"m-" (1,n-1) Minkowski (One positive square)
p (p,n-p) General (integer not string input)
Metric specification
Attributes
----------
g : sympy matrix[,]
metric tensor
g_inv : sympy matrix[,]
inverse of metric tensor
norm : list of sympy numbers
normalized diagonal metric tensor
coords : list[] of sympy symbols
coordinate variables
is_ortho : bool
True if basis is orthogonal
connect_flg : bool
True if connection is non-zero
basis : list[] of non-commutative sympy variables
basis vector symbols
r_symbols : list[] of non-commutative sympy variables
reciprocal basis vector symbols
n : integer
dimension of vector space/manifold
n_range :
list of basis indices
de : list[][]
derivatives of basis functions. Two dimensional list. First
entry is differentiating coordiate. Second entry is basis
vector. Quantities are linear combinations of basis vector
symbols.
sig : Tuple[int, int]
Signature of metric ``(p,q)`` where ``n = p+q``. If metric tensor
is numerical and orthogonal it is calculated. Otherwise the
following inputs are used:
========= =========== ==================================
Input Signature Type
========= =========== ==================================
``"e"`` ``(n,0)`` Euclidean
``"m+"`` ``(n-1,1)`` Minkowski (One negative square)
``"m-"`` ``(1,n-1)`` Minkowski (One positive square)
``p`` ``(p,n-p)`` General (integer not string input)
========= =========== ==================================
gsym : str
String for symbolic metric determinant. If self.gsym = 'g'
then det(g) is sympy scalar function of coordinates with
name 'det(g)'. Useful for complex non-orthogonal coordinate
systems or for calculations with general metric.
"""

count = 1
Expand Down Expand Up @@ -588,14 +620,8 @@ def __init__(self, basis, **kwargs):
coords = kwargs['coords'] # Manifold coordinates (sympy symbols)
norm = kwargs['norm'] # Normalize basis vectors
self.sig = kwargs['sig'] # Hint for metric signature
"""
String for symbolic metric determinant. If self.gsym = 'g'
then det(g) is sympy scalar function of coordinates with
name 'det(g)'. Useful for complex non-orthogonal coordinate
systems or for calculations with general metric.
"""
self.gsym = kwargs['gsym']
self.Isq = kwargs['Isq'] # Sign of I**2, only needed if I**2 not a number
self.Isq = kwargs['Isq'] #: Sign of I**2, only needed if I**2 not a number

self.debug = debug
self.is_ortho = False # Is basis othogonal
Expand All @@ -605,9 +631,9 @@ def __init__(self, basis, **kwargs):
else:
self.connect_flg = True # Connection needed for postion dependent metric
self.norm = norm # True to normalize basis vectors
self.detg = None # Determinant of g
self.g_adj = None # Adjugate of g
self.g_inv = None # Inverse of g
self.detg = None #: Determinant of g
self.g_adj = None #: Adjugate of g
self.g_inv = None #: Inverse of g
# Generate list of basis vectors and reciprocal basis vectors
# as non-commutative symbols

Expand Down
Loading

0 comments on commit 018bb9f

Please sign in to comment.