proteus  1.8.1
C/C++/Fortran libraries
mohrCoulomb2.h
Go to the documentation of this file.
1 
2 inline void mohrCoulomb2(const double& phi, const double& psi, const double& c, const double* stress, //inputs
3  double& f, double* df, double& g, double* r, double* dr) //outputs
4 {
5  const int sXX=0,sYY=1,sZZ=2,sYZ=3,sZX=4,sXY=5;
6  const double &sigma_x(stress[sXX]),
7  &sigma_y(stress[sYY]),
8  &sigma_z(stress[sZZ]),
9  &sigma_yz(stress[sYZ]),
10  &sigma_zx(stress[sZX]),
11  &sigma_xy(stress[sXY]);
12  const double eps(1.0e-8);
13  double Df_sigma_m,Df_sigma_b,Df_theta,//f is function arg
14  theta,Dtheta_arg,Dtheta_x,Dtheta_y,Dtheta_z,Dtheta_xy,Dtheta_yz,Dtheta_zx,
15  sin_theta,cos_theta,
16  sigma_m,Dsigma_m_x,Dsigma_m_y,Dsigma_m_z,
17  sigma_b,sigma_b_star,Dsigma_b_x,Dsigma_b_y,Dsigma_b_z,Dsigma_b_xy,Dsigma_b_yz,Dsigma_b_zx,
18  t,t_star,Dt_x,Dt_y,Dt_z,Dt_yz,Dt_zx,Dt_xy,
19  s_x,Ds_x_x,Ds_x_y,Ds_x_z,
20  s_y,Ds_y_x,Ds_y_y,Ds_y_z,
21  s_z,Ds_z_x,Ds_z_y,Ds_z_z,
22  J_3,DJ_3_x,DJ_3_y,DJ_3_z,DJ_3_xy,DJ_3_yz,DJ_3_zx,
23  arg,arg_star,Darg_J_3,Darg_t,
24  Dg_sigma_m,Dg_sigma_b,Dg_theta;//g is function arg
25 
26  sigma_m = (sigma_x + sigma_y + sigma_z)/3.0;
27  Dsigma_m_x = 1.0/3.0;
28  Dsigma_m_y = 1.0/3.0;
29  Dsigma_m_z = 1.0/3.0;
30  //sigma_b
31  sigma_b = sqrt(pow(sigma_x - sigma_y,2) +
32  pow(sigma_y - sigma_z,2) +
33  pow(sigma_z - sigma_x,2) +
34  6.0*pow(sigma_xy,2) +
35  6.0*pow(sigma_yz,2) +
36  6.0*pow(sigma_zx,2))/ sqrt(2.0);
37  sigma_b_star = sigma_b;
38  if (sigma_b < eps)
39  {
40  sigma_b_star = eps;
41  }
42  Dsigma_b_x = (2.0*sigma_x - sigma_y - sigma_z)/(2.0*sigma_b_star);
43  Dsigma_b_y = (2.0*sigma_y - sigma_x - sigma_z)/(2.0*sigma_b_star);
44  Dsigma_b_z = (2.0*sigma_z - sigma_y - sigma_x)/(2.0*sigma_b_star);
45  Dsigma_b_xy = (3.0*sigma_xy)/sigma_b_star;
46  Dsigma_b_yz = (3.0*sigma_yz)/sigma_b_star;
47  Dsigma_b_zx = (3.0*sigma_zx)/sigma_b_star;
48 
49  //t
50  t = sigma_b*sqrt(2.0/3.0);
51  t_star = t;
52  if(t < eps)
53  {
54  t_star = eps;
55  }
56  Dt_x = Dsigma_b_x*sqrt(2.0/3.0);
57  Dt_y = Dsigma_b_y*sqrt(2.0/3.0);
58  Dt_z = Dsigma_b_z*sqrt(2.0/3.0);
59  Dt_xy = Dsigma_b_xy*sqrt(2.0/3.0);
60  Dt_yz = Dsigma_b_yz*sqrt(2.0/3.0);
61  Dt_zx = Dsigma_b_zx*sqrt(2.0/3.0);
62 
63  //J_3
64  s_x = (2.0*sigma_x - sigma_y - sigma_z)/3.0;
65  Ds_x_x = 2.0/3.0;
66  Ds_x_y = -1.0/3.0;
67  Ds_x_z = -1.0/3.0;
68  s_y = (2.0*sigma_y - sigma_x - sigma_z)/3.0;
69  Ds_y_x = -1.0/3.0;
70  Ds_y_y = 2.0/3.0;
71  Ds_y_z = -1.0/3.0;
72  s_z = (2.0*sigma_z - sigma_y - sigma_x)/3.0;
73  Ds_z_x = -1.0/3.0;
74  Ds_z_y = -1.0/3.0;
75  Ds_z_z = 2.0/3.0;
76 
77  J_3 = s_x*s_y*s_z - s_x*pow(sigma_yz,2) - s_y*pow(sigma_zx,2) - s_z*pow(sigma_xy,2) + 2.0*sigma_xy*sigma_yz*sigma_zx;
78  DJ_3_x = Ds_x_x*s_y*s_z + s_x*Ds_y_x*s_z + s_x*s_y*Ds_z_x
79  - Ds_x_x*pow(sigma_yz,2)
80  - Ds_y_x*pow(sigma_zx,2)
81  - Ds_z_x*pow(sigma_xy,2);
82  DJ_3_y = Ds_x_y*s_y*s_z + s_x*Ds_y_y*s_z + s_x*s_y*Ds_z_y
83  - Ds_x_y*pow(sigma_yz,2)
84  - Ds_y_y*pow(sigma_zx,2)
85  - Ds_z_y*pow(sigma_xy,2);
86  DJ_3_z = Ds_x_z*s_y*s_z + s_x*Ds_y_z*s_z + s_x*s_y*Ds_z_z
87  - Ds_x_z*pow(sigma_yz,2)
88  - Ds_y_z*pow(sigma_zx,2)
89  - Ds_z_z*pow(sigma_xy,2);
90  DJ_3_xy = - 2.0*s_z*sigma_xy + 2.0*sigma_yz*sigma_zx;
91  DJ_3_yz = - 2.0*s_x*sigma_yz + 2.0*sigma_xy*sigma_zx;
92  DJ_3_zx = - 2.0*s_y*sigma_zx + 2.0*sigma_xy*sigma_yz;
93 
94  arg = -3.0*sqrt(6.0)*J_3/pow(t_star,3);
95  arg_star = arg;
96  if (arg >= 1.0-eps)
97  {
98  arg_star = 1.0-eps;
99  arg = 1.0;
100  }
101  if (arg <= -1.0+eps)
102  {
103  arg_star = -1.0+eps;
104  arg = -1.0;
105  }
106  Darg_J_3 = -3.0*sqrt(6.0)/pow(t_star,3);
107  Darg_t = 9.0*sqrt(6.0)*J_3/pow(t_star,4);
108 
109  theta = asin(arg)/3.0;
110 
111  sin_theta = sin(theta);
112  cos_theta = cos(theta);
113 
114  Dtheta_arg = 1.0/(3.0*sqrt(1.0-pow(arg_star,2)));
115  Dtheta_x = Dtheta_arg*(Darg_J_3*DJ_3_x + Darg_t*Dt_x);
116  Dtheta_y = Dtheta_arg*(Darg_J_3*DJ_3_y + Darg_t*Dt_y);
117  Dtheta_z = Dtheta_arg*(Darg_J_3*DJ_3_z + Darg_t*Dt_z);
118  Dtheta_xy = Dtheta_arg*(Darg_J_3*DJ_3_xy + Darg_t*Dt_xy);
119  Dtheta_yz = Dtheta_arg*(Darg_J_3*DJ_3_yz + Darg_t*Dt_yz);
120  Dtheta_zx = Dtheta_arg*(Darg_J_3*DJ_3_zx + Darg_t*Dt_zx);
121 
122  //f
123  f = sigma_m*sin(phi)
124  + sigma_b*(cos_theta/sqrt(3.0) - (sin_theta*sin(phi))/3.0)
125  - c*cos(phi);
126 
127  Df_sigma_m = sin(phi);
128 
129  Df_sigma_b = (cos_theta/sqrt(3.0) - (sin_theta*sin(phi))/3.0);
130 
131  Df_theta = sigma_b*(-sin_theta/sqrt(3.0) - (cos_theta*sin(phi))/3.0);
132 
133  df[sXX] = Df_sigma_m*Dsigma_m_x +
134  Df_sigma_b*Dsigma_b_x +
135  Df_theta*Dtheta_x;
136  df[sYY] = Df_sigma_m*Dsigma_m_y +
137  Df_sigma_b*Dsigma_b_y +
138  Df_theta*Dtheta_y;
139  df[sZZ] = Df_sigma_m*Dsigma_m_z +
140  Df_sigma_b*Dsigma_b_z +
141  Df_theta*Dtheta_z;
142  df[sXY] = Df_sigma_b*Dsigma_b_xy +
143  Df_theta*Dtheta_xy;
144  df[sYZ] = Df_sigma_b*Dsigma_b_yz +
145  Df_theta*Dtheta_yz;
146  df[sZX] = Df_sigma_b*Dsigma_b_zx +
147  Df_theta*Dtheta_zx;
148  //r
149  g = sigma_m*sin(psi)
150  + sigma_b*(cos_theta/sqrt(3.0) - (sin_theta*sin(psi))/3.0)
151  - c*cos(psi);
152 
153  Dg_sigma_m = sin(psi);
154 
155  Dg_sigma_b = (cos_theta/sqrt(3.0) - (sin_theta*sin(psi))/3.0);
156 
157  Dg_theta = sigma_b*(-sin_theta/sqrt(3.0) - (cos_theta*sin(psi))/3.0);
158 
159  r[sXX] = Dg_sigma_m*Dsigma_m_x +
160  Dg_sigma_b*Dsigma_b_x +
161  Dg_theta*Dtheta_x;
162  r[sYY] = Dg_sigma_m*Dsigma_m_y +
163  Dg_sigma_b*Dsigma_b_y +
164  Dg_theta*Dtheta_y;
165  r[sZZ] = Dg_sigma_m*Dsigma_m_z +
166  Dg_sigma_b*Dsigma_b_z +
167  Dg_theta*Dtheta_z;
168  r[sXY] = Dg_sigma_b*Dsigma_b_xy +
169  Dg_theta*Dtheta_xy;
170  r[sYZ] = Dg_sigma_b*Dsigma_b_yz +
171  Dg_theta*Dtheta_yz;
172  r[sZX] = Dg_sigma_b*Dsigma_b_zx +
173  Dg_theta*Dtheta_zx;
174 }
f
Double f
Definition: Headers.h:64
df
double df(double C, double b, double a, int q, int r)
Definition: analyticalSolutions.c:2209
phi
Double phi
Definition: Headers.h:76
c
Double c
Definition: Headers.h:54
mohrCoulomb2
void mohrCoulomb2(const double &phi, const double &psi, const double &c, const double *stress, double &f, double *df, double &g, double *r, double *dr)
Definition: mohrCoulomb2.h:2
r
Double r
Definition: Headers.h:83
psi
Double psi
Definition: Headers.h:78