Reputation: 11
I want to model rotational spring for beams in my model in notepad++ (I used tcl lang. in notepad++ editor so I can find lines of errors and open brackets etc., a bit easier) like the picture (MRF) that I add, but without considering RBS. I wrote the code that I paste its lines below but unfortunately, it has an error (warning domain). I did lots of trial and error but I couldn't fix it. Can anyone please help me? (j=floors i=piers) (because my model is big (10 stories), I want to model it on a programming base)
for {set j 1} {$j <= $nFlrs} {incr j} {
for {set i 1} {$i <= $nBays} {incr i} {
set ID1 [expr 4*1000+($i*10+$j)*10+1]
set nodeR1 [expr ($i*10+$j)*100+5]
set nodeC1 [expr ($i*10+$j)*10+1]
}
for {set i 1} {$i <= $nBays+1} {incr i} {
set ID2 [expr 4*1000+($i*10+$j)*10+2]
set nodeR2 [expr (($i+1)*10+$j)*100+10]
set nodeC2 [expr (($i+1)*10+$j)*10+2]
}
}
uniaxialMaterial Bilin $ID1 $ke $alfah $alfah $my -$my $lambda 0\
0 0 1 0 0 0 $tetap $tetap $tetapc $tetapc 0 0 $tetau $tetau 1 1 $nFactor
uniaxialMaterial Bilin $ID2 $ke $alfah $alfah $my -$my $lambda 0\
0 0 1 0 0 0 $tetap $tetap $tetapc $tetapc 0 0 $tetau $tetau 1 1 $nFactor
# define beam springs
element zeroLength $ID1 $nodeR1 $nodeC1 -mat $ID1 -dir 6
element zeroLength $ID2 $nodeR2 $nodeC2 -mat $ID2 -dir 6
#Constrain the translational DOF with a multi-point constraint
# retained constrained DOF_1 DOF_2 ... DOF_n
equalDOF $nodeR1 $nodeC1 1 2
equalDOF $nodeR2 $nodeC2 1 2
}
incr ID1
incr ID2
warning: WARNING Domain::addElement - In element 4401
no Node 4005 exists in the domain
Upvotes: 0
Views: 135
Reputation: 137727
The big problem you've got is that you are not doing the making of the entities that you'll be simulating in the loops; you loop, but you don't do anything useful with that.
Now, I really don't know OpenSees, but here's a guess as to how you might go about fixing things. Or at least the first step.
for {set j 1} {$j <= $nFlrs} {incr j} {
for {set i 1} {$i <= $nBays} {incr i} {
set ID1 [expr 4*1000+($i*10+$j)*10+1]
set nodeR1 [expr ($i*10+$j)*100+5]
set nodeC1 [expr ($i*10+$j)*10+1]
uniaxialMaterial Bilin $ID1 $ke $alfah $alfah $my -$my $lambda 0\
0 0 1 0 0 0 $tetap $tetap $tetapc $tetapc 0 0 $tetau $tetau 1 1 $nFactor
element zeroLength $ID1 $nodeR1 $nodeC1 -mat $ID1 -dir 6
equalDOF $nodeR1 $nodeC1 1 2
}
for {set i 1} {$i <= $nBays+1} {incr i} {
set ID2 [expr 4*1000+($i*10+$j)*10+2]
set nodeR2 [expr (($i+1)*10+$j)*100+10]
set nodeC2 [expr (($i+1)*10+$j)*10+2]
uniaxialMaterial Bilin $ID2 $ke $alfah $alfah $my -$my $lambda 0\
0 0 1 0 0 0 $tetap $tetap $tetapc $tetapc 0 0 $tetau $tetau 1 1 $nFactor
element zeroLength $ID2 $nodeR2 $nodeC2 -mat $ID2 -dir 6
equalDOF $nodeR2 $nodeC2 1 2
}
}
All I have done here is move code that was after the loops to inside the loops (and deleted a few junk lines). I do not know that what's written now is correct, but it looks much more likely to be so. In particular, the places where the variables are written are next to where they are used, which is probably a good idea.
The next stage of cleaning up this code is to introduce a helper procedure.
# I'm terrible at naming things!
proc makeThing {id nodeR nodeC} {
global ke alfah my lambda tetap tetapc tetau nFactor
uniaxialMaterial Bilin $id $ke $alfah $alfah $my -$my $lambda 0\
0 0 1 0 0 0 $tetap $tetap $tetapc $tetapc 0 0 $tetau $tetau 1 1 $nFactor
element zeroLength $id $nodeR $nodeC -mat $id -dir 6
equalDOF $nodeR $nodeC 1 2
}
for {set j 1} {$j <= $nFlrs} {incr j} {
for {set i 1} {$i <= $nBays} {incr i} {
# I'm also going to put the expressions in braces, for performance
# It gives the expression compiler a chance to do something sensible!
set ID1 [expr { 4*1000+($i*10+$j)*10+1 }]
set nodeR1 [expr { ($i*10+$j)*100+5 }]
set nodeC1 [expr { ($i*10+$j)*10+1 }]
makeThing $ID1 $nodeR1 $nodeC1
}
for {set i 1} {$i <= $nBays+1} {incr i} {
set ID2 [expr { 4*1000+($i*10+$j)*10+2 }]
set nodeR2 [expr { (($i+1)*10+$j)*100+10 }]
set nodeC2 [expr { (($i+1)*10+$j)*10+2 }]
makeThing $ID2 $nodeR2 $nodeC2
}
}
The point of the procedure is that you have one place where you try to do things right (test it until it works) and then you can effectively stamp out all the places where you need that little pattern by just calling the procedure.
Upvotes: 0