SimulatedRandomProcessSeries.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 2001, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** Reliability module developed by:                                   **
00020 **   Terje Haukaas (haukaas@ce.berkeley.edu)                          **
00021 **   Armen Der Kiureghian (adk@ce.berkeley.edu)                       **
00022 **                                                                    **
00023 ** ****************************************************************** */
00024                                                                         
00025 // $Revision: 1.1 $
00026 // $Date: 2003/03/04 00:49:21 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/domain/pattern/SimulatedRandomProcessSeries.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu), February 2002
00032 // Revised: 
00033 //
00034 
00035 #include <SimulatedRandomProcessSeries.h>
00036 #include <Vector.h>
00037 #include <Channel.h>
00038 #include <Spectrum.h>
00039 #include <RandomNumberGenerator.h>
00040 #include <classTags.h>
00041 //#include <fstream>
00042 
00043 
00044 SimulatedRandomProcessSeries::SimulatedRandomProcessSeries(
00045                                                                 RandomNumberGenerator *theRandNumGenerator,
00046                                                                 Spectrum *theSpectr,
00047                                                                 int numFreqInt,
00048                                                                 double pmean)
00049 :TimeSeries(TSERIES_TAG_SimulatedRandomProcessSeries)
00050 {
00051         theRandomNumberGenerator = theRandNumGenerator;
00052         theSpectrum = theSpectr;
00053         numFreqIntervals = numFreqInt;
00054         mean = pmean;
00055 
00056         
00057         // Generate random numbers, uniformly distributed between 0 and 2pi
00058         double pi = 3.14159265358979;
00059         theRandomNumberGenerator->generate_nIndependentUniformNumbers(numFreqIntervals,0.0,(2*pi));
00060         Vector theta1 = theRandomNumberGenerator->getGeneratedNumbers();
00061         theta = new Vector(theta1);
00062         
00063 
00064         // Generate standard normal random numbers
00065         theRandomNumberGenerator->generate_nIndependentStdNormalNumbers(numFreqIntervals);
00066         Vector A1 = theRandomNumberGenerator->getGeneratedNumbers();
00067         A = new Vector(A1);
00068 
00069 
00070         // Length of each interval
00071         deltaW = (theSpectrum->getMaxFrequency()-theSpectrum->getMinFrequency())/numFreqIntervals;
00072 
00073 
00074 }
00075 
00076 
00077 SimulatedRandomProcessSeries::~SimulatedRandomProcessSeries()
00078 {
00079         if (theta != 0)
00080                 delete theta;
00081         if (A != 0) 
00082                 delete A;
00083 }
00084 
00085 
00086 double
00087 SimulatedRandomProcessSeries::getFactor(double time)
00088 {
00089 //static ofstream outputFile( "simulated_process.out" , ios::out );
00090 
00091         if (time == 0.0) {
00092                 return 0.0;
00093         }
00094         else {
00095 
00096                 // Add up over all frequency intervals
00097                 double factor = 0.0;
00098                 double W, S;
00099                 for (int i=0; i<numFreqIntervals; i++) {
00100                         W = (i+0.5)*deltaW+theSpectrum->getMinFrequency();
00101                         S = theSpectrum->getAmplitude(W);
00102                         factor += sqrt(2.0*S*deltaW) * (*A)(i) * cos(W*time+(*theta)(i));
00103                 }
00104 
00105 //outputFile << (mean+factor) << endl;
00106 
00107                 return (mean + factor);
00108         }
00109 }
00110 
00111 
00112 
00113 
00114 int
00115 SimulatedRandomProcessSeries::sendSelf(int commitTag, Channel &theChannel)
00116 {
00117         return 0;
00118 }
00119 
00120 
00121 int 
00122 SimulatedRandomProcessSeries::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00123 {
00124         return 0;    
00125 }
00126 
00127 
00128 void
00129 SimulatedRandomProcessSeries::Print(OPS_Stream &s, int flag)
00130 {
00131 }

Generated on Mon Oct 23 15:05:02 2006 for OpenSees by doxygen 1.5.0