Skip to main content

A set of standard models for assessing structural and geotechnical problems

Project description

.. image::
:alt: Testing Status

.. image::
:alt: PyPi version

.. image::

.. image::
:alt: License


A set of python objects to represent physical objects for assessing structural and geotechnical problems

Attempting to solve the `Liskov Substitution Principle <>`_
problem for combining independently developed source
code in the fields of structural and geotechnical engineering.

Models represent states of physical objects, currently can not represent dynamic/changing states.

Model inheritance system

Every object contains a `type`, a `base_type` and a list of `ancestor_types`.

- `type` is the current type of the class or instance of the class
- `base_type` is what class should be considered as for standard operations such as saving and loading.
- `ancestor_types` is a list of the `type` of the ancestors of the class

Generation of new custom models

It is easiest to create a new object by inheriting from `sm.CustomObject`, as this contains the default parameters
needed for loading and saving the model.

If you chose not to use the default custom object, you must set the object `base_type` parameter to `"custom_object"`.

Loading a custom object

pass a dictionary to the `custom_object` parameter in the `sm.load_json` function, where the dictionary contains:
`custom={"<base_type>-<type>": Object}`.


.. code:: bash
pip install sfsimodels

Saving and loading models

.. code-block:: python
structure = models.Structure() # Create a structure object = 1 # Assign it an id = "sample building" # Assign it a name and other parameters
structure.h_eff = 10.0
structure.t_fixed = 1.0
structure.mass_eff = 80000.
structure.mass_ratio = 1.0 # Set vertical and horizontal masses are equal

ecp_output = files.Output() # Create an output object
ecp_output.add_to_dict(structure) # Add the structure to the output object = "test data"
ecp_output.units = "N, kg, m, s" # Set the units
ecp_output.comments = ""

p_str = json.dumps(ecp_output.to_dict(), skipkeys=["__repr__"], indent=4) # Assign it to a json string
objs = files.loads_json(p_str) # Load a json string and convert to a dictionary of objects
assert ct.isclose(structure.mass_eff, objs['buildings'][1].mass_eff) # Access the object

How do I get set up?

1. Run ``pip install -r requirements.txt``


Tests are run with pytest

* Locally run: ``pytest`` on the command line.

* Tests are run on every push using travis, see the ``.travis.yml`` file


To deploy the package to you need to:

1. Push to the *pypi* branch. This executes the tests on

2. Create a git tag and push to github, run: ```` or manually:

.. code:: bash
git tag 0.5.2 -m "version 0.5.2"
git push --tags origin pypi



Known bugs

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
sfsimodels-0.8.6.tar.gz (30.0 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page