{"action":"created","issue":{"url":"https://api.github.com/repos/hoburg/gpkit/issues/770","repository_url":"https://api.github.com/repos/hoburg/gpkit","labels_url":"https://api.github.com/repos/hoburg/gpkit/issues/770/labels{/name}","comments_url":"https://api.github.com/repos/hoburg/gpkit/issues/770/comments","events_url":"https://api.github.com/repos/hoburg/gpkit/issues/770/events","html_url":"https://github.com/hoburg/gpkit/issues/770","id":166098529,"number":770,"title":"beam example solution full of nans","user":{"login":"whoburg","id":6042395,"avatar_url":"https://avatars.githubusercontent.com/u/6042395?v=3","gravatar_id":"","url":"https://api.github.com/users/whoburg","html_url":"https://github.com/whoburg","followers_url":"https://api.github.com/users/whoburg/followers","following_url":"https://api.github.com/users/whoburg/following{/other_user}","gists_url":"https://api.github.com/users/whoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/whoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whoburg/subscriptions","organizations_url":"https://api.github.com/users/whoburg/orgs","repos_url":"https://api.github.com/users/whoburg/repos","events_url":"https://api.github.com/users/whoburg/events{/privacy}","received_events_url":"https://api.github.com/users/whoburg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hoburg/gpkit/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/hoburg/gpkit/milestones/13","html_url":"https://github.com/hoburg/gpkit/milestones/Next%20release","labels_url":"https://api.github.com/repos/hoburg/gpkit/milestones/13/labels","id":1608329,"number":13,"title":"Next release","description":"Frustrations / bugs / etc that are achievable in ~ 1 month timeframe.","creator":{"login":"whoburg","id":6042395,"avatar_url":"https://avatars.githubusercontent.com/u/6042395?v=3","gravatar_id":"","url":"https://api.github.com/users/whoburg","html_url":"https://github.com/whoburg","followers_url":"https://api.github.com/users/whoburg/followers","following_url":"https://api.github.com/users/whoburg/following{/other_user}","gists_url":"https://api.github.com/users/whoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/whoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whoburg/subscriptions","organizations_url":"https://api.github.com/users/whoburg/orgs","repos_url":"https://api.github.com/users/whoburg/repos","events_url":"https://api.github.com/users/whoburg/events{/privacy}","received_events_url":"https://api.github.com/users/whoburg/received_events","type":"User","site_admin":false},"open_issues":39,"closed_issues":12,"state":"open","created_at":"2016-02-26T16:03:40Z","updated_at":"2016-07-18T15:49:12Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-07-18T13:52:55Z","updated_at":"2016-07-18T19:31:34Z","closed_at":null,"body":"The solution `w_gp` to `docs/source/examples/beam.py` is full of nans. This does not seem right. Below is a copy of the example code with one line inserted to `print w_gp`:\r\n\r\n```python\r\n\"\"\"\r\nA simple beam example with fixed geometry. Solves the discretized\r\nEuler-Bernoulli beam equations for a constant distributed load\r\n\"\"\"\r\nimport numpy as np\r\nfrom gpkit import Variable, VectorVariable, Model, units\r\nfrom gpkit.small_scripts import mag\r\n\r\n\r\nclass Beam(Model):\r\n    \"\"\"Discretization of the Euler beam equations for a distributed load.\r\n\r\n    Arguments\r\n    ---------\r\n    N : int\r\n        Number of finite elements that compose the beam.\r\n    L : float\r\n        [m] Length of beam.\r\n    EI : float\r\n        [N m^2] Elastic modulus times cross-section's area moment of inertia.\r\n    q : float or N-vector of floats\r\n        [N/m] Loading density: can be specified as constants or as an array.\r\n    \"\"\"\r\n    def __init__(self, N=4, **kwargs):\r\n        EI = Variable(\"EI\", 1e4, \"N*m^2\")\r\n        dx = Variable(\"dx\", \"m\", \"Length of an element\")\r\n        L = Variable(\"L\", 5, \"m\", \"Overall beam length\")\r\n        q = VectorVariable(N, \"q\", 100*np.ones(N), \"N/m\",\r\n                           \"Distributed load at each point\")\r\n        V = VectorVariable(N, \"V\", \"N\", \"Internal shear\")\r\n        V_tip = Variable(\"V_{tip}\", 0, \"N\", \"Tip loading\")\r\n        M = VectorVariable(N, \"M\", \"N*m\", \"Internal moment\")\r\n        M_tip = Variable(\"M_{tip}\", 0, \"N*m\", \"Tip moment\")\r\n        th = VectorVariable(N, \"\\\\theta\", \"-\", \"Slope\")\r\n        th_base = Variable(\"\\\\theta_{base}\", 0, \"-\", \"Base angle\")\r\n        w = VectorVariable(N, \"w\", \"m\", \"Displacement\")\r\n        w_base = Variable(\"w_{base}\", 0, \"m\", \"Base deflection\")\r\n        # below: trapezoidal integration to form a piecewise-linear\r\n        #        approximation of loading, shear, and so on\r\n        # shear and moment increase from tip to base (left > right)\r\n        shear_eq = (V >= V.right + 0.5*dx*(q + q.right))\r\n        shear_eq[-1] = (V[-1] >= V_tip)  # tip boundary condition\r\n        moment_eq = (M >= M.right + 0.5*dx*(V + V.right))\r\n        moment_eq[-1] = (M[-1] >= M_tip)\r\n        # slope and displacement increase from base to tip (right > left)\r\n        theta_eq = (th >= th.left + 0.5*dx*(M + M.left)/EI)\r\n        theta_eq[0] = (th[0] >= th_base)  # base boundary condition\r\n        displ_eq = (w >= w.left + 0.5*dx*(th + th.left))\r\n        displ_eq[0] = (w[0] >= w_base)\r\n        # minimize tip displacement (the last w)\r\n        Model.__init__(self, w[-1],\r\n                       [shear_eq, moment_eq, theta_eq, displ_eq,\r\n                        L == (N-1)*dx], **kwargs)\r\n\r\n\r\nb = Beam(N=6, substitutions={\"L\": 6, \"EI\": 1.1e4, \"q\": 110*np.ones(10)})\r\nb.zero_lower_unbounded_variables()\r\nsol = b.solve(verbosity=1)\r\nw_gp = sol(\"w\")  # deflection along beam\r\n\r\nL, EI, q = sol(\"L\"), sol(\"EI\"), sol(\"q\")\r\nx = np.linspace(0, mag(L), len(q))*units.m  # position along beam\r\nq = q[0]  # assume uniform loading for the check below\r\nw_exact = q/(24.*EI) * x**2 * (x**2 - 4*L*x + 6*L**2)  # analytic soln\r\n\r\nprint w_gp\r\nassert max(abs(w_gp - w_exact)) <= 1e-2*units.m\r\n```\r\n\r\nThe printout is:\r\n```\r\n[  0.  nan  nan  nan  nan  nan] meter\r\n```"},"comment":{"url":"https://api.github.com/repos/hoburg/gpkit/issues/comments/233433365","html_url":"https://github.com/hoburg/gpkit/issues/770#issuecomment-233433365","issue_url":"https://api.github.com/repos/hoburg/gpkit/issues/770","id":233433365,"user":{"login":"whoburg","id":6042395,"avatar_url":"https://avatars.githubusercontent.com/u/6042395?v=3","gravatar_id":"","url":"https://api.github.com/users/whoburg","html_url":"https://github.com/whoburg","followers_url":"https://api.github.com/users/whoburg/followers","following_url":"https://api.github.com/users/whoburg/following{/other_user}","gists_url":"https://api.github.com/users/whoburg/gists{/gist_id}","starred_url":"https://api.github.com/users/whoburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whoburg/subscriptions","organizations_url":"https://api.github.com/users/whoburg/orgs","repos_url":"https://api.github.com/users/whoburg/repos","events_url":"https://api.github.com/users/whoburg/events{/privacy}","received_events_url":"https://api.github.com/users/whoburg/received_events","type":"User","site_admin":false},"created_at":"2016-07-18T19:31:34Z","updated_at":"2016-07-18T19:31:34Z","body":"👍 "}}
{"actor":{"display_login":"whoburg"}}