NEW SCRIPT -- view your deformed shape

If you have a script you think might be useful to others post it
here. Hopefully we will be able to get the most useful of these incorporated in the manuals.

Moderators: silvia, Moderators

NEW SCRIPT -- view your deformed shape

Postby silvia » Thu Mar 02, 2006 1:36 pm

I just put together a proc to display the deformed shape. I tried to balance control and ease. I am still trying to understand what ALL the control parameters are, but this works pretty well for me.
Go ahead and make the necessary modifications. And if you have any questions or recommendations, please let me know.

Code: Select all
proc procDisplayDShape { {ndm 3} {dAmp 1} {viewPlane XY} {xLoc 10} {yLoc 10} {yPixels 600}  {uMin -100} {uMax 100} {vMin -100} {vMax 100}  {wMin -1}

{wMax 1}} {


   ################################################################################################################
   #### -- procedure to display the deformed shape
   #### -- by Silvia Mazzoni, 2006 (mazzoni@berkeley_NO_SPAM_.edu)
   ####
   ####    input variables:
   #### set  xLoc 10;      # horizontal location of graphical window (0=upper left-most corner)
   #### set  yLoc 10;      # vertical location of graphical window (0=upper left-most corner)
   #### set  yPixels 600;   # height of graphical window in pixels
   #### set  viewPlane XY;   # set viewPlane local xy axes in global coordinates (XY,YX,XZ,ZX,YZ,ZY)
   #### set  uMin -100;    # view bounds in local coords - local-u Min, the proc will add padding on the sides
   #### set  uMax 100;    # view bounds in local coords - local-u Max, the proc will add padding on the sides
   #### set  vMin -100;    # view bounds in local coords - local-v Min, the proc will add padding on the sides
   #### set  vMax 100;    # view bounds in local coords - local-v Max, the proc will add padding on the sides
   #### set  dAmp 1;      # relative amplification factor for deformations
   #### set  ndm 2;      # number of dimensions defined in the modelBuilder.
   #### set  wMin -1;       # distance to front clipping planes from eye - local-w Min, optional, needed only for ndm=3
   #### set  wMax 1;       # distance to back clipping planes from eye - local-w Max, optional, needed only for ndm=3
   ####   internal variables:
   #### set  xPixels 400;   # width of graphical window in pixels
   #### set  Xo 0.;       # globalX coordinate of center of view plane
   #### set  Yo 0.;       # globalY coordinate of center of view plane
   #### set uLocal X;      # viewPlane local-x axis in global coordinates
   #### set vLocal Y;      # viewPlane local-y axis in global coordinates
   #### set  Zo 0.;       # globalZ coordinate of center of view plane
   ####   call:
   #### procDisplayDShape $ndm $dAmp $viewPlane $xLoc $yLoc $yPixels $uMin $uMax $vMin $vMax $wMin $wMax
   ############################################################################################################

   set uLocal [string index $viewPlane 0];   # viewPlane local-x axis in global coordinates
   set vLocal [string index $viewPlane 1];   # viewPlane local-y axis in global coordinates

   set Xo [expr ($uMin)];
   set Yo [expr ($vMin)];
   set Zo [expr ($wMin)];

   set epsilon 1e-3
   set uWide [expr $uMax - $uMin+$epsilon];
   set vWide [expr $vMax - $vMin+$epsilon];
   set uSide [expr 0.125*$uWide];
   set vSide [expr 0.125*$vWide];
   set uMin [expr $uMin - $uSide];
   set uMax [expr $uMax + $uSide];
   set vMin [expr $vMin - $vSide];
   set vMax [expr $vMax + $vSide];
   set uWide [expr $uMax - $uMin];
   set vWide [expr $vMax - $vMin];

   if {[expr int($uWide/$vWide*$yPixels)] >1} {
      set xPixels [expr int($uWide/$vWide*$yPixels)];
   } else {
      set xPixels 400
   }

   set space " "
   set PlaneTXT plane
   set windowTitle DispShape$space$viewPlane$PlaneTXT
   recorder display $windowTitle $xLoc $yLoc $xPixels $yPixels -wipe
   # next three commmands define viewing system, all values in global coords
   vrp $Xo $Yo $Zo;    # point on the view plane in global coord, center of local viewing system
   if {$vLocal == "X"} {
      vup 1 0 0; # dirn defining up direction of view plane
   } elseif {$vLocal == "Y"} {
      vup 0 1 0; # dirn defining up direction of view plane
   } elseif {$vLocal == "Z"} {
      vup 0 0 1; # dirn defining up direction of view plane
   }
   if {$viewPlane =="YZ" || $viewPlane =="ZY" } {
      vpn 1 0 0; # direction of outward normal to view plane
   } elseif  {$viewPlane =="XY" || $viewPlane =="YX" } {
      vpn 0 0 1; # direction of outward normal to view plane
   } else {
      vpn 0 1 0; # direction of outward normal to view plane
   }
   # next three commands define view, all values in local coord system
   prp 0 0 100; # eye location in local coord sys defined by viewing system
   viewWindow $uMin $uMax $vMin $vMax # view bounds  in local coords
   if {$ndm==3 } {
      plane $wMin $wMax; # distance to front and back clipping planes from eye
   }
   projection 0;    # projection mode
   port -1 1 -1 1    # area of window that will be drawn into
   fill 1;       # fill mode
   display 1 5 $dAmp;
}







and it is called this way:
Code: Select all
source libDisplay.tcl;   # source in file with proc on displaying deformated shape
set xLoc 10;      # horizontal location of graphical window (0=upper left-most corner)
set yLoc 10;      # vertical location of graphical window (0=upper left-most corner)
set yPixels 600;      # height of graphical window in pixels
set uMin 0;       # view bounds in local coords - local-u Min
set uMax 0;       # view bounds in local coords - local-u Max
set vMin 0;       # view bounds in local coords - local-v Min
set vMax $Lcol;       # view bounds in local coords - local-v Max
set dAmp 0.00000001;   # relative amplification factor for deformations
set ndm 2;      # number of dimensions defined in the modelBuilder.
set viewPlane XY;      # set viewPlane local xy axes in global coordinates

procDisplayDShape $ndm $dAmp $viewPlane $xLoc $yLoc $yPixels $uMin $uMax $vMin $vMax

Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

INELASTIC CANTILEVER AND DEFORMED SHAPE PROC

Postby ngeorgal » Mon Jan 07, 2008 3:22 am

hello and happy new year
i placed the proc after the modelbuild and nothing happend just like there was not there

i am reffering to the Example 2. 2D cantilever column, dynamic eq ground motion

may you help me
thanks a lot
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby silvia » Mon Jan 07, 2008 8:34 am

did you call the proc?
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

Postby ngeorgal » Mon Jan 07, 2008 10:19 am

yes i pasted exactly in the way you describe to call it
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby silvia » Tue Jan 08, 2008 8:40 am

please post the script
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

Postby ngeorgal » Tue Jan 08, 2008 10:37 am

source units_vp.tcl
source Wsection.tcl
source DisplayModel3D.tcl
source DisplayPlane.tcl

wipe; # clear opensees model
model basic -ndm 2 -ndf 3; # 2D, 3 DOFs per node
file mkdir Results1; # create data directory

set LCol [expr 3.5*$m]; #cantilever height
set span [expr 6.0*$m]; #span

# nodal coordinates:
node 1 0 0; # node#, X Y
node 2 0 [expr $LCol]
node 3 [expr $span] [expr $LCol]
node 4 [expr $span] 0

# Single point constraints -- Boundary Conditions
fix 1 1 1 1 ; # node DX DY RZ, fix Node 1
fix 4 1 1 1 ; # node DX DY RZ, fix Node 1

#+++++++++++++++++++++++++++++++++++++++++++++++++

mass 2 0.0946 0.0946 0.000001
mass 3 0.0946 0.0946 0.000001
#+sections definitions
set d1 0.2400 ;
set bf1 0.2400 ;
set tf1 0.0170 ;
set tw1 0.0100 ;

set d5 0.1800 ;
set bf5 0.0910 ;
set tf5 0.0080 ;
set tw5 0.0053 ;

set J1 0.107000E-05 ;
set J5 0.614000E-06 ;

set nfdw 16 ; # number of fibers along dw
set nftw 2 ; # number of fibers along tw
set nfbf 16 ; # number of fibers along bf
set nftf 4 ; # number of fibers along tf



set Col1SecTagFiber 1; # assign a tag number to the column section tag
set BeamSecTagFiber 2;
set ColMatTag 3 ;# assign a tag number to the column material
set SecTagTorsion1 4
set SecTagTorsion5 5
set Col1SecTag 6
set BeamSecTag 7

set Emodulus [expr 200*$GPa]
set sigma_y [expr 400*$MPa]
set bhard 0.0001 ;# strain-hardening ratio (ratio between post-yield tangent and initial elastic tangent)
set nu 0.3
set Gs [expr $Emodulus/2./[expr 1+$nu]];


set Hiso 0
set Hkin 1000
set matIDhard 1

uniaxialMaterial Hardening $matIDhard $Emodulus $sigma_y $Hiso $Hkin




# ELEMENT properties
# Structural-Steel W-section properties
# column sections:col1 HEB180
Wsection $Col1SecTagFiber $matIDhard $d1 $tw1 $bf1 $tf1 $nfdw $nftw $nfbf $nftf
# beam sections: BEAM X IPE 300 ( BEAM )
Wsection $BeamSecTagFiber $matIDhard $d5 $tw5 $bf5 $tf5 $nfdw $nftw $nfbf $nftf

# set real torsional stiffness
set JK1 [expr $Gs*$J1]
set JK5 [expr $Gs*$J5]


# assign torsional Stiffness for 3D Model EACH SECTION HAS EACH OWN TORSIONAL STIFFNESS
uniaxialMaterial Elastic $SecTagTorsion1 $JK1
uniaxialMaterial Elastic $SecTagTorsion5 $JK5


section Aggregator $Col1SecTag $SecTagTorsion1 T -section $Col1SecTagFiber

section Aggregator $BeamSecTag $SecTagTorsion5 T -section $BeamSecTagFiber

set numfib 10; # number of fibers for concrete in z-direction






# define geometric transformation: performs a linear geometric transformation of beam stiffness and resisting force from the basic system to the global-coordinate system
set ColTransfTag 1; # associate a tag to column transformation
geomTransf Linear $ColTransfTag;

set numIntgrPts 10; # number of integration points for force-based element
element nonlinearBeamColumn 1 1 2 $numIntgrPts $Col1SecTag $ColTransfTag; # self-explanatory when using variables
element nonlinearBeamColumn 2 2 3 $numIntgrPts $BeamSecTag $ColTransfTag; # self-explanatory when using variables
element nonlinearBeamColumn 3 3 4 $numIntgrPts $BeamSecTag $ColTransfTag; # self-explanatory when using variables

source getperiod.tcl
procGetTperiod 2 on

# Define DISPLAY -------------------------------------------------------------
set xPixels 1024; # height of graphical window in pixels
set yPixels 768; # height of graphical window in pixels
set xLoc1 0; # horizontal location of graphical window (0=upper left-most corner)
set yLoc1 10; # vertical location of graphical window (0=upper left-most corner)
set dAmp 2; # scaling factor for viewing deformed shape, it depends on the dimensions of the model
#DisplayModel3D NodeNumbers $dAmp $xLoc1 $yLoc1 $xPixels $yPixels
DisplayModel3D nill $dAmp $xLoc1 $yLoc1 $xPixels $yPixels


# Define RECORDERS -------------------------------------------------------------
recorder Node -file Results1/DFree.txt -time -node 2 -dof 1 2 3 disp; # displacements of free nodes
recorder Node -file Results1/DBase.txt -time -node 1 -dof 1 2 3 disp; # displacements of support nodes
recorder Node -file Results1/RBase.txt -time -node 1 -dof 1 2 3 reaction; # support reaction
recorder Drift -file Results1/Drift.txt -time -iNode 1 -jNode 2 -dof 1 -perpDirn 2 ; # lateral drift
recorder Element -file Results1/FCol.txt -time -ele 2 globalForce; # element forces -- column
recorder Element -file Results1/ForceColSec1.txt -time -ele 1 section 1 force; # Column section forces, axial and moment, node i
recorder Element -file Results1/DefoColSec1.txt -time -ele 1 section 1 deformation; # section deformations, axial and curvature, node i
recorder Element -file Results1/ForceColSec$numIntgrPts.txt -time -ele 1 section $numIntgrPts force; # section forces, axial and moment, node j
recorder Element -file Results1/DefoColSec$numIntgrPts.txt -time -ele 1 section $numIntgrPts deformation; # section deformations, axial and curvature, node j


recorder Element -file Results1/sec01ss.out -time -ele 2 section 1 fiber [expr -$tw1] 0.0 stressStrain
recorder Element -file Results1/sec01s1.out -time -ele 2 section 1 fiber [expr -$tw1] [expr $d1/10] stressStrain
recorder Element -file Results1/sec10ss.out -time -ele 2 section 10 fiber [expr -$tw1] 0.0 stressStrain
recorder Element -file Results1/sec10s1.out -time -ele 2 section 10 fiber [expr -$tw1] [expr $d1/10] stressStrain



# STATIC PUSHOVER ANALYSIS --------------------------------------------------------------------------------------------------
#
# we need to set up parameters that are particular to the model.
set IDctrlNode 2; # node where displacement is read for displacement control
set IDctrlDOF 1; # degree of freedom of displacement read for displacement contro
set Dmax 0.40; # maximum displacement of pushover.
set Dincr [expr 0.01]; # displacement increment for pushover. you want this to be very small, but not too small to slow down the analysis

# create load pattern for lateral pushover load
set Hload 1.0 ; # define the lateral load as a proportion of the weight so that the pseudo time equals the lateral-load coefficient when using linear load pattern
pattern Plain 200 Linear {; # define load pattern -- generalized
load 2 $Hload 0.0 0.0 0.0 0.0 0.0; # define lateral load in static lateral analysis
}

constraints Plain;
numberer Plain
system BandGeneral
set Tol 1.e-8; # Convergence Test: tolerance
set maxNumIter 6; # Convergence Test: maximum number of iterations that will be performed before "failure to converge" is returned
set printFlag 0; # Convergence Test: flag used to print information on convergence (optional) # 1: print information on each step;
set TestType EnergyIncr ; # Convergence-test type
test $TestType $Tol $maxNumIter $printFlag;
set algorithmType Newton
algorithm $algorithmType;
integrator DisplacementControl $IDctrlNode $IDctrlDOF $Dincr
analysis Static

# --------------------------------- perform Static Pushover Analysis
set Nsteps [expr int($Dmax/$Dincr)]; # number of pushover analysis steps
set ok [analyze $Nsteps]; # this will return zero if no convergence problems were encountered

# ---------------------------------- in case of convergence problems
if {$ok != 0} {
# change some analysis parameters to achieve convergence
# performance is slower inside this loop
set ok 0;
set controlDisp 0.0; # start from zero
set D0 0.0; # start from zero
set Dstep [expr ($controlDisp-$D0)/($Dmax-$D0)]
while {$Dstep < 1.0 && $ok == 0} {
set controlDisp [nodeDisp $IDctrlNode $IDctrlDOF ]
set Dstep [expr ($controlDisp-$D0)/($Dmax-$D0)]
set ok [analyze 1 ]
if {$ok != 0} {
puts "Trying Newton with Initial Tangent .."
test NormDispIncr $Tol 2000 0
algorithm Newton -initial
set ok [analyze 1 ]
test $TestType $Tol $maxNumIter 0
algorithm $algorithmType
}
if {$ok != 0} {
puts "Trying Broyden .."
algorithm Broyden 8
set ok [analyze 1 ]
algorithm $algorithmType
}
if {$ok != 0} {
puts "Trying NewtonWithLineSearch .."
algorithm NewtonLineSearch .8
set ok [analyze 1 ]
algorithm $algorithmType
}
}
}; # end if ok !0

puts "DonePushover"



i am using the 1.7.5version
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby silvia » Tue Jan 08, 2008 11:03 am

you are using the 3d model display proc on a 2d model.
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

Postby ngeorgal » Thu Jan 10, 2008 2:46 am

! oh yes!
i 'll try with vees
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

problem with vees

Postby ngeorgal » Thu Jan 17, 2008 12:01 pm

is it able for the nodes of a model to be shown using vees? because i have my full model and deformations but not the no's of elements and nodes

is it my error or is not supported by vees

thanks
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby silvia » Thu Jan 17, 2008 12:03 pm

You need to contact VEES support. i have never used it.
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

some out of topic help ...

Postby ngeorgal » Thu Jan 17, 2008 1:23 pm

there is something not so relevant with the topic i opend buti would appreciate if you could help me with opening reading and writting values into a file.

i have a file with two columns ( lets say p and u)
after an analysis

i want to open the file read the values from the first line to the end
and if 1 and 2 are the first two lines i want to calculate the p2-p1/k2-k1 quantity wich will be written in a new file (of course for all lines )

thanks in advance
ng
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby silvia » Thu Jan 17, 2008 2:58 pm

here is something i wrote to read two columns and split them, you can modify it for what you need:
Code: Select all
proc SplitTimeData {inFilename outFilenameTime outFilenameData {NumberHeaderLines 0}} {
   ##############################################################
   # SplitTimeData $inFilename $outFilenameTime  $outFilenameData      
   ##############################################################
   # read a plain file where column 1 is time, column 2 is data (displacement or acceleration)
   # & split into two separate files for series command.
   # Silvia Mazzoni, 2006
   # Formal arguments
   #   inFilename -- file which contains strong motion record
   #   outFilenameTime -- time in one file
   #   outFilenameData -- data (disp or acc) in other file
   #
   # Open the input file and catch the error if it can't be read
   if [catch {open $inFilename r} inFileID] {
      puts stderr "Cannot open $inFilename for reading"
   } else {
      # Open output file for writing
      set outFileTimeID [open $outFilenameTime w]
      set outFileDataID [open $outFilenameData w]
   
      # Look at each line in the file
      set LineCounter 0
      foreach line [split [read $inFileID] \n] {
         incr LineCounter
         while {$LineCounter>$NumberHeaderLines} {
            if {[llength $line] == 0} {
               # Blank line --> do nothing
               continue
            } else {
               set Time [lindex $line 0]
               set Data [lindex $line 1]
               write $outFileTimeID $Time
               write $outFileDataID $Data
            }
         }
      }
      close $outFileTimeID;   # Close the output file
      close $outFileDataID
      close $inFileID;   # Close the input file
   }
}
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
silvia
 
Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

Postby ngeorgal » Fri Jan 18, 2008 12:29 am

thank you very much but the problem remains to make the substraction between the elements of two subsequent lines
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Postby ngeorgal » Fri Jan 18, 2008 4:12 am

the write command ? i cant find it - how it works ? it crashes when interprets the write command :s
is htere write command in tcl ? what about puts ?

in more detail
i have created two files
one is pload.out ( they contain one column ( with 50 elements each) and the ather is uload.out- what i am trying unsuccesfully to do is ,to make a new file where i ll have calculated the k value where k= (p2-p1)/(u2-u1) - that means that i want to read the file one time starting from the first line and the other starting form the second- io tried lindex and foreach line but i cant find a way to read it from the second line - it always start from the firs - can you post a little script to do the job ?
it may be very simple but i am a new tcl user - and even this little thing seems to be very difficult

thank you very much
ngeorgal
 
Posts: 20
Joined: Mon Oct 16, 2006 3:52 am
Location: national technical univercity of athens

Problem using displaymodel2d

Postby Sh_gharavi » Fri May 15, 2009 9:09 pm

hello
when I call the procedure DisplayModel2D as below:

set xPixels 1024;
set yPixels 768;
set xLoc1 0;
set yLoc1 10;
set dAmp 2;
DisplayModel2D NodeNumbers $dAmp $xLoc1 $yLoc1 $xPixels $yPixels

this problem rises: Invalid Command name "nodeBounds"
as I checked nodebound is a list used in DisplayPlane and is not defined anywhere before. so the error makes sense. but I dont understand how the others have used this proc.
thanx
Sh_gharavi
 
Posts: 3
Joined: Sun Mar 08, 2009 3:08 pm

Next

Return to Useful Scripts.

Who is online

Users browsing this forum: No registered users and 1 guest

cron