How to use get_bo method in avocado

Best Python code snippet using avocado_python

vb_oil.py

Source:vb_oil.py Github

copy

Full Screen

1import numpy as np2import pandas as pd3import matplotlib.pyplot as plt4import seaborn as sns5sns.set() # probably not a best practice for a module - fix class call to sns.6class vb_oil:7 '''8 ...9 An instance of the vb_oil class represents a liquid that10 behaves as described by the Vasquez-Beggs Oil Correlation.11 ...12 Required Arguments:13 --------14 Yo : Oil Specific Gravity (degrees API)15 Yg : Gas Specific Gravity (decimal ratio)16 Rsi: Initial Solution Gas-Oil Ratio (SCF/STB)17 T : Temperature (degrees Fahrenheit)18 ...19 Methods20 --------21 get_Rs(P) : returns the solution gas-oil ratio of the fluid at a22 given pressure23 get_Pb() : returns the bubble-point pressure of the fluid based24 on fluid parameters entered as arguments in the class25 plot_Rs() : returns a chart showing solution gas-oil ratio behavior26 from pressure = 0 PSIG to pressure = 1.3 * Pb27 get_Bo(P) : returns the oil formation volume factor in Stocktank Barrels28 per Reservoir Barrel (STB/RB) at a given pressure29 plot_Bo() : returns a chart showing oil formation volume factor behavior30 from pressure = 0 PSIG to pressure = 1.3 * Pb31 summary() : returns a Pandas dataframe summarizing key fluid properties32 ...33 '''34 def __init__(self, Yo, Yg, Rsi, T):35 self.Yo = Yo36 self.Yg = Yg37 self.Rsi = Rsi38 self.T = T39 self.Pb = self.get_Pb()40 self.co = .000006 # for now...need to add a co function later41 def __repr__(self):42 return 'vb_oil({}, {}, {}, {})'.format(self.Yo, self.Yg, self.Rsi, self.T)43 def __str__(self):44 return 'Vasquez-Beggs Oil\n\45 Yo = {}\n\46 Yg = {}\n\47 Rsi = {}\n\48 T = {}'.format(self.Yo, self.Yg, self.Rsi, self.T)49 def get_Rs(self, P):50 if self.Yo > 30:51 c1 = .017852 c2 = 1.18753 c3 = 23.93154 else:55 c1 = .036256 c2 = 1.093757 c3 = 25.72458 if P > self.Pb:59 Rs = self.Rsi60 else:61 Rs = c1 * self.Yg * P**c2 * np.exp(c3 * (self.Yo / (self.T + 460)))62 return Rs63 def get_Pb(self):64 if self.Yo > 30:65 c1 = .017866 c2 = 1.18767 c3 = 23.93168 else:69 c1 = .036270 c2 = 1.093771 c3 = 25.72472 Pb = (self.Rsi / (c1 * self.Yg * np.exp(c3 * (self.Yo / (self.T + 460))))) ** (1 / c2)73 return Pb74 def plot_Rs(self):75 xs = np.linspace(0, self.Pb, 1000).tolist()76 ys = []77 for i in xs:78 ys.append(self.get_Rs(i))79 x2, x3 = self.Pb, 1.5 * self.Pb80 y2, y3 = self.get_Rs(x2), self.get_Rs(x3)81 xs.extend([x2, x3])82 ys.extend([y2, y3])83 plt.figure(figsize=(4,3))84 plt.plot(xs, ys)85 plt.ylim(None, 1.2 * y3)86 plt.xlabel('Pressure (PSI)')87 plt.ylabel('Rs');88 def get_Bo(self, P):89 if self.Yo > 30:90 c1 = 4.67e-491 c2 = 1.1e-592 c3 = 1.377e-993 else:94 c1 = 4.677e-495 c2 = 1.751e-596 c3 = -1.811e-897 Bob = 1 + c1 * self.get_Rs(self.Pb) + c2 * (self.T - 60) * (98 self.Yo / self.Yg) + c3 * self.get_Rs(self.Pb) * (self.T - 60) * (self.Yo / self.Yg)99 if P < self.Pb:100 Bo = 1 + c1 * self.get_Rs(P) + c2 * (self.T - 60) * (101 self.Yo / self.Yg) + c3 * self.get_Rs(P) * (self.T - 60) * (self.Yo / self.Yg)102 else:103 Bo = Bob * np.exp(self.co * (self.Pb - P))104 return Bo105 def plot_Bo(self):106 xs = []107 ys = []108 psubi = 0109 n = 1000110 for i in range(n):111 xs.append(psubi)112 ys.append(self.get_Bo(psubi))113 psubi = psubi + self.Pb * 1.5 / n114 plt.figure(figsize=(4,3))115 plt.plot(xs, ys);116 plt.xlabel('Pressure (PSI)')117 plt.ylabel('Oil FVF')118 plt.ylim(1,2)119 def summary(self):...

Full Screen

Full Screen

wandb_branin.py

Source:wandb_branin.py Github

copy

Full Screen

...36 'num_init': num_init,37 'ind_bo': ind_bo,38}39wandb.init(project='wandb-branin', entity='jungtaekkim', config=config)40def get_bo(str_fun, range_X, fun_target, num_iter, str_surrogate, str_cov, str_acq, str_initial_method_bo, str_optimizer_method_bo, num_samples_ao, normalize_Y):41 model_bo = BayesianOptimization(range_X, fun_target, num_iter,42 str_surrogate=str_surrogate,43 str_cov=str_cov,44 str_acq=str_acq,45 normalize_Y=normalize_Y,46 use_ard=True,47 str_initial_method_bo=str_initial_method_bo,48 str_sampling_method_ao='sobol',49 str_optimizer_method_gp='BFGS',50 str_optimizer_method_tp='SLSQP',51 str_optimizer_method_bo=str_optimizer_method_bo,52 str_mlm_method='regular',53 str_modelselection_method='ml',54 num_samples_ao=num_samples_ao,55 str_exp=str_fun,56 debug=False,57 )58 return model_bo59if __name__ == '__main__':60 seed = 4261 if str_fun == 'branin':62 obj_fun = Branin()63 else:64 raise ValueError()65 fun_target = obj_fun.output66 range_X = obj_fun.get_bounds()67 seed_ = seed * ind_bo + 10168 model_bo = get_bo(69 str_fun, 70 range_X, fun_target, num_iter,71 str_surrogate, str_cov, str_acq,72 str_initial_method, str_optimizer,73 num_samples_ao, normalize_Y74 )75 X = model_bo.model_bo.get_initials(str_initial_method, num_init, seed=seed_)76 Y = fun_target(X)77 times_overall = []78 times_surrogate = []79 times_acq = []80 ind_min = np.argmin(Y)81 wandb.log({82 'bx': X[ind_min],...

Full Screen

Full Screen

led.py

Source:led.py Github

copy

Full Screen

...14 def check(self):15 # check status, and activity, if dimming, or whatever, run that, return 1 if completed and status updated16 pass17 def update(self, show=False):18 self.strip.setPixelColor(self.place, self.form_color(self.r, self.g, self.b, self.get_bo()))19 if show:20 self.strip.show()21 def set_color(self, color, show=False):22 self.strip.setPixelColor(self.place, color)23 if show:24 self.strip.show()25 def dim_in(self):26 if self.dim_level >= 100:27 return self.dim_level28 def dim_out(self):29 if self.dim_level <= 0:30 return self.dim_level31 def get_bo(self):32 return int(self.brightness) * int(self.dim_level) / 10033 def form_color(self, r, g, b, bo):34 def form_value(loc):35 return int((bo if bo != -1 else int(self.brightness)) * int(loc) / 255)36 return Color(form_value(r), form_value(g), form_value(b))37 def form_color_from_status(self, status, brightness_override=-1):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful