Skip to content

Commit a83eaeb

Browse files
committed
Add uniaxial stress optim example plot
1 parent a0ce1ce commit a83eaeb

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

optim_benchmark.py renamed to examples/optim_benchmark.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@
6363
jit_updated = init_vals
6464
jitted_update = jax.jit(solver.update)
6565
for step in tqdm(range(20)):
66-
# jit_updated = solver.update(jit_updated, step + 1)
6766
jit_updated = jitted_update(jit_updated, step + 1)
6867

6968
true_vel = jit_updated.particles[0].stress
7069

7170

7271
def compute_loss(params, *, solver, target_vel, config):
73-
# material = init_simple({"E": params, "density": 1, "id": -1})
7472
material = init_linear_elastic(
7573
{
7674
"youngs_modulus": params["ym"],
@@ -157,10 +155,11 @@ def optax_adam(params, niter, mpm, target_vel, config):
157155
) # ADAM optimizer
158156

159157
fig, ax = plt.subplots(1, 2, figsize=(16, 6))
160-
ax[0].plot(param_list["ym"], "ko", markersize=2, label="E")
158+
ax[0].plot(param_list["ym"], "ko", markersize=2, label="Youngs Modulus")
161159
ax[0].grid()
162160
ax[0].legend()
163161
ax[1].plot(loss_list, "ko", markersize=2, label="Loss")
164162
ax[1].grid()
165163
ax[1].legend()
166-
plt.show()
164+
# plt.show()
165+
fig.savefig("./examples/optim_uniaxial_stress.png")

examples/optim_uniaxial_stress.png

37.7 KB
Loading

0 commit comments

Comments
 (0)