# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/Materials.jl/blob/master/LICENSE

using Tensors, Materials, Test

# TODO: Civilized way to place this wall of numbers at the end of the source file?
# TODO: Or maybe read the expected results from a text file, like the other tests do?
let stresses_expected = [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [10.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [20.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [30.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [40.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [50.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [60.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [70.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [80.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [90.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [110.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [119.995, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [129.743, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [137.812, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [143.250, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [146.767, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [149.313, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [151.463, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [153.465, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [155.402, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [157.301, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [159.164, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [160.991, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [162.780, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [164.529, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [166.236, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [167.902, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [169.527, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [171.110, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [172.653, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [174.155, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [175.618, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [177.042, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [178.429, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [179.779, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [181.094, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [182.373, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [183.619, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [184.833, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [186.014, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [10.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [20.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [30.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [40.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [50.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [60.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [70.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [80.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [90.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [110.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [120.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [130.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [140.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [150.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [159.999, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [169.920, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [179.177, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [187.533, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [195.357, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [202.848, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [209.935, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [216.120, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [219.606, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [216.262, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [209.090, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [203.945, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [201.241, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [200.038, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [199.668, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [199.760, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [200.115, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [200.622, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [201.219, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [201.867, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [202.542, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [203.231, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [203.922, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [204.611, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [205.293, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [205.967, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [206.630, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [207.282, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [207.922, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [208.551, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [209.168, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [209.774, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [210.368, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [210.952, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [211.525, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [212.087, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [212.640, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [213.183, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [213.717, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [214.242, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [214.758, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [215.266, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [215.766, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [216.259, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [216.743, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [217.221, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [217.691, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [218.155, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [218.612, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [219.063, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [219.507, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [219.946, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [220.379, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [220.807, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [221.229, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [221.646, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [222.059, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [222.466, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [222.868, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [223.266, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [223.660, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [224.049, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [224.435, 0.0, 0.0, 0.0, 0.0, 0.0],
                         [224.816, 0.0, 0.0, 0.0, 0.0, 0.0]],
    strains_expected = [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                        [0.00005, -0.00002, -0.00002, 0.0, 0.0, 0.0],
                        [0.00010, -0.00003, -0.00003, 0.0, 0.0, 0.0],
                        [0.00015, -0.00004, -0.00004, 0.0, 0.0, 0.0],
                        [0.00020, -0.00006, -0.00006, 0.0, 0.0, 0.0],
                        [0.00025, -0.00008, -0.00008, 0.0, 0.0, 0.0],
                        [0.00030, -0.00009, -0.00009, 0.0, 0.0, 0.0],
                        [0.00035, -0.00010, -0.00010, 0.0, 0.0, 0.0],
                        [0.00040, -0.00012, -0.00012, 0.0, 0.0, 0.0],
                        [0.00045, -0.00014, -0.00014, 0.0, 0.0, 0.0],
                        [0.00050, -0.00015, -0.00015, 0.0, 0.0, 0.0],
                        [0.00055, -0.00017, -0.00017, 0.0, 0.0, 0.0],
                        [0.00060, -0.00018, -0.00018, 0.0, 0.0, 0.0],
                        [0.00065, -0.00020, -0.00020, 0.0, 0.0, 0.0],
                        [0.00070, -0.00021, -0.00021, 0.0, 0.0, 0.0],
                        [0.00075, -0.00023, -0.00023, 0.0, 0.0, 0.0],
                        [0.00080, -0.00025, -0.00025, 0.0, 0.0, 0.0],
                        [0.00085, -0.00028, -0.00028, 0.0, 0.0, 0.0],
                        [0.00090, -0.00030, -0.00030, 0.0, 0.0, 0.0],
                        [0.00095, -0.00032, -0.00032, 0.0, 0.0, 0.0],
                        [0.00100, -0.00034, -0.00034, 0.0, 0.0, 0.0],
                        [0.00105, -0.00037, -0.00037, 0.0, 0.0, 0.0],
                        [0.00110, -0.00039, -0.00039, 0.0, 0.0, 0.0],
                        [0.00115, -0.00041, -0.00041, 0.0, 0.0, 0.0],
                        [0.00120, -0.00044, -0.00044, 0.0, 0.0, 0.0],
                        [0.00125, -0.00046, -0.00046, 0.0, 0.0, 0.0],
                        [0.00130, -0.00048, -0.00048, 0.0, 0.0, 0.0],
                        [0.00135, -0.00051, -0.00051, 0.0, 0.0, 0.0],
                        [0.00140, -0.00053, -0.00053, 0.0, 0.0, 0.0],
                        [0.00145, -0.00055, -0.00055, 0.0, 0.0, 0.0],
                        [0.00150, -0.00058, -0.00058, 0.0, 0.0, 0.0],
                        [0.00155, -0.00060, -0.00060, 0.0, 0.0, 0.0],
                        [0.00160, -0.00062, -0.00062, 0.0, 0.0, 0.0],
                        [0.00165, -0.00065, -0.00065, 0.0, 0.0, 0.0],
                        [0.00170, -0.00067, -0.00067, 0.0, 0.0, 0.0],
                        [0.00175, -0.00070, -0.00070, 0.0, 0.0, 0.0],
                        [0.00180, -0.00072, -0.00072, 0.0, 0.0, 0.0],
                        [0.00185, -0.00074, -0.00074, 0.0, 0.0, 0.0],
                        [0.00190, -0.00077, -0.00077, 0.0, 0.0, 0.0],
                        [0.00195, -0.00079, -0.00079, 0.0, 0.0, 0.0],
                        [0.00200, -0.00081, -0.00081, 0.0, 0.0, 0.0],
                        [0.00107, -0.00053, -0.00053, 0.0, 0.0, 0.0],
                        [0.00107, -0.00053, -0.00053, 0.0, 0.0, 0.0],
                        [0.00112, -0.00055, -0.00055, 0.0, 0.0, 0.0],
                        [0.00117, -0.00056, -0.00056, 0.0, 0.0, 0.0],
                        [0.00122, -0.00058, -0.00058, 0.0, 0.0, 0.0],
                        [0.00127, -0.00059, -0.00059, 0.0, 0.0, 0.0],
                        [0.00132, -0.00061, -0.00061, 0.0, 0.0, 0.0],
                        [0.00137, -0.00062, -0.00062, 0.0, 0.0, 0.0],
                        [0.00142, -0.00064, -0.00064, 0.0, 0.0, 0.0],
                        [0.00147, -0.00065, -0.00065, 0.0, 0.0, 0.0],
                        [0.00152, -0.00067, -0.00067, 0.0, 0.0, 0.0],
                        [0.00157, -0.00068, -0.00068, 0.0, 0.0, 0.0],
                        [0.00162, -0.00070, -0.00070, 0.0, 0.0, 0.0],
                        [0.00167, -0.00071, -0.00071, 0.0, 0.0, 0.0],
                        [0.00172, -0.00073, -0.00073, 0.0, 0.0, 0.0],
                        [0.00177, -0.00074, -0.00074, 0.0, 0.0, 0.0],
                        [0.00182, -0.00076, -0.00076, 0.0, 0.0, 0.0],
                        [0.00187, -0.00077, -0.00077, 0.0, 0.0, 0.0],
                        [0.00192, -0.00079, -0.00079, 0.0, 0.0, 0.0],
                        [0.00197, -0.00081, -0.00081, 0.0, 0.0, 0.0],
                        [0.00202, -0.00082, -0.00082, 0.0, 0.0, 0.0],
                        [0.00207, -0.00084, -0.00084, 0.0, 0.0, 0.0],
                        [0.00212, -0.00086, -0.00086, 0.0, 0.0, 0.0],
                        [0.00217, -0.00088, -0.00088, 0.0, 0.0, 0.0],
                        [0.00222, -0.00089, -0.00089, 0.0, 0.0, 0.0],
                        [0.00227, -0.00092, -0.00092, 0.0, 0.0, 0.0],
                        [0.00232, -0.00094, -0.00094, 0.0, 0.0, 0.0],
                        [0.00237, -0.00098, -0.00098, 0.0, 0.0, 0.0],
                        [0.00242, -0.00101, -0.00101, 0.0, 0.0, 0.0],
                        [0.00247, -0.00103, -0.00103, 0.0, 0.0, 0.0],
                        [0.00252, -0.00106, -0.00106, 0.0, 0.0, 0.0],
                        [0.00257, -0.00109, -0.00109, 0.0, 0.0, 0.0],
                        [0.00262, -0.00111, -0.00111, 0.0, 0.0, 0.0],
                        [0.00267, -0.00113, -0.00113, 0.0, 0.0, 0.0],
                        [0.00272, -0.00116, -0.00116, 0.0, 0.0, 0.0],
                        [0.00277, -0.00118, -0.00118, 0.0, 0.0, 0.0],
                        [0.00282, -0.00121, -0.00121, 0.0, 0.0, 0.0],
                        [0.00287, -0.00123, -0.00123, 0.0, 0.0, 0.0],
                        [0.00292, -0.00126, -0.00126, 0.0, 0.0, 0.0],
                        [0.00297, -0.00128, -0.00128, 0.0, 0.0, 0.0],
                        [0.00302, -0.00131, -0.00131, 0.0, 0.0, 0.0],
                        [0.00307, -0.00133, -0.00133, 0.0, 0.0, 0.0],
                        [0.00312, -0.00135, -0.00135, 0.0, 0.0, 0.0],
                        [0.00317, -0.00138, -0.00138, 0.0, 0.0, 0.0],
                        [0.00322, -0.00140, -0.00140, 0.0, 0.0, 0.0],
                        [0.00327, -0.00143, -0.00143, 0.0, 0.0, 0.0],
                        [0.00332, -0.00145, -0.00145, 0.0, 0.0, 0.0],
                        [0.00337, -0.00148, -0.00148, 0.0, 0.0, 0.0],
                        [0.00342, -0.00150, -0.00150, 0.0, 0.0, 0.0],
                        [0.00347, -0.00152, -0.00152, 0.0, 0.0, 0.0],
                        [0.00352, -0.00155, -0.00155, 0.0, 0.0, 0.0],
                        [0.00357, -0.00157, -0.00157, 0.0, 0.0, 0.0],
                        [0.00362, -0.00160, -0.00160, 0.0, 0.0, 0.0],
                        [0.00367, -0.00162, -0.00162, 0.0, 0.0, 0.0],
                        [0.00372, -0.00165, -0.00165, 0.0, 0.0, 0.0],
                        [0.00377, -0.00167, -0.00167, 0.0, 0.0, 0.0],
                        [0.00382, -0.00170, -0.00170, 0.0, 0.0, 0.0],
                        [0.00387, -0.00172, -0.00172, 0.0, 0.0, 0.0],
                        [0.00392, -0.00174, -0.00174, 0.0, 0.0, 0.0],
                        [0.00397, -0.00177, -0.00177, 0.0, 0.0, 0.0],
                        [0.00402, -0.00179, -0.00179, 0.0, 0.0, 0.0],
                        [0.00407, -0.00182, -0.00182, 0.0, 0.0, 0.0],
                        [0.00412, -0.00184, -0.00184, 0.0, 0.0, 0.0],
                        [0.00417, -0.00187, -0.00187, 0.0, 0.0, 0.0],
                        [0.00422, -0.00189, -0.00189, 0.0, 0.0, 0.0],
                        [0.00427, -0.00192, -0.00192, 0.0, 0.0, 0.0],
                        [0.00432, -0.00194, -0.00194, 0.0, 0.0, 0.0],
                        [0.00437, -0.00197, -0.00197, 0.0, 0.0, 0.0],
                        [0.00442, -0.00199, -0.00199, 0.0, 0.0, 0.0],
                        [0.00447, -0.00201, -0.00201, 0.0, 0.0, 0.0],
                        [0.00452, -0.00204, -0.00204, 0.0, 0.0, 0.0],
                        [0.00457, -0.00206, -0.00206, 0.0, 0.0, 0.0],
                        [0.00462, -0.00209, -0.00209, 0.0, 0.0, 0.0],
                        [0.00467, -0.00211, -0.00211, 0.0, 0.0, 0.0],
                        [0.00472, -0.00214, -0.00214, 0.0, 0.0, 0.0],
                        [0.00477, -0.00216, -0.00216, 0.0, 0.0, 0.0],
                        [0.00482, -0.00219, -0.00219, 0.0, 0.0, 0.0],
                        [0.00487, -0.00221, -0.00221, 0.0, 0.0, 0.0],
                        [0.00492, -0.00224, -0.00224, 0.0, 0.0, 0.0],
                        [0.00497, -0.00226, -0.00226, 0.0, 0.0, 0.0],
                        [0.00502, -0.00229, -0.00229, 0.0, 0.0, 0.0]],

    parameters = DSAParameterState(E =    200.0e3,
                                   nu =      0.3,
                                   R0 =   100.0,
                                   Kn =   100.0,
                                   nn =    10.0,
                                   C1 = 10000.0,
                                   D1 =   100.0,
                                   C2 = 50000.0,
                                   D2 =  1000.0,
                                   Q =     50.0,
                                   b =      0.1,
                                   w =      1e-5,
                                   P1 =   200.0,
                                   P2 =     1e-1,
                                   m =      0.66,
                                   m1 =     6.0,
                                   m2 =     6.0,
                                   M1 =  6000.0,
                                   M2 =  6000.0,
                                   ba =     1e4,
                                   xi =      1.0),
    material    = DSA(parameters=parameters),
    dtime       = 0.25,
    n_steps     = 100,
    n_interrupt = 40,  # for interrupt-and-hold test

    dstrain11   = 2e-4 * dtime, # Corresponds to 10 MPa elastic stress response

    tostrain(tens::Symm2) = copy(tovoigt(tens; offdiagscale=2.0)),
    tostress(tens::Symm2) = copy(tovoigt(tens)),

    times     = [material.drivers.time],
    stresses  = [tostress(material.variables.stress)],
    strains   = [tostrain(material.drivers.strain)],
    Ras       = [copy(material.variables.Ra)],
    tas       = [copy(material.variables.ta)],
    cumeqs    = [copy(material.variables.cumeq)]

    function snapshot!()
        push!(times, material.drivers.time)
        push!(stresses, tostress(material.variables.stress))
        push!(strains, tostrain(material.drivers.strain))
        push!(Ras, material.variables.Ra)
        push!(tas, material.variables.ta)
        push!(cumeqs, copy(material.variables.cumeq))
    end

    # TODO: This doesn't actually test anything.
    # # Uninterrupted test
    # material2 = DSA(parameters = parameters)
    # times2    = [material2.drivers.time]
    # stresses2 = [tostress(material2.variables.stress)]
    # strains2  = [tostrain(material2.drivers.strain)]
    # for i in 1:n_steps
    #     uniaxial_increment!(material2, dstrain11, dtime)
    #     update_material!(material2)
    #     push!(times2, material2.drivers.time)
    #     push!(stresses2, copy(tovoigt(material2.variables.stress)))
    #     push!(strains2, copy(tovoigt(material2.drivers.strain; offdiagscale = 2.0)))
    # end

    # Interrupted test
    for i in 1:n_interrupt
        uniaxial_increment!(material, dstrain11, dtime)
        update_material!(material)
        snapshot!()
    end

    # Interrupt and hold
    # Drive to zero stress
    strain_at_stop = material.drivers.strain[1,1]
    let dstress11 = -material.variables.stress[1,1]
        stress_driven_uniaxial_increment!(material, dstress11, dtime)
    end
    update_material!(material)
    snapshot!()
    # Hold for 3600 seconds
    stress_driven_uniaxial_increment!(material, 0.0, 3600)
    update_material!(material)
    snapshot!()

    # Continue test
    dstrain_extra = strain_at_stop - material.drivers.strain[1,1]
    n_extra_steps = Int(ceil(dstrain_extra / dstrain11))
    for i in (n_interrupt + 1):(n_steps + n_extra_steps)
        uniaxial_increment!(material, dstrain11, dtime)
        update_material!(material)
        snapshot!()
    end

    for i in 1:length(times)
        @test isapprox(stresses[i], stresses_expected[i]; atol = 1e-3)
        @test isapprox(strains[i],  strains_expected[i]; atol = 1e-5)
    end
    dcumeq = cumeqs[end] - cumeqs[end - 1]
    @test dcumeq > 0
end

# Plotting
# using PyPlot
# x11     = [a[1] for a in strains]
# y11     = [a[1] for a in stresses]
# x112    = [a[1] for a in strains2]
# y112    = [a[1] for a in stresses2]
# RasNorm = [Ra / parameters.P1 for Ra in Ras]
# tasNorm = [ta / maximum(tas) for ta in tas]
# fig = figure("test_DSA.jl", figsize = (5, 12)) # Create a new blank figure
# subplot(211)
# plot(x11,y11, label = "interrupted")
# plot(x112,y112,linestyle = "--", label = "uninterrupted")
# title("test_DSA.jl")
# xlabel("Strain, \$\\varepsilon_{11}\$")
# ylabel("Stress, \$\\sigma_{11}\$")
# legend()
# subplot(212)
# plot(times, RasNorm, label = "\$R_a\$")
# plot(times, tasNorm, linestyle = "--", label = "\$t_a\$")
# xlim([3600.0, maximum(times)])
# title("Normalized Evolution of \$R_a\$ & \$t_a\$")
# xlabel("Time")
# ylabel("Ra, ta")
# legend()
# fig.canvas.draw() # Update the figure
# show()
# gcf()
