Initial Conditions

There are a couple ways to set initial conditions for nodal displacements and velocities in OpenSees. If you look at the end of this post, you’ll see the hard way to do it: set initial displacements as single point (sp) constraints in a load pattern, do one analysis step, then remove the load pattern prior to the response history analysis. You could do the same shenanigans with velocity.

But, when something is that complicated, there should be an easier way–use the setNodeDisp and setNodeVel commands. You just have to be sure to use the '-commit' option with these commands; otherwise, the initial conditions are only trial values that get overwritten on the first analysis step.

Below is a simple script for damped free vibration of an elastic SDF system.

import openseespy.opensees as ops

m = 1 # Mass
c = 0.1*m # Damping

# Period and stiffness
Tn = 2
k = m*(2*3.14159/Tn)**2


ops.node(1,0); ops.fix(1,1)
ops.node(2,0); ops.mass(2,m)


# Initial displacement and velocity
u0 = 1
v0 = -5


Tf = 10
dt = 0.01
Nsteps = int(Tf/dt)

for i in range(Nsteps):

The resulting displacement response history shows the initial conditions are enforced.

You can also use the setNodeAccel command to set initial acceleration for masses subjected to step forces. To automate the calculation of initial acceleration, first apply the force and compute reactions. The reactions command forces OpenSees to compute unbalanced nodal loads–prior to any analysis steps, the unbalance is equal to the applied loads. Finally, compute the initial acceleration using the nodeUnbalance and nodeMass commands, then set the nodal acceleration.


a0 = ops.nodeUnbalance(2,1)/ops.nodeMass(2,1)

for i in range(Nsteps):

This post focused on an SDF model, but it is straightforward to scale initial conditions up to larger models. Note that the automated calculation of initial acceleration assumes a diagonal mass matrix for the model.

Thanks to Tuan Nguyen for asking about initial accelerations in this post on the OpenSees Facebook group.

One thought on “Initial Conditions

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.