]> www.ginac.de Git - ginac.git/blobdiff - check/exam_indexed.cpp
used new diag_matrix() and matrix from lst constructor
[ginac.git] / check / exam_indexed.cpp
index 11182cb9f3479c051ffa1fa6cb7cf2b5c530f0db..21e75405e80f92a06646f9abb68f05a612c1850f 100644 (file)
@@ -103,6 +103,26 @@ static unsigned metric_check(void)
        return result;
 }
 
+static unsigned epsilon_check(void)
+{
+       // checks identities of the epsilon tensor
+
+       unsigned result = 0;
+
+       symbol s_mu("mu"), s_nu("nu"), s_rho("rho"), s_sigma("sigma");
+       varidx mu(s_mu, 4), nu(s_nu, 4), rho(s_rho, 4), sigma(s_sigma, 4);
+
+       // antisymmetry
+       result += check_equal(lorentz_eps(mu, nu, rho, sigma) + lorentz_eps(sigma, rho, mu, nu), 0);
+
+       // convolution is zero
+       result += check_equal(lorentz_eps(mu, nu, rho, nu.toggle_variance()), 0);
+       result += check_equal(lorentz_eps(mu, nu, mu.toggle_variance(), nu.toggle_variance()), 0);
+       result += check_equal_simplify(lorentz_g(mu.toggle_variance(), nu.toggle_variance()) * lorentz_eps(mu, nu, rho, sigma), 0);
+
+       return result;
+}
+
 static unsigned symmetry_check(void)
 {
        // check symmetric/antisymmetric objects
@@ -123,8 +143,10 @@ static unsigned symmetry_check(void)
 
 static unsigned edyn_check(void)
 {
-       // relativistic electrodynamics: check transformation laws of electric
-       // and magnetic fields by applying a Lorentz boost to the field tensor
+       // Relativistic electrodynamics
+
+       // Test 1: check transformation laws of electric and magnetic fields by
+       // applying a Lorentz boost to the field tensor
 
        unsigned result = 0;
 
@@ -139,23 +161,15 @@ static unsigned edyn_check(void)
        L.set(0, 1, -beta*gamma);
        L.set(1, 0, -beta*gamma);
        L.set(1, 1, gamma);
-       L.set(2, 2, 1);
-       L.set(3, 3, 1);
+       L.set(2, 2, 1); L.set(3, 3, 1);
 
        // Electromagnetic field tensor
-       matrix F(4, 4);
-       F.set(0, 1, -Ex);
-       F.set(1, 0, Ex);
-       F.set(0, 2, -Ey);
-       F.set(2, 0, Ey);
-       F.set(0, 3, -Ez);
-       F.set(3, 0, Ez);
-       F.set(1, 2, -Bz);
-       F.set(2, 1, Bz);
-       F.set(1, 3, By);
-       F.set(3, 1, -By);
-       F.set(2, 3, -Bx);
-       F.set(3, 2, Bx);
+       matrix F(4, 4, lst(
+                0, -Ex, -Ey, -Ez,
+               Ex,   0, -Bz,  By,
+               Ey,  Bz,   0, -Bx,
+               Ez, -By,  Bx // 0
+       ));
 
        // Indices
        symbol s_mu("mu"), s_nu("nu"), s_rho("rho"), s_sigma("sigma");
@@ -163,8 +177,8 @@ static unsigned edyn_check(void)
 
        // Apply transformation law of second rank tensor
        ex e = (indexed(L, mu, rho.toggle_variance())
-          * indexed(L, nu, sigma.toggle_variance())
-          * indexed(F, rho, sigma)).simplify_indexed();
+             * indexed(L, nu, sigma.toggle_variance())
+             * indexed(F, rho, sigma)).simplify_indexed();
 
        // Extract transformed electric and magnetic fields
        ex Ex_p = e.subs(lst(mu == 1, nu == 0)).normal();
@@ -182,6 +196,35 @@ static unsigned edyn_check(void)
        result += check_equal(By_p, gamma * (By + beta * Ez));
        result += check_equal(Bz_p, gamma * (Bz - beta * Ey));
 
+       // Test 2: check energy density and Poynting vector of electromagnetic field
+
+       // Minkowski metric
+       ex eta = diag_matrix(lst(1, -1, -1, -1));
+
+       // Covariant field tensor
+       ex F_mu_nu = (indexed(eta, mu.toggle_variance(), rho.toggle_variance())
+                   * indexed(eta, nu.toggle_variance(), sigma.toggle_variance())
+                   * indexed(F, rho, sigma)).simplify_indexed();
+
+       // Energy-momentum tensor
+       ex T = (-indexed(eta, rho, sigma) * F_mu_nu.subs(s_nu == s_rho) 
+               * F_mu_nu.subs(lst(s_mu == s_nu, s_nu == s_sigma))
+             + indexed(eta, mu.toggle_variance(), nu.toggle_variance())
+               * F_mu_nu.subs(lst(s_mu == s_rho, s_nu == s_sigma))
+               * indexed(F, rho, sigma) / 4).simplify_indexed() / (4 * Pi);
+
+       // Extract energy density and Poynting vector
+       ex E = T.subs(lst(s_mu == 0, s_nu == 0)).normal();
+       ex Px = T.subs(lst(s_mu == 0, s_nu == 1));
+       ex Py = T.subs(lst(s_mu == 0, s_nu == 2)); 
+       ex Pz = T.subs(lst(s_mu == 0, s_nu == 3));
+
+       // Check results
+       result += check_equal(E, (Ex*Ex+Ey*Ey+Ez*Ez+Bx*Bx+By*By+Bz*Bz) / (8 * Pi));
+       result += check_equal(Px, (Ez*By-Ey*Bz) / (4 * Pi));
+       result += check_equal(Py, (Ex*Bz-Ez*Bx) / (4 * Pi));
+       result += check_equal(Pz, (Ey*Bx-Ex*By) / (4 * Pi));
+
        return result;
 }
 
@@ -194,6 +237,7 @@ unsigned exam_indexed(void)
 
        result += delta_check();  cout << '.' << flush;
        result += metric_check();  cout << '.' << flush;
+       result += epsilon_check();  cout << '.' << flush;
        result += symmetry_check();  cout << '.' << flush;
        result += edyn_check();  cout << '.' << flush;