{ "info": { "author": "Jason K. Moore", "author_email": "moorepants@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Topic :: Scientific/Engineering :: Physics" ], "description": "PyDy Code Generation\n====================\n\nThis distribution provides code generation facilities for PyDy_. For now, it\ngenerates functions that can evaluate the right hand side of the ordinary\ndifferential equations generated with sympy.physics.mechanics_ with three\ndifferent backends: SymPy's lambdify_, Theano_, and Cython_.\n\n.. _PyDy: http://pydy.org\n.. _sympy.physics.mechanics: http://docs.sympy.org/latest/modules/physics/mechanics\n.. _lambdify: http://docs.sympy.org/latest/modules/utilities/lambdify.html#sympy.utilities.lambdify.lambdify\n.. _Theano: http://deeplearning.net/software/theano/\n.. _Cython: http://cython.org/\n\nDependencies\n============\n\nRequired\n--------\n\n- Python: 2.7 (Python 3+ may work)\n- setuptools\n- NumPy: >=1.6.1\n- SymPy: >=0.7.3\n\nOptional\n--------\n\n- Cython: >=0.15.1\n- Theano: >=0.6.0\n- SciPy: >=0.9 (only for full examples)\n- matplotlib: >=0.99 (only for full examples)\n\nThere are a variety of methods to install these packages. Refer to the SciPy\nStack installation instructions for details.\n\nInstallation\n============\n\nOnce the dependencies are installed, the package can be installed from PyPi\nusing::\n\n $ easy_install pydy-code-gen\n\nor::\n\n $ pip install pydy-code-gen\n\nYou can also grab the source and then install\\ [#]_.\n\nUsing the zip download::\n\n $ wget https://github.com/PythonDynamics/pydy-code-gen/archive/master.zip\n $ unzip pydy-code-gen-master.zip\n $ cd pydy-code-gen-master\n $ python setup.py install\n\nUsing Git::\n\n $ git clone https://github.com/PythonDynamics/pydy-code-gen.git\n $ cd pydy-code-gen\n $ python setup.py install\n\n.. [#] Note that this is the latest development version. Specific releases\n can be found here: https://github.com/PythonDynamics/pydy-code-gen/releases\n or by checking out a tag with Git.\n\nUsage\n=====\n\nThis is an example of a simple 1 degree of freedom system: a mass, spring,\ndamper system under the influence of gravity and a force::\n\n\n / / / / / / / / /\n -----------------\n | | | | g\n \\ | | | V\n k / --- c |\n | | | x, v\n -------- V\n | m | -----\n --------\n | F\n V\n\nDerive the system::\n\n from sympy import symbols\n import sympy.physics.mechanics as me\n\n mass, stiffness, damping, gravity = symbols('m, k, c, g')\n\n position, speed = me.dynamicsymbols('x v')\n positiond = me.dynamicsymbols('x', 1)\n force = me.dynamicsymbols('F')\n\n ceiling = me.ReferenceFrame('N')\n\n origin = me.Point('origin')\n origin.set_vel(ceiling, 0)\n\n center = origin.locatenew('center', position * ceiling.x)\n center.set_vel(ceiling, speed * ceiling.x)\n\n block = me.Particle('block', center, mass)\n\n kinematic_equations = [speed - positiond]\n\n force_magnitude = mass * gravity - stiffness * position - damping * speed + force\n forces = [(center, force_magnitude * ceiling.x)]\n\n particles = [block]\n\n kane = me.KanesMethod(ceiling, q_ind=[position], u_ind=[speed],\n kd_eqs=kinematic_equations)\n kane.kanes_equations(forces, particles)\n\nStore the expressions and symbols in sequences for the code generation::\n\n mass_matrix = kane.mass_matrix_full\n forcing_vector = kane.forcing_full\n constants = (mass, stiffness, damping, gravity)\n coordinates = (position,)\n speeds = (speed,)\n specified = (force,)\n\nNow generate the function needed for numerical evaluation of the ODEs. The\ngenerator can use various back ends: ``lambdify``, ``theano``, or ``cython``::\n\n from pydy_code_gen.code import generate_ode_function\n\n evaluate_ode = generate_ode_function(mass_matrix, forcing_vector, constants,\n coordinates, speeds, specified,\n generator='lambdify')\n\nIntegrate the equations of motion under the influence of a specified sinusoidal\nforce::\n\n from numpy import array, linspace, sin\n from scipy.integrate import odeint\n\n x0 = array([0.1, -1.0])\n args = {'constants': array([1.0, 1.0, 0.2, 9.8]),\n 'specified': lambda x, t: sin(t)}\n t = linspace(0.0, 10.0, 1000)\n\n y = odeint(evaluate_ode, x0, t, args=(args,))\n\nPlot the results::\n\n import matplotlib.pyplot as plt\n\n plt.plot(t, y)\n plt.legend((str(position), str(speed)))\n plt.show()\n\nDevelopment Environment\n=======================\n\nDevelopment Dependencies\n------------------------\n\n- nose: 1.3.0\n\nInstallation\n------------\n\nThe following installation assumes you have virtualenvwrapper_ and all the\ndependencies needed to build the packages::\n\n $ mkvirtualenv pydy-dev\n (pydy-dev)$ pip install numpy scipy cython nose theano sympy\n (pydy-dev)$ pip install matplotlib # make sure to do this after numpy\n (pydy-dev)$ git clone git@github.com:PythonDynamics/pydy-code-gen.git\n (pydy-dev)$ cd pydy-code-gen\n (pydy-dev)$ python setup.py develop\n\n.. _virtualenvwrapper: https://pypi.python.org/pypi/virtualenvwrappe://pypi.python.org/pypi/virtualenvwrapper\n\nRun the tests::\n\n (pydy-dev)$ nosetests\n\nRun the benchmark to test the n-link pendulum problem.::\n\n (pydy-dev)$ python bin/benchmark_pydy_code_gen.py <# of time steps>\n\nRelease Notes\n=============\n\n0.1.0\n-----\n\n- Initial version.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PythonDynamics/pydy-code-gen/", "keywords": "dynamics multibody simulation code generation", "license": "UNLICENSE", "maintainer": null, "maintainer_email": null, "name": "pydy-code-gen", "package_url": "https://pypi.org/project/pydy-code-gen/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pydy-code-gen/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/PythonDynamics/pydy-code-gen/" }, "release_url": "https://pypi.org/project/pydy-code-gen/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Code generation for multibody dynamic systems.", "version": "0.1.0" }, "last_serial": 995837, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d47821fe1a338a1b05253fd366bb2d5d", "sha256": "cbd9782299b685d268aad36b361f3e61e6f92860497ad460e9da5e8b433fb411" }, "downloads": -1, "filename": "pydy-code-gen-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d47821fe1a338a1b05253fd366bb2d5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17661, "upload_time": "2014-02-10T03:48:25", "url": "https://files.pythonhosted.org/packages/f1/40/5ea694c1b565ac5083466e4e32e453e26b437c6ab3596501be88b7a781e5/pydy-code-gen-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d47821fe1a338a1b05253fd366bb2d5d", "sha256": "cbd9782299b685d268aad36b361f3e61e6f92860497ad460e9da5e8b433fb411" }, "downloads": -1, "filename": "pydy-code-gen-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d47821fe1a338a1b05253fd366bb2d5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17661, "upload_time": "2014-02-10T03:48:25", "url": "https://files.pythonhosted.org/packages/f1/40/5ea694c1b565ac5083466e4e32e453e26b437c6ab3596501be88b7a781e5/pydy-code-gen-0.1.0.tar.gz" } ] }