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