QuadraticCyclic.cpp

Go to the documentation of this file.
00001 #include "QuadraticCyclic.h"
00002 #include <math.h>
00003 
00004 Matrix QuadraticCyclic::X(3,3);
00005 Vector QuadraticCyclic::Y(3);
00006 Vector QuadraticCyclic::A(3);
00007 
00008 QuadraticCyclic::QuadraticCyclic(int tag, double wt, double fac_y)
00009 :CyclicModel(tag, -1), weightFactor(wt), facty(fac_y),
00010  qx1(0.0), qy1(0.0), qx2(0.0), qy2(0.0), qx3(0.0), qy3(0.0)
00011 {
00012 
00013 }
00014 
00015 QuadraticCyclic::~QuadraticCyclic()
00016 {
00017   // does nothing
00018 }
00019 
00020 int QuadraticCyclic::createFullCycleTask()
00021 {
00022 int res = this->CyclicModel::createFullCycleTask();
00023     res+= createTask();
00024 
00025 return res;
00026 }
00027 
00028 int QuadraticCyclic::createHalfCycleTask()
00029 {
00030 int res = this->CyclicModel::createHalfCycleTask();
00031     res+= createTask();
00032     
00033 return res;
00034 }
00035 
00036 
00037 CyclicModel *QuadraticCyclic::getCopy()
00038 {
00039 CyclicModel *newModel = new QuadraticCyclic(getTag(), weightFactor, facty);     
00040         return newModel;
00041 }
00042 
00043 
00044 int QuadraticCyclic::createTask()
00045 {
00046         if(f_bgn*f_end < 0)
00047         {
00048                 double k0 = k_init;
00049                 double delx0 = f_bgn/(resFactor*k0);  //say +ive
00050 
00051                 double qy = facty;
00052                 double x1 = d_bgn,                   y1 = f_bgn;
00053 
00054 //              double x2 = d_bgn + delx0*(qy-1),    y2 = qy*f_bgn;
00055 //              double x3 = qx*(d_bgn-delx0),        y3 = 0.0;
00056 
00057 //              double x2 = qx*(d_bgn - delx0),      y2 = 0.0;
00058 //              double x3 = d_end;
00059 //              double y3 = f_end;
00060 
00061 
00062 
00063                 double delx2 = delx0*(1 - qy);   // +ive
00064                 double x2 = d_bgn - delx2;       // +ive
00065                 double y2 = qy*f_bgn;            // +ive
00066 
00067                 double x0 = d_bgn - delx0;       // +ive (at least 0)
00068                 double y0 = 0.0;  // always - don't change
00069                 
00070                 double R  = sqrt( (x2 - x0)*(x2 - x0) + (y2 - y0)*(y2 - y0));
00071                 double delx_end = d_end - x0;    // -ive
00072         double dely_end = f_end - y0;    // -ive
00073                 
00074                 double R_end = sqrt(delx_end*delx_end + dely_end*dely_end);
00075 
00076                 double delx3 = delx_end*R/R_end; // -ive
00077                 double y3 = f_end*R/R_end;       // -ive
00078                 double x3 = x0 + delx3;          // +ive
00079                 
00080 //        opserr << "R = " << R << ", Re = " << R_end << ", R/Re = " << R/R_end << endln;
00081 //        opserr << "x1, y1 = " << x1 << ", " << y1 << endln;
00082 //        opserr << "x2, y2 = " << x2 << ", " << y2 << endln;
00083 //        opserr << "x0, y0 = " << x0 << ", " << y0 << endln;
00084 //        opserr << "x3, y3 = " << x3 << ", " << y3 << endln;
00085 //
00086 //        opserr << *this;
00087 //        opserr << "\a";
00088 
00089         qx1 = x1; qy1 = y1;
00090         qx2 = x2; qy2 = y2;
00091         qx3 = x3; qy3 = y3;
00092                                        
00093                 solveQuad(x1, y1, x2, y2, x3, y3);
00094         }
00095 
00096         return 0;
00097 }
00098 
00099 
00100 int QuadraticCyclic::solveQuad(double x1, double y1, double x2,
00101                                double y2, double x3, double y3)
00102 {
00103 
00104         X(0,0) = x1*x1; X(0,1) = x1; X(0,2) = 1.0;
00105         X(1,0) = x2*x2; X(1,1) = x2; X(1,2) = 1.0;
00106         X(2,0) = x3*x3; X(2,1) = x3; X(2,2) = 1.0;
00107 
00108         Y(0) = y1; Y(1) = y2; Y(2) = y3;
00109 
00110         A = Y/X;
00111         a = A(0);
00112         b = A(1);
00113         c = A(2);
00114         
00115         // opserr << A;
00116 
00117         return 0;
00118 }
00119 
00120 double QuadraticCyclic::getQuadFactor(double x1, double y1, double dx)
00121 {
00122 // double dx = (d_curr - d_hist)/2;
00123 double x_nxt = x1 + dx;
00124 double y_nxt = a*x_nxt*x_nxt + b*x_nxt + c;
00125 double x_prv = x1 - dx;
00126 double y_prv = a*x_prv*x_prv + b*x_prv + c;
00127 
00128 //      opserr << "x1, y1 = " << x_nxt << ", " <<  y_nxt << endln;
00129 //      opserr << "x2, y2 = " << x_prv << ", " <<  y_prv << endln;
00130         return (rationalize(x_prv, y_prv, x_nxt, y_nxt));
00131 
00132 }
00133 
00134 
00135 double QuadraticCyclic::getTaskFactor()
00136 {
00137 double tfactor;
00138 //      // redundant - only for print
00139 //      if(d_curr >= 0 && !initYieldPos)
00140 //              return 1.0;
00141 //      if(d_curr  < 0 && !initYieldNeg)
00142 //              return 1.0;
00143 //      // end redundant
00144 
00145 
00146 
00147         if(yielding /*&& fabs(d_curr) >= fabs(d_end) */)
00148 //              return resFactor; // will eventually unload
00149                 tfactor = cycFactor_hist;
00150     else
00151     {
00152         if(f_bgn*f_end < 0)
00153         {
00154                 // if(contains(0.0, f_bgn, f_curr))
00155                         if(contains(qy1, qy3, f_curr))  
00156                         tfactor = getQuadFactor(d_curr, f_curr, (d_curr - d_hist)/2);
00157                 else
00158                         {
00159                                 tfactor=rationalize(d_curr, f_curr, d_end, f_end);
00160                                 tfactor = weightFactor*tfactor + (1 - weightFactor)*resFactor;
00161                     }
00162         }
00163         else // half-cycle
00164                 {
00165                 tfactor = rationalize(d_bgn, f_bgn, d_end, f_end);
00166             tfactor = weightFactor*tfactor + (1 - weightFactor)*resFactor;
00167                 }
00168         }
00169 
00170 //      opserr << "tfactor = " << tfactor << endln;
00171         return tfactor;
00172 }
00173 
00174 void QuadraticCyclic::Print (OPS_Stream &s, int flag)
00175 {
00176         this->CyclicModel::Print (s, flag);
00177         s << "+QuadraticCyclic\n";
00178         s << "   taskFactor = " << cycFactor << endln;
00179         s << "   a=" << a <<", b=" << b <<", c=" << c << endln;
00180         s << "----------------------------------------"
00181       << "----------------------------------------"
00182           << endln;
00183 }
00184 
00185 
00186 

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