Function Description
Initialize the package.
- class pecst.CalculatedRequirementsValues(requirement_c_min: float, i_rms: float, i_max: float)
Bases:
objectFrom input values calculated values or requirements.
- i_max: float
- i_rms: float
- requirement_c_min: float
- class pecst.CapacitanceTolerance(*values)
Bases:
IntEnumTypical capacitance tolerance values as enum.
- FivePercent = 5
- TenPercent = 10
- class pecst.CapacitorRequirements(maximum_peak_to_peak_voltage_ripple: float, current_waveform_for_op_max_current: ndarray, v_dc_for_op_max_voltage: float, temperature_ambient: float, voltage_safety_margin_percentage: float, capacitor_type_list: list[CapacitorType], maximum_number_series_capacitors: int, capacitor_tolerance_percent: CapacitanceTolerance, lifetime_h: float, results_directory: str)
Bases:
objectInput values and boundaries for the capacitor selection.
- capacitor_tolerance_percent: CapacitanceTolerance
- capacitor_type_list: list[CapacitorType]
- current_waveform_for_op_max_current: ndarray
- lifetime_h: float
- maximum_number_series_capacitors: int
- maximum_peak_to_peak_voltage_ripple: float
- results_directory: str
- temperature_ambient: float
- v_dc_for_op_max_voltage: float
- voltage_safety_margin_percentage: float
- class pecst.CapacitorType(*values)
Bases:
IntEnumEnum for the capacitor type.
- ElectrolyticCapacitor = 1
- FilmCapacitor = 0
- class pecst.IntEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
int,ReprEnumEnum where members are also (and must be) ints
- class pecst.LifetimeDerating(voltage: float, temperature: float, lifetime: DataFrame)
Bases:
objectClass to handle capacitor lifetime_h derating.
- lifetime: DataFrame
- temperature: float
- voltage: float
- pecst.calc_parallel_capacitors_dvdt(capacitance: float, rated_voltage: float, i_peak: float, dvdt_df: DataFrame, ordering_number: str, calculated_boundaries: CalculatedRequirementsValues) int
Calculate the number of parallel capacitors needed due to the maximum dv/dt requirement.
- Parameters:
capacitance (float) – capacitance in F
rated_voltage (float) – capacitors rated voltage in V
i_peak (float) – peak current of the capacitor bank
dvdt_df (pd.DataFrame) – dataframe with information about dv/dt limits
ordering_number (str) – capacitor ordering number
calculated_boundaries (CalculatedRequirementsValues) – Calculated boundaries
- Returns:
number of parallel capacitors needed due to dv/dt requirement
- Return type:
int
- pecst.calculate_from_requirements(capacitor_requirements: CapacitorRequirements, debug: bool = False) CalculatedRequirementsValues
Values and requirements for further calculations needed from the input values.
- Parameters:
capacitor_requirements (CapacitorRequirements) – capacitor requirements and input values in a DTO
debug (bool) – True to show debug plots
- Returns:
calculated requirements and values (from input parameters)
- Return type:
- pecst.cost_electrolytic_capacitor(voltage_rated: float, capacitance_rated: float) float
Calculate the cost in euro of a electrolytic capacitor.
- Parameters:
voltage_rated (float) – rated capacitor voltage in V
capacitance_rated (float) – rated capacitor capacitance in F
- Returns:
Cost of the capacitor
- Return type:
float
- pecst.cost_film_capacitor(voltage_rated: float, capacitance_rated: float) float
Calculate the cost in euro of a film capacitor.
- Parameters:
voltage_rated (float) – rated capacitor voltage in V
capacitance_rated (float) – rated capacitor capacitance in F
- Returns:
Cost of the capacitor
- Return type:
float
- pecst.current_capability_film_capacitor(order_number: str, frequency_list: list[float], current_amplitude_list: list[float], derating_factor: float) int
Film capacitor power loss estimation.
- Parameters:
order_number (str) – capacitor order number
frequency_list (list[float]) – frequency in Hertz in a list
current_amplitude_list (list[float]) – current in ampere in a list
derating_factor (float) – derating factor
- Returns:
number of parallel capacitors needed due to current limit
- Return type:
int
- pecst.dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.
- pecst.download_esr_csv_files(capacitor_series_name_list: list[str] = ['B3271*P', 'B3272*AGT', 'B3277*P']) None
Download ESR over frequency data from the manufacturers homepage.
- Parameters:
capacitor_series_name_list (list[str]) – list of capacitor series names to download
- pecst.fft(period_vector_t_i: ndarray, sample_factor: int = 1000, plot: str = 'no', mode: str = 'rad', f0: float | None = None, title: str = 'ffT', filter_type: str = 'factor', filter_value_factor: float = 0.01, filter_value_harmonic: int = 100, figure_size: tuple | None = None, figure_directory: str | None = None) ndarray
Calculate the FFT for a given input signal. Input signal is in vector format and should include one period.
Output vector includes only frequencies with amplitudes > 1% of input signal
- Minimal Example:
>>> import numpy as np >>> example_waveform = np.array([[0, 1.34, 3.14, 4.48, 6.28],[-175.69, 103.47, 175.69, -103.47,-175.69]]) >>> out = fft(example_waveform, plot='yes', mode='rad', f0=25000, title='ffT input current')
- Parameters:
period_vector_t_i (np.array) – numpy-array [[time-vector[,[current-vector]]. One period only
sample_factor (int) – f_sampling/f_period, defaults to 1000
plot (str) – insert anything else than “no” or ‘False’ to show a plot to visualize input and output
mode (str) – ‘rad’[default]: full period is 2*pi, ‘deg’: full period is 360°, ‘time’: time domain.
f0 (float) – fundamental frequency. Needs to be set in ‘rad’- or ‘deg’-mode
title (str) – plot window title, defaults to ‘ffT’
filter_type (str) – ‘factor’[default] or ‘harmonic’ or ‘disabled’.
filter_value_factor (float) – filters out amplitude-values below a certain factor of max. input amplitude. Should be 0…1, default to 0.01 (1%)
filter_value_harmonic (int) – filters out harmonics up to a certain number. Default value is 100. Note: count 1 is DC component, count 2 is the fundamental frequency
figure_directory (tuple) – full path with file extension
figure_size (tuple) – None for auto-fit; fig_size for matplotlib (width, length)
- Returns:
numpy-array [[frequency-vector],[amplitude-vector],[phase-vector]]
- Return type:
np.ndarray[list]
- pecst.filter_df(df: DataFrame, x: str = 'volume_total', y: str = 'power_loss_total', factor_min_dc_losses: float = 0.5, factor_max_dc_losses: float = 1000) DataFrame
Remove designs with too high losses compared to the minimum losses.
- Parameters:
df (pd.DataFrame) – pandas dataframe with study results
x (str) – x-value name for Pareto plot filtering
y (str) – y-value name for Pareto plot filtering
factor_min_dc_losses (float) – filter factor for the minimum dc losses
factor_max_dc_losses (float) – dc_max_loss = factor_max_dc_losses * min_available_dc_losses_in_pareto_front
- Returns:
pandas dataframe with Pareto front near points
- Return type:
pd.DataFrame
- pecst.get_equivalent_heat_coefficient(df: DataFrame, width: float, length: float, height: float) float
Read the thermal equivalent heat coefficient (from data sheet).
- Parameters:
df (pandas.DataFrame) – dataframe with equivalent self-heating coefficient based on the capacitor housing dimensions.
width (float) – capacitor width in meter
length (float) – capacitor length in meter
height (float) – capacitor height in meter
- Returns:
thermal equivalent coefficient
- Return type:
float
- pecst.get_str_value_from_str(text: str, start: str, end: str) str
Get string value between start and end from a given string.
- Parameters:
text (str) – text to find the values
start (str) – string in front of the string to return
end (str) – string directly after the string to return
- Returns:
string between start and end
- Return type:
str
- pecst.get_temperature_current_derating_factor(ambient_temperature: float, df_derating: DataFrame) float
Read the capacitors temperature derating factor from a look-up table (from data sheet).
- Parameters:
ambient_temperature (float) – ambient temperature in degree Celsius
df_derating (pd.DataFrame) – dataframe with temperature derating information
- Returns:
derating factor
- Return type:
float
- pecst.get_voltage_from_semilogx_lifetime(lifetime: float, lifetime_vec: Series, voltage_vec: Series) ndarray
Semilogarithmic interpolation from voltage over lifetime curve to get the maximum allowed voltage (to reach the lifetime).
close to: https://www.robsiegwart.com/interpolating-logarithmic-plots-for-fatigue-analysis.html :param lifetime: lifetime in hours :type lifetime: float :param lifetime_vec: vector lifetime :type lifetime_vec: pd.Series :param voltage_vec: vector voltage :type voltage_vec: pd.Series :return:
- pecst.global_plot_settings_font_latex() None
Set the plot fonts to LaTeX-font.
- pecst.global_plot_settings_font_sansserif() None
Set the plot fonts to Sans-Serif-Font.
- pecst.integrate(time: ndarray, data: ndarray) ndarray
Integrate a given time series.
- Parameters:
time (np.ndarray) – list of time
data (np.ndarray) – list of data
- class pecst.interp1d(x, y, kind='linear', axis=-1, copy=True, bounds_error=None, fill_value=nan, assume_sorted=False)
Bases:
_Interpolator1DInterpolate a 1-D function (legacy).
x and y are arrays of values used to approximate some function f:
y = f(x). This class returns a function whose call method uses interpolation to find the value of new points.- Parameters:
x ((npoints, ) array_like) – A 1-D array of real values.
y ((..., npoints, ...) array_like) – A N-D array of real values. The length of y along the interpolation axis must be equal to the length of x. Use the
axisparameter to select correct axis. Unlike other interpolators, the default interpolation axis is the last axis of y.kind (str or int, optional) – Specifies the kind of interpolation as a string or as an integer specifying the order of the spline interpolator to use. The string has to be one of ‘linear’, ‘nearest’, ‘nearest-up’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, or ‘next’. ‘zero’, ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of zeroth, first, second or third order; ‘previous’ and ‘next’ simply return the previous or next value of the point; ‘nearest-up’ and ‘nearest’ differ when interpolating half-integers (e.g. 0.5, 1.5) in that ‘nearest-up’ rounds up and ‘nearest’ rounds down. Default is ‘linear’.
axis (int, optional) – Axis in the
yarray corresponding to the x-coordinate values. Unlike other interpolators, defaults toaxis=-1.copy (bool, optional) – If
True, the class makes internal copies of x and y. IfFalse, references toxandyare used if possible. The default is to copy.bounds_error (bool, optional) – If True, a ValueError is raised any time interpolation is attempted on a value outside of the range of x (where extrapolation is necessary). If False, out of bounds values are assigned fill_value. By default, an error is raised unless
fill_value="extrapolate".fill_value (array-like or (array-like, array_like) or "extrapolate", optional) –
if a ndarray (or float), this value will be used to fill in for requested points outside of the data range. If not provided, then the default is NaN. The array-like must broadcast properly to the dimensions of the non-interpolation axes.
If a two-element tuple, then the first element is used as a fill value for
x_new < x[0]and the second element is used forx_new > x[-1]. Anything that is not a 2-element tuple (e.g., list or ndarray, regardless of shape) is taken to be a single array-like argument meant to be used for both bounds asbelow, above = fill_value, fill_value. Using a two-element tuple or ndarray requiresbounds_error=False.Added in version 0.17.0.
If “extrapolate”, then points outside the data range will be extrapolated.
Added in version 0.17.0.
assume_sorted (bool, optional) – If False, values of x can be in any order and they are sorted first. If True, x has to be an array of monotonically increasing values.
- fill_value
- __call__()
See also
splrep,splevUnivariateSplineAn object-oriented wrapper of the FITPACK routines.
interp2d2-D interpolation
Notes
Calling interp1d with NaNs present in input values results in undefined behaviour.
Input values x and y must be convertible to float values like int or float.
If the values in x are not unique, the resulting behavior is undefined and specific to the choice of kind, i.e., changing kind will change the behavior for duplicates.
Examples
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy import interpolate >>> x = np.arange(0, 10) >>> y = np.exp(-x/3.0) >>> f = interpolate.interp1d(x, y)
>>> xnew = np.arange(0, 9, 0.1) >>> ynew = f(xnew) # use interpolation function returned by `interp1d` >>> plt.plot(x, y, 'o', xnew, ynew, '-') >>> plt.show()
- dtype
- property fill_value
The fill value.
- pecst.load_dc_film_capacitors(capacitor_series_name: str) tuple[DataFrame, DataFrame, DataFrame, DataFrame, list[LifetimeDerating]]
Load dc film capacitors from the database.
- Parameters:
capacitor_series_name (str) – name of the capacitor series to download
- Returns:
unified list of film capacitors
- Return type:
tuple[pandas.DataFrame, pandas.DataFrame, pandas.DataFrame]
- pecst.power_loss_film_capacitor(order_number: str, frequency_list: list[float], current_amplitude_list: list[float], number_parallel_capacitors: int) float
Film capacitor power loss estimation.
- Parameters:
order_number (str) – capacitor order number
frequency_list (list[float]) – frequency in Hertz in a list
current_amplitude_list (list[float]) – current in ampere in a list
number_parallel_capacitors (int) – number of parallel capacitors to estimate the current per capacitor
- Returns:
loss of a single capacitor in Watt
- Return type:
float
- pecst.read_capacitor_frequency_dependent_limits(order_number: str) DataFrame
Read the frequency-dependent limits from csv file to a pandas data frame.
- This contains:
frequency-dependent equivalent series resistance (ESR)
frequency-dependent current capability
frequency-dependent AC RMS voltage
- Parameters:
order_number (str) – order number
- Returns:
frequency-dependent ESR, current capability and AC RMS voltage in a pandas data frame
- Return type:
pandas.DataFrame
- pecst.select_capacitors(c_requirements: CapacitorRequirements) tuple[list[str], list[DataFrame]]
Select suitable capacitors for the given application.
- Function works as a “big filter”:
reads in all available capacitor data depending on the given capacitor type
use series connection up to a maximum given number of capacitors to reach the operating voltage
adds parallel capacitors to reach the minimum required capacitance value
adds parallel capacitors to not raise the current limit per capacitor
considers current derating according to the ambient temperature
considers self-heating derating according to the ambient temperature
sort out non-working designs/construction (raising voltage limits, raising temperature limits)
The resulting pandas data frame contains the whole Pareto plane with all technically possible capacitor designs. Filtering e.g. for the Pareto front must be done in a separate step by the user.
- Parameters:
c_requirements (CapacitorRequirements) – capacitor requirements
- Returns:
pandas data frame with all possible capacitors.
- Return type:
pandas.DataFrame
- pecst.series_in_order_number(series_name: str, ordering_number: str) bool
Check for series name in ordering number.
- Parameters:
series_name (str) – capacitor series name
ordering_number (str) – capacitor ordering number
- Returns:
True if capacitor series name is in capacitor ordering number, else False
- Return type:
True
- pecst.update_font_size(font_size: int = 11) None
Update the figure font size.
- Parameters:
font_size (int) – font size
- pecst.voltage_rating_due_to_lifetime(target_lifetime: float, operating_temperature: float, voltage_rating: float, lt_dto_list: list[LifetimeDerating], is_debug: bool = False) float
Voltage dearting due to capacitor lifetime_h.
- Parameters:
target_lifetime (float) – capacitor target lifetime_h in hours
operating_temperature (float) – operating temperature in degree Celsius
voltage_rating (float) – capacitor operating voltage in V
lt_dto_list (list[LifetimeDerating]) – lifetime_h DTO list
is_debug (bool) – True to show interpolation plot
- Returns:
voltage
- Return type:
float