MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/models/unconv04.h
Go to the documentation of this file.
00001 /************************************************************************
00002  * MechSys - Open Library for Mechanical Systems                        *
00003  * Copyright (C) 2005 Dorival M. Pedroso, Raul Durand                   *
00004  * Copyright (C) 2009 Sergio Galindo                                    *
00005  *                                                                      *
00006  * This program is free software: you can redistribute it and/or modify *
00007  * it under the terms of the GNU General Public License as published by *
00008  * the Free Software Foundation, either version 3 of the License, or    *
00009  * any later version.                                                   *
00010  *                                                                      *
00011  * This program is distributed in the hope that it will be useful,      *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
00014  * GNU General Public License for more details.                         *
00015  *                                                                      *
00016  * You should have received a copy of the GNU General Public License    *
00017  * along with this program. If not, see <http://www.gnu.org/licenses/>  *
00018  ************************************************************************/
00019 
00020 #ifndef MECHSYS_UNCONV04_H
00021 #define MECHSYS_UNCONV04_H
00022 
00023 // MechSys
00024 #include <mechsys/models/model.h>
00025 
00026 using std::cout;
00027 using std::endl;
00028 
00029 class Unconv04 : public Model
00030 {
00031 public:
00032     // Constructor
00033     Unconv04 (int NDim, SDPair const & Prms);
00034 
00035     // Derived methods
00036     void InitIvs    (SDPair const & Ini, State * Sta)                             const;
00037     void TgIncs     (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const;
00038     void Stiffness  (State const * Sta, Mat_t & D)                                const;
00039     bool LoadCond   (State const * Sta, Vec_t const & DEps, double & alpInt)      const;
00040     void UpdatePath (State const * Sta, Vec_t const & DEps, Vec_t const & DSig)   const;
00041 
00042     // Internal methods
00043     void Ref (double x, double a, double b, double c, double A, double B, double bet, double x0, double y0, double & D, double & lam, double & y) const;
00044 
00045     // Parameters
00046     double lam0, lam1, lam2, x1, x2, bet0, bet1;
00047     double psi0, psi1, ev1, ev2, bet2, bet3;
00048     double g0, g1, Mcs, Mso, bet4, bet5;
00049     double K, G;
00050 
00051     // Auxiliar data
00052     Vec_t I;
00053     Mat_t IdyI, Psd;
00054 
00055     // Modifiable data
00056     mutable double alpha;
00057 };
00058 
00059 
00061 
00062 
00063 inline Unconv04::Unconv04 (int NDim, SDPair const & Prms)
00064     : Model (NDim,Prms,/*niv*/0,"Unconv04"), alpha(0.0)
00065 {
00066     lam0 = Prms("lam0");
00067     lam1 = Prms("lam1");
00068     lam2 = Prms("lam2");
00069     x1   = Prms("x1");
00070     x2   = Prms("x2");
00071     bet0 = Prms("bet0");
00072     bet1 = Prms("bet1");
00073 
00074     psi0 = Prms("psi0");
00075     psi1 = Prms("psi1");
00076     ev1  = Prms("ev1");
00077     ev2  = Prms("ev2");
00078     bet2 = Prms("bet2");
00079     bet3 = Prms("bet3");
00080 
00081     g0   = Prms("g0");
00082     g1   = Prms("g1");
00083     Mcs  = Prms("Mcs");
00084     Mso  = Prms("Mso");
00085     bet4 = Prms("bet4");
00086     bet5 = Prms("bet5");
00087 
00088     K    = Prms("K");
00089     G    = Prms("G");
00090 
00091     Calc_I    (NCps, I);
00092     Calc_IdyI (NCps, IdyI);
00093     Calc_Psd  (NCps, Psd);
00094 }
00095 
00096 inline void Unconv04::InitIvs (SDPair const & Ini, State * Sta) const
00097 {
00098     EquilibState * sta = static_cast<EquilibState*>(Sta);
00099     sta->Init (Ini);
00100 }
00101 
00102 inline void Unconv04::TgIncs (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const
00103 {
00104     Mat_t D;
00105     Stiffness (Sta, D);
00106     DSig = D*DEps;
00107 }
00108 
00109 inline void Unconv04::Stiffness (State const * Sta, Mat_t & D) const
00110 {
00111     EquilibState const * sta = static_cast<EquilibState const*>(Sta);
00112 
00113     Vec3_t Le, Ls, v0, v1, v2, w0, w1, w2;
00114     Vec_t P0,P1,P2, Q0,Q1,Q2;
00115     EigenProj (sta->Eps, Le, w0,w1,w2, Q0,Q1,Q2, /*sort*/true);
00116     EigenProj (sta->Sig, Ls, v0,v1,v2, P0,P1,P2, /*sort*/true);
00117 
00118     Mat3_t X, Y, Yi; // devedgamdL, dpqthdL, dLdpqth
00119     double ev,ed,te;
00120     double p, q, ts;
00121     OctDerivs (Le, ev, ed, te, X);
00122     OctDerivs (Ls, p,  q,  ts, Y);
00123     InvOctDerivs (Ls, p,  q,  ts, Yi);
00124     double x = log(1.0+p);
00125 
00126     X(0,0) *= -1.;
00127     X(0,1) *= -1.;
00128     X(0,2) *= -1.;
00129 
00130     ev *= 100.;
00131     ed *= 100.;
00132 
00133     double D1,D3,D5,r0,r1,r2,lr0,lr1,lr2;
00134     //   x  , a    , b    , c        , A     , B    , bet  , x0  , y0    , D  , lam , y
00135     Ref (x  , lam1 , 1.0  , -lam1*x1 , lam2  , lam1 , bet1 , x2  , 0.0   , D1 , lr0 , r0);
00136     Ref (ed , 0.0  , -1.0 , ev2      , -psi1 , 0.0  , bet3 , 0.0 , ev1   , D3 , lr1 , r1);
00137     //Ref (ed , 0.0  , 1.0  , -Mcs   , g1    , 0.0  , bet5 , 0.0 , Mso , D5 , lr2 , r2);
00138     Ref (ed , 0.0  , 1.0  , -Mcs*p   , g1    , 0.0  , bet5 , 0.0 , Mso*p , D5 , lr2 , r2);
00139 
00140     double D0  = r0 - ev;
00141     double D2  = ev - r1;
00142     double D4  = r2 - q;
00143     double lam = lam0 + ( lr0 - lam0)*exp(-bet0*D0);
00144     double psi = psi0 + ( lr1 - psi0)*exp(-bet2*D2);
00145     double g   = g0   + (-lr2 - g0  )*exp(-bet4*D4);
00146     double A   = 1.0;
00147     double B   = 1.0;
00148 
00149     double a = -100.*(1.0+p)/(lam*A);
00150     double b = -100.*psi*B*(1.0+p)/(lam*A);
00151     double d =  100.*g;
00152     double m = 1.0;
00153 
00154     printf("a=%g, b=%g, d=%g\n",a,b,d);
00155 
00156 
00157     Mat3_t Z;
00158     Z =  a,   b,   0., 
00159          0.,  d,   0., 
00160          0.,  0.,  m;
00161 
00162     Mat3_t tm, E;
00163     //Inv (Y, Yi);
00164     tm = product (Yi, Z); // tm = Yi*Z
00165     E  = product (tm, X); // E  = tm*X = Yi*Z*X
00166 
00167     std::cout << "E=\n"   << PrintMatrix(E)        << std::endl;
00168 
00169     if (q<1.0e-7)
00170     {
00171         E = K+(4.0*G)/3.0,  K-(2.0*G)/3.0,  K-(2.0*G)/3.0,
00172             K-(2.0*G)/3.0,  K+(4.0*G)/3.0,  K-(2.0*G)/3.0,
00173             K-(2.0*G)/3.0,  K-(2.0*G)/3.0,  K+(4.0*G)/3.0;
00174     }
00175 
00176     std::cout << "sig="   << PrintVector(sta->Sig) << std::endl;
00177     std::cout << "X=\n"   << PrintMatrix(X)        << std::endl;
00178     std::cout << "Y=\n"   << PrintMatrix(Y)        << std::endl;
00179     std::cout << "Yi=\n"  << PrintMatrix(Yi)       << std::endl;
00180     std::cout << "Z=\n"   << PrintMatrix(Z)        << std::endl;
00181     std::cout << "E=\n"   << PrintMatrix(E)        << std::endl;
00182 
00183     D.change_dim (NCps,NCps);
00184     set_to_zero  (D);
00185     for (size_t i=0; i<NCps; ++i)
00186     for (size_t j=0; j<NCps; ++j)
00187     {
00188         //if (i<3 && j<3) D(i,j) = E(i,j);
00189         D(i,j) = P0(i)*E(0,0)*P0(j) + P0(i)*E(0,1)*P1(j) + P0(i)*E(0,2)*P2(j) + 
00190                  P1(i)*E(1,0)*P0(j) + P1(i)*E(1,1)*P1(j) + P1(i)*E(1,2)*P2(j) + 
00191                  P2(i)*E(2,0)*P0(j) + P2(i)*E(2,1)*P1(j) + P2(i)*E(2,2)*P2(j);
00192         if (i>2 && j>2 && i==j) D(i,j) += 1.0;
00193     }
00194 
00195     //Mat_t De;
00196     //De = (2.0*G)*Psd + K*IdyI;
00197     //std::cout << "De=\n" << PrintMatrix(De) << std::endl;
00198     std::cout << "D=\n"  << PrintMatrix(D)  << std::endl;
00199     //D = De;
00200 }
00201 
00202 inline bool Unconv04::LoadCond (State const * Sta, Vec_t const & DEps, double & alpInt) const
00203 {
00204     return true;
00205 }
00206 
00207 inline void Unconv04::UpdatePath (State const * Sta, Vec_t const & DEps, Vec_t const & DSig) const
00208 {
00209     double dq = Calc_qoct (DSig);
00210     double dp = Calc_poct (DSig);
00211     alpha = atan2(dq,dp);
00212     //printf("alpha = %g\n",alpha*180./Util::PI);
00213 }
00214 
00215 inline void Unconv04::Ref (double x, double a, double b, double c, double A, double B, double bet, double x0, double y0, double & D, double & lam, double & y) const
00216 {
00217     double c1 = bet*(b*A-a);
00218     double c2 = (A-B)*exp(-c*bet)/(A-a/b);
00219     double c3 = exp(b*bet*(y0+A*x0)) - c2*exp(c1*x0);
00220     //printf("c1=%g, c2=%g, c3=%g  ",c1,c2,c3);
00221     y   = -A*x + log(c3+c2*exp(c1*x))/(b*bet);
00222     D   = a*x + b*y + c;
00223     lam = A + (B - A)*exp(-bet*D);
00224 }
00225 
00226 
00228 
00229 
00230 Model * Unconv04Maker(int NDim, SDPair const & Prms, Model const * O) { return new Unconv04(NDim,Prms); }
00231 
00232 int Unconv04Register()
00233 {
00234     ModelFactory   ["Unconv04"] = Unconv04Maker;
00235     MODEL.Set      ("Unconv04", (double)MODEL.Keys.Size());
00236     MODEL_PRM_NAMES["Unconv04"].Resize(21);
00237     MODEL_PRM_NAMES["Unconv04"] = "lam0", "lam1", "lam2", "x1", "x2", "bet0", "bet1",
00238                                   "psi0", "psi1", "ev1", "ev2", "bet2", "bet3",
00239                                   "g0", "g1", "Mcs", "Mso", "bet4", "bet5",
00240                                   "K", "G";
00241     MODEL_IVS_NAMES["Unconv04"].Resize(0);
00242     return 0;
00243 }
00244 
00245 int __Unconv04_dummy_int = Unconv04Register();
00246 
00247 #endif // MECHSYS_UNCONV04_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines