Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup for The Diagram Styles #31

Merged
merged 11 commits into from
Aug 31, 2020
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,16 @@ You need to install these libraries for pyXDSM to work. See the [install guide](
## How do I use it?
Here is a simple example. There are some other more advanced things you can do as well. Check out the [examples folder](https://github.com/mdolab/pyXDSM/blob/master/examples)
```python
from pyxdsm.XDSM import XDSM

opt = 'Optimization'
solver = 'MDA'
func = 'Function'
from pyxdsm.XDSM import XDSM, OPT, SOLVER, FUNC

x = XDSM()

x.add_system('opt', opt, r'\text{Optimizer}')
x.add_system('solver', solver, r'\text{Newton}')
x.add_system('D1', func, 'D_1')
x.add_system('D2', func, 'D_2')
x.add_system('F', func, 'F')
x.add_system('G', func, 'G')
x.add_system('opt', OPT, r'\text{Optimizer}')
x.add_system('solver', SOLVER, r'\text{Newton}')
x.add_system('D1', FUNC, 'D_1')
x.add_system('D2', FUNC, 'D_2')
x.add_system('F', FUNC, 'F')
x.add_system('G', FUNC, 'G')

x.connect('opt', 'D1', 'x, z')
x.connect('opt', 'D2', 'z')
Expand Down
Binary file modified examples/kitchen_sink.pdf
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/kitchen_sink.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pyxdsm.XDSM import XDSM
from pyxdsm.XDSM import (XDSM, OPT, SUBOPT, SOLVER, DOE,
IFUNC, FUNC, GROUP, IGROUP, METAMODEL)

# styling names for the boxes
opt = 'Optimization'
Expand Down
Binary file modified examples/mat_eqn_example.pdf
Binary file not shown.
Binary file modified examples/mdf.pdf
Binary file not shown.
18 changes: 7 additions & 11 deletions examples/mdf.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from pyxdsm.XDSM import XDSM

opt = 'Optimization'
solver = 'MDA'
func = 'Function'
from pyxdsm.XDSM import XDSM, OPT, SOLVER, FUNC

# Change `use_sfmath` to False to use computer modern
x = XDSM(use_sfmath=True)

x.add_system('opt', opt, r'\text{Optimizer}')
x.add_system('solver', solver, r'\text{Newton}')
x.add_system('D1', func, 'D_1')
x.add_system('D2', func, 'D_2')
x.add_system('F', func, 'F')
x.add_system('G', func, 'G')
x.add_system('opt', OPT, r'\text{Optimizer}')
x.add_system('solver', SOLVER, r'\text{Newton}')
x.add_system('D1', FUNC, 'D_1')
x.add_system('D2', FUNC, 'D_2')
x.add_system('F', FUNC, 'F')
x.add_system('G', FUNC, 'G')

x.connect('opt', 'D1', 'x, z')
x.connect('opt', 'D2', 'z')
Expand Down
10 changes: 10 additions & 0 deletions pyxdsm/XDSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

from pyxdsm import __version__ as pyxdsm_version

OPT = 'Optimization'
SUBOPT = 'SubOptimization'
SOLVER = 'MDA'
DOE = 'DOE'
IFUNC = 'ImplicitFunction'
FUNC = 'Function'
GROUP = 'Group'
IGROUP = 'ImplicitGroup'
METAMODEL = 'Metamodel'

tikzpicture_template = r"""
%%% Preamble Requirements %%%
% \usepackage{{geometry}}
Expand Down
32 changes: 16 additions & 16 deletions pyxdsm/tests/test_xdsm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import os
from pyxdsm.XDSM import XDSM, __file__
from pyxdsm.XDSM import XDSM, __file__, OPT, FUNC, SOLVER
from numpy.distutils.exec_command import find_executable


Expand Down Expand Up @@ -56,8 +56,8 @@ def test_examples(self):

def test_connect(self):
x = XDSM(use_sfmath=False)
x.add_system('D1', 'Function', 'D_1', label_width=2)
x.add_system('D2', 'Function', 'D_2', stack=False)
x.add_system('D1', FUNC, 'D_1', label_width=2)
x.add_system('D2', FUNC, 'D_2', stack=False)

try:
x.connect('D1', 'D2', r'\mathcal{R}(y_1)', 'foobar')
Expand All @@ -74,12 +74,12 @@ def test_options(self):
# Change `use_sfmath` to False to use computer modern
x = XDSM(use_sfmath=False)

x.add_system('opt', 'Optimization', r'\text{Optimizer}')
x.add_system('solver', 'MDA', r'\text{Newton}')
x.add_system('D1', 'Function', 'D_1', label_width=2)
x.add_system('D2', 'Function', 'D_2', stack=False)
x.add_system('F', 'Function', 'F', faded=True)
x.add_system('G', 'Function', 'G', spec_name="G_spec")
x.add_system('opt', OPT, r'\text{Optimizer}')
x.add_system('solver', SOLVER, r'\text{Newton}')
x.add_system('D1', FUNC, 'D_1', label_width=2)
x.add_system('D2', FUNC, 'D_2', stack=False)
x.add_system('F', FUNC, 'F', faded=True)
x.add_system('G', FUNC, 'G', spec_name="G_spec")

x.connect('opt', 'D1', 'x, z')
x.connect('opt', 'D2', 'z')
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_stacked_system(self):

x = XDSM()

x.add_system('test', 'Optimization', r'\text{test}', stack=True)
x.add_system('test', OPT, r'\text{test}', stack=True)

file_name = "stacked_test"
x.write(file_name)
Expand Down Expand Up @@ -251,12 +251,12 @@ def test_tikz_content(self):

x = XDSM(use_sfmath=True)

x.add_system('opt', 'Optimization', r'\text{Optimizer}')
x.add_system('solver', 'MDA', r'\text{Newton}')
x.add_system('D1', 'Function', 'D_1')
x.add_system('D2', 'Function', 'D_2')
x.add_system('F', 'Function', 'F')
x.add_system('G', 'Function', 'G')
x.add_system('opt', OPT, r'\text{Optimizer}')
x.add_system('solver', SOLVER, r'\text{Newton}')
x.add_system('D1', FUNC, 'D_1')
x.add_system('D2', FUNC, 'D_2')
x.add_system('F', FUNC, 'F')
x.add_system('G', FUNC, 'G')

x.connect('opt', 'D1', 'x, z')
x.connect('opt', 'D2', 'z')
Expand Down