Skip to content

Commit

Permalink
Add uniaxial stress optim example plot
Browse files Browse the repository at this point in the history
  • Loading branch information
chahak13 committed Aug 17, 2023
1 parent 03f112c commit fcec796
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions optim_benchmark.py → examples/optim_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@
jit_updated = init_vals
jitted_update = jax.jit(solver.update)
for step in tqdm(range(20)):
# jit_updated = solver.update(jit_updated, step + 1)
jit_updated = jitted_update(jit_updated, step + 1)

true_vel = jit_updated.particles[0].stress


def compute_loss(params, *, solver, target_vel, config):
# material = init_simple({"E": params, "density": 1, "id": -1})
material = init_linear_elastic(
{
"youngs_modulus": params["ym"],
Expand Down Expand Up @@ -157,10 +155,11 @@ def optax_adam(params, niter, mpm, target_vel, config):
) # ADAM optimizer

fig, ax = plt.subplots(1, 2, figsize=(16, 6))
ax[0].plot(param_list["ym"], "ko", markersize=2, label="E")
ax[0].plot(param_list["ym"], "ko", markersize=2, label="Youngs Modulus")
ax[0].grid()
ax[0].legend()
ax[1].plot(loss_list, "ko", markersize=2, label="Loss")
ax[1].grid()
ax[1].legend()
plt.show()
# plt.show()
fig.savefig("./examples/optim_uniaxial_stress.png")
Binary file added examples/optim_uniaxial_stress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fcec796

Please sign in to comment.