단질점 저항계의 지진 반응(선형 가속도법-C# 코드)

2092 단어
        /// 
        ///        f             ath           
        /// 
        ///    
        ///           
        ///            
        ///      
        /// 
        public static void  SdofResponse(double h, double f, double dt, double[] ath,ref double[] acc,ref double[] vel,ref double[] dis)
        {
            int nSample = ath.Length;
             //acc = new double[nSample];
             //vel = new double[nSample];
             //dis = new double[nSample];
            double w = 2 * Math.PI * f;
            double w2 = w * w;
            double hw = h * w;
            double wd = w * Math.Sqrt(1 - h * h);
            double wdt = wd * dt;
            double E = Math.Exp(-hw * dt);
            double cwdt = Math.Cos(wdt);
            double swdt = Math.Sin(wdt);
            double a11 = E * (cwdt + hw * swdt / wd);
            double a12 = E * swdt / wd;
            double a21 = -E * w2 * swdt / wd;
            double a22 = E * (cwdt - hw * swdt / wd);

            double s1 = 2 * h / w2 / w / dt;
            double s2 = (1 - 2 * h * h) / w2 / wdt;
            double s3 = 1 / w2 / dt;
            double s4 = h / w / wdt;
            double b11 = E * ((1 / w2 + s1) * cwdt + (h / w / wd - s2) * swdt) - s1;
            double b12 = E * (-s1 * cwdt + s2 * swdt) - 1 / w2 + s1;
            double b21 = E * (-s3 * cwdt - (s4 + 1 / wd) * swdt) + s3;
            double b22 = E * (s3 * cwdt + s4 * swdt) - s3;

            acc[0] = 2 * hw * ath[0] * dt;
            vel[0] = -ath[0] * dt;
            dis[0] = 0;
            //acc[0] = 0;
            //vel[0] = 0;
            //dis[0] = 0;

            for (int i = 1; i < nSample; i++)
            {
                dis[i] = a11 * dis[i - 1] + a12 * vel[i - 1] + b11 * ath[i - 1] + b12 * ath[i];
                vel[i] = a21 * dis[i - 1] + a22 * vel[i - 1] + b21 * ath[i - 1] + b22 * ath[i];
                acc[i] = -2 * hw * vel[i] - w2 * dis[i];
            }
        } 

좋은 웹페이지 즐겨찾기