simulasi gempa dengan tmd

20
Simulasi Gempa Pada Gedung Tinggi Dengan Tuned Mass Damper (TMD) Topik Khusus Sains Komputasi (Dosen: Prof. Zaki Suud) Dian Nuraiman (20912017) Muhaza Liebenlito(20912020) April 15, 2013 1 Pendahuluan Gedung pencakar langit dapat berfungsi sebagai tempat untuk melakukan aktifitas bisnis ataupun sebagai simbol kedigdayaan suatu negara. Namun untuk merancang gedung terse- but tidak mudah. Terdapat faktor-faktor yang perlu dipertimbangkan untuk keselamatan penggunanya seperti konstruksi bangunan, ketahanan terhadap bencana alam, dan lain-lain. Bencana alam merupakan hal yang terjadi suatu waktu dan sulit untuk diprediksi, termasuk gempa bumi. Sehingga gedung pencakar langit perlu untuk meminimalkan resiko bencana yang terjadi. Tuned Mass Damper (TMD) merupakan salah satu teknik yang mampu mem- inimalkan guncangan yang terjadi akibat gempa bumi. TMD diinspirasi oleh dua benda dengan massa yang berbeda yang dihubungkan dengan menggunakan pegas sehingga gerak salah satu benda akan teredam akibat dari perbedaan massa yang terjadi pada konfigurasi tersebut. Adapun Tujuan dari simulasi ini adalah untuk melihat pengaruh TMD pada gedung tinggi pada saat terjadi gempa. Asumsi yang kami gunakan dalam mendesain simulasi ini: Gedung yang akan disimulasikan yaitu Taipei 101. Desain simulasi dua dimensi. Lantai dan dinding diasumsikan sebagai pegas dengan dua bola bermassa yang saling berinteraksi. Pegas diposisikan menyilang antar satu lantai dengan lantai yang lain. 1

Upload: liebenlito

Post on 16-Jan-2016

36 views

Category:

Documents


1 download

DESCRIPTION

TMD

TRANSCRIPT

Page 1: Simulasi Gempa Dengan TMD

Simulasi Gempa Pada Gedung Tinggi Dengan TunedMass Damper (TMD)

Topik Khusus Sains Komputasi(Dosen: Prof. Zaki Suud)

Dian Nuraiman (20912017)Muhaza Liebenlito(20912020)

April 15, 2013

1 Pendahuluan

Gedung pencakar langit dapat berfungsi sebagai tempat untuk melakukan aktifitas bisnisataupun sebagai simbol kedigdayaan suatu negara. Namun untuk merancang gedung terse-but tidak mudah. Terdapat faktor-faktor yang perlu dipertimbangkan untuk keselamatanpenggunanya seperti konstruksi bangunan, ketahanan terhadap bencana alam, dan lain-lain.Bencana alam merupakan hal yang terjadi suatu waktu dan sulit untuk diprediksi, termasukgempa bumi. Sehingga gedung pencakar langit perlu untuk meminimalkan resiko bencanayang terjadi. Tuned Mass Damper (TMD) merupakan salah satu teknik yang mampu mem-inimalkan guncangan yang terjadi akibat gempa bumi. TMD diinspirasi oleh dua bendadengan massa yang berbeda yang dihubungkan dengan menggunakan pegas sehingga geraksalah satu benda akan teredam akibat dari perbedaan massa yang terjadi pada konfigurasitersebut.

Adapun Tujuan dari simulasi ini adalah untuk melihat pengaruh TMD pada gedungtinggi pada saat terjadi gempa. Asumsi yang kami gunakan dalam mendesain simulasi ini:

• Gedung yang akan disimulasikan yaitu Taipei 101.

• Desain simulasi dua dimensi.

• Lantai dan dinding diasumsikan sebagai pegas dengan dua bola bermassa yang salingberinteraksi.

• Pegas diposisikan menyilang antar satu lantai dengan lantai yang lain.

1

Page 2: Simulasi Gempa Dengan TMD

2 Teori Pendukung

2.1 Shear Force

Pada simulasi ini, shear force diasumsikan sebagai gaya yang dapat bekerja pada pegas yangdiposisikan saling menyilang di tiap lantai. Pada Figure 1 mengilustrasikan bagaimana shearforce tersebut bekerja, dimana bidang tampang lintang ini selalu horizontal pada saat shearforce bekerja, sehingga material atau gedung tersebut dapat mengalami perenggangan secaralinear. Perenggangan secara linear ini disimulasikan menggunakan gaya pegas menyilang.Ketinggian tampang lintang awal dapat berubah menjadi lebih rendah ketika shear forcebekerja. Ini dikarenakan asumsi bahwa dinding dari bangunan adalah benda tegar dengankekakuan sempurna. Perhitungan shear force dilakukan dengan cara menghitung percepatanbola bermassa di masing-masing lantai.

Figure 1: Pergerakan bola bermassa

2.2 Peak Ground Acceleration (PGA)

PGA merupakan percepatan terbesar dari pergerakan tanah pada saat gempa bumi. Jikapola gerakan yang diberikan adalah sinusoidal, maka percepatan terbesar dapat dirumuskanpada persamaan:

amax = Aω2

dimana A adalah besar amplitudo getaran yang terjadi pada saat gempa dan ω adalahfrekuensi getarannya.

2.3 Tuned Mass Damper (TMD)

Persamaan gerak untuk massa primer atau massa gedung seperti yang diperlihatkan padaFigure 2 adalah:

(1 + m)u+ 2εωmu+ ω2u =p

m− mud

2

Page 3: Simulasi Gempa Dengan TMD

m didefinisikan sebagai perbandingan massa antara massa gedung dengan massa damper,m = md

m, u adalah kecepatan, u percepatan, ε adalah faktor damping dari massa primer.

Figure 2: Sistem SDOF-TMD.

Sehingga persamaan gerak untuk TMD adalah:

ud + 2εdωdud + ω2dud = −ud

Tujuan menambahkan massa damper adalah untuk mengontrol vibrasi dari struktur ketikaterjadi terjadi guncangan. Massa damper mempunyai parameter yaitu massa md, konstantapegas kd dan koefisien damping cd. Damper dibangun untuk menjadi frekuensi pokok daristruktur sehingga

ωd = ω

kd = mk

Massa primer bergerak secara periodik sinusoidal

p = p sin Ωt

maka respon yang diberikan adalah

u = u sin(Ωt+ δ1)

ud = ud sin(Ωt+ δ1 + δ2)

dimana u dan δ dinotasikan sebagai pergeseran (displacement) benda dan phase shift, secaraberurut. Untuk mengatasi masalah kondisi resonan, maka solusinya adalah:

u =p

mk

√1/(1 + (2ε/m+ 1/2εd)2) (1)

ud = (1/2εd)u

tan δ1 = −(2ε/m+ 1/2εd)

tan δ2 = −π/2

3

Page 4: Simulasi Gempa Dengan TMD

Persamaan di atas menunjukan bahwa respon dari TMD adalah 90 dari fase dengan responyang terjadi pada massa primer. Dari persamaan (1) didapat

εd =m

2

√1/1 + (2ε/m+ 1/2εd)2 (2)

Persamaan (2) menunjukan kontribusi relatif dari TMD dari total damping.

3 Hasil dan Pembahasan

Desain gedung pada simulasi ini diasumsikan sebagai kumpulan bola bermassa yang di-hubungkan oleh pegas satu dengan yang lainnya, dimana setiap lantai terdiri dari tigabola bermassa. TMD diletakkan di lantai paling atas yang dihubungkan dengan dua bolabermassa dari kiri dan kanan. Seperti yang terlihat pada Figure 3. Pada simulasi ini metodeuntuk menghitung perubahan posisi bola pada waktu t dapat menggunakan algoritma Ver-let. Karena berdasarkan teori pendukung 2.3 perubahan posisi yang terjadi pada waktu tmerupakan . Dengan demikian ketika didapat perubahan posisi bola bermassa pada waktut, selanjutnya menghitung dengan shear force yang terjadi dari interaksi perubahan bolabermassa tersebut.

Figure 3: Asumsi Desain Gedung.

Tabel di bawah ini adalah data-data pendukung untuk melakukan simulasi.

4

Page 5: Simulasi Gempa Dengan TMD

Tinggi Gedung 509 mJumlah Lantai 196Massa Gedung 700000 tonMassa Damper 730 tonJumlah Bola per Lantai 3PGA 0.5g, 1.7g, 2.7g (g = 9.8m/s2)Amplitudo 0.3Massa 119047.19 kgKonstanta Pegas Damper 6.25e09Konstanta Pegas Dinding 6.25e09

Dari Figure 4 terlihat bahwa gedung yang menggunakan TMD menghasilkan shear forceyang lebih kecil dibandingkan dengan gedung yang tidak menggunakan TMD. Lantai ataspada gedung yang menggunakan TMD mempunyai shear force yang hampir mendekati nilai0 dibandingkan dengan lantai 1 s/d 18. Hal ini dikarenakan gedung pada lantai 1 s/d 18lebih dekat dengan gempa dibandingkan dengan bola TMDnya.

5

Page 6: Simulasi Gempa Dengan TMD

(a) PGA 0.5 (Non-TMD) (b) PGA 0.5 (TMD)

(c) PGA 1.7 (Non-TMD) (d) PGA 1.7 (TMD)

(e) PGA 2.7 (Non-TMD) (f) PGA 2.7 (Non-TMD)

Figure 4: Grafik Perbandingan Shear Force.

4 Kesimpulan

Hasil simulasi di atas menunjukkan simulasi dengan tuned mass damper (TMD) meng-hasilkan shear force yang lebih kecil dengan tanpa menggunakan TMD. Hal ini menunjukkanbahwa TMD mampu meredam getaran gempa. Simulasi dengan TMD menunjukkan bahwagedung hanya menerima getaran di bawah lantai 20.

6

Page 7: Simulasi Gempa Dengan TMD

References

[1] Misrha, Rashmi. 2011. Application of Tuned Mass Damper For Vibration Controlof Frame Structures Under Seismic Excitaions. Thesis.

[2] Esteki, Kambiz. 2011. Semi-Active Tuned Mass Damper for Seismic Applications.International Workshop Smart Materials, Structures and NDT in Aerospace Con-ference.

[3] Zahrai, S.M. 2013. Seismic Design of Fuzzy Controller For Semi-Active TunedMass Damper Using Top Stories As The Mass. Asian Journal of Civil Engineering(BHRC) Vol. 14, No. 3.

[4] Min-Ho Chey. 2010. Semi-Active Tuned Mass Damper Building System: Appli-cation. Earthquake Engineering and Structural Dynamics (EESD), 39.

7

Page 8: Simulasi Gempa Dengan TMD

Lampiran

Listing 1: gnuplot.h

1 // 15.2.2012 9:272 #ifndef GNUPLOT_H3 #define GNUPLOT_H4 /**5

6 [== "Gnuplot.h"7 This class serves as easier access to gnuplot and its executable .txt

file8

9 . The Gnuplot class constructed with two .txt file created, one forstoring data,

10 one for executing commands from the shell. The default name of thosefiles are:

11 plotcommand12 plotdata13 User may declare a Gnuplot class via14 Gnuplot sine;15 (this will open a stream to data file and command file)16

17 . User may insert a text to both of the command and data file via18 objectname.command<<" "19 objectname.data<<" "20

21 . User may execute the command in the command file via22 objectname.plot();23 (this will close the entire data stream before executing)24

25 . User can do a rewrite to the data file or the command file via26 objectname.redata();27 objectname.recommand();28 (this will reopen the data stream if they are closed)29 ==]30

31 */32 class Gnuplot33 34 public:35 char* plotcommand;36 char* plotdata;37

38 ofstream command;39 ofstream data;40

41 bool commandFlag;42 bool dataFlag;43

44 Gnuplot(char _plotcommand[]="plotcommand.txt", char _plotdata[]="plotdata.txt")

8

Page 9: Simulasi Gempa Dengan TMD

45 46 plotcommand=_plotcommand; plotdata=_plotdata;47 command.open(plotcommand); data.open(plotdata);48 command49 <<"unset key\n"50 <<"set grid\n";51 commandFlag=true;52 dataFlag=true;53 54

55 virtual ˜Gnuplot()56 57 58

59 void redata()60 61 if(dataFlag==false) 62 data.open(plotdata);63 dataFlag=true;64 65 66

67 //Close the data plot file (if it is necessary in the middle of the plotscheme)

68 void closeData()69 70 data.close();71 dataFlag=false;72 73

74 void recommand()75 76 if(commandFlag==false) 77 command.open(plotcommand);78 command79 <<"unset key\n"80 <<"set grid\n";81 commandFlag=true;82 83

84 85

86 void plot()//Execute the gnuplot87 88 command.close();89 data.close();90 string shellcommand= "D:\\Documents\\gnuplot\\binary\\gnuplot -

e \"load ’";91 shellcommand.append(plotcommand);92 shellcommand.append("’; unset out\" ");93 system(shellcommand.c_str());94

95 commandFlag=false;96 dataFlag=false;

9

Page 10: Simulasi Gempa Dengan TMD

97 98

99 ;100 #endif // GNUPLOT_H

Listing 2: sphere.h

1 /**2 This class is an Sphere class using array algorithm version3 15.2.2012 9:274 */5

6 #ifndef SPHERE_H7 #define SPHERE_H8

9 #define maxNum 10000 //Define max number of Spheres in the simulation10

11

12 class Sphere13 14 public:15 double mass[maxNum], radius[maxNum];16 double xpos[maxNum], ypos[maxNum], zpos[maxNum];17 double xinit[maxNum], yinit[maxNum], zinit[maxNum];18 double xvel[maxNum], yvel[maxNum], zvel[maxNum];19 double xacc[maxNum], yacc[maxNum], zacc[maxNum];20 double xaccTemp[maxNum], yaccTemp[maxNum], zaccTemp[maxNum]; //for

velocity verlet21 double xtotalF[maxNum], ytotalF[maxNum], ztotalF[maxNum];22

23 int numOfSpheres;24

25 Sphere(int _numOfSpheres);//const26

27 virtual ˜Sphere() 28

29 /*the force applied ussualy not more that three kinds of force30 User must declare the forces outside the class*/31 void force0();32 void force1();33

34 //This function apply all of the force functions35 void totalF()36 37 force0();38 force1();39 40

41 //Move the Sphere in one time step (the time Step MUST be an input)42 void velVerletMove(double timeStep);43

44 ;45

10

Page 11: Simulasi Gempa Dengan TMD

46

47

48 Sphere::Sphere(int _numOfSpheres)49 50 numOfSpheres = _numOfSpheres;51

52 for(int i = 0; i<numOfSpheres; i++)53 54

55 mass[i]=1.0;56 xpos[i]=0.0; ypos[i]=0.0; zpos[i]=0.0;57 xinit[i]=0.0; yinit[i]=0.0; zinit[i]=0.0;58 xvel[i]=0.0; yvel[i]=0.0; zvel[i]=0.0;59 xacc[i]=0.0; yacc[i]=0.0; zacc[i]=0.0;60 xtotalF[i]=0.0, ytotalF[i]=0.0; ztotalF[i]=0.0;61 xaccTemp[i]=0.0; yaccTemp[i]=0.0; zaccTemp[i]=0.0;//for

velocity verlet62

63 64 65

66

67 void Sphere::velVerletMove(double timeStep)68 69 //Nullifies all forces70 for(int i=0; i<numOfSpheres; i++)71 72 xtotalF[i] = 0.0;73 ytotalF[i] = 0.0;74 ztotalF[i] = 0.0;75 76

77 //=====force sum=====78 totalF();79 //===================80

81 //Update the velocity82 for(int i=0; i<numOfSpheres; i++)83 84 xacc[i] = xtotalF[i]/mass[i];85 yacc[i] = ytotalF[i]/mass[i];86 zacc[i] = ztotalF[i]/mass[i];87

88 //Update velocity here89 xvel[i] += timeStep*0.5*(xacc[i]+xaccTemp[i]);90 yvel[i] += timeStep*0.5*(yacc[i]+yaccTemp[i]);91 zvel[i] += timeStep*0.5*(zacc[i]+zaccTemp[i]);92

93

94 95

96 //the move one step loop97 for(int i=0; i<numOfSpheres; i++)98

11

Page 12: Simulasi Gempa Dengan TMD

99 xaccTemp[i] = xacc[i];100 yaccTemp[i] = yacc[i];101 zaccTemp[i] = zacc[i];102

103 xpos[i] +=104 timeStep*xvel[i] + 0.5*timeStep*timeStep*xacc[i];105

106 ypos[i] +=107 timeStep*yvel[i] + 0.5*timeStep*timeStep*yacc[i];108

109 zpos[i] +=110 timeStep*zvel[i] + 0.5*timeStep*timeStep*zacc[i];111 112

113

114 115

116

117

118 #endif // SPHERE_H

Listing 3: main.cpp

1 #include<iostream>2 #include<fstream>3 #include<cstdlib>4 #include<cstdio>5 #include<math.h>6 #include<time.h>7 #include<string>8

9 using namespace std;10 #include "Gnuplot.h"11 #include "Sphere.h"12 #define pi 3.1415926513

14 //============================================== SIMULATION PARAMETER15 const int numOfFloors = 196; // jumlah lantai16 const int numOfRooms = 2; //FIXED. DO NOT CHANGE THIS17

18 const int nSpheres = numOfFloors*3;19

20 const int nSprings = 10000; //there are 1078 springs21

22 double timeStep = 0.002;23 double timeEnds = 5;24 double pngPlotPerStep = 25;25 double gravAcc = 9.8;26

27 double springConst[nSprings];28 double springLength[nSprings];29 double wallSpringConst = 6.25*1e9;30 double shearSpringConst = 6.25*1e9;

12

Page 13: Simulasi Gempa Dengan TMD

31 double dampingConst = 0.5;32 double massPerSphere = 1190471.19;33

34 double massDamper = 700000;35 double springDamperConst = 6.25*1e9;36

37 bool createMovie = true;38 string movieSpeed = "80";39 int sphereIndex[5000][2]; //corresponds to the pair that uses the spring

attachment40 int pairIndex = 0; // Initiate the initial counter of how many spring pairs41

42 bool torquePlot = true;43 //oscillation parameter44 bool shake = true;45 double amplitude = 0.3;46 double PGA = 0.5*gravAcc;47 double omega = sqrt(PGA/amplitude);48

49 //============================================== DECLARATION50 Sphere ball(nSpheres);51 Sphere* pball = &ball;52

53 //I declare the gnuplot to plot the resulting position54 Gnuplot spherePlot;55 Gnuplot* pspherePlot = &spherePlot;56

57 Gnuplot shearPlot("shearCommand.txt", "shearData.txt");58 Gnuplot* pshearPlot = &shearPlot;59

60 //============================================== SPRING FORCE & GRAVITY61

62 void Sphere::force0() //Simple constant near surface gravity63 64 for(int i=0; i<numOfSpheres; i++)65 66 ytotalF[i] = -gravAcc;67 68 69

70 void attachSpring(int i, int j, double springL, double springC) //to attachspring on sphere i and sphere j

71 72 sphereIndex[pairIndex][0]=i;73 sphereIndex[pairIndex][1]=j;74 springConst[pairIndex] = springC;75 springLength[pairIndex] = springL;76 pairIndex++;77 78

79 void Sphere::force1() //Spring Force, works only on attached spheres, withdamping

80 81 double R, Rx, Ry, xFji=0, yFji=0, deltaR;

13

Page 14: Simulasi Gempa Dengan TMD

82 int i,j;83

84 //sums all of the forces (beware of the sign) for all pairs85 for(int k=0; k<pairIndex; k++)86 87 i = sphereIndex[k][0];88 j = sphereIndex[k][1];89

90

91 //determine the relative position vector92 Rx = ( xpos[i] - xpos[j] );93 Ry = ( ypos[i] - ypos[j] );94

95

96 R = sqrt(Rx*Rx + Ry*Ry);97 deltaR = R - springLength[k];98

99 xFji = springConst[k]*deltaR*Rx/R;100

101 xtotalF[j] += xFji - dampingConst*(xvel[j] - xvel[i]);102

103 xtotalF[i] += -xFji - dampingConst*(xvel[i] - xvel[j]);104

105 yFji = springConst[k]*deltaR*Ry/R;106

107 ytotalF[j] += yFji - dampingConst*(yvel[j] - yvel[i])108 ;109

110 ytotalF[i] += -yFji - dampingConst*(yvel[i] - yvel[j])111 ;112

113 114 115

116 //===================================================== GROUND CONSTRAINT117 void checkGround()118 119 for(int i=0; i<nSpheres; i++)120 121 if(pball->ypos[i] <= 0)122 123 pball->yvel[i] = fabs(pball->yvel[i]);124 pball->ypos[i] = 0;125 126 127 128

129

130 //================================================= MOVER, PLOTTER, MOVIEMAKER

131

132 void horiOscillator(double times) //oscillate the ground floor133 134 static double xi = pball->xpos[0];

14

Page 15: Simulasi Gempa Dengan TMD

135 static double xj = pball->xpos[1];136 static double xk = pball->xpos[2];137 //static double xl = pball->xpos[3];138

139 //stab the sphere140 pball->ypos[0] = 0.0;141 pball->ypos[1] = 0.0;142 pball->ypos[2] = 0.0;143

144 pball->xpos[0] = -4 + amplitude*sin(omega*times);145 pball->xpos[1] = 0 + amplitude*sin(omega*times);146 pball->xpos[2] = 4 + amplitude*sin(omega*times);147 148

149 void plotToMonitor()150 151 pspherePlot->redata();152 pspherePlot->recommand();153

154 for(int l=0; l<nSpheres; l++)155 156 pspherePlot->data157 <<pball->xpos[l]<<" "<<pball->ypos[l]<<endl;158 159

160

161 for(int k=0; k<pairIndex; k++)162 163 int i = sphereIndex[k][0];164 int j = sphereIndex[k][1];165

166 pspherePlot->command167 <<"set arrow "<<k+1<<" from "<<pball->xpos[i]<<","<<pball->ypos[i

]<<" to "168 <<pball->xpos[j]<<","<<pball->ypos[j]<<" nohead lw 6 ;"<<endl;169 170

171 pspherePlot->command172 <<"set xzeroaxis 7;set size square;"173 <<"set border;"174 <<"plot [-11:11][-2:"<<numOfFloors*3.2<<"]"175 <<"’plotdata.txt’ w p pt 7 ps 1.5 lc 3"176 <<";pause -1 \n";177

178 pspherePlot->plot();179 180

181 void plotToPNG() //move all the balls and put it on a frame182 183 static int imageNum = 0.0;184 pspherePlot->redata();185 pspherePlot->recommand();186

187

15

Page 16: Simulasi Gempa Dengan TMD

188 //plot the motions and apply the periodic boundary algorithm189 for(int i =0; i<nSpheres; i++) 190 pspherePlot->data191 <<pball->xpos[i]<<" "<<pball->ypos[i]<<endl;192 193

194

195 for(int k=0; k<pairIndex; k++)196 197 int i = sphereIndex[k][0];198 int j = sphereIndex[k][1];199

200 pspherePlot->command201 <<"set arrow "<<k+1<<" from "<<pball->xpos[i]<<","<<pball->ypos[i

]<<" to "202 <<pball->xpos[j]<<","<<pball->ypos[j]<<" nohead lw 6 ;"<<endl;203 204

205 pspherePlot->command206 <<"set term png size 480,750;set xzeroaxis 7;"207 <<"set out "208 <<"’images"209 <<"_"<<imageNum<<".png’ ;" // png filename210 <<"set border;"211 <<"plot [-11:11] [-2:"<<numOfFloors*3<<"]"212 <<" ’plotdata.txt’ w p pt 7 ps 1.5 lc 3"213 <<";\n";214

215 pspherePlot->plot();216

217 imageNum++;218 219

220 void makeMovie()221 222 string movieCommand= "C:\\Users\\user\\Downloads\\ffmpeg\\bin\\ffmpeg -

qscale 5 -r ";223 movieCommand.append(movieSpeed);224 movieCommand.append(" -b 9600 -i image\\_\%d.png quake.mp4 \n");225 system(movieCommand.c_str());226 227

228 //double dampingRatioTMD(int floor)229 //230 // double totalMassBuilding = massPerSphere*floor;231 // double massBar = massDamper/totalMassBuilding;232 // double xi = 0;233 //234 // return ;235 //236

237 double meanShearForce(int floor) //menghitung gaya gunting tiap lantai238 239 double f1,f2,f3,result;

16

Page 17: Simulasi Gempa Dengan TMD

240 f1 = pball->xacc[floor*3] * massPerSphere;241 f2 = pball->xacc[floor*3+1] * massPerSphere;242 f3 = pball->xacc[floor*3+2] * massPerSphere;243 result = (f1+f2+f3)/3.0;244 return fabs(result);245 246

247

248 double temp[numOfFloors+1];249 void shearForcePlot() //plot the shear forces on each floor250 251 static int firstTime = 1;252 double tempValue;253

254 pshearPlot->redata();255

256 if(firstTime != 0)257 258 for(int i=0; i<(numOfFloors+1); i++)259 260 temp[i] = 0.0;261 262 firstTime=0;263 264

265 for(int f=1;f<numOfFloors;f++)266 267 tempValue = meanShearForce(f);268

269 if(tempValue>temp[f])270 271 pshearPlot->data272 <<f<<" "<<tempValue<<endl;273 temp[f] = tempValue;274

275 276 else277 278 pshearPlot->data279 <<f<<" "<<temp[f]<<endl;280 281

282 283

284 pshearPlot->closeData();285 286

287 void plotShearToMonitor()288 289 pspherePlot->recommand();290

291 pspherePlot->command292 <<"set zeroaxis 7; set xlabel ’Floor Number’; set ylabel ’Maximum

Shear Force (N)’;"

17

Page 18: Simulasi Gempa Dengan TMD

293 <<"set border; set grid;"294 <<"plot "295 <<"’shearData.txt’ w l"296 <<";pause -1 \n";297

298 pspherePlot->plot();299 300

301

302 //============================================== MAIN FUNCTION303 int main()304 305 //place the y position spheres306 for(int f = 0; f<=numOfRooms ; f++)307 308 for(int r = 0; r<=numOfFloors; r++)309 310 pball->ypos[3*r+f] = 3.0*r;311 312 313

314 for(int r = 0; r<=numOfFloors; r++)315 316 pball->xpos[r*3] = -4;317 pball->xpos[r*3+1] = 0;318 pball->xpos[r*3+2] = 4;319 320

321

322 //wall spring323 for(int r = 0; r<nSpheres-3; r++)324 325 attachSpring(r,r+3, 3.0, wallSpringConst);326 327

328 //floor spring329 for(int r = 0; r < numOfFloors; r++)330 331 attachSpring(r*3, r*3+1, 4.0, wallSpringConst);332 attachSpring(r*3+1, r*3+2, 4.0, wallSpringConst);333 334

335 //cross spring336 for(int r = 0; r < numOfFloors-1; r++)337 338 attachSpring(r*3,r*3+4, 5.0, shearSpringConst);339 attachSpring(r*3+1,r*3+5, 5.0, shearSpringConst);340 341

342 for(int r = 0; r < numOfFloors-1; r++)343 344 attachSpring(r*3+1,r*3+1+2, 5.0, shearSpringConst);345 attachSpring(r*3+2,r*3+2+2, 5.0, shearSpringConst);346

18

Page 19: Simulasi Gempa Dengan TMD

347

348

349 //attach the mass350 for(int i = 0; i<nSpheres; i++)351 352 pball->mass[i] = massPerSphere;353 354

355 //Plot the initial conditions to monitor356 plotToMonitor();357 cout<<"calculating..."<<endl;358

359 //Compute and write the changing positions360 for(double time=0.0;time<timeEnds;time+=timeStep)361 362 checkGround();363

364 pball->velVerletMove(timeStep);365

366 if (shake==true) horiOscillator(time);367

368 if(torquePlot==true) shearForcePlot();369

370 if((createMovie==true) and ((int) (time/timeStep)%25 == 0))371 372 plotToPNG();373 374

375 //describe the computation progress376 if( ((int) (time/timeStep)) % 50 == 0)377 378 system("cls");379 cout<< (int) (100 * time/timeEnds) <<" % ";380 381

382 383 system("cls");384 cout<<"100 %"<<endl;385

386

387 //Plot the final conditions388 plotToMonitor();389 cout<<endl;390

391 if(createMovie==true)392 393 makeMovie();394 395

396 if(torquePlot==true)397 398 plotShearToMonitor();399 400

19

Page 20: Simulasi Gempa Dengan TMD

401 system("pause");402

20