%Sijkova 2020
%NACITANIE VYSLEDKOV Z ANSYSU JE NUTNE ZVOLIT SPRAVNU CESTU
clear all; close all; clc
set(groot,'defaulttextinterpreter','latex');  
set(groot, 'defaultAxesTickLabelInterpreter','latex');  
set(groot, 'defaultLegendInterpreter','latex');
y0=2;
% AnalysisName = strcat('PVDF_R_model_',num2str(y0),'mmA');
AnalysisName = strcat('Jednomorfny_PVDF_nosnik');
harmonicpath = strcat(AnalysisName,'_files\dp12\SYS-16\MECH');
transientpath= strcat(AnalysisName,'_files\dp12\SYS-17\MECH');
path = 'C:\Users\simon\OneDrive - Vysoké učení technické v Brně\VUT_Dokumenty\DP\Ansys\PVDF_R_modely\';

%% HARMONICKA ANALYZA
T1= importdata(strcat(path,harmonicpath,'\Harmonic10MOhm.txt'));
% T1= importdata('Harmonic10MOhm.txt');
f_ans = T1(:,1);
U_ans = T1(:,2);
V_ans = T1(:,3);
f_ans = f_ans(1:length(f_ans)/2);
U_ans = U_ans(1:length(U_ans)/2);
V_ans = V_ans(1:length(V_ans)/2);
figure
subplot(2,1,1)
    [~,om0]=max(U_ans);
    plot(f_ans,U_ans*1e3,'-x')
%     text(0.7,0.7,['y_{max} = ',num2str(round(max(y_end*1e3),2)),' mm'],'FontSize',10,'Units','normalized'); 
    xlabel('f [Hz]')
    ylabel('U0 [mm]')
    ylim([0.8*min(U_ans)*1e3 1.2*max(U_ans)*1e3])
    grid on
    title('Amplitudovo-frekvencna charakteristika @10MOhm @0.5 m/s^{2}')

subplot(2,1,2)
    plot(f_ans,V_ans,'-x')
    text(0.7,0.7,{['U_{max} = ',num2str(round(max(V_ans),2)),' V'],['\Omega_{0} = ',num2str(round(f_ans(om0),2)),' Hz']},'FontSize',10,'Units','normalized'); 
    xlabel('f [Hz]')
    ylabel('V [V]')
    ylim([0.8*min(V_ans) 1.2*max(V_ans)])
    grid on
save('NDOFANSYSPlotAF','f_ans','V_ans','U_ans');


%% TRANZIENTNA ANALYZA
T2= importdata(strcat(path,transientpath,'\Transient10MOhm.txt'));
% T2= importdata('Transient10MOhm.txt');
t_ans = T2(:,1);
U_ans = T2(:,2);
V_ans = T2(:,3);

figure
subplot(2,1,1)
plot(t_ans,U_ans*1e3)
xlabel('t [s]')
ylabel('U0 [mm]')
ylim([1.2*min(U_ans)*1e3 1.2*max(U_ans)*1e3])
text(0.3,0.2,['|y_{max}| = ',num2str(round(abs(min(U_ans*1e3)),2)),' mm'],'FontSize',10,'Units','normalized'); 
grid on
title(strcat('Tlmené harmonické kmitanie @10MOhm, @y_{0}=',num2str(y0),'mm AnizotropneE'))


grid on
subplot(2,1,2)
plot(t_ans,V_ans)
text(0.4,0.8,['V_{max} = ',num2str(round(max(V_ans),2)),' V'],'FontSize',10,'Units','normalized'); 
xlabel('t [s]')
ylabel('V [V]')
ylim([1.2*min(V_ans) 1.2*max(V_ans)])
grid on

save('NDOFANSYSPlotTR','t_ans','V_ans','U_ans');



