def create_config(n_clicks, val, wellbore, section): if (val and wellbore and section): input_text = val input_text.strip() text = input_text.split() username = text[0][text[0].find('=') + 2:-1] apikey = text[1][text[1].find('=') + 2:-1] licenseguid = text[2][text[2].find('=') + 2:-1] session = openlab.http_client(username=username, apikey=apikey, licenseguid=licenseguid) with open(f'Configurations/{wellbore}_section_{section}.json', 'r') as f: data = json.load(f) new_config = session.create_configuration( f'{wellbore}_section_{section}', data['Data'])
import openlab #initiate http_client_session session = openlab.http_client() #get configuration data configs = session.configurations() #show all theconfigs and their simulations if they have any for config in configs: has_simulations = config["HasSimulations"] msg = "has" if has_simulations else "does not have" print("Configuration '{}' {} simulations".format(config["Name"],msg)) if has_simulations: simulations = session.configuration_simulations(config["ConfigurationID"]) #sort the simulations by update date sortedSimulations = sorted(simulations, key=lambda k:k['LastUpdatedDate'], reverse=True) for simulation in sortedSimulations: print("\tName: {:20}\tID: {:}\tLast Updated: {}\tCurrent Step: {}".format( simulation["Name"], simulation["SimulationID"], simulation["LastUpdatedDate"],simulation["CurrentStep"]))
""" A simple drilling simulation that increases the RPM by 20 every 30 steps """ import openlab import numpy config_name = "PUT CONFIGURATION NAME HERE" sim_name = "Simple Python Simulation" initial_bit_depth = 2500 client = openlab.http_client() sim = client.create_simulation(config_name, sim_name, initial_bit_depth) #this is how setpoints set. the sim.step() method handles getting the setpoints at every step sim.setpoints.RPM = 0 #Hz sim.setpoints.DesiredROP = 0.02 #m/s sim.setpoints.TopOfStringVelocity = 0.02 sim.setpoints.FlowRateIn = 2500 / 60000 #60000 is to convert m^3/s #number of steps to take maxSimulationSteps = 1000 #sweep Values rpmValues = numpy.arange( 20, 160, 20) #won't include the endpoint i.e. this will be 0 : 120 rpmStepDuration = 30 #seconds #"jsonify" the np.array rpmValuesList = rpmValues.tolist() rpmIndex = 0