why linsert does not work?

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
yuejun
Posts: 27
Joined: Wed Oct 31, 2007 12:43 pm
Location: MTU
Contact:

why linsert does not work?

Post by yuejun »

The following code is part of example 6, by which I want to change one column section. In the end I try to insert the weight of level 2 into the floorweight list which already contains floorweight from level 3 to level 13. By puts the length of the list, I found it does not change at all. Why is that?

Code: Select all

# --------------------------------------------------------------------------------------------------
# Example 6. 2D Frame
#		Silvia Mazzoni & Frank McKenna, 2006
# nonlinearBeamColumn element, inelastic fiber section
#

# SET UP ----------------------------------------------------------------------------
wipe;				# clear memory of all past model definitions
model BasicBuilder -ndm 2 -ndf 3;	# Define the model builder, ndm=#dimension, ndf=#dofs
set dataDir Data;			# set up name of data directory (can remove this)
file mkdir $dataDir; 			# create data directory
source LibUnits.tcl;			# define units

# define GEOMETRY -------------------------------------------------------------
# define structure-geometry paramters
set LCol [expr 14*$ft];		# column height
set LBeam [expr 24*$ft];		# beam length
set NStory 12;			# number of stories above ground level -------------- you can change this.
set NBay 9;			# number of bays (max 9) ------------------------------you can change this.

# define NODAL COORDINATES
for {set level 1} {$level <=[expr $NStory+1]} {incr level 1} {
	set Y [expr ($level-1)*$LCol];
	for {set pier 1} {$pier <= [expr $NBay+1]} {incr pier 1} {
		set X [expr ($pier-1)*$LBeam];
		set nodeID [expr $level*10+$pier]
		node $nodeID $X $Y;		# actually define node
	}
}
# determine support nodes where ground motions are input, for multiple-support excitation
set iSupportNode ""
set level 1
for {set pier 1} {$pier <= [expr $NBay+1]} {incr pier 1} {
	set nodeID [expr $level*10+$pier]
	lappend iSupportNode $nodeID
}


# BOUNDARY CONDITIONS
fixY 0.0 1 1 0;		# pin all Y=0.0 nodes

# calculated MODEL PARAMETERS, particular to this model
puts "Number of Stories: $NStory Number of bays: $NBay"
# Set up parameters that are particular to the model for displacement control
set IDctrlNode [expr ($NStory+1)*10+1];		# node where displacement is read for displacement control
set IDctrlDOF 1;		# degree of freedom of displacement read for displacement control
set LBuilding [expr $NStory*$LCol];	# total building height

# Structural-Steel W-section properties
# material properties:
set Es [expr 29000*$ksi];		# Steel Young's Modulus
set nu 0.3;
set Gs [expr $Es/2./[expr 1+$nu]];  # Torsional stiffness Modulus

# column sections: W44x290
set AgCol [expr 85.4*pow($in,2)];		# cross-sectional area
set IzCol [expr 27000.*pow($in,4)];		# moment of Inertia
# damaged column W40x264
set AgColDamaged [expr 85.4*pow($in,2)];
set IzColDamaged [expr 27000.0*pow($in,4)];
# beam sections: W24x94
set AgBeam [expr 27.7*pow($in,2)];		# cross-sectional area
set IzBeam [expr 2700.*pow($in,4)];		# moment of Inertia

set ColSecTag 1
set BeamSecTag 2
set DamagedColSecTag 3
section Elastic $ColSecTag $Es $AgCol $IzCol 
section Elastic $BeamSecTag $Es $AgBeam $IzBeam
section Elastic $DamagedColSecTag $Es $AgColDamaged $IzColDamaged 

# define ELEMENTS
# set up geometric transformations of element
#   separate columns and beams, in case of P-Delta analysis for columns
set IDColTransf 1; # all columns
set IDBeamTransf 2; # all beams
set ColTransfType Linear ;			# options, Linear PDelta Corotational 
geomTransf $ColTransfType $IDColTransf  ; 	# only columns can have PDelta effects (gravity effects)
geomTransf Linear $IDBeamTransf

# Define Beam-Column Elements
set np 5;	# number of Gauss integration points for nonlinear curvature distribution-- np=2 for linear distribution ok
# columns
set N0col 100;	# column element numbers
set level 0
# 1st column in level 1 is damaged
element nonlinearBeamColumn 111 11 21 $np $DamagedColSecTag $IDColTransf;
for {set pier 2} {$pier <= [expr $NBay+1]} {incr pier 1} {
	set elemID [expr 110+$pier]
	set nodeI [expr 10+$pier]
	set nodeJ [expr 20+$pier]
	element nonlinearBeamColumn $elemID $nodeI $nodeJ $np $ColSecTag $IDColTransf;
}

for {set level 2} {$level <=$NStory} {incr level 1} {
	for {set pier 1} {$pier <= [expr $NBay+1]} {incr pier 1} {
		set elemID [expr $N0col  + $level*10 +$pier]
		set nodeI [expr  $level*10 + $pier]
		set nodeJ  [expr  ($level+1)*10 + $pier]
		element nonlinearBeamColumn $elemID $nodeI $nodeJ $np $ColSecTag $IDColTransf;		# columns
	}
}

# beams
set N0beam 300;	# beam element numbers
set M0 0
for {set level 2} {$level <=[expr $NStory+1]} {incr level 1} {
	for {set bay 1} {$bay <= $NBay} {incr bay 1} {
		set elemID [expr $N0beam + $level*10 +$bay]
		set nodeI [expr  $M0 + $level*10 + $bay]
		set nodeJ  [expr  $M0 + $level*10 + $bay+1]
		element nonlinearBeamColumn $elemID $nodeI $nodeJ $np $BeamSecTag $IDBeamTransf;	# beams
	}
}
                  
# Define GRAVITY LOADS, weight and masses
# calculate dead load of frame, assume this to be an internal frame (do LL in a similar manner)
# calculate distributed weight along the beam length
set GammaConcrete [expr 150*$pcf];   		# Reinforced-Concrete floor slabs
set Tslab [expr 6*$in];			# 6-inch slab
set Lslab [expr 2*$LBeam/2]; 			# assume slab extends a distance of $LBeam1/2 in/out of plane
set Qslab [expr $GammaConcrete*$Tslab*$Lslab]; 
set QBeam [expr 94*$lbf/$ft];		# W-section weight per length
set QdlBeam [expr $Qslab + $QBeam]; 	# dead load distributed along beam.
set QdlCol [expr 290*$lbf/$ft]; 	# W-section weight per length
set QdlColDamaged [expr 290.*$lbf/$ft];
set WeightCol [expr $QdlCol*$LCol];  		# total Column weight
set WeightColDamaged [expr $QdlColDamaged*$LCol];
set WeightBeam [expr $QdlBeam*$LBeam]; 	# total Beam weight

# assign masses to the nodes that the columns are connected to 
# each connection takes the mass of 1/2 of each element framing into it (mass=weight/$g)
# level 2 node 21 (leftmost node)
set weightNode_21 [expr $WeightColDamaged/2.0 + $WeightCol/2.0 + $WeightBeam/2.0];
set massNode_21 [expr $weightNode_21/$g];
mass 21 $massNode_21 0.0 0.0 0.0 0.0 0.0;
# level 2 node 30
set weightNode_30 [expr $WeightCol+$WeightBeam/2.0];
set massNode_30 [expr $weightNode_30/$g];
mass 30 $massNode_30 0.0 0.0 0.0 0.0 0.0;
set FloorWeight_2 [expr $weightNode_21+$weightNode_30]; # initialize
# level 2 node 22 through 29
for {set pier 2} {$pier <= [expr $NBay]} {incr pier 1} {
	set nodeID [expr 20+$pier];
	set weightNode [expr $WeightCol + $WeightBeam]; # nodes inside (22~29) weight
	set massNode [expr $weightNode/$g];
	set FloorWeight_2 [expr $FloorWeight_2 + $weightNode]; # calculate FloorWeight_2
	mass $nodeID $massNode 0.0 0.0 0.0 0.0 0.0;
}
# level 3 through level 13
set iFloorWeight ""; # list of floor weight (3~13)
set WeightTotal_3_to_13 0.0; # initialize
set sumWiHi_3_to_13 0.0; # sum of storey weight times height, for lateral-load distribution
for {set level 3} {$level <=[expr $NStory+1]} {incr level 1} { ;		
	set FloorWeight 0.0
	if {$level == [expr $NStory+1]}  {
		set ColWeightFact 1;		# one column in top story
	} else {
		set ColWeightFact 2;		# two columns elsewhere
	}
	for {set pier 1} {$pier <= [expr $NBay+1]} {incr pier 1} {;
		if {$pier == 1 || $pier == [expr $NBay+1]} {
			set BeamWeightFact 1;	# one beam at exterior nodes
		} else {;
			set BeamWeightFact 2;	# two beams elewhere
		}
		set WeightNode [expr $ColWeightFact*$WeightCol/2 + $BeamWeightFact*$WeightBeam/2]
		set MassNode [expr $WeightNode/$g];
		set nodeID [expr $level*10+$pier]
		mass $nodeID $MassNode 0.0 0.0 0.0 0.0 0.0;			# define mass
		set FloorWeight [expr $FloorWeight+$WeightNode];
	}
	lappend iFloorWeight $FloorWeight; # lappend command add elements to a list
	set WeightTotal_3_to_13 [expr $WeightTotal_3_to_13+ $FloorWeight]
	set sumWiHi_3_to_13 [expr $sumWiHi_3_to_13+$FloorWeight*($level-1)*$LCol];		
}
set sumWiHi_2 [expr $FloorWeight_2*$LCol];
set sumWiHi [expr $sumWiHi_2 + $sumWiHi_3_to_13];# sum of storey weight times height, for lateral-load distribution
set WeightTotal [expr $FloorWeight_2 + $WeightTotal_3_to_13];
set MassTotal [expr $WeightTotal/$g];	
puts [llength $iFloorWeight ];
linsert $iFloorWeight 0 $FloorWeight_2
puts [llength $iFloorWeight ];
zvidrih
Posts: 39
Joined: Wed Apr 30, 2008 1:55 am
Location: Ljubljana, Slovenia

linsert

Post by zvidrih »

Hi, I guess you've solved the problem. Just in case if somebody else needs the solution

Instead of:

Code: Select all

linsert $iFloorWeight 0 $FloorWeight_2 
use

Code: Select all

set iFloorWeight [linsert $iFloorWeight 0 $FloorWeight_2]

:wink:
Zlatko Vidrih
Institute of Structural Engineering, earthquake Engineering and Construction IT
Faculty of Civil and Geodetic Engineering
University of Ljubljana, Slovenia
Post Reply