|
Subject: DeRhamComplex?
If we were to create a new domain that allows metric to be part of the definition,
what should it be called?
On 7 October 2014 12:13 Kurt Pagani wrote to fricas-devel@googlegroups.com:
I have no idea. You tell me? I can't yet overview how the final module(s) should
look like. What I have in mind is first to complete this by functions like proj
(projection on homogeneous parts, subspaces), push forward/pull back, interior
product and Lie derivative which is possible which little effort, second
to have simplicial homology (e.g. a type Simplex) then using FreeAbelianGroup?(Simplex),
defining boundaryOperator and so on such that one can deal with integration of
differential forms over simplicial complexes (Stokes theorem, Hodge pairing and
so on you know). It's almost all there but one has to organize it. It should be
a teamwork to becoming really useful, so any suggestions welcome.
fricas )lib DERHAM
DeRhamComplex is now explicitly exposed in frame initial
DeRhamComplex will be automatically loaded when needed from
/var/aw/var/LatexWiki/DERHAM.NRLIB/DERHAM
spad )abbrev domain DIFGEOM DifferentialGeometry
DifferentialGeometry(n:NNI, CoefRing, listIndVar : DirectProduct(n,Symbol), g:SMR) : Export == Implement where
CoefRing : Join(IntegralDomain, Comparable)
ASY ==> AntiSymm(R, listIndVar)
DERHAM ==> DeRhamComplex(CoefRing, members listIndVar)
DIFRING ==> DifferentialRing
LALG ==> LeftAlgebra
FMR ==> FreeMod(R, EAB)
I ==> Integer
L ==> List
EAB ==> ExtAlgBasis -- these are exponents of basis elements in order
NNI ==> NonNegativeInteger
O ==> OutputForm
R ==> Expression(CoefRing)
SMR ==> SquareMatrix(n,R)
Export == Join(LALG(R), RetractableTo(R)) with
leadingCoefficient : % -> R
++ leadingCoefficient(df) returns the leading
++ coefficient of differential form df.
leadingBasisTerm : % -> %
++ leadingBasisTerm(df) returns the leading
++ basis term of differential form df.
reductum : % -> %
++ reductum(df), where df is a differential form,
++ returns df minus the leading
++ term of df if df has two or more terms, and
++ 0 otherwise.
coefficient : (%, %) -> R
++ coefficient(df, u), where df is a differential form,
++ returns the coefficient of df containing the basis term u
++ if such a term exists, and 0 otherwise.
generator : NNI -> %
++ generator(n) returns the nth basis term for a differential form.
homogeneous? : % -> Boolean
++ homogeneous?(df) tests if all of the terms of
++ differential form df have the same degree.
retractable? : % -> Boolean
++ retractable?(df) tests if differential form df is a 0-form,
++ i.e., if degree(df) = 0.
degree : % -> NNI
++ changed from I to NNI , then works
++ degree(df) returns the homogeneous degree of differential form df.
map : (R -> R, %) -> %
++ map(f, df) replaces each coefficient x of differential
++ form df by \spad{f(x)}.
totalDifferential : R -> %
++ totalDifferential(x) returns the total differential
++ (gradient) form for element x.
exteriorDifferential : % -> %
++ exteriorDifferential(df) returns the exterior
++ derivative (gradient, curl, divergence, ...) of
++ the differential form df.
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
dim : % -> NNI
++ dimension of underlying space
++ that is dim ExtAlg = 2^dim
hodgeStar : (%) -> %
++ computes the Hodge dual of the differential form % with respect
++ to a metric g.
dot : (%,%) -> R
++ computes the inner product of two differential forms w.r.t. g
proj : (%,NNI) -> %
++ projection to homogeneous terms of degree p
interiorProduct : (Vector(R),%) -> %
++ calculates the interior product i_X(a) of the vector field X
++ with the differential form a (w.r.t. metric g).
lieDerivative : (Vector(R),%) -> %
++ calculates the Lie derivative L_X(a) of the differential
++ form a with respect to the vector field X (w.r.t. metric g).
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
Implement == DERHAM add
Rep := DERHAM
terms : % -> List Record(k : EAB, c : R)
terms(a) ==
-- it is the case that there are at least two terms in a
a pretend List Record(k : EAB, c : R)
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
-- error messages
err2:="Not implemented"
err3:="Degenerate metric"
err4:="Index out of range"
-- coord space dimension
dim(f) == n
-- flip 0->1, 1->0
flip(b:ExtAlgBasis):ExtAlgBasis ==
bl := b pretend List(NNI)
[(i+1) rem 2 for i in bl] pretend ExtAlgBasis
-- list the positions of a's (a=0,1) in x
pos(x:EAB, a:NNI):List(NNI) ==
y:= x pretend List(NNI)
[j for j in 1..#y | y.j=a]
-- compute dot of singletons
dot1(r:Record(k : EAB, c : R),s:Record(k : EAB, c : R)):R ==
test(r.k ~= s.k) => 0::R
idx := pos(r.k,1)
idx = [] => r.c * s.c
reduce("*",[1/g(j,j) for j in idx]::List(R)) * r.c * s.c
-- export
dot(x,y) ==
tx := terms(x)
ty := terms(y)
reduce("+",[dot1(tx.j,ty.j) for j in 1..#tx])
-- export
hodgeStar(x) ==
not diagonal? g => error(err2)
v := sqrt(abs(determinant(g))) -- volume factor
v = 0 => error(err3)
t := terms(x)
s := [copy(r) for r in t] -- we need a copy of x!
for j in 1..#t repeat
s.j.k := flip(s.j.k)
fs:= [s.j] pretend %
ft:= [t.j] pretend %
s.j.c := s.j.c * v * dot1(t.j,t.j)/leadingCoefficient(ft*fs)
s pretend %
-- export
proj(x,p) ==
p < 0 or p > n => error(err4)
t := terms(x)
idx := [j for j in 1..#t | #pos(t.j.k,1)=p]
s := [copy(t.j) for j in idx::List(NNI)]
s pretend %
interiorProduct(v,x) ==
f := reduce("+", [generator(i)$% for i in 1..n]::List(%))
t := terms(f)
for j in 1..n repeat
t.(n-j+1).c := g(j,j)*v(j) -- reverse order!
f -- term manipulations are destructive ;)
dg:R := determinant(g)
sg:R := dg/abs(dg)
if odd?(n) then
m:R := sg
else
m:R := (-1)^degree(x) * sg
m * hodgeStar(f * hodgeStar(x))
lieDerivative(v,x) ==
a := exteriorDifferential(interiorProduct(v,x))
b := interiorProduct(v, exteriorDifferential(x))
a+b
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
spad Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7961152715829501373-25px002.spad
using old system compiler.
DIFGEOM abbreviates domain DifferentialGeometry
------------------------------------------------------------------------
initializing NRLIB DIFGEOM for DifferentialGeometry
compiling into NRLIB DIFGEOM
****** Domain: CoefRing already in scope
compiling local terms : $ -> List Record(k: ExtAlgBasis,c: Expression CoefRing)
DIFGEOM;terms is replaced by a
Time: 0.06 SEC.
compiling exported dim : $ -> NonNegativeInteger
Time: 0 SEC.
compiling local flip : ExtAlgBasis -> ExtAlgBasis
Time: 0 SEC.
compiling local pos : (ExtAlgBasis,NonNegativeInteger) -> List NonNegativeInteger
Time: 0.03 SEC.
compiling local dot1 : (Record(k: ExtAlgBasis,c: Expression CoefRing),Record(k: ExtAlgBasis,c: Expression CoefRing)) -> Expression CoefRing
Time: 0.65 SEC.
compiling exported dot : ($,$) -> Expression CoefRing
Time: 0.02 SEC.
compiling exported hodgeStar : $ -> $
Time: 3.31 SEC.
compiling exported proj : ($,NonNegativeInteger) -> $
Time: 0.15 SEC.
compiling exported interiorProduct : (Vector Expression CoefRing,$) -> $
Time: 0.10 SEC.
compiling exported lieDerivative : (Vector Expression CoefRing,$) -> $
Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |DifferentialGeometry| REDEFINED
;;; *** |DifferentialGeometry| REDEFINED
Time: 0 SEC.
Warnings:
[1] dot1: k has no value
[2] dot1: c has no value
[3] hodgeStar: c has no value
Cumulative Statistics for Constructor DifferentialGeometry
Time: 4.33 seconds
finalizing NRLIB DIFGEOM
Processing DifferentialGeometry for Browser database:
--->-->DifferentialGeometry(constructor): Not documented!!!!
--------(leadingCoefficient ((Expression CoefRing) %))---------
--------(leadingBasisTerm (% %))---------
--------(reductum (% %))---------
--------(coefficient ((Expression CoefRing) % %))---------
--------(generator (% (NonNegativeInteger)))---------
--------(homogeneous? ((Boolean) %))---------
--------(retractable? ((Boolean) %))---------
--------(degree ((NonNegativeInteger) %))---------
--->-->DifferentialGeometry((degree ((NonNegativeInteger) %))): Improper first word in comments: changed
"changed from \\spad{I} to NNI ,{} then works degree(\\spad{df}) returns the homogeneous degree of differential form \\spad{df}."
--------(map (% (Mapping (Expression CoefRing) (Expression CoefRing)) %))---------
--------(totalDifferential (% (Expression CoefRing)))---------
--------(exteriorDifferential (% %))---------
--------(dim ((NonNegativeInteger) %))---------
--->-->DifferentialGeometry((dim ((NonNegativeInteger) %))): Improper first word in comments: dimension
"dimension of underlying space that is dim ExtAlg = 2^dim"
--------(hodgeStar (% %))---------
--->-->DifferentialGeometry((hodgeStar (% %))): Improper first word in comments: computes
"computes the Hodge dual of the differential form \\% with respect to a metric \\spad{g}."
--------(dot ((Expression CoefRing) % %))---------
--->-->DifferentialGeometry((dot ((Expression CoefRing) % %))): Improper first word in comments: computes
"computes the inner product of two differential forms \\spad{w}.\\spad{r}.\\spad{t}. \\spad{g}"
--------(proj (% % (NonNegativeInteger)))---------
--->-->DifferentialGeometry((proj (% % (NonNegativeInteger)))): Improper first word in comments: projection
"projection to homogeneous terms of degree \\spad{p}"
--------(interiorProduct (% (Vector (Expression CoefRing)) %))---------
--->-->DifferentialGeometry((interiorProduct (% (Vector (Expression CoefRing)) %))): Improper first word in comments: calculates
"calculates the interior product i_X(a) of the vector field \\spad{X} with the differential form a (\\spad{w}.\\spad{r}.\\spad{t}. metric \\spad{g})."
--------(lieDerivative (% (Vector (Expression CoefRing)) %))---------
--->-->DifferentialGeometry((lieDerivative (% (Vector (Expression CoefRing)) %))): Improper first word in comments: calculates
"calculates the Lie derivative \\spad{L_X}(a) of the differential form a with respect to the vector field \\spad{X} (\\spad{w}.\\spad{r}.\\spad{t}. metric \\spad{g})."
--->-->DifferentialGeometry(): Missing Description
; compiling file "/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM.lsp" (written 04 APR 2022 07:56:21 PM):
; /var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM.fasl written
; compilation finished in 0:00:00.095
------------------------------------------------------------------------
DifferentialGeometry is now explicitly exposed in frame initial
DifferentialGeometry will be automatically loaded when needed from
/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM
fricas d ==> exteriorDifferential
Type: Void
fricas G:=diagonalMatrix([1,1,1])
Type: Matrix(Integer)
fricas X := DIFGEOM(3,Integer,[x,y,z],G)
Type: Type
fricas [dx,dy,dz] := [generator(i)$X for i in 1..3]
Type: List(DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]]))
fricas f : BOP := operator('f);
fricas g : BOP := operator('g);
fricas h : BOP := operator('h);
fricas a : BOP := operator('a);
fricas b : BOP := operator('b);
fricas c : BOP := operator('c);
fricas U : BOP := operator('U);
fricas V : BOP := operator('V);
fricas W : BOP := operator('W);
fricas v:=vector[U(x,y,z),V(x,y,z),W(x,y,z)]
Type: Vector(Expression(Integer))
fricas sigma := f(x,y,z) * dx + g(x,y,z) * dy + h(x,y,z) * dz
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas theta := a(x,y,z) * dx * dy + b(x,y,z) * dx * dz + c(x,y,z) * dy * dz
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas interiorProduct(v,sigma)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas interiorProduct(v,theta)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas d interiorProduct(v,dx*dy*dz)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas hodgeStar(%) -- should be div(v) !
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas eta:=lieDerivative(v,theta)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas proj(dx+dy*dz+dx*dy*dz,2)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas proj(sigma+theta,1)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas dim(sigma)
fricas degree(sigma)
fricas dot(sigma,sigma)
Type: Expression(Integer)
fricas hodgeStar(sigma)
Type: DifferentialGeometry ?(3, Integer, [x, y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
Laplace Operator for
fricas )clear all
All user variables and function definitions have been cleared.
d ==> exteriorDifferential
Type: Void
fricas Y := DIFGEOM(2,Integer,[r,theta],diagonalMatrix([1,r^2]))
Type: Type
fricas F:=operator 'F
fricas [dr,dtheta] := [generator(i)$Y for i in 1..2]
Type: List(DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]]))
fricas F0:=F(r,theta)::Y
Type: DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]])
fricas F1:=d F0
Type: DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]])
fricas F2:= hodgeStar(F1)
Type: DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]])
fricas F3:=d F2
Type: DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]])
fricas LaplaceF := hodgeStar(F3)
Type: DifferentialGeometry ?(2, Integer, [r, theta], [[1, 0], [0, r^2]])
fricas subst(LaplaceF::Expression Integer,abs(r^2)=r^2)
Type: Expression(Integer)
fricas )lib DIFGEOM
DifferentialGeometry is already explicitly exposed in frame initial
DifferentialGeometry will be automatically loaded when needed from
/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM
fricas G:=diagonalMatrix([1,1,1])
Type: Matrix(Integer)
fricas X := DIFGEOM(3,Integer,[x',y,z],G)
Type: Type
fricas Y := DIFGEOM(3,Integer,[x,y',z],G)
Type: Type
fricas xy:X
Type: Void
fricas xy:=generator(1)$X
Type: DifferentialGeometry ?(3, Integer, [x', y, z], [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
fricas xy:=generator(1)$Y
Cannot convert right-hand side of assignment
dx
to an object of the type DifferentialGeometry(3,Integer,[x',y,z],
[[1,0,0],[0,1,0],[0,0,1]]) of the left-hand side.
|