mdolab / OpenAeroStruct

OpenAeroStruct is a lightweight tool that performs aerostructural optimization using OpenMDAO.
Apache License 2.0
196 stars 118 forks source link

"array must not contain infs or NaNs" crash #33

Closed btracey closed 6 years ago

btracey commented 7 years ago

Cloning from master branch, and adding the following conditions (before the call to OAS_prob.run():

OAS_prob.prob['wing.thickness_cp'] = np.array([ 4.5279479027781128e-01,1.9036800154838401e-01,9.8321106961832772e-02])
OAS_prob.prob['alpha'] = -4.0948666786020738e-01
OAS_prob.prob['wing.twist_cp'] = np.array([ -3.2162315517514468e+00,7.1314196111774741e+00,-3.2470369225802571e+00])

Crashes with

Traceback (most recent call last):
  File "run_aerostruct.py", line 132, in <module>
    OAS_prob.run()
  File "/Users/brendan/Documents/SFI/codeother/openaeroversions/aerotest/OpenAeroStruct/run_classes.py", line 587, in run
    self.prob.run_once()
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/problem.py", line 1170, in run_once
    driver.run_once(self)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/driver.py", line 786, in run_once
    system.solve_nonlinear(metadata=metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 739, in solve_nonlinear
    self.nl_solver.solve(params, unknowns, resids, self, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/solver_base.py", line 23, in wrapper
    fn(driver, params, unknowns, resids, system, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/run_once.py", line 51, in solve
    system.children_solve_nonlinear(local_meta)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 759, in children_solve_nonlinear
    sub.solve_nonlinear(sub.params, sub.unknowns, sub.resids, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 739, in solve_nonlinear
    self.nl_solver.solve(params, unknowns, resids, self, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/solver_base.py", line 23, in wrapper
    fn(driver, params, unknowns, resids, system, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/nl_gauss_seidel.py", line 132, in solve
    system.children_solve_nonlinear(local_meta)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 759, in children_solve_nonlinear
    sub.solve_nonlinear(sub.params, sub.unknowns, sub.resids, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 739, in solve_nonlinear
    self.nl_solver.solve(params, unknowns, resids, self, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/solver_base.py", line 23, in wrapper
    fn(driver, params, unknowns, resids, system, metadata)
  File "/usr/local/lib/python3.6/site-packages/openmdao/solvers/run_once.py", line 51, in solve
    system.children_solve_nonlinear(local_meta)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/group.py", line 757, in children_solve_nonlinear
    sub._sys_solve_nonlinear(sub.params, sub.unknowns, sub.resids)
  File "/usr/local/lib/python3.6/site-packages/openmdao/core/component.py", line 609, in _sys_solve_nonlinear
    self.solve_nonlinear(params, unknowns, resids)
  File "/Users/brendan/Documents/SFI/codeother/openaeroversions/aerotest/OpenAeroStruct/vlm.py", line 973, in solve_nonlinear
    self.lup = lu_factor(params['AIC'])
  File "/usr/local/lib/python3.6/site-packages/scipy/linalg/decomp_lu.py", line 58, in lu_factor
    a1 = asarray_chkfinite(a)
  File "/usr/local/lib/python3.6/site-packages/numpy/lib/function_base.py", line 1215, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs
johnjasa commented 7 years ago

I updated the code to throw an AnalysisError when this is detected. This way, if the coupled system doesn't converge, your optimizer or code can handle that error however you choose.

Also, I suggest using the latest version of OpenMDAO1 from https://github.com/openmdao/openmdao1 The latest version has Aitken relaxation, which sometimes helps converge troublesome coupled systems. OpenAeroStruct automatically uses Aitken relaxation if it's available.