úÎ}T{      sHamiltonian dynamics for physical systems on generalized coordinates using automatic differentiation(c) Justin Le 2016BSD-3 justin@jle.imunstableportableNone"#%&',-06FQSTV]hyó:Represents a physical system in which physics happens. A  m n) is a system whose state described using n generalized coordinates (an "nK-dimensional" system), where the underlying cartesian coordinate space is m -dimensional.9For the most part, you are supposed to be able to ignore m. mž is only provided because it's useful when plotting/drawing the system with a given state back in rectangular coordinates. (The only function that use the m at the moment is  )A  m n's state is described using a  n; (which describes the system in configuration space) or a  n. (which describes the system in phase space).)Represents the full state of a system of nQ generalized coordinates in phase space (informally, "positions and momentums").ÿˆPhase space representations are much nicer to work with mathematically because of some neat underlying symmetries. For one, positions and momentums are "interchangeable" in a system; if you swap every coordinate's positions with their momentums, and also swap them in the equations of motions, you get the same system back. This isn't the case with configuration space representations.tA hamiltonian simulation basically describes the trajectory of each coordinate through phase space, so this is the state¹ of the simulation. However, configuration space representations are much more understandable to humans, so it might be useful to give an initial state in configuration space using , and then convert it to a  with .0The current values ("positions") of each of the n generalized coordinates.<The current conjugate momenta ("momentums") to each of the n generalized coordinates)Represents the full state of a system of nY generalized coordinates in configuration space (informally, "positions and velocities")ÿ A configuration space representaiton is more directly "physically meaningful" and intuitive/understandable to humans than a phase space representation. However, it's much less mathematically ideal to work with because of the lack of some neat underlying symmetries.You can convert a  n into a  nL (convert from configuration space to phase space) for a given system with —. This allows you to state your system in configuration space and then convert it to phase space before handing it off to the hamiltonian machinery.0The current values ("positions") of each of the n generalized coordinates;The current rate of changes ("velocities") of each of the n generalized coordinates ÄConverts the position of generalized coordinates of a system to the coordinates of the system's underlying cartesian coordinate system. Useful for plotting/drawing the system in cartesian space. cThe potential energy of a system, given the position in the generalized coordinates of the system. Create a system with nñ generalized coordinates by describing its coordinate space (by a function from the generalized coordinates to the underlying cartesian coordinates), the inertia of each of those underlying coordinates, and the pontential energy function.eThe potential energy function is expressed in terms of the genearlized coordinate space's positions. Convenience wrapper over  r that allows you to specify the potential energy function in terms of the underlying cartesian coordinate space. Compute the generalized momenta conjugate to each generalized coordinate of a system by giving the configuration-space state of the system.%Note that getting the momenta from a  n involves just using .iConvert a configuration-space representaiton of the state of the system to a phase-space representation./Useful because the hamiltonian simulations use  as its working state, but Á is a much more human-understandable and intuitive representation. This allows you to state your starting state in configuration space and convert to phase space for your simulation to use.QThe kinetic energy of a system, given the system's state in configuration space.“The Lagrangian of a system (the difference between the kinetic energy and the potential energy), given the system's state in configuration space.lCompute the rate of change of each generalized coordinate by giving the state of the system in phase space.(Note that getting the velocities from a  n involves just using .Invert ~ and convert a description of a system's state in phase space to a description of the system's state in configuration space.‚Possibly useful for showing the phase space representation of a system's state in a more human-readable/human-understandable way.IThe kinetic energy of a system, given the system's state in phase space.{The Hamiltonian of a system (the sum of kinetic energy and the potential energy), given the system's state in phase space.ÑThe "hamiltonian equations" for a given system at a given state in phase space. Returns the rate of change of the positions and conjugate momenta, which can be used to progress the simulation through time.>Step a system through phase space over over a single timestep.WEvolve a system using a hamiltonian stepper, with the given initial phase space state.=Desired solution times provided as a list instead of a sized  ?. The output list should be the same length as the input list.WEvolve a system using a hamiltonian stepper, with the given initial phase space state.A convenience wrapper for I that works on configuration space states instead of phase space states.Note that the simulation itself still runs in phase space; this function just abstracts over converting to and from phase space for the inputs and outputs.A convenience wrapper for I that works on configuration space states instead of phase space states.Note that the simulation itself still runs in phase space; this function just abstracts over converting to and from phase space for the inputs and outputs.FStep a system through configuration space over over a single timestep.›Note that the simulation itself still runs in phase space; this function just abstracts over converting to and from phase space for the input and output. The "inertia" of each of the mœ coordinates in the underlying cartesian space of the system. This should be mass for linear coordinates and rotational inertia for angular coordinates.|Conversion function to convert points in the generalized coordinate space to the underlying cartesian space of the system.bThe potential energy of the system as a function of the generalized coordinate space's positions. The "inertia" of each of the mœ coordinates in the underlying cartesian space of the system. This should be mass for linear coordinates and rotational inertia for angular coordinates.|Conversion function to convert points in the generalized coordinate space to the underlying cartesian space of the system.kThe potential energy of the system as a function of the underlying cartesian coordinate space's positions.timestep to step throughsystem to simulateinitial state, in phase spacesystem to simulateinitial state, in phase spacedesired solution timessystem to simulateinitial state, in phase spacedesired solution timessystem to simulate%initial state, in configuration spacedesired solution timessystem to simulate%initial state, in configuration spacedesired solution timestimestep to step throughsystem to simulateinitial state, in phase space    !"#$%&'(      !"#$%&'()*+,'hamilton-0.1.0.2-5anxmUEHofZ4uH3wdb3zPJNumeric.HamiltonSystemPhasePhs phsPositions phsMomentaConfigCfg cfgPositions cfgVelocities underlyingPospemkSystem mkSystem'momentatoPhasekeC lagrangian velocities fromPhasekeP hamiltonianhamEqsstepHam evolveHam' evolveHam evolveHamC' evolveHamCstepHamC$fGenericConfig$fGenericPhase $fShowPhase $fShowConfig+vector-sized-0.6.1.0-FU84QajAWIHATrkkyd8S0PData.Vector.SizedVectorSys _sysInertia _sysCoords _sysJacobian _sysJacobian2 _sysPotential_sysPotentialGrad