clear all;

% Call 90 Celsius, 22% RH, oxidative, no UV aging condition "A"
% Call 90 Celsius, test tube sealing, no UV aging condition "B"

%% Plotting for EVA, POE, and EPE condition "A" and condition "B"

%{
%%% Below data is from the DSC 1st heating curve, linear baselines
% Plot the % crystallinity results
% 1 week = 168 hours
t_crystallinity_conditionA = [0; 168; 168*2; 168*4; 168*8];
t_crystallinity_EPE_conditionA = [0; 168*2; 168*4];

crystallinity_EVA_conditionA_1stheating = [10.6; 9.03; 8.89; 8.30];
errorbars_crystallinity_EVA_conditionA_1stheating = [0.3; 0.58; 0.23; 0.32];

crystallinity_POE_conditionA_1stheating = [8.35; 7.08; 6.86; 6.92];
errorbars_crystallinity_POE_conditionA_1stheating = [0.21; 0.13; 0.16; 0.17];

crystallinity_EPE_conditionA_1stheating = [9.10; 6.30; 5.96];
errorbars_crystallinity_EPE_conditionA_1stheating = [0.52; 0.38; 0.27];

figure; hold on
plot(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'r');
plot(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'b');
plot(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'g');
errorbar(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating, errorbars_crystallinity_EVA_conditionA_1stheating,...
    'or', "LineWidth", 2);
errorbar(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating, errorbars_crystallinity_POE_conditionA_1stheating,...
    'ob', "LineWidth", 2);
errorbar(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating, errorbars_crystallinity_EPE_conditionA_1stheating,...
    'og', "LineWidth", 2);
set(gca, 'FontSize', 18, 'FontName', 'Arial');
legend("EVA", "POE", "EPE");
xlabel("Aging time, t (hrs)")
ylabel("Crystallinity, \chi_c (%)");
title("First heating curve, linear baseline");
box on;
ylim([5 12]);

%}

%%% Below data is from the DSC 1st heating curve, sigmoidal baselines
% Plot the % crystallinity results
% The 1 hour results may need to be redone (redoing on 03/20/2024)
% The 1 hour results may be invalid due to non-equilibration??
% 1 week = 168 hours
t_crystallinity_conditionA = [0; 168; 168*2; 168*4; 168*8; 168*14; 168*20; 168*30];
t_crystallinity_EPE_conditionA = [0; 168*2; 168*4; 168*8 + 14; 168*16+29; 168*20; 168*30];

crystallinity_EVA_conditionA_1stheating = [10.52; 8.96; 8.95; 8.68; 7.84; 7.77; 7.71; 8.48];
errorbars_crystallinity_EVA_conditionA_1stheating = [0.28; 0.74; 0.19; 0.42; 0.20; 0.28; 0.20; 0.31];

crystallinity_POE_conditionA_1stheating = [8.89; 7.56; 7.32; 7.49; 7.19; 6.51; 6.66; 7.34];
errorbars_crystallinity_POE_conditionA_1stheating = [0.33; 0.09; 0.14; 0.23; 0.31; 0.12; 0.06; 0.98];

crystallinity_EPE_conditionA_1stheating = [9.21; 6.59; 6.44; 6.81; 6.25; 6.37; 6.61];
errorbars_crystallinity_EPE_conditionA_1stheating = [0.15; 0.28; 0.11; 0.19; 0.25; 0.11; 0.31];

figure; hold on
plot(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'r');
plot(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'b');
plot(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', "#77AC30");
errorbar(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating, errorbars_crystallinity_EVA_conditionA_1stheating,...
    'or', "LineWidth", 1);
errorbar(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating, errorbars_crystallinity_POE_conditionA_1stheating,...
    'ob', "LineWidth", 1);
errorbar(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating, errorbars_crystallinity_EPE_conditionA_1stheating,...
    'o', "LineWidth", 1, "color", "#77AC30");
set(gca, 'FontSize', 18, 'FontName', 'Arial');
legend("EVA 90^oC,22% RH", "POE 90^oC,22% RH", "EPE 90^oC,22% RH");
xlabel("Aging time, t (hrs)")
ylabel("Degree of Crystallinity, \chi_c (%)");
% title("90^oC, 22% RH, no UV", "FontWeight", "Normal");
box on;
ylim([6 11]);


%%% Below data is from the DSC 1st heating curve, sigmoidal baselines
% Plot the % crystallinity results
% 1 week = 168 hours
t_crystallinity_conditionB = [168*2; 168*4; 168*8+14; 168*14; 168*20; 168*30];
t_crystallinity_EPE_conditionB = [168*2; 168*4; 168*7+14; 168*14; 168*20; 168*30];

crystallinity_EVA_conditionB_1stheating = [8.50; 7.92; 7.95; 7.51; 8.42; 8.69];
errorbars_crystallinity_EVA_conditionB_1stheating = [0.16; 0.49; 0.44; 0.34; 0.26; 0.78];

crystallinity_POE_conditionB_1stheating = [7.07; 6.68; 6.87; 6.23; 7.62; 6.42];
errorbars_crystallinity_POE_conditionB_1stheating = [0.24; 0.15; 0.27; 0.06; 0.54; 0.10];

crystallinity_EPE_conditionB_1stheating = [6.73; 6.40; 6.44; 5.87; 6.41; 6.40];
errorbars_crystallinity_EPE_conditionB_1stheating = [0.35; 0.21; 0.35; 0.13; 0.10; 0.16];

figure; hold on
plot(t_crystallinity_conditionB, crystallinity_EVA_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', 'r');
plot(t_crystallinity_conditionB, crystallinity_POE_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', 'b');
plot(t_crystallinity_EPE_conditionB, crystallinity_EPE_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', "#77AC30");
errorbar(t_crystallinity_conditionB, crystallinity_EVA_conditionB_1stheating, errorbars_crystallinity_EVA_conditionB_1stheating,...
    'or', "LineWidth", 1, "MarkerSize", 0.01);
errorbar(t_crystallinity_conditionB, crystallinity_POE_conditionB_1stheating, errorbars_crystallinity_POE_conditionB_1stheating,...
    'ob', "LineWidth", 1, "MarkerSize", 0.01);
errorbar(t_crystallinity_EPE_conditionB, crystallinity_EPE_conditionB_1stheating, errorbars_crystallinity_EPE_conditionB_1stheating,...
    'o', "LineWidth", 1, 'color', "#77AC30", "MarkerSize", 0.01);
set(gca, 'FontSize', 18, 'FontName', 'Arial');
legend("EVA 90^oC,inert sealed", "POE 90^oC,inert sealed", "EPE 90^oC,inert sealed");
xlabel("Aging time, t (hrs)")
ylabel("Degree of Crystallinity, \chi_c (%)");
% title("90^oC, sealed N_2 air, no UV", "FontWeight", "Normal");
box on;
ylim([6 11]);


%% Plotting everything together
figure; hold on
plot(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'r');
plot(t_crystallinity_conditionB, crystallinity_EVA_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', 'r');
plot(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', 'b');
plot(t_crystallinity_conditionB, crystallinity_POE_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', 'b');
plot(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating,...
    "--.", "MarkerSize", 30, "LineWidth", 2, 'color', "#77AC30");
plot(t_crystallinity_EPE_conditionB, crystallinity_EPE_conditionB_1stheating,...
    "--o", "MarkerSize", 10, "LineWidth", 2, 'color', "#77AC30");
errorbar(t_crystallinity_conditionA, crystallinity_EVA_conditionA_1stheating, errorbars_crystallinity_EVA_conditionA_1stheating,...
    'or', "LineWidth", 1);
errorbar(t_crystallinity_conditionB, crystallinity_EVA_conditionB_1stheating, errorbars_crystallinity_EVA_conditionB_1stheating,...
    'or', "LineWidth", 1, "MarkerSize", 0.01);
errorbar(t_crystallinity_conditionA, crystallinity_POE_conditionA_1stheating, errorbars_crystallinity_POE_conditionA_1stheating,...
    'ob', "LineWidth", 1);
errorbar(t_crystallinity_conditionB, crystallinity_POE_conditionB_1stheating, errorbars_crystallinity_POE_conditionB_1stheating,...
    'ob', "LineWidth", 1, "MarkerSize", 0.01);
errorbar(t_crystallinity_EPE_conditionA, crystallinity_EPE_conditionA_1stheating, errorbars_crystallinity_EPE_conditionA_1stheating,...
    'o', "LineWidth", 1, "color", "#77AC30");
errorbar(t_crystallinity_EPE_conditionB, crystallinity_EPE_conditionB_1stheating, errorbars_crystallinity_EPE_conditionB_1stheating,...
    'o', "LineWidth", 1, 'color', "#77AC30", "MarkerSize", 0.01);
set(gca, 'FontSize', 18, 'FontName', 'Arial');
legend("EVA 90^oC,22% RH", "EVA 90^oC,inert sealed", "POE 90^oC,22% RH", "POE 90^oC,inert sealed", ...
    "EPE 90^oC,22% RH", "EPE 90^oC,inert sealed", "FontSize", 15);
legend boxoff;
xlabel("Aging time, t (hrs)");
ylabel("Degree of Crystallinity, \chi_c (%)");
% title("90^oC, 22% RH, no UV", "FontWeight", "Normal");
box on;
ylim([5.5 13]);
