156def Run_Serial_Fit(Compare_Serial, Consider_Modes, Num_Constants, P, Num_Elements, Nektar_Modes, Timings, Pressure, Velocity_1, Velocity_2, Velocity_3, Scheme):
 
  157    
  158    
  159    Data = []
  160 
  161    
  162    for i in range(0, len(Consider_Modes)):
  163        Data.append(np.mean(Timings[str(Consider_Modes[i])])/10)
  164    
  165    
  166    T_A = []
  167    T_E = []
  168    
  169    
  170    for i in range(0, len(Consider_Modes)):
  171 
  172        
  173        N_P = 0
  174        N_V_1 = 0
  175        N_V_2 = 0
  176        N_V_3 = 0
  177        
  178        
  179        for j in range(1, Consider_Modes[i] + 1):
  180            
  181            
  182            if (j == 2):
  183                continue 
  184            
  185            
  186            
  187            try:
  188                N_P += Pressure[str(j)][0]
  189            except:
  190                Turing = 'King of Computers'
  191 
  192            try:
  193                N_V_1 += Velocity_1[str(j)][0]
  194            except:
  195                Turing = 'King of Computers'
  196 
  197            try:
  198                N_V_2 += Velocity_2[str(j)][0]
  199            except:
  200                Turing = 'King of Computers'
  201 
  202            try:
  203                N_V_3 += Velocity_3[str(j)][0]
  204            except:
  205                Turing = 'King of Computers'
  206         
  207        
  208        (t_a, t_e) = 
Operation_Count(P, Num_Elements, Consider_Modes[i], N_P, N_V_1, N_V_2, N_V_3, Scheme)
 
  209        T_A.append(t_a)
  210        T_E.append(t_e)
  211 
  212    
  213    Fit = 
Fit_Model(Num_Constants, Data, T_A, T_E)
 
  214    
  215    
  216    print(Fit)
  217    
  218    
  219    if Compare_Serial is True:
  220        
  221        
  222        Data = []
  223 
  224        for i in range(1, len(Nektar_Modes)):
  225            Data.append(np.mean(Timings[str(Nektar_Modes[i])])/10)
  226 
  227        Time = []
  228 
  229        for i in range(1, len(Nektar_Modes)):
  230            N_P = 0
  231            N_V_1 = 0
  232            N_V_2 = 0
  233            N_V_3 = 0
  234 
  235            for j in range(1, Nektar_Modes[i] + 1):
  236 
  237                if (j == 2):
  238                    continue 
  239        
  240                try:
  241                    N_P += Pressure[str(j)][0]
  242                except:
  243                    Turing = 'King of Computers'
  244 
  245                try:
  246                    N_V_1 += Velocity_1[str(j)][0]
  247                except:
  248                    Turing = 'King of Computers'
  249 
  250                try:
  251                    N_V_2 += Velocity_2[str(j)][0]
  252                except:
  253                    Turing = 'King of Computers'
  254 
  255                try:
  256                    N_V_3 += Velocity_3[str(j)][0]
  257                except:
  258                    Turing = 'King of Computers'
  259 
  260            Time.append(
Serial_Computation(P, Num_Elements, Nektar_Modes[i], N_P, N_V_1, N_V_2, N_V_3, Num_Constants, Fit, Scheme))
 
  261 
  262        Nektar_Modes = list(Nektar_Modes)
  263        Nektar_Modes.pop(0)
  264        
  265        
  266        difference = []
  267 
  268        for i in range(0, len(Nektar_Modes)):
  269            difference.append(
abs(Data[i] - Time[i]))
 
  270        
  271        mean_diff = np.mean(difference) 
  272        std_dev_diff = np.std(difference)
  273        var_diff = np.var(difference)
  274        
  275        
  276        print('The mean of the differences between the Data and the Model is ' + str(mean_diff))
  277        print('The standard deviation of the differences between the Data and the Model is ' + str(std_dev_diff))
  278        print('The variance of the differences between the Data and the Model is ' + str(var_diff))
  279 
  280        
  281        fig, ax = plt.subplots()
  282        ax.plot(Nektar_Modes, Data, label = 'Data')
  283        ax.errorbar(Nektar_Modes, Time, label = 'Model')
  284        ax.set_xlabel('$ N_Z $')
  285        ax.set_ylabel('Timestep (s)')
  286        ax.set_title('Length of Single Timestep: Model vs Data')
  287        plt.legend(loc=4)
  288        fig.savefig("Output/Figures/Model_vs_Data.png")
  289 
  290    return(Fit)
  291 
  292
  293
  294
def Run_Serial_Fit(Compare_Serial, Consider_Modes, Num_Constants, P, Num_Elements, Nektar_Modes, Timings, Pressure, Velocity_1, Velocity_2, Velocity_3, Scheme)
 
def Serial_Computation(P, Num_Elements, Num_Modes, N_P, N_V_1, N_V_2, N_V_3, Num_Constants, constants, Scheme)
 
scalarT< T > abs(scalarT< T > in)