close all;clear all; clc;

%Rozmìry experimentu
l=300;
hh=0.7;
hj=39.5;
hd=0.7;
b=91.5;
F=1e3;
dT=[28.7246;28.7246;28.7246];

%Parametry materiálù
Eh=2e5;
Gh=77e3;
alfah=17.3e-6;
vh=(Eh-2*Gh)/2/Gh;

Ej=12.6864;
alfaj=4.5e-5;
vj=0.5682;
Gj=Ej/(2*vj+2);

Ed=73.1e3;
Gd=28e3;
alfad=23.2e-6;
vd=(Ed-2*Gd)/2/Gd;

%Matice tuhostí
%Horní potah
C11=Eh*(1-vh)/(1+vh)/(1-2*vh);
C12=Eh*vh/(1+vh)/(1-2*vh);

Ch=[C11    C12   C12    0               0      0;
    C12    C11   C12    0               0      0;
    C12    C12   C11    0               0      0;
     0      0     0   1/2*(C11-C12)     0      0;
     0      0     0     0        1/2*(C11-C12) 0;
     0      0     0     0               0  1/2*(C11-C12);];
 
%Jádro
C11=Gj;
C12=0;

Cj=[C11    C12   C12    0               0      0;
    C12    C11   C12    0               0      0;
    C12    C12   C11    0               0      0;
     0      0     0   1/2*(C11-C12)     0      0;
     0      0     0     0        1/2*(C11-C12) 0;
     0      0     0     0               0  1/2*(C11-C12);];
 
%Dolní potah
C11=Ed*(1-vd)/(1+vd)/(1-2*vd);
C12=Ed*vd/(1+vd)/(1-2*vd);

Cd=[C11    C12   C12    0               0      0;
    C12    C11   C12    0               0      0;
    C12    C12   C11    0               0      0;
     0      0     0   1/2*(C11-C12)     0      0;
     0      0     0     0        1/2*(C11-C12) 0;
     0      0     0     0               0  1/2*(C11-C12);];
 
%Vzdálenosti
h1=-hh-hj/2;
h2=-hj/2;
h3=hj/2;
h4=hd+hj/2; 
 
%Matice A

A11=Ch(1,1)*(h2-h1)+Cd(1,1)*(h4-h3);
A12=Ch(1,2)*(h2-h1)+Cd(1,2)*(h4-h3);
A16=Ch(1,6)*(h2-h1)+Cd(1,6)*(h4-h3);
A21=Ch(2,1)*(h2-h1)+Cd(2,1)*(h4-h3);
A22=Ch(2,2)*(h2-h1)+Cd(2,2)*(h4-h3);
A26=Ch(2,6)*(h2-h1)+Cd(2,6)*(h4-h3);
A61=Ch(6,1)*(h2-h1)+Cd(6,1)*(h4-h3);
A62=Ch(6,2)*(h2-h1)+Cd(6,2)*(h4-h3);
A66=Ch(6,6)*(h2-h1)+Cd(6,6)*(h4-h3);

A=[A11     A12     A16;
   A21     A22     A26;
   A61     A62     A66;];

%Matice AT

AT11=alfah*Ch(1,1)*(h2-h1)+alfad*Cd(1,1)*(h4-h3);
AT12=alfah*Ch(1,2)*(h2-h1)+alfad*Cd(1,2)*(h4-h3);
AT16=alfah*Ch(1,6)*(h2-h1)+alfad*Cd(1,6)*(h4-h3);
AT21=alfah*Ch(2,1)*(h2-h1)+alfad*Cd(2,1)*(h4-h3);
AT22=alfah*Ch(2,2)*(h2-h1)+alfad*Cd(2,2)*(h4-h3);
AT26=alfah*Ch(2,6)*(h2-h1)+alfad*Cd(2,6)*(h4-h3);
AT61=alfah*Ch(6,1)*(h2-h1)+alfad*Cd(6,1)*(h4-h3);
AT62=alfah*Ch(6,2)*(h2-h1)+alfad*Cd(6,2)*(h4-h3);
AT66=alfah*Ch(6,6)*(h2-h1)+alfad*Cd(6,6)*(h4-h3);

AT=[AT11     AT12     0;
    AT21     AT22     0;
    AT61     AT62     0;];


%Matice B
B11=hj/2*(Cd(1,1)*(h4-h3)-Ch(1,1)*(h2-h1));
B12=hj/2*(Cd(1,2)*(h4-h3)-Ch(1,2)*(h2-h1));
B16=hj/2*(Cd(1,6)*(h4-h3)-Ch(1,6)*(h2-h1));
B21=hj/2*(Cd(2,1)*(h4-h3)-Ch(2,1)*(h2-h1));
B22=hj/2*(Cd(2,2)*(h4-h3)-Ch(2,2)*(h2-h1));
B26=hj/2*(Cd(2,6)*(h4-h3)-Ch(2,6)*(h2-h1));
B61=hj/2*(Cd(6,1)*(h4-h3)-Ch(6,1)*(h2-h1));
B62=hj/2*(Cd(6,2)*(h4-h3)-Ch(6,2)*(h2-h1));
B66=hj/2*(Cd(6,6)*(h4-h3)-Ch(6,6)*(h2-h1));

B=[B11     B12     B16;
   B21     B22     B26;
   B61     B62     B66;];

%Matice C
C11=1/2*(Cd(1,1)*(h4^2-h3^2)+Ch(1,1)*(h2^2-h1^2));
C12=1/2*(Cd(1,2)*(h4^2-h3^2)+Ch(1,2)*(h2^2-h1^2));
C16=1/2*(Cd(1,6)*(h4^2-h3^2)+Ch(1,6)*(h2^2-h1^2));
C21=1/2*(Cd(2,1)*(h4^2-h3^2)+Ch(2,1)*(h2^2-h1^2));
C22=1/2*(Cd(2,2)*(h4^2-h3^2)+Ch(2,2)*(h2^2-h1^2));
C26=1/2*(Cd(2,6)*(h4^2-h3^2)+Ch(2,6)*(h2^2-h1^2));
C61=1/2*(Cd(6,1)*(h4^2-h3^2)+Ch(6,2)*(h2^2-h1^2));
C62=1/2*(Cd(6,2)*(h4^2-h3^2)+Ch(6,2)*(h2^2-h1^2));
C66=1/2*(Cd(6,6)*(h4^2-h3^2)+Ch(6,6)*(h2^2-h1^2));

C=[C11     C12     C16;
   C21     C22     C26;
   C61     C62     C66;];

%Matice CT
BT11=1/2*(alfah*Cd(1,1)*(h4^2-h3^2)+alfah*Ch(1,1)*(h2^2-h1^2));
BT12=1/2*(alfah*Cd(1,2)*(h4^2-h3^2)+alfah*Ch(1,2)*(h2^2-h1^2));
BT16=1/2*(alfah*Cd(1,6)*(h4^2-h3^2)+alfah*Ch(1,6)*(h2^2-h1^2));
BT21=1/2*(alfah*Cd(2,1)*(h4^2-h3^2)+alfah*Ch(2,1)*(h2^2-h1^2));
BT22=1/2*(alfah*Cd(2,2)*(h4^2-h3^2)+alfah*Ch(2,2)*(h2^2-h1^2));
BT26=1/2*(alfah*Cd(2,6)*(h4^2-h3^2)+alfah*Ch(2,6)*(h2^2-h1^2));
BT61=1/2*(alfah*Cd(6,1)*(h4^2-h3^2)+alfah*Ch(6,2)*(h2^2-h1^2));
BT62=1/2*(alfah*Cd(6,2)*(h4^2-h3^2)+alfah*Ch(6,2)*(h2^2-h1^2));
BT66=1/2*(alfah*Cd(6,6)*(h4^2-h3^2)+alfah*Ch(6,6)*(h2^2-h1^2));

BT=[BT11     BT12     0;
    BT21     BT22     0;
    BT61     BT62     0;];

%Matice D
D11=hj/4*(Cd(1,1)*(h4^2-h3^2)-Ch(1,1)*(h2^2-h1^2));
D12=hj/4*(Cd(1,2)*(h4^2-h3^2)-Ch(1,2)*(h2^2-h1^2));
D16=hj/4*(Cd(1,6)*(h4^2-h3^2)-Ch(1,6)*(h2^2-h1^2));
D21=hj/4*(Cd(2,1)*(h4^2-h3^2)-Ch(2,1)*(h2^2-h1^2));
D22=hj/4*(Cd(2,2)*(h4^2-h3^2)-Ch(2,2)*(h2^2-h1^2));
D26=hj/4*(Cd(2,6)*(h4^2-h3^2)-Ch(2,6)*(h2^2-h1^2));
D61=hj/4*(Cd(6,1)*(h4^2-h3^2)-Ch(6,1)*(h2^2-h1^2));
D62=hj/4*(Cd(6,2)*(h4^2-h3^2)-Ch(6,2)*(h2^2-h1^2));
D66=hj/4*(Cd(6,6)*(h4^2-h3^2)-Ch(6,6)*(h2^2-h1^2));

D=[D11     D12     D16;
   D21     D22     D26;
   D61     D62     D66;];

%Matice N

%Matice M
M=[F*l/4/b;
   0;
   0 ];

disp('Sendvicova teorie s vlivem teploty');
%Prùhyb bez smyku
disp('bez smyku');

X=inv(B*inv(A)*-B+D)*(BT*dT-B*A^-1*AT*dT);
w_ft=-X(1,1)/2*l^2/4+X(1,1)*l^2/4;

X=inv(B*inv(A)*-B+D);
w_f=F*l^3/(48*b)*X(1,1)+w_ft

%Prùhyb se smykem
disp('se smykem')
F45=0;
F54=0;
F55=Cj(5,5)*hj;
F44=Cj(4,4)*hj;
F55hv=1/hj/Gj;

w_fs=F*l^3/48/b*X(1,1)*(1+12*F55hv/X(1,1)/l^2)+w_ft
