@@ -202,18 +202,21 @@ def thermodynamic_pressure(self, volumetric_strain):
202202 # Compute the stress
203203 def compute_stress (self , dstrain , particles , state_vars ):
204204 shear_rate_threshold = 1e-15
205+ # dirac delta in Voigt notation
205206 dirac_delta = jnp .array ([0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ]).reshape ((6 , 1 ))
206- dirac_delta = lax .cond (
207+ dirac_delta = lax .cond (
207208 self .ndim == 1 ,
208209 lambda x : x .at [0 , 0 ].set (1.0 ),
209210 lambda x : x .at [0 :2 , 0 ].set (1.0 ),
210211 dirac_delta ,
211212 )
213+ # Set threshold for minimum critical shear rate
212214 self .properties ["critical_shear_rate" ] = lax .select (
213215 self .properties ["critical_shear_rate" ] < shear_rate_threshold ,
214216 shear_rate_threshold ,
215217 self .properties ["critical_shear_rate" ],
216218 )
219+
217220 @jit
218221 def compute_stress_per_particle (
219222 particle_strain_rate ,
@@ -223,10 +226,23 @@ def compute_stress_per_particle(
223226 dirac_delta ,
224227 ):
225228 strain_r = particle_strain_rate
229+ # Convert strain rate to rate of deformation tensor
226230 strain_r = strain_r .at [- 3 :].multiply (0.5 )
231+ """
232+ Rate of shear = sqrt(2 * D_ij * D_ij)
233+ Since D (D_ij) is in Voigt notation (D_i), and the definition above is in
234+ matrix, the last 3 components have to be doubled D_ij * D_ij = D_0^2 +
235+ D_1^2 + D_2^2 + 2*D_3^2 + 2*D_4^2 + 2*D_5^2 Yielding is defined: rate of
236+ shear > critical_shear_rate_^2 Checking yielding from strain rate vs
237+ critical yielding shear rate
238+ """
227239 shear_rate = jnp .sqrt (
228240 2.0 * (strain_r .T @ (strain_r ) + strain_r [- 3 :].T @ strain_r [- 3 :])
229241 )
242+ """
243+ Apparent_viscosity maps shear rate to shear stress
244+ Check if shear rate is 0
245+ """
230246 apparent_viscosity_true = 2.0 * (
231247 (self .properties ["tau0" ] / shear_rate [0 , 0 ]) + self .properties ["mu" ]
232248 )
@@ -235,17 +251,34 @@ def compute_stress_per_particle(
235251 * self .properties ["critical_shear_rate" ]
236252 )
237253 apparent_viscosity = lax .select (condition , apparent_viscosity_true , 0.0 )
254+ """
255+ Compute shear change to volumetric
256+ tau deviatoric part of cauchy stress tensor
257+ """
238258 tau = apparent_viscosity * strain_r
239- trace_invariant2 = 0.5 * jnp .dot (tau [:3 , 0 ], tau [:3 , 0 ])
240- tau = lax .cond (
241- trace_invariant2 < (self .properties ["tau0" ] * self .properties ["tau0" ]),
259+ """
260+ von Mises criterion
261+ trace of second invariant J2 of deviatoric stress in matrix form
262+ Since tau is in Voigt notation, only the first three numbers matter
263+ yield condition trace of the invariant > tau0^2
264+ """
265+ trace_invariant = 0.5 * jnp .dot (tau [:3 , 0 ], tau [:3 , 0 ])
266+ tau = lax .cond (
267+ trace_invariant < (self .properties ["tau0" ] * self .properties ["tau0" ]),
242268 lambda x : x .at [:].set (0 ),
243269 lambda x : x ,
244270 tau ,
245271 )
272+ # update pressure
246273 state_vars_pressure += self .properties [
247274 "compressibility_multiplier"
248275 ] * self .thermodynamic_pressure (dvolumetric_strain_per_particle )
276+ """
277+ Update volumetric and deviatoric stress
278+ thermodynamic pressure is from material point
279+ stress = -thermodynamic_pressure I + tau, where I is identity matrix or
280+ direc_delta in Voigt notation
281+ """
249282 updated_stress_per_particle = (
250283 - (state_vars_pressure )
251284 * dirac_delta
0 commit comments