r"""vegie Module for vector algebra (C) Alexander Heger, 2023 This module was wrtting to do some calcualtions for quadrupole-quarupole interaction(s) of multi-star/planet systems. Select features - transform flipsco/contravariance of valence slots (all by default) - transpose re-orders valnce slots. The last two by default Example: from vegie import * i,j,k,l,m,n = indices('i,j,k,l,m,n') T = Variable('T','--++') V = Variable('v','+') U = Variable('u','+') t = T(i,j,k,l) u = U(-i) v = V(+j) s = Tensor('s') f = ((3 * u(-i)*u(+j) - u(-k)*u(+k)*Delta(-i,+j)) * (3 * v(-i)*v(+j) - u(-l)*u(+l)*Delta(-i,+j)).T) f // u f // v from vegie import * i, j = indices('i, j') P, Q = variables('$!P++, $!Q--') r, s, t, v = variables('r+', 's+', 't+', 'v+') ### paper # two permanent - A3 Phi = -3/2 * Q(i,j) * r(i) * r(j) / r**5 G = -Phi // r(i) // r(j) | S U = -1/2 * G * P(i,j) | S F = -U // r(i) | S T = F @ r(-i) | S # two tidal - A4.1 Qpq = (r(i)*r(j) - 1/3 * r**2 * Delta(+i,+j)) / r**5 Qqp = (r(i)*r(j) - 1/3 * r**2 * Delta(+i,+j)) / r**5 Phi = -3/2*Qpq*r(-r)*r(-j) / r**5 | S G = -Phi // r(i) // r(j) | S U = -1/2 * G * Qpq | S F = - U // r(i) | S T = F @ r(-i) | S # permanent in tidal - A4.2 Phi = -3/2 / r**6 G = -Phi // r(i) // r(j) | S U = -1/2 * G * P(i,j) | S F = - U // r(i) | S T = F @ r(-i) | S # tidal in permament - A4.3 Phi = -3/2 * Q(i,j) * r(i) * r(j) / r**5 G = -Phi // r(i) // r(j) | S Qqp = (r(i)*r(j)-1/3 * r**2 * Delta(+i,+j)) / r**5 U = -1/2 * G * Qqp | S F = -U // r(i) | S T = F @ r(-i) | S # spin-spin - A5.1 Wp, Wq = variables('Wp+, Wq+') Wq.set_latex('\Omega','\mathrm{q}') Wp.set_latex('\Omega','\mathrm{p}') Qp = (Wp(i) * Wp(j) - 1/3 * Wp**2 * Delta(+i, +j)) Phi = -3/2 * ((r(i)*Wq(-i))**2 - 1/3 * r**2 * Wq**2) / r**5 | S G = -Phi // r(i) // r(j) | S U = -1/2*G1 * Qp | S F = -U // r(i) | S T = F @ r(-i) | S G | extract(3/2*Norm(r)**(-9)) | rename('k+') | jtex G | extract(3/2*Norm(r)**(-9)) | jvec(doc=True) U | extract(3/4/r**9) | jvec(doc=True) F | extract(15/4/r**11) | jvec(doc=True) T | extract(15/2/r**11) | jvec(doc=True) # ALTERNATE (using repleace) - spin-spin - A5.1 Qp = (Wp(i) * Wp(j) - 1/3 * Wp**2 * Delta(+i, +j)) Qq = (Wq(-i) * Wq(-j) - 1/3 * Wq**2 * Delta(-i, -j)) Phi = -3/2 * Q(i,j) * r(i) * r(j) / r**5 G = -Phi // r(i) // r(j) | S U = -1/2 * G * P(i,j) | S F = -U // r(i) | S T = F @ r(-i) | S G1 = G | replace(Q, Qq) | S U1 = U | replace(Q, Qq) | replace(P, Qp) | S F1 = F | replace(Q, Qq) | replace(P, Qp) | S T1 = T | replace(Q, Qq) | replace(P, Qp) | S # spin (P) in tidal field (Q) - A5.2 Wp = variables('Wp+') Wp.set_latex('\Omega','\mathrm{p}') Qp = (Wp(+i) * Wp(+j) - 1/3 * Wp**2 * Delta(+i, +j)) Phi = -3/2 / r**6 G = -Phi // r(i) // r(j) | S U = -1/2 * G * Qp | S F = -U // r(i) | S T = F @ r(-i) | S G | extract(9/r**10) | rename('k+') | jtex G | extract(9/r**10) | jvec(doc=True) U | extract(12/r**10) | jvec(doc=True) F | extract(24/r**12) | jvec(doc=True) T | extract(72/r**10) | jvec(doc=True) % ======================================================================= TODO - add simplifyer that extracts values from inside powers TODO - automatically extract maximum negative powers of norms, common integer factors and fractions TODO - *** automatic simplification *** TODO - add more algebra for Variable objects (non-commutative), inclduing number-typed objects - double contraction should likely be of that kind - have special tensors to host these, similar to Norm - there could be a special FundamentalNorm (or Scalar) for them - possibly a separate Norm for non-fundamental scalars - Norm is just a fancy way to take square root of contraction, same as contraction power 1/2. TODO - group by common scalar groups if they are long - add function to count complexity/length TODO - group Norms to beginning and combine with values for LaTeX output of Dot TODO - proper re-design of __str__ and __repr__ TODO - VariableDoubleContraction similar to VariableNorm TODO - Apply assumptions such as two vectors being parallel or pendicular TODO - add doube contaction for complex tensors for vector notation TODO - expand even powers of compound (Sum) Norm / VariableNorm TODO - expand positive integer powers of Power of scalrs containing Sum """ from .command import * from .index import indices from .variable import variables from .norm import Norm from .special import Delta, Epsilon