# Getting Started with OpenSees -- Lateral Loads -- Dynamic ground motion
__NOTOC__
The following commands assume that the example.tcl and the gravityloads.tcl files have been run. The wipe command should be used at the beginning of the input to clear any previous OpenSees-objects definition:
```Tcl wipe source example.tcl source gravityloads.tcl ```
The dynamic ground-motion analysis is a transient, rather than static, type of analysis. Therefore, most of the analysis components should be redefined.
First of all, the load pattern needs to be defined. The load pattern here consists of defining an acceleration time-history applied at the support nodes. The time-history is defined in a file named BM68elc.th, taken from the PEER strong-motion database. The first lines of this file are:
PACIFIC ENGINEERING AND ANALYSIS STRONG-MOTION DATA BORREGO MOUNTAIN 04/09/68 0230, EL CENTRO ARRAY #9, 270 ACCELERATION TIME HISTORY IN UNITS OF G NPTS= 4000, DT= .01000 SEC -.1368849E-02 -.1659410E-02 -.1466880E-02 -.6865326E-03 -.6491235E-03 -.6172128E-03 -.5942289E-03 -.5720329E-03 -.5517003E-03 -.5367939E-03 -.5300330E-03 -.5315104E-03 -.5389920E-03 -.5492582E-03 -.5592027E-03 -.5659958E-03 -.5672101E-03 -.5617805E-03 -.5502959E-03 -.5347288E-03 -.5176619E-03 -.5013709E-03 -.4873454E-03 -.4763228E-03 -.4683559E-03 -.4626830E-03 -.4579708E-03 -.4512405E-03 -.4376077E-03 -.4130071E-03 -.3772566E-03 -.3363394E-03 -.3030926E-03 -.2926074E-03 -.3144186E-03 -.3668375E-03 -.4373818E-03 -.5104884E-03 -.5745380E-03 -.6248976E-03
A number of tcl scripts are available to the user at the openSees web site which have been written for specific tasks. The file ReadSMDFile.tcl is a script procedure which parses a ground motion record from the PEER strong motion database by finding dt in the record header, then echoing data values to the output file. This file should be saved in the same directory as the OpenSees executable:
```Tcl
proc ReadSMDFile {inFilename outFilename dt} {
upvar $dt DT
if [catch {open $inFilename r} inFileID] { puts stderr "Cannot open $inFilename for reading" } else {
set outFileID [open $outFilename w]
set flag 0
foreach line [split [read $inFileID] \n] { if {[llength $line] == 0} {
continue } elseif {$flag == 1} {
puts $outFileID $line } else {
foreach word [split $line] {
if {$flag == 1} { set DT $word break }
if {[string match $word "DT="] == 1} { set flag 1 } } } }
close $outFileID
close $inFileID } }
```
Once this file has been created, it can be read-in by the input file and used in the analysis procedure, where an acceleration time-series is defined and used in a UniformExcitation load pattern:
```Tcl Series -dt $dt -filePath $fileName <-factor $cFactor> pattern UniformExcitation $patternTag $dir -accel (TimeSeriesType arguments) <-vel0 $ver0>
source ReadSMDFile.tcl ReadSMDFile BM68elc.th BM68elc.acc dt set accelSeries "Series -dt $dt -filePath BM68elc.acc -factor 1"; pattern UniformExcitation 2 1 -accel $accelSeries ```
The stiffness and mass-proportional damping factors can then be defined using the rayleigh command:
rayleigh $alphaM $betaK $betaKinit $betaKcomm There are three different stiffnesses the user can use, the current value, the initial value, or the stiffness at the last committed state (which is what is used here):
```Tcl
rayleigh 0. 0. 0. [expr 2*0.02/pow([eigen 1],0.5)] The various analysis components are defined as follows:
wipeAnalysis constraints Plain numberer RCM system UmfPack test NormDispIncr 1.0e-8 10 algorithm Newton integrator Newmark 0.5 0.25 analysis Transient ```
In a transient analysis, the analyze command also requires a time step. This time step does not have to be the same as the input ground motion. The number of time steps is equal to the total duration of the analysis (10 seconds) divided by the time step (0.02):
```Tcl analyze [expr 10/0.02] 0.02 ```
Return to Getting Started with OpenSees