run automatically
Moderators: silvia, selimgunay, Moderators
-
- Posts: 1
- Joined: Sat Nov 15, 2008 11:08 pm
run automatically
Dear all,
Would any one help me to find out how Opensees runs automatically by writing some code into applicable proggraming software?
I'm going to perform some repeated analysis by changing a parameter, but it take much time to analyze individually.
thanks
Would any one help me to find out how Opensees runs automatically by writing some code into applicable proggraming software?
I'm going to perform some repeated analysis by changing a parameter, but it take much time to analyze individually.
thanks
-
- Posts: 73
- Joined: Tue Feb 20, 2007 6:48 am
- Location: IIEES
- Contact:
yes, look at a presentation of mine about parameter studies in the past opensees workshops.
http://opensees.berkeley.edu/workshop/OpenSeesDays.html
http://opensees.berkeley.edu/workshop/OpenSeesDays.html
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
-
- Posts: 73
- Joined: Tue Feb 20, 2007 6:48 am
- Location: IIEES
- Contact:
also, you can use your prefer programing language to create input file. for example I like python and this an example:
Code: Select all
import string
import os
import math
def findNode(n1,n2,n3,n4,nodeBox):
if len(nodeBox) == 0:
find = 0;
for item in nodeBox:
if n1 == item or n2 == item or n3 == item or n4 == item:
find = 1
break
find = 0
return find
def createSoilNodes(numXnode,numYnode,nodeNum,xSize,ySize,x1,x2,y1,nodesFile):
f1 = open(nodesFile,"w")
nodeBox = [];
for j in range(1,numYnode+1):
for i in range(1,numXnode+1):
nodeNum = nodeNum + 1;
xdim = (i-1)*xSize; ydim = (j-1)*ySize
if x1 < xdim < x2 and ydim > y1:
nodeBox.append(nodeNum)
continue
line = 'node\t'+str(nodeNum)+'\t'+str(xdim)+'\t'+str(ydim)+'\n'
f1.write(line)
f1.close()
return nodeBox,nodeNum
def createBasePlateNodes(numXnode,numYnode,nodeNum,xSize,ySize,x1,x2,y1,y2,nodesFile):
f1 = open(nodesFile,"w")
nodeBox = [];
for j in range(1,numYnode+1):
for i in range(1,numXnode+1):
nodeNum = nodeNum + 1;
xdim = (i-1)*xSize + x1; ydim = (j-1)*ySize + y1;
if x1 < xdim < x2 and y1 < ydim < y2 :
nodeBox.append(nodeNum)
continue
line = 'node\t'+str(nodeNum)+'\t'+str(xdim)+'\t'+str(ydim)+'\n'
f1.write(line)
f1.close()
return nodeBox,nodeNum
def createSoilElements(numXele,numYele,eleNum,nodeBox,elementsFile):
f1 = open(elementsFile,"w")
for i in range(1,numXele+1):
for j in range(1,numYele+1):
eleNum = eleNum + 1;
n1 = i + (j - 1) * numXnode
n2 = n1 + 1
n3 = i + j * numXnode
n4 = n3 + 1
if findNode(n1,n2,n3,n4,nodeBox):
continue
line = 'element quad\t'+str(eleNum)+'\t'+str(n1)+'\t'+str(n2)+'\t'+str(n4)+'\t'+str(n3)+'\t'+str(1.0*m*scale)+'\t'+'''"PlaneStrain" 1 0 0. '''+str(gravX)+'\t'+str(gravY)+'\n'
f1.write(line)
f1.close()
diameter = 120.0;
height = 60.0;
lenBasePlate = 20.0;
buryDepth = 6.0;
xSize = 5.0/1.0;
if buryDepth == 0.0:
ySize = 3.0
else :
ySize = buryDepth / 2.;
scale = 1;
numStory = 20;
typeAnalys = 'ssi'
xiI = .038;
xiJ = .045;
numXele = int(diameter/xSize);
numYele = int(height/ySize);
numXnode = numXele + 1;
numYnode = numYele + 1;
xLeftBasePlate = (diameter-lenBasePlate)/2.
xRightBasePlate = xLeftBasePlate + lenBasePlate
yBasePlate = (height-buryDepth)
nodeNum = 0;
eleNum = 0;
###################################
# Units.tcl #
###################################
#Basic units
m = 1.0; # meter for length
sec = 1.0; # second for time
ton = 1.0; # ton for mass
kN = 1.0 ;# kilo-Nioton for force
# length
cm = 0.01 * m;
mm = 0.001 * m;
# mass
kg = 0.001 * ton
# and set the gravity
g = -9.81 * m/(sec**2); # gravitational constant in m/sec^2
# force
N = 0.001 * kN; # Newton for force
kgF = -g*kg
tonF = 1000*kgF
# pressure
Pa = 1.0*N/(m**2);
kPa = 1000.0*Pa;
MPa = 1000000.0*Pa;
GPa = 1000.0*MPa
# set the pi value
pi = math.pi;
###########################################
# Material Parameters
###########################################
rho = 1.9*ton/m**3; # for kinematic interaction set rho0 = 0
gravX = 0;#1.9*ton/pow(m,3)
gravY = g*rho ;# soil mass density
#================================================================
#Elastic-plastic model
#================================================================
cohesion = 10*kPa*scale
peakShearStrain = 0.1 ;
nu_soil = 0.4 ;#Poisson's Ratio
G = 18.61e4*kPa*scale
E_soil = 2*(1+nu_soil)*G
B = E_soil/(3*(1-2*nu_soil)) ;
press = 0 ;# isotropic consolidation pressure on quad element(s)
# uniaxialMaterial parameters
Vs = math.sqrt(G/rho)
dampH = rho*Vs ;
BnodeDampH = ySize*1*m*dampH*scale
# input motion parameters
accMul = -g ;# acc. multiplier (m/s/s)
accFolder = '/home/ebi/Desktop/realSsi/GMdir/testResult/1' ;
accNam = accFolder+'/test49/_49tab30.008' ;# acc. file name if imposed motion is read from file
accDt = 0.033 ;# dt for input acc
deltaT = 0.02 ;# time step for analysis
numSteps = 1000 ;# Number of analysis steps
gamma = 0.5 ;# Newmark integration parameter
massProportionalDamping = 0.0 ;
InitStiffnessProportionalDamping = 0.002 ;
# ------------------------------------------------------------------------------------------------------------------------------------------
# creat parameters file
fileParameter = 'parameters.tcl'
parameterFile = open(fileParameter,"w")
parameterFile.write('set pi '+str(pi)+'\n')
parameterFile.write('set deltaT '+str(deltaT)+'\n')
parameterFile.write('set xiI '+str(xiI)+'\n')
parameterFile.write('set xiJ '+str(xiJ)+'\n')
parameterFile.write('set numSteps '+str(numSteps)+'\n')
parameterFile.write('set saveFolder output'+'\n')
parameterFile.write('set scale '+str(scale)+'\n')
parameterFile.write('set numStory '+str(numStory)+'\n')
parameterFile.close()
# ------------------------------------------------------------------------------------------------------------------------------------------
# creat nodes file
soilNodesFile = 'soilNodes.tcl'
nodeBoxSoil,nodeNumSoil = createSoilNodes(numXnode,numYnode,nodeNum,xSize,ySize,xLeftBasePlate,xRightBasePlate,yBasePlate,soilNodesFile)
print nodeBoxSoil
# ------------------------------------------------------------------------------------------------------------------------------------------
# creat elements file
soilElementsFile = 'soilElements.tcl'
createSoilElements(numXele,numYele,eleNum,nodeBoxSoil,soilElementsFile)
# ------------------------------------------------------------------------------------------------------------------------------------------
# creat soilMaterials file
soilMaterialsFile = 'soilMaterials.tcl'
soilMat = open(soilMaterialsFile,"w")
ndmaterial = 'nDMaterial PressureIndependMultiYield 1 2'+'\t'+str(rho)+'\t'+str(G)+'\t'+str(B)+'\t'+str(cohesion)+'\t'+str(peakShearStrain)+'\t'+'21.4 80 0 -9 1.e-06 1 3.16e-06 0.913 1.e-05 0.761 3.16e-05 0.565 1.e-04 0.4 3.16e-04 0.261 1.e-03 0.152 3.16e-03 0.076 1.e-02 0.037\n'
# Define Spring and Damper parameters
uniaxial = 'uniaxialMaterial Elastic 2 0'+'\t'+str(BnodeDampH)
soilMat.write(ndmaterial)
soilMat.write(uniaxial)
soilMat.close()
# ------------------------------------------------------------------------------------------------------------------------------------------
# creat input motion file
inputMotionFile = 'inputMotion.tcl'
earth = open(inputMotionFile,"w")
uniform = '''pattern UniformExcitation 1 1 -accel "Series -factor '''+'\t'+str(accMul)+'\t-filePath '+str(accNam)+'\t-dt '+str(accDt)+'''"'''
earth.write(uniform)
earth.close()
# ------------------------------------------------------------------------------------------------------------------------------------------
##recorder for nodal displacement along the vertical center line.
recorderFile = 'recorder.tcl'
recordersFile = open(recorderFile,"w")
for i in range(0,numYnode-int(buryDepth/ySize)):
nodeID = numXnode/2 + i * numXnode
recordersFile.write('recorder Node -file ./$saveFolder/disp'+str(nodeID)+' -time -node '+str(nodeID)+' -dof 1 2 -dT $deltaT disp\n')
recordersFile.write('recorder Node -file ./$saveFolder/acc'+str(nodeID)+' -time -node '+str(nodeID)+' -dof 1 2 -dT $deltaT accel\n')
## structure node recorder
#recorder Node -file ./$dir/strucDisp -time -node $nodeID -dof 1 -dT $deltaT disp
#recorder Node -file ./$dir/strucAcc -time -node $nodeID -dof 1 -dT $deltaT accel
##recorder for element output along the vertical center line.
for i in range(1,numYnode-int(buryDepth/ySize)):
ele = numXele - numXele/2 + (i -1) * numXele
recordersFile.write('recorder Element -ele '+str(ele)+' -time -file ./$saveFolder/stress'+str(ele)+' material 1 stress\n')
recordersFile.write('recorder Element -ele '+str(ele)+' -time -file ./$saveFolder/strain'+str(ele)+' material 1 strain\n')
recordersFile.write('recorder Element -ele '+str(ele)+' -file ./$saveFolder/strain'+str(ele)+' -dT 1000 material 1 backbone 50\n')
recordersFile.close()
ssiFile = open('ssi.tcl',"w")
ssiFile.write('###################################\n')
ssiFile.write('# unit ton-m-sec-kN\n')
ssiFile.write('####################################\n')
ssiFile.write('wipe\n')
ssiFile.write('\n')
ssiFile.write('source '+fileParameter+'\n')
ssiFile.write('\n')
ssiFile.write('file mkdir $saveFolder;\n')
ssiFile.write('# ################################\n')
ssiFile.write('# create the modelbuilder\n')
ssiFile.write('# #################################\n')
ssiFile.write('model BasicBuilder -ndm 2 -ndf 2\n')
ssiFile.write('\n')
ssiFile.write('source '+soilMaterialsFile+'\n')
ssiFile.write('\n')
ssiFile.write('source '+soilNodesFile+'\n')
ssiFile.write('\n')
ssiFile.write('source '+soilElementsFile+'\n')
ssiFile.write('\n')
ssiFile.write('fixY 0.0 1 1\n')
ssiFile.write('\n')
ssiFile.write('updateMaterialStage -material 1 -stage 0\n')
ssiFile.write('\n')
ssiFile.write('set lambda [eigen 2];\n')
ssiFile.write('\n')
ssiFile.write('for {set mod 1} {$mod <= 2} {incr mod 1} {\n')
ssiFile.write(' set Lambda [lindex $lambda [expr $mod-1]];\n')
ssiFile.write(' set W$mod [expr pow($Lambda,0.5)];\n')
ssiFile.write('}\n')
ssiFile.write('\n')
ssiFile.write('set lambda [eigen 1]\n')
ssiFile.write('set wn [expr pow($lambda,.5)]\n')
ssiFile.write('set period [expr 2*$pi/$wn]\n')
ssiFile.write('puts "period is $period"\n')
ssiFile.write('\n')
ssiFile.write('#############################################################\n')
ssiFile.write('# GRAVITY APPLICATION (elastic behavior)\n')
ssiFile.write('# create the SOE, ConstraintHandler, Integrator, Algorithm and Numberer\n')
ssiFile.write('system ProfileSPD\n')
ssiFile.write('test NormDispIncr 1.e-5 10 0\n')
ssiFile.write('algorithm ModifiedNewton\n')
ssiFile.write('constraints Transformation\n')
ssiFile.write('integrator LoadControl 1 1 1 1\n')
ssiFile.write('numberer RCM\n')
ssiFile.write('\n')
ssiFile.write('# create the Analysis\n')
ssiFile.write('analysis Static\n')
ssiFile.write('analyze 1\n')
ssiFile.write('\n')
ssiFile.write('source '+recorderFile+'\n')
ssiFile.write('\n')
ssiFile.write('# rayleigh coefficient\n')
ssiFile.write('set massDamping [expr 2*($xiI*$W2-$xiJ*$W1)/($W2/$W1-$W1/$W2)]\n')
ssiFile.write('set stiffnessDamping [expr 2*($xiJ*$W2-$xiI*$W1)/(pow($W2,2) - pow($W1,2))]\n')
ssiFile.write('\n')
ssiFile.write('puts "massDamping = $massDamping , stiffnessDamping = $stiffnessDamping"\n')
ssiFile.write('rayleigh $massDamping 0.0 $stiffnessDamping 0.0\n')
ssiFile.write('\n')
ssiFile.write('# switch the material to plastic\n')
ssiFile.write('updateMaterialStage -material 1 -stage 1\n')
ssiFile.write('\n')
ssiFile.write('#================================================================\n')
ssiFile.write('# stage 2 -- pushover analysis\n')
ssiFile.write('#================================================================\n')
ssiFile.write('#############################################################\n')
ssiFile.write('# NOW APPLY LOADING SEQUENCE AND ANALYZE\n')
ssiFile.write('# rezero time\n')
ssiFile.write('setTime 0.0\n')
ssiFile.write('wipeAnalysis\n')
ssiFile.write('\n')
ssiFile.write('source '+inputMotionFile+'\n')
ssiFile.write('\n')
ssiFile.write('source /home/ebi/Desktop/realSsi/libFile/display.tcl\n')
ssiFile.write('# create the Analysis\n')
ssiFile.write('constraints Transformation\n')
ssiFile.write('test NormDispIncr 1.e-5 10 0\n')
ssiFile.write('numberer RCM\n')
ssiFile.write('algorithm Newton\n')
ssiFile.write('system ProfileSPD\n')
ssiFile.write('integrator Newmark 0.5 0.25 0.0 0.0 0.002 0.0\n')
ssiFile.write('analysis VariableTransient\n')
ssiFile.write('\n')
ssiFile.write('#analyze\n')
ssiFile.write('set startT [clock seconds]\n')
ssiFile.write('analyze $numSteps $deltaT [expr $deltaT/100] $deltaT 5\n')
ssiFile.write('set endT [clock seconds]\n')
ssiFile.write('puts "Execution time: [expr $endT-$startT] seconds."\n')
ssiFile.write('\n')
ssiFile.write('wipe #flush ouput stream\n')
ssiFile.write('\n')
ssiFile.close()
# NOW WE RUN OPENSEES
osFile = "os ssi.tcl"
os.system(osFile)
operating system: Debian Gnu/Linux lenny 64Bit debian (DOT) org/
email : e.roknabadi (AT) iiees.ac.ir
email : e.roknabadi (AT) iiees.ac.ir