def defElasticSection1d(self, preprocessor, material): ''' Return an elastic section appropiate for truss analysis. :param preprocessor: preprocessor object. :param material: material constitutive model (for which E is the Young's modulus) ''' if (not self.xc_material): materialHandler = preprocessor.getMaterialHandler if (materialHandler.materialExists(self.sectionName)): lmsg.warning("Section: " + self.sectionName + " already defined.") self.xc_material = materialHandler.getMaterial( self.sectionName) else: self.xc_material = typical_materials.defElasticSection1d( preprocessor, self.sectionName, self.A(), material.E, linearRho=material.rho * self.A()) else: lmsg.warning('Material: ' + self.sectionName + ' already defined as:' + str(self.xc_material)) return self.xc_material
feProblem = xc.FEProblem() preprocessor = feProblem.getPreprocessor nodes = preprocessor.getNodeHandler # Problem type modelSpace = predefined_spaces.StructuralMechanics3D(nodes) # nodes.defaultTag= 1 # First node number. n1 = nodes.newNodeXYZ(0, 0, 0) n2 = nodes.newNodeXYZ(l, 0, 0) # Materials definition trussScc = typical_materials.defElasticSection1d(preprocessor, "trussScc", A, E, linearRho=10.0 * A) # Element definition. elements = preprocessor.getElementHandler elements.dimElem = 3 # Three-dimensional space. elements.defaultMaterial = trussScc.name truss = elements.newElement("TrussSection", xc.ID([n1.tag, n2.tag])) constraints = preprocessor.getBoundaryCondHandler # Zero movement for node 1. modelSpace.fixNode000_000(n1.tag) # Zero movement for node 2. modelSpace.fixNode000_000(n2.tag)
E = 2.1e6 * 9.81 / 1e-4 # Elastic modulus alpha = 1.2e-5 # Thermal expansion coefficient of the steel A = 4e-4 # bar area expressed in square meters AT = 10 # Temperature increment (Celsius degrees) # Problem type feProblem = xc.FEProblem() preprocessor = feProblem.getPreprocessor nodes = preprocessor.getNodeHandler modelSpace = predefined_spaces.SolidMechanics2D(nodes) nod1 = nodes.newNodeXY(0.0, 0.0) nod2 = nodes.newNodeXY(L, 0.0) # Materials definition scc = typical_materials.defElasticSection1d(preprocessor, "scc", A, E) # Elements definition elements = preprocessor.getElementHandler elements.defaultMaterial = scc.name elements.dimElem = 2 # Dimension of element space elements.defaultTag = 1 # Tag for the next element. truss = elements.newElement("CorotTrussSection", xc.ID([nod1.tag, nod2.tag])) # Constraints constraints = preprocessor.getBoundaryCondHandler spc1 = constraints.newSPConstraint(nod1.tag, 0, 0.0) spc2 = constraints.newSPConstraint(nod1.tag, 1, 0.0) spc3 = constraints.newSPConstraint(nod2.tag, 0, 0.0) spc4 = constraints.newSPConstraint(nod2.tag, 1, 0.0)