def displayLocalAxes(self,setToDisplay=None,vectorScale=1.0,viewDef= vtk_graphic_base.CameraParameters('XYZPos'), caption= '',fileName=None,defFScale=0.0): '''vector field display of the loads applied to the chosen set of elements in the load case passed as parameter :param setToDisplay: set of elements to be displayed (defaults to total set) :param vectorScale: factor to apply to the vectors length in the representation :param viewDef: parameters that define the view to use predefined view names: 'XYZPos','XNeg','XPos','YNeg','YPos', 'ZNeg','ZPos' :param fileName: full name of the graphic file to generate. Defaults to `None`, in this case it returns a console output graphic. :param caption: text to display in the graphic :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay == None): setToDisplay=self.getPreprocessor().getSets.getSet('total') setToDisplay.fillDownwards() lmsg.warning('set to display not defined; using total set.') defDisplay= vtk_FE_graphic.RecordDefDisplayEF() defDisplay.setupGrid(setToDisplay) if setToDisplay.color.Norm()==0: setToDisplay.color=xc.Vector([rd.random(),rd.random(),rd.random()]) vField=lavf.LocalAxesVectorField(setToDisplay.name+'_localAxes',vectorScale) vField.dumpVectors(setToDisplay) defDisplay.cameraParameters= viewDef defDisplay.defineMeshScene(None,defFScale,color=setToDisplay.color) vField.addToDisplay(defDisplay) defDisplay.displayScene(caption,fileName) return defDisplay
def VtkDefineElementsActor(self, reprType,field,color=xc.Vector([rd.random(),rd.random(),rd.random()])): ''' Define the actor to display elements :param reprType: type of representation ("points", "wireframe" or "surface") :param field: field to be repreresented :param color: RGB color to represent the elements (defaults to random color) ''' if(field): field.setupOnGrid(self.gridRecord.uGrid) self.gridMapper= vtk.vtkDataSetMapper() self.gridMapper.SetInputData(self.gridRecord.uGrid) if(field): field.setupOnMapper(self.gridMapper) elemActor= vtk.vtkActor() elemActor.SetMapper(self.gridMapper) elemActor.GetProperty().SetColor(color[0],color[1],color[2]) if(reprType=="points"): elemActor.GetProperty().SetRepresentationToPoints() elif(reprType=="wireframe"): elemActor.GetProperty().SetRepresentationToWireFrame() elif(reprType=="surface"): elemActor.GetProperty().SetRepresentationToSurface() else: lmsg.error("Representation type: '"+ reprType+ "' unknown.") self.renderer.AddActor(elemActor) if(field): field.creaColorScaleBar() self.renderer.AddActor2D(field.scalarBar)
def dumpLoads(self, preprocessor,defFScale, showElementalLoads= True, showNodalLoads= True): ''' Iterate over loads dumping them into the graphic. :param lp: load pattern :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. :param showElementalLoads: if true show loads over elements. :param showNodalLoads: if true show loads over nodes. ''' preprocessor.resetLoadCase() loadPatterns= preprocessor.getLoadHandler.getLoadPatterns loadPatterns.addToDomain(self.lpName) lp= loadPatterns[self.lpName] count= 0 if(lp): numberOfLoads= self.populateLoads(preprocessor,lp) if(numberOfLoads>0): self.data.scaleFactor/= self.getMaxLoad() #Iterate over loaded elements. count+= self.dumpElementalPositions(preprocessor,lp) #Iterate over loaded nodes. count+= self.dumpNodalPositions(preprocessor,lp,defFScale) if(count==0): lmsg.warning('LoadVectorField.dumpLoads: no loads defined.') loadPatterns.removeFromDomain(self.lpName) else: lmsg.error('Load pattern: '+ self.lpName + ' not found.') return count
def simulaCargasXYFromTable(nmbQuery, nmbTbEsf, idElem, offset): ''' Crea las cargas sobre cada uno de los elementos a partir de las tablas creadas anteriormente nmbQuery: Nombre de la consulta que se empleara para obtener las cargas. nmbTbEsf: Nombre de la tabla que contiene los índices de sección. idElem: Identificador del elemento shell. ''' idSecc1= idElem*10 iNod1= idSecc1+1 idSecc2= offset+idSecc1 iNod2= idSecc2+1 cargas= preprocessor.getLoadHandler casos= cargas.getLoadPatterns lmsg.info("Cargando elemento: ",int(idElem),"\n") con= sqlite.connect(nmbDataBase) con.row_factory = sqlite.Row idSecc= 0.0 cur= con.cursor() cur.execute("select * from "+ nmbTbEsf + " where ELEM = " + sqlValue(idElem)) for row in cur: idAccion= row['ACCION'] lp= casos.getLoadPattern(idAccion) lp.setCurrentLoadPattern() lp.newNodalLoad(iNod1,xc.Vector([row['AXIL_X'],row['Q_X'],row['RASANTE'],row['TORSOR'],row['MOM_X'],0.0])) lp.newNodalLoad(iNod2,xc.Vector([row['AXIL_Y'],row['Q_Y'],row['RASANTE'],row['TORSOR'],row['MOM_Y'],0.0]))
def getElementComponentData(self,elem): '''Returns the data to use to represent the diagram over the element :param elem: element to deal with. :param component: component to represent: ''' # default values. elemVDir= elem.getJVector3d(True) #initialGeometry= True value1= 0.0 value2= 0.0 if(self.component == 'N'): value1= elem.getN1 value2= elem.getN2 elif(self.component == 'Qy'): elemVDir= elem.getJVector3d(True) # initialGeometry= True value1= elem.getVy1 value2= elem.getVy2 elif(self.component == 'Qz'): elemVDir= elem.getKVector3d(True) # initialGeometry= True value1= elem.getVz1 value2= elem.getVz2 elif(self.component == 'T'): value1= elem.getT1 value2= elem.getT2 elif(self.component == 'My'): elemVDir= elem.getKVector3d(True) # initialGeometry= True value1= elem.getMy1 value2= elem.getMy2 elif(self.component == 'Mz'): elemVDir= elem.getJVector3d(True) # initialGeometry= True value1= elem.getMz1 value2= elem.getMz2 else: lmsg.warning("'component :'"+ self.component+ "' unknown.") return [elemVDir,value1,value2]
def J(self): '''Return torsional constant of the section''' msg= 'Torsional constant not implemented for section:' msg+= self.sectionName msg+= '. Zero returned' lmsg.warning(msg) return 0.0
def exportaEsfuerzosShellSet(preprocessor,nmbComb, st, fName): '''Writes a comma separated values file with the element's internal forces.''' errMsg= 'exportaEsfuerzosShellSet deprecated use exportInternalForces' errMsg+= 'with apropriate arguments' lmsg.error(errMsg) elems= st.getElements exportShellInternalForces(nmbComb,elems,fName)
def setUniaxialBearing2D(self,iNod,bearingMaterial,direction): '''Modelize an uniaxial bearing on the defined direction. Args: iNod (int): node identifier (tag). bearingMaterial (str): material name for the zero length element. Returns: :rtype: (int, int) new node tag, new element tag. ''' nodes= self.preprocessor.getNodeHandler newNode= nodes.duplicateNode(iNod) # new node. # Element definition elems= self.preprocessor.getElementHandler elems.dimElem= self.preprocessor.getNodeHandler.dimSpace # space dimension. if(elems.dimElem>2): lmsg.warning("Not a bi-dimensional space.") elems.defaultMaterial= bearingMaterial zl= elems.newElement("ZeroLength",xc.ID([newNode.tag,iNod])) zl.setupVectors(xc.Vector([direction[0],direction[1],0]),xc.Vector([-direction[1],direction[0],0])) zl.clearMaterials() zl.setMaterial(0,bearingMaterial) # Boundary conditions numDOFs= self.preprocessor.getNodeHandler.numDOFs for i in range(0,numDOFs): spc= self.constraints.newSPConstraint(newNode.tag,i,0.0) return newNode.tag, zl.tag
def alphaZ(self): '''Return shear shape factor with respect to local z-axis''' msg= 'alphaZ: shear shape factor not implemented for section: ' msg+= self.sectionName msg+= '. 5/6 returned' lmsg.warning(msg) return 5.0/6.0
def gdls_resist_materiales2D(nodes): '''Defines the dimension of the space: nodes by two coordinates (x,y) and three DOF for each node (Ux,Uy,theta) :param nodes: preprocessor nodes handler ''' lmsg.warning('gdls_resist_materiales2D DEPRECATED; use StructuralMechanics2D.') return StructuralMechanics2D(nodes)
def gdls_elasticidad2D(nodes): '''Defines the dimension of the space: nodes by two coordinates (x,y) and two DOF for each node (Ux,Uy) :param nodes: nodes handler ''' lmsg.warning('gdls_elasticidad2D DEPRECATED; use SolidMechanics2D.') return SolidMechanics2D(nodes)
def dispLoadCaseBeamEl(self,loadCaseName='',setToDisplay=None,fUnitConv=1.0,elLoadComp='transComponent',elLoadScaleF=1.0,nodLoadScaleF=1.0,viewDef= vtk_graphic_base.CameraParameters('XYZPos'),caption='',fileName=None,defFScale=0.0): '''Display the loads applied on beam elements and nodes for a given load case :param setToDisplay: set of beam elements to be represented :param fUnitConv: factor of conversion to be applied to the results (defaults to 1) :param elLoadComp: component of the loads on elements to be depicted [possible components: 'axialComponent', 'transComponent', 'transYComponent', 'transZComponent'] :param elLoadScaleF: factor of scale to apply to the diagram display of element loads (defaults to 1) :param nodLoadScaleF: factor of scale to apply to the vector display of nodal loads (defaults to 1) :param vwDef: camera parameters. :param caption: caption for the graphic :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay): self.xcSet= setToDisplay if self.xcSet.color.Norm()==0: self.xcSet.color=xc.Vector([rd.random(),rd.random(),rd.random()]) else: lmsg.warning('QuickGraphics::dispLoadCaseBeamEl; set to display not defined; using previously defined set (total if None).') preprocessor= self.feProblem.getPreprocessor loadPatterns= preprocessor.getLoadHandler.getLoadPatterns loadPatterns.addToDomain(loadCaseName) defDisplay= self.getDisplay(viewDef) grid= defDisplay.setupGrid(self.xcSet) defDisplay.defineMeshScene(None,defFScale,color=self.xcSet.color) orNodalLBar='H' #default orientation of scale bar for nodal loads # auto-scaling parameters LrefModSize=setToDisplay.getBnd(1.0).diagonal.getModulo() #representative length of set size (to auto-scale) diagAux=lld.LinearLoadDiagram(scale=elLoadScaleF,fUnitConv=fUnitConv,loadPatternName=loadCaseName,component=elLoadComp) maxAbs=diagAux.getMaxAbsComp(preprocessor) if maxAbs > 0: elLoadScaleF*=LrefModSize/maxAbs*100 # diagram= lld.LinearLoadDiagram(scale=elLoadScaleF,fUnitConv=fUnitConv,loadPatternName=loadCaseName,component=elLoadComp) diagram.addDiagram(preprocessor) if diagram.isValid(): defDisplay.appendDiagram(diagram) orNodalLBar='V' # nodal loads vField=lvf.LoadVectorField(loadPatternName=loadCaseName,fUnitConv=fUnitConv,scaleFactor=nodLoadScaleF,showPushing= True) # loadPatterns= preprocessor.getLoadHandler.getLoadPatterns lPattern= loadPatterns[loadCaseName] count= 0 if(lPattern): count=vField.dumpNodalLoads(preprocessor,defFScale=defFScale) else: lmsg.error('load pattern: '+ loadCaseName + ' not found.') if count >0: vField.addToDisplay(defDisplay,orientation=orNodalLBar) defDisplay.displayScene(caption=caption,fName=fileName)
def defConcrete02(preprocessor,name,epsc0,fpc,fpcu,epscu,ratioSlope,ft,Ets): ''''Constructs an uniaxial concrete material with linear tension softening. Compressive concrete parameters should be input as negative values. The initial slope for this model is (2*fpc/epsc0) :param preprocessor: preprocessor :param name: name identifying the material :param epsc0: concrete strain at maximum strength :param fpc: concrete compressive strength at 28 days (compression is negative) :param fpcu: concrete crushing strength :param epscu: concrete strain at crushing strength :param ratioSlope: ratio between unloading slope at epscu and initial slope :param ft: tensile strength :param Ets: tension softening stiffness (absolute value) (slope of the linear tension softening branch) ''' materials= preprocessor.getMaterialHandler materials.newMaterial("concrete02_material",name) retval= materials.getMaterial(name) retval.name= name retval.epsc0= epsc0 retval.fpc= fpc retval.fpcu= fpcu retval.epscu= epscu retval.ratioSlope=ratioSlope retval.ft=ft retval.Ets=Ets if fpc==fpcu: lmsg.warning("concrete02 compressive strength fpc is equal to crushing strength fpcu => the solver can return wrong stresses or have convergence problems ") return retval
def displayDispRot(self,itemToDisp='',setToDisplay=None,fConvUnits=1.0,unitDescription= '',viewDef= vtk_graphic_base.CameraParameters('XYZPos',1.0),fileName=None,defFScale=0.0,rgMinMax=None): '''displays the component of the displacement or rotations in the set of entities. :param itemToDisp: component of the displacement ('uX', 'uY' or 'uZ') or the rotation ('rotX', rotY', 'rotZ') to be depicted :param setToDisplay: set of entities to be represented (defaults to all entities) :param fConvUnits: factor of conversion to be applied to the results (defaults to 1) :param unitDescription: string describing units like '[mm] or [cm]' :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) :param rgMinMax: range (vmin,vmax) with the maximum and minimum values of the field to be represented. All the values less than vmin are displayed in blue and those greater than vmax in red (defaults to None) ''' if(setToDisplay): self.xcSet= setToDisplay else: lmsg.warning('QuickGraphics::displayDispRot; set to display not defined; using previously defined set (total if None).') vCompDisp= self.getDispComponentFromName(itemToDisp) nodSet= self.xcSet.getNodes for n in nodSet: n.setProp('propToDisp',n.getDisp[vCompDisp]) field= Fields.ScalarField(name='propToDisp',functionName="getProp",component=None,fUnitConv=fConvUnits,rgMinMax=rgMinMax) defDisplay= self.getDisplay(viewDef) defDisplay.displayMesh(xcSets=self.xcSet,field=field,diagrams= None, fName=fileName,caption=self.loadCaseName+' '+itemToDisp+' '+unitDescription+' '+self.xcSet.description,defFScale=defFScale)
def displayNodeValueDiagram(self,itemToDisp='',setToDisplay=None,fConvUnits=1.0,scaleFactor=1.0,unitDescription= '',viewDef= vtk_graphic_base.CameraParameters('XYZPos'),fileName=None,defFScale=0.0): '''displays the a displacement (uX,uY,...) or a property defined in nodes as a diagram over lines (i.e. appropiated for beam elements). :param itemToDisp: item to display. :param setToDisplay: set of entities (elements of type beam) to be represented :param fConvUnits: factor of conversion to be applied to the results (defalts to 1) :param scaleFactor: factor of scale to apply to the diagram display of :param unitDescription: string like '[m]' or '[rad]' or '[m/s2]' :param viewDef: camera parameters. :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay): self.xcSet= setToDisplay if self.xcSet.color.Norm()==0: self.xcSet.color=xc.Vector([rd.random(),rd.random(),rd.random()]) else: lmsg.warning('QuickGraphics::displayNodeValueDiagram; set to display not defined; using previously defined set (total if None).') diagram= npd.NodePropertyDiagram(scaleFactor= scaleFactor,fUnitConv= fConvUnits,sets=[self.xcSet],attributeName= itemToDisp) diagram.addDiagram() defDisplay= self.getDisplay(viewDef) defDisplay.setupGrid(self.xcSet) defDisplay.defineMeshScene(None,defFScale,color=self.xcSet.color) defDisplay.appendDiagram(diagram) #Append diagram to the scene. caption= self.loadCaseName+' '+itemToDisp+' '+unitDescription +' '+self.xcSet.description defDisplay.displayScene(caption=caption,fName=fileName)
def VtkCreaStrArraySetData(setToDraw, entTypeName, attr): '''Creates an array of strings with information associated to the points and cells. Parameters: setToDraw: set of entities to be displayed entTypeName: type of entities to be displayed ("pnts", "lines", "nodes", "elementos") attr: attribute to be stored in the array ''' # Define matrix arr= vtk.vtkStringArray() arr.SetName(attr) container= None if(entTypeName=="pnts"): container= setToDraw.getPoints elif(entTypeName=="lines"): container= setToDraw.getLines elif(entTypeName=="nodes"): container= setToDraw.getNodes elif(entTypeName=="elementos"): container= setToDraw.getElements else: lmsg.error("error: "+entTypeName+" not implemented.") for e in container: tmp= str(getattr(e,attr)) arr.InsertValue(e.getIdx,tmp) return arr
def defVarControlMov(obj, code): if(not obj.hasProp('span')): lmsg.warning('span property not defined for: '+str(obj.tag) + ' object.') obj.setProp(code+'Max',0.0) obj.setProp('Comb'+code+'Max',"") obj.setProp(code+'Min',0.0) obj.setProp('Comb'+code+'Min',"")
def ic(self,deltaB,deltaL,Hload,Beff,Leff): '''Factor that introduces the effect of load inclination on the cohesion component. :param deltaB: angle between the load and the foundation width atan(HloadB/VLoad). :param deltaL: angle between the load and the foundation length atan(HloadL/VLoad). :param Hload: Horizontal load. :param Beff: Width of the effective foundation area (see figure 12 in page 44 of reference[2]). :param Leff: Length of the effective foundation area (see figure 12 in page 44 of reference[2]). ''' if(self.getDesignPhi()!=0.0): iq= self.iq(deltaB,deltaL) return (iq*self.Nq()-1.0)/(self.Nq()-1.0) else: #See expresion (15) in reference [2] resist= Beff*Leff*self.getDesignC() if(Hload<=resist): twoAlpha= math.acos(Hload/resist) return 0.5+(twoAlpha+math.sin(twoAlpha))/(math.pi+2.0) else: lmsg.warning('Load (H= '+str(Hload)+') greater than soil strength R='+str(resist)+' returns 0.0') return 0.0
def check(self,reinfConcreteSections): '''Checking of displacements under frequent loads in serviceability limit states (see self.dumpCombinations). :param reinfConcreteSections: Reinforced concrete sections on each element. ''' lmsg.error('FreqLoadsDisplacementControlLimitStateData.check() not implemented.')
def gdls_resist_materiales3D(nodes): '''Define the dimension of the space: nodes by three coordinates (x,y,z) and six DOF for each node (Ux,Uy,Uz,thetaX,thetaY,thetaZ) :param nodes: preprocessor nodes handler ''' lmsg.warning('gdls_resist_materiales3D DEPRECATED; use StructuralMechanics3D.') return StructuralMechanics3D(nodes)
def runChecking(self,outputCfg): '''This method reads, for the elements in setCalc, the internal forces previously calculated and saved in the corresponding file. Using the 'initControlVars' and 'checkSetFromIntForcFile' methods of the controller, the appropiate attributes are assigned to the elements and the associated limit state verification is run. The results are written to a file in order to be displayed or listed. :param outputCfg: instance of class 'verifOutVars' which defines the variables that control the output of the checking (set of elements to be analyzed, append or not the results to the result file [defatults to 'N'], generation or not of list file [defatults to 'N', ...) :param setCalc: set that contains elements to be checked :param appendToResFile: 'Yes','Y','y',.., if results are appended to existing file of results (defaults to 'N') :param listFile: 'Yes','Y','y',.., if latex listing file of results is desired to be generated (defaults to 'N') ''' retval=None if outputCfg.setCalc: prep=outputCfg.setCalc.getPreprocessor intForcCombFileName=self.getInternalForcesFileName() self.controller.initControlVars(outputCfg.setCalc) self.controller.checkSetFromIntForcFile(intForcCombFileName,outputCfg.setCalc) retval=cv.writeControlVarsFromElements(self.controller.limitStateLabel,prep,self.getOutputDataBaseFileName(),outputCfg) else: lmsg.error("Result file hasn't been created, you must specify a valid set of elements") return retval
def set_included_in_orthoPrism(preprocessor,setInit,prismBase,prismAxis,setName): '''reselect from set setInit those elements included in a orthogonal prism defined by a 2D polygon and the direction of its axis. :param preprocessor: preprocessor :param setInit: set of elements to which restrict the search :param prismBase: 2D polygon that defines the n-sided base of the prism. The vertices of the polygon are defined in global coordinates in the following way: - for X-axis-prism: (y,z) - for Y-axis-prism: (x,z) - for Z-axis-prism: (x,y) :param prismAxis: axis of the prism (can be equal to 'X', 'Y', 'Z') :param setName: name of the set to be generated ''' sElIni=setInit.getElements if prismAxis in ['X','x']: elem_inside_prism=[e for e in sElIni if prismBase.In(geom.Pos2d(e.getPosCentroid(True).y,e.getPosCentroid(True).z),0)] elif prismAxis in ['Y','y']: elem_inside_prism=[e for e in sElIni if prismBase.In(geom.Pos2d(e.getPosCentroid(True).x,e.getPosCentroid(True).z),0)] elif prismAxis in ['Z','z']: elem_inside_prism=[e for e in sElIni if prismBase.In(geom.Pos2d(e.getPosCentroid(True).x,e.getPosCentroid(True).y),0)] else: lmsg.error("Wrong prisma axis. Available values: 'X', 'Y', 'Z' \n") s=lstElem_to_set(preprocessor,elem_inside_prism,setName) s.fillDownwards() return s
def displayElementUniformLoad(self, preprocessor, unifLoad,loadPattern, color, force, fScale): loadPatternName= loadPattern.getProp("dispName") actorName= "flechaU"+loadPatternName+"%04d".format(unifLoad.tag) eleTags= unifLoad.elementTags for tag in eleTags: ele= preprocessor.getElementHandler.getElement(tag) actorName+= "%04d".format(tag) # Tag elemento. lmsg.error('displayElementUniformLoad not implemented.')
def getSectionNamesForElement(self,tagElem): '''Returns the section names for the element which tag is being passed as a parameter.''' if tagElem in self.sectionDistribution.keys(): return self.sectionDistribution[tagElem] else: lmsg.error("element with tag: "+str(tagElem)+" not found.") return None
def writeResultTraction(self,outputFile,Nd): famArm= self.tensionRebars concrete= self.concrete AsMin= self.getMinReinfAreaUnderTension()/2 ancrage= famArm.getBasicAnchorageLength(concrete) ng_rebar_def.writeRebars(outputFile,concrete,famArm,AsMin) if(abs(Nd)>0): lmsg.error("ERROR; tension not implemented.")
def getPressure(self,z): '''Return the earth pressure acting on the points at global coordinate z.''' ret_press= 0.0 if(z<self.zGround): ret_press=0.65*self.K*self.gammaSoil*self.H if(z<self.zWater): lmsg.error('pressures under water table not implemented.''') return ret_press
def gdls_elasticidad3D(nodes): '''Defines the dimension of the space: nodes by three coordinates (x,y,z) and three DOF for each node (Ux,Uy,Uz) :param nodes: preprocessor nodes handler ''' lmsg.warning('gdls_elasticidad3D DEPRECATED; use SolidMechanics3D.') return SolidMechanics3D(nodes)
def setSLSInternalForcesEnvelope(self,wallInternalForces): '''Assigns the serviceability limit state infernal forces envelope for the stem.''' if(hasattr(self,'stemHeight')): if(self.getWFStemHeigth()!=wallInternalForces.stemHeight): lmsg.warning('stem height (' + str(self.stemHeight) + ' m) different from length of internal forces envelope law('+ str(wallInternalForces.stemHeight)+ ' m') else: self.stemHeight= wallInternalForces.stemHeight self.internalForcesSLS= wallInternalForces
def setULSInternalForcesEnvelope(self,wallInternalForces): '''Assigns the ultimate limit state infernal forces envelope for the stem.''' if(hasattr(self,'stemHeight')): if(self.getWFStemHeigth()!=wallInternalForces.stemHeight): lmsg.warning('stem height (' + str(self.stemHeight) + ' m) different from length of internal forces envelope law('+ str(wallInternalForces.stemHeight)+ ' m') else: self.stemHeight= wallInternalForces.stemHeight-self.footingThickness/2.0 self.internalForcesULS= wallInternalForces
def check(self,elements,nmbComb): ''' For each element in the set 'elememts' passed as first parameter and the resulting internal forces for the load combination 'nmbComb' passed as second parameter, this method calculates all the variables involved in the crack-SLS checking and obtains the crack width. In the case that the calculated crack width is greater than the biggest obtained for the element in previous load combinations, this value is saved in the element results record. Elements processed are those belonging to the phantom model, that is to say, of type xc.ZeroLengthSection. As we have defined the variable fakeSection as False, a reinfoced concrete fiber section is generated for each of these elements. ''' lmsg.log("Postprocessing combination: "+nmbComb) for e in elements: Aceff=0 #init. value R=e.getResistingForce() sct=e.getSection() sctCrkProp=lscb.fibSectLSProperties(sct) sctCrkProp.setupStrghCrackDist() hceff=self.EC2_hceff(sctCrkProp.h,sctCrkProp.d,sctCrkProp.x) Acgross=sct.getGrossEffectiveConcreteArea(hceff) Aceff=sct.getNetEffectiveConcreteArea(hceff,"tensSetFb",15.0) concrete=EC2_materials.concrOfName[sctCrkProp.concrName] rfSteel=EC2_materials.steelOfName[sctCrkProp.rsteelName] k2=self.EC2_k2(sctCrkProp.eps1,sctCrkProp.eps2) # print 'elem= ',e.tag, ' Aceff= ',Aceff if Aceff<=0: s_rmax=0 else: ro_s_eff=sctCrkProp.As/Aceff #effective ratio of reinforcement s_rmax=self.k3*sctCrkProp.cover+self.k1*k2*self.k4*sctCrkProp.fiEqu/ro_s_eff #Parameters for tension stiffening of concrete paramTS= concrete_base.paramTensStiffness(concrMat=concrete,reinfMat=rfSteel,reinfRatio=ro_s_eff,diagType='K') concrete.tensionStiffparam=paramTS #parameters for tension #stiffening are assigned to concrete ftdiag=concrete.tensionStiffparam.pointOnsetCracking()['ft'] #stress at the adopted point for concrete onset cracking Etsdiag=abs(concrete.tensionStiffparam.regresLine()['slope']) fiber_sets.redefTensStiffConcr(setOfTenStffConcrFibSect=sctCrkProp.setsRC.concrFibers,ft=ftdiag,Ets=Etsdiag) e.setProp('ResF',R) #vector resisting force e.setProp('s_rmax',s_rmax) #maximum crack distance self.preprocessor.getDomain.revertToStart() predefined_solutions.resuelveComb(self.preprocessor,nmbComb,self.analysis,1) for e in elements: sct=e.getSection() rfset=sct.getFiberSets()["reinfSetFb"] eps_sm=rfset.getStrainMax() srmax=e.getProp("s_rmax") # eps_cm=concrete.fctm()/2.0/concrete.E0() # wk=srmax*(eps_sm-eps_cm) wk=srmax*eps_sm # print ' eps_sm= ',eps_sm, ' srmax= ', srmax, ' wk= ',wk # print 'e.getProp(self.limitStateLabel).wk', e.getProp(self.limitStateLabel).wk if (wk>e.getProp(self.limitStateLabel).wk): R=e.getProp('ResF') e.setProp(self.limitStateLabel,cv.RCCrackStraightControlVars(idSection=e.getProp("idSection"),combName=nmbComb,N=-R[0],My=-R[4],Mz=-R[5],s_rmax=srmax,eps_sm=eps_sm,wk=wk))
def appendUniformLoadsBeamsToCurrentLoadPattern(self): for load in self.unifVectLoadBeam: lmsg.log('unifVectLoadBeam: '+ load.name) load.appendLoadToCurrentLoadPattern(self.lPattern)
def appendEarthPressureLoadsToCurrentLoadPattern(self): for ep in self.earthPressLoad: lmsg.log('earthPressLoad: '+ ep.name) ep.appendEarthPressureToCurrentLoadPattern()
def appendTemperatureGradientToLoadPattern(self): for gt in self.tempGrad: lmsg.log('tempGrad: '+ gt.name) gt.appendLoadToLoadPattern(self.lPattern)
def displayScalarField(self, preprocessor, xcSet, field, fName= None): lmsg.warning('displayScalarField DEPRECATED; use displayMesh.') self.displayMesh(xcSet, field, None, fName)
def saveAll(self, feProblem, combContainer, setCalc, fConvIntForc=1.0, analysisToPerform=defaultAnalysis, lstSteelBeams=None): '''Write internal forces, displacements, .., for each combination :param feProblem: XC finite element problem to deal with. :param setCalc: set of entities for which the verification is going to be performed :param fConvIntForc: conversion factor between the unit of force in which the calculation is performed and that one desired for the displaying of internal forces (The use of this factor won't be allowed in future versions) :param lstSteelBeams: list of steel beams to analyze (defaults to None) ''' if fConvIntForc != 1.0: lmsg.warning('fConvIntForc= ' + fConvIntForc + 'conversion factor between units is DEPRECATED') preprocessor = feProblem.getPreprocessor loadCombinations = preprocessor.getLoadHandler.getLoadCombinations #Putting combinations inside XC. loadCombinations = self.dumpCombinations(combContainer, loadCombinations) elemSet = setCalc.elements nodSet = setCalc.nodes fNameInfForc = self.getInternalForcesFileName() fNameDispl = self.getDisplacementsFileName() os.system("rm -f " + fNameInfForc) #Clear obsolete files. os.system("rm -f " + fNameDispl) fIntF = open(fNameInfForc, "a") fDisp = open(fNameDispl, "a") if lstSteelBeams: fIntF.write( " Comb. , Elem. , Sect. , N , Vy , Vz , T , My , Mz ,chiLT\n") else: fIntF.write( " Comb. , Elem. , Sect. , N , Vy , Vz , T , My , Mz \n") fDisp.write(" Comb. , Node , Ux , Uy , Uz , ROTx , ROTy , ROTz \n") fIntF.close() fDisp.close() for key in loadCombinations.getKeys(): comb = loadCombinations[key] feProblem.getPreprocessor.resetLoadCase() comb.addToDomain() #Combination to analyze. #Solution result = analysisToPerform(feProblem) if lstSteelBeams: for sb in lstSteelBeams: sb.updateLateralBucklingReductionFactor() #Writing results. fIntF = open(fNameInfForc, "a") fDisp = open(fNameDispl, "a") eif.exportInternalForces(comb.getName, elemSet, fIntF) edisp.exportDisplacements(comb.getName, nodSet, fDisp) fIntF.close() fDisp.close() comb.removeFromDomain() #Remove combination from the model.
def check(self, elements, nmbComb): '''Crack control.''' lmsg.error('limit state check not implemented.')
def getElementsPart(self): '''DEPRECATED (use getElements); return a list of the elements of the material line.''' lmsg.warning('MaterialLine.getElementsPart DEPRECATED; use getElements.') return self.getElements()
def checkAbscissa(self,x): if(x<0.0 or x>self.arcSpan): lmsg.warning('checkAbscissa: abscissa out of arc: x= '+str(x)+' (0.0,'+str(self.arcSpan)+')')
def appendUniformLoadOnLinesInRangeToLoadPattern(self): '''uniform loads on the lines in a list of grid ranges to the load pattern.''' for unifLin in self.unifLoadLinRng: lmsg.log('unifLoadLinRng: '+ unifLin.name) unifLin.appendLoadToLoadPattern(self.lPattern)
def dispLoadCaseBeamEl(self,loadCaseName='',setToDisplay=None,fUnitConv=1.0,elLoadComp='transComponent',elLoadScaleF=1.0,nodLoadScaleF=1.0,viewName='XYZPos',hCamFct=1.0,caption='',fileName=None,defFScale=0.0): '''Display the loads applied on beam elements and nodes for a given load case :param setToDisplay: set of beam elements to be represented :param fUnitConv: factor of conversion to be applied to the results (defaults to 1) :param elLoadComp: component of the loads on elements to be depicted [possible components: 'axialComponent', 'transComponent', 'transYComponent', 'transZComponent'] :param elLoadScaleF: factor of scale to apply to the diagram display of element loads (defaults to 1) :param nodLoadScaleF: factor of scale to apply to the vector display of nodal loads (defaults to 1) :param viewName: name of the view that contains the renderer (possible options: "XYZPos", "XPos", "XNeg","YPos", "YNeg", "ZPos", "ZNeg") (defaults to "XYZPos") :param hCamFct: factor that applies to the height of the camera position in order to change perspective of isometric views (defaults to 1). Usual values 0.1 to 10 :param caption: caption for the graphic :param fileName: name of the file to plot the graphic. Defaults to None, in that case an screen display is generated :param defFScale: factor to apply to current displacement of nodes so that the display position of each node equals to the initial position plus its displacement multiplied by this factor. (Defaults to 0.0, i.e. display of initial/undeformed shape) ''' if(setToDisplay): self.xcSet= setToDisplay else: lmsg.warning('QuickGraphics::displayLoadCaseBeamEl; set to display not defined; using previously defined set (total if None).') print 'xcSet', self.xcSet.name preprocessor= self.feProblem.getPreprocessor loadPatterns= preprocessor.getLoadLoader.getLoadPatterns loadPatterns.addToDomain(loadCaseName) defDisplay= self.getDisplay(vwName=viewName,hCamF= hCamFct) grid= defDisplay.setupGrid(self.xcSet) defDisplay.defineMeshScene(None,defFScale) orNodalLBar='H' #default orientation of scale bar for nodal loads # element loads print 'scale=',elLoadScaleF,'fUnitConv=',fUnitConv,'loadPatternName=',loadCaseName,'component=',elLoadComp diagram= lld.LinearLoadDiagram(scale=elLoadScaleF,fUnitConv=fUnitConv,loadPatternName=loadCaseName,component=elLoadComp) diagram.addDiagram(preprocessor) if (diagram.valMax > -1e+99) or (diagram.valMin<1e+99): defDisplay.appendDiagram(diagram) orNodalLBar='V' # nodal loads vField=lvf.LoadVectorField(loadPatternName=loadCaseName,fUnitConv=fUnitConv,scaleFactor=nodLoadScaleF,showPushing= True) # loadPatterns= preprocessor.getLoadLoader.getLoadPatterns lPattern= loadPatterns[loadCaseName] count= 0 if(lPattern): count=vField.dumpNodalLoads(preprocessor,lp=loadPatterns[loadCaseName],defFScale=defFScale) else: lmsg.error('load pattern: '+ loadCaseName + ' not found.') if count >0: vField.setupActor() defDisplay.renderer.AddActor(vField.actor) vField.creaColorScaleBar(orientation=orNodalLBar) defDisplay.renderer.AddActor2D(vField.scalarBar) defDisplay.displayScene(caption=caption,fName=fileName)
def plotFigures(self,preprocessor,figDefinitionList,LatexFigsFilename,LatexListFilename): lmsg.warning('plotFigures DEPRECATED; use displayFigures.') self.displayFigures(figDefinitionList,LatexFigsFilename,LatexListFilename)
def setControlPoints(self): '''Set the five equally spaced points in the beam where the moment Mz will be evaluated in order to obtain the moment gradient factor involved in the calculation of the lateral-torsional buckling reduction factor. That moment gradient factor will be calculated following the general expression proposed by A. López, D. J. Yong, M. A. Serna. An attribute of EC3Beam is created, named 'contrPnt' that contains a list of five tuples (elem,relativDist), each of which contains the element of the beam nearest to one control-point and the relative distance from this control point to the first node of the element. The method also creates the attributes 'length' and 'elemSet' that represent the lenght of the beam and the set of elements included in it. ''' if self.lstLines: lstLn = self.lstLines pointsHandler = lstLn[ 0].getPreprocessor.getMultiBlockTopology.getPoints lstP3d = [ pointsHandler.get(l.getKPoints()[0]).getPos for l in lstLn ] lstP3d.append(pointsHandler.get(lstLn[-1].getKPoints()[1]).getPos) elif self.lstPoints: lstP3d = [p.getPos for p in self.lstPoints] lstLn = [ smg.get_lin_2Pts(self.lstPoints[i], self.lstPoints[i + 1]) for i in range(len(self.lstPoints) - 1) ] lstLn.append( smg.get_lin_2Pts(self.lstPoints[-2], self.lstPoints[-1])) else: lmsg.warning( 'Beam insufficiently defined: list of lines or points required' ) #set of elements included in the EC3beam s = lstLn[0].getPreprocessor.getSets.defSet(self.name + 'Set') self.elemSet = s.getElements for l in lstLn: for e in l.getElements(): self.elemSet.append(e) nmbSpac = 4 # number of divisions (five points equally spaced) pol = geom.Polyline3d() for p in lstP3d: pol.append(p) self.length = pol.getLength() nTotSegm = pol.getNumSegments() eqDistCP = .25 * self.length #equidistance between control points nmbCP = nmbSpac - 1 #number of intermediate control points cumLength = 0 #cumulate length in the polyline nmbSegm = 1 #starting number of segment self.contrPnt = list() firstPnt = lstP3d[0] self.contrPnt.append((lstLn[0].getNearestElement(firstPnt), 0)) for i in range(1, nmbCP + 1): #intermediate points lengthCP = i * eqDistCP - cumLength for j in range(nmbSegm, nTotSegm + 1): sg = pol.getSegment(j) LSegm = sg.getLength() if lengthCP < LSegm: pnt = sg.getPoint(lengthCP / LSegm) elem = lstLn[nmbSegm - 1].getNearestElement(pnt) elSegm = elem.getLineSegment(0) relDistPointInElem = (pnt - elSegm.getOrigen() ).getModulo() / elSegm.getLength() self.contrPnt.append((elem, relDistPointInElem)) break else: nmbSegm += 1 cumLength += LSegm lengthCP -= LSegm lastPnt = lstP3d[-1] self.contrPnt.append((lstLn[-1].getNearestElement(lastPnt), 1)) return
def muestraEscena(self): lmsg.warning('muestraEscena is deprecated. Use displayScene') self.displayScene('noCaption', None)
def append(self, ns): if (ns.nodeId in self): lmsg.warning('support for node: '+ns.nodeId+' redefined.') self[ns.nodeId]= ns
def plot2D(self, XaxisValues='X', axisEqualScale='N', symbolRougPoints=None, symbolFinePoints=None, symbolTendon=None, symbolLossFriction=None, symbolStressAfterLossFriction=None, symbolLossAnch=None, symbolStressAfterLossAnch=None): '''Return in a 2D graphic the results to which a symbol is assigned. Symbol examples: 'r-': red solid line, 'mo': magenta circle, 'b--': blue dashes, 'ks':black square,'g^' green triangle_up, 'c*': cyan star, ... :param XaxisValues: ='X' (default) to represent in the diagram X-axis the X coordinates of the tendon, ='Y' to represent in the diagram X-axis the Y coordinates of the tendon, ='XY' to represent in the diagram X-axis the coordinate by the projection of the curve on the XY plane :param axisEqualScale: ='Y', 'y','yes' or 'Yes' for equal aspect ratio (defaults to 'N') ''' if XaxisValues.upper() == 'X': XaxisCoord = self.fineCoordMtr[0] XaxisRoughCoord = self.roughCoordMtr[0] xLab = 'X' elif XaxisValues.upper() == 'Y': XaxisCoord = self.fineCoordMtr[1] YaxisRoughCoord = self.roughCoordMtr[1] xLab = 'Y' elif XaxisValues.upper() == 'XY': XaxisCoord = self.fineProjXYcoord x0, y0 = (self.roughCoordMtr[0][0], self.roughCoordMtr[1][0]) XaxisRoughCoord = ((self.roughCoordMtr[0] - x0)**2 + (self.roughCoordMtr[1] - y0)**2)**(0.5) xLab = 'XYproj' else: lmsg.warning( "Wrong value for XaxisValues ('X','Y','S'): X coordinates are represented in the figure" ) fig = plt.figure() ax2d = plt.subplot(111) if symbolRougPoints: ax2d.plot(XaxisRoughCoord, self.roughCoordMtr[2], symbolRougPoints, label='Rough points') if symbolFinePoints: ax2d.plot(XaxisCoord, self.fineCoordMtr[2], symbolFinePoints, label='Interpolated points (spline)') if symbolTendon: ax2d.plot(XaxisCoord, self.fineCoordMtr[2], symbolTendon, label='Tendon') if symbolLossFriction: ax2d.plot(XaxisCoord, self.lossFriction, symbolLossFriction, label='Immediate loss due to friction') if symbolStressAfterLossFriction: ax2d.plot(XaxisCoord, self.stressAfterLossFriction, symbolStressAfterLossFriction, label='Stress after loss due to friction') if symbolLossAnch: ax2d.plot(XaxisCoord, self.lossAnch, symbolLossAnch, label='Immediate loss due to anchorage slip') if symbolStressAfterLossAnch: ax2d.plot(XaxisCoord, self.stressAfterLossAnch, symbolStressAfterLossAnch, label='Stress after loss due to anchorage slip') ax2d.legend() ax2d.set_xlabel(xLab) if str.lower(axisEqualScale[0]) == 'y': ax2d.axis('equal') return fig, ax2d
def appendPunctualLoadsToLoadPattern(self,nodes): '''Append punctual loads to the load pattern.''' for cpunt in self.pointLoad: lmsg.log('pointLoad: '+ cpunt.name) cpunt.appendLoadToLoadPattern(nodes,self.lPattern)
def plot(self, defDisplay, fName=None, caption=''): lmsg.warning('ExtrapolatedScalarField.plot is DEPRECATED use display.') self.display(defDisplay, fName, caption, deform)
def appendInertialLoadsToCurrentLoadPattern(self): for pp in self.inercLoad: lmsg.log('inercLoad: '+ pp.name) pp.appendLoadToCurrentLoadPattern()
def plot(self, defDisplay, fName=None, caption=''): lmsg.warning('ExtrapolatedProperty.plot is DEPRECATED use display.') self.display(defDisplay, fName, caption)
def appendRanges(self,ijkRangeList): if(ijkRangeList.grid==self.grid): self.ranges.extend(ijkRangeList.ranges) else: lmsg.error("Error: reference grids are not the same.")
def displayElementalLoads(self, preprocessor,loadPattern, color, fScale): loadPattern.addToDomain() eleLoadIter= loadPattern.loads.getElementalLoadIter eleLoad= eleLoadIter.next() lmsg.error('displayElementalLoads not implemented.')
combs = cargas.getLoadCombinations comb = combs.newLoadCombination("COMB", "1.33*A+1.5*B") #We add the load case to domain. cargas.addToDomain("COMB") import os from miscUtils import LogMessages as lmsg fname = os.path.basename(__file__) # Solution analisis = predefined_solutions.simple_static_linear(feProblem) result = analisis.analyze(1) os.system("rm -f /tmp/combinacion04.db") lmsg.error(fname + ' test in QUARANTINE; SQLite interface debugging needed.') exit(-1) db = feProblem.newDatabase("SQLite", "/tmp/combinacion04.db") db.save(100) feProblem.clearAll() db.restore(100) nodes = preprocessor.getNodeLoader nod2 = nodes.getNode(2) deltax = nod2.getDisp[0] deltay = nod2.getDisp[2] elements = preprocessor.getElementLoader
def getVplRdy(self): '''Return y direction (web direction) plastic shear resistance''' if (self.shearBucklingVerificationNeeded()): lmsg.warning('section needs shear buckling verification.') return self.getAvy() * (self.steelType.fy / math.sqrt(3)) / self.steelType.gammaM0()
f1 = preprocessor.getSets.getSet("f1") nodes = preprocessor.getNodeHandler node = f1.getNodeIJK(1, NumDivI / 2 + 1, NumDivJ / 2 + 1) # print "Central node: ", node.tag # print "Central node coordinates: ", node.getCoo # print "Central node displacements: ", node.getDisp UZ = node.getDisp[2] UZTeor = -7.25 ratio1 = (abs((UZ - UZTeor) / UZTeor)) ratio2 = (abs((nElems - 64) / 64)) ''' print "UZ= ",UZ print "Number of nodes: ",nNodes print "Number of elements: ",nElems print "ratio1: ",ratio1 print "ratio2: ",ratio2 ''' import os from miscUtils import LogMessages as lmsg fname = os.path.basename(__file__) if (abs(ratio1) < 0.18) & (abs(ratio2) < 1e-9): print "test ", fname, ": ok." else: lmsg.error(fname + ' ERROR.')
def defSeccShElastica2d(preprocessor, defSecc): lmsg.warning('DEPRECATED; use object\'s method defSeccShElastica2d') return defSecc.defSeccShElastica2d(preprocessor)
def plotMultiBlockModel(self, xcSet, fName, caption=''): lmsg.warning('plotMultiBlockModel DEPRECATED; use displayBlocks.') self.displayBlocks(xcSet, fName, caption)
def plot2D(self, XaxisValues='X', axisEqualScale='N', symbolRougPoints=None, symbolFinePoints=None, symbolTendon=None, resultsToPlot=list()): '''Return in a 2D graphic the results to which a symbol is assigned. Symbol examples: 'r-': red solid line, 'mo': magenta circle, 'b--': blue dashes, 'ks':black square,'g^' green triangle_up, 'c*': cyan star, ... :param XaxisValues: ='X' (default) to represent in the diagram X-axis the X coordinates of the tendon, ='Y' to represent in the diagram X-axis the Y coordinates of the tendon, ='XY' to represent in the diagram X-axis the coordinate by the projection of the curve on the XY plane :param axisEqualScale: ='Y', 'y','yes' or 'Yes' for equal aspect ratio (defaults to 'N') :param resultsToPlot: list of results to plot. Each result to be displayed is input with the following parameters: (matRes,symb,label), where: - matRes: is the matrix of dimension 1*number of elements in the tendon with the value of the result for each of those elements - symb: is the symbol to use for representing this result - label: is the text to label this result ''' if XaxisValues.upper() == 'X': XaxisCoord = self.fineCoordMtr[0] XaxisRoughCoord = self.roughCoordMtr[0] xLab = 'X' elif XaxisValues.upper() == 'Y': XaxisCoord = self.fineCoordMtr[1] YaxisRoughCoord = self.roughCoordMtr[1] xLab = 'Y' elif XaxisValues.upper() == 'XY': XaxisCoord = self.fineProjXYcoord x0, y0 = (self.roughCoordMtr[0][0], self.roughCoordMtr[1][0]) XaxisRoughCoord = ((self.roughCoordMtr[0] - x0)**2 + (self.roughCoordMtr[1] - y0)**2)**(0.5) xLab = 'XYproj' else: lmsg.warning( "Wrong value for XaxisValues ('X','Y','S'): X coordinates are represented in the figure" ) fig = plt.figure() ax2d = plt.subplot(111) if symbolRougPoints: ax2d.plot(XaxisRoughCoord, self.roughCoordMtr[2], symbolRougPoints, label='Rough points') if symbolFinePoints: ax2d.plot(XaxisCoord, self.fineCoordMtr[2], symbolFinePoints, label='Interpolated points (spline)') if symbolTendon: ax2d.plot(XaxisCoord, self.fineCoordMtr[2], symbolTendon, label='Tendon') for res in resultsToPlot: ax2d.plot(XaxisCoord, res[0], res[1], label=res[2]) ax2d.legend() ax2d.set_xlabel(xLab) if str.lower(axisEqualScale[0]) == 'y': ax2d.axis('equal') return fig, ax2d