// Pb 7-8, 7-9, 7-10, 7-11, & 7-12. 
mode(0); // prints each line like MATLAB unless suppressed by ;
funcprot(0); // to avoid warnings
exec('C:/Users/EJB/OneDrive/Scilab/CLT.sci',0);

orientation = [0,45,-45,45,0]; // deg
thickness   = [1, 1, 2, 1, 1]*2.5; // mm
N = length(thickness);  // # of laminas
// properties E-glass/polyester
E1 = 204.6E3;   // MPa
E2 = 20.46E3;     // MPa
v12 = 0.3;
v23 = 0.5;      // not given
G12 = 6.89E3;    // MPa
F1t = 826.8;    // MPa
F1c = 482.3;
F2t = 68.9;
F2c = F2t;
F6 = 241.15;

// Pb. 7.8
Q = buildQ(E1,E2,G12,v12);    
[A,B,D] = buildABD(Q,thickness,orientation)

// Pb. 7.9
N = [1000,1000,0]'; // ' makes it a column array
eps0 = A\N;

// Pb. 7.10
//function T=transf(theta)//in degrees--use from CLT
//    m = cosd(theta);
//    n = sind(theta);
//    R = [[1 0 0];[0 1 0];[0 0 2]];
//    T = [[m^2 n^2 2*m*n];[n^2 m^2 -2*m*n];[-m*n m*n m^2-n^2]]
//endfunction

// 0 deg lamina (k=1)
sig = Q(:,:,1)*eps0

// 45 deg (lamina k=2)
T=transf(45); 
Q45 = T^-1*Q(:,:,1)*T'^-1;
sig = Q45*eps0

// -45 deg (lamina k=3)
T=transf(-45); 
Qm45 = T^-1*Q(:,:,1)*T'^-1;
sig = Qm45*eps0

// Pb. 7.11 & 7.12
//Reuter = [[1,0,0];[0,1,0];[0,0,2]];//use from CLT
T=transf(0); 
eps = Reuter*T*Reuter^-1*eps0   // 7.11
sig = Q(:,:,1)*eps              // 7.12

T=transf(45); 
eps = Reuter*T*Reuter^-1*eps0   // 7..1
sig = Q(:,:,1)*eps              // 7.12

T=transf(-45); 
eps = Reuter*T*Reuter^-1*eps0   // 7.11
sig = Q(:,:,1)*eps              // 7.12

//format('v',6)
//prettyprint(Q(:,:,1)*1E-3)
//prettyprint(A*1E-6)
//prettyprint(D*1E-6)
//prettyprint(eps0*1E6)
prettyprint(sig')
//prettyprint(eps'*1E6)
