MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/models/unconv01.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_UNCONV01_H
00021 #define MECHSYS_UNCONV01_H
00022 
00023 // MechSys
00024 #include <mechsys/models/elastoplastic.h>
00025 
00026 using std::cout;
00027 using std::endl;
00028 
00029 class Unconv01 : public Model
00030 {
00031 public:
00032     // Constructor
00033     Unconv01 (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 
00041     // Data
00042     double         l0,l1,l3,betb,betbb; 
00043     mutable double v0,xR10,xR30;        
00044     double         M;                   
00045     mutable double K,G,nu;              
00046     Vec_t          I;                   
00047     Mat_t          De;                  
00048 
00049     // Scratchpad
00050     mutable Vec_t  V,Vb,VDe,DeW,devSig,depsEl;
00051     mutable double p,q,t,y0,lamb,lambb,hp;
00052 
00053 private:
00054     // internal methods
00055     void _calc_invariants_and_gradients (EquilibState const * Sta) const 
00056     {
00057         // invariants
00058         OctInvs (Sta->Sig, p,q,t);
00059         Dev     (Sta->Sig, devSig);
00060 
00061         // gradients
00062         double z0 = Sta->Ivs(0);
00063         double pb = exp(z0);
00064         y0 = -M*M*p*exp(z0);
00065         V  = (M*M*(pb-2.0*p)/Util::SQ3)*I + 2.0*devSig;
00066     }
00067     void _calc_hardening (EquilibState const * Sta) const 
00068     {
00069         // internal variables
00070         double z0 = Sta->Ivs(0);
00071         double z1 = Sta->Ivs(1);
00072         double v  = Sta->Ivs(2);
00073 
00074         // isotropic coefficients
00075         double xR1    = xR10 + (log(v0/v))/l1;
00076         double distb  = z1 - xR1;
00077         double distbb = z1 - z0;
00078         double trW    = Tra(V);
00079         if (distb <0.0) distb  = 0.0;
00080         if (distbb<0.0) distbb = 0.0;
00081         lamb  = l3+(l1  -l3)*exp(-betb *distb);
00082         lambb = l0+(lamb-l0)*exp(-betbb*distbb);
00083         double H0 = -trW/lambb;
00084         hp = y0*H0;
00085         Vb = V + (y0*(-1.0/(3.0*lambb*K)))*I;
00086     }
00087 };
00088 
00089 
00091 
00092 
00093 inline Unconv01::Unconv01 (int NDim, SDPair const & Prms)
00094     : Model (NDim,Prms,"Unconv01")
00095 {
00096     // parameters
00097     l0    = Prms("l0");
00098     l1    = Prms("l1");
00099     l3    = Prms("l3");
00100     betb  = Prms("betb");
00101     betbb = Prms("betbb");
00102     M     = Phi2M(Prms("phi"));
00103     K     = Prms("K");
00104     G     = Prms("G");
00105 
00106     // constants
00107     I.change_dim (NCps);
00108     if (NDim==2) I = 1.0, 1.0, 1.0, 0.0;
00109     else         I = 1.0, 1.0, 1.0, 0.0, 0.0, 0.0;
00110 
00111     // internal values
00112     NIvs = 3;
00113     IvNames.Push ("z0");
00114     IvNames.Push ("z1");
00115     IvNames.Push ("v"); // specific volume = 1+e
00116 
00117     // elastic stiffness
00118     if (GTy==pse_t) throw new Fatal("Unconv01::Unconv01: This model does not work for plane-stress (pse)");
00119     Mat_t Psd,IdyI;
00120     Calc_Psd  (NCps,Psd);
00121     Calc_IdyI (NCps,IdyI);
00122     De = (2.0*G)*Psd + K*IdyI;
00123 
00124     /*
00125     double E  = 6000.0;
00126     double nu = 0.3;
00127     double c  = E/((1.0+nu)*(1.0-2.0*nu));
00128     De = c*(1.0-nu),       c*nu ,      c*nu ,            0.0,            0.0,            0.0,
00129               c*nu ,  c*(1.0-nu),      c*nu ,            0.0,            0.0,            0.0,
00130               c*nu ,       c*nu , c*(1.0-nu),            0.0,            0.0,            0.0,
00131                0.0 ,        0.0 ,       0.0 , c*(1.0-2.0*nu),            0.0,            0.0,
00132                0.0 ,        0.0 ,       0.0 ,            0.0, c*(1.0-2.0*nu),            0.0,
00133                0.0 ,        0.0 ,       0.0 ,            0.0,            0.0, c*(1.0-2.0*nu);
00134     cout <<"De(KG) =\n" << PrintMatrix(De);
00135     cout <<"De(Enu) =\n" << PrintMatrix(De);
00136     */
00137 
00138     // scratchpad
00139     V     .change_dim (NCps);
00140     Vb    .change_dim (NCps);
00141     VDe   .change_dim (NCps);
00142     DeW   .change_dim (NCps);
00143     devSig.change_dim (NCps);
00144     depsEl.change_dim (NCps);
00145 }
00146 
00147 inline void Unconv01::InitIvs (SDPair const & Ini, State * Sta) const
00148 {
00149     // initialize state
00150     EquilibState * sta = static_cast<EquilibState*>(Sta);
00151     sta->Init (Ini, NIvs);
00152 
00153     // NCL position and specific void
00154     xR10 = Ini("xR10");
00155     xR30 = Ini("xR30");
00156     v0   = Ini("v0");
00157 
00158     // invariants
00159     double p,q,t;
00160     OctInvs (sta->Sig, p,q,t);
00161 
00162     // internal variables
00163     double pb = p+(q*q)/(p*M*M);
00164     sta->Ivs(0) = log(pb);
00165     sta->Ivs(1) = xR30;
00166     sta->Ivs(2) = v0;
00167 
00168     // check initial yield function
00169     double f = q*q + (p-pb)*p*M*M;
00170     if (f>1.0e-8) throw new Fatal("Unconv01:InitIvs: stress point (sig=(%g,%g,%g,%g], p=%g, q=%g) is outside yield surface (f=%g) with pb=%g",sta->Sig(0),sta->Sig(1),sta->Sig(2),sta->Sig(3)/Util::SQ2,p,q,f,pb);
00171 }
00172 
00173 inline void Unconv01::TgIncs (State const * Sta, Vec_t & DEps, Vec_t & DSig, Vec_t & DIvs) const
00174 {
00175     // state
00176     EquilibState const * sta = static_cast<EquilibState const *>(Sta);
00177 
00178     // invariants and gradients
00179     _calc_invariants_and_gradients (sta); // calc: devSig,p,q,t,V,y0
00180 
00181     // volume strain increment and internal variables
00182     double dev = Calc_ev(DEps);
00183     //double z0  = sta->Ivs(0);
00184     double v   = sta->Ivs(2);
00185     //double pb  = exp(z0);
00186     //double f   = q*q + (p-pb)*p*M*M;
00187     //cout << "f(before) = " << f << endl;
00188 
00189     // increments
00190     if (sta->Ldg)
00191     {
00192         // hardening
00193         _calc_hardening (sta); // calc: lamb,lambb,hp,Vb
00194 
00195         // plastic multiplier
00196         Mult (Vb, De, VDe);
00197         double phi = dot(VDe,V) - hp;
00198         double gam = dot(VDe,DEps)/phi;
00199 
00200         // stress increment
00201         depsEl = DEps - gam*V;
00202         DSig   = De*depsEl;
00203 
00204         //double gam_ = -dot(Vb,DSig)/hp;
00205         //cout << "gam = " << gam << ", gam_ = " << gam_ << endl;
00206 
00207         // increment of internal values
00208         DIvs(0) = (-1.0/lambb)*dev;
00209         DIvs(1) = (-1.0/lamb )*dev;
00210         DIvs(2) = v*dev;
00211 
00212         //Vec_t hh0((-1.0/(3.0*lambb*K))*I);
00213         //double dz0 = dot(hh0,DSig) - Tra(V)*gam/lambb;
00214         //cout << "DIvs(0) = " << DIvs(0) << ", dz0 = " << dz0 << endl;
00215         //DIvs(0) = dz0;
00216 
00217         //Vec_t sigf(sta->Sig+DSig);
00218         //double z0f = z0+DIvs(0);
00219         //double pbf = exp(z0f);
00220         //double pf  = Calc_poct(sigf);
00221         //double qf  = Calc_qoct(sigf);
00222         //double ff  = qf*qf + (pf-pbf)*pf*M*M;
00223         //cout << "f(after)  = " << ff << endl; cout << endl;
00224     }
00225     else
00226     {
00227         // stress increment
00228         DSig = De*DEps;
00229 
00230         // increment of internal values
00231         Vec_t VDe;
00232         Mult (V, De, VDe);
00233         DIvs(0) = -dot(V,DSig)/y0;
00234         DIvs(1) = 0.0;
00235         DIvs(2) = v*dev;
00236     }
00237 }
00238 
00239 inline void Unconv01::Stiffness (State const * Sta, Mat_t & D) const
00240 {
00241     // state
00242     EquilibState const * sta = static_cast<EquilibState const *>(Sta);
00243 
00244     // stiffness
00245     if (sta->Ldg)
00246     {
00247         // invariants and gradients
00248         _calc_invariants_and_gradients (sta); // calc: devSig,p,q,t,V,y0
00249 
00250         // hardening
00251         _calc_hardening (sta); // calc: lamb,lambb,hp,Vb
00252 
00253         // auxiliar vectors
00254         Mult (Vb, De, VDe);
00255         double phi = dot(VDe,V) - hp;
00256         DeW = De*V;
00257 
00258         // elastoplastic stiffness
00259         D.change_dim (NCps, NCps);
00260         for (size_t i=0; i<NCps; ++i)
00261         for (size_t j=0; j<NCps; ++j)
00262             D(i,j) = De(i,j) - DeW(i)*VDe(j)/phi;
00263     }
00264     else D = De;
00265 }
00266 
00267 inline bool Unconv01::LoadCond (State const * Sta, Vec_t const & DEps, double & alpInt) const
00268 {
00269     // state
00270     EquilibState const * sta = static_cast<EquilibState const *>(Sta);
00271 
00272     // invariants and gradients
00273     _calc_invariants_and_gradients (sta); // calc: devSig,p,q,t,V,y0
00274 
00275     // check loading condition
00276     Mult (V, De, VDe);
00277     double num = dot(VDe,DEps);
00278     if (num<0.0) throw new Fatal("Unconv03::LoadCond: num(%g)<0 not ready yet",num);
00279 
00280     alpInt = -1.0; // no intersection (never in this model)
00281     return (num>0.0);
00282 }
00283 
00284 
00286 
00287 
00288 Model * Unconv01Maker(int NDim, SDPair const & Prms, Model const * O) { return new Unconv01(NDim,Prms); }
00289 
00290 int Unconv01Register()
00291 {
00292     ModelFactory["Unconv01"] = Unconv01Maker;
00293     MODEL.Set ("Unconv01", (double)MODEL.Keys.Size());
00294     return 0;
00295 }
00296 
00297 int __Unconv01_dummy_int = Unconv01Register();
00298 
00299 #endif // MECHSYS_UNCONV01_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines