Skip to content

Commit

Permalink
Merge pull request #120 from bhosale2/118_update_timestep_for_new_dam…
Browse files Browse the repository at this point in the history
…ping_module

[WIP] Update timestep values for the new damping module
  • Loading branch information
bhosale2 authored Jul 6, 2022
2 parents a8cb32c + 6e00f63 commit d3d7201
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 34 deletions.
7 changes: 5 additions & 2 deletions examples/AxialStretchingCase/axial_stretching.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ class StretchingBeamSimulator(
)

# add damping
damping_constant = 1.0
dl = base_length / n_elem
dt = 0.01 * dl
# old damping model (deprecated in v0.3.0) values
# dt = 0.01 * dl
# damping_constant = 1.0
dt = 0.1 * dl
damping_constant = 0.1
stretch_sim.dampen(stretchable_rod).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down
4 changes: 2 additions & 2 deletions examples/Binder/2_Slithering_Snake.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
"outputs": [],
"source": [
"dt = 8.0e-6\n",
"dt = 1e-4\n",
"snake_sim.dampen(shearable_rod).using(\n",
" ExponentialDamper,\n",
" damping_constant=nu,\n",
Expand Down Expand Up @@ -324,7 +324,7 @@
"\n",
"pp_list = defaultdict(list)\n",
"snake_sim.collect_diagnostics(shearable_rod).using(\n",
" ContinuumSnakeCallBack, step_skip=1000, callback_params=pp_list\n",
" ContinuumSnakeCallBack, step_skip=100, callback_params=pp_list\n",
")\n",
"print(\"Callback function added to the simulator\")"
]
Expand Down
8 changes: 5 additions & 3 deletions examples/ContinuumFlagellaCase/continuum_flagella.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ def run_flagella(
)

# add damping
damping_constant = 2.5
dt = 2.5e-5 * period
# old damping model (deprecated in v0.3.0) values
# damping_constant = 2.5
# dt = 2.5e-5 * period
damping_constant = 0.625
dt = 1e-4 * period
flagella_sim.dampen(shearable_rod).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down Expand Up @@ -130,7 +133,6 @@ def make_callback(self, system, time, current_step: int):
# timestepper = PEFRL()

final_time = (10.0 + 0.01) * period
dt = 2.5e-5 * period
total_steps = int(final_time / dt)
print("Total steps", total_steps)
integrate(timestepper, flagella_sim, final_time, total_steps)
Expand Down
12 changes: 8 additions & 4 deletions examples/ContinuumSnakeCase/continuum_snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def run_snake(
# Simulation parameters
period = 2
final_time = (11.0 + 0.01) * period
time_step = 8e-6
total_steps = int(final_time / time_step)
rendering_fps = 60
step_skip = int(1.0 / (rendering_fps * time_step))

# setting up test params
n_elem = 50
Expand Down Expand Up @@ -103,13 +99,21 @@ def run_snake(
)

# add damping
# old damping model (deprecated in v0.3.0) values
# damping_constant = 2e-3
# time_step = 8e-6
damping_constant = 2e-3
time_step = 1e-4
snake_sim.dampen(shearable_rod).using(
ExponentialDamper,
damping_constant=damping_constant,
time_step=time_step,
)

total_steps = int(final_time / time_step)
rendering_fps = 60
step_skip = int(1.0 / (rendering_fps * time_step))

# Add call backs
class ContinuumSnakeCallBack(CallBackBaseClass):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ def apply_forces(self, system, time: np.float64 = 0.0):


# add damping
damping_constant = 4e-2
dt = 1e-5
# old damping model (deprecated in v0.3.0) values
# damping_constant = 4e-2
# dt = 1e-5
damping_constant = 4e-3
dt = 1e-3
parallel_connection_sim.dampen(rod_one).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down Expand Up @@ -171,17 +174,17 @@ def make_callback(self, system, time, current_step: int):


parallel_connection_sim.collect_diagnostics(rod_one).using(
ParallelConnecitonCallback, step_skip=1000, callback_params=pp_list_rod1
ParallelConnecitonCallback, step_skip=40, callback_params=pp_list_rod1
)
parallel_connection_sim.collect_diagnostics(rod_two).using(
ParallelConnecitonCallback, step_skip=1000, callback_params=pp_list_rod2
ParallelConnecitonCallback, step_skip=40, callback_params=pp_list_rod2
)


parallel_connection_sim.finalize()
timestepper = PositionVerlet()

final_time = 5.0
final_time = 20.0
dl = base_length / n_elem
total_steps = int(final_time / dt)
print("Total steps", total_steps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def simulate_rolling_friction_initial_velocity_with(IFactor=0.0):
base_area = np.pi * base_radius ** 2
mass = 1.0
density = mass / (base_length * base_area)
nu = 1e-6
nu = 1e-6 / 2
E = 1e9
# For shear modulus of 2E/3
poisson_ratio = 0.5
Expand Down Expand Up @@ -74,7 +74,7 @@ def simulate_rolling_friction_initial_velocity_with(IFactor=0.0):
rolling_friction_initial_velocity_sim.constrain(shearable_rod).using(FreeBC)

# Add damping
dt = 1e-6
dt = 1e-6 * 2
rolling_friction_initial_velocity_sim.dampen(shearable_rod).using(
ExponentialDamper,
damping_constant=nu,
Expand Down
5 changes: 4 additions & 1 deletion examples/JointCases/fixed_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ class FixedJointSimulator(
)

# add damping
# old damping model (deprecated in v0.3.0) values
# damping_constant = 0.4
# dt = 1e-5
damping_constant = 0.4
dt = 1e-5
dt = 1e-4
fixed_joint_sim.dampen(rod1).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down
6 changes: 4 additions & 2 deletions examples/JointCases/hinge_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ class HingeJointSimulator(
)

# add damping
# old damping model (deprecated in v0.3.0) values
# damping_constant = 4e-3
# dt = 1e-5
damping_constant = 4e-3
dt = 1e-5
dt = 5e-5
hinge_joint_sim.dampen(rod1).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down Expand Up @@ -145,7 +148,6 @@ def make_callback(self, system, time, current_step: int):

final_time = 10
dl = base_length / n_elem
dt = 1e-5
total_steps = int(final_time / dt)
print("Total steps", total_steps)
integrate(timestepper, hinge_joint_sim, final_time, total_steps)
Expand Down
6 changes: 4 additions & 2 deletions examples/JointCases/spherical_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ class SphericalJointSimulator(
)

# add damping
# old damping model (deprecated in v0.3.0) values
# damping_constant = 4e-3
# dt = 1e-5
damping_constant = 4e-3
dt = 1e-5
dt = 5e-5
spherical_joint_sim.dampen(rod1).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down Expand Up @@ -146,7 +149,6 @@ def make_callback(self, system, time, current_step: int):

final_time = 10
dl = base_length / n_elem
dt = 1e-5
total_steps = int(final_time / dt)
print("Total steps", total_steps)
integrate(timestepper, spherical_joint_sim, final_time, total_steps)
Expand Down
2 changes: 1 addition & 1 deletion examples/MuscularFlagella/muscular_flagella.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class MuscularFlagellaSimulator(
base_length_muscle,
base_radius_muscle,
density_muscle,
nu_muscle,
0.0, # internal damping constant, deprecated in v0.3.0
E_muscle,
shear_modulus=shear_modulus_muscle,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/MuscularSnake/muscular_snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class MuscularSnakeSimulator(
base_length_muscle,
muscle_radius,
density_muscle,
nu_muscle,
0.0, # internal damping constant, deprecated in v0.3.0
youngs_modulus=E_muscle,
shear_modulus=shear_modulus_muscle,
)
Expand Down Expand Up @@ -191,7 +191,7 @@ class MuscularSnakeSimulator(
base_length_muscle,
muscle_radius,
density_muscle,
nu_muscle,
0.0, # internal damping constant, deprecated in v0.3.0
youngs_modulus=E_muscle,
shear_modulus=shear_modulus_muscle,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class InclinedRodRodContact(
inclined_rod_rod_contact_sim = InclinedRodRodContact()

# Simulation parameters
dt = 5e-5
# old damping model (deprecated in v0.3.0) values
# dt = 5e-5
dt = 2.5e-4
final_time = 20
total_steps = int(final_time / dt)
time_step = np.float64(final_time / total_steps)
Expand Down Expand Up @@ -93,7 +95,9 @@ class InclinedRodRodContact(
)

# add damping
damping_constant = 2e-3
# old damping model (deprecated in v0.3.0) values
# damping_constant = 2e-3
damping_constant = 4e-4
inclined_rod_rod_contact_sim.dampen(rod_one).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class ParallelRodRodContact(
parallel_rod_rod_contact_sim = ParallelRodRodContact()

# Simulation parameters
dt = 5e-5
# old damping model (deprecated in v0.3.0) values
# dt = 5e-5
dt = 5e-4
final_time = 10
total_steps = int(final_time / dt)
time_step = np.float64(final_time / total_steps)
Expand Down Expand Up @@ -90,7 +92,9 @@ class ParallelRodRodContact(
)

# add damping
damping_constant = 2e-3
# old damping model (deprecated in v0.3.0) values
# damping_constant = 2e-3
damping_constant = 2e-4
parallel_rod_rod_contact_sim.dampen(rod_one).using(
ExponentialDamper,
damping_constant=damping_constant,
Expand Down
4 changes: 2 additions & 2 deletions examples/TimoshenkoBeamCase/convergence_timoshenko.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def simulate_timoshenko_beam_with(
base_length = 3.0
base_radius = 0.25
density = 5000
nu = 0.1 / density / (np.pi * base_radius ** 2)
nu = 0.1 / 7 / density / (np.pi * base_radius ** 2)
E = 1e6
# For shear modulus of 1e4, nu is 99!
poisson_ratio = 99
Expand All @@ -60,7 +60,7 @@ def simulate_timoshenko_beam_with(
timoshenko_sim.append(shearable_rod)
# add damping
dl = base_length / n_elem
dt = 0.01 * dl
dt = 0.07 * dl
timoshenko_sim.dampen(shearable_rod).using(
ExponentialDamper,
damping_constant=nu,
Expand Down
4 changes: 2 additions & 2 deletions examples/TimoshenkoBeamCase/timoshenko.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TimoshenkoBeamSimulator(
base_radius = 0.25
base_area = np.pi * base_radius ** 2
density = 5000
nu = 0.1 / density / base_area
nu = 0.1 / 7 / density / base_area
E = 1e6
# For shear modulus of 1e4, nu is 99!
poisson_ratio = 99
Expand All @@ -56,7 +56,7 @@ class TimoshenkoBeamSimulator(
timoshenko_sim.append(shearable_rod)
# add damping
dl = base_length / n_elem
dt = 0.01 * dl
dt = 0.07 * dl
timoshenko_sim.dampen(shearable_rod).using(
ExponentialDamper,
damping_constant=nu,
Expand Down

0 comments on commit d3d7201

Please sign in to comment.