Learn R Programming

RandomWalker (version 1.1.0)

double_pendulum_walk: Double Pendulum Walk

Description

Simulate a planar frictionless double pendulum with massless rigid rods and point masses. Randomness enters only through starting angles; subsequent continuous-time motion is deterministic.

Usage

double_pendulum_walk(
  .num_walks = 5,
  .n = 401,
  .delta_time = 0.05,
  .theta1 = pi/2,
  .theta2 = pi/2,
  .omega1 = 0,
  .omega2 = 0,
  .angle_sd = 0.01,
  .m1 = 1,
  .m2 = 1,
  .l1 = 1,
  .l2 = 1,
  .gravity = 9.81
)

Value

An ungrouped tibble with factor walk_number, integer step_number, time, angles theta1, theta2, angular velocities omega1, omega2, first bob coordinates x1, y1, and second bob coordinates x, y. Coordinates are positions, not increments; no cumulative columns are added. Attributes contain parameters, initial_states, fns, n, num_steps, num_walks, delta_time, and dimensions = 2.

Arguments

.num_walks

Positive integer number of trajectories.

.n

Integer number of observations, including time zero (at least two).

.delta_time

Positive sampling interval in seconds, not the solver step.

.theta1, .theta2

Initial angles in radians from vertically downward.

.omega1, .omega2

Initial angular velocities in radians per second.

.angle_sd

Nonnegative standard deviation of independent normal angle perturbations. Zero consumes no random numbers. Use set.seed() for repeatability.

.m1, .m2

Positive bob masses in kilograms.

.l1, .l2

Positive rod lengths in meters.

.gravity

Positive gravitational acceleration in meters per second squared.

Author

Steven P. Sanderson II, MPH

Details

Uses optional package deSolve and adaptive LSODA integration with relative and absolute tolerances of 1e-9. Times are (0:(.n - 1)) * .delta_time. The default covers 20 seconds. Angles are absolute, not relative to the other rod; positive angles move toward positive x from downward vertical. The pivot is at the origin and y increases upward. This is an ensemble of randomized initial conditions, not a process with random forces or random waiting times.

References

Equations: https://www.myphysicslab.com/pendulum/double-pendulum-en.html.

See Also

Other Generator Functions: brownian_motion(), custom_walk(), discrete_walk(), geometric_brownian_motion(), random_beta_walk(), random_binomial_walk(), random_cauchy_walk(), random_chisquared_walk(), random_displacement_walk(), random_exponential_walk(), random_f_walk(), random_gamma_walk(), random_geometric_walk(), random_hypergeometric_walk(), random_logistic_walk(), random_lognormal_walk(), random_multinomial_walk(), random_negbinomial_walk(), random_normal_drift_walk(), random_normal_walk(), random_poisson_walk(), random_smirnov_walk(), random_t_walk(), random_uniform_walk(), random_weibull_walk(), random_wilcox_walk(), random_wilcoxon_sr_walk()

Other Continuous Distribution: brownian_motion(), geometric_brownian_motion(), random_beta_walk(), random_cauchy_walk(), random_chisquared_walk(), random_exponential_walk(), random_f_walk(), random_gamma_walk(), random_logistic_walk(), random_lognormal_walk(), random_normal_drift_walk(), random_normal_walk(), random_t_walk(), random_uniform_walk(), random_weibull_walk()

Examples

Run this code
if (requireNamespace("deSolve", quietly = TRUE)) {
  set.seed(287)
  walks <- double_pendulum_walk(.num_walks = 2, .n = 21)
  head(walks)
}

Run the code above in your browser using DataLab