Script to calculate nodal masses for elastic beam column elements. Not ideal, as it requires two input data files (nodes, elements), since I typically write these for other uses it worked ok for me. Hope its of some use...
Paul B.
******************************************************
proc EBCMasses {EL_WDensity grav NDfln0 EBCfln0 Massfln0} {
#EL_WDensity - Weight density of the EBC elements (input)
#grav - Gravity (input)
#NDfln - Node coordinate file name (input)
#EBCfln - EBC element filename (input)
#Massfln - Mass filename (ouput)
#This procedure calculates and applies lumped masses at beam-column element nodes.
#It requires two input files, a node coordinate file and an element file
#The node coordinate file should be formatted as lines of ID X Y Z
#The element file should consist of lines that are echoes of the EBC command, i.e.
#$eleTag $iNode $jNode $A $E $G $J $Iy $Iz $transfTag
#EL is an Element List, ND is a Node list, containing the input file data
#ND_ID is an array filled with node id's, ND_Mass is an array with masses, indexed to correspond to the nodes in ND_ID
set NDfln [open $NDfln0 r]
set EBCfln [open "$EBCfln0" r]
set Massfln [open $Massfln0 w]
#Form element list___________________________________________
set ELp [gets $EBCfln]
split $ELp
set NElems 1
while {1} {
set ELi [gets $EBCfln]
if {[eof $EBCfln] == 1} then {break}
set NElems [expr $NElems+1]
split $ELi
set EL [concat $ELp $ELi]
set ELp $EL
}
close $EBCfln
#Form node list______________________________________________
set NDp [gets $NDfln]
set NNDs 1
split $NDp
while {1} {
set NDi [gets $NDfln]
if {[eof $NDfln] == 1} then {break}
set NNDs [expr $NNDs+1]
split $NDi
set ND [concat $NDp $NDi]
set NDp $ND
}
close $NDfln
#Other data____________________________________________________
set ELL [llength $EL]
set NDL [llength $ND]
#puts "Number of elements $NElems" ;#Turned off as default
#puts "Number of nodes $NNDs" ;#Turned off as default
#Node ID Array and INitialize Node Mass Array__________________
for {set i 0} {$i < $NNDs} {incr i 1} {
set ND_ID($i) "[lindex $ND [expr 4*$i]]"
set ND_Mass($i) 0.
#puts "ND ID($i) = $ND_ID($i)" ;#Echo, turned off as default
}
#Each element, find node coords________________________________
for {set i 1} {$i <= $NElems} {incr i 1} {
set ELNum [lindex $EL [expr 10*($i-1)+0]]
set ni [lindex $EL [expr 10*($i-1)+1]]
set NDi_index -1
for {set j 1} {$j <= $NNDs} {incr j 1} {
set nn [lindex $ND [expr 4*($j-1)]]
if {$ni == $nn} {set NDi_index [expr 4*($j-1)];break}
}
set nj [lindex $EL [expr 10*($i-1)+2]]
set NDj_index -1
for {set j 1} {$j <= $NNDs} {incr j 1} {
set nn [lindex $ND [expr 4*($j-1)]]
if {$nj == $nn} {set NDj_index [expr 4*($j-1)];break}
}
set ni_x [lindex $ND [expr $NDi_index+1]]
set ni_y [lindex $ND [expr $NDi_index+2]]
set ni_z [lindex $ND [expr $NDi_index+3]]
set nj_x [lindex $ND [expr $NDj_index+1]]
set nj_y [lindex $ND [expr $NDj_index+2]]
set nj_z [lindex $ND [expr $NDj_index+3]]
#puts "Element index = $i, Element# = $ELNum Node# = $ni NDi_index = $NDi_index ni_x = $ni_x" ;#debugging line
set dx [expr $nj_x - $ni_x]
set dy [expr $nj_y - $ni_y]
set dz [expr $nj_z - $ni_z]
set EL_Area [lindex $EL [expr 10*($i-1)+3]]
set EL_Length [expr sqrt(pow($dx,2) + pow($dy,2) +pow($dz,2))]
set EL_Wt [expr $EL_Length*$EL_Area*$EL_WDensity]
set EL_Mass [expr $EL_Wt/$grav]
set ND_ID_index [expr $NDi_index/4]
set NewNodeMass [expr $ND_Mass($ND_ID_index) + 0.5*$EL_Mass ]
set ND_Mass($ND_ID_index) $NewNodeMass
set ND_ID_index [expr $NDj_index/4]
set NewNodeMass [expr $ND_Mass($ND_ID_index) + 0.5*$EL_Mass ]
set ND_Mass($ND_ID_index) $NewNodeMass
}
#Write masses to file_______________________________________________________________________
for {set i 0} {$i < $NNDs} {incr i 1} {
if {$ND_Mass($i) > 0.0 } {
puts $Massfln "mass $ND_ID($i) $ND_Mass($i) $ND_Mass($i) $ND_Mass($i) 0.0 0.0 0.0"
}
}
close $Massfln
}
EBC masses
Moderators: silvia, selimgunay, Moderators