Model#

The Model class is an alternative to the model command in Python that creates an isolated model that is safe from global state corruption. An instance of Model has all of the standard OpenSees modeling commands exposed as methods.

class xara.Model(ndm, ndf=None, group=None, space=None, echo_file=None)#

Create an isolated model for given number of dimensions and number of DOFs.

Parameters:
ndm: integer

number of dimensions

ndf: integer

number of dofs (optional, default ndm*(ndm+1)/2)

echo_file: FileLike

Optional file handle to write command history to. This allows Python scripts to be converted exactly to Tcl. See echo-file for details.

ndm: int#

The number of dimensions in the model.

ndf: int#

The number of degrees-of-freedom at each node.

The Model class prevents inadvertent corruption of global state that may be caused when using the model command that was implemented by older finite element interpreters. Each instance of a Model owns a unique instance of an interpreter which can only be manipulated through the instance itself. This interpreter can be be used from Python to invoke either Tcl or Python commands. These additional commands are described in the subsequent sections.

Examples#

The following examples demonstrate the creation of a Basic model builder that will create nodes with in 2D space (ndm of 2) and with ndf=3 degrees-of-freedom at each node.

import xara
model = xara.Model(ndm=2, ndf=3)

model.node(1, 2.0, 3.0)
...

References#

Code Developed by: Claudio M. Perez