Fortran 板


LINE

由於已經可以把data值跑出來但要如何取一段時間內 找出波峰的最大值, 外加求出週期比和頻率比的關係 程式如下fortran77語法有些真的很難懂 implicit real*8 (a-h,o-z) parameter (maxnf=200000) dimension f(maxnf),x(maxnf),v(maxnf),a(maxnf),res(maxnf) open(file='2freq.out', unit=20) PI=3.141592654 ncycle=100 F0=1.0 F1=0.5 phi1=0.0*PI xi=0.0 ratio=2 w=1.0*2*PI w2=w*ratio period=(2.*PI)/w dt=0.0025*period nf=int(period*real(ncycle)/dt) wn=2*PI alpha=0.05 fy=1.0 Fs=F1 do 234 jj=1,nf t=dt*real(jj-1) f(jj)=F0*cos(w*t)+F1*cos(w2*t+phi1) 234 continue call elastop(xi,wn,fy,alpha,nf,dt,f,x,v,res,xmax, & resmax,xmu) do 331 j=1,nf,1 t=dt*real(j-1) tscale=t/period acc=f(j)-2.*xi*wn*v(j)-res(j) write(20,300) tscale,x(j),v(j),acc,res(j),f(j) 331 continue 300 format (8f9.4) stop end subroutine elastop(xi,wn,fy,alpha,nf,dtorig,f,x,xd,res,xmax, & resmax,xmu) implicit real*8 (a-h,o-z) dimension f(*),x(*),res(*),xd(*) fyratio=0.005 ! 1% is allowed toler=0.001 ! 0.001 in vtol=wn*toler maxiter=5 cp=1.0 xxmax=0.0 xresmax=0.0 xdd0=cp*f(1) xkt1=(1.0-alpha)*wn*wn xkt2=alpha*wn*wn fy1=(1.0-alpha)*fy xy=fy1/xkt1 x(1)=0.0 xd(1)=0.0 pcenter=0.0 nstate=0 xold=0.0 xdold=0.0 xddold=xdd0 b=2.0*xi*wn t=0.0 do 100 i=1,nf dtmove=0.0 tprev=dtorig*(i-1) dt=dtorig t=tprev+dtorig df=f(i+1)-f(i) fprev=f(i) force=f(i+1) goto 467 466 icut=1 ! reduce time step dt=dt*0.5 df=df*0.5 force=fprev+df t=tprev+dt 468 if(icut.eq.0) then dt=dtorig-dtmove t=tprev+dtorig fprev=force df=f(i+1)-fprev force=f(i+1) endif 467 continue temp1=4.0/dt/dt + 2.0*b/dt xtemp=xnew do 234 iter=1,maxiter if (nstate.eq.0) then temp2=xkt1+xkt2 else temp2=xkt2 endif temp3=4.0/dt + b temp5=force+temp1*xold +temp3*xdold+ xddold if (nstate.eq.0) then gtemp=(xtemp-pcenter)*xkt1+xtemp*xkt2 elseif (nstate.eq.1) then gtemp=fy1+xtemp*xkt2 elseif (nstate.eq.2) then gtemp=-fy1+xtemp*xkt2 endif temp6=temp1*xtemp+gtemp dx= (temp5-temp6)/(temp1+temp2) xtemp=xtemp+dx if (abs(dx) .gt.toler) then goto 234 else goto 355 endif 234 continue 355 continue xnewtemp=xtemp xddnewtemp = 4.0/dt/dt*(xnewtemp-xold) -4.0/dt*xdold -xddold xdnewtemp = xdold +(xddold+xddnewtemp)*0.5*dt subroutine linear2(xi,wn,nf,dt,f,x,v,a,xmax) implicit real*8 (a-h,o-z) dimension array1(2,2),array2(2,2) dimension f(*),x(nf),v(nf),a(nf) wd=wn*sqrt(1.0-xi**2) dino1=exp((-1.0)*xi*wn*dt) dino2=xi/sqrt(1.0-xi**2) dino3=cos(wd*dt) dino4=sin(wd*dt) dino5=(2.0*xi**2-1.0)/(wn**2*dt) dino6=(2.0*xi)/(wn**3*dt) array1(1,1)=dino1*(dino3+dino2*dino4) array1(1,2)=(dino1/wd)*dino4 array1(2,1)=((-1.0)*wn/sqrt(1.0-xi**2))*dino1*dino4 array1(2,2)=dino1*(dino3-dino2*dino4) array2(1,1)=dino1*((dino5+xi/wn)*dino4/wd & +(dino6+1./wn**2)*dino3)-dino6 array2(1,2)=(-1.)*dino1*(dino5*dino4/wd+dino6*dino3) & -1./wn**2+dino6 array2(2,1)=(-1.)*(array1(1,1)-1.)/(wn**2*dt)-array1(1,2) array2(2,2)=(-1.)*array2(2,1)-array1(1,2) x(1)=0.0 v(1)=0.0 a(1)=f(1) xold=x(1) vold=v(1) fold=f(1) xmax=x(1) do 10 i=2,nf xnew=array1(1,1)*xold+array1(1,2)*vold & -array2(1,1)*fold-array2(1,2)*f(i) vnew=array1(2,1)*xold+array1(2,2)*vold & -array2(2,1)*fold-array2(2,2)*f(i) anew=f(i)-2.0*xi*wn*vnew-wn**2*xnew x(i)=xnew v(i)=vnew a(i)=anew fold=f(i) xold=xnew vold=vnew if(abs(x(i)).gt.xmax) xmax=abs(x(i)) 10 continue return end subroutine whitegen(w,nw,dt,S0,seed) implicit real*8 (a-h,o-z) dimension w(*) PI=3.14159 cons= sqrt(2*PI*S0/dt) do 11 i=1,nw,2 call myrand(seed) temp1=seed call myrand(seed) temp2=seed w(i) =cons*sqrt(-2.0*dlog(temp1))*cos(2.0*PI*temp2) w(i+1)=cons*sqrt(-2.0*dlog(temp1))*sin(2.0*PI*temp2) 11 continue return end subroutine myrand (x) implicit real*8(a-h,o-z) m=67108864 rm=67108864.0 a=3125.0 temp=x*a*rm xxrand=mod(temp,rm) x=xxrand/rm return end --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.205.61
1F:→ YCTzeng:抱歉,根本看不懂你在問什麼 04/30 15:03
2F:→ charlesdc:建議先自己先整個看懂吧 才知道要編輯哪裡 04/30 18:15
3F:→ boto18:我再說清楚一些 05/01 13:15
4F:→ boto18:我已經跑出所需要的data值但現在需要作量化的圖形 05/01 13:16
5F:→ boto18:想要利用do loop的形式 取在特定時間內圖形中波峰最大值 05/01 13:18
6F:→ boto18:外加求出此最大波峰值對應的週期和相鄰的兩波峰的數值 05/01 13:19
7F:→ YCTzeng:特定時間是指某一次迴圈當中的意思嗎?還是你的data有時間? 05/01 21:13
8F:→ boto18:我的程式跑出來第一行就是時間,我現在只想取其中一個區段 05/02 15:27
9F:→ boto18:例如30~100之間,ncycle=100就是我所設定的最大值 05/02 15:29
10F:→ boto18:程式跑來的第二行是位移 我已經運用繪圖軟體畫出所需之圖形 05/02 15:30
11F:→ boto18:但由於點數過多無法從肉眼分辨圖形中的波峰最大值 05/02 15:31
12F:→ charlesdc:設一個矩陣去吃再利用矩陣函式去找最大值?? 05/02 17:20
13F:→ boto18:我之前就是用矩陣的情況去寫,結果教授不接受 05/02 17:51
14F:→ YCTzeng:多宣告一個變數,初值=0.0,進入迴圈後判斷波峰是否大於變數 05/02 18:38
15F:→ YCTzeng:,.true.的話,變數=波峰,等迴圈全部作完,就是波峰最大值, 05/02 18:40
16F:→ charlesdc:你有問為什麼不接受嗎..... 05/02 21:06
17F:→ boto18:Y大不好意思 由於圖形的最大值可能不只一個 05/02 21:39
18F:→ boto18:我要取的兩個最大的波峰之間的週期,還有相鄰波峰的週期 05/02 21:40







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:iOS站內搜尋

TOP