carbatpy.utils.curve_min_distance_finder
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
Functions
|
Calculating the integral between a straight line and points from a curve |
|
Finds a straight line which approaches a curve, without crossing. |
|
calculate the mean distance between two equally-spaced arrays |
Module Contents
- carbatpy.utils.curve_min_distance_finder.straight_diff(param, values, below=True)[source]
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.
- Parameters:
param (list of float) – [slope,intercept].
values (numpy.array [2,n_points]) – values[0,:] are the x values, values[1,:] are the y-values.
below (boolean, optional) – is the straight line below. The default is True.
- Returns:
integral of the difference between the curves.
- Return type:
float
- carbatpy.utils.curve_min_distance_finder.find_min_approach(values_in, below=True, delta=0)[source]
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.
- Parameters:
values (numpy array [2,n]) – [0,n] are the x-values, [1,n] are the y-values.
below (boolean, optional) – should the straight line be below? The default is True.
delta (float, optional) – wanted least distance between curves (absolute value.)
- 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}.
- Return type:
dictionary
- carbatpy.utils.curve_min_distance_finder.diff_mean(high, low, dist_min=0.0, optimize=False)[source]
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!
- Parameters:
high (numpy array (length m)) – the high values.
low (numpy array(length m)) – the low values.
dist_min (float, optional) – minimum required distnce, must be positive. The default is 0..
optimize (boolean, optional) – if used for optimization. The default is False.
- Returns:
for optimization the mean difference is returned, else a dictionary with success, mean-difference, all differences, dist_min.
- Return type:
dictionary or float