More questions about Maxima's tensor functions



Glenn,

Yes, I think it's a fair statement to say that if you have no use for
Riemannian geometry subroutines, then ctensor is of no use to you. It
doesn't do anything special for representing tensors; they're just Maxima
matrices or lists. If you want to do with them something other than what's
built into ctensor, you don't need to load ctensor to accomplish your task.

As for itensor, yes, it is useful for manipulating indexed expressions. It
has another use, though, which was shown in the little example I sent to
you: it can generate ctensor-style program lines, which can be quite
convenient at times.

The problem you encounter with diff() is not really a tensor package problem
but a limitation in diff() itself; it chokes in some cases when you attempt
to differentiate with respect to a function argument, e.g.,

	diff(f(),g());

Unfortunately, since itensor objects are seen as functions (e.g.,
g([i,j],[]), a function of two arguments) by Maxima, we run into this
limitation. One workaround is to ensure that the noun form of diff is used
up to the point where the functions are evaluated, and only evaluate diff
afterwards. Here's a non-itensor example. The first command here will fail
but the rest will succeed:

	diff(f(h),exp(g));

	'diff(f(h),exp(g));
	%,g=log(h);
	%,diff;

The bottom line is that diff should only be evaluated when its second
argument has been reduced to something Maxima can accept as an independent
variable.

I also need to call your attention to the fact that

	EQ:Q([],[])=b[ff]*(E([f,f],[]))^2

is not a valid itensor expression. You cannot have the same index (f) occur
twice in a covariant position. I think what you are trying to say here
should be expressed as

	EQ:Q([],[])=b[ff]*(E([f],[f]))^2

where the same index occurring once in a covariant and once in a
contravariant position implies summation. But this expression also will not
work very well, since it is not linear in E([f],[f]), and itensor (and
specifically, ic_convert()) loses track of indices.

One way to deal with these problems is to use only linear expressions in
itensor prior to converting them to a ctensor-style program, and then
complete the rest there. For instance:

	EQ:sqQ([],[])=b[ff]*E([f],[f]);
	ic_convert(EQ);
	ev(%);
	Q:sqQ^2/b[ff];

or something along these lines.

Lastly, I thank you for your patience as you're trying to put the tensor
packages to good use. I am using these exchanges to gather information to
find out what needs to be done to make the packages more usable. I think
it's obvious that they were originally designed to assist with conventional
gravity theories, but the design seems flexible enough to accommodate other
needs... I've already taken care of a number of issues, and based on
feedback like yours, I hope to be able to improve the packages more.


Viktor

 

-----Original Message-----
From: Glenn Ramsey [mailto:glenn at componic] 
Sent: Thursday, November 17, 2005 4:02 AM
To: Viktor T. Toth
Cc: maxima@math.utexas.edu
Subject: Re: [Maxima] More questions about Maxima's tensor functions

Hi Viktor,

Thanks for the tips.

I have the calculation working now but since there isn't any 
manipulation to do for this problem I don't think there is any advantage 
in using itensor. I also can't see that there is any advantage to using 
ctensor over matrices in this case either, is that correct?

FYI here's what I did:

dim:3;

f:1; n:2; s:3;
ff:1; fn:2; fs:3; nn:4; ns:5; ss:6;

/* Strain energy function - Costa et al, Ph.Tr.R.Soc.,359,2001 */
/* b[i] are the parameters to be estimated */

Q:b[ff]*(E[f,f])^2 + \
2*b[fn]*((1/2)*(E[n,f]+E[f,n]))^2 + \
2*b[fs]*((1/2)*(E[f,s]+E[s,f]))^2 + \
b[nn]*(E[n,n])^2 + \
2*b[ns]*((1/2)*(E[n,s]+E[s,n]))^2 + \
b[ss]*(E[s,s])^2$

W:(1/2)*a*(exp(Q)-1);

/* 2nd Piola-Kirchhoff stress */
S:zeromatrix(dim,dim);
for i thru dim do for j thru dim do S[i,j]:diff(W,E[i,j]);

/* Deformation gradient */
F: matrix([1,0,k], [0,1,0], [0,0,1]);

/* Green strain */
E: (1/2)*(transpose(F).F-ident(dim));

/* Face normal.Area */
N:matrix([0, 0, C]);

/* force on top face - to use in objective function */
t:ev(F.S.N);


If I use the procedure that you suggested starting with the function in 
tensor form:

EQ:Q([],[])=b[ff]*(E([f,f],[]))^2 + \
2*b[fn]*((1/2)*(E([n,f],[])+E([f,n],[])))^2 + \
2*b[fs]*((1/2)*(E([f,s],[])+E([s,f],[])))^2 + \
b[nn]*(E([n,n],[]))^2 + \
2*b[ns]*((1/2)*(E([n,s],[])+E([s,n],[])))^2 + \
b[ss]*(E([s,s],[]))^2$

W:(1/2)*a*(exp(Q)-1);

After converting to ctensor and creating S then ev(S) fails with an 
error message "Wrong number of arguments to diff".

I tried with a simpler expression: EQ:Q([],[])=b[ff]*(E([f,f],[]))^2
and that has the same result.

I'm not sure why that fails but I think in this case it doesn't make 
sense to use itensor so I'm not surprised that it doesn't work.

Regards
Glenn

Viktor T. Toth wrote:

> 
> For instance, instead of defining W, you can use itensor to define logW as
> follows:
> 
> 	load(itensor);
> 	load(ctensor);
> 	EQ:logW([],[])=c2*E([i,j],[])*kdelta([],[i,j])$
> 	ishow(EQ)$
> 
> Now you can use the ic_convert function to convert EQ into a ctensor
> program. It is then also necessary to replace the itensor kdelta with
> ctensor's kdelt function (yes, perhaps it should be done automagically,
but
> it isn't) and then evaluate it:
> 
> 	ic_convert(EQ);
> 	subst('kdelt(i,j),'kdelta[i,j],%);
> 	%,eval,kdelt;
> 
> Now you can carry out the exponentiation:
> 
> 	W:c1*exp(%);
> 
> Finally, you can build a ctensor-style expression by hand to get your
sigma
> matrix:
> 
> 	S:zeromatrix(dim,dim);
> 	for i thru dim do for j thru dim do S[i,j]:diff(W,E[i,j]);
> 
> Note that I set S explicitly to a matrix first, in order to ensure that it
> is treated as a matrix, not as a list, when indices in square brackets are
> used.
> 
> And, needless to say, you may want to set dim to something other than the
> default 4 first, before carrying out these steps.
> 
> I hope I understood your problem correctly and this is of some use to you.
> 
> 
> Viktor
> 

-- 
Glenn Ramsey  07 8627077
http://www.componic.co.nz