Skip to content

Commit

Permalink
Merge pull request #169 from fast-aircraft-design/non-regression-fix
Browse files Browse the repository at this point in the history
Non regression fix
  • Loading branch information
christophe-david committed May 15, 2020
2 parents a31be67 + 87ac66d commit d644c6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/fastoad/io/xml/resources/legacy1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ data:geometry:propulsion:fan:length, Aircraft/geometry/propulsion/fan_length
data:geometry:propulsion:nacelle:y, Aircraft/geometry/propulsion/y_nacell
data:geometry:landing_gear:height, Aircraft/geometry/LG/LG_height
data:aerodynamics:aircraft:landing:CL_max_clean, Aircraft/aerodynamics/CZ_max_clean
data:aerodynamics:aircraft:landing:CL_max_clean_2D, Aircraft/aerodynamics/CZ_max_clean_2D
data:aerodynamics:aircraft:landing:CL_max, Aircraft/aerodynamics/CZ_max_landing
data:aerodynamics:aircraft:takeoff:CL0_clean, Aircraft/aerodynamics/Cz_0_AOA
data:aerodynamics:aircraft:takeoff:CL_alpha, Aircraft/aerodynamics/Cz_alpha_low
Expand Down
35 changes: 19 additions & 16 deletions src/fastoad/openmdao/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,20 @@ def from_problem(
use_initial_values: bool = False,
use_inputs: bool = True,
use_outputs: bool = True,
promoted_only=True,
) -> "VariableList":
"""
Creates a VariableList instance containing
variables (inputs and/or outputs) of a an OpenMDAO Problem.
If variables are promoted, the promoted name will be used. Otherwise, the absolute name will be
used.
If variables are promoted, the promoted name will be used. Otherwise ( and if
promoted_only is False), the absolute name will be used.
:param problem: OpenMDAO Problem instance to inspect
:param use_initial_values: if True, returned instance will contain values before computation
:param use_inputs: if True, returned instance will contain inputs of the problem
:param use_outputs: if True, returned instance will contain outputs of the problem
:param promoted_only: if True, non-promoted variables will be excluded
:return: VariableList instance
"""
variables = VariableList()
Expand All @@ -424,20 +426,21 @@ def from_problem(
prom2abs.update(model._var_allprocs_prom2abs_list["output"])

for prom_name, abs_names in prom2abs.items():
# Pick the first
abs_name = abs_names[0]
metadata = model._var_abs2meta[abs_name]
variable = Variable(name=prom_name, **metadata)
if not use_initial_values:
try:
# Maybe useless, but we force units to ensure it is consistent
variable.value = problem.get_val(prom_name, units=variable.units)
except RuntimeError:
# In case problem is incompletely set, problem.get_val() will fail.
# In such case, falling back to the method for initial values
# should be enough.
pass
variables.append(variable)
if not promoted_only or "." not in prom_name:
# Pick the first
abs_name = abs_names[0]
metadata = model._var_abs2meta[abs_name]
variable = Variable(name=prom_name, **metadata)
if not use_initial_values:
try:
# Maybe useless, but we force units to ensure it is consistent
variable.value = problem.get_val(prom_name, units=variable.units)
except RuntimeError:
# In case problem is incompletely set, problem.get_val() will fail.
# In such case, falling back to the method for initial values
# should be enough.
pass
variables.append(variable)

return variables

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
<CL_alpha_ht>3.46981756498</CL_alpha_ht>
<CL_alpha_vt>2.54615644328</CL_alpha_vt>
<CZ_max_clean>1.586002</CZ_max_clean>
<CZ_max_clean_2D>1.94</CZ_max_clean_2D>
<CZ_max_landing>2.8022927874308396</CZ_max_landing>
<Cz_0_AOA>0.02228</Cz_0_AOA>
<Cz_alpha_low>4.58079757207</Cz_alpha_low>
Expand Down

0 comments on commit d644c6f

Please sign in to comment.