def _dsarrfit(temps, rate_constants, a_guess, n_guess, ea_guess, fit_type, dsarrfit_path, a_conv_factor): """ call the dsarrfit code for either a single or double fit """ # Write the input file for the ratefit code ratefit_inp_str = dsarrfit_io.write_input(temps, rate_constants, a_guess, n_guess, ea_guess) dsarrfit_inp_file = os.path.join(dsarrfit_path, 'arrfit.dat') with open(dsarrfit_inp_file, 'w') as arrfit_infile: arrfit_infile.write(ratefit_inp_str) # Run the ratefit program dsarrfit_io.run_dsarrfit(dsarrfit_path) # Read the output of the single and double fit #if fit_type == 'single': # arrname = 'arrfit.out' #elif fit_type == 'double': # arrname = 'darrfit.out' arrname = 'arrfit.out' dsarrfit_out_file = os.path.join(dsarrfit_path, arrname) with open(dsarrfit_out_file, 'r') as arrfit_outfile: arrfit_out_str = arrfit_outfile.read() # Parse the ratefit files for the Arrhenius fit parameters fit_params = dsarrfit_io.read_params(arrfit_out_str, fit_type, a_conv_factor) return fit_params
def _dsarrfit(temps, rate_constants, arr1_guess, arr2_guess, fit_type, dsarrfit_path, a_conv_factor): """ Routine calls the dsarrfit code to fit a set of rate constants to a single or double Arrhenius functional expression :param temps: temperatures :type temps: numpy.ndarray :param rate_constants: rate constants :type rate_constants: numpy.ndarray :param arr1_guess: A, n, Ea forr Arrhenius 1 :type arr1_guess: list(float) :param arr2_guess: A, n, Ea forr Arrhenius 2 :type arr2_guess: list(float) :param fit_type: var signaling for a single or double fit :type fit_type: str :param dsarrfit_path: path to run dsarrfit :type dsarrfit_path: str :param a_conv_factor: Conversion factor for A parameter :type a_conv_factor: float :return fit_params: fitting parameters for function :rtype: list(float) """ # Write the input file for the ratefit code ratefit_inp_str = dsarrfit_io.write_input(temps, rate_constants, fit_type=fit_type, arr1_guess=arr1_guess, arr2_guess=arr2_guess) dsarrfit_inp_file = os.path.join(dsarrfit_path, 'arrfit.dat') with open(dsarrfit_inp_file, 'w') as arrfit_infile: arrfit_infile.write(ratefit_inp_str) # Run the ratefit program dsarrfit_io.run_dsarrfit(dsarrfit_path) # Read the output of the single and double fit # if fit_type == 'single': # arrname = 'sgl_arrfit.out' # else: # arrname = 'dbl_arrfit.out' arrname = 'arrfit.out' dsarrfit_out_file = os.path.join(dsarrfit_path, arrname) if os.path.exists(dsarrfit_out_file): with open(dsarrfit_out_file, 'r') as arrfit_outfile: arrfit_out_str = arrfit_outfile.read() # Parse the ratefit files for the Arrhenius fit parameters fit_params = dsarrfit_io.read_params(arrfit_out_str, fit_type, a_conv_factor) else: fit_params = None return fit_params