This document provides installation instructions and usage examples.
API documentation is available at https://barischrooneyj.github.io/bridge-sim.
Table of Contents
If you are interested in using this library, please open an issue to ask any questions! Please open one issue per question. I welcome all feedback, so don’t hesitate to communicate any thoughts. Please star the project if you like it.
If you know what you’re doing and just want to see something run:
$ docker run -it barischrooneyj/bridge-sim:v0.0.5
$ pipenv run python example.py
Make sure you have Docker installed.
Then in a terminal run the following to jump into a Docker image that already has all dependencies installed:
$ docker run -it barischrooneyj/bridge-sim:v0.0.5
You are now in the /bridge-sim
directory of the Docker container. You can run the provided example file example.py
with pipenv run python example.py
. This will generate a file /root/docker.png
.
To copy docker.png
to your host system run the following commands in another terminal. The first command lists all running Docker containers. Copy the container ID and then use the docker cp
command to copy docker.png
to your host system.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d297a50ff165 barischrooneyj/bridge-sim:v0.0.5 "/bin/bash" 37 seconds ago Up 37 seconds vigorous_leavitt
$ docker cp d297a50ff165:/root/docker.png docker.png
To copy files to the /root
directory of the Docker container you can run docker cp local-files/ d297a50ff165:/root
. Run docker cp --help
or search the web for more information on Docker.
The Docker image that you enter with docker run
has OpenSees installed at /root/bin/OpenSees
. The bridge-sim
source code along with all installed Python dependencies are in /bridge-sim
. We have shown how to run the provided example.py
file but you could modify this file and run a different example, some examples are given below.
These instructions are if you are interested in developing the bridge-sim
software or if you cannot run bridge-sim
via Docker. A Python package will be published on PyPI at some point however hopefully one of the available methods should suffice in the meantime.
Make sure you have Python 3.7+ installed. And also install Pipenv. Perhaps with pip install --user pipenv
?
You will need OpenSees, you can download it here. If installing OpenSees on Linux the top answer here may be of some help.
Clone this repository and change into the directory:
$ git clone https://github.com/barischrooneyj/bridge-sim
$ cd bridge-sim
In the bridge-sim
directory install project dependencies with pipenv install
. If you have an error and are on the Windows OS you may need to pipenv install pypiwin32
. I do not run Windows so can be of limited help there.
A package is in the works.
A brief introduction to some of the Python classes provided. A Bridge
describes the material properties and geometry of a bridge. A FEMRunner
is capable of transforming a Bridge
along with some additional simulation parameters into a model file, running that file, and returning the responses from simulation. This project currently provides one instance of FEMRunner
which is called OSRunner
and is capable of running simulations with OpenSees. A Config
contains some additional global configuration but is also used as a container for a Bridge
and FEMRunner
. This is useful because all three of these objects are required in many situations and combining them into one object makes life a bit easier than passing these three objects around separately.
If you have managed to install the software then the next step is to run an example such as example.py. You will need to make sure that OpenSees is on your PATH, if you have followed the Docker installation instructions then this is already done for you. The file example.py can be run with pipenv run python example.py
.
Example bridge with a single point load applied.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim
config = configs.opensees_default(bridges.bridge_narrow)
point_loads = [model.PointLoad(x=5, z=0, load=100)]
responses = sim.responses.load(config, model.RT.YTrans, point_loads)
plot.contour_responses(config, responses, point_loads)
plot.top_view_bridge(config, piers=True)
plt.tight_layout()
plt.show()
Example bridge with a 4-axled vehicle on it, each wheel is a point load.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim, vehicle
config = configs.opensees_default(bridges.bridge_narrow, shorten_paths=True)
point_loads = vehicle.truck1.to_point_load_pw(
time=3.5, bridge=config.bridge, list=True)
responses = sim.responses.load(config, model.RT.YTrans, point_loads)
plot.contour_responses(config, responses, point_loads)
plot.top_view_bridge(config, piers=True)
plt.tight_layout()
plt.show()
Wide bridge with two supporting piers, two piers are settled. The first by 1.2 m and the second by 0.5 m.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim
config = configs.opensees_default(bridges.bridge_wide)
responses = sim.responses.load(
config,
model.RT.YTrans,
pier_settlement=[model.PierSettlement(0, 1.2), model.PierSettlement(1, 0.5)]
)
plot.contour_responses(config, responses)
plot.top_view_bridge(config, piers=True, lanes=True)
plt.tight_layout()
plt.show()
Like the pier settlement example but plotting multiple response types.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim
config = configs.opensees_default(bridges.bridge_wide)
plt.figure(figsize=(16, 10))
for subplot, response_type in enumerate([
model.RT.YTrans, model.RT.ZTrans,
model.RT.StrainXXB, model.RT.StrainZZB,
]):
responses = sim.responses.load(
config,
response_type,
pier_settlement=[model.PierSettlement(0, 1)],
).resize()
plt.subplot(2, 2, subplot + 1)
plot.contour_responses(config, responses)
plot.top_view_bridge(config, piers=True, lanes=True)
plt.title(response_type.name())
plt.tight_layout()
plt.show()
Like the first point-load example but with a really long and narrow bridge.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim
from bridge_sim.bridges import Bridge, Lane, MaterialDeck, MaterialSupport, Support
def new_bridge():
return Bridge(
name="example", # Name used to identify saved/loaded data.
length=40, # Length of this bridge.
width=3, # Width of this bridge.
supports=[
Support(
x=20, # X position of center of the support.
z=0, # Z position of center of the support.
length=2, # Length between support columns (X direction).
height=2, # Height from top to bottom of support.
width_top=2, # Width of support column at top (Z direction).
width_bottom=1, # Width of support column at bottom (Z direction).
materials=[ # List of materials for the support columns.
MaterialSupport(
density=0.7,
thickness=0.7,
youngs=40000,
poissons=0.2,
start_frac_len=0,
)
],
fix_z_translation=True,
fix_x_translation=True,
)
],
# List of materials for the bridge deck.
materials=[MaterialDeck(thickness=0.7, youngs=40000, poissons=0.2,)],
# List of lanes where traffic can drive on the bridge.
lanes=[Lane(-1, 1, True)],
)
config = configs.opensees_default(new_bridge)
point_loads = [model.PointLoad(x=18, z=0, load=100)]
responses = sim.responses.load(config, model.RT.YTrans, point_loads)
plot.contour_responses(config, responses, point_loads)
plot.top_view_bridge(config, piers=True)
plt.tight_layout()
plt.show()
Like the first static vehicle example, but this time with a custom vehicle.
import matplotlib.pyplot as plt
from bridge_sim import bridges, configs, model, plot, sim
from bridge_sim.model import Vehicle
new_vehicle = Vehicle(
# Load intensity of each axle.
kn=[5000, 4000, 4000, 5000, 7000],
# Distance between each pair of axles.
axle_distances=[2, 2, 2, 1],
# Width of each axle, distance between point loads.
axle_width=2.5,
# Speed of the vehicle.
kmph=20,
)
config = configs.opensees_default(bridges.bridge_narrow, shorten_paths=True)
point_loads = new_vehicle.to_point_load_pw(time=3.5, bridge=config.bridge, list=True)
responses = sim.responses.load(config, model.RT.YTrans, point_loads)
plot.contour_responses(config, responses, point_loads)
plot.top_view_bridge(config, piers=True)
plt.tight_layout()
plt.show()