Skip to main content

Python helpers for writing OpenSees scripts.

Project description

Python wrappers and helpers for (Tcl) OpenSees analyses.

Installation

Conda:

conda install -c otaithleigh opswrapper

Usage

The objects provided in this package largely line up with their OpenSees Tcl counterparts. The general workflow is to create a list of objects, and then call str on them while printing to a file. Each entry in the list will become a line in the Tcl script, allowing for mixing of raw Tcl code and opswrapper objects.

Simple Example

import opswrapper as ops
model = []
model.append(ops.Model(ndm=2, ndf=3))
model.append(ops.Node(1, 0, 0))
model.append(ops.Node(2, 0, 10))
model.append(ops.material.Elastic(1, 29000))
model.append(ops.element.Truss(1, 1, 2, mat=1, A=10))
print(*model, sep='\n')

Output:

model basic -ndm 2 -ndf 3
node 1 0 0
node 2 0 10
uniaxialMaterial Elastic 1 29000
element truss 1 1 2 10 1

Formatting

Objects can be formatted via multiple ways. The simplest is to convert them to str:

>>> str(Elastic(1, 29000))
'uniaxialMaterial 1 29000'

A float format specifier may be specified when used with the built-in format commands:

>>> format(Elastic(1, 29000), 'e')
'uniaxialMaterial 1 2.900000e+4'
>>> f'{Elastic(1, 29000):.2e}'
'uniaxialMaterial 1 2.90e+04'

Specifiers for other numeric types may be passed using the tcl_code method:

>>> Elastic(1, 29000).tcl_code(int='4d')
'uniaxialMaterial Elastic    1 29000'

Defaults can be set on a global basis using base.set_global_format_spec, on a per-class basis using cls.set_class_format_spec, or on a per-object basis using self.set_format_spec:

>>> set_global_format_spec(float='#.3g')
>>> section.Elastic2D.set_class_format_spec(float='#.3g')
>>> s = section.Elastic2D(...)
>>> s.set_format_spec(float='#.3g')

Each of these methods return the previously-set modifiers if you wish to restore them later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opswrapper-1.0.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opswrapper-1.0.1-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file opswrapper-1.0.1.tar.gz.

File metadata

  • Download URL: opswrapper-1.0.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5

File hashes

Hashes for opswrapper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2fa9637e14f58dbc8c3891d3f436fab1f982fbbd0e643a65ab175b233354dce7
MD5 417028df402f21ceb4cf0df27fb51830
BLAKE2b-256 db7d1c0b6881d3395ee81283ae0842c2c23129863c32b04bc5adc9eeb29ca617

See more details on using hashes here.

File details

Details for the file opswrapper-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: opswrapper-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5

File hashes

Hashes for opswrapper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7366662a3f463c588306e166438487c8fb33ea0b576d625d4dea9a2f5103424
MD5 61b9300df3c73ced198a5fcfc6cac2b7
BLAKE2b-256 e97030162098a86576f0a9daf701f14330716246b3c47786863e2c689c23e18f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page