-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #408 from fast-aircraft-design/issue-406_indep_var…
…_comp Issue 406 - Adding internal IndepVarComp to inputs
- Loading branch information
Showing
16 changed files
with
328 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/fastoad/io/configuration/tests/data/conf_sellar_example/indep.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Sellar indeps""" | ||
# This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design | ||
# Copyright (C) 2021 ONERA & ISAE-SUPAERO | ||
# FAST is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import openmdao.api as om | ||
|
||
from fastoad.module_management.service_registry import RegisterOpenMDAOSystem | ||
|
||
|
||
@RegisterOpenMDAOSystem("configuration_test.sellar.indeps") | ||
class Indeps(om.Group): | ||
def setup(self): | ||
# System variables | ||
comp = om.IndepVarComp() | ||
comp.add_output("system:x", val=2) | ||
|
||
self.add_subsystem("indeps", comp, promotes=["*"]) |
56 changes: 56 additions & 0 deletions
56
src/fastoad/io/configuration/tests/data/valid_sellar_with_indep.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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 | ||
|
||
|
||
submodels: | ||
service.function.f: function.f.default | ||
service.function.g1: function.g1.default | ||
service.function.g2: function.g2.default | ||
|
||
optimization: | ||
design_variables: | ||
- name: x | ||
lower: 0 | ||
upper: 10 | ||
- name: z | ||
lower: 0 | ||
upper: 10 | ||
constraints: | ||
- name: g1 | ||
lower: -100 | ||
upper: 0 | ||
- name: g2 | ||
upper: 0 | ||
objective: | ||
- name: f | ||
scaler: 1e-1 | ||
|
||
unknown_section: | ||
foo: bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Module for custom Exception classes linked to OpenMDAO | ||
""" | ||
|
||
|
||
# This file is part of FAST-OAD : A framework for rapid Overall Aircraft Design | ||
# Copyright (C) 2022 ONERA & ISAE-SUPAERO | ||
# FAST is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
|
||
from typing import List | ||
|
||
from fastoad.exceptions import FastError | ||
|
||
|
||
class FASTOpenMDAONanInInputFile(FastError): | ||
"""Raised if NaN values are read in input data file.""" | ||
|
||
def __init__(self, input_file_path: str, nan_variable_names: List[str]): | ||
self.input_file_path = input_file_path | ||
self.nan_variable_names = nan_variable_names | ||
|
||
msg = "NaN values found in input file (%s). Please check following variables: %s" % ( | ||
input_file_path, | ||
nan_variable_names, | ||
) | ||
|
||
super().__init__(self, msg) |
Oops, something went wrong.