carbatpy.utils.curve_min_distance_finder ======================================== .. py:module:: carbatpy.utils.curve_min_distance_finder .. autoapi-nested-parse:: find the straight line which just touches a curve, while having the minimum area between the curves. 2024-02-11 part of carbatpy @author: atakan Attributes ---------- .. autoapisummary:: carbatpy.utils.curve_min_distance_finder.x_val Functions --------- .. autoapisummary:: carbatpy.utils.curve_min_distance_finder.straight_diff carbatpy.utils.curve_min_distance_finder.find_min_approach carbatpy.utils.curve_min_distance_finder.diff_mean Module Contents --------------- .. py:function:: straight_diff(param, values, below=True) Calculating the integral between a straight line and points from a curve the line is defined by the param values [slope,intercept], values[0,:] are the x values, values[1,:] are the y-values. below decides, whether the straight line should be below or not. This function is used for minimization. If the curves cross each other or if the line is on the wrong side, a large value is returned. :param param: [slope,intercept]. :type param: list of float :param values: values[0,:] are the x values, values[1,:] are the y-values. :type values: numpy.array [2,n_points] :param below: is the straight line below. The default is True. :type below: boolean, optional :returns: integral of the difference between the curves. :rtype: float .. py:function:: find_min_approach(values_in, below=True, delta=0) Finds a straight line which approaches a curve, without crossing. Mainly for finding the minimum approach of a fluid with phase change to a fluid with a constant heat capacity along heat transfer. One can select, whether the straight line should be *below* the curve or above. :param values: [0,n] are the x-values, [1,n] are the y-values. :type values: numpy array [2,n] :param below: should the straight line be below? The default is True. :type below: boolean, optional :param delta: wanted least distance between curves (absolute value.) :type delta: float, optional :returns: **output** -- keys are "success", "integral": the integral between curve and line, "line_par": slope and intercept of the line (np.array),"below":as above, "message": result.message from minimize}. :rtype: dictionary .. py:function:: diff_mean(high, low, dist_min=0.0, optimize=False) calculate the mean distance between two equally-spaced arrays In thermodynamics/heat exchangers for minimum approach temperature. The size of both arrays must be the same. If the curves cross, success will be False! :param high: the high values. :type high: numpy array (length m) :param low: the low values. :type low: numpy array(length m) :param dist_min: minimum required distnce, must be positive. The default is 0.. :type dist_min: float, optional :param optimize: if used for optimization. The default is False. :type optimize: boolean, optional :returns: for optimization the mean difference is returned, else a dictionary with success, mean-difference, all differences, dist_min. :rtype: dictionary or float .. py:data:: x_val