From c66f04b987df4f9c434bbfdcca3618280096904e Mon Sep 17 00:00:00 2001 From: Maximilian Stolzle Date: Fri, 27 Oct 2023 12:09:47 +0200 Subject: [PATCH] Increase damping planar hsa simulation --- examples/simulate_planar_hsa.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/simulate_planar_hsa.py b/examples/simulate_planar_hsa.py index 32d0758..d6925d8 100644 --- a/examples/simulate_planar_hsa.py +++ b/examples/simulate_planar_hsa.py @@ -2,7 +2,7 @@ from jax import config as jax_config jax_config.update("jax_enable_x64", True) # double precision -from diffrax import diffeqsolve, Euler, ODETerm, SaveAt +from diffrax import diffeqsolve, Euler, ODETerm, SaveAt, Tsit5 from jax import Array, jit, vmap from jax import numpy as jnp from functools import partial @@ -32,11 +32,16 @@ phi = jnp.array([jnp.pi, jnp.pi / 2]) # motor actuation angles # set simulation parameters -dt = 1e-4 # time step +dt = 5e-5 # time step ts = jnp.arange(0.0, 5, dt) # time steps skip_step = 100 # how many time steps to skip in between video frames video_ts = ts[::skip_step] # time steps for video +# increase damping for simulation stability +params["zetab"] = 5 * params["zetab"] +params["zetash"] = 5 * params["zetash"] +params["zetaa"] = 5 * params["zetaa"] + # video settings video_width, video_height = 700, 700 # img height and width video_path = Path(__file__).parent / "videos" / "planar_hsa.mp4" @@ -292,7 +297,7 @@ def chi2u(chi: Array) -> Array: sol = diffeqsolve( ode_term, - solver=Euler(), + solver=Tsit5(), t0=ts[0], t1=ts[-1], dt0=dt,