<commit_before>#!/usr/bin/python
# Filename: enclosureCalc.py
# Calculates inner volume of desired box and few additional parameters. 
# Uses International System of Units (SI)
# By <NAME>

import math

class driverManager:
    '''DriverManager encapsulates all the electrical variables of speaker driver entity. With these variables
    one can calculate response curves for different box/driver combinations.'''
    # Class variable. Names of all instances created from this class
    drivers = []
    
    def __init__(self,name):
        '''Defines all Thiele/small variables and sets them to zero.'''
        
        self.name = name
        
        # Small signal parameters
        self.Qts = 0            # Total Q of the driver at Fs 
        self.Qms = 0            # Mechanical Q of the driver at Fs
        self.Qes = 0            # Electrical Q of the driver at Fs
        self.Fs = 0             # Resonant frequency of the driver
        self.Vas = 0            # Equivalent Compliance Volume
        
        # Fundamental small signal mechanical parameters
        self.Sd = 0             # Projected area of the driver diaphragm, in square metres.
        self.Mms = 0            # Mass of the diaphragm/coil, including acoustic load, in kilograms.
        self.Cms = 0            # Compliance of the driver's suspension, in metres per newton (the reciprocal of its 'stiffness').
        self.Rms = 0            # The mechanical resistance of a driver's suspension (ie, 'lossiness') in N*s/m
        self.Re = 0             # DC resistance of the voice coil, measured in ohms.
        self.Le = 0             # Voice coil inductance measured in millihenries (mH) (Frequency dependent, usually measured at 1 kHz).
        self.Bl = 0             # The product of magnet field strength in the voice coil gap and the length of wire in the magnetic field, in tesla-metres (T*m).
        
        # Large signal parameters
        self.Xmax = 0           # Maximum linear peak excursion (in mm) of the cone.
        self.Xmech = 0          # Maximum physical excursion of the driver before physical damage.
        self.Sd = 0             # Peak displacement volume, calculated by Vd = Sd*Xmax
        self.Pe = 0             # Thermal power handling capacity of the driver, in watts.
        
        # Other parameters
        self.EBP = 0            # The efficiency bandwidth product, a rough indicator measure.
        self.N0 = 0             # The reference or "power available" efficiency of the driver, in percent.
        self.Sens = 0           # Sensitivity of the driver
        self.Zmax = 0           # The impedance of the driver at Fs, used when measuring Qes and Qms.
        self.Znom = 0           # The nominal impedance of the loudspeaker, typically 4, 8 or 16 ohms.
        
        print 'Creating driver instance: {0}'.format(self.name)
        driverManager.drivers.append(self.name)            
        
    def __del__(self):
        '''Deletes instance of driver from driver list '''
        print 'Deleting driver instance: {0}'.format(self.name)
        driverManager.drivers.remove(self.name)

    def __calculateN0(self):
        #self.N0 = DO THIS! 

    def __calculateEBP(self):
        self.EBP = self.Fs / self.Qes
        
    def __calculateZmax(self):
        self.Zmax = self.Re * (1 + self.Qms / self.Qes)

    def setQts(self, Qts):
        self.Qts = Qts

    def setQms(self, Qms):
        self.Qms = Qms

    def setQes(self, Qes):
        self.Qes = Qes

    def setFs(self, Fs):
        self.Fs = Fs

    def setVas(self, Vas):
        self.Vas = Vas
<commit_msg>Added calculator methods for small signal parameters.<commit_after>#!/usr/bin/python
# Filename: enclosureCalc.py
# Calculates inner volume of desired box and few additional parameters. 
# Uses International System of Units (SI)
# By <NAME>

import math

class driverManager:
    '''DriverManager encapsulates all the electrical variables of speaker driver entity. With these variables
    one can calculate response curves for different box/driver combinations.'''
    drivers = []    # Class variable. Names of all instances created from this class
    p = 1.184       # Density of air at 25C degree, in kg/m^3.
    c = 346.1       # Speed of sound, in m/s.
    
    def __init__(self,name):
        '''Defines all Thiele/small variables and sets them to zero.'''
        
        self.name = name
        
        # Small signal parameters
        self.Qts = 0            # Total Q of the driver at Fs 
        self.Qms = 0            # Mechanical Q of the driver at Fs
        self.Qes = 0            # Electrical Q of the driver at Fs
        self.Fs = 0             # Resonant frequency of the driver
        self.Vas = 0            # Equivalent Compliance Volume
        
        # Fundamental small signal mechanical parameters
        self.Sd = 0             # Projected area of the driver diaphragm, in square metres.
        self.Mms = 0            # Mass of the diaphragm/coil, including acoustic load, in kilograms.
        self.Cms = 0            # Compliance of the driver's suspension, in metres per newton (the reciprocal of its 'stiffness').
        self.Rms = 0            # The mechanical resistance of a driver's suspension (ie, 'lossiness') in N*s/m
        self.Re = 0             # DC resistance of the voice coil, measured in ohms.
        self.Le = 0             # Voice coil inductance measured in millihenries (mH) (Frequency dependent, usually measured at 1 kHz).
        self.Bl = 0             # The product of magnet field strength in the voice coil gap and the length of wire in the magnetic field, in tesla-metres (T*m).
        
        # Large signal parameters
        self.Xmax = 0           # Maximum linear peak excursion (in mm) of the cone.
        self.Xmech = 0          # Maximum physical excursion of the driver before physical damage.
        self.Sd = 0             # Peak displacement volume, calculated by Vd = Sd*Xmax
        self.Pe = 0             # Thermal power handling capacity of the driver, in watts.
        
        # Other parameters
        self.EBP = 0            # The efficiency bandwidth product, a rough indicator measure.
        self.N0 = 0             # The reference or "power available" efficiency of the driver, in percent.
        self.Sens = 0           # Sensitivity of the driver, in dB.
        self.Zmax = 0           # The impedance of the driver at Fs, used when measuring Qes and Qms.
        self.Znom = 0           # The nominal impedance of the loudspeaker, typically 4, 8 or 16 ohms.
        
        print 'Creating driver instance: {0}'.format(self.name)
        driverManager.drivers.append(self.name)            
        
    def __del__(self):
        '''Deletes instance of driver from driver list '''
        print 'Deleting driver instance: {0}'.format(self.name)
        driverManager.drivers.remove(self.name)

    def __calculateFs(self):
        self.Fs = 1 / ( 2 * math.pi * (self.Cms * self.Mms)**0.5 )

    def __calculateQes(self):
        self.Qes = (2 * math.pi * self.Fs * self.Mms * self.Re) / (self.Bl**2)

    def __calculateQms(self):
        self.Qms = (2 * math.pi * self.Fs * self.Mms) / self.Rms

    def __calculateQts(self):
        self.Qts = (self.Qms * self.Qes) / (self.Qms + self.Qes)

    def __calculateVas(self):
        self.Vas = p * c**2 * self.Sd**2 * self.Cms * 1000

    def __calculateN0(self):
        self.N0 = (p / 2*math.pi*c) * (( self.Bl**2 * self.Sd**2 ) / (self.Mms**2 * self.Re**2)) * 100  

    def __calculateEBP(self):
        self.EBP = self.Fs / self.Qes
        
    def __calculateZmax(self):
        self.Zmax = self.Re * (1 + self.Qms / self.Qes)

    def setQts(self, Qts):
        self.Qts = Qts

    def setQms(self, Qms):
        self.Qms = Qms

    def setQes(self, Qes):
        self.Qes = Qes

    def setFs(self, Fs):
        self.Fs = Fs

    def setVas(self, Vas):
        self.Vas = Vas

{'fraction_non_alphanumeric': 0.08265395710523016, 'fraction_numerical': 0.012040637150382541, 'mean_word_length': 1.9316176470588236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '571892', 'n_tokens_mistral': 2434, 'n_tokens_neox': 2237, 'n_words': 848}