Skip to content

Commit

Permalink
added some new stuff to the update from 1 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinSGray committed Nov 11, 2017
1 parent 83a4588 commit ec85a56
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 12 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ at https://github.com/OpenMDAO/OpenMDAO1
The OpenMDAO 2.0.x code has taken the name OpenMDAO,
and it resides at https://github.com/OpenMDAO/OpenMDAO.

Installation of 2.0.x code will now work with `pip install openmdao`.
Installation of 2.0.x code will now work with `pip install openmdao`.
Installation of 1.7.3 code will now only work with a version specifier: `pip install openmdao==1.7.3`

To use the OpenMDAO v0.x legacy version
Expand Down Expand Up @@ -50,18 +50,17 @@ Features of OpenMDAO 1.7.x Not Yet in 2.x
Be aware that this is an Alpha.
Not all the features of 1.7.x exist in 2.x yet.

Here is a list of things that have not yet been fully developed in 2.x:
Here is a list of things that have not yet been developed in 2.x:

* Pass-by-object variables
* automatic ordering of groups/components based on data connections
* DOE (Design of Experiment) driver and all other case drivers
* Parallel Finite Difference
* File-wrapping utilities
* File variables
* Active-set constraint calculation disabling
* Brent Solver
* CaseRecording using CSV, HDF5, and dump recorders (SqliteRecorder and WebRecorder are currently supported)
* 'auto' selection of mode based on sizes of design variables and responses
* CaseRecording using CSV, HDF5, and dump recorders (SqliteRecorder and WebRecorder are currently supported)
* 'auto' selection of derivatives mode based on sizes of design variables and responses

Installation Instructions:
--------------------------
Expand Down
68 changes: 67 additions & 1 deletion openmdao/core/tests/test_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,77 @@ def test_feature_simple_run_once_no_promote(self):
model.connect('p1.x', 'comp.x')
model.connect('p2.y', 'comp.y')

prob.setup(check=False)
prob.setup()
prob.run_model()

assert_rel_error(self, prob['comp.f_xy'], -15.0)


def test_feature_simple_run_once_input_input(self):
from openmdao.api import Problem, Group, IndepVarComp
from openmdao.test_suite.components.paraboloid import Paraboloid

prob = Problem()
model = prob.model = Group()

model.add_subsystem('p1', IndepVarComp('x', 3.0))

#promote the two inputs to the same name
model.add_subsystem('comp1', Paraboloid(), promotes_inputs=['x'])
model.add_subsystem('comp2', Paraboloid(), promotes_inputs=['x'])

#connect the source to the common name
model.connect('p1.x', 'x')

prob.setup()
prob.run_model()

assert_rel_error(self, prob['comp1.f_xy'], 13.0)
assert_rel_error(self, prob['comp2.f_xy'], 13.0)

def test_feature_simple_run_once_compute_totals(self):
from openmdao.api import Problem, Group, IndepVarComp
from openmdao.test_suite.components.paraboloid import Paraboloid

prob = Problem()
model = prob.model = Group()

model.add_subsystem('p1', IndepVarComp('x', 3.0))
model.add_subsystem('p2', IndepVarComp('y', -4.0))
model.add_subsystem('comp', Paraboloid())

model.connect('p1.x', 'comp.x')
model.connect('p2.y', 'comp.y')

prob.setup()
prob.run_model()

assert_rel_error(self, prob['comp.f_xy'], -15.0)

prob.compute_totals(of=['comp.f_xy'], wrt=['p1.x', 'p2.y'])

def test_feature_simple_run_once_set_deriv_mode(self):
from openmdao.api import Problem, Group, IndepVarComp
from openmdao.test_suite.components.paraboloid import Paraboloid

prob = Problem()
model = prob.model = Group()

model.add_subsystem('p1', IndepVarComp('x', 3.0))
model.add_subsystem('p2', IndepVarComp('y', -4.0))
model.add_subsystem('comp', Paraboloid())

model.connect('p1.x', 'comp.x')
model.connect('p2.y', 'comp.y')

prob.setup(mode='rev')
#prob.setup(mode='fwd')
prob.run_model()

assert_rel_error(self, prob['comp.f_xy'], -15.0)

prob.compute_totals(of=['comp.f_xy'], wrt=['p1.x', 'p2.y'])

def test_set_2d_array(self):
import numpy as np

Expand Down
78 changes: 72 additions & 6 deletions openmdao/docs/api_translation/index.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.. _`api_translation`:

******************
Upgrading from 1.x
******************
**************************
Upgrading from OpenMDAO 1
**************************

This guide takes how you did things in OpenMDAO Alpha and shows how to do them in the latest version of OpenMDAO.
This guide takes how you did things in OpenMDAO 1 and shows how to do them OpenMDAO 2.
It is not a comprehensive guide to using OpenMDAO 2, but focus only on the things that have changed in the API.


Build a Model
Expand Down Expand Up @@ -104,6 +105,34 @@ Define an Implicit Component
return J
Input-Input connections
============================

See more details in the doc for :ref:`add_subsystem() <feature_adding_subsystem_to_a_group>`.

.. content-container ::
.. embed-compare::
openmdao.core.tests.test_problem.TestProblem.test_feature_simple_run_once_input_input
Problem
run_model
prob = Problem()
root = prob.root = Group()
root.add('p1', IndepVarComp('x', 3.0))
root.add('comp1', Paraboloid())
root.add('comp2', Paraboloid())
#input-input connection
root.connect('comp1.x', 'comp2.x')
#then connect the indep var to just one of the inputs
root.connect('p1.x', 'comp1.x')
prob.setup()
prob.run()
Run a Model
-----------
Expand Down Expand Up @@ -264,8 +293,8 @@ Check Partial Derivatives with Complex Step
prob.check_partials()
Change Derivative Behavior
--------------------------
Change Group Level Derivative Behavior
---------------------------------------

Force Group or Model to use Finite Difference
=============================================
Expand Down Expand Up @@ -397,3 +426,40 @@ Specify Linear Block Gauss Seidel as a Linear Solver in a Group
LinearBlockGS()
model.ln_solver = LinearGaussSeidel()
Total Derivatives
----------------------------------


Computing Total Derivatives
================================

.. content-container ::
.. embed-compare::
openmdao.core.tests.test_problem.TestProblem.test_feature_simple_run_once_compute_totals
prob.compute_totals
prob.compute_totals
prob.calc_gradient(indep_list=['p1.x', 'p2.y'], unknown_list=['comp.f_xy'])
Setting Derivative Computation Mode
========================================

.. content-container ::
.. embed-compare::
openmdao.core.tests.test_problem.TestProblem.test_feature_simple_run_once_set_deriv_mode
prob.setup
prob.compute_totals
root.ln_solver.options['mode'] = 'rev'
# root.ln_solver.options['mode'] = 'fwd'
# root.ln_solver.options['mode'] = 'auto'
prob.setup()
prob.run()
prob.calc_gradient(indep_list=['p1.x', 'p2.y'], unknown_list=['comp.f_xy'])

0 comments on commit ec85a56

Please sign in to comment.