SORMAnalysis.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.6 $
00026 // $Date: 2003/10/27 23:45:41 $
00027 // $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/analysis/SORMAnalysis.cpp,v $
00028 
00029 
00030 //
00031 // Written by Terje Haukaas (haukaas@ce.berkeley.edu)
00032 //
00033 
00034 #include <SORMAnalysis.h>
00035 #include <ReliabilityDomain.h>
00036 #include <ReliabilityAnalysis.h>
00037 #include <FindCurvatures.h>
00038 #include <LimitStateFunction.h>
00039 #include <NormalRV.h>
00040 #include <math.h>
00041 #include <Vector.h>
00042 
00043 #include <fstream>
00044 #include <iomanip>
00045 #include <iostream>
00046 using std::ifstream;
00047 using std::ios;
00048 using std::setw;
00049 using std::setprecision;
00050 using std::setiosflags;
00051 
00052 
00053 SORMAnalysis::SORMAnalysis(     ReliabilityDomain *passedReliabilityDomain,
00054                                                         FindCurvatures *passedCurvaturesAlgorithm,
00055                                                     TCL_Char *passedFileName)
00056 :ReliabilityAnalysis()
00057 {
00058         theReliabilityDomain = passedReliabilityDomain;
00059         theCurvaturesAlgorithm = passedCurvaturesAlgorithm;
00060         fileName = new char[256];
00061         strcpy(fileName,passedFileName);
00062 }
00063 
00064 
00065 SORMAnalysis::~SORMAnalysis()
00066 {
00067         if (fileName != 0)
00068                 delete [] fileName;
00069 }
00070 
00071 
00072 
00073 int 
00074 SORMAnalysis::analyze(void)
00075 {
00076         // Alert the user that the SORM analysis has started
00077         opserr << "SORM Analysis is running ... " << endln;
00078 
00079 
00080         // Declare variables used in this method
00081         Vector curvatures;
00082         int numberOfCurvatures;
00083         double beta;
00084         double pf1;
00085         double psi_beta;
00086         double product;
00087         int i;
00088         double pf2Breitung;
00089         double betaBreitung;
00090         LimitStateFunction *theLimitStateFunction;
00091         NormalRV *aStdNormRV = 0;
00092         aStdNormRV = new NormalRV(1,0.0,1.0,0.0);
00093 
00094 
00095         // Check if computer ran out of memory
00096         if (aStdNormRV==0) {
00097                 opserr << "SORMAnalysis::analyze() - out of memory while instantiating internal objects." << endln;
00098                 return -1;
00099         }
00100 
00101 
00102         // Number of limit-state functions
00103         int numLsf = theReliabilityDomain->getNumberOfLimitStateFunctions();
00104 
00105 
00106         // Open output file
00107         ofstream outputFile( fileName, ios::out );
00108 
00109 
00110         // Loop over number of limit-state functions
00111         for (int lsf=1; lsf<=numLsf; lsf++ ) {
00112 
00113 
00114                 // Inform the user which limit-state function is being evaluated
00115                 opserr << "Limit-state function number: " << lsf << endln;
00116 
00117 
00118                 // Set tag of "active" limit-state function
00119                 theReliabilityDomain->setTagOfActiveLimitStateFunction(lsf);
00120 
00121 
00122                 // Get the limit-state function pointer
00123                 theLimitStateFunction = 0;
00124                 lsf = theReliabilityDomain->getTagOfActiveLimitStateFunction();
00125                 theLimitStateFunction = theReliabilityDomain->getLimitStateFunctionPtr(lsf);
00126                 if (theLimitStateFunction == 0) {
00127                         opserr << "SORMAnalysis::analyze() - could not find" << endln
00128                                 << " limit-state function with tag #" << lsf << "." << endln;
00129                         return -1;
00130                 }
00131 
00132 
00133                 // Compute curvature(s)
00134                 if (theCurvaturesAlgorithm->computeCurvatures(theReliabilityDomain) < 0){
00135                         opserr << "SORMAnalysis::analyze() - failed while finding " << endln
00136                                 << " curvatures for limit-state function number " << lsf << "." << endln;
00137                         return -1;
00138                 }
00139 
00140 
00141                 // Get results
00142                 curvatures = theCurvaturesAlgorithm->getCurvatures();
00143                 numberOfCurvatures = curvatures.Size();
00144                         
00145 
00146                 // Get FORM results from the limit-state function
00147                 beta = theLimitStateFunction->FORMReliabilityIndexBeta;
00148                 pf1 = theLimitStateFunction->FORMProbabilityOfFailure_pf1;
00149 
00150 
00151                 // Compute failure probability by "Breitung"
00152                 double denominator = aStdNormRV->getCDFvalue(-beta);
00153                 if (denominator == 0.0) {
00154                         opserr << "SORMAnalysis::analyze() - denominator zero " << endln
00155                                 << " due to too large reliability index value." << endln;
00156                         return -1;
00157                 }
00158                 psi_beta = aStdNormRV->getPDFvalue(beta)/denominator;
00159                 product = 1.0;
00160                 for (i=0; i<numberOfCurvatures; i++ ) {
00161                         product = product / sqrt(1.0+psi_beta*curvatures(i));
00162                 }
00163                 pf2Breitung = pf1 * product;
00164 
00165 
00166                 // Compute corresponding beta's
00167                 betaBreitung = -aStdNormRV->getInverseCDFvalue(pf2Breitung);
00168 
00169 
00170                 // Put results into reliability domain
00171                 theLimitStateFunction->numberOfCurvatauresUsed = numberOfCurvatures;
00172                 theLimitStateFunction->SORMUsingSearchPf2Breitung = pf2Breitung;
00173                 theLimitStateFunction->SORMUsingSearchBetaBreitung = betaBreitung;
00174 
00175 
00176                 // Print SORM results to the output file
00177                 outputFile << "#######################################################################" << endln;
00178                 outputFile << "#  SORM ANALYSIS RESULTS, LIMIT-STATE FUNCTION NUMBER "
00179                         <<setiosflags(ios::left)<<setprecision(1)<<setw(4)<<lsf <<"            #" << endln;
00180                 outputFile << "#  (Curvatures found from search algorithm.)                          #" << endln;
00181                 outputFile << "#                                                                     #" << endln;
00182                 outputFile << "#  Number of principal curvatures used: ............... " 
00183                         <<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<numberOfCurvatures
00184                         << "  #" << endln;
00185                 outputFile << "#  Reliability index beta (impr. Breitung's formula):.. " 
00186                         <<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<betaBreitung 
00187                         << "  #" << endln;
00188                 outputFile << "#  Corresponding estimated probability of failure pf2:.." 
00189                         <<setiosflags(ios::left)<<setprecision(5)<<setw(12)<<pf2Breitung 
00190                         << "  #" << endln;
00191                 outputFile << "#                                                                     #" << endln;
00192                 outputFile << "#######################################################################" << endln << endln << endln;
00193         }
00194 
00195 
00196         // Inform user on screen
00197         opserr << "SORM analysis completed. " << endln;
00198 
00199         // Clean up
00200         outputFile.close();
00201         delete aStdNormRV;
00202 
00203         return 0;
00204 }
00205 

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