/* Copyright (C) 2009 Viktor T. Toth <http://www.vttoth.com/>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * MAXIMA CTENSOR demo: Deriving the equation of hydrostatic
 * equilibrium in a spherically symmetric static metric.
 *
 */

("

We derive the equation of hydrostatic equilibrium in a static,
spherically symmetric metric. First, we load the tensor packages...")$
if get('ctensor,'version)=false then load(ctensor);
if get('itensor,'version)=false then load(itensor);
("The metric is characterized by two parameters, A and B, as usual.")$
("In addition, we have the energy density rho and pressure p.")$
("These are all functions of the radial coordinate r.")$
derivabbrev:true;
depends([A,B,rho,p],[r]);
("We form the covariant derivative of the stress-energy tensor,
and convert it into a ctensor program. This derivative must be zero
for matter distribution satisfying the Einstein field equations.")$
EQ:ic_convert(covdiff(T([a],[b]),b)=J([a],[]));
("We now form the general spherically symmetric static metric.")$
ct_coords:[t,r,theta,phi];
lg:ident(4);
lg[1,1]:B;
lg[2,2]:-A;
lg[3,3]:-r^2;
lg[4,4]:-r^2*sin(theta)^2;
cmetric();
christof(false);
("We also form the energy-momentum tensor from rho and p.")$
T:ident(4);
T[1,1]:rho;
T[2,2]:T[3,3]:T[4,4]:-p;
("We initialize J as a zero vector...")$
J:[0,0,0,0];
("... and evaluate the program generated by ic_convert.")$
EQ,eval;
("We note that only one component of J is not trivial:")$
J;
("However, even this component must be zero.
We convert this equation into the usual form:")$
factor(diff(p,r)=diff(p,r)+J[2]);
("This is the equation of hydrostatic equilibrium.")$
("It appears in many textbooks, for instance Weinberg's Gravitation
and Cosmology (1972), Eq. (11.1.8).")$

/* End of demo -- comment line needed by MAXIMA to resume demo menu */
