fast-aircraft-design / FAST-OAD

FAST-OAD: An open source framework for rapid Overall Aircraft Design
GNU General Public License v3.0
47 stars 25 forks source link

ValueError: Math domain error running MDA with MTO=90000 #119

Closed jpruscio closed 3 years ago

jpruscio commented 4 years ago

I changed only the MTO (maximum thrust at SL) value from the original input xml file to 90000 N, I ran MDA, and I obitained the error attached

I downloaded and installed again FAST-OAD today from the link indicated in the readme: https://github.com/fast-aircraft-design/FAST-OAD/archive/master.zip

fast oad error 90000.zip

Thanks!

christophe-david commented 4 years ago

Hi, Thank you for the report.

Sometimes, at beginning of the iterating process, OpenMDAO explores "too much" and produces values that cannot fit in a log (or a square root). Issue #118 is about securing these parts of code (among other things).

@jpruscio, could you please attach your input files (TOML and XML)? It is worth having such case to reproduce. Also, for providing error message, having a zip file that contains a 2kB file just make more difficult to get the info. You may as well attach the text file, or even better, put the message directly in your post (even if it is 200 lines long, it is OK). You can make it nice by enclosing it in triple quotes (if you don't see what I mean, click on "Edit" in the "three point menu" to see how it is done), which will look like:

Some error message
Some other error message

Cheers

jpruscio commented 4 years ago

Great, thanks for the explanation and the advice! 🥇 I attach the requested files

ValueError                                Traceback (most recent call last)
<ipython-input-10-8250723f1a05> in <module>
----> 1 eval_problem = api.evaluate_problem(CONFIGURATION_FILE, overwrite=True)
      2 print('Input max thrust: %.0f' % eval_problem['propulsion:MTO_thrust'], ' [N]')
      3 print('Cruise thrust rate: %.2f' % eval_problem['propulsion:thrust_rate'], ' [-]')
      4 print('MTOW: %.0f' % eval_problem['weight:aircraft:MTOW'], ' [kg]')

d:\data\fast-oad-master\src\fastoad\cmd\api.py in evaluate_problem(configuration_file_path, overwrite)
    257     :return: the OpenMDAO problem after run
    258     """
--> 259     return _run_problem(configuration_file_path, overwrite, 'run_model')
    260 
    261 

d:\data\fast-oad-master\src\fastoad\cmd\api.py in _run_problem(configuration_file_path, overwrite, mode)
    240     problem.setup()
    241     if mode == 'run_model':
--> 242         problem.run_model()
    243     else:
    244         problem.run_driver()

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\problem.py in run_model(self, case_prefix, reset_iter_counts)
    626         self.final_setup()
    627         self.model._clear_iprint()
--> 628         self.model.run_solve_nonlinear()
    629 
    630     def run_driver(self, case_prefix=None, reset_iter_counts=True):

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\system.py in run_solve_nonlinear(self)
   3508         """
   3509         with self._scaled_context_all():
-> 3510             self._solve_nonlinear()
   3511 
   3512     def run_apply_linear(self, vec_names, mode, scope_out=None, scope_in=None):

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\group.py in _solve_nonlinear(self)
   1623 
   1624         with Recording(name + '._solve_nonlinear', self.iter_count, self):
-> 1625             self._nonlinear_solver.solve()
   1626 
   1627     def _guess_nonlinear(self):

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in solve(self)
    623             if self.options['debug_print']:
    624                 self._print_exc_debug_info()
--> 625             reraise(*exc)
    626 
    627     def _iter_initialize(self):

C:\ProgramData\Anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
    691             if value.__traceback__ is not tb:
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:
    695             value = None

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in solve(self)
    618         """
    619         try:
--> 620             self._solve()
    621         except Exception:
    622             exc = sys.exc_info()

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in _solve(self)
    392         while self._iter_count < maxiter and norm > atol and norm / norm0 > rtol:
    393             with Recording(type(self).__name__, self._iter_count, self) as rec:
--> 394                 self._single_iteration()
    395                 self._iter_count += 1
    396                 self._run_apply()

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\nonlinear\nonlinear_block_gs.py in _single_iteration(self)
    126 
    127         self._solver_info.append_subsolver()
--> 128         self._gs_iter()
    129         self._solver_info.pop()
    130 

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in _gs_iter(self)
    708 
    709             if local:
--> 710                 subsys._solve_nonlinear()
    711 
    712             system._check_child_reconf(subsys)

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\group.py in _solve_nonlinear(self)
   1623 
   1624         with Recording(name + '._solve_nonlinear', self.iter_count, self):
-> 1625             self._nonlinear_solver.solve()
   1626 
   1627     def _guess_nonlinear(self):

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\nonlinear\nonlinear_runonce.py in solve(self)
     38             # If this is not a parallel group, transfer for each subsystem just prior to running it.
     39             else:
---> 40                 self._gs_iter()
     41 
     42             rec.abs = 0.0

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in _gs_iter(self)
    708 
    709             if local:
--> 710                 subsys._solve_nonlinear()
    711 
    712             system._check_child_reconf(subsys)

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\group.py in _solve_nonlinear(self)
   1623 
   1624         with Recording(name + '._solve_nonlinear', self.iter_count, self):
-> 1625             self._nonlinear_solver.solve()
   1626 
   1627     def _guess_nonlinear(self):

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\nonlinear\nonlinear_runonce.py in solve(self)
     38             # If this is not a parallel group, transfer for each subsystem just prior to running it.
     39             else:
---> 40                 self._gs_iter()
     41 
     42             rec.abs = 0.0

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\solvers\solver.py in _gs_iter(self)
    708 
    709             if local:
--> 710                 subsys._solve_nonlinear()
    711 
    712             system._check_child_reconf(subsys)

C:\ProgramData\Anaconda3\lib\site-packages\openmdao\core\explicitcomponent.py in _solve_nonlinear(self)
    269                                      self._discrete_outputs)
    270                     else:
--> 271                         self.compute(self._inputs, self._outputs)
    272                 finally:
    273                     self._inputs.read_only = False

d:\data\fast-oad-master\src\fastoad\modules\aerodynamics\components\cd0_ht.py in compute(self, inputs, outputs)
     62 
     63         cf_ht_hs = 0.455 / (
---> 64                 (1 + 0.144 * mach ** 2) ** 0.65 * (math.log10(re_hs * ht_length)) ** 2.58)
     65         ke_cd0_ht = 4.688 * el_ht ** 2 + 3.146 * el_ht
     66         k_phi_cd0_ht = 1 - 0.000178 * sweep_25_ht ** 2 - 0.0065 * sweep_25_ht

ValueError: math domain error

Value_error_math_domain___MDA_with_MTO_90000N.zip

christophe-david commented 4 years ago

Thank you.

no surprise, I can reproduce the crash :) This will be helpful!

ScottDelbecq commented 4 years ago

Hi, I have just checked this issue for the beta release. I cannot reproduce the error anymore. The MDA process has been restructured since and might have solved this issue. @christophe-david or @jpruscio can you test and confirm?

christophe-david commented 4 years ago

You might have a look at PR #126, that I created to secure the branch where this failure case was reproduced. I had once replayed this case after rebasing the branch after the restructuration of the process and got the same result as you.

After that, I experimented a bit and found that with a different module order, the crash could happen again. Therefore, I prefer to keep this issue alive, so we can investigate deeper in the future to ensure more robustness.

christophe-david commented 3 years ago

Closing the issue. It had been solved by the reordering of modules, and current state of FAST-OAD makes that the test case no more relevant.