Skip to content

Commit 4def8da

Browse files
committed
added anchors
1 parent 0b92dff commit 4def8da

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

3_contact/BarrierEnergy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ANCHOR: val_grad_hess
12
import math
23
import numpy as np
34

@@ -33,10 +34,13 @@ def hess(x, y_ground, contact_area):
3334
else:
3435
IJV[2][i] = 0.0
3536
return IJV
37+
# ANCHOR_END: val_grad_hess
3638

39+
# ANCHOR: init_step_size
3740
def init_step_size(x, y_ground, p):
3841
alpha = 1
3942
for i in range(0, len(x)):
4043
if p[i][1] < 0:
4144
alpha = min(alpha, 0.9 * (y_ground - x[i][1]) / p[i][1])
42-
return alpha
45+
return alpha
46+
# ANCHOR_END: init_step_size

3_contact/simulator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
is_DBC = [False] * len(x)
3131
for i in DBC:
3232
is_DBC[i] = True
33+
# ANCHOR: contact_area
3334
contact_area = [side_len / n_seg] * len(x) # perimeter split to each node
35+
# ANCHOR_END: contact_area
3436

3537
# simulation with visualization
3638
resolution = np.array([900, 900])

3_contact/time_integrator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ def step_forward(x, e, v, m, l2, k, y_ground, contact_area, is_DBC, h, tol):
2323
print('Iteration', iter, ':')
2424
print('residual =', LA.norm(p, inf) / h)
2525

26+
# ANCHOR: filter_ls
2627
# filter line search
2728
alpha = BarrierEnergy.init_step_size(x, y_ground, p) # avoid interpenetration and tunneling
2829
while IP_val(x + alpha * p, e, x_tilde, m, l2, k, y_ground, contact_area, h) > E_last:
2930
alpha /= 2
31+
# ANCHOR_END: filter_ls
3032
print('step size =', alpha)
3133

3234
x += alpha * p

0 commit comments

Comments
 (0)