The following are30Code samples forscipy.log10()You can upvote the ones you like or downvote the ones you don't, and go back to the original project or source file by following the links above each example. You can also check all available functions/classes of the modulespy, or treatthe search function.
example 1
source file:ne.pyVonpychemqtconGNU General Public License v3.0 | 6wishes | ![]() ![]() |
def _visco0(self, rho, T, phase=None): a = [17,67484, -2,78751, 311498,7, -48826500, 3938774000, -1,654629e11, 2,86561e12] Tr = T/0,29944 y = 0,683]21*(a[ 0] + a[1]*log10(Tr) + a[2]/Tr**2 + a[3]/Tr**3 + a[4]/Tr**4 + a[5]/Tr **5 + a[6]/Tr**6) nt = 266,93*(T*self.M)**0,5/y om = rho/1673,0 c = [1,03010, -0,99175, 2,47127, -3,11864, 1,57066] b = [ 0,48148, -1,18732, 2,80277, -5,41058, 7,04779, -3,76608] summe1 = summe([ci*om**i für i, ci in enumerate(c. )]) summe2 = summe([bi*om **i für i , bi in enumerate(b)]) sigma = 3.05e-10*(sum1-sum2*log10(T/122.1)) br = 2.0/3.0* pi*Avogadro*sigma**3 brho = rho /self.M*1000*br d = [1, 0,27676, 0,014355, 2,6480, -1,9643, 0,89161] nd = sum([di*brho**i for i, di in enumerate (d) ] ) Rückgabeeinheiten Viskosität ( nd * nt / 100 , " mupas " )
Example #2
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 6wishes | ![]() ![]() |
def w_Korsten(Tb, Tc, Pc): """Calculation of the acentricity factor of the oil fractions with the correlation of Korsten (2000) Parameters ------------ Tb : float normal boiling temperature , [K ] Tc : float Critical Temperature, [K] Pc : Float Critical Pressure, [Pa] Returns ------- w: Float Acentric Factor, [-] """ tbr = Tb/Tc # Eq. 29 w = 0.5899 *tbr* *1.3/(1-tbr**1.3)*log10(PC/101325)-1. return {"w": units.Dimensionless(w)}
Example #3
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 6wishes | ![]() ![]() |
def Viscosity_ASTM(self, T, T1=units.Temperature(100, "F"), T2=units.Temperature(210, "F"), mu1=0, mu2=0): """Calculation of the kinematic viscosity any temperature, if two other viscosity values are known at other temperatures, API procedure 11A4.4, page 1063 Parameters: T: temperature at which the viscosity is to be calculated T1, T2: optional, temperature at which the viscosity is known mu1 ,mu2:optional, known viscosity values If the optional parameters are not supplied, the values at 100 and 210ºF are taken as """ if mu1==0: mu1=self.v100.cSt if mu2==0: mu2=self.v210 .cSt t=units.Temperature(T) Z1=mu1+0.7+exp(-1.47-1.84*mu1-0.51*mu1**2) Z2=mu2+0.7+exp(-1.47-1.84* mu2-0.51 * mu2**2) B=(log10(log10(Z1))-log10(log10(Z2)))/(log10(T1.R)-log10(T2.R)) Z=10**( 10** (log10(log10(Z1))+B*(log10(t.R)-log10(T1.R)))) return units. Diffusivity(Z-0.7-exp(-0.7487-3.295*(Z-0.7) +0.6119*(Z-0.7)**2-0.3191*(Z-0.7)**3), "cSt")
Example #4
source file:util.pyVonAzimuthcon"New" or "Revised" 3-Clause BSD License | 6wishes | ![]() ![]() |
def addqqplotinfo(qnull,M,xl='-log10(P) observed',yl='-log10(P) expected',xlim=None,ylim=None,alphalevel=0.05,legendlist=None,fixaxes=False): distr='log10' pl.plot([0,qnull.max()], [0,qnull.max()],'k') pl.ylabel(xl) pl.xlabel(yl) if xlim is not None is : pl.xlim(xlim) if ylim is not None: pl.ylim(ylim) if levelalpha is not None: if distr == 'log10': betaUp, betaDown, theoretical values = _qqplot_bar(M=M,alphalevel= alphalevel , .distr =distr) lower = -sp.log10(theoretical-betaValuesLower) upper = -sp.log10(theoretical+betaUpper) pl.fill_between(-sp.log10(theoreticalvalues),lower,upper,color="grey" , alpha=0.5 ) #pl.plot(-sp.log10(theoreticalPvals),lower,'g-.') #pl.plot(-sp.log10(theoreticalPvals),upper,'g-.') si legendlist is not None: leg = pl.legend(legendlist, loc=4, numpoints=1) # set the marker size for the legend in leg.legendHandles: lo.set_markersize(10) if fixaxes: fix_axes();
Example #5
source file:tdft.pyVonShazamconMY license | 5wishes | ![]() ![]() |
def tdft(audio, srate, windowsize, windowshift, fftsize): """Calculate the fast Fourier transform of the real value of an audio segment multiplied by a Hamming window. Then convert to decibels by multiplying by 20*log10. Repeat for all audio segments.""" windowamp = int(windowsize*srate) shift = int(windowshift*srate) window = scipy.hamming(windowsamp) spectrogram = scipy.array([20*scipy.log10(abs(np. fft .rfft(window*audio[i:i+windowsamp],fftsize))) for i in range(0, len(audio)-windowsamp, shift)]) returns the spectrogram
Example #6
source file:heat transfer.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def h_anulli_Turbulent(Re, Pr, a, dhL=0, border=0): """VDI Heat Atlas G2 Pag.703""" if border == 0: #heated inner surface Fann = 0.75*a** -0.17 elif limit == 1: #Outer surface heated Fann = (0.9-0.15*a**0.6) elif limit == 2: #Both surfaces heated Fann = (0.75*a**-0.17+(0.9- 0.15*a* *0, 6))/(1+a) Re_ = Re*((1+a**2)*log(a)+(1-a**2))/((1-a)* *2*log ( a)) Xann = (1.8*log10(Re_)-1.5)**-2 k1 = 1.07+900/Re-0.63/(1+10*Pr) Nu = Xann/8* Re*Pr/(k1+ 12.7 *(Xann/8)**0.5*(Pr**(2nd/3rd)-1))*(1+dhL**(2nd/3rd))* Fan return Nu
Example #7
source file:H2.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def _Sublimation_Pressure(cls, T): """Special Sublimation Pressure Correlation""" # Use decimal logarithm P = 10**(-43.39/T+2.5*log10(T)+2.047) return Units.Pressure(P , "mmHg")
Example #8
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Z_Brill_Beggs(Tr,Pr): """Gas compressibility factor calculation using Brill-Beggs (1974) correlation Parameters ------------ Tr : Float Reduced Temperature [-] Pr : Float Reduced Pressure [-] Returns ------- Z : Compressibility factor of suspension gas [-] Notes ----- Increase :class:`NotImplementedError` if the input pair is not in the limit: * 1.15 ≤ Tr ≤ 2.4 * 0.2 ≤ Pr ≤ 15 """ # Check input in valid range if Tr < 1.15 or Tr > 2.4 or Pr < 0.2 or Pr > 15: raise NotImplementedError("Incoming out of bounds" ) A = 1.39* (Tr-0.92 ) **0.5 - 0.36*Tr - 0.101 B = (0.62-0.23*Tr)*Pr + (0.066/(Tr-0.86)-0.037)*Pr* *2 + \ 0.32 /10**(9*(Tr - 1))*Pr**6 C = 0.132 - 0.32*log10(Tr) D = 10**(0.3016-0.49 *Tr+0.1824* Tr**2) Z = A + (1-A)/exp( B ) + C*Pr**D return units. dimensionless (Z)
Example #9
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def pb_Vazquez_Beggs(self, T, ts=350, ps=10): """Vazquez, M.E. and Beggs, H.D.: "Correlations for Fluid Physical Property Prediction", J.Pet. Tech. 970 """ t=units. Temperatur(T) ts=units.Temperature(ts) ps=units.Pressure(ps, "atm") if self.API<=30: C1, C2, C3=0.0362, 1.0937.000.25.724 sonst: C1, C2 , C3=0.0178, 1.187, 23.931 gravity_corr=self.gas.SG*(1.+5.912e-5*self.API*ts.F*log10(ps.psi/114.7)) Einheiten der Rendite. Druck((self.Rgo.ft3bbl/C1/gravity_corr/exp(C3*self.API/T.R))**(1./C2), "psi")
Example #10
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def pb_Kartoatmodjo_Schmidt(selbst, T, ts=350, ps=10): „““Kartoatmodjo, T. und Schmidt, Z.: „Large Data Bank Improves Crude Physical Property Correlations“, Oil and Gas J. (4. Juli 2010 ). 1994 ) 51-55""" t=units.Temperature(T) ts=units.Temperature(ts) ps=units.Pressure(ps, "atm") if self.API<=30: C1, C2, C3, C4 = 0,05958, 0,7972, 13,1405, 0,9986 plus: C1, C2, C3, C4 = 0,0315, 0,7587, 11,2895, 0,9143 Schwerkraftkorr = Eigengas.SG* (1+0,1595*Selbst.API**0,4078* ts.F* *-0.2506*log10(ps.psi/114.7)) Rückgabeeinheiten.Pressure((self.Rgo.ft3bbl/C1/gravity_corr**C2/ 10**(C3*self.API/t.R)) **C4, "psi")
Example #11
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def B_Vazquez_Beggs(selbst, T, ts=350, ps=10): „““Vázquez, M.E. and Beggs, H.D.: „Correlations for Fluid Physical Property Prediction“, J. Pet. Tech. (junio de 1980), 968- 970 """ t=Einheit.Temperatura(T) ts=Einheit.Temperatura(ts) ps=Einheit.Presión(ps, "atm") si self.API<=30: C1, C2, C3=4.667e-4 , 1.751e-5, -1.8106e-6 mehr: C1, C2, C3=4.67e-4, 1.1e-5, 1.337e-9 gravity_corr=self.gas.SG*(1.+5.912e-5* self .API*ts.F*log10(ps.psi/114.7)) volver 1.+C1*self.Rgo.ft3bbl+C2*(t.F-60)*self.API/gravity_corr+C3*self.Rgo.ft3bbl * (t.F-60)*self.API/gravity_corr
Example #12
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def B_Glaso(self, T): """Glaso, O.: "Generalized Pressure-Volume-Temperature Correlations", J. Pet. Tech. (May 1980), 785-795""" t=unidades.Temperature(T ) F=self.Rgo.ft3bbl(self.gas.SG/self.SG)**0.526*+0.968*t.F return 1.+10**(-6.58511+2.91329*log10(F)-0.27683*log10(F )**2)
Example #13
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def B_Kartoatmodjo_Schmidt(self, T, ts=350, ps=10): „““Kartoatmodjo, T. and Schmidt, Z.: „Large Data Bank Improves Crude Physical Property Correlations“, Oil and Gas J. (4. Juli 1994 ) 51-55""" t=units.Temperature(T) ts=units.Temperature(ts) ps=units.Pressure(ps, "atm") gravity_corr=self.gas.SG*(1+0.1595* self .API**0.4078*ts.F**-0.2506*log10(ps.psi/114.7)) F=self.Rgo.ft3bbl**0.755*gravity_corr**0.25*self.SG**-1.5+0.45* t.F gibt 0,98496+1e-4*F**1,5 zurück
Example #14
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Mu_Glass(self, T): """Glass, O.: "Generalized Pressure-Volume-Temperature Correlations", J. Pet. Tech. (Mai 1980), 785-795""" t=units.Temperature(T ) mu=3.141e10*t.F**-3.444*log10(self.API)**(10.313*log10(t.F)-36.447) Rückgabeeinheiten.Viskosität(mu, "cP");
Example #15
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Mu_Kartoatmodjo_Schmidt(self, T): """Kartoatmodjo, T. and Schmidt, Z.: "Large Data Bank Improves Crude Physical Property Correlations", Oil and Gas J. (4. Juli 1994) 51-55""" t =units.Temperature(T) mu=16e8*t.F**-2.8177*log10(self.API)**(5.7526*log10(t.F)-26.9718) Return units.Viscosity(mu, "cP");
Example #16
source file:crudo.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Viscosity_Carr_Kobayashi_Burrows(self, T): """Carr, N., R. Kobayashi y D. Burrows. "Viscosity of Hydrocarbon Gases under Pressure". Transacciones del AIME 201 (1954): 270–275.""" muo= 8.118e-3-6.15e-3*log10(self.SG)+(1.709e-5-2.062e-6*self.SG) *unidades.Temperature(T, "R").F muN2=self.N2 *(8,49e-3*log10(selbst.SG)+9,59e-3) muCO2=selbst.CO2*(9,08e-3*log10 (selbst.SG)+6,24e-3) muH2S=selbst.H2S*( 8.49e-3*log10(self.SG)+3.73e-3) unidades de retorno.Viscosidad(muo+muN2+muCO2+muH2S, "cP")
Example #17
source file:Grayson_Streed.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def _nio(self, T, P): """liquid volatility coefficient""" nio = [] for cmp in self.component: Tr = T/cmp.Tc Pr = P/cmp.Pc # parameters modified from [2 ]_ if cmp.id == 1: # Hydrogen A = [1.50709, 2.74283, -.0211, .00011, 0, .008585, 0, 0, 0, 0] elif cmp.id == 2: # Methane A = [ 1.36822, -1.54831, 0, 0.02889, -0.01076, 0.10486, -0.02529, 0, 0, 0] plus: A = [2.05135, -2 0.10899, 0, -0.19396, 0.02282, 0.08852, 08, -2 , -0.0 0.00353, 0.00203] # Equation 3 logn0 = A[0] + A[1]/Tr + A [ 2]*Tr + A[3]*Tr**2 + A[4]*Tr**3 + \ ( A[5]+A[6]*Tr+A[7]*Tr**2) * Pr + (A[8]+A[9]*Tr)*Pr**2 - log10(Pr ) # Equivalent 4 logn1 = -4.23893 + 8.65808*Tr - 1.2206/Tr - 3, 15224*Tr**3 - \ 0.025 *(Pr-0.6) # Eq 2 nio.append(10**(logn0 + cmp.f_acent_mod*logn1 )) # Correlation uses modified acentric factor table return nio
Example #18
source file:mezcla.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def _Pv(T, Tcm, Pcm, wm): """Pseudo-vapor pressure of pseudocritical properties for use in density correlations of compressed liquids Parameters ---------- T : Float temperature, [K] Tcm : Float pseudocritical temperature of Mixture, [K] Pcm : Float Pseudocritical pressure of the mixture, [Pa] wm : Float Acentric factor of the mixture, [-] Returns ------- Pbp : Float Point pressure Boiling point, [Pa] """ Trm = T/Tcm alpha = 35 - 36/Trm - 96.736*log10(Trm) + Trm**6 # Eq 22 beta = log10(Trm) + 0.03721754*alpha # Eq 23 Pro = 5.8031817* log10(Trm ) +0.07608141*alpha # Eq 20 # Using modified Aalto equation Eq 8 Pr1 = 4.86601*beta+0.03721754*alpha # Eq 21 Pbp = Pcm*10**(Pro+wm*Pr1 ) units of return.Pressure( Pbp )# liquid viscosity correlations
Example #19
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def prop_Standing(M,SG): """Calculation of the properties of the petroleum fractions with the correlations of Standing (1977) based on the graphical diagram of Mathews et al (1942) using molecular weight and specific gravity as parameters Input parameters -- - -- ------- M: float molecular weight, [-] SG: float specific gravity, [-] Returns ------- prop : dict A dict with the calculated properties: * Tc: critical temperature , [K] * Pc: Critical pressure, [atm] Examples -------- Example 2.3 from [9]_: Oil fraction with M=216 and SG=0.8605 >>> p = prop_Standing(216, 0.8605) > >> "%.1f %.0f" % (p["Tc"].R, p["Pc"].psi) '1269.3 270' """ Tc = 608 + 364*log10( M-71.2) + (2450*log10(M)-3800)*log10(SG) # Eq 25 Pc = 1188 - 431*log10(M-61.1) + (2319-852*log10(M-53 ,7 ))*(SG- 0.8) # Eq 26 prop = {} prop["M"] = Units.Dimensionless(M) prop["SG"] = Units.Dimensionless(SG) prop["Tc"] = Units. Temperature(Tc, "R ") prop["Pc"] = units.Pressure(Pc, "psi") prop return
Example #20
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def prop_Tsonopoulos(SG,Tb): """Calculation of properties of petroleum fractions with correlations according to Tsonopoulos (1990) using molecular weight and specific gravity as input parameters ---------- -- SG: Float Specific Gravity, [-] Tb: Float boiling point, [K] Returns ------- prop : dict A dict with the calculated properties: * Tc: Critical temperature, [K] * Pc : Critical pressure, [MPa] "" " # TODO: Find reference Tc = 10**(1.20016 - 0.61954*log10(Tb) + 0.48262*log10(SG) + 0.67365*log10(SG)**2) Pc = 10 ** (7.37498 - 2.15833*log10( Tb ) + 3.35417*log10(SG) + 5.64019*log10(SG)**2) prop = {} prop["Tb"] = units.Temp( Tb) prop["SG "] = units.Dimensionless(SG) prop ["Tc"] = units.Temperature(Tc) prop["Pc"] = units.Pressure(Pc, "bar") Return prop
Example #21
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def MuL_Singh(T, v100): """Calculation of the kinematic viscosity of low-pressure liquid petroleum fractions using the Singh correlation, which is also mentioned in API Procedure 11A4.1, p 1031. Parameters ------ ----- - T : Float Temperature, [K] v100 : Float Kinematic Viscosity at 100ºF, [cSt] Returns ------- v : Float Kinematic Viscosity at T, [cSt] Examples ---- - --- Example for [20 ]_, Sumatran Crude Oil at 210ºF >>> T = Units.Temperature(210, "F") >>> "%0.3f" % MuL_Singh(T, 1.38).cSt '0.705 ' """ # Convert inlet temperature to Rankine t_R = units. K2R(T) S = 0.28008*log10(v100) + 1.8616 B = log10(v100) + 0.86960 mu = 10**(B*(559.67/t_R)* *S - 0.86960 ) return units .Diffusivity(mu, "cSt")# component prediction
Example #22
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Pv_Maxwell_Bonnell(self, T, mod=False): """Maxwell, J.B. and Bonnell, L.S., Vapor Pressure Charts for Petroleum Engineers, Exxon Research and Engineering Company, Florham Park, NJ, 1955. Reimpreso en 1974". Desviación y Precision of a New Vapor Pressure Correlation for Petroleum Hydrocarbons", Industrial and Engineering Chemistry, Vol. 49, 1957, pp. 1187-1196. Modification of Tsonopoulos for coal liquids: Tsonopoulos, C., Heidman, J. L. and Hwang, S. -C., Propiedades termodinámicas y de transporte de líquidos de carbón, una monografía de Exxon, Wiley, Nueva York, 1986.""" if mod: if self.Tb<=366.5: F1=0 else: F1=- 1+ 0.009*(self.Tb-255.37) F2=(self.watson-12)-0.01304*(self.watson-12)**2 else: if self.Tb<367: F=0 elif self.Tb< 478: F=- 3.2985+0.0009*self.Tb else: F=-3.2985+0.009*self.Tb pvap=0. pvapcalc=1. while abs(pvap-pvapcalc)<1e-6: pvap=pvapcalc if mod: if pvap<=760: F3=1.47422*log10(pvap/760.) else: F3=1.47422*log10(pvap/760.)+1.190833 *(log10(pvap/760.))**2 DTb=F1*F2*F3 more: DTb=1.3889*F*(self.watson-12)*log10(pvap/760.) Tb_=self.Tb-DTb Q=(Tb_/T-0.00051606*Tb_)/(748.1-0.3861*Tb_) si Q>0.0022: pvapcalc=10**((3000.538*Q-6.76156)/(43*Q-0.987672)) elif Q>= 0.0013: pvapcalc=10**((2663.129*Q-5.994296)/(95.76*Q-0.972546)) else: pvapcalc=10**((2770.085*Q-6.412631)/(36*Q-0.989679)) returns Unidades back .Presión(pvapcalc, "mmHg")
Example #23
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Mu_Singh(self, T, mu): """Calculation of kinematic viscosity of petroleum fractions at low pressure, known kinematic viscosity at 100ºF, API Method 11A4.1 page 1054 mu: experimental kinematic viscosity value at 100ºF obtained in Centistokes """ t=units Temperature(T) S=0.28008*log10(mu)+1.8616 B=log10(mu)+0.86960 Returns 10**(B*(559.67/t.R) **S-0.86960)
Example #24
source file:petro.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def Viscosity_Index(self): """Viscosity Index Calculation Method, API Procedure 11A6.1, page 1083""" if self.v210.cSt>70: L=0.8353*self.v210.cSt**2+ 14.67*self .v210.cSt-216 H=0.1684*self.v210.cSt**2+11.85*self.v210.cSt-97 otherwise: #adaptation of the table data, generation of an own """polynomial adaptation of the data set: Table1_L, with the function : a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5 ----------- --- --- --- ------------------------------------------------------ ------ --- ------------------------------------------------------ ------ --- -------------- Chi^2/doF = 1.4854228443647e+00 R^2 = 0.9999990418201 Adjusted R^2 = 0.9999990229086 RMSE (Root Mean Square Error) = 1.218779243491 RSS (residual total number of squares) = 453.0539675312 ------------------------.- -------------- ----------------------------------- --------------------------- - ----------------------- ------- Polynomial fit of the dataset: Table1_H, using the function: a0 +a1*x +a2 *x^2+a3*x^3+a4*x^4+a5*x^5 ---- --------- ------------ - -- ----------------------------------------------- ------------------------------------------------- --- ------ Chi^2/doF = 1.7949865589785e-01 R^2 = 0.9999998895674 Adjusted R^2 = 0.9999988738781 RMSE (Root Mean Square Error) = 0.4236728170391 RSS (Residual Sum of Squares) = 54.747090 -----4884 -------------------------. ------------------------------------------------- - --- --------------------------------------------- - - ** 3+3.18417573 e-05*self.v210.cSt**4-1.8264076604682e-07*self.v210.cSt**5 H=-7.6607640162508+5.4845434135144*self.v210.cStv+0.cSt** 2 -2.6556039 e-03 *self.v210.cSt**3+5.1653200038471e-05*self.v210.cSt**4-2.3274903246922e-07*self.v210.cSt**5 if self.v100 .cSt> H :VI =(L -self.v100.cSt)/(L-H)*100 else: N=(log10(H)-log10(self.v100.cSt))/log10(self.v210.cSt);VI = ( 10 * * N - 1 ) / 0.00715 + 100 return VI
Example #25
source file:launisch.pyVonpychemqtconGNU General Public License v3.0 | 5wishes | ![]() ![]() |
def compute(config): fanning = config.getboolean("Moody", "fanning") method = config.getint("Moody", "method") eD = eval(config.get("Moody", "eD") ) F = f_list[method] dat = {} dat["fan"] = fan dat["method"] = method # Slice if fan: dat["slice"] = [16./R for R in Re_slice] x = 4 otherwise: dat["laminar"] = [64./R for R in Re_laminar] x = 1 # turbulent turb = {} for e in eD: turb[e] = [F(Rei, e)/x for Rei in Re_turbulent] dat["turbulent"] = turb # Line defining fully developed turbulent flow dat["fully"] = [(1/(1.14-2*log10(3500/R)))**2/x for R in Re_fully] # Save to file with open(conf_dir+"moody.dat", "w") as file: json.dump(dat, file, indent=4)
Example #26
source file:util.pyVonAzimuthcon"New" or "Revised" 3-Clause BSD License | 5wishes | ![]() ![]() |
def _qqplot_bar(M=1000000, alphalevel = 0.05,distr = 'log10'): ''' Calculate error bars for a QQ plot --------------------- - ---------------------------------------------- Contribution: - - ----------- ---------------------------------------------------- - ------------- M Number of points to calculate error bars Alpha level Significance level for error bars (default 0.05) Distribution space in which error bars are implemented Note: only log10 is implemented (default 'log10 ' ) ----------------------------------------- ------ - - ------------------- Return: ------------- -------- ------ - - ------------------------------------------ betaUp upper error bars betaDown lower error bars theoretical Pval's theoretical P-values under uniform --------------------------------- -------- -- ---- --------------------- ''' # assumes 'log10' mRange=10**(sp .arange(sp.log10(0.5 ) ,sp.log10(M-0.5)+0.1,0.1));#must be exp or 10**? numPts=length(mRange); betaalphaLevel=sp.zeros(numPts);#down on the chart betaOneMinusalphaLevel=sp.zeros(numPts);#up on the chart betaInvHalf=sp.zeros(numPts); for n in xrange(numPts): m=mRange[n]; #numlessThanThresh=m; betaInvHalf[n]=st.beta.ppf(0.5,m,M-m); betaalphaLevel[n]=st.beta.ppf(alphalevel,m,M-m); betaOneMinusalphaLevel[n]=st.beta.ppf(1-alphalevel,m,M-m); pass betaDown=betaInvHalf-betaalphaLevel; betaUp=betaOneMinusalphaLevel-betaInvHalf; ValuesTheoreticalValues=mArea/M; betaUp, betaDown, return theoretical values
Example #27
source file:Entropie.pyVonTrace of language changecon"New" or "Revised" 3-Clause BSD License | 5wishes | ![]() ![]() |
def get_base(unit='bit'): if unit == 'bit': log = sp.log2 elif unit == 'nat': log = sp.log elif unit in ('digit', 'dit'): log = sp.log10 else: Increase ValueError('The "unit" "%s" is not understood' % unit) return log
Example #28
source file:nichols.pyVonPython controlcon"New" or "Revised" 3-Clause BSD License | 4wishes | ![]() ![]() |
def nichols_plot(sys_list, omega=None, grid=None): """Nichols plot for a system Draws a Nichols plot for the system over a range of frequencies (optional). Parameters --------- - sys_list : list of LTIs, or LTI list of linear input/output systems (single system is ok) omega: array_like frequency range (list or bounds) in rad/s raster: boolean, optional true if graph is a Nichols graph raster should contain Default is True Returns ------- None """ # Get parameter values grid = config._get_param('nichols', 'grid', grid, True) # If the argument was a singleton, cast it to a List um if not getattr(sys_list, '__iter__', False): sys_list = (sys_list,) # Choose a default range if none is specified if omega is None: omega = default_frequency_range( sys_list) for sys in sys_list: # Get magnitude and phase from system mag_tmp, phase_tmp, omega = sys.freqresp(omeg a) mag = np.squeeze(mag_tmp) phase = np.squeeze(phase_tmp) # In Nicho convert ls plot format (phase to degrees, # and magnitude to dB) X = unwrap(sp.degrees(phase), 360) y = 20*sp.log10(mag) # generate plot plt.plot(x, y) plt.xlabel('Phase (degrees)') plt.ylabel(' Magnitude (dB)') plt.title('Nichols Plot ') # Plot point -180 plt.plot([-180], [0], 'r+') # add grid if grid: nichols_grid()
Example #29
source file:compuestos.pyVonpychemqtconGNU General Public License v3.0 | 4wishes | ![]() ![]() |
def RhoL_YamadaGunn(T, Tc, Pc, w, M): r"""Calculates the saturation liquid volume using the Gunn-Yamada correlation .. math:: V/V_sc = V_R^{(0)}\ left(1 - \ omega\delta\right) Parameters ---------- T : Float Temperature, [K] Tc : Float Critical Temperature, [K] Pc : Float Critical Pressure, [Pa] w : Float Acentric Factor , [ -] M : float molecular weight, [g/mol] Return ------- rhos : float density of the liquid, [kg/m³] Notes ----- The equation is defined in [ 27]_ related to the volume """ Tr = T/Tc when Tr < 0.8: # Eq 3 Vr = 0.33593-0.33953*Tr+1.51941*Tr**2-2.02512*Tr**3+ 1.11422*Tr**4 elif Tr < 1: # Eq 4 Vr = 1+1.3*(1-Tr)**0.5*log10(1-Tr)-0.50879*(1-Tr )-0.91534*(1-Tr)**2 elif Tr == 1: Vr = 1 # Eq. 5 d = 0.29607-0.09045*Tr-0.04842*Tr**2 Zsc = 0.292-0.0967*w # Eq. 7 Vsc = Zsc *R*Tc/Pc V = Vsc*Vr*(1- w*d ) # Eq 1 return units. Density (M/V, "gm3")
Example #30
source file:compuestos.pyVonpychemqtconGNU General Public License v3.0 | 4wishes | ![]() ![]() |
def prop_Edmister(**kwargs): """Compute the missing parameters between Tc, Pc, Tb and the acentric factor of the correlations by Edmister (1958) Parameters ------------ Tc : Float Temperature critical , [ºR] Pc : Float Critical Pressure, [psi] Tb : Float Boiling Temperature, [ºR] w : Float Acentric Factor, [-] Returns ------- prop : Dict with input parameter y missing parameter in input " "" available_count = 0 if "Tc" in kwargs and kwargs["Tc"]: available_count += 1 Tc = units.Temp(kwargs["Tc"]) else: unknown = "Tc" if "Pc" in kwargs and kwargs["Pc"]: available_count += 1 Pc = units.Pressure(kwargs["Pc"]) else: unknown = "Pc" if "Tb" in kwargs and kwargs["Tb"] : available_count += 1 Tb = units.Temp(kwargs["Tb"]) else: unknown = "Tb" if "w" in kwargs: available_count += 1 w = units.Dimensionless(kwargs["w"]) else : unknown = " w " if count_available != 3: Increase ValueError("Incorrect input variable entry") if unknown oce == "Tc": Tc = Units.Temp(Tb.R *(3*log10(Pc.psi)/7/(w+1)+1), "R") unknown elif == "Pc": Pc = units.pressure (10**(7/3.*( w+1)*(Tc.R/Tb.R-1)), "atm") unknown elif == "Tb": Tb = units. Temperature (Tb.R/(3*log10(Pc.atm)/7/(w+1 )+1), "R") unknown elif == "w": w = units. Dimensionless (3/7*log10 (Pc.atm)/(Tc.R/Tb.R-1)-1) prop = {} prop["Tc"] = Tc prop["Pc"] = Pc prop[" Tb"] = Tb prop[ "w"] = w returns prop