Contents
%mat_transform2.m % %Transforms a general rank 2 tensor according to a chosen transformation %matrix. Generating matrices can be loaded by entering their number. %General, already created group elements can be loaded by entering their %file name (no file extension necessary). The tensor will be tranformed and %a system of 6 equations will be created via the invariance condition %(h_ij = g_ij, with h_ij the transformed tensor). The transformed tensor as %well as the resulting independent elements will be shown at the end. % %input: nam ... name or # of tranforming matrix % %output: hs ... transformed rank 2 tensor % hi ... resulting tensor with independent elements % %Valentin Zauner % %05.2008 clear all; clc; rep = 1; while rep clear all; %initialize general rank 2 tensor with elements named according to 1-d %representation for symmetric tensors syms g1 g2 g3 g4 g5 g6 h g g = [g1,g6,g5;g6,g2,g4;g5,g4,g3];
load transformation matrix
nam = input('Transforming matrix: ','s'); if isempty(nam) %if nothing is entered identity matrix will be loaded M = eye(3); elseif ~isempty(str2num(nam)); %if only a number is entered the corresponding generating matrix will %be loaded t = struct2cell(load(['M',nam])); M = t{1}; else t = struct2cell(load(nam)); M = t{1}; end;
transform tensor
h = simple(inv(M)*g*M); ind = [1,5,9,8,7,4];%mask for vector - representation for symmetric matrices t = h(ind);%map to vector - representation for symmetric matrices x = [g1,g2,g3,g4,g5,g6];
solve for independent elements
y = cell(1,6); for k = 1:6 y{k} = [char(t(k)),'=',char(x(k))];%generate defining equations for each element end; S = struct2cell(solve(y{:},'g1','g2','g3','g4','g5','g6'));%solve system of eqns hi = sym(zeros(3,3)); hs = sym(zeros(3,3)); hs(ind) = t;%representation with 0 below diagonal for symmetric matrix for k = 1:6 hi(ind(k)) = S{k}; end;
display results
disp('Transformed matrix:'); disp(hs); disp('Independent elements:'); disp(hi); rep = input('repeat: '); if isempty(rep),rep=1;end; end;