def calculate_TorqueAndDrag(self): #self.v4TorqueDragForces_fields.MD.clear() self.v4TorqueDragForces_fields.Torque.clear() self.v4TorqueDragForces_fields.Drag_u.clear() self.v4TorqueDragForces_fields.Drag_s.clear() self.v4TorqueDragForces_fields.Drag_d.clear() self.v4TorqueDragForces_fields.uncTorque.clear() self.v4TorqueDragForces_fields.uncDrag_u.clear() self.v4TorqueDragForces_fields.uncDrag_s.clear() self.v4TorqueDragForces_fields.uncDrag_d.clear() self.v4Settings_fields.Psi.clear() self.v4Settings_fields.dMD.clear() #for field in self.v4Settings_fields[:5]: # value = self.s4Settings_tableWidget.item(field.pos,0).realValue # field.append( value ) #if len(self.v3WellboreInnerStageData): # msg = "Any inner wellbore stage completed. Can not proceed." # QMessageBox.critical(self.s4TorqueDragSideforce_tableWidget, 'Error', msg) # return K = list(mdl.get_sortedIndexes_of_wellboreInnerStageData(self)) K.reverse() set_initial_TDSConditions_to_fields( self, self.v3WellboreInnerStageData[K[0]]['PipeProps'].OD[0]) mdl.calculate_TDS(self) """
def set_initial_TDSConditions_to_fields(self, diameter): # Verify WOB, TOB, TAW if they are not filled set 0 if self.v4Settings_fields.WOB == []: mu.create_physicalValue_and_appendTo_field(0, self.v4Settings_fields.WOB) #self.v4Settings_fields.WOB.referenceUnitConvert() if self.v4Settings_fields.TOB == []: mu.create_physicalValue_and_appendTo_field(0, self.v4Settings_fields.TOB) #self.v4Settings_fields.TOB.referenceUnitConvert() if self.v4Settings_fields.TAW == []: mu.create_physicalValue_and_appendTo_field(0, self.v4Settings_fields.TAW) #self.v4Settings_fields.TAW.referenceUnitConvert() if self.v4Settings_fields.TrV == []: mu.create_physicalValue_and_appendTo_field(0, self.v4Settings_fields.TrV) #self.v4Settings_fields.TrV.referenceUnitConvert() if self.v4Settings_fields.RoR == []: mu.create_physicalValue_and_appendTo_field(0, self.v4Settings_fields.RoR) #self.v4Settings_fields.RoR.referenceUnitConvert() mdl.calculate_psiAngle(self, diameter) mdl.set_stepMD(self)
def save_file(self): print('---------------------------------------------------------') filename = QFileDialog.getSaveFileName( self.s1Info_tableWidget, 'Save File ...', self.v1WorkingDirectory + '/untitled.csf', 'Central-Soft File (*.csf)')[0] OBJ = {} for attrname in dir(self): if not re.match('v[1234]+', attrname): continue OBJ[attrname] = getattr(self, attrname) OBJ['v2SurveyTortuosity'] = self.s2SurveyTortuosity_checkBox.isChecked( ) with open(filename, 'wb') as File: mdl.save_obj(OBJ, File) print(OBJ) print(filename, ' saved!') print('---------------------------------------------------------')
def update_calculations(self): """ locations = self.ssCentralizerLocations_fields.hsMD SOatC_field = self.ssCentralizerLocations_fields.hsSOatC ClatC_field = self.ssCentralizerLocations_fields.hsClatC SOatM_field = self.ssCentralizerLocations_fields.hsSOatM ClatM_field = self.ssCentralizerLocations_fields.hsClatM mdl.calculate_standOff_atCentralizers(self, locations, SOatC_field, ClatC_field) mdl.calculate_standOff_atMidspan(self, locations, ClatC_field, SOatM_field, ClatM_field) locations = self.ssCentralizerLocations_fields.dsMD SOatC_field = self.ssCentralizerLocations_fields.dsSOatC ClatC_field = self.ssCentralizerLocations_fields.dsClatC SOatM_field = self.ssCentralizerLocations_fields.dsSOatM ClatM_field = self.ssCentralizerLocations_fields.dsClatM mdl.calculate_standOff_atCentralizers(self, locations, SOatC_field, ClatC_field) mdl.calculate_standOff_atMidspan(self, locations, ClatC_field, SOatM_field, ClatM_field) """ locations = self.ssCentralizerLocations_fields.MD SOatC_field = self.ssCentralizerLocations_fields.SOatC ClatC_field = self.ssCentralizerLocations_fields.ClatC SOatM_field = self.ssCentralizerLocations_fields.SOatM ClatM_field = self.ssCentralizerLocations_fields.ClatM LatC_field = self.ssCentralizerLocations_fields.LatC Inc_field = self.ssCentralizerLocations_fields.Inc mdl2.calculate_standOff_atCentralizers(self, locations, SOatC_field, ClatC_field, LatC_field) mdl2.calculate_standOff_atMidspan(self, locations, ClatC_field, SOatM_field, ClatM_field, Inc_field) for i in range(self.ssCentralizerLocations_tableWidget.rowCount()): try: item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.Inc.pos ) item.set_text( self.ssCentralizerLocations_fields.Inc[i] ) item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.SOatC.pos ) item.set_text( self.ssCentralizerLocations_fields.SOatC[i] ) item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.SOatM.pos ) item.set_text( self.ssCentralizerLocations_fields.SOatM[i] ) except IndexError: item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.Inc.pos ) item.set_text() item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.SOatC.pos ) item.set_text() item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.SOatM.pos ) item.set_text() self.meanSOatC = mu.np.round( mu.np.mean(SOatC_field), 1 ) self.meanSOatM = mu.np.round( mu.np.mean(SOatM_field), 1 ) self.ssMeanSOatC_label.setText( 'Mean SO at centralizers:\t{mSOatC} {unit}'.format( mSOatC=self.meanSOatC, unit=SOatC_field.unit ) ) self.ssMeanSOatM_label.setText( 'Mean SO at minspan:\t{mSOatM} {unit}'.format( mSOatM=self.meanSOatM, unit=SOatM_field.unit ) ) cu.idleFunction()
def setup_s2DataSurvey_tableWidget(self): self.v2DataSurvey_fields = mdl.get_v2DataSurvey_fields() self.v3Forces_fields = mdl.get_v3Forces_fields() for field in self.v2DataSurvey_fields: item = self.s2DataSurvey_tableWidget.horizontalHeaderItem( field.pos) item.setText(field.headerName) for i in range(self.s2DataSurvey_tableWidget.rowCount()): item = cu.TableWidgetFieldItem(field, i % 2 == 0) self.s2DataSurvey_tableWidget.setItem(i, field.pos, item)
def setup_s2KOP_tableWidget(self): self.v2KOP_fields = mdl.get_v2KOP_fields() item = self.s2KOP_tableWidget.verticalHeaderItem(0) item.setText(self.v2KOP_fields[0].headerName) item = cu.TableWidgetFieldItem(self.v2KOP_fields[0], True) self.s2KOP_tableWidget.setItem(0, 0, item)
def __init__s1Info_tableWidget(self): self.s1Info_tableWidget.parent = self self.s1Info_tableWidget.setContextMenuPolicy(Qt.ActionsContextMenu) C = cu.CopySelectedCells_action(self.s1Info_tableWidget) self.s1Info_tableWidget.addAction(C) V = cu.PasteToCells_action(self.s1Info_tableWidget) self.s1Info_tableWidget.addAction(V) self.v1Info_fields = mdl.get_v1Info_fields() item = cu.TableWidgetFieldItem(self.v1Info_fields[0], False) self.s1Info_tableWidget.setItem(0, 0, item) item = cu.TableWidgetFieldItem(self.v1Info_fields[1], False) self.s1Info_tableWidget.setItem(1, 0, item) item = cu.TableWidgetFieldItem(self.v1Info_fields[2], False) self.s1Info_tableWidget.setItem(2, 0, item) item = cu.TableWidgetFieldItem(self.v1Info_fields[3], False) self.s1Info_tableWidget.setItem(3, 0, item) item = cu.TableWidgetFieldItem(self.v1Info_fields[4], False) self.s1Info_tableWidget.setItem(4, 0, item) item = cu.TableWidgetFieldItem(self.v1Info_fields[5], False) self.s1Info_tableWidget.setItem(5, 0, item) select_row = lambda r, c: cu.select_tableWidgetRow( self.s1Info_tableWidget, r) def update_fieldItem(item): value = cu.mdl.physicalValue(item.text(), '') call = lambda: item.field.put(0, value) cu.update_fieldItem(item, call) self.s1Info_tableWidget.cellPressed.connect(select_row) self.s1Info_tableWidget.itemChanged.connect(update_fieldItem)
def select_innerStageRow_and_prepare_innerStageObjects(self, row): self.currentWellboreInnerStageDataItem = None cu.select_tableWidgetRow(self.s3WellboreInnerStages_tableWidget, row) #self.s3InnerStageToolkit_tabWidget.setEnabled(False) clear_wellboreInnerStageToolkit(self) if row in self.v3WellboreInnerStageData: self.currentWellboreInnerStageDataItem = self.v3WellboreInnerStageData[ row] load_wellboreInnerStageToolkit(self, self.v3WellboreInnerStageData[row]) else: self.v3WellboreInnerStageData[row] = mdl.WellboreInnerStageDataItem( row) self.currentWellboreInnerStageDataItem = self.v3WellboreInnerStageData[ row] save_information(self, row) try: stageLabel = self.currentWellboreInnerStageDataItem['Centralization'][ 'Ensemble']['label'] except (KeyError, TypeError): stageLabel = '=\n|\n|\n|\n=' self.s3StageEnsemble_label.setText(stageLabel) self.s3StageNumber_label1.setText(f"STAGE {row+1}") self.s3StageNumber_label2.setText(f"STAGE {row+1}") cu.idleFunction() print_wellboreInnerStageData(self)
def setup_s4Settings_tableWidget(self): self.v4Settings_fields = mdl.get_v4Settings_fields() for field in self.v4Settings_fields[:5]: item = QTableWidgetItem() self.s4Settings_tableWidget.setVerticalHeaderItem(field.pos, item) item.setText(cu.extend_text(field.headerName, 40)) item = cu.TableWidgetFieldItem(field, False) self.s4Settings_tableWidget.setItem(field.pos, 0, item)
def __init__s3CentralizerLocation_tableWidgets(self): self.v3CentralizerLocation_fields_A = mdl.get_v3CentralizerLocation_fields( ) self.s3CentralizerLocation_tableWidget_A.parent = self wf.init_s3CentralizerLocation_tableWidget(self, 'A') #wf.setup2_s3CentralizerLocation_tableWidget(self, 'A') self.v3CentralizerLocation_fields_B = mdl.get_v3CentralizerLocation_fields( ) self.s3CentralizerLocation_tableWidget_B.parent = self wf.init_s3CentralizerLocation_tableWidget(self, 'B') #wf.setup2_s3CentralizerLocation_tableWidget(self, 'B') self.v3CentralizerLocation_fields_C = mdl.get_v3CentralizerLocation_fields( ) self.s3CentralizerLocation_tableWidget_C.parent = self wf.init_s3CentralizerLocation_tableWidget(self, 'C')
def print_wellboreOuterStageData(self): print('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv') K = mdl.get_sortedIndexes_of_wellboreOuterStageData(self) #K = self.v3WellboreOuterStageData.keys() #K.sort() for k in K: print('\n', self.v3WellboreOuterStageData[k], '\n') print('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n') pass
def adjust_ID(self): OD = self.s3PipeProperties_tableWidget.item( self.v3PipeProperties_fields.OD.pos, 0).realValue ID = self.s3PipeProperties_tableWidget.item( self.v3PipeProperties_fields.ID.pos, 0).realValue Wt = self.s3PipeProperties_tableWidget.item( self.v3PipeProperties_fields.PipeW.pos, 0).realValue ID = mdl.adjust_ID(OD, ID, Wt) self.s3PipeProperties_tableWidget.item(self.v3PipeProperties_fields.ID.pos, 0).set_text(ID)
def setup_s3PipeProperties_tableWidget(self): self.v3PipeProperties_fields = mdl.get_v3PipeProperties_fields() for field in self.v3PipeProperties_fields: item = QTableWidgetItem() self.s3PipeProperties_tableWidget.setVerticalHeaderItem( field.pos, item) item.setText(cu.extend_text(field.headerName, 30)) item = cu.TableWidgetFieldItem(field, False) self.s3PipeProperties_tableWidget.setItem(field.pos, 0, item)
def select_outerStageRow_and_prepare_outerStageObjects(self, row): self.currentWellboreOuterStageDataItem = None cu.select_tableWidgetRow(self.s3WellboreOuterStages_tableWidget, row) if not row in self.v3WellboreOuterStageData: self.v3WellboreOuterStageData[row] = mdl.WellboreOuterStageDataItem( row) self.currentWellboreOuterStageDataItem = self.v3WellboreOuterStageData[row] print_wellboreOuterStageData(self)
def put_location_to_CentralizationFields(self, pos, MD): MD = mu.physicalValue( MD, self.lsCentralization_fields.MD.unit ) innerStage = mdl.get_innerStage_at_MD(self.parent, MD) if not innerStage['Centralization']['Mode']: return False outerStage = mdl.get_outerStage_at_MD(self.parent, MD) Inc, Azi = mdl.get_ASCIncAzi_from_MD(self.parent, MD) EW,NS,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MD) DL = mdl.get_ASCDogleg_from_MD(self.parent, MD) ID = mdl.get_wellboreID_at_MD(self.parent, MD) avgID = outerStage['WellboreProps'].ID[0] row = mu.physicalValue(innerStage['row'],None) self.lsCentralization_fields.MD.put( pos, MD ) self.lsCentralization_fields.Inc.put( pos, Inc ) self.lsCentralization_fields.Azi.put( pos, Azi ) self.lsCentralization_fields.EW.put( pos, EW ) self.lsCentralization_fields.NS.put( pos, NS ) self.lsCentralization_fields.TVD.put( pos, VD ) self.lsCentralization_fields.HD.put( pos, HD ) self.lsCentralization_fields.DL.put( pos, DL ) self.lsCentralization_fields.ID.put( pos, ID ) self.lsCentralization_fields.avgID.put( pos, avgID ) self.lsCentralization_fields.Stage.put( pos, row ) return True
def setup_s3WellboreOuterStages_tableWidget(self): self.v3WellboreOuterStages_fields = mdl.get_v3WellboreOuterStages_fields( ) for field in self.v3WellboreOuterStages_fields: item = self.s3WellboreOuterStages_tableWidget.horizontalHeaderItem( field.pos) item.setText(field.headerName) for i in range(self.s3WellboreOuterStages_tableWidget.rowCount()): item = cu.TableWidgetFieldItem(field, i % 2 == 0) self.s3WellboreOuterStages_tableWidget.setItem( i, field.pos, item)
def update_wellboreOuterStageData(self): if self.wellboreOuterStageDataIsUpdatable: self.currentWellboreOuterStageDataItem['WellboreProps'] = None self.v3WellboreOuterStages_fields.clear_content() row = self.s3WellboreOuterStages_tableWidget.selectedRow for field in self.v3WellboreOuterStages_fields: item = self.s3WellboreOuterStages_tableWidget.item(row, field.pos) field.append(item.realValue) self.currentWellboreOuterStageDataItem[ 'WellboreProps'] = copy.deepcopy(self.v3WellboreOuterStages_fields) workWellbore_exist = False K = mdl.get_sortedIndexes_of_wellboreOuterStageData(self) #K = list(self.v3WellboreOuterStageData.keys()) #K.sort() for k in K: stage = self.v3WellboreOuterStageData[k] if stage['CaliperData'] != None: MD = stage['CaliperData']['MD_array'] ID = stage['CaliperData']['CALmax_array'] elif stage['WellboreProps'] != None: MD = cu.mdl.array([ stage['WellboreProps'].MDtop[0], stage['WellboreProps'].MDbot[0] ]) ID = cu.mdl.array([ stage['WellboreProps'].DriftID[0], stage['WellboreProps'].DriftID[0] ]) else: del self.v3WellboreOuterStageData[k] MD = cu.mdl.array([]) ID = cu.mdl.array([]) if workWellbore_exist: self.v3WorkWellboreMD = mdl.np.hstack( (self.v3WorkWellboreMD, MD)) self.v3WorkWellboreID = mdl.np.hstack( (self.v3WorkWellboreID, ID)) else: self.v3WorkWellboreMD = MD self.v3WorkWellboreID = ID workWellbore_exist = True
def setup_s3WellboreInnerStages_tableWidget(self): self.v3WellboreInnerStages_fields = mdl.get_v3WellboreInnerStages_fields( ) for size, field in zip([40, 20, 20], self.v3WellboreInnerStages_fields): item = self.s3WellboreInnerStages_tableWidget.horizontalHeaderItem( field.pos) item.setText(cu.extend_text(field.headerName, size, mode='center')) for i in range(self.s3WellboreInnerStages_tableWidget.rowCount()): item = cu.TableWidgetFieldItem(field, i % 2 == 0) self.s3WellboreInnerStages_tableWidget.setItem( i, field.pos, item)
def setup_s4TorqueDragSideforce_tableWidget(self): self.v4TorqueDragForces_fields = mdl.get_v4TorqueDragForces_fields() for size, field in zip([20, 20, 20, 20, 20, 20, 20], self.v4TorqueDragForces_fields[:7]): item = self.s4TorqueDragSideforce_tableWidget.horizontalHeaderItem( field.pos) item.setText(cu.extend_text(field.headerName, size, mode='center')) for i in range(self.s4TorqueDragSideforce_tableWidget.rowCount()): item = cu.TableWidgetFieldItem(field, i % 2 == 0) self.s4TorqueDragSideforce_tableWidget.setItem( i, field.pos, item)
def set_workUnits_as(self, unitSystem): self.v1UnitSystem = unitSystem mdl.set_workUnits_as(unitSystem) self.v3WellboreInnerStageData = {} self.v3WellboreOuterStageData = {} self.wellboreOuterStageDataIsUpdatable = False self.wellboreInnerStageDataIsUpdatable = False self.wellboreInnerStageDataIsEnabled = False self._PipeCentralizationStageAdjusting_isEnabled = False self.setup_s2DataSurvey_tableWidget() self.setup_s2KOP_tableWidget() self.setup_s2SurveyTortuosity_tableWidget() self.setup_s2TortuosityInterval_tableWidget() self.setup_s3WellboreOuterStages_tableWidget() self.setup_s3WellboreInnerStages_tableWidget() #self.setup_s3CentralizerSpacing_tableWidget() self.setup_s3PipeProperties_tableWidget() wf.setup_s3CentralizerProperties_tableWidget(self, 'A') wf.setup_s3CentralizerProperties_tableWidget(self, 'B') wf.setup_s3CentralizerProperties_tableWidget(self, 'C') #wf.setup_s3CentralizerRunningForce_tableWidget(self,'A') #wf.setup_s3CentralizerRunningForce_tableWidget(self,'B') #wf.setup_s3CentralizerRunningForce_tableWidget(self,'C') wf.setup_s3CentralizerLocation_tableWidget(self, 'A') wf.setup_s3CentralizerLocation_tableWidget(self, 'B') wf.setup_s3CentralizerLocation_tableWidget(self, 'C') self.setup_s4Settings_tableWidget() self.setup_s4TorqueDragSideforce_tableWidget() self.wellboreOuterStageDataIsUpdatable = True self.wellboreInnerStageDataIsUpdatable = True self.wellboreInnerStageDataIsEnabled = True self._PipeCentralizationStageAdjusting_isEnabled = True
def cat_locations(self): self.lsCentralization_fields.clear_content() K = mdl.get_sortedIndexes_of_wellboreInnerStageData(self.parent) for k in K: stage = self.parent.v3WellboreInnerStageData[k] fields = stage['Centralization']['Fields'] if fields==None: continue goodstage = stage rows = [mu.physicalValue(stage['row'],None) for md in fields.MD] self.lsCentralization_fields.MD.extend( fields.MD ) self.lsCentralization_fields.Inc.extend( fields.Inc ) self.lsCentralization_fields.Azi.extend( fields.Azi ) self.lsCentralization_fields.EW.extend( fields.EW ) self.lsCentralization_fields.NS.extend( fields.NS ) self.lsCentralization_fields.TVD.extend( fields.TVD ) self.lsCentralization_fields.HD.extend( fields.HD ) self.lsCentralization_fields.DL.extend( fields.DL ) self.lsCentralization_fields.ID.extend( fields.ID ) self.lsCentralization_fields.avgID.extend( fields.avgID ) self.lsCentralization_fields.Stage.extend( rows ) PL = mu.unitConvert_value( 480, 'in', self.lsCentralization_fields.MD.unit ) CEL = goodstage['Centralization']['Ensemble']['PLfactor']*PL*0.9 if self.lsCentralization_fields.MD[-1] + CEL > stage['MDbot']: self.lsCentralization_fields.MD.pop() self.lsCentralization_fields.Inc.pop() self.lsCentralization_fields.Azi.pop() self.lsCentralization_fields.EW.pop() self.lsCentralization_fields.NS.pop() self.lsCentralization_fields.TVD.pop() self.lsCentralization_fields.HD.pop() self.lsCentralization_fields.DL.pop() self.lsCentralization_fields.ID.pop() self.lsCentralization_fields.avgID.pop() self.lsCentralization_fields.Stage.pop() return len(K)
def get_LASMDandCALID_intoInterval(self): MD = self.parent.v3WorkWellboreMD ID = self.parent.v3WorkWellboreID try: min_index = np.where(MD <= self.min_MD)[0][-1] except IndexError: min_index = 0 try: max_index = np.where(MD >= self.max_MD)[0][0] + 1 except IndexError: max_index = len(MD) MD = MD[min_index:max_index] ID = ID[min_index:max_index] ID[0] = (ID[0] - ID[1]) / (MD[0] - MD[1]) * (self.min_MD - MD[1]) + ID[1] ID[-1] = (ID[-1] - ID[-2]) / (MD[-1] - MD[-2]) * (self.max_MD - MD[-2]) + ID[-2] lim_ID = np.max(ID) * 1.2 MD[0] = self.min_MD MD[-1] = self.max_MD K = mdl.get_sortedIndexes_of_wellboreOuterStageData(self.parent) #K = list(self.parent.wellboreOuterStageData.keys()) #K.sort() mean_ID = [] for md in MD: for k in K: stage = self.parent.wellboreOuterStageData[k] if md >= stage['WellboreProps'].MDtop and md <= stage[ 'WellboreProps'].MDbot: mean_ID.append(stage['WellboreProps'].ID[0]) break mean_ID = np.array(mean_ID) return MD, ID, mean_ID, lim_ID
def __init__(self, dialog, parent): Ui_SpacingSetup.__init__(self) zp = pu.ZoomPan() self.setupUi(dialog) self.dialog = dialog self.parent = parent self.centralizerCount = 0 self.ssAccept_pushButton.clicked.connect( self.makeResults_and_done ) self.ssNextSpacing_fields = mdl.get_ssNextSpacing_fields() self.ssCentralizerLocations_fields = mdl.get_ssCentralizerLocations_fields() #mdl.calculate_axialForce_field(self) self.__init__ssCentralizerLocations_tableWidget() self.__init__ssNextSpacing_tableWidget() self.stage = parent.currentWellboreInnerStageDataItem self.max_MD = self.stage['MD'] self.min_MD = self.max_MD-self.stage['Length'] self.IPOD = self.stage['PipeProps'].OD[0] self.centralizers = copy.deepcopy(self.stage['Centralization']) del self.centralizers['Mode'] del self.centralizers['Fields'] MD, ID, mean_ID, lim_ID = mdl.get_LASMDandCALID_intoInterval(self) self.MD = MD self.ID = ID self.mean_ID = mean_ID #------------------------------------------------- self.ssCaliperMap_graphicsView.axes.set_position([0.2,0.15,0.75,0.8]) self.ssCaliperMap_graphicsView_ylimits = [None,None] self.ssCaliperMap_graphicsView_yselection = [] self.ssSOVisualization_graphicsView.axes.set_position([0.2,0.15,0.75,0.8]) self.ssSOVisualization_graphicsView_ylimits = [None,None] self.ssSOVisualization_graphicsView_yselection = [] zp.zoomYD_factory( (self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes), (self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits) ) zp.panYD_factory( (self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes), (self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits), (self.ssCaliperMap_graphicsView_yselection, self.ssSOVisualization_graphicsView_yselection), ypressfunction1=self.highlight_MDlocation, ypressfunction3=self.choose_MDlocation ) self.ssCaliperMap_graphicsView.axes.clear() self.ssSOVisualization_graphicsView.axes.clear() #------------------------------------------------- self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -ID, +ID, alpha=0.5, color='C0') factors = mu.np.linspace(1,2,11) for factor in factors[1:]: IPOD = self.IPOD*factor self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, +IPOD, +ID, where=IPOD<ID, alpha=0.05, color='C3') self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -IPOD, -ID, where=IPOD<ID, alpha=0.05, color='C3') self.ssCaliperMap_graphicsView.axes.plot( [ -self.IPOD, -self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 ) self.ssCaliperMap_graphicsView.axes.plot( [ +self.IPOD, +self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 ) MDHeaderName = self.ssCentralizerLocations_fields.MD.headerName IDHeaderName = self.ssCentralizerLocations_fields.ID.headerName self.ssCaliperMap_graphicsView.axes.set_xlabel( IDHeaderName ) self.ssCaliperMap_graphicsView.axes.set_ylabel( MDHeaderName ) self.ssCaliperMap_graphicsView.axes.set_xlim( -lim_ID, lim_ID ) self.ssCaliperMap_graphicsView.axes.set_ylim( self.max_MD, self.min_MD ) self.ssCaliperMap_graphicsView.draw() #------------------------------------------------- SOHeaderName = self.ssCentralizerLocations_fields.SOatC.headerName +' & '+ self.ssCentralizerLocations_fields.SOatM.headerName if self.ssCentralizerLocations_fields.SOatC.unit=='%': self.max_SO = 100 self.min_SO = 67 self.ΔSO = 10 elif self.ssCentralizerLocations_fields.SOatC.unit=='1': self.max_SO = 1 self.min_SO = 0.67 self.ΔSO = 0.1 self.ssSOVisualization_graphicsView.axes.set_xlabel( SOHeaderName ) self.ssSOVisualization_graphicsView.axes.set_ylabel( MDHeaderName ) self.ssSOVisualization_graphicsView.axes.set_xlim( -self.ΔSO, self.max_SO+self.ΔSO ) self.ssSOVisualization_graphicsView.axes.set_ylim( self.max_MD, self.min_MD ) #self.ssSOVisualization_graphicsView.axes.grid() self.ssSOVisualization_graphicsView.axes.plot( [self.min_SO, self.min_SO], [self.max_MD, self.min_MD], 'C3--', lw=2 ) self.ssSOVisualization_graphicsView.axes.plot( [0, 0], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 ) self.ssSOVisualization_graphicsView.axes.plot( [self.max_SO, self.max_SO], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 ) self.ssSOVisualization_graphicsView.draw() #------------------------------------------------- min_EW,min_NS,min_VD,min_index = mdl2.get_ASCCoordinates_from_MD(parent, self.min_MD, unit=parent.s2DataSurvey_fields.MD.unit) max_EW,max_NS,max_VD,max_index = mdl2.get_ASCCoordinates_from_MD(parent, self.max_MD, unit=parent.s2DataSurvey_fields.MD.unit) EW = parent.s2DataSurvey_fields.EW[min_index:max_index+1] NS = parent.s2DataSurvey_fields.NS[min_index:max_index+1] VD = parent.s2DataSurvey_fields.TVD[min_index:max_index+1] EW[0] = min_EW NS[0] = min_NS VD[0] = min_VD EW[-1] = max_EW NS[-1] = max_NS VD[-1] = max_VD curve, = self.ssWellbore3D_graphicsView.axes.plot( EW, NS, VD ) self.ssWellbore3D_graphicsView.axes.set_xlabel( parent.s2DataSurvey_fields.EW.headerName ) self.ssWellbore3D_graphicsView.axes.set_ylabel( parent.s2DataSurvey_fields.NS.headerName ) self.ssWellbore3D_graphicsView.axes.set_zlabel( parent.s2DataSurvey_fields.TVD.headerName ) max_EW = max(parent.s2DataSurvey_fields.EW) min_EW = min(parent.s2DataSurvey_fields.EW) max_NS = max(parent.s2DataSurvey_fields.NS) min_NS = min(parent.s2DataSurvey_fields.NS) ΔEW = max_EW - min_EW ΔNS = max_NS - min_NS if ΔEW>ΔNS: self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW ) Δ = (ΔEW-ΔNS)/2 self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS-Δ, max_NS+Δ ) elif ΔNS>ΔEW: self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS ) Δ = (ΔNS-ΔEW)/2 self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW-Δ, max_EW+Δ ) else: self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW ) self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS ) self.ssWellbore3D_graphicsView.axes.set_zlim( max(VD), min(VD) ) self.ssWellbore3D_graphicsView.axes.mouse_init() #zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve) zp.zoom3D_factory( self.ssWellbore3D_graphicsView.axes, curve ) self.ssWellbore3D_graphicsView.draw() dialog.setAttribute(Qt.WA_DeleteOnClose) dialog.exec_()
def __init__(self, dialog, parent): Ui_DiagramWindow.__init__(self) #zp = pu.ZoomPan() self.setupUi(dialog) self.dialog = dialog self.parent = parent self.dwWellboreSchematic_graphicsView self.dwWellboreSchematic_graphicsView.axes.set_position([0.2,0.15,0.75,0.8]) zp = pu.ZoomPan() zp.zoom2D_factory( self.dwWellboreSchematic_graphicsView.axes ) zp.pan2D_factory( self.dwWellboreSchematic_graphicsView.axes ) self.dwWellboreSchematic_graphicsView.axes.clear() MDs = self.parent.v3Forces_fields.MD[:] for stage in self.parent.v3WellboreInnerStageData.values(): MDbot = stage['MDbot'] MDs.append(MDbot) for stage in self.parent.v3WellboreOuterStageData.values(): MDbot = stage['WellboreProps'].MDbot[0] MDs.append(MDbot) MDs.sort() MDunit = MDbot.unit factor = max(self.parent.v3Forces_fields.HD)/mdl.get_outerStage_at_MD( self.parent, 0.0, MDunit )['WellboreProps'].ID[0]*0.2 HDu_i = [] VDu_i = [] HDd_i = [] VDd_i = [] HDu_o = [] VDu_o = [] HDd_o = [] VDd_o = [] for MD in MDs: ew,ns,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MD, MDunit) T = mdl.get_ASCT_from_MD(self.parent, MD, MDunit) t = mu.np.array([ T[3], T[2], 0 ]) t = t.reshape(1,-1) normt = mu.np.linalg.norm(t) if normt!=0.0: t /=normt u = mu.np.array([ 0, 0, 1 ]) u = u.reshape(1,-1) nu = mu.np_cross(t,u) d = mu.np.array([ 0, 0, -1 ]) d = d.reshape(1,-1) nd = mu.np_cross(t,d) innerStage = mdl.get_innerStage_at_MD(self.parent, MD, MDunit) factor_i = factor*innerStage['PipeProps'].OD[0] outerStage = mdl.get_outerStage_at_MD(self.parent, MD, MDunit) if outerStage['PipeBase']==None: noise = 0.1*(mu.np.random.rand()-0.5)+1 else: noise = 1 factor_o = factor*outerStage['WellboreProps'].ID[0]*noise HDu_i.append( HD+nu[0][0]*factor_i ) VDu_i.append( VD+nu[0][1]*factor_i ) HDd_i.append( HD+nd[0][0]*factor_i ) VDd_i.append( VD+nd[0][1]*factor_i ) HDu_o.append( HD+nu[0][0]*factor_o ) VDu_o.append( VD+nu[0][1]*factor_o ) HDd_o.append( HD+nd[0][0]*factor_o ) VDd_o.append( VD+nd[0][1]*factor_o ) max_VD = max( self.parent.v3Forces_fields.TVD ) min_VD = min( self.parent.v3Forces_fields.TVD ) delta = (max_VD-min_VD)*0.55 self.dwWellboreSchematic_graphicsView.axes.axis('equal') self.dwWellboreSchematic_graphicsView.axes.set_ylim( max_VD+delta, min_VD-delta ) self.dwWellboreSchematic_graphicsView.axes.set_xlabel( self.parent.v3Forces_fields.HD.headerName ) self.dwWellboreSchematic_graphicsView.axes.set_ylabel( self.parent.v3Forces_fields.TVD.headerName ) self.dwWellboreSchematic_graphicsView.axes.plot( self.parent.v3Forces_fields.HD, self.parent.v3Forces_fields.TVD, 'k--', lw=1 ) self.dwWellboreSchematic_graphicsView.axes.plot( HDu_i, VDu_i, 'C1', lw=3 ) self.dwWellboreSchematic_graphicsView.axes.plot( HDd_i, VDd_i, 'C1', lw=3 ) self.dwWellboreSchematic_graphicsView.axes.plot( HDu_o, VDu_o, 'C0', lw=3 ) self.dwWellboreSchematic_graphicsView.axes.plot( HDd_o, VDd_o, 'C0', lw=3 ) for stage in self.parent.v3WellboreInnerStageData.values(): MDbot = stage['MDbot'] EW,NS,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MDbot) T = mdl.get_ASCT_from_MD(self.parent, MDbot, MDbot.unit) t = mu.np.array([ T[3], T[2], 0 ]) t = t.reshape(1,-1) normt = mu.np.linalg.norm(t) if normt!=0.0: t /=normt u = mu.np.array([ 0, 0, 1 ]) u = u.reshape(1,-1) nu = mu.np_cross(t,u) nu *= 0.3*max_VD d = mu.np.array([ 0, 0, -1 ]) d = d.reshape(1,-1) nd = mu.np_cross(t,d) nd *= 0.3*max_VD self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nu[0][0], nu[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5) self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nd[0][0], nd[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5) dialog.setAttribute(Qt.WA_DeleteOnClose) dialog.exec_()
def calculate_standOff_at_Midspans(self): Loc_field = self.lsCentralization_fields.MD Inc_field = self.lsCentralization_fields.Inc Azi_field = self.lsCentralization_fields.Azi SOatM_field = self.lsCentralization_fields.SOatM ClatM_field = self.lsCentralization_fields.ClatM AFatM_field = self.lsCentralization_fields.AFatM SFatM_field = self.lsCentralization_fields.SFatM ClatC_field = self.lsCentralization_fields.ClatC ID_field = self.lsCentralization_fields.ID avgID_field = self.lsCentralization_fields.avgID stage_field = self.lsCentralization_fields.Stage self.lsCentralization_fields.referenceUnitConvert_fields() MDs = self.lsCentralization_fields.MD.factorToReferenceUnit*self.MD IDs = self.lsCentralization_fields.ID.factorToReferenceUnit*self.ID stageRow = None for i in range(len(Loc_field)-1): j = i+1 stage = self.parent.v3WellboreInnerStageData[ stage_field[j] ] if stageRow!=stage['row']: stageRow = stage['row'] PD = stage['PipeProps'].OD[0] Pd = stage['PipeProps'].ID[0] PE = stage['PipeProps'].E[0] PW = stage['PipeProps'].PW[0] PL = stage['PipeBase'].PL[0] ρi = stage['PipeProps'].InnerMudDensity[0] ρe = stage['PipeProps'].OuterMudDensity[0] ρs = stage['PipeProps'].Density[0] PD = mu.referenceUnitConvert_value( PD, PD.unit ) Pd = mu.referenceUnitConvert_value( Pd, Pd.unit ) PE = mu.referenceUnitConvert_value( PE, PE.unit ) PW = mu.referenceUnitConvert_value( PW, PW.unit ) PL = mu.referenceUnitConvert_value( PL, PL.unit ) ρi = mu.referenceUnitConvert_value( ρi, ρi.unit ) ρe = mu.referenceUnitConvert_value( ρe, ρe.unit ) ρs = mu.referenceUnitConvert_value( ρs, ρs.unit ) c = stage['Centralization'] CEL = c['Ensemble']['PLfactor']*PL*0.9 buoyancyFactor = mu.calculate_buoyancyFactor( OD=PD, ID=Pd, ρs=ρs, ρe=ρe, ρi=ρi ) PWb = PW*buoyancyFactor PI = np.pi/64*(PD**4-Pd**4) PR = PD/2 MD1 = Loc_field[i]+CEL MD2 = Loc_field[j] In1 = Inc_field[i] In2 = Inc_field[j] Az1 = Azi_field[i] Az2 = Azi_field[j] mID1 = avgID_field[i] mID2 = avgID_field[j] L = MD2-MD1 MDm = MD1 + L/2 mHd = (MDm-MD1)/(MD2-MD1)*(mID2-mID1)+mID1 MDi = MDs[0] IDi = IDs[0] for MDj,IDj in zip(MDs[1:],IDs[1:]): if MDm<MDj: Hd = (MDm-MDi)/(MDj-MDi)*(IDj-IDi)+IDi break else: MDi = MDj IDi = IDj Ft = mdl.get_axialTension_below_MD(self.parent, MD2, referenceUnit=True) u = np.sqrt( Ft*L**2/4/PE/PI ) β = np.arccos( np.cos(In1)*np.cos(In2) + np.sin(In1)*np.sin(In2)*np.cos(Az2-Az1) ) if β==0.0: Fl = 0.0 δ = 0.0 else: cosγ0 = np.sin(In1)*np.sin(In2)*np.sin(Az2-Az1)/np.sin(β) cosγn = np.sin( abs(In1-In2)/2 )*np.sin( (In1+In2)/2 )/np.sin(β/2) if In1>In2: Fldp = PWb*L*cosγn + 2*Ft*np.sin(β/2) elif In1<In2: Fldp = PWb*L*cosγn - 2*Ft*np.sin(β/2) else: Fldp = 0.0 Flp = PWb*L*cosγ0 Fl = np.sqrt( Fldp**2 + Flp**2 ) δ = Fl*L**3/384/PE/PI*24/u**4*(u**2/2 - u*(np.cosh(u)-1)/np.sinh(u) ) c1 = ClatC_field[i] c2 = ClatC_field[j] Hr = Hd/2 mHr = mHd/2 mHc = mHr-PR Mc = (c1+c2)/2-δ xHc = mHr-Hr #Mc = Mc if (Mc>xHc) else xHc if Mc>xHc: Fl = -Fl else: Mc = xHc SO = Mc/mHc mu.create_physicalValue_and_appendTo_field( SO, SOatM_field, SOatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( Mc, ClatM_field, ClatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( Ft, AFatM_field, AFatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( Fl, SFatM_field, SFatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( 0, SOatM_field, SOatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( 0, ClatM_field, ClatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( 0, AFatM_field, AFatM_field.referenceUnit ) mu.create_physicalValue_and_appendTo_field( 0, SFatM_field, SFatM_field.referenceUnit ) self.lsCentralization_fields.inverseReferenceUnitConvert_fields()
def calculate_SO_per_centralizer(label,ctype,supports,ΔMD1): # Equations Reference: # H.C. Juvkam-Wold et al. Casing Deflection and Centralizer Spacing Calculations. # SPE Drilling Engineering, December 1992. """ Define before use: MD0, MD1, MD2, inc Return "SO, Cc, L" in reference units. """ MD1_ = MD1 + ΔMD1 R = D[label]/2 if ctype=='Bow Spring': L = get_L(MD0, MD1_, MD2, In1, Hr) if MD0==None: Ft = mdl.get_axialTension_below_MD(self.parent, MD2, referenceUnit=True) Fl = Ft*np.sin(In1)/supports elif MD2==None: Ft = 0.0 Fl = PWb*L*np.sin(In1)/supports else: Ft = mdl.get_axialTension_below_MD(self.parent, MD2, referenceUnit=True) u = np.sqrt( Ft*L**2/4/PE/PI ) β = np.arccos( np.cos(In0)*np.cos(In2) + np.sin(In0)*np.sin(In2)*np.cos(Az2-Az0) ) if β==0.0: Fl = 0.0 else: cosγ0 = np.sin(In0)*np.sin(In2)*np.sin(Az2-Az0)/np.sin(β) cosγn = np.sin( abs(In0-In2)/2 )*np.sin( (In0+In2)/2 )/np.sin(β/2) if In0>In2: Fldp = PWb*L*cosγn + 2*Ft*np.sin(β/2) elif In0<In2: Fldp = PWb*L*cosγn - 2*Ft*np.sin(β/2) else: Fldp = 0.0 Flp = PWb*L*cosγ0 Fl = np.sqrt( Fldp**2 + Flp**2 )/supports #f = PWb*L*np.sin(In1)/supports resK = 2*ResF[label]/( D[label]-d[label]-0.67*(Hr*2-PD) ) y = Fl/resK Rmin = PR+(R-PR)*0.1 R = (R-y) if (R<Hr) else (Hr-y) R = Rmin if (R<Rmin) else R mHc = mHr-PR Cc = R-PR-(Hr-mHr) SO = Cc/mHc elif ctype=='Resin': SO_ = [] Cc_ = [] L_ = [] for i in range(B[label]): L = get_L(MD0, MD1_, MD2, In1, Hr) mHc = mHr-PR cc = mHc if (R>Hr) else R-PR-(Hr-mHr) Cc_.append( cc ) SO_.append( cc/mHc ) L_.append( L ) MD1_ += CL[label]/B[label] Cc = np.mean( Cc_ ) SO = np.mean( SO_ ) L = np.mean( L_ ) if MD0==None: Ft = mdl.get_axialTension_below_MD(self.parent, MD2, referenceUnit=True) Fl = Ft*np.sin(In1)/supports elif MD2==None: Ft = 0.0 Fl = PWb*L*np.sin(In1)/supports else: Ft = mdl.get_axialTension_below_MD(self.parent, MD2, referenceUnit=True) u = np.sqrt( Ft*L**2/4/PE/PI ) β = np.arccos( np.cos(In0)*np.cos(In2) + np.sin(In0)*np.sin(In2)*np.cos(Az2-Az0) ) if β==0.0: Fl = 0.0 else: cosγ0 = np.sin(In0)*np.sin(In2)*np.sin(Az2-Az0)/np.sin(β) cosγn = np.sin( abs(In0-In2)/2 )*np.sin( (In0+In2)/2 )/np.sin(β/2) if In0>In2: Fldp = PWb*L*cosγn + 2*Ft*np.sin(β/2) elif In0<In2: Fldp = PWb*L*cosγn - 2*Ft*np.sin(β/2) else: Fldp = 0.0 Flp = PWb*L*cosγ0 Fl = np.sqrt( Fldp**2 + Flp**2 )/supports return SO, Cc, Ft, Fl, L
def open_LS_dialog(self): importlib.reload(ls) if not mdl.get_centralizationLocations(self): return print_wellboreInnerStageData(self) dialog = QDialog(self.s3ManageLocations_pushButton) LS = ls.Main_LocationSetup(dialog, self) del dialog if not hasattr(LS, 'fields'): self.v3CentralizationChanged_flag = False return K = mdl.get_sortedIndexes_of_wellboreInnerStageData(self) for k in K: datafields = self.v3WellboreInnerStageData[k]['Centralization'][ 'Fields'] if datafields == None: continue datafields.clear_content() for i, row in enumerate(LS.fields.Stage): datafields = self.v3WellboreInnerStageData[row]['Centralization'][ 'Fields'] for lsfield in LS.fields: if lsfield.abbreviation != 'Stage': datafield = getattr(datafields, lsfield.abbreviation) datafield.append(lsfield[i]) currfields = self.currentWellboreInnerStageDataItem['Centralization'][ 'Fields'] if currfields: for tab in ['A', 'B', 'C']: s3CentralizerLocation_tableWidget = eval( 'self.s3CentralizerLocation_tableWidget_{tab}'.format(tab=tab)) s3CentralizerLocation_fields = eval( 'self.v3CentralizerLocation_fields_{tab}'.format(tab=tab)) field = s3CentralizerLocation_fields.MD if self.currentWellboreInnerStageDataItem['Centralization'][tab][ 'Type'] != None: for i in range(s3CentralizerLocation_tableWidget.rowCount()): item = s3CentralizerLocation_tableWidget.item(i, field.pos) try: value = currfields.MD[i] item.set_text(value, value.unit) except IndexError: item.set_text() self.meanSOatC = LS.meanSOatC self.meanSOatM = LS.meanSOatM self.v4TorqueDragForces_fields.MD[:] = LS.fields.MD self.v4TorqueDragForces_fields.AxialF[:] = LS.fields.AFatC self.v4TorqueDragForces_fields.SideF[:] = LS.fields.SFatC print('+++++++++++++++++++++++++++++++++++++++++++') for field in LS.fields: print(field.abbreviation, len(field)) print('+++++++++++++++++++++++++++++++++++++++++++') self.v3SOs_MD = [] self.v3SOs_SO = [] for k in range(2 * len(LS.fields.MD) - 1): if k % 2 == 0: self.v3SOs_MD.append(LS.fields.MD[k // 2]) self.v3SOs_SO.append(LS.fields.SOatC[k // 2]) elif k % 2 == 1: self.v3SOs_MD.append( (LS.fields.MD[(k + 1) // 2] + LS.fields.MD[(k - 1) // 2]) / 2) self.v3SOs_SO.append(LS.fields.SOatM[k // 2]) for i, (AF, SF) in enumerate(zip(LS.fields.AFatM[:-1], LS.fields.SFatM[:-1])): MD0 = LS.fields.MD[i] MD1 = LS.fields.MD[i + 1] MDm = mdl.mu.physicalValue((MD1 + MD0) / 2, LS.fields.MD.unit) self.v4TorqueDragForces_fields.MD.insert(i * 2 + 1, MDm) self.v4TorqueDragForces_fields.AxialF.insert(i * 2 + 1, AF) self.v4TorqueDragForces_fields.SideF.insert(i * 2 + 1, SF) if self.v4TorqueDragForces_fields.MD[0] != self.v3Forces_fields.MD[0]: self.v4TorqueDragForces_fields.MD.insert(0, self.v3Forces_fields.MD[0]) self.v4TorqueDragForces_fields.AxialF.insert( 0, self.v3Forces_fields.AxialF[0]) self.v4TorqueDragForces_fields.SideF.insert( 0, self.v3Forces_fields.SideF[0]) if self.v4TorqueDragForces_fields.MD[-1] != self.v3Forces_fields.MD[-1]: self.v4TorqueDragForces_fields.MD.append(self.v3Forces_fields.MD[-1]) self.v4TorqueDragForces_fields.AxialF.append( self.v3Forces_fields.AxialF[-1]) self.v4TorqueDragForces_fields.SideF.append( self.v3Forces_fields.SideF[-1]) self.msg_label.setText( 'Mean SO at centralizers: {meanSOatC} {unit} , Mean SO at minspan: {meanSOatM} {unit}' .format(meanSOatC=LS.meanSOatC, meanSOatM=LS.meanSOatM, unit=LS.fields.SOatC.unit)) del LS cu.idleFunction()
def open_specifyCentralization_dialog(self): #try: mdl.get_centralizationLocations(self) print_wellboreInnerStageData(self) open_LS_dialog(self)
def choose_MDlocation(self, MD, overwrite=False): if MD>=self.min_MD and MD<=self.max_MD: if overwrite: r = self.ssCentralizerLocations_tableWidget.selectedRow if r<len(self.ssCentralizerLocations_fields.MD): del self.ssCentralizerLocations_fields.MD[r] MD_bk = copy.deepcopy( self.ssCentralizerLocations_fields.MD ) EW_bk = copy.deepcopy( self.ssCentralizerLocations_fields.EW ) NS_bk = copy.deepcopy( self.ssCentralizerLocations_fields.NS ) VD_bk = copy.deepcopy( self.ssCentralizerLocations_fields.TVD ) DL_bk = copy.deepcopy( self.ssCentralizerLocations_fields.DL ) MD = mdl.set_newSpacedLocations_under_MD_with_variations(self, MD) self.ssCentralizerLocations_fields.EW.clear() self.ssCentralizerLocations_fields.NS.clear() self.ssCentralizerLocations_fields.TVD.clear() self.ssCentralizerLocations_fields.DL.clear() self.ssCentralizerLocations_fields.Inc.clear() self.ssCentralizerLocations_fields.SOatC.clear() self.ssCentralizerLocations_fields.SOatM.clear() self.ssCentralizerLocations_fields.ClatC.clear() self.ssCentralizerLocations_fields.ClatM.clear() self.ssCentralizerLocations_fields.LatC.clear() self.centralizerCount = len(self.ssCentralizerLocations_fields.MD) for i in range(self.ssCentralizerLocations_tableWidget.rowCount()): try: MDi = self.ssCentralizerLocations_fields.MD[i] EWi,NSi,VDi,_ = mdl2.get_ASCCoordinates_from_MD(self.parent, MDi) DLi = mdl2.get_ASCDogleg_from_MD(self.parent, MDi) mu.create_physicalValue_and_appendTo_field( EWi, self.ssCentralizerLocations_fields.EW ) mu.create_physicalValue_and_appendTo_field( NSi, self.ssCentralizerLocations_fields.NS ) mu.create_physicalValue_and_appendTo_field( VDi, self.ssCentralizerLocations_fields.TVD ) mu.create_physicalValue_and_appendTo_field( DLi, self.ssCentralizerLocations_fields.DL ) item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.MD.pos ) item.set_text( MDi ) if MDi==MD: EW = EWi NS = NSi VD = VDi cu.select_tableWidgetRow(self.ssCentralizerLocations_tableWidget, i, alltherow=True) except IndexError: item = self.ssCentralizerLocations_tableWidget.item( i, self.ssCentralizerLocations_fields.MD.pos ) item.set_text() try: self.update_calculations() except mu.LogicalError: msg = "There is a logical error between centralizer locations and length.\nPlease try with a larger spacing." QMessageBox.critical(self.ssCentralizerLocations_tableWidget, 'Error', msg) self.ssCentralizerLocations_fields.MD = MD_bk self.ssCentralizerLocations_fields.EW = EW_bk self.ssCentralizerLocations_fields.NS = NS_bk self.ssCentralizerLocations_fields.TVD = VD_bk self.ssCentralizerLocations_fields.DL = DL_bk self.update_calculations() return self.draw_MDlocations(MD, EW, NS, VD)
def calculateAndDraw_torque_drag_sideforce(self): for field in self.v4TorqueDragForces_fields: print(field.headerName, len(field), field) calculate_TorqueAndDrag(self) for field in self.v4TorqueDragForces_fields: print(field.headerName, len(field), field) TDS_fields = self.v4TorqueDragForces_fields for field in self.v4TorqueDragForces_fields[:7]: for row, value in enumerate(field): item = self.s4TorqueDragSideforce_tableWidget.item(row, field.pos) item.set_text(value, value.unit) max_MD = max(TDS_fields.MD) self.s4Drag_graphicsView.axes.clear() self.s4Drag_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName) self.s4Drag_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName) #self.s4Drag_graphicsView.axes.set_xlim( 0, self.max_SO ) self.s4Drag_graphicsView.axes.set_ylim(max_MD * 1.2, 0) self.s4Drag_graphicsView.axes.grid() self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_u, TDS_fields.MD, 'C0', lw=2) self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_s, TDS_fields.MD, 'C1', lw=2) self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_d, TDS_fields.MD, 'C2', lw=2) self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_u, TDS_fields.MD, 'C0--', lw=2) self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_s, TDS_fields.MD, 'C1--', lw=2) self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_d, TDS_fields.MD, 'C2--', lw=2) self.s4Drag_graphicsView.draw() #--------------------------------------------- self.s4Torque_graphicsView.axes.clear() self.s4Torque_graphicsView.axes.set_xlabel(TDS_fields.Torque.headerName) self.s4Torque_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName) #self.s4Torque_graphicsView.axes.set_xlim( 0, self.max_SO ) self.s4Torque_graphicsView.axes.set_ylim(max_MD * 1.2, 0) self.s4Torque_graphicsView.axes.grid() self.s4Torque_graphicsView.axes.plot(TDS_fields.Torque, TDS_fields.MD, 'C0', lw=2) self.s4Torque_graphicsView.axes.plot(TDS_fields.uncTorque, TDS_fields.MD, 'C0--', lw=2) self.s4Torque_graphicsView.draw() #--------------------------------------------- self.s4Sideforce_graphicsView.axes.set_position([0.2, 0.15, 0.75, 0.8]) zp = pu.ZoomPan() zp.zoom2D_factory(self.s4Sideforce_graphicsView.axes) zp.pan2D_factory(self.s4Sideforce_graphicsView.axes) self.s4Sideforce_graphicsView.axes.clear() max_VD = max(self.v3Forces_fields.TVD) min_VD = min(self.v3Forces_fields.TVD) max_SF = max(self.v3Forces_fields.SideF) self.s4Sideforce_graphicsView.axes.axis('equal') self.s4Sideforce_graphicsView.axes.set_ylim(max_VD, min_VD) self.s4Sideforce_graphicsView.axes.set_xlabel( self.v3Forces_fields.HD.headerName) self.s4Sideforce_graphicsView.axes.set_ylabel( self.v3Forces_fields.TVD.headerName) self.s4Sideforce_graphicsView.axes.plot(self.v3Forces_fields.HD, self.v3Forces_fields.TVD, 'C0', lw=3) factor = max(self.v3Forces_fields.HD) / max( self.v3Forces_fields.SideF) * 0.5 for i, MDi in enumerate(self.v3Forces_fields.MD): HDi = self.v3Forces_fields.HD[i] VDi = self.v3Forces_fields.TVD[i] DFi = self.v3Forces_fields.DLplaneF[i] SFi = self.v3Forces_fields.SideF[i] T = mdl.get_ASCT_from_MD(self, MDi, MDi.unit) t = mu.np.array([T[3], T[2], 0]) t = t.reshape(1, -1) normt = mu.np.linalg.norm(t) if normt != 0.0: t /= normt u = mu.np.array([0, 0, -DFi]) u = u.reshape(1, -1) normu = mu.np.linalg.norm(u) if normu != 0.0: u /= normu if normt == 0 or normu == 0: n = mu.np.array([0, 0, 0]) n = n.reshape(1, -1) else: n = mu.np_cross(t, u) n *= SFi * factor self.s4Sideforce_graphicsView.axes.arrow(HDi, VDi, n[0][0], n[0][1], head_width=factor * 0.1, head_length=factor * 0.2, fc='C1', ec='C1') #self.s4Sideforce_graphicsView.axes.arrow(HDi, VDi, t[0][0], t[0][1], head_width=factor*0.1, head_length=factor*0.2, fc='C1', ec='C1') for stage in self.v3WellboreInnerStageData.values(): MDbot = stage['MDbot'] EW, NS, VD, HD, i = mdl.get_ASCCoordinates_from_MD(self, MDbot) T = mdl.get_ASCT_from_MD(self, MDbot, MDbot.unit) t = mu.np.array([T[3], T[2], 0]) t = t.reshape(1, -1) normt = mu.np.linalg.norm(t) if normt != 0.0: t /= normt u = mu.np.array([0, 0, 1]) u = u.reshape(1, -1) nu = mu.np_cross(t, u) nu *= 1.2 * max_SF * factor d = mu.np.array([0, 0, -1]) d = d.reshape(1, -1) nd = mu.np_cross(t, d) nd *= 1.2 * max_SF * factor self.s4Sideforce_graphicsView.axes.arrow(HD, VD, nu[0][0], nu[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5) self.s4Sideforce_graphicsView.axes.arrow(HD, VD, nd[0][0], nd[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5) #------------------------------------------------- self.s4HookLoad_graphicsView.axes.clear() self.s4HookLoad_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName) self.s4HookLoad_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName) self.s4HookLoad_graphicsView.axes.set_ylim(max_MD * 1.2, 0) self.s4HookLoad_graphicsView.axes.grid() max_Drag_u = max(TDS_fields.Drag_u) max_Drag_s = max(TDS_fields.Drag_s) max_Drag_d = max(TDS_fields.Drag_d) max_uncDrag_u = max(TDS_fields.uncDrag_u) max_uncDrag_s = max(TDS_fields.uncDrag_s) max_uncDrag_d = max(TDS_fields.uncDrag_d) self.s4HookLoad_graphicsView.axes.plot(max_Drag_u - mu.array(TDS_fields.Drag_u), TDS_fields.MD, 'C0', lw=2) self.s4HookLoad_graphicsView.axes.plot(max_Drag_s - mu.array(TDS_fields.Drag_s), TDS_fields.MD, 'C1', lw=2) self.s4HookLoad_graphicsView.axes.plot(max_Drag_d - mu.array(TDS_fields.Drag_d), TDS_fields.MD, 'C2', lw=2) self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_u - mu.array(TDS_fields.uncDrag_u), TDS_fields.MD, 'C0--', lw=2) self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_s - mu.array(TDS_fields.uncDrag_s), TDS_fields.MD, 'C1--', lw=2) self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_d - mu.array(TDS_fields.uncDrag_d), TDS_fields.MD, 'C2--', lw=2) self.s4HookLoad_graphicsView.draw()