Update use_api_mphys authored by Adrien Crovato's avatar Adrien Crovato
## MPhys API ## MPhys API
[MPhys](https://github.com/openMDAO/MPHYS) (Multi-Physics) is a framework designed to perform multi-physics analysis and optimization, and is built on top of [OpenMDAO](https://openmdao.org/). The API allows to interface DART with other software through MPhys, and is implemented under [api/mphys](https://gitlab.uliege.be/am-dept/dartflo/blob/master/dart/api/mphys.py). [MPhys](https://github.com/openMDAO/MPHYS) (Multi-Physics) is a framework designed to perform multi-physics analysis and optimization, and is built on top of [OpenMDAO](https://openmdao.org/). The API allows to interface DART with other software through MPhys, and is implemented under [api/mphys](https://gitlab.uliege.be/am-dept/dartflo/blob/master/dart/api/mphys.py).
**0. Importing the API** **0. Importing the API**
Since MPhys couples multiple software, it is required to install them before using MPhys. As such, DART cannot be used from a development environment (it must be installed), and must be imported by calling, Since MPhys couples multiple software, it is required to install them before using MPhys. As such, DART cannot be used from a development environment (it must be installed), and must be imported by calling,
```python ```python
from dartflo.dart.api.mphys import DartBuilder from dartflo.dart.api.mphys import DartBuilder
``` ```
**1. Initializing the interface** **1. Initializing the interface**
In practise, the MPhys API uses the [Core API](use_api_core) to initialize DART. Note that the interface must be setup in an MPhys class, In practise, the MPhys API uses the [Core API](use_api_core) to initialize DART. Note that the interface must be setup in an MPhys class,
```python ```python
from mphys import Multipoint from mphys import Multipoint
class Top(Multipoint): class Top(Multipoint):
# ... # ...
dart = DartBuilder(cfg, scenario='aerodynamic', task='analysis', saveAll=False, raiseError=False) dart = DartBuilder(cfg, save_all=False, raise_error=False)
``` ```
where `cfg` is a dictionary of parameters (available choices are listed in [core](use_api_core)), and where valid choices for `scenario` are `'aerodynamic'` or `'aerostructural'`, and valid choices for `task` are `'analysis'` or `'optimization'`. Additionally, `saveAll` is a boolean indicating whether to write results to different files at each (major) iteration, and `raiseError` is a boolean indicating whether to raise an `OpenMDAO.AnalysisError` when the solver does not fully converge. where `cfg` is a dictionary of parameters (available choices are listed in [core](use_api_core)), `save_all` is a boolean indicating whether to write results to different files at each (major) iteration, and `raise_error` is a boolean indicating whether to raise an `openmdao.api.AnalysisError` when the solver does not fully converge.
*Note* DART can be coupled with [pyGeo](https://github.com/mdolab/pyGeo), which uses the free-form deformation technique, to perform aerodynamic shape optimization. Since pyGeo only handles 3D geometries, users wanting to perform 2D shape optimization must provide a so-called 2.5D geometry, which consists of an extruded 2D geometry enclosed between two symmetry walls. In such a case, the parameters `'WakeTips'` MUST NOT be given. *Note* DART can be coupled with [pyGeo](https://github.com/mdolab/pyGeo), which uses the free-form deformation technique, to perform aerodynamic shape optimization. Since pyGeo only handles 3D geometries, users wanting to perform 2D shape optimization must provide a so-called 2.5D geometry, which consists of an extruded 2D geometry enclosed between two symmetry walls. In such a case, the parameters `'free_edge'` MUST NOT be given.
**2. Using the interface** **2. Using the interface**
Users should refer to the MPhys documentation to connect the interface through MPhys. In version 1.3.0, this is done by calling, Users should refer to the MPhys documentation to connect the interface through MPhys. In version 2.0.0, this is done by calling,
```python ```python
# for pure aerodynamic computations... # for pure aerodynamic computations...
from mphys.scenario_aerodynamic import ScenarioAerodynamic from mphys.scenarios.aerodynamic import ScenarioAerodynamic
self.mphys_add_scenario('...', ScenarioAerodynamic(aero_builder=dart)) self.mphys_add_scenario('...', ScenarioAerodynamic(aero_builder=dart))
# ... or for aerostructural computations # ... or for aerostructural computations
from mphys.scenario_aerostructural import ScenarioAeroStructural from mphys.scenarios.aerostructural import ScenarioAeroStructural
self.mphys_add_scenario('...', ScenarioAeroStructural(aero_builder=dart, struct_builder=..., ldxfer_builder=..., geometry_builder=..., in_MultipointParallel=...), coupling_nonlinear_solver=..., coupling_linear_solver=...) self.mphys_add_scenario('...', ScenarioAeroStructural(aero_builder=dart, struct_builder=..., ldxfer_builder=..., geometry_builder=..., in_MultipointParallel=...), coupling_nonlinear_solver=..., coupling_linear_solver=...)
``` ```