{"action":"opened","issue":{"url":"https://api.github.com/repos/convexopt/gpkit/issues/492","labels_url":"https://api.github.com/repos/convexopt/gpkit/issues/492/labels{/name}","comments_url":"https://api.github.com/repos/convexopt/gpkit/issues/492/comments","events_url":"https://api.github.com/repos/convexopt/gpkit/issues/492/events","html_url":"https://github.com/convexopt/gpkit/issues/492","id":119389561,"number":492,"title":"ufunc 'isnan' not supported for the input types","user":{"login":"pgkirsch","id":8702579,"avatar_url":"https://avatars.githubusercontent.com/u/8702579?v=3","gravatar_id":"","url":"https://api.github.com/users/pgkirsch","html_url":"https://github.com/pgkirsch","followers_url":"https://api.github.com/users/pgkirsch/followers","following_url":"https://api.github.com/users/pgkirsch/following{/other_user}","gists_url":"https://api.github.com/users/pgkirsch/gists{/gist_id}","starred_url":"https://api.github.com/users/pgkirsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgkirsch/subscriptions","organizations_url":"https://api.github.com/users/pgkirsch/orgs","repos_url":"https://api.github.com/users/pgkirsch/repos","events_url":"https://api.github.com/users/pgkirsch/events{/privacy}","received_events_url":"https://api.github.com/users/pgkirsch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-29T21:26:45Z","updated_at":"2015-11-29T21:26:45Z","closed_at":null,"body":"I made the mistake of pulling a new version of gpkit 2 days before my paper is due and now one of my models returns a mysterious new error.\r\n```python\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n/Users/philippekirschen/Documents/MIT/Research/GPjet/gpjet/landing_gear/landing_gear.py in <module>()\r\n    230 \r\n    231 if __name__ == \"__main__\":\r\n--> 232     LandingGear().test()\r\n\r\n/Users/philippekirschen/Documents/MIT/Research/GPjet/gpjet/landing_gear/landing_gear.py in test(self)\r\n    218 \r\n    219     def test(self):\r\n--> 220         sol = self.localsolve()\r\n    221         npt.assert_almost_equal( sol('x_n') + sol('B'), sol('x_m'), decimal=5)\r\n    222         npt.assert_almost_equal( sol('\\Delta x_{CG-n}') + sol('x_n'), sol('x_{CG}'), decimal=1)\r\n\r\n/Users/philippekirschen/Documents/MIT/Research/GPkit/gpkit/gpkit/model.pyc in localsolve(self, solver, verbosity, skipsweepfailures, *args, **kwargs)\r\n    381             with SignomialsEnabled():\r\n    382                 return self._solve(\"sp\", solver, verbosity, skipsweepfailures,\r\n--> 383                                    *args, **kwargs)\r\n    384         except ValueError as err:\r\n    385             if err.message == (\"SignomialPrograms must contain at least one\"\r\n\r\n/Users/philippekirschen/Documents/MIT/Research/GPkit/gpkit/gpkit/model.pyc in _solve(self, programType, solver, verbosity, skipsweepfailures, *args, **kwargs)\r\n    494             kwargs.update({\"verbosity\": verbosity-1})\r\n    495             signomials, beforesubs.smaps = simplify_and_mmap(signomials,\r\n--> 496                                                              constants)\r\n    497             # NOTE: SIDE EFFECTS\r\n    498             self.program, solvefn = form_program(programType, signomials,\r\n\r\n/Users/philippekirschen/Documents/MIT/Research/GPkit/gpkit/gpkit/model.pyc in simplify_and_mmap(constraints, subs)\r\n    769         _, exps, cs, _ = substitution(s, subs)\r\n    770         # remove any cs that are just nans and/or 0s\r\n--> 771         notnan = ~np.isnan(cs)\r\n    772         if np.any(notnan) and np.any(cs[notnan] != 0):\r\n    773             exps, cs, smap = simplify_exps_and_cs(exps, cs, return_map=True)\r\n\r\nTypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''\r\n```\r\n\r\n\r\n```python\r\nfrom gpkit import Variable, Model, SignomialsEnabled, units\r\nimport numpy as np\r\nimport numpy.testing as npt\r\n\r\nclass LandingGear(Model):\r\n    \"\"\"\r\n    Landing gear sizing\r\n    sources:\r\n    AERO 481 notes\r\n    http://www.fzt.haw-hamburg.de/pers/Scholz/dglr/hh/text_2002_04_11_Fahrwerk.pdf\r\n    http://faculty.dwc.edu/sadraey/Chapter%209.%20Landing%20Gear%20Design.pdf\r\n    http://www.dept.aoe.vt.edu/~mason/Mason_f/M96SC03.pdf\r\n    http://asm.matweb.com/search/SpecificMaterial.asp?bassnum=MTP641\r\n    https://en.wikipedia.org/wiki/Buckling\r\n    http://arc.aiaa.org/doi/pdf/10.2514/3.7771\r\n    \"\"\"\r\n    def setup(self):\r\n        # Variables\r\n        B       = Variable('B', 'm', 'Landing gear base')\r\n        D       = Variable('D', 'N', 'Drag due to landing gear struts')\r\n        D_m     = Variable('D_m', 'N', 'Drag due to one main gear strut')\r\n        D_n     = Variable('D_n', 'N', 'Drag due to nose gear strut')\r\n        Dtm     = Variable('D_{t_m}', 'in', 'Outer diameter of main gear tyres') # b737.org.uk\r\n        Eland   = Variable('Eland', 'J', 'Max kinetic energy of aircraft to be absorbed in landing')\r\n        Fwm     = Variable('Fwm', '-', 'Weight factor (main)') # Currey p143\r\n        Fwn     = Variable('Fwn', '', 'Weight factor (nose)') # Currey p143\r\n        I_m     = Variable('I_m', 'm^4', 'Area moment of inertia of main gear struts')\r\n        I_n     = Variable('I_n', 'm^4', 'Area moment of inertia of nose gear strut')\r\n        l_m     = Variable('l_m', 'm', 'Length of main gear')\r\n        l_n     = Variable('l_n', 'm', 'Length of nose gear')\r\n        L_m     = Variable('L_m', 'N', 'Maximum static load in main gear (not per strut)')\r\n        L_n     = Variable('L_n', 'N', 'Minimum static load in nose gear')\r\n        L_n_dyn = Variable('L_{n_{dyn}}', 'N', 'Dynamic braking load in nose gear')\r\n        Lwm     = Variable('L_{w_m}', 'N', 'Static load per wheel (main)')\r\n        Lwn     = Variable('L_{w_n}', 'N', 'Static load per wheel (nose)')\r\n        r_m     = Variable('r_m', 'm', 'Radius of main gear struts')\r\n        r_n     = Variable('r_n', 'm', 'Radius of nose gear struts')\r\n        S       = Variable('S', 'm', 'Stroke of the shock absorber')\r\n        S_t     = Variable('S_t', 'm', 'Tyre deflection')\r\n        t_m     = Variable('t_m', 'm', 'Thickness of main gear strut wall')\r\n        t_n     = Variable('t_n', 'm', 'Thickness of nose gear strut wall')\r\n        T       = Variable('T', 'm', 'Main landing gear track')\r\n        tan_phi = Variable('\\\\tan(\\\\phi)', '-', 'Angle between main gear and CG/gear line')\r\n        tan_psi = Variable('\\\\tan(\\\\psi)', '-', 'Tip over angles')\r\n        WAWm    = Variable('WAWm', 'lbf', 'Wheel assembly weight for a single main gear wheel')\r\n        WAWn    = Variable('WAWn', 'lbf', 'Wheel assembly weight for a single nose gear wheel')\r\n        W_lg    = Variable('W_{lg}', 'N', 'Weight of landing gear')\r\n        W_ng    = Variable('W_{ng}', 'N', 'Weight of nose gear')\r\n        W_ns    = Variable('W_{ns}', 'N', 'Weight of nose strut')\r\n        W_nw    = Variable('W_{nw}', 'N', 'Weight of nose wheel (aggregate)')\r\n        W_mg    = Variable('W_{mg}', 'N', 'Weight of main gear')\r\n        W_ms    = Variable('W_{ms}', 'N', 'Weight of main struts')\r\n        W_mw    = Variable('W_{mw}', 'N', 'Weight of main wheels (aggregate per strut)')\r\n        wtm     = Variable('w_{t_m}', 'in', 'Tyre max width (main)')\r\n        x_m     = Variable('x_m',  'm', 'x-location of main gear')\r\n        x_n     = Variable('x_n', 'm', 'x-location of nose gear')\r\n        xcgm    = Variable('\\\\Delta x_{CG-m}',  'm', 'Distance between main gear and aft CG')\r\n        xcgn    = Variable('\\\\Delta x_{CG-n}', 'm', 'Distance between nose gear and aft CG')\r\n        y_m     = Variable('y_m', 'm', 'y-location of main gear (symmetric)')\r\n\r\n        # Constants\r\n        CD        = Variable('C_D', 0.8, '-', 'Drag coefficient on a finite cylinder AR=15') # http://arc.aiaa.org/doi/pdf/10.2514/3.7771\r\n        d_nac     = Variable('d_{nacelle}', 2, 'm', 'Nacelle diameter')\r\n        E         = Variable('E', 113.8, 'GPa', 'Modulus of elasticity, Ti 6-4')\r\n        eta_s     = Variable('\\\\eta_s', 0.8, '-', 'Efficiency of shock absorber')\r\n        eta_t     = Variable('\\\\eta_t', 0.47, '-', 'Efficiency of tyre in shock absorption')\r\n        g         = Variable('g', 9.81, 'm/s^2', 'Gravitational acceleration')\r\n        h_nac     = Variable('h_{nacelle}', 0.5, 'm', 'Minimum nacelle ground clearance')\r\n        K         = Variable('K', 2, '-', 'Column effective length factor')\r\n        lam       = Variable('\\\\lambda', 2.5, '-', 'Ratio of maximum load to static load') # Torenbeek p360\r\n        n_mg      = Variable('n_{mg}', 2, '-', 'Number of main gear struts')\r\n        N_s       = Variable('N_s', 2, '-', 'Factor of safety')\r\n        nwps      = Variable('n_{wps}', 2, '-', 'Number of wheels per strut')\r\n        Dtn       = Variable('D_{t_n}', 44.5, 'in', 'Outer diameter of nose gear tyres') # b737.org.uk\r\n        p_oleo    = Variable('p_{oleo}', 1800, 'lbf/in^2', 'Oleo internal pressure')\r\n#        p_t       = Variable('p_t', 170, 'lbf/in^2', 'Tyre pressure')\r\n        rhoinf    = Variable('\\\\rho_{\\infty}', 1.225, 'kg/m^3', 'Air density at sea level')\r\n        rho_Ti    = Variable('\\\\rho_{Ti}', 4430, 'kg/m^3', 'Density of Ti 6-4')\r\n        sig_y_c   = Variable('\\\\sigma_{y_c}', 970E6, 'Pa', 'Compressive yield strength Ti 6-4 ')\r\n        tan_15    = Variable('\\\\tan(15)', np.tan(15*np.pi/180), '-', 'Lower bound on phi')\r\n        tan_63    = Variable('\\\\tan(63)', np.tan(63*np.pi/180), '-', 'Upper bound on psi')\r\n        tan_th_TO = Variable('\\\\tan(\\\\theta_{TO})', np.tan(15*np.pi/180), '-', 'Takeoff angle of attack (15 deg)')\r\n        VTO       = Variable('V_{TO}', 150, 'm/s', 'Takeoff velocity')\r\n        w         = Variable('w', 10, 'ft/s', 'Ultimate velocity of descent')\r\n        W_0       = Variable('W_0', 82000*9.81, 'N', 'Weight of aircraft excluding landing gear (Boeing 737 Max airport doc)')\r\n        xcg       = Variable('x_{CG}', 18, 'm', 'x-location of aft CG excluding landing gear (737 approx)')\r\n        x_upswp   = Variable('x_{upswp}', 28, 'm', 'x-location of fuselage upsweep (737 approx)')\r\n        y_eng     = Variable('y_{eng}', 4.83, 'm', 'Spanwise location of engines') # source: Boeing airport doc\r\n        z_CG_0    = Variable('z_{CG}', 2, 'm', 'z-location of aircraft CG relative to bottom of fuselage excluding landing gear ')\r\n        l_oleo = Variable('l_{oleo}', 'm', 'Length of oleo shock absorber')\r\n        D_oleo = Variable('D_{oleo}', 'm', 'Diameter of oleo shock absorber')\r\n        Waddm = Variable('W_{add_m}', 'N', 'Proportional added weight (main gear)')\r\n        Waddn = Variable('W_{add_n}', 'N', 'Proportional added weight (nose gear)')\r\n\r\n        with SignomialsEnabled():\r\n\r\n            objective = W_lg + 0.1*D\r\n\r\n           constraints = [\r\n                           # Track and Base geometry definitions\r\n                           l_n == l_m, # Possibly change TODO\r\n                           T == 2*y_m,\r\n                           x_n + B <= x_m,\r\n                           x_n >= 5*units.m, # nose gear after nose\r\n\r\n                           # Geometric constraints relating gear placement with fore/aft CG locations\r\n                           xcgn + x_n >= xcg, # [SP] Needs to be tight\r\n                           xcgm + xcg >= x_m, # [SP] Needs to be tight\r\n                           # TODO forward and aft CG\r\n\r\n                           # Maximum static loads through main and nose gears\r\n                           L_n == W_0*xcgm/B,\r\n                           L_m == W_0*xcgn/B,\r\n\r\n                           # Dynamic braking load through nose gear (assumes deceleration of 10 ft/s^2)\r\n                           L_n_dyn >= 0.31*((z_CG_0+l_m)/B)*W_0,\r\n\r\n                           # For steering don't want too much or too little load on nose gear (8%?)\r\n                           L_n/W_0 >= 0.05,\r\n                           L_n/W_0 <= 0.20,\r\n\r\n                           # Longitudinal tip over (static)\r\n                           # Assumes that landing gear does not appreciably move the CG\r\n                           # TODO: how to handle the ambiguity of which way the LG moves the CG?\r\n                           x_m >= tan_phi*(z_CG_0+l_m) + xcg,\r\n                           tan_phi >= tan_15,\r\n\r\n                           # Lateral tip over in turn (dynamic)\r\n                           # http://www.dept.aoe.vt.edu/~mason/Mason_f/M96SC03.pdf\r\n                           # stricter constraint uses forward CG\r\n                           # need upper bound on xcgn \r\n                           # cos(arctan(y/x))) = x/sqrt(x^2 + y^2)\r\n                           1 >= (z_CG_0 + l_m)**2 * (y_m**2 + B**2) / (xcgn * y_m * tan_psi)**2,\r\n                           tan_psi <= tan_63,\r\n\r\n                           # Tail strike: Longitudinal ground clearance in takeoff, landing (Raymer says 10-15 degrees)\r\n                           # TODO?: 2 cases:(i) upsweep angle >= rotation angle,(ii) upsweep angle < rotation ang\r\n                           x_upswp - x_m <= l_m/tan_th_TO, # SP\r\n\r\n                           # Engine ground clearance\r\n                           # TODO: add dihedral?\r\n                           d_nac + h_nac <= l_m,\r\n\r\n                           # Size/Volume for retraction\r\n                           y_m >= l_m,\r\n\r\n                           # Constrains/is constrained by engine location\r\n                           y_m <= y_eng,\r\n\r\n                           # Brake sizing for stopping aircraft\r\n\r\n                           # Hard landing\r\n                           # http://www.boeing.com/commercial/aeromagazine/articles/qtr_3_07/AERO_Q307_article3.pdf\r\n                           # sink rate of 10 feet per second at the maximum design landing weight\r\n                           # sink rate of 6 feet per second at the maximum design takeoff weight\r\n                           # Landing condition from Torenbeek p360\r\n                           Eland == W_0/(2*g)*w**2, # Torenbeek (10-26)\r\n#                           S_t == 0.5*lam*Lwm/(p*(Dtm*bt)**0.5), # Torenbeek (10-30)\r\n                           S == (1/eta_s)*(Eland/(L_m*lam)),# - eta_t*S_t), # [SP] Torenbeek (10-28)\r\n                           l_oleo == 2.5*S, # Raymer 244\r\n                           D_oleo == 1.3*(4*lam*L_m/n_mg/(np.pi*p_oleo))**0.5,\r\n                           Lwm == L_m/(n_mg*nwps),\r\n                           Lwn == L_n/nwps,\r\n\r\n                           # Wheel weights\r\n                           Fwm == Lwm*Dtm/(1000*Lwm.units*Dtm.units),\r\n                           WAWm == 1.2*units.lbf*Fwm**0.609,# Norman Currey p145\r\n                           Fwn == Lwn*Dtn/(1000*units.lbf*units.inches),\r\n                           WAWn == 1.2*units.lbf*Fwn**0.609,# Norman Currey p145\r\n\r\n                           # Main wheel diameter/width (Raymer)\r\n                           Dtm == 1.63*units.inches*(Lwm/(4.44*units.N))**0.315, # Raymer p233 (converting units)\r\n                           wtm == 0.1043*units.inches*(Lwm/(4.44*units.N))**0.480,\r\n\r\n                           # Maximum beam bending (limits track, downward pressure on y_m)\r\n\r\n                           # Weight is a function of height and load through each strut \r\n                           # as well as tyre size (and obviously number of struts)\r\n                           # Main gear strut weight (for a single strut) is a function of length and load passing through strut\r\n                           W_ms >= 2*np.pi*r_m*t_m*l_m * rho_Ti * g,\r\n                           N_s * lam * L_m/n_mg <= sig_y_c * (2*np.pi*r_m*t_m), # find cross sectional area based on compressive yield in hard landing condition\r\n                           W_mw == nwps*WAWm,\r\n\r\n                           # Nose gear strut weight is a function of length and load passing through strut\r\n                           W_ns >= 2*np.pi*r_n*t_n*l_n * rho_Ti * g,\r\n                           N_s * (L_n + L_n_dyn) <= sig_y_c * (2*np.pi*r_n*t_n), # find cross sectional area based on compressive yield\r\n                           W_nw >= nwps*WAWn,\r\n\r\n                           # Buckling constraint on main gear\r\n                           L_m <= np.pi**2*E*I_m/(K*l_m)**2,\r\n                           I_m == np.pi*r_m**3*t_m,\r\n\r\n                           # Buckling constraint on nose gear\r\n                           # source: https://en.wikipedia.org/wiki/Buckling\r\n                           L_n <= np.pi**2*E*I_n/(K*l_n)**2,\r\n                           I_n == np.pi*r_n**3*t_n,\r\n\r\n                           # Machining constraint # p89 Mason\r\n                           # http://www.dept.aoe.vt.edu/~mason/Mason_f/M96SC08.pdf\r\n                           2*r_m/t_m <= 40,\r\n                           2*r_m/t_n <= 40,\r\n\r\n\r\n                           # Drag on a cylinder\r\n                           D >= D_n + n_mg*D_m,\r\n                           D_m >= 0.5*rhoinf*VTO**2* r_m*l_m *CD,\r\n                           D_n >= 0.5*rhoinf*VTO**2* r_n*l_n *CD,\r\n\r\n                           # Weight accounting\r\n                           Waddm == 1.5*W_mw, # Currey p264\r\n                           Waddn == 5*W_nw,\r\n                           W_mg >= n_mg*(W_ms + W_mw + Waddm),\r\n                           W_ng >= W_ns + W_nw + Waddn,\r\n                           W_lg >= W_mg + W_ng,\r\n                          ]\r\n        return objective, constraints\r\n\r\n    def test(self):\r\n        sol = self.localsolve()\r\n        npt.assert_almost_equal( sol('x_n') + sol('B'), sol('x_m'), decimal=5)\r\n        npt.assert_almost_equal( sol('\\Delta x_{CG-n}') + sol('x_n'), sol('x_{CG}'), decimal=1)\r\n        npt.assert_almost_equal(sol('\\Delta x_{CG-m}') + sol('x_{CG}') , sol('x_m'), decimal=4)\r\n\r\n#        with open('landing_gear.tex', 'w') as outfile:\r\n#            outfile.write(self.latex())\r\n\r\n        with open('soltable.tex', 'w') as outfile:\r\n            outfile.write(sol.table(latex=True))\r\n\r\nif __name__ == \"__main__\":\r\n    LandingGear().test()"}}