##Naide2_10.m
#  vt lk 313
close all 
clear
## 
#dbwhere(486)
#
##=========================================================================
## This Program is written by Andres Lahe,   2015-03-30
##                    e-mail: andres.lahe@ttu.ee
## LAST MODIFIED: Andres Lahe,    2015-05-05
## Copyright (c)  2015  by Tallinn University of Technology 
##                Department of Mechanics
##                http://www.ttu.ee/%
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
##=========================================================================
#
# eps2=0.0000000001
 eps1=1.0*10e-11;
  eps2=0.00001 # 4 nulli pärast koma, eristab sortimisel  299.99999
 global spA
 global X
 global AP
# global AP1
# global AP2
# global AP3 
NNK=3*8+3
#--------- Define a matrix spA to be sparse -----------
disp('-------- Sparse matrix instantiation --------  ')
disp('  spA=sparse(NNK,NNK)  ')
spA=sparse(NNK,NNK) # nullistan võrrandisüsteemi kordajate maatriksi
#--------- Define a vector B ------------
disp('-------- Right-hand side of the equations (RHS). --------  ')
disp('  Bvb=zeros(NNK,1);  ')
Bvb=zeros(NNK,1);   # nullistan võrrandisüsteemi vabaliikmed
disp('   ')
#######
#baasi0=1.0   # baasjäikus
l1=800  # cm   # varda 1 pikkus   
l2=600  # cm   # varda 2 pikkus 
l3=200  # cm   # varda 3 pikkus 
#x=0.0 # cm   # koordinaat x
a1=0.0;
a2=300  # cm   # lausmomendi algus
a3=0.0;
mx=1000.0 # N    # lausmoment 
mx1=mx;
#mx=1000.0 
#mx=10000.0 # N    # lausmoment
Mx2=3.20e+05 # Ncm    # koondmoment 320 000
#Mx=3.20e+05 # Ncm    # koondmoment 
#By=-1.00e+07 # Ncm2    # koondbimoment 10 000 000
By=-1.00e+07
#By=1.00e+11
#
# Iw=1349900
# It= 195.50
#GIt= 1.5837e+09  # Ncm2      # väändejäikus
GIt= 1.5637e+09
#GIt= 1.5640e+09 
baasi0=1.0e+8  # baasjäikus
EIw= 2.8348e+13 #Ncm4 # kooldumisjäikus
#Iw=1.3671e+06
##EIw=2.8356e+13
#######
#G =  8000000                                                                                                                                                                                                            
#E =  21000000                                                                                                                                                                                                             
#It =  195.50                                                                                                 
#Iw =  1349900                                                                                                       
#GIt=G*It =  1.5640e+09                                                                                                   
#EIw=E*Iw =  2.8348e+13                                                                                                
#kt=sqrt(GIt/EIw)   =  0.0074278 
##k = 0.0074278 # cm^{-1}
k=sqrt(GIt/EIw)
#######
#######
spvF=yspWGvfmhvI(baasi0,l1,GIt,EIw);  # hõreda laiendatud ülekandemaatriksi arvutus
#AAAA=full(spvF)
vB1=yzWGmx(baasi0,l1,l1,a1,mx,GIt,EIw); # koormusvektori arvutus
IIv=1;
IJv=1;
vB1=vB1.*(-1);
spA=spInsertBtoA(spA,IIv,IJv,spvF);     # astab ülekandemaatriksi võrrandisüsteemi
Bvb=InsertBtoA(Bvb,NNK,1,IIv,1,vB1,4,1); # astab koormusvektori vabaliikmesse
####### 
spvF=yspWGvfmhvI(baasi0,l2,GIt,EIw);  # hõreda laiendatud ülekandemaatriksi arvutus
vB2=yzWGMx(baasi0,l2,l2,a2,Mx2,GIt,EIw); # koormusvektori arvutus
krda=2;
IIv=krda*4-3;
IJv=krda*8-7;
vB2=vB2.*(-1);
spA=spInsertBtoA(spA,IIv,IJv,spvF);     # astab ülekandemaatriksi võrrandisüsteemi
Bvb=InsertBtoA(Bvb,NNK,1,IIv,1,vB2,4,1); # astab koormusvektori vabaliikmesse
####### 
spvF=yspWGvfmhvI(baasi0,l3,GIt,EIw);  # hõreda laiendatud ülekandemaatriksi arvutus
##vB3=yzWGBy(baasi0,l3,l3,a3,By,GIt,EIw); # koormusvektori arvutus
krda=3;
IIv=krda*4-3;
IJv=krda*8-7;
#vB3=vB3.*(-1);
spA=spInsertBtoA(spA,IIv,IJv,spvF);     # astab ülekandemaatriksi võrrandisüsteemi
##Bvb=InsertBtoA(Bvb,NNK,1,IIv,1,vB3,4,1); # astab koormusvektori vabaliikmesse
##figure(1)
##spy(spA)
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vorrandeidB=size(spA);
#rows_of_basic_equations=vorrandeidB(1,1);
#cols_of_basic_equations=vorrandeidB(1,2);
#non_zero_elements_in_the_basic_equations=nnz(spA);

spRidu=vorrandeidB(1,1);
pohivorrandiXe=vorrandeidB(1,2);
disp('  ')
disp('-------- Pärast põhivõrrandite sisestamist on võrrandisüsteemis  ----  ')
spA_rida=sprintf(' %d', spRidu)
spA_veergu=sprintf(' %d', pohivorrandiXe)
disp('  ')
Nr1=spRidu+1;
#disp('  ')
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

####### Rajatingimused 
# Pidevustingimused
# Tugi 2
spA=spSisestaArv(spA,13,5,1);    # $theta_{5}$  on võrdne
spA=spSisestaArv(spA,13,9,-1);   # $theta_{9}$ väändenurgaga
  spA=spSisestaArv(spA,14,6,1);    # $T_{t6}$ on võrdne
  spA=spSisestaArv(spA,14,10,1);  # $T_{t10}$  
# Tugi 3
spA=spSisestaArv(spA,15,13,1);    # $theta_{13}$ - väändenurk
spA=spSisestaArv(spA,15,17,-1);  # võrdne $theta_{17}$ väändenurga
  spA=spSisestaArv(spA,16,14,1);   # $T_{t14}$  on võrdne
  spA=spSisestaArv(spA,16,18,1);  # $T_{t18}$
  
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#disp('----- ')
vorrandeidD=size(spA);
#
#disp(' ')
disp('-------- Pärast pidevusvõrrandite lisamist on võrrandisüsteemis  ----  ')
spA_rida=vorrandeidD(1,1)
spA_rowsD=spA_rida;
spA_veergu=vorrandeidD(1,2)
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   
# Tasakaalutingimused
# Tugi 1
spA=spSisestaArv(spA,17,2,1);    # $T_{t2}$ + 
spA=spSisestaArv(spA,17,4,1);    # $T_{t4}$ = $T_{sum}$ ja
spA=spSisestaArv(spA,17,25,-1);  # $C_{sum25}$ summa on tasakaalus
# Tugi 2
spA=spSisestaArv(spA,18,7,1);    # $B_{7}$ -bimoment 
spA=spSisestaArv(spA,18,11,1);   # $B_{11}$ summa on tasakaalus
  spA=spSisestaArv(spA,19,6,1);    # $T_{t8}$ +
  spA=spSisestaArv(spA,19,8,1);    # $T_{w8}$ +
  spA=spSisestaArv(spA,19,10,1);   # $T_{t10}$ +  
  spA=spSisestaArv(spA,19,12,1);   # $T_{w12}$ = $T_{sum}$ -
  spA=spSisestaArv(spA,19,26,-1);  # $C_{sum26}$ 
# Tugi 3
spA=spSisestaArv(spA,20,15,1);   # $B_{15}$ -bimomendi 
spA=spSisestaArv(spA,20,19,1);   # ja $B_{19}$ summa on tasakaalus
  spA=spSisestaArv(spA,21,14,1);   # $T_{t14}$ + 
  spA=spSisestaArv(spA,21,16,1);   # $T_{w16}$ +
  spA=spSisestaArv(spA,21,18,1);   # $T_{t18}$ +  
  spA=spSisestaArv(spA,21,20,1);   # $T_{w20}$ = $T_{sum}$
  spA=spSisestaArv(spA,21,27,-1);  # $C_{sum27}$ summa on tasakaalus
#SUM1=Z(25,1)+Z(26,1)+Z(27,1)
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vorrandeid=size(spA);
spRidu=vorrandeid(1,1);
#disp('----- ')
vorrandeidE=size(spA);
disp(' ')
disp('-------- Pärast tasakaaluvõrrandite lisamist on võrrandisüsteemis  ----  ')
spA_rows=vorrandeidE(1,1);
spA_rida=spA_rows
spA_rowsE=spA_rows;
spA_cols=vorrandeidE(1,2);
spA_veergu=spA_cols
#Nr1=spRidu+1;
#ABB=ABB;
#ABBdim=size(ABB) ;
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Toetingimused
# Tugi 1
spA=spSisestaArv(spA,22,1,1);  # $theta_A$ - väändenurk on null
spA=spSisestaArv(spA,23,2,1);  # $T_tA$ - kooldumisväändemoment
# Tugi 2
spA=spSisestaArv(spA,24,9,1);  # $theta_A$ - väändenurk on null
# Tugi 3
spA=spSisestaArv(spA,25,17,1);  # $theta_A$ - väändenurk on null
# 0ts 4
spA=spSisestaArv(spA,26,23,1);  # $B_{L}$ -bimoment 
Bvb(26,1)=By ;
#Bvb(26,1)=-By ;
spA=spSisestaArv(spA,27,22,1);  # $T_{tL}+ T_{\omega L}$ - 
spA=spSisestaArv(spA,27,24,1);  #         -üldväändemoment
Bvb(27,1)=0.0;
#Bvb(27,1)=0.0;
#spA=spSisestaArv(spA,27,21,-1);
#  vastavd  vabaliikmed Bvb on juba nullistatud
#
#spA_rank = sprank(spA) # võrrandisüsteemi astak
#A=full(spA)
#Bvb
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
vorrandeid=size(spA);
spRidu=vorrandeid(1,1);   
#
#disp('----- ')
vorrandeidR=size(spA);
#
disp(' ')
disp('-------- Pärast toetingimuste lisamist on võrrandisüsteemis  ----  ')
spA_rows=vorrandeidR(1,1);
spA_rida=spA_rows
spA_cols=vorrandeidR(1,2);
spA_veergu=spA_cols
spA_rows=vorrandeidR(1,1);
#
disp('  ')
spA_rank = sprank(spA)
disp('  ')
#
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ')
#spA_rank = sprank(spA)
disp('  ')
spA
Bvb
# Teine märgikokkulepe.Väändnurk skaleeritud
Z=spA\Bvb; # lahendab võrrandisõteemist spA*X=Bvb
Z
C25=Z(25,1)
C26=Z(26,1)
C27=Z(27,1)
#Z(26,1)
#Z(27,1)
#Z(10,1)=-Z(6,1)
#Z(18,1)=-Z(14,1)
Z6=Z(6,1)
Z10=Z(10,1)
Z14=Z(14,1)
Z18=Z(18,1)

#
#spA_rank = sprank(spA)
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
#SUM1=C_{sum25}+C_{sum26+C_{sum27}=  = -8320010
SUM1=Z(25,1)+Z(26,1)+Z(27,1) 
#
#mx =  mx1;
Mx2 =  320000;
SUM2=mx1*800+Mx2  %%=8320000;
#SUM2=mx+Mx2=1000.0*800+3.20e+05 = 1120000
## OK lk 52 kõik klapib
  
#NEARV=1;
#baasi0=1.0
#for i=1:NEARV
#%siireVardaA(i,1:2)
AlgPar1(1:4,1)=[Z(1,1)/baasi0   Z(2,1)  Z(3,1)   Z(4,1)]
AlgPar2(1:4,1)=[Z(9,1)/baasi0   Z(10,1) Z(11,1)  Z(12,1)]
#vordle3lopp2(1:4,1)=[Z(13,1)/baasi0   Z(14,1) Z(15,1)  Z(16,1)];
AlgPar3(1:4,1)=[Z(17,1)/baasi0  Z(18,1) Z(19,1)  Z(20,1)]
#endfor
#      
#AlgParm=AlgPar;  
#disp('skaleerimata väändenurk skaleerimata väändenurk varda lõpus ')
#theta=Z(5,1)/baasi0 # skaleerimata väändenurk varda lõpus
#spA  # hõre laiendatud ¨ulekandemaatriks
disp(' Algparameetrid - AP ') 
   AP1=AlgPar1(:,1);
   AP2=AlgPar2(:,1);
   AP3=AlgPar3(:,1);  
# Varras 1
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
disp('   ')
#
  suurused=[' theta -'; 
            '    Tt -'; 
            '     B -'; 
            '    Tw -'; 
            '  Tsum -']; 
#
#  size(suurused)
disp(' Algparameetrid - AP1          AP2          AP3 ')  
for i=1:4 
disp(sprintf('%8s %14.4e %14.4e %14.4e',suurused(i,:), AP1(i,1), AP2(i,1), AP3(i,1) ))
endfor 
disp('   ')  
 
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

 AP=AP1;
baasi0=1.0
Nmitmeks=4
xx=0.0;
xsamm=0.0;
xsamm=l1/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l1,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);               # ylfhlin(1.0,xx,EA,GAr,EI);  
  vvB1=yzWGmx(baasi0,l1,xx,a1,mx1,GIt,EIw); 
#  vvB=ESTtalaKrmus(1.0,xx,Li,Fjoud,qkoormus,EI);
  
 Fvv(1:4,ij)=vvF*AP+vvB1;
 Fvv(5,ij)=Fvv(2,ij)+Fvv(4,ij);
xx=xx+xsamm;
endfor 
#Fvv(1,:)
Fvv;
kt=sqrt(GIt/EIw);
k=kt
  nu=l1*sqrt(GIt/EIw);
 nul=nu/l1;
 lnu=l1/nu;
%%# nux=nul*x;
  nux=nul*l1;
 ch=cosh(nux);
 sh=sinh(nux);
#
  
  suurused=[' theta -'; 
            '    Tt -'; 
            '     B -'; 
            '    Tw -'; 
            '  Tsum -']; 
#disp(' size(suurused) ')            
  size(suurused);          

#for i=1:5
disp(sprintf('%9s %9.2f    %9.2f     %9.2f    %9.2f    %9.2f', ' x= ',  Xloikes(1,1), Xloikes(2,1), Xloikes(3,1), Xloikes(4,1),Xloikes(5,1)))
#endfor
 #  
#
for i=1:5 
disp(sprintf('%8s %12.3e %12.3e %12.3e %12.3e %12.3e',suurused(i,:), Fvv(i,1), Fvv(i,2), Fvv(i,3), Fvv(i,4), Fvv(i,5)))
endfor
 # 
disp('  ') 
#%%%%%%%%%%%%%%%%%%%%%%%%%%%
#figure(1)
#spy(spA)
#title('spy(spA) - the sparse matrix spA(8,8) non zero elements [31%] ')
#refresh  
##print('-dfig','-landscape','spESTNaide2_1_sparse_matrix.fig');  
#refresh
#disp('-----------------------------------')
#disp('  ')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 AP=AP2;
baasi0=1.0
Nmitmeks=4
xx=0.0;
xsamm=0.0;
xsamm=l2/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l2,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);               # ylfhlin(1.0,xx,EA,GAr,EI);  
  vvB2=yzWGMx(baasi0,l2,xx,a2,Mx2,GIt,EIw); 
#  vvB=ESTtalaKrmus(1.0,xx,Li,Fjoud,qkoormus,EI);
  
 Fvv(1:4,ij)=vvF*AP+vvB2;
 Fvv(5,ij)=Fvv(2,ij)+Fvv(4,ij);
xx=xx+xsamm;
endfor 
#Fvv(1,:)
Fvv;
kt=sqrt(GIt/EIw);
k=kt
  nu=l2*sqrt(GIt/EIw);
 nul=nu/l2;
 lnu=l2/nu;
# nux=nul*x;
  nux=nul*l2;
 ch=cosh(nux);
 sh=sinh(nux);
#
  
  suurused=[' theta -'; 
            '    Tt -'; 
            '     B -'; 
            '    Tw -'; 
            '  Tsum -']; 
#disp(' size(suurused) ');            
  size(suurused);          

#for i=1:5
disp(sprintf('%9s %9.2f    %9.2f     %9.2f    %9.2f    %9.2f', ' x= ',  Xloikes(1,1), Xloikes(2,1), Xloikes(3,1), Xloikes(4,1),Xloikes(5,1)))
#endfor
 # 
#
for i=1:5 
disp(sprintf('%8s %12.3e %12.3e %12.3e %12.3e %12.3e',suurused(i,:), Fvv(i,1), Fvv(i,2), Fvv(i,3), Fvv(i,4), Fvv(i,5)))
endfor
 # 
disp('  ')  
X= l2/2-eps1;
#X=l2
SFv=SisejoudWGMxpunktis(l2,X,a2,AP,Mx2,GIt,EIw,suurused); 
 # 
disp('  ') 
#%%%%%%%%%%%%%%%%%%%%%%%%%%%
#figure(2)
#spy(spA)
#title('spy(spA) - the sparse matrix spA(8,8) non zero elements [31%] ')
#refresh  
##print('-dfig','-landscape','spESTNaide2_2a_sparse_matrix.fig');  
#refresh
#disp('-----------------------------------')
#disp('  ')
#disp(' The END ')
#%%%%%%%%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  


disp(' Algparameetrid - AP ') 
   AP=AP3;
baasi0=1.0
Nmitmeks=4
xx=0.0;
xsamm=0.0;
xsamm=l3/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l3,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);  
#vvB3=yzWGBy(baasi0,l,x,a,By,GIt,EIw)
#  vvB=ESTtalaKrmus(1.0,xx,Li,Fjoud,qkoormus,EI);
  
 Fvv(1:4,ij)=vvF*AP;  %+vvB3;
 Fvv(5,ij)=Fvv(2,ij)+Fvv(4,ij);
xx=xx+xsamm;
endfor 
#Fvv(1,:)
Fvv;
kt=sqrt(GIt/EIw);
k=kt
  nu=l3*sqrt(GIt/EIw);
 nul=nu/l3;
 lnu=l3/nu;
# nux=nul*x;
  nux=nul*l3;
 ch=cosh(nux);
 sh=sinh(nux);
#
  
  suurused=[' theta -'; 
            '    Tt -'; 
            '     B -'; 
            '    Tw -'; 
            '  Tsum -']; 
#disp(' size(suurused) ')            
  size(suurused);    
  
#for i=1:5
disp(sprintf('%9s %9.2f    %9.2f     %9.2f    %9.2f    %9.2f', ' x= ',  Xloikes(1,1), Xloikes(2,1), Xloikes(3,1), Xloikes(4,1),Xloikes(5,1)))
#endfor
 #
#
for i=1:5 
disp(sprintf('%8s %12.3e %12.3e %12.3e %12.3e %12.3e',suurused(i,:), Fvv(i,1), Fvv(i,2), Fvv(i,3), Fvv(i,4), Fvv(i,5)))
endfor
 # 
disp('  ')  

#%%%%%%%%%%%%%%%%
figure(1)
#
#spy(spA,'*')
#spy(spA,'o')
spy(spA,'+','b')
#spy(spA,'x')
#tapio=char(&#245;)
#titleliit1=strcat("spy(spA) - h",char("õ"),"reda maatriksi spA(27,27) nullist erinevad elemendid [11%]");
#titlestring='spy(spA) - hõreda maatriksi spA(27,27) nullist erinevad elemendid [11%] '
#title(titleliit1)
title('spy(spA) - hõreda maatriksi spA(27,27) nullist erinevad elemendid [11%] ')
grid("on")
refresh 
#%print('-dfig','-landscape','-mono','-solid','spESTNaide2_10_sparse_matrix.fig');
#print('-dfigc','-landscape','spESTNaide2_10_sparse_matrix.fig');  
refresh
disp('-----------------------------------')
disp('  ')
disp(' The END ')
#%%%%%%%%%%%%%%%    
 disp('  ') 
disp('  ') 
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% 
  #  
 MiMaSg=minMaxGrfVnurk(Fvv);
disp('  ') 
Nmitmeks=80
AP=AP1;

baasi0=1.0
xx=0;
xsamm=l1/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l1,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);               # ylfhlin(1.0,xx,EA,GAr,EI);  
  vvB=yzWGmx(baasi0,l1,xx,a1,mx1,GIt,EIw); 
#    vvB1=yzWGmx(baasi0,l1,xx,a1,mx1,GIt,EIw); 
#  vvB=ESTtalaKrmus(1.0,xx,Li,Fjoud,qkoormus,EI);
  
 Fvv1(1:4,ij)=vvF*AP+vvB;
 Fvv1(5,ij)=Fvv1(2,ij)+Fvv1(4,ij);
  Fvv1(6,ij)=xx;
xx=xx+xsamm;
ViimaneX1=ij;
endfor 
Fvv1(6,ViimaneX1)=Fvv1(6,ViimaneX1)-eps2;
#%%%%
AP=AP2;

baasi0=1.0
disp('  ') 
Nmitmeks=60
xx=0;
xsamm=l2/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l2,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);               # ylfhlin(1.0,xx,EA,GAr,EI);  
  vvB=yzWGMx(baasi0,l2,xx,a2,Mx2,GIt,EIw);
  
 Fvv2(1:4,ij)=vvF*AP+vvB;
 Fvv2(5,ij)=Fvv2(2,ij)+Fvv2(4,ij);
 Fvv2(6,ij)=xx+l1;
xx=xx+xsamm;
ViimaneX2=ij;
endfor 
# 
Fvv1(6,ViimaneX2)=Fvv1(6,ViimaneX2)-eps2;
#%%%
AP=AP3;

baasi0=1.0
Nmitmeks=8
xx=0.0;
xsamm=0.0;
xsamm=l3/Nmitmeks;
for ij=1:Nmitmeks+1  # 5 - displacements and forces at x=0.0   
Xloikes(ij,1)=xx;
   vvF=ylWGfhlin(baasi0,l3,xx,GIt,EIw);
# vvF=ylTfhlin(1.0,xx,GAr,EI);  
#vvB3=yzWGBy(baasi0,l,x,a,By,GIt,EIw)
#  vvB=ESTtalaKrmus(1.0,xx,Li,Fjoud,qkoormus,EI);
  
 Fvv3(1:4,ij)=vvF*AP;  %+vvB3;
 Fvv3(5,ij)=Fvv3(2,ij)+Fvv3(4,ij);
 Fvv3(6,ij)=xx+l1+l2; 
xx=xx+xsamm;
ViimaneX3=ij;
endfor 
#
#ViimaneX=ViimaneX1+ViimaneX2+ViimaneX3
#%%%%%%%%%%%%%%%%%
#Fvv(1:4,:)=[Fvv1(1:4,:) Fvv2(1:4,:) Fvv3(1:4,:)];
#Fvv(5,:)=[Fvv1(5,:) Fvv2(5,:) Fvv3(5,:)];
Fvv11=Fvv1(1,:);
Fvv12=Fvv2(1,:);
Fvv13=Fvv3(1,:);
Fvv1s=[Fvv11 Fvv12 Fvv13];

Fvv21=Fvv1(2,:);
Fvv22=Fvv2(2,:);
Fvv23=Fvv3(2,:);
Fvv2s=[Fvv21 Fvv22 Fvv23];

Fvv31=Fvv1(3,:);
Fvv32=Fvv2(3,:);
Fvv33=Fvv3(3,:);
Fvv3s=[Fvv31 Fvv32 Fvv33];

Fvv41=Fvv1(4,:);
Fvv42=Fvv2(4,:);
Fvv43=Fvv3(4,:);
Fvv4s=[Fvv41 Fvv42 Fvv43];

Fvv51=Fvv1(5,:);
Fvv52=Fvv2(5,:);
Fvv53=Fvv3(5,:);
Fvv5s=[Fvv51 Fvv52 Fvv53];

Fvv61=Fvv1(6,:);
Fvv62=Fvv2(6,:);
Fvv63=Fvv3(6,:);
Fvv6s=[Fvv61 Fvv62 Fvv63];
#Fvv(6,:)=[Fvv1(6,:) Fvv2(6,:) Fvv3(6,:)]; 
Fvvs=[Fvv1s; Fvv2s; Fvv3s; Fvv4s; Fvv5s; Fvv6s];
FvvsSize=size(Fvvs);
#%%%%%%%%%%%%%%%%%
%ViimaneX=ij
disp('  ')  
X=l2/2-eps2;
AlgPar2(1:4,1)=[Z(9,1)/baasi0   Z(10,1) Z(11,1)  Z(12,1)]
SFv=SisejoudWGMxpunktisGr(l2,X,a2,AP2,Mx2,GIt,EIw,suurused); 
 # 
disp('  ')
#
SFv(6,1)=SFv(6,1)+l1;
ViimaneX=FvvsSize(1,2);
#ViimaneX=ViimaneX1+ViimaneX2+ViimaneX3
ViimaneX=ViimaneX+1;
Fvvs(1:6,ViimaneX)=SFv(1:6,1);
FvvsSize=size(Fvvs);
FvvsTus=Fvvs';
FvvsT=sortrows(FvvsTus,6);
FvvsT(:,6);
Fvvs=FvvsT'; 
#%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  MiMaTa=minMaxGrfVnurk(Fvvs);
  	maxthetagr=MiMaTa(1,1);
	minthetagr=MiMaTa(1,2);
	maxTtgr=MiMaTa(2,1);
	minTtgr=MiMaTa(2,2);
	maxBwgr=MiMaTa(3,1);
	minBwgr=MiMaTa(3,2);
	maxTwgr=MiMaTa(4,1);
	minTwgr=MiMaTa(4,2);        
	maxTsumgr=MiMaTa(5,1);
	minTsumgr=MiMaTa(5,2); 
%%%%%%%%%
L=l1+l2+l3;
JA=-0.075*L;
JL=L+0.075*L;
%jaotT=L/8;
jaotT=100;
XL1=L;
Xg=[0.0; XL1];
Yg=[0.0; 0.0];
%%%%%%%%%
Xloikes=Fvvs(6,:);
XloikesT= Xloikes';
 FvvsT=Fvvs; 
%%
 XA0=XloikesT(1,1);
 YA0=0.0;
%% Xloikes(ij,1)%
 ViimaneXm=size(Xloikes);
 ViimaneX=ViimaneXm(1,2);
%%%%%%%%% 
 YAY=FvvsT(1,1);
 YLY=FvvsT(1,ViimaneX);
 X0=[0.0; 0.0];
 Y0=[0.0;  YAY];
 YAY=FvvsT(1,1);
 XL=[L; L];
 YL=[0.0; YLY];
% mxtheta=max(FvvsT(1,:));
 Xsuurus=size(Xloikes);
% thetasuurus=size(FvvsT(1,:);)
% FvvsT(1,:);
%%%%%%%%%  
figure(2)
%
  plot( X0,Y0,"3",Xloikes(1,:),FvvsT(1,:),"3",Xg,Yg,"3",XL,YL,"3")
grid("on")
% http://www.network-theory.co.uk/docs/octave3/octave_160.html
%grid("off")
%
ax = gca ();
set (ax, "outerposition", [ 0  0  1 0.55])
%minthetagr-150maxthetagr+150     minthetagr-0.001 maxthetagr+0.002
 axis([JA JL  -0.01 0.03], "ij")  % telgede piirid [Xalg Xlõpp Zalg Zlõpp]
 ax=gca();
   xticks(1,:)=0.0:jaotT:L;
 set (ax, "xtick", xticks)
title('Väändenurk theta ',"fontsize",10)
        xlabel('x [m]',"fontsize",10)
	ylabel('theta [rad]',"fontsize",10)
%
%%print('-deps','V66ndenurk_theta.eps');
%%print('-dpng','V66ndenurk_theta.png');
%print('-dfig','-landscape','-mono','-solid','V66ndenurk_theta.fig');
%%print('-dfig','-solid','-landscape','-color','V66ndenurk_theta.fig');
%%http://www.gnu.org/software/octave/doc/interpreter/Printing-Plots.html
refresh
%title('Kooldumisv66ndemoment Tw ',"fontsize",10)
%Vabav66ndemoment
%Koguv66ndemoment
%%%%%%%%%      
%%%%%%%%% 
 YAY=FvvsT(2,1);
 YLY=FvvsT(2,ViimaneX);
 X0=[0.0; 0.0];
 Y0=[0.0;  YAY];
 YAY=FvvsT(2,1);
 XL=[L; L];
 YL=[0.0; YLY];
% mxtheta=max(FvvsT(2,:));
 Xsuurus=size(Xloikes);
% thetasuurus=size(FvvsT(2,:);)
% FvvsT(2,:);
%%%%%%%%%   
figure(3)
%
  plot( X0,Y0,"3",Xloikes(1,:),FvvsT(2,:),"3",Xg,Yg,"3",XL,YL,"3")
grid("on")
% http://www.network-theory.co.uk/docs/octave3/octave_160.html
%grid("off")
%
ax = gca ();
set (ax, "outerposition", [ 0  0  1 0.55])
%axis([JA JL -50000000 30000000]
 axis([JA JL -200000 200000], "ij")  % telgede piirid [Xalg Xlõpp Zalg Zlõpp]
 ax=gca();
   xticks(1,:)=0.0:jaotT:L;
 set (ax, "xtick", xticks)
title('Vabav66ndemoment Tt ',"fontsize",10)
        xlabel('x [m]',"fontsize",10)
	ylabel('Tt [Ncm]',"fontsize",10)
%
%%print('-deps','Vabav66ndemoment_Tt.eps');
%%print('-dpng','Vabav66ndemoment_Tt.png');
%print('-dfig','-landscape','-mono','-solid','Vabav66ndemoment_Tt.fig');
%%print('-dfig','-solid','-landscape','-color','Vabav66ndemoment_Tt.fig');
%%http://www.gnu.org/software/octave/doc/interpreter/Printing-Plots.html
refresh
%title('Kooldumisv66ndemoment Tw ',"fontsize",10)
%Vabav66ndemoment
%%%%%%%%%   
%%%%%%%%% 
 YAY=FvvsT(3,1);
 YLY=FvvsT(3,ViimaneX);
 X0=[0.0; 0.0];
 Y0=[0.0;  YAY];
 YAY=FvvsT(3,1);
 XL=[L; L];
 YL=[0.0; YLY];
% mxtheta=max(FvvsT(3,:));
 Xsuurus=size(Xloikes);
% thetasuurus=size(FvvsT(3,:);)
% FvvsT(3,:);
%%%%%%%%%   
figure(4)
%
  plot( X0,Y0,"3",Xloikes(1,:),FvvsT(3,:),"3",Xg,Yg,"3",XL,YL,"3")
grid("on")
% http://www.network-theory.co.uk/docs/octave3/octave_160.html
%grid("off")
%
ax = gca ();
set (ax, "outerposition", [ 0  0  1 0.55])
%axis([JA JL -50000000 30000000]
 axis([JA JL -50000000 30000000], "ij")  % telgede piirid [Xalg Xlõpp Zalg Zlõpp]
 ax=gca();
   xticks(1,:)=0.0:jaotT:L;
 set (ax, "xtick", xticks)
title('Bimoment Bw ',"fontsize",10)
        xlabel('x [m]',"fontsize",10)
	ylabel('B [Ncm2]',"fontsize",10)
%
%%print('-deps','Bimoment_Bw.eps');
%%print('-dpng','Bimoment_Bw.png');
%print('-dfig','-landscape','-mono','-solid','Bimoment_Bw.fig');
%%print('-dfig','-solid','-landscape','-color','Bimoment_Bw.fig');
%%http://www.gnu.org/software/octave/doc/interpreter/Printing-Plots.html
refresh
%title('Kooldumisv66ndemoment Tw ',"fontsize",10)
%Vabav66ndemoment
%%%%%%%%%    
%%%%%%%%% 
 YAY=FvvsT(4,1);
 YLY=FvvsT(4,ViimaneX);
 X0=[0.0; 0.0];
 Y0=[0.0;  YAY];
 YAY=FvvsT(4,1);
 XL=[L; L];
 YL=[0.0; YLY];
% mxtheta=max(FvvsT(4,:));
 Xsuurus=size(Xloikes);
% thetasuurus=size(FvvsT(4,:);)
% FvvsT(4,:);
%%%%%%%%%   
figure(5)
%
  plot( X0,Y0,"3",Xloikes(1,:),FvvsT(4,:),"3",Xg,Yg,"3",XL,YL,"3")
grid("on")
% http://www.network-theory.co.uk/docs/octave3/octave_160.html
%grid("off")
%
ax = gca ();
set (ax, "outerposition", [ 0  0  1 0.55])
%minTwgr-10000 maxTwgr+10000]
 axis([JA JL -500000 600000], "ij")  % telgede piirid [Xalg Xlõpp Zalg Zlõpp]
 ax=gca();
   xticks(1,:)=0.0:jaotT:L;
 set (ax, "xtick", xticks)
title('Kooldumisv66ndemoment Tw ',"fontsize",10)
        xlabel('x [m]',"fontsize",10)
	ylabel('Tw [Ncm]',"fontsize",10)
%
%%print('-deps','Kooldumisv66ndemoment_Tw.eps');
%%print('-dpng','Kooldumisv66ndemoment_Tw.png');
%print('-dfig','-landscape','-mono','-solid','Kooldumisv66ndemoment_Tw.fig');
%%print('-dfig','-solid','-landscape','-color','Kooldumisv66ndemoment_Tw.fig');
%%http://www.gnu.org/software/octave/doc/interpreter/Printing-Plots.html
refresh
%title('Kooldumisv66ndemoment Tw ',"fontsize",10)
%Vabav66ndemoment
%%%%%%%%%    
%%%%%%%%% 
 YAY=FvvsT(5,1);
 YLY=FvvsT(5,ViimaneX);
 X0=[0.0; 0.0];
 Y0=[0.0;  YAY];
 YAY=FvvsT(5,1);
 XL=[L; L];
 YL=[0.0; YLY];
% mxtheta=max(FvvsT(5,:));
 Xsuurus=size(Xloikes);
% thetasuurus=size(FvvsT(5,:);)
% FvvsT(5,:);
%%%%%%%%%   
figure(6)
%
  plot( X0,Y0,"3",Xloikes(1,:),FvvsT(5,:),"3",Xg,Yg,"3",XL,YL,"3")
grid("on")
% http://www.network-theory.co.uk/docs/octave3/octave_160.html
%grid("off")
%
ax = gca ();
set (ax, "outerposition", [ 0  0  1 0.55])
%minTwgr-10000 maxTwgr+10000]
 axis([JA JL -550000 600000], "ij")  % telgede piirid [Xalg Xlõpp Zalg Zlõpp]
 ax=gca();
   xticks(1,:)=0.0:jaotT:L;
 set (ax, "xtick", xticks)
title('Koguv66ndemoment Tsum ',"fontsize",10)
        xlabel('x [m]',"fontsize",10)
	ylabel('Tsum [kNcm]',"fontsize",10)
%
%%print('-deps','Koguv66ndemoment_Tsum.eps');
%%print('-dpng','Koguv66ndemoment_Tsum.png');
%print('-dfig','-landscape','-mono','-solid','Koguv66ndemoment_Tsum.fig');
%%print('-dfig','-solid','-landscape','-color','Koguv66ndemoment_Tsum.fig');
%%http://www.gnu.org/software/octave/doc/interpreter/Printing-Plots.html
refresh
%title('Kooldumisv66ndemoment Tw ',"fontsize",10)
%Vabav66ndemoment
%Koguv66ndemoment
%%%%%%%%



   








