itensor and ctensor: indexed objects in moving frames in specific coordinate systems and frame basis



Many thanks!
I did it  in old fashion. You program is much more elegant!

On Sunday 13 February 2011 18:35:51 Viktor T. Toth wrote:
> Valery,
> 
> I think your example can actually take better advantage of the built-in
> features of ctensor/itensor. For instance, here is one way:
> 
> load(itensor);
> load(ctensor);
> imetric(g);
> E:subst(lc(i,n,m),'levi_civita[i,n,m],ic_convert(ishow(curl([],[i])='levi_c
> i vita([],[i,n,m])*covdiff(V([m],[]),n))))$
> ct_coordsys(spherical);
> cmetric();
> christof(false);
> depends([Vr,Vt,Om],[r,theta]);
> V:transpose(lg.[Vr,Vt/r,Om])[1];
> assume(sin(theta)>0);
> lc(i,j,k):=lc0([i,j,k]);
> curl:[0,0,0];
> ev(E);
> expand(trigsimp(curl.lg/sqrt(determinant(lg))));
> 
> Note that it was not necessary to explicitly write in metric components, or
> to rewrite the ic_convert expression "by hand". Also, it is possible to
> side-step the lc0/levi_civita issue by defining the function lc().
> 
> Alternatively, albeit it's a bit longer, it is perhaps slightly more
> elegant to make explicit use of frame base support to obtain the same
> result:
> 
> load(itensor);
> load(ctensor);
> iframe_flag:true;
> cframe_flag:true;
> ishow(curl([],[i])='levi_civita([],[i,n,m])*covdiff(V([m],[]),n))$
> ishow(ev(%,icc2,ifc2,ifc1,ifb))$
> E:subst(lc(i,n,m),'levi_civita[i,n,m],ic_convert(%))$
> ct_coordsys(spherical);
> cmetric();
> christof(false);
> depends([Vr,Vt,Om],[r,theta]);
> depends([ifg,ifr,ifri],ct_coords)$
> V:transpose(lg.[Vr,Vt/r,Om])[1];
> lc(i,j,k):=lc0([i,j,k]);
> curl:[0,0,0];
> ifg:lfg;
> ifr:fri;
> ifri:fri^^-1;
> ev(E);
> expand(trigsimp(curl.lg/determinant(fri)));
> 
> 
> Viktor
> 
> 
> 
> 
> 
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Valery Pipin
> Sent: Sunday, February 13, 2011 4:26 PM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] itensor and ctensor: indexed objects in moving frames
> in specific coordinate systems and frame basis
> 
> I would say
> 
> > Please don't hesitate to correct me if I am wrong, but it seems to me
> > that you are expecting the result to be expressed in the coordinate
> > base,
> 
> the text books (unfortunately not Landay -Lifshitz, you can look to Mizner
> Torn, Wheeler, or B Schutz) call this orthonormal but non-coordinate basis.
> For this  basis, product of the basis components  is the unit matrix. While
> the answer in this basis looks, sometimes, simplier, it is not good for the
> calculus purpose.
> For example, the curl of the velocity flow in the spherical coordinates
> 
> 
> load("itensor.lisp");
> if get('ctensor, 'version) = false then load(ctensor);
> 
> /* define dimension and the name for the metric */
> idim(3);
> remcomps(g);
> imetric(g);
> /*define the components of the curl using the Levi-Chevitta symbol*/
> remcomps(curlc);
> components(curlc([],[i]),'levi_civita([],[i,n,m])*covdiff(V([m],[]),n));
> 
> /* show them */
> eqn :ishow(curl([],[i]) =canform(rename(expand(curlc([],[i])))))$
> 
> /* convert itensor's curl  ctensor format*/
> display2d:false;
> eqnc : ic_convert(eqn);
> 
> /* define coordinates */
> ct_coords:[r,th,ph];
> depends([Vr,Vt,Om],[r,th]);
> /* NB! the proper factors for covariant basis, which is used by ctensor*/
> V:[Vr,Vt*r,Om*r^2*sin(th)^2];
> 
> /*define the metric and compute connectivity componentets of the metrics*/
> lg:matrix([1,0,0],[0,r^2,0],[0,0,r^2*sin(th)^2])$
> dlt:matrix([1,0,0],[0,1,0],[0,0,1])$
> ug:invert(lg)$
> christof(all);
> /*NB! this a metric factor for the curl! */
> sgdet:r^2*sin(th);
> 
> /* Below is ctensor loop to  compute components */
> /* I replace 'levi_civita[%1,%2,i] -> lc0([%1,%2,i])/sgdet */
> /* This should be implemented somehow in a future */
> for i thru dim do
> 
> curl[i]:sum(sum(lc0([%1,%2,i])/sgdet*diff(V[%2],ct_coords[%1]),%1,
>                            1,dim),%2,1,dim)
>                   
> -sum(sum(sum(lc0([%1,%2,i])/sgdet*mcs[%1,%2,%3]*V[%3],%1,
> 1,dim),%2,1,dim),%3,1,dim)
> display2d:true;
> ratexpand(trigsimp(ratexpand(curl[1])));
> /* gives*/
>  'diff(Om,th,1)*sin(th)+2*Om*cos(th)
> 
> ratexpand(trigsimp(ratexpand(r*curl[2])));
> /* gives*/
> -'diff(Om,r,1)*r*sin(th)-2*Om*sin(th)
> ratexpand(trigsimp(ratexpand(r*sin(th)*curl[3])));
> /* gives*/
>  'diff(Vt,r,1)+Vt/r-'diff(Vr,th,1)/r
> 
> FWIW
> Valery
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima