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

Variable connections in the configuration file are ignored for indep variables when generating the input file #436

Closed ScottDelbecq closed 2 years ago

ScottDelbecq commented 2 years ago

Describe the bug In the presence of IndepVarComp and if these are connected to component inputs directly in the configuration file, the connections are ignored when generating the input file. Though, it seems when a run_model is achieved the connections are not ignored.

To Reproduce I added a unit test here: https://github.com/fast-aircraft-design/FAST-OAD/blob/22e52d93b784fb92e9cefbbaea305111c5625491/src/fastoad/io/configuration/tests/test_configuration.py#L159-L201

The test uses this configuration file:

title: Sellar

module_folders:
  - conf_sellar_example
  - d:/path/does/not/exist  # will only trigger a warning

input_file: ../results/problem_definition_with_indep/inputs.xml
output_file: ../results/problem_definition_with_indep/outputs.xml

driver: om.ScipyOptimizeDriver(optimizer='SLSQP')
model:
  indep:
    id: configuration_test.sellar.indeps
  connections:
    - source: system:x
      target: x
    - source: y1
      target: yy1
    - source: y2
      target: yy2
  cycle:
    nonlinear_solver: om.NonlinearBlockGS(iprint=1)
    linear_solver: om.ScipyKrylov()
    disc1:
      id: configuration_test.sellar.disc1
    disc2:
      id: configuration_test.sellar.disc2
  functions:
    id: configuration_test.sellar.functions

Expected behavior x that is connected to system:x should not appear in the generated input file. In the unit test provided we should obtain:

<FASTOAD_model>
  <z units="m**2" is_input="True">[5.0, 2.0]</z>
  <system>
    <x is_input="True">2</x>
  </system>
</FASTOAD_model>

Instead of:

<FASTOAD_model>
  <x is_input="True">1.0</x>
  <z units="m**2" is_input="True">[5.0, 2.0]</z>
  <system>
    <x is_input="True">2</x>
  </system>
</FASTOAD_model>

Environment