Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,316 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
|
||
file_excludes = [ | ||
'test_*', | ||
'__init__.py', | ||
'_*.py', | ||
] | ||
|
||
ignores = { | ||
|
Binary file added
BIN
+261 KB
openmdao/docs/features/model_visualization/images/meta_model_viewer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ a model. | |
view_connections.rst | ||
n2_basics.rst | ||
n2_details.rst | ||
meta_model_basics.rst |
38 changes: 38 additions & 0 deletions
38
openmdao/docs/features/model_visualization/meta_model_basics.rst
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,38 @@ | ||
.. _meta_model_basics: | ||
|
||
************************* | ||
Metamodel Visualization | ||
************************* | ||
|
||
When evaluating surrogate models, it can be helpful to determine training data fit graphically. OpenMDAO | ||
has created a package to visualize the training data and surrogate models generated from it. This page | ||
explains how to use the `meta_model_viewer.py` package from the command line. | ||
|
||
The metamodel viewer allows a user the ability of reducing a high dimentional input space down | ||
to three dimensions to enable the user to determine the fit of a surrogate model to the given | ||
training data. | ||
|
||
.. embed-code:: | ||
../test_suite/test_examples/meta_model_examples/meta_model_viewer_example.py | ||
|
||
|
||
From the Command Line | ||
--------------------- | ||
|
||
.. _om-command-view_meta_model: | ||
|
||
Generating a metamodel diagram for a model from the command line is easy. You need a | ||
Python script that contains the metamodel. | ||
|
||
Running :code:`openmdao meta_model meta_model_viewer_example.py` will open the metamodel generated from the script in the | ||
browser and generate a metamodel viewer like the one below. | ||
|
||
.. image:: images/meta_model_viewer.png | ||
:width: 900 | ||
|
||
The command, :code:`openmdao meta_model` requires a file path and the name of the surrogate model which you | ||
want to visualize if there is more than one surrogate in your file: | ||
|
||
.. embed-shell-cmd:: | ||
:cmd: openmdao meta_model -h | ||
|
34 changes: 34 additions & 0 deletions
34
openmdao/test_suite/test_examples/meta_model_examples/meta_model_viewer_example.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,34 @@ | ||
"""Example script for meta model viewer.""" | ||
import numpy as np | ||
import openmdao.api as om | ||
from openmdao.visualization.meta_model_viewer.meta_model_visualization import MetaModelVisualization | ||
|
||
# Model | ||
interp = om.MetaModelUnStructuredComp() | ||
|
||
# Training Data | ||
x_train1 = np.linspace(0, 10, 20) | ||
x_train2 = np.linspace(0, 20, 20) | ||
x_train3 = np.linspace(0, 30, 20) | ||
x_train4 = np.linspace(0, 40, 20) | ||
y_train = np.linspace(10, 20, 20) | ||
|
||
# Inputs | ||
interp.add_input('input_1', 0., training_data=x_train1) | ||
interp.add_input('input_2', 0., training_data=x_train2) | ||
interp.add_input('input_3', 0., training_data=x_train3) | ||
interp.add_input('input_4', 0., training_data=x_train4) | ||
|
||
# Outputs | ||
interp.add_output('output_1', 0., training_data=.5 * np.cos(y_train)) | ||
interp.add_output('output_2', 0., training_data=.5 * np.sin(y_train)) | ||
|
||
# Surrogate Model | ||
interp.options['default_surrogate'] = om.ResponseSurface() | ||
|
||
prob = om.Problem() | ||
prob.model.add_subsystem('interp', interp) | ||
prob.setup() | ||
prob.final_setup() | ||
|
||
viz = MetaModelVisualization(interp) |
37 changes: 37 additions & 0 deletions
37
openmdao/test_suite/test_examples/meta_model_examples/slinear_meta_model_viewer_example.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,37 @@ | ||
import numpy as np | ||
import openmdao.api as om | ||
from openmdao.visualization.meta_model_viewer.meta_model_visualization import MetaModelVisualization | ||
|
||
num_train = 10 | ||
|
||
x0_min, x0_max = -5.0, 10.0 | ||
x1_min, x1_max = 0.0, 15.0 | ||
train_x0 = np.linspace(x0_min, x0_max, num_train) | ||
train_x1 = np.linspace(x1_min, x1_max, num_train) | ||
t_data = np.array([[308.12909601, 253.61567418, 204.6578079, 161.25549718, 123.40874201, 91.1175424, 64.38189835, 43.20180985, 27.5772769, 17.50829952], | ||
[162.89542418, 123.20470795, 89.06954726, 60.48994214, 37.46589257, 19.99739855, 8.08446009, 1.72707719, 0.92524984, 5.67897804,], | ||
[ 90.2866907, 63.02637433, 41.32161352, 25.17240826, 14.57875856, 9.54066442, 10.05812583, 16.13114279, 27.75971531, 44.94384339,], | ||
[ 55.60211264, 38.37989042, 26.71322375, 20.60211264, 20.04655709, 25.04655709, 35.60211264, 51.71322375, 73.37989042, 100.60211264], | ||
[ 22.81724065, 13.24080685, 9.2199286, 10.75460591, 17.84483877, 30.49062719, 48.69197117, 72.4488707, 101.76132579, 136.62933643], | ||
[ 5.11168719, 0.78873608, 2.02134053, 8.80950054, 21.1532161, 39.05248721, 62.50731389, 91.51769611, 126.0836339, 166.20512723], | ||
[ 14.3413983, 12.87962416, 16.97340558, 26.62274256, 41.82763509, 62.58808317, 88.90408682, 120.77564601, 158.20276077, 201.18543108], | ||
[ 20.18431209, 19.1914092, 23.75406186, 33.87227009, 49.54603386, 70.77535319, 97.56022808, 129.90065853, 167.79664453, 211.24818608], | ||
[ 8.48953212, 5.57319475, 8.21241294, 16.40718668, 30.15751598, 49.46340083, 74.32484124, 104.74183721, 140.71438873, 182.2424958 ], | ||
[ 10.96088904, 3.72881146, 2.05228945, 5.93132298, 15.36591208, 30.35605673, 50.90175693, 77.00301269, 108.65982401, 145.87219088]]) | ||
|
||
prob = om.Problem() | ||
ivc = om.IndepVarComp() | ||
ivc.add_output('x0', 0.0) | ||
ivc.add_output('x1', 0.0) | ||
|
||
prob.model.add_subsystem('p', ivc, promotes=['*']) | ||
mm = prob.model.add_subsystem('mm', om.MetaModelStructuredComp(method='slinear'), | ||
promotes=['x0', 'x1']) | ||
mm.add_input('x0', 0.0, train_x0) | ||
mm.add_input('x1', 0.0, train_x1) | ||
mm.add_output('f', 0.0, t_data) | ||
|
||
prob.setup() | ||
prob.final_setup() | ||
|
||
MetaModelVisualization(mm) |
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
Empty file.
Oops, something went wrong.