@@ -27,6 +27,10 @@ class Elastic(Base):
2727 Poisson ratio, describing the material's volume change under stress. Default is 0.2.
2828 rho: float, optional
2929 Material density (kg/m^3). Default is 1000.
30+ hydroelastic_modulus: float, optional
31+ Hydroelastic modulus for hydroelastic contact. Default is 1e7.
32+ friction_mu: float, optional
33+ Friction coefficient. Default is 0.1.
3034 model: str, optional
3135 Constitutive model to use for stress computation. Options are:
3236 - 'linear': Linear elasticity model
@@ -39,23 +43,26 @@ def __init__(
3943 E = 1e6 , # Young's modulus
4044 nu = 0.2 , # Poisson's ratio
4145 rho = 1000.0 , # density (kg/m^3)
46+ hydroelastic_modulus = 1e7 , # hydroelastic_modulus for hydroelastic contact
47+ friction_mu = 0.1 ,
4248 model = "linear" ,
4349 ):
44- super ().__init__ (E , nu , rho )
50+ super ().__init__ (E , nu , rho , hydroelastic_modulus , friction_mu )
4551
4652 if model == "linear" :
4753 self .update_stress = self .update_stress_linear
4854 self .compute_energy_gradient_hessian = self .compute_energy_gradient_hessian_linear
55+ self .compute_energy_gradient = self .compute_energy_gradient_linear
4956 self .compute_energy = self .compute_energy_linear
50- elif model == "stable_neohookean" :
51- self .update_stress = self .update_stress_stable_neohookean
52- self .compute_energy_gradient_hessian = self .compute_energy_gradient_hessian_stable_neohookean
53- self .compute_energy = self .compute_energy_stable_neohookean
54- elif model == "stable_neohooken" :
55- gs .logger .warning ("The 'stable_neohooken' model is deprecated. Use 'stable_neohookean' instead." )
57+ self .hessian_invariant = True
58+ elif model in ("stable_neohookean" , "stable_neohooken" ):
5659 self .update_stress = self .update_stress_stable_neohookean
5760 self .compute_energy_gradient_hessian = self .compute_energy_gradient_hessian_stable_neohookean
61+ self .compute_energy_gradient = self .compute_energy_gradient_stable_neohookean
5862 self .compute_energy = self .compute_energy_stable_neohookean
63+ self .hessian_invariant = False
64+ if model == "stable_neohooken" :
65+ gs .logger .warning ("The 'stable_neohooken' model is deprecated. Use 'stable_neohookean' instead." )
5966 else :
6067 gs .raise_exception (f"Unrecognized constitutive model: { model } " )
6168
@@ -147,6 +154,48 @@ def compute_energy_gradient_hessian_linear(self, mu, lam, J, F, actu, m_dir, i_e
147154 hessian_field [i_b , 1 , 2 , i_e ][1 , 2 ] = hessian_field [i_b , 2 , 1 , i_e ][2 , 1 ] = lam
148155 return energy , gradient
149156
157+ @ti .func
158+ def compute_energy_gradient_linear (self , mu , lam , J , F , actu , m_dir , i_e , i_b ):
159+ """
160+ Compute the energy, gradient for linear elasticity.
161+
162+ Parameters
163+ ----------
164+ mu: float
165+ The first Lame parameter (shear modulus).
166+ lam: float
167+ The second Lame parameter (related to volume change).
168+ J: float
169+ The determinant of the deformation gradient F.
170+ F: ti.Matrix
171+ The deformation gradient matrix.
172+ actu: ti.Matrix
173+ The activation matrix (not used in linear elasticity).
174+ m_dir: ti.Matrix
175+ The material direction (not used in linear elasticity).
176+
177+ Returns
178+ -------
179+ energy: float
180+ The computed energy.
181+ gradient: ti.Matrix
182+ The gradient of the energy with respect to the deformation gradient F.
183+
184+ Notes
185+ -------
186+ This implementation assumes small deformations and linear stress-strain relationship.
187+ It is adapted from the HOBAKv1 implementation for linear elasticity:
188+ https://github.com/theodorekim/HOBAKv1/blob/8420c51b795735d8fb912e0f8810f935d96fb636/src/Hyperelastic/Volume/LINEAR.cpp
189+ """
190+ I = ti .Matrix .identity (dt = gs .ti_float , n = 3 )
191+ eps = 0.5 * (F + F .transpose ()) - I
192+ trEps = eps .trace ()
193+ energy = mu * eps .norm_sqr () + 0.5 * lam * trEps ** 2
194+
195+ gradient = 2.0 * mu * eps + lam * trEps * I
196+
197+ return energy , gradient
198+
150199 @ti .func
151200 def compute_energy_linear (self , mu , lam , J , F , actu , m_dir ):
152201 """
@@ -176,8 +225,7 @@ def compute_energy_linear(self, mu, lam, J, F, actu, m_dir):
176225 -------
177226 This implementation assumes small deformations and linear stress-strain relationship.
178227 It is adapted from the HOBAKv1 implementation for linear elasticity:
179- https://github.com/theodorekim/HOBAKv1/blob/main/src/Hyperelastic/Volume/LINEAR.cpp
180-
228+ https://github.com/theodorekim/HOBAKv1/blob/8420c51b795735d8fb912e0f8810f935d96fb636/src/Hyperelastic/Volume/LINEAR.cpp
181229 """
182230 I = ti .Matrix .identity (dt = gs .ti_float , n = 3 )
183231 eps = 0.5 * (F + F .transpose ()) - I
@@ -228,6 +276,45 @@ def compute_energy_gradient_hessian_stable_neohookean(self, mu, lam, J, F, actu,
228276 """
229277 raise NotImplementedError ("Hessian computation is not implemented for stable_neohookean model." )
230278
279+ @ti .func
280+ def compute_energy_gradient_stable_neohookean (self , mu , lam , J , F , actu , m_dir , i_e , i_b ):
281+ """
282+ Compute the energy, gradient for the stable Neo-Hookean model.
283+
284+ Parameters
285+ ----------
286+ mu: float
287+ The first Lame parameter (shear modulus).
288+ lam: float
289+ The second Lame parameter (related to volume change).
290+ J: float
291+ The determinant of the deformation gradient F.
292+ F: ti.Matrix
293+ The deformation gradient matrix.
294+ actu: ti.Matrix
295+ The activation matrix (not used in stable Neo-Hookean).
296+ m_dir: ti.Matrix
297+ The material direction (not used in stable Neo-Hookean).
298+
299+ Returns
300+ -------
301+ energy: float
302+ The computed energy.
303+ gradient: ti.Matrix
304+ The gradient of the energy with respect to the deformation gradient F.
305+
306+ Raises
307+ -------
308+ NotImplementedError
309+ This implementation does not compute the Gradient for the stable Neo-Hookean model.
310+
311+ Notes
312+ -------
313+ This implementation is adapted from the HOBAKv1 stable Neo-Hookean model:
314+ https://github.com/theodorekim/HOBAKv1/blob/8420c51b795735d8fb912e0f8810f935d96fb636/src/Hyperelastic/Volume/SNH.cpp
315+ """
316+ raise NotImplementedError ("Gradient computation is not implemented for stable_neohookean model." )
317+
231318 @ti .func
232319 def compute_energy_stable_neohookean (self , mu , lam , J , F , actu , m_dir ):
233320 """
@@ -256,7 +343,7 @@ def compute_energy_stable_neohookean(self, mu, lam, J, F, actu, m_dir):
256343 Notes
257344 -------
258345 This implementation is adapted from the HOBAKv1 stable Neo-Hookean model:
259- https://github.com/theodorekim/HOBAKv1/blob/main /src/Hyperelastic/Volume/SNH.cpp
346+ https://github.com/theodorekim/HOBAKv1/blob/8420c51b795735d8fb912e0f8810f935d96fb636 /src/Hyperelastic/Volume/SNH.cpp
260347 """
261348 _lambda = lam + mu
262349 _alpha = 1.0 + mu / _lambda
0 commit comments