예제 #1
0
def main():  # pragma: no cover
    p = Problem()
    p.model = LaunchVehicleLinearTangentODE(num_nodes=1)
    p.setup()

    p.run_model()

    var_map = {
        'rho': r'$\rho$',
        'x': r'$x$',
        'y': r'$y$',
        'vx': r'$v_x$',
        'vy': r'$v_y$',
        'm': r'$m$',
        'mdot': r'$\dot{m}$',
        'Isp': r'$I_{sp}$',
        'thrust': r'$F_{T}$',
        'ydot': r'$\dot{y}$',
        'xdot': r'$\dot{x}$',
        'vxdot': r'$\dot{v}_x$',
        'vydot': r'$\dot{v}_y$',
        'theta': r'$\theta$',
        'a_ctrl': r'$a$',
        'b_ctrl': r'$b$',
        'time': r'$time$'
    }

    xdsm = XDSM()
    xdsm.from_openmdao_group(p.model, var_map=var_map)
    xdsm.write('ssto_linear_tangent_xdsm', build=True, cleanup=True)
예제 #2
0
def main():
    p = Problem()
    p.model = LaunchVehicleODE(num_nodes=1)
    p.setup()

    p.run_model()

    var_map = {
        'rho': r'$\rho$',
        'x': r'$x$',
        'y': r'$y$',
        'vx': r'$v_x$',
        'vy': r'$v_y$',
        'm': r'$m$',
        'mdot': r'$\dot{m}$',
        'Isp': r'$I_{sp}$',
        'thrust': r'$F_{T}$',
        'ydot': r'$\dot{y}$',
        'xdot': r'$\dot{x}$',
        'vxdot': r'$\dot{v}_x$',
        'vydot': r'$\dot{v}_y$',
        'theta': r'$\theta$'
    }

    xdsm = XDSM()
    xdsm.from_openmdao_group(p.model, var_map=var_map)
    xdsm.write('ssto_xdsm', build=True, cleanup=True)
예제 #3
0
    def test_stacked_system(self):

        x = XDSM()

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

        file_name = "stacked_test"
        x.write(file_name)

        tikz_file = file_name + ".tikz"
        with open(tikz_file, "r") as f:
            tikz = f.read()

        self.assertIn(r"\node [Optimization,stack]", tikz)
예제 #4
0
파일: test_xdsm.py 프로젝트: mdolab/pyXDSM
    def test_write_outdir(self):
        fname = "test"

        for abspath in [True, False]:
            subdir = tempfile.mkdtemp(dir=self.tempdir)
            outdir = subdir if abspath else os.path.basename(subdir)

            x = XDSM()
            x.add_system("x", FUNC, "x")
            x.write(fname, outdir=outdir)

            for ext in [".tex", ".tikz", ".pdf"]:
                self.assertTrue(
                    os.path.isfile(os.path.join(subdir, fname + ext)))

        # no files outside the subdirs
        self.assertFalse(
            any(os.path.isfile(fp) for fp in os.listdir(self.tempdir)))
예제 #5
0
    def test_options(self):

        filename = "xdsm_test_options"
        spec_dir = filename + "_specs"

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

        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")
        x.connect("opt", "F", "x, z")
        x.connect("solver", "D1", "y_2")
        x.connect("solver", "D2", "y_1")
        x.connect("D1", "solver", r"\mathcal{R}(y_1)")
        x.connect("solver", "F", "y_1, y_2")
        x.connect("D2", "solver", r"\mathcal{R}(y_2)")
        x.connect("solver", "G", "y_1, y_2")

        x.connect("F", "opt", "f")
        x.connect("G", "opt", "g")

        x.add_output("opt", "x^*, z^*", side="right")
        x.add_output("D1", "y_1^*", side="left", stack=True)
        x.add_output("D2", "y_2^*", side="left")
        x.add_output("F", "f^*", side="left")
        x.add_output("G", "g^*")
        x.write(filename)
        x.write_sys_specs(spec_dir)

        # Test if files where created
        self.assertTrue(os.path.isfile(filename + ".tikz"))
        self.assertTrue(os.path.isfile(filename + ".tex"))
        self.assertTrue(os.path.isdir(spec_dir))
        self.assertTrue(os.path.isfile(os.path.join(spec_dir, "F.json")))
        self.assertTrue(os.path.isfile(os.path.join(spec_dir, "G_spec.json")))
예제 #6
0
    def test_options(self):

        filename = 'xdsm_test_options'
        spec_dir = filename + '_specs'

        # 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', text_width=2.0)
        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.connect('opt', 'D1', 'x, z')
        x.connect('opt', 'D2', 'z')
        x.connect('opt', 'F', 'x, z')
        x.connect('solver', 'D1', 'y_2')
        x.connect('solver', 'D2', 'y_1')
        x.connect('D1', 'solver', r'\mathcal{R}(y_1)')
        x.connect('solver', 'F', 'y_1, y_2')
        x.connect('D2', 'solver', r'\mathcal{R}(y_2)')
        x.connect('solver', 'G', 'y_1, y_2')

        x.connect('F', 'opt', 'f')
        x.connect('G', 'opt', 'g')

        x.add_output('opt', 'x^*, z^*', side='right')
        x.add_output('D1', 'y_1^*', side='left', stack=True)
        x.add_output('D2', 'y_2^*', side='left')
        x.add_output('F', 'f^*', side='left')
        x.add_output('G', 'g^*')
        x.write(filename)
        x.write_sys_specs(spec_dir)

        # Test if files where created
        self.assertTrue(os.path.isfile(filename + '.tikz'))
        self.assertTrue(os.path.isfile(filename + '.tex'))
        self.assertTrue(os.path.isdir(spec_dir))
        self.assertTrue(os.path.isfile(os.path.join(spec_dir, 'F.json')))
        self.assertTrue(os.path.isfile(os.path.join(spec_dir, 'G_spec.json')))
from pyxdsm.XDSM import XDSM, OPT, SOLVER, FUNC, GROUP

x = XDSM()

x.add_system("top_opt", OPT, "Optimizer")
x.add_system("sub_opt", OPT, "Sub\_Optimizer")
x.add_system("comp_pitch_angles", FUNC, "ComputePitchAngle", stack=True)

x.connect('top_opt', 'comp_pitch_angles', 'drag\_modifier')
x.connect('comp_pitch_angles', 'top_opt', 'total\_power')
x.connect("sub_opt", "comp_pitch_angles", "pitch\_angle", stack=True)
x.connect("comp_pitch_angles", "sub_opt", "powers", stack=True)

x.add_input("comp_pitch_angles", "wind\_speeds", stack=True)

x.write("run_comp_pitch_angles_sub_opt")
예제 #8
0
    def test_tikz_content(self):
        # Check if TiKZ file was created.
        # Compare the content of the sample below and the newly created TiKZ file.

        tikz_txt = r"""
            
            %%% Preamble Requirements %%%
            % \usepackage{geometry}
            % \usepackage{amsfonts}
            % \usepackage{amsmath}
            % \usepackage{amssymb}
            % \usepackage{tikz}
            
            % Optional packages such as sfmath set through python interface
            % \usepackage{sfmath}
            
            % \usetikzlibrary{arrows,chains,positioning,scopes,shapes.geometric,shapes.misc,shadows}
            
            %%% End Preamble Requirements %%%
            
            \input{"D:/Documents/GitHub/mypyXDSM/pyXDSM/pyxdsm/diagram_styles"}
            \begin{tikzpicture}
            
            \matrix[MatrixSetup]{
            %Row 0
            \node [DataIO] (left_output_opt) {$x^*, z^*$};&
            \node [Optimization] (opt) {$\text{Optimizer}$};&
            &
            \node [DataInter] (opt-D1) {$x, z$};&
            \node [DataInter] (opt-D2) {$z$};&
            \node [DataInter] (opt-F) {$x, z$};&
            \\
            %Row 1
            &
            &
            \node [MDA] (solver) {$\text{Newton}$};&
            \node [DataInter] (solver-D1) {$y_2$};&
            \node [DataInter] (solver-D2) {$y_1$};&
            \node [DataInter] (solver-F) {$y_1, y_2$};&
            \node [DataInter] (solver-G) {$y_1, y_2$};\\
            %Row 2
            \node [DataIO] (left_output_D1) {$y_1^*$};&
            &
            \node [DataInter] (D1-solver) {$\mathcal{R}(y_1)$};&
            \node [Function] (D1) {$D_1$};&
            &
            &
            \\
            %Row 3
            \node [DataIO] (left_output_D2) {$y_2^*$};&
            &
            \node [DataInter] (D2-solver) {$\mathcal{R}(y_2)$};&
            &
            \node [Function] (D2) {$D_2$};&
            &
            \\
            %Row 4
            \node [DataIO] (left_output_F) {$f^*$};&
            \node [DataInter] (F-opt) {$f$};&
            &
            &
            &
            \node [Function] (F) {$F$};&
            \\
            %Row 5
            \node [DataIO] (left_output_G) {$g^*$};&
            \node [DataInter] (G-opt) {$g$};&
            &
            &
            &
            &
            \node [Function] (G) {$G$};\\
            %Row 6
            &
            &
            &
            &
            &
            &
            \\
            };
            
            % XDSM process chains
            
            
            \begin{pgfonlayer}{data}
            \path
            % Horizontal edges
            (opt) edge [DataLine] (opt-D1)
            (opt) edge [DataLine] (opt-D2)
            (opt) edge [DataLine] (opt-F)
            (solver) edge [DataLine] (solver-D1)
            (solver) edge [DataLine] (solver-D2)
            (D1) edge [DataLine] (D1-solver)
            (solver) edge [DataLine] (solver-F)
            (D2) edge [DataLine] (D2-solver)
            (solver) edge [DataLine] (solver-G)
            (F) edge [DataLine] (F-opt)
            (G) edge [DataLine] (G-opt)
            (opt) edge [DataLine] (left_output_opt)
            (D1) edge [DataLine] (left_output_D1)
            (D2) edge [DataLine] (left_output_D2)
            (F) edge [DataLine] (left_output_F)
            (G) edge [DataLine] (left_output_G)
            % Vertical edges
            (opt-D1) edge [DataLine] (D1)
            (opt-D2) edge [DataLine] (D2)
            (opt-F) edge [DataLine] (F)
            (solver-D1) edge [DataLine] (D1)
            (solver-D2) edge [DataLine] (D2)
            (D1-solver) edge [DataLine] (solver)
            (solver-F) edge [DataLine] (F)
            (D2-solver) edge [DataLine] (solver)
            (solver-G) edge [DataLine] (G)
            (F-opt) edge [DataLine] (opt)
            (G-opt) edge [DataLine] (opt);
            \end{pgfonlayer}
            
            \end{tikzpicture}"""

        def filter_lines(lns):
            # Empty lines are excluded.
            # Leading and trailing whitespaces are removed
            # Comments are removed.
            return [
                ln.strip() for ln in lns
                if ln.strip() and not ln.strip().startswith('%')
            ]

        filename = 'xdsm_test_tikz'

        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.connect('opt', 'D1', 'x, z')
        x.connect('opt', 'D2', 'z')
        x.connect('opt', 'F', 'x, z')
        x.connect('solver', 'D1', 'y_2')
        x.connect('solver', 'D2', 'y_1')
        x.connect('D1', 'solver', r'\mathcal{R}(y_1)')
        x.connect('solver', 'F', 'y_1, y_2')
        x.connect('D2', 'solver', r'\mathcal{R}(y_2)')
        x.connect('solver', 'G', 'y_1, y_2')

        x.connect('F', 'opt', 'f')
        x.connect('G', 'opt', 'g')

        x.add_output('opt', 'x^*, z^*', side='left')
        x.add_output('D1', 'y_1^*', side='left')
        x.add_output('D2', 'y_2^*', side='left')
        x.add_output('F', 'f^*', side='left')
        x.add_output('G', 'g^*', side='left')
        x.write(filename)

        # Check if file was created
        tikz_file = filename + '.tikz'

        self.assertTrue(os.path.isfile(tikz_file))

        tikz_lines = tikz_txt.split('\n')
        tikz_lines = filter_lines(tikz_lines)

        with open(tikz_file, "r") as f:
            lines = filter_lines(f.readlines())

        sample_no_match = []  # Sample text
        new_no_match = []  # New text

        for line1, line2 in zip(lines, tikz_lines):
            if line1 != line2:  # else everything is okay
                # This can be because of the different ordering of lines or because of an error.
                sample_no_match.append(line1)
                new_no_match.append(line2)

        # Sort both sets of suspicious lines
        sample_no_match.sort()
        new_no_match.sort()

        for line1, line2 in zip(sample_no_match, new_no_match):
            # Now the lines should match, if only the ordering was different
            self.assertEqual(line1, line2)

        # To be sure, check the length, otherwise a missing last line could get unnoticed because of using zip
        self.assertEqual(len(lines), len(tikz_lines))
예제 #9
0
x.connect('prop_comp', 'e_comp', r'P_{prop}, N')

x.connect('solver', 'aero_comp', r'\alpha')  # , V_{\infty}
x.connect('solver', 'flight_dynamics', r'\alpha')

x.connect('aero_comp', 'flight_dynamics', r'L_{wing}')
x.connect('aero_comp', 'EOM_comp', r'D_{wing}')

x.connect('flight_dynamics', 'balance', r'\alpha_{LHS}, \alpha_{RHS}')

x.connect('balance', 'solver', r'\mathcal{R} \alpha')

x.connect('engine_comp', 'DYMOS', r'w_{fuel}^*')

# x.connect('e_comp', 'cool_comp', r'Q_{heat 1,2,3...}')
x.connect('e_comp', 'engine_comp', r'P_{shaft}, N')

# x.connect('cool_comp', 'DYMOS', r'T_{fins}^*')
# x.connect('cool_comp', 'drag_comp', 'D_{cool}')

# x.connect('drag_comp', 'EOM_comp', r'D_{tot}')

x.connect('EOM_comp', 'DYMOS', r'h^*, r^*')

x.add_output('DYMOS', r'r,h', side='right')
x.add_output('prop_comp', r'P_{prop,max}', side='right')
x.add_output('engine_comp', r'T_4', side='right')
# x.add_output('cool_comp', r'T_{fins}', side='right')

x.write('Mission_XDSM')
예제 #10
0
comp = 'Analysis'
group = 'Metamodel'
func = 'Function'


x = XDSM()
x.add_system('d1', comp, r'\TwolineComponent{10em}{Discipline 1}{$y_1 = z_1^2 + z_2 + x_1 - 0.2y_2$}')
x.add_system('d2', comp, r'\TwolineComponent{8em}{Discipline 2}{$y_2 = \sqrt{y_1} + z_1 + z_2$}')

x.add_system('f', func, r'\TwolineComponent{10em}{Objective}{$f = x^2 + z_1 + y_1 + e^{-y_2}$}')
x.add_system('g1', func, r'\TwolineComponent{7em}{Constraint 1}{$g1 = 3.16-y_1 $}')
x.add_system('g2', func, r'\TwolineComponent{7em}{Constraint 2}{$g_2 = y_2 - 24.0$}')

x.connect('d1', 'd2', r'$y_1$')
x.connect('d1', 'f', r'$y_1$')
x.connect('d1', 'g1', r'$y_1$')

x.connect('d2', 'd1', r'$y_2$')
x.connect('d2', 'f', r'$y_2$')
x.connect('d2', 'g2', r'$y_2$')

x.add_input('d1', r'$x, z_1, z_2$')
x.add_input('d2', r'$z_1, z_2$')
x.add_input('f', r'$x, z_1$')

x.add_output('f', r'$f$', side='right')
x.add_output('g1', r'$g_1$', side='right')
x.add_output('g2', r'$g_2$', side='right')

x.write('sellar_xdsm')
예제 #11
0
x.add_input('e_comp', r'\bar{X}_{electrical}')
x.add_input('engine_comp', r'\bar{X}_{turboshaft}')
x.add_input('aero_comp', r'\bar{X}_{wing}')
x.add_input('aircraft_mass', [r'\bar{X}_{aircraft}', r'm_{fuel}'])

x.add_output('e_comp', r'\bar{Y}_{electrical}', side='right')
x.add_output('engine_comp', r'\bar{Y}_{turboshaft}', side='right')
x.add_output('aero_comp', [r'\bar{Y}_{wing}'], side='right')
x.add_output('aircraft_mass', [r'm_{total}'], side='right')

x.connect('eng_ambient', 'prop_comp', [r'FC'])
x.connect('eng_ambient', 'engine_comp', [r'FC'])
x.connect('thrust_comp', 'prop_comp', [r'T'])
x.connect('prop_comp', 'e_comp', [r'P_{propeller}'])
x.connect('e_comp', 'engine_comp', [r'P_{generator}'])

x.connect('prop_comp', 'aircraft_mass', [r'm_{propeller}'])
x.connect('e_comp', 'aircraft_mass', [r'm_{electrical}'])
x.connect('engine_comp', 'aircraft_mass', [r'm_{turboshaft}'])
x.connect('wing_ambient', 'aero_comp', [r'FC'])
x.connect('aero_comp', 'aircraft_mass', [r'm_{wing}'])

x.connect('solver', 'thrust_comp', [r'm_{total}^*'])
x.connect('solver', 'aero_comp', [r'm_{total}^*'])
x.connect('solver', 'balance', [r'm_{total}^*'])
x.connect('aircraft_mass', 'balance', [r'm_{total}'])

x.connect('balance', 'solver', [r'm_{total} = m_{total}^*'])

x.write('Design_XDSM')
예제 #12
0
파일: mdf.py 프로젝트: youkas/pyXDSM
func = 'Function'

x = XDSM()

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

x.connect('opt', 'D1', r'x, z')
x.connect('opt', 'D2', r'z')
x.connect('opt', 'F', r'x, z')
x.connect('solver', 'D1', r'y_2')
x.connect('solver', 'D2', r'y_1')
x.connect('D1', 'solver', r'\mathcal{R}(y_1)')
x.connect('solver', 'F', r'y_1, y_2')
x.connect('D2', 'solver', r'\mathcal{R}(y_2)')
x.connect('solver', 'G', r'y_1, y_2')

x.connect('F', 'opt', r'f')
x.connect('G', 'opt', r'g')

x.add_output('opt', r'x^*, z^*', side='left')
x.add_output('D1', r'y_1^*', side='left')
x.add_output('D2', r'y_2^*', side='left')
x.add_output('F', r'f^*', side='left')
x.add_output('G', r'g^*', side='left')
x.write('mdf')
# x.connect('CAMRAD_od', 'CAMRAD_opt', [r'\text{Rotor}',r'\text{Performance Data}'])


x.connect('NDARC_opt', 'NDARC', [r'\text{Aircraft Design}',r'\text{Variables}'])
x.connect('NDARC', 'NDARC_opt', [r'\text{Aircraft Design and}',r'\text{Performance Data}'])
# x.connect('NDARC_opt', 'NDARC_des', [r'\text{Aircraft Design}',r'\text{Variables}'])
# x.connect('NDARC_des', 'NDARC_od', [r'\text{Aircraft Design}',r'\text{Characteristics}'])
# x.connect('NDARC_des', 'NDARC_opt', [r'\text{Aircraft}',r'\text{Design Data}'])
# x.connect('NDARC_od', 'NDARC_opt', [r'\text{Mission}',r'\text{Performance Data}'])



x.connect('NPSS', 'NDARC', [r'\text{Engine}',r'\text{Performance Data}'])
x.connect('CAMRAD', 'NDARC', [r'\text{Rotor}',r'\text{Performance Data}'])


x.connect('opt', 'NPSS', [r'\text{Engine Design}',r'\text{Variables}'])
x.connect('opt', 'CAMRAD', [r'\text{Rotor Design}',r'\text{Variables}'])
x.connect('opt', 'NDARC', [r'\text{Aircraft Design}',r'\text{Variables}'])
x.connect('NDARC', 'opt', [r'\text{Mission}',r'\text{Performance Data}'])


# x.connect('opt', 'des', [r'\text{Discipline}',r'\text{Design Variables}'])
# x.connect('opt', 'miss', [r'\text{Optimal Control}',r'\text{Variables}'])
# x.connect('des', 'miss', [r'\text{Discipline Design}',r'\text{Characteristics}'])

# x.connect('des', 'opt', [r'\text{Design Constraints}'])
# x.connect('miss', 'opt', [r'\text{Objective Function,}',r'\text{Operational Constraints}'])

x.write('Traditional_XDSM')
예제 #14
0
#
opt = 'Optimization'
solver = 'MDA'
comp = 'Analysis'
group = 'Metamodel'
func = 'Function'

x = XDSM()

x.add_system('EOM', comp, r'EOM')
x.add_system('nav', comp, r'nav')
x.add_system('threat', func, r'threat')

# x.connect('opt', 'EOM', r'x, z')
# x.connect('opt', 'nav', r'z')
# x.connect('opt', 'F', r'x, z')
# x.connect('solver', 'EOM', r'y_2')
# x.connect('solver', 'nav', r'y_1')
x.connect('nav', 'threat', r'r_{ship}')
# x.connect('solver', 'F', r'y_1, y_2')
# x.connect('solver', 'G', r'y_1, y_2')

x.add_input('EOM', r'v, \phi')
x.add_input('nav', r'x, y')
x.add_input('threat', r'time')

# x.add_output('opt', r'x^*, z^*', side='left')
x.add_output('EOM', r'\dot{x}, \dot{y}', side='right')
x.add_output('threat', r'range_{sub}', side='right')
x.write('donner_sub_ode_xdsm')
예제 #15
0
from pyxdsm.XDSM import XDSM, OPT, SOLVER, FUNC, GROUP

x = XDSM()

x.add_system("prob1_opt", OPT, "Optimize\_Prob1")
x.add_system("d_airfoil", FUNC, "DesignAirfoil", stack=True)
x.add_system("comp_mod_power", FUNC, "ComputeModifiedPower")

x.connect("prob1_opt", "d_airfoil", "airfoil\_design")
x.connect("comp_mod_power", "prob1_opt", "modified\_power")
x.connect("d_airfoil", "comp_mod_power", "aerodynamic\_eff", stack=True)
x.connect("d_airfoil", "comp_mod_power2", "aerodynamic\_eff*", stack=True)

x.add_input("d_airfoil", "wind\_speeds", stack=True)

x.add_system("prob2_opt", OPT, "Optimize\_Prob2")
x.add_system("comp_pitch_angles", GROUP, "ComputeOptPitchAngle", stack=True)
x.add_system("comp_mod_power2", FUNC, "ComputeModifiedPower")

x.connect("prob2_opt", "comp_pitch_angles", "drag\_modifier")
x.connect("comp_mod_power2", "prob2_opt", "powers, modified\_power")
x.connect("comp_pitch_angles", "comp_mod_power2", "powers*", stack=True)
x.connect("comp_pitch_angles", "comp_mod_power", "powers**", stack=True)

x.add_input("comp_pitch_angles", "wind\_speeds", stack=True)

x.write("run_sequential_top_level")
예제 #16
0
from pyxdsm.XDSM import XDSM, OPT, SOLVER, FUNC, GROUP

x = XDSM()

# Systems
x.add_system("top_opt", OPT, "Optimizer")
x.add_system("comp_pitch_angles", GROUP, "ComputeOptPitchAngle", stack=True)
x.add_system("d_airfoil", FUNC, "DesignAirfoil", stack=True)
x.add_system("comp_mod_power", FUNC, "ComputeModifiedPower")

x.connect("d_airfoil", "comp_mod_power", "aerodynamic\_eff", stack=True)
x.connect("comp_pitch_angles", "comp_mod_power", "powers*", stack=True)
x.connect("top_opt", "d_airfoil", "airfoil\_design")
x.connect("top_opt", "comp_pitch_angles", "drag\_modifier")
x.connect("comp_mod_power", "top_opt", "modified\_power")

x.add_input("d_airfoil", "wind\_speeds", stack=True)
x.add_input("comp_pitch_angles", "wind\_speeds", stack=True)

x.write("run_MDF_top_level")
예제 #17
0
ecomp = 'Analysis'
icomp = 'ImplicitAnalysis'


x = XDSM()

x.add_system('moi', ecomp, [r'\text{1) moment of inertia}',
                            r'I_i = \frac{1}{4} b * h_i^3'])

x.add_system('local_K', ecomp, [r'\text{2) local stiffness:}',
                                r'\left[K_\text{local}\right]_i'])

x.add_system('global_K', icomp, [r'\text{3) FEM:}',
                                 r'\left[K_\text{global}\right] u = f', 
                                 r'u = [d, \theta]'])

x.add_system('compliance', ecomp, [r'\text{4) compliance:}', 
                                   r'c = f \cdot d'])

x.add_system('volume', ecomp, [r'\text{5) volume:}', 
                               r'\sum h_i b L_i'])

x.connect('moi', 'local_K', 'I')
x.connect('local_K', 'global_K', r'K_\text{local}')
x.connect('global_K', 'compliance', r'd')

x.add_input('volume', 'h')
x.add_input('moi', 'h')

x.write('fem_xdsm')
예제 #18
0
x.connect("subopt", "MM", "z_2")
x.connect("opt", "G2", "z")
x.connect("opt", "F", "x, z")
x.connect("opt", "F", "y_1, y_2")

# you can also stack variables
x.connect("opt", "H", "y_1, y_2", stack=True)

x.connect("D1", "opt", r"\mathcal{R}(y_1)")
x.connect("D2", "opt", r"\mathcal{R}(y_2)")

x.connect("F", "opt", "f")
x.connect("H", "opt", "h", stack=True)

# can specify inputs to represent external information coming into the XDSM
x.add_input("D1", "P_1")
x.add_input("D2", "P_2")
x.add_input("opt", r"x_0", stack=True)

# can put outputs on the left or right sides
x.add_output("opt", r"x^*, z^*", side="right")
x.add_output("D1", r"y_1^*", side="left")
x.add_output("D2", r"y_2^*", side="left")
x.add_output("F", r"f^*", side="right")
x.add_output("H", r"h^*", side="right")
x.add_output("opt", r"y^*", side="left")

x.add_process(["output_opt", "opt", "left_output_opt"])

x.write("kitchen_sink", cleanup=False)
x.write_sys_specs("sink_specs")
예제 #19
0
x.add_system('drive', FUNC, r'\text{DrivetrainSE}')
x.add_system('tower', FUNC, r'\text{TowerSE}')
x.add_system('CSM', FUNC, r'\text{NREL CSM}')
x.add_system('BOS', FUNC, r'\text{LandBOSSE}')
x.add_system('costs', FUNC, r'\text{Plant\_FinanceSE}')

# Feed-forward connections; from, to, name for connections
x.connect('opt', 'rotor', r'\text{Blade design variables}')
x.connect('rotor', 'drive', r'\text{Performance, loads}')
x.connect('rotor', 'BOS', r'\text{Rotor and blade mass}')
x.connect('drive', 'tower', (r'\text{Forces, moments,}', r'\text{mass properties}'))
x.connect('tower', 'CSM', r'\text{Tower mass}')
x.connect('drive', 'CSM', r'\text{Drivetrain mass}')
x.connect('rotor', 'CSM', r'\text{Rotor mass}')
x.connect('CSM', 'BOS', r'\text{Turbine mass and costs}')
x.connect('BOS', 'costs', r'\text{BOS costs}')

# Feed-backward connections
x.connect('drive', 'rotor', r'\text{Efficiency}')
x.connect('costs', 'opt', r'\text{Cost and profit values}')
x.connect('tower', 'opt', (r'\text{Tower stress and}', r'\text{buckling values}'))
x.connect('rotor', 'opt', (r'\text{Blade tip deflection,}', r'\text{blade strains}'))

# Outputs on the left-hand side
# x.add_output('opt', 'x^*, z^*', side='left')

x.add_process(["opt", "rotor", "drive", "tower", "CSM", "BOS", "costs", "opt"])

# Compile latex and write pdf
x.write('xdsm_wisdem')
예제 #20
0
파일: idf.py 프로젝트: bouhlelma/pyXDSM
x.add_system('G', func, r'$G$', stack=True)

x.add_process(['opt', 'D1', 'D2', 'F', 'G', 'opt'], arrow=True)

x.connect('opt', 'D1', r'$x, z, y_2$')
x.connect('opt', 'D2', r'$z, y_1$')
x.connect('opt', 'F', r'$x, z$')
x.connect('opt', 'F', r'$y_1, y_2$')

# you can also stack variables
x.connect('opt', 'G', r'$y_1, y_2$', stack=True)

x.connect('D1', 'opt', r'$\mathcal{R}(y_1)$')
x.connect('D2', 'opt', r'$\mathcal{R}(y_2)$')

x.connect('F', 'opt', r'$f$')
x.connect('G', 'opt', r'$g$', stack=True)

# can specify inputs to represent external information coming into the XDSM
x.add_input('D1', r'$P_1$')
x.add_input('D2', r'$P_2$')

# can put outputs on the left or right sides
x.add_output('opt', r'$x^*, z^*$', side='right')
x.add_output('D1', r'$y_1^*$', side='left')
x.add_output('D2', r'$y_2^*$', side='left')
x.add_output('F', r'$f^*$', side='right')
x.add_output('G', r'$g^*$', side='right')

x.write('idf', cleanup=False)
예제 #21
0
    def test_tikz_content(self):
        # Check if TiKZ file was created.
        # Compare the content of the sample below and the newly created TiKZ file.

        sample_txt = r"""

            %%% Preamble Requirements %%%
            % \usepackage{geometry}
            % \usepackage{amsfonts}
            % \usepackage{amsmath}
            % \usepackage{amssymb}
            % \usepackage{tikz}

            % Optional packages such as sfmath set through python interface
            % \usepackage{sfmath}

            % \usetikzlibrary{arrows,chains,positioning,scopes,shapes.geometric,shapes.misc,shadows}

            %%% End Preamble Requirements %%%

            \input{"path/to/diagram_styles"}
            \begin{tikzpicture}

            \matrix[MatrixSetup]{
            %Row 0
            \node [DataIO] (left_output_opt) {$x^*, z^*$};&
            \node [Optimization] (opt) {$\text{Optimizer}$};&
            &
            \node [DataInter] (opt-D1) {$x, z$};&
            \node [DataInter] (opt-D2) {$z$};&
            \node [DataInter] (opt-F) {$x, z$};&
            \\
            %Row 1
            &
            &
            \node [MDA] (solver) {$\text{Newton}$};&
            \node [DataInter] (solver-D1) {$y_2$};&
            \node [DataInter] (solver-D2) {$y_1$};&
            \node [DataInter] (solver-F) {$y_1, y_2$};&
            \node [DataInter] (solver-G) {$y_1, y_2$};\\
            %Row 2
            \node [DataIO] (left_output_D1) {$y_1^*$};&
            &
            \node [DataInter] (D1-solver) {$\mathcal{R}(y_1)$};&
            \node [Function] (D1) {$D_1$};&
            &
            &
            \\
            %Row 3
            \node [DataIO] (left_output_D2) {$y_2^*$};&
            &
            \node [DataInter] (D2-solver) {$\mathcal{R}(y_2)$};&
            &
            \node [Function] (D2) {$D_2$};&
            &
            \\
            %Row 4
            \node [DataIO] (left_output_F) {$f^*$};&
            \node [DataInter] (F-opt) {$f$};&
            &
            &
            &
            \node [Function] (F) {$F$};&
            \\
            %Row 5
            \node [DataIO] (left_output_G) {$g^*$};&
            \node [DataInter] (G-opt) {$g$};&
            &
            &
            &
            &
            \node [Function] (G) {$G$};\\
            %Row 6
            &
            &
            &
            &
            &
            &
            \\
            };

            % XDSM process chains


            \begin{pgfonlayer}{data}
            \path
            % Horizontal edges
            (opt) edge [DataLine] (opt-D1)
            (opt) edge [DataLine] (opt-D2)
            (opt) edge [DataLine] (opt-F)
            (solver) edge [DataLine] (solver-D1)
            (solver) edge [DataLine] (solver-D2)
            (D1) edge [DataLine] (D1-solver)
            (solver) edge [DataLine] (solver-F)
            (D2) edge [DataLine] (D2-solver)
            (solver) edge [DataLine] (solver-G)
            (F) edge [DataLine] (F-opt)
            (G) edge [DataLine] (G-opt)
            (opt) edge [DataLine] (left_output_opt)
            (D1) edge [DataLine] (left_output_D1)
            (D2) edge [DataLine] (left_output_D2)
            (F) edge [DataLine] (left_output_F)
            (G) edge [DataLine] (left_output_G)
            % Vertical edges
            (opt-D1) edge [DataLine] (D1)
            (opt-D2) edge [DataLine] (D2)
            (opt-F) edge [DataLine] (F)
            (solver-D1) edge [DataLine] (D1)
            (solver-D2) edge [DataLine] (D2)
            (D1-solver) edge [DataLine] (solver)
            (solver-F) edge [DataLine] (F)
            (D2-solver) edge [DataLine] (solver)
            (solver-G) edge [DataLine] (G)
            (F-opt) edge [DataLine] (opt)
            (G-opt) edge [DataLine] (opt);
            \end{pgfonlayer}

            \end{tikzpicture}"""

        filename = "xdsm_test_tikz"

        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.connect("opt", "D1", "x, z")
        x.connect("opt", "D2", "z")
        x.connect("opt", "F", "x, z")
        x.connect("solver", "D1", "y_2")
        x.connect("solver", "D2", "y_1")
        x.connect("D1", "solver", r"\mathcal{R}(y_1)")
        x.connect("solver", "F", "y_1, y_2")
        x.connect("D2", "solver", r"\mathcal{R}(y_2)")
        x.connect("solver", "G", "y_1, y_2")

        x.connect("F", "opt", "f")
        x.connect("G", "opt", "g")

        x.add_output("opt", "x^*, z^*", side="left")
        x.add_output("D1", "y_1^*", side="left")
        x.add_output("D2", "y_2^*", side="left")
        x.add_output("F", "f^*", side="left")
        x.add_output("G", "g^*", side="left")
        x.write(filename)

        # Check if file was created
        tikz_file = filename + ".tikz"

        self.assertTrue(os.path.isfile(tikz_file))

        sample_lines = sample_txt.split("\n")
        sample_lines = filter_lines(sample_lines)

        with open(tikz_file, "r") as f:
            new_lines = filter_lines(f.readlines())

        sample_no_match = []  # Sample text
        new_no_match = []  # New text

        for new_line, sample_line in zip(new_lines, sample_lines):
            if new_line.startswith(r"\input{"):
                continue
            if new_line != sample_line:  # else everything is okay
                # This can be because of the different ordering of lines or because of an error.
                sample_no_match.append(new_line)
                new_no_match.append(sample_line)

        # Sort both sets of suspicious lines
        sample_no_match.sort()
        new_no_match.sort()

        for sample_line, new_line in zip(sample_no_match, new_no_match):
            # Now the lines should match, if only the ordering was different
            self.assertEqual(new_line, sample_line)

        # To be sure, check the length, otherwise a missing last line could get unnoticed because of using zip
        self.assertEqual(len(new_lines), len(sample_lines))
예제 #22
0
x.add_process(['opt', 'D1', 'D2', 'F', 'G', 'opt'], arrow=True)

x.connect('opt', 'D1', r'x, z, y_2')
x.connect('opt', 'D2', r'z, y_1')
x.connect('opt', 'D3', r'z, y_1')
x.connect('opt', 'F', r'x, z')
x.connect('opt', 'F', r'y_1, y_2')

# you can also stack variables
x.connect('opt', 'G', r'y_1, y_2', stack=True)

x.connect('D1', 'opt', r'\mathcal{R}(y_1)')
x.connect('D2', 'opt', r'\mathcal{R}(y_2)')

x.connect('F', 'opt', r'f')
x.connect('G', 'opt', r'g', stack=True)

# can specify inputs to represent external information coming into the XDSM
x.add_input('D1', r'P_1')
x.add_input('D2', r'P_2')

# can put outputs on the left or right sides
x.add_output('opt', r'x^*, z^*', side='right')
x.add_output('D1', r'y_1^*', side='left')
x.add_output('D2', r'y_2^*', side='left')
x.add_output('F', r'f^*', side='right')
x.add_output('G', r'g^*', side='right')

x.write('kitchen_sink', cleanup=False)
예제 #23
0
x.connect('e_solver', 'battery', '')

# Connect Zappy outputs to subsystems
x.connect('e_comp', 'battery', 'I_{batt}')
x.add_output('e_comp', 'Q_{lines}', side='right') # output to thermal phase
# x.add_output('e_comp', r'C_{max}', side='right')

# Connect Battery outputs to subsystems
x.add_input('battery', ['n_{series}','n_{parallel}','Q_{max}'])
x.connect('battery', 'DYMOS', ['dXdt:SOC', 'dXdt:V_{thev}','dXdt:PCM_{sat}'])
x.connect('battery', 'e_comp', 'V_{batt,actual}')
x.connect('battery', 'e_solver', '')
x.connect('battery', 'TMS', ['T_{cold}'])
x.add_output('battery', ['T_{batt}'], side='right')

x.add_input('TMS', ['A_{cold}'])
x.connect('TMS','battery',['Q_{rej}'])


# # Connect Thermal outputs to subsystems
# x.add_input('tms_comp', [r'W_{coolant}', 'mass_{res,coolant}',r'mass_{motor}',r'mass_{battery}',r'width_{ACC}',r'height_{ACCc}',r'height_{ACCa}',r'Area_{throat}'])
# x.connect('tms_comp', 'DYMOS', ['dXdt:T_{coolant}','dXdt:T_{batt}','dXdt:T_{motor}'])
# x.add_output('tms_comp', 'Power_{TMS}', side='right')
# x.add_output('tms_comp', r'T_{coolant}', side='right')
# #x.connect('tms_comp', 'drag_comp', 'D_{cool}')

x.write('ODE_XDSM')

x.write_sys_specs('ODE_specs')

from pyxdsm.XDSM import XDSM

#
opt = 'Optimization'
solver = 'MDA'
comp = 'ImplicitAnalysis'
group = 'Metamodel'
func = 'Function'

x = XDSM()

x.add_system('dv', func, (r'x=1', r'\text{Design Variable}'))
x.add_system('d1', func, (r'y_1=y_2^2', r'\text{Discipline 1}'))
x.add_system('d2', comp, (r'\exp(-y_1 y_2) - x y_2', r'\text{Discipline 2}'))
x.add_system('f', func, (r'y_1^2 - y_2 + 3', r'\text{Objective}'))

x.connect('dv', 'd2', 'x')
x.connect('d1', 'd2', 'y_1')
x.connect('d2', 'd1', 'y_1')
x.connect('d1', 'f', 'y_1')
x.connect('d2', 'f', 'y_2')

x.write('simple_example_xdsm')
예제 #25
0
x.connect('O', 'opt', r'f_{0}')
x.connect('I', 'opt', r'c_{0}')
x.connect('C', 'opt', r'c_{c}')

x.add_input(
    'opt',
    r'S_{e}^{0},b_{e}^{0},\lambda_{e}^{0},\Lambda_{LE}^{0},CST_{root}^{0},CST_{tip}^{0},\phi_{t}^{0},loc_{engines}^{0},\hat{MTOW}^{0},\hat{W_{f}}^{0},\hat{loading}^{0},\hat{L/D}{^0}'
)

x.add_output(
    'opt',
    r'S_{e}^{*},b_{e}^{*},\lambda_{e}^{*},\Lambda_{LE}^{*},CST_{root}^{*},CST_{tip}^{*},\phi_{t}^{*},loc_{engines}^{*},\hat{MTOW}^{*},\hat{W_{f}}^{*},\hat{loading}^{*},\hat{L/D}^{*}',
    side='left')
x.add_output('A', r'L/D^{*}', side='left')
x.add_output('L', r'loading^{*}', side='left')
x.add_output('S', r'MTOW^{*}', side='left')
x.add_output('P', r'W_{f}^{*}', side='left')
#x.add_output('F', r'f^*', side='left')
#x.add_output('G', r'g^*', side='left')

x.add_process(['opt', 'A', 'C', 'opt'])
x.add_process(['opt', 'L', 'C', 'opt'])
x.add_process(['opt', 'S', 'C', 'opt'])
x.add_process(['opt', 'S', 'I', 'opt'])
x.add_process(['opt', 'P', 'C', 'opt'])
x.add_process(['opt', 'P', 'I', 'opt'])
x.add_process(['opt', 'P', 'O', 'opt'])

x.write('mdf4')
x.add_system("solver", SOLVER, [r"\text{MDA}"])
x.add_system("D1", IFUNC, ["Aerodynamic", "F=CA_fv^2"])
x.add_system("D2", IFUNC, ["Structural", "k\\theta=\\frac{1}{2}\\rho C_D"])
x.add_system("G", FUNC, ["Constraint1", "g=F-F_{max}"])
x.add_system("H", FUNC, ["Constraint2", "h=lw-A"])
x.add_system("OBJ", FUNC, ["Objective", "f=(\\theta-{\\hat \\theta})^2"])

x.add_input("opt", "l^{(0)},w^{(0)}")

x.connect("opt", "D1", "l,w")
x.connect("opt", "D2", "l")
x.connect("opt", "H", "l,w")

x.connect("solver", "G", "F")
x.connect("solver", "OBJ", "\\theta")

x.connect("D1", "solver", "F")
x.connect("D2", "solver", "\\theta")
x.connect("OBJ", "opt", "f")
x.connect("G", "opt", "g")
x.connect("H", "opt", "h")

x.add_output("opt", "l^*,w^*", side="left")
x.add_output("D1", "F^*", side="left")
x.add_output("D2", "\\theta^*", side="left")
x.add_output("G", "g^*", side="left")
x.add_output("H", "h^*", side="left")
x.add_output("OBJ", "f^*", side="left")

x.write("xdsm_airflow_sensor_mdf")
예제 #27
0
from pyxdsm.XDSM import XDSM

# Part-1 : Generate XDSM class object
x = XDSM()

# Part-2 :  Define shape styles used in XDSM
DataIO = 'DataIO'
comp2 = 'ImplicitFunction'
group = 'Metamodel'
func = 'Function'
OPT = "Optimization"

#  Part-3 : create system
x.add_system('opt', OPT, r'\text{Optimizer}')
x.add_system('D1', func, (r'Discipline1', r'y_1 = y_2^2'))
x.add_system('D2', comp2, (r'Discipline2', r'exp(-y_1y_2)-xy_2 = 0 '))
x.add_system('F', func, (r'\text{Model Output}', r'f= y_1^2 - y_2 +3'))

#  Part-4 : Connect systems with variables
x.connect('opt', 'D2', 'x')
x.connect('D1', 'D2', r'y_1')
x.connect('D1', 'F', r'y_1')
x.connect('D2', 'F', r'y_2')
x.connect('D2', 'D1', r'y_2')
x.connect('F', 'opt', r'f')

x.add_output('opt', 'x^*', side='left')

#  Part-5 : write Sellar.tex, Sellar.tikz, Sellar.pdf files
x.write('Sellar')
예제 #28
0
x.connect('Optimizer', 'Geometry', ['extra', 'ratio', 'cell_d'])

# Geometry
# x.add_input('pack_design', ['L_{pack}', 'W_{pack}','L_{cell}', 'W_{cell}', 'H_{cell}',
#             'mass_{cell}','voltage_{low,cell}','voltage_{nom,cell}','dischargeRate_{cell}','Q_{max}','V_{batt}'])
x.connect('Geometry', 'Thermal', ['dimensions'])
x.connect('Geometry', 'Structural', 'dimensions')
x.connect('Geometry', 'Optimizer', 'mass')
# x.add_output('pack_design', ['n_{series}','n_{parallel}'], side='right')

# Thermal
x.connect('Thermal', 'Optimizer', 'temp')

# Geometry
# x.add_input('heat_pipe', ['d_{init}','rho_{HP}', 'L_{pack}'])
x.connect('Geometry', 'Structural', 'mesh')
x.connect('Geometry', 'Thermal', 'mesh')
x.connect('Geometry', 'Sweep', r'\frac{Wh}{kg}')

# Structural
x.add_input('Structural', 'Loads')
x.connect('Structural', 'Optimizer', 'stress')

# Sweep
x.connect('Sweep', 'Geometry', 'properties')
x.connect('Sweep', 'Thermal', 'energy')
# x.add_output('Struct', ['mass_{battery}'], side='right')

x.write('baseline_XDSM')

# x.write_sys_specs('Design_specs')
예제 #29
0
FUNC = "Function"
GROUP = "Group"
IGROUP = "ImplicitGroup"
METAMODEL = "Metamodel"
DataIO = "DataIO"
DataInter = "DataInter"

x.add_system("D1", FUNC, ["Discipline1", "y_1=z_1^2+z_2+x_1-0.2y_2"])
x.add_system("D2", FUNC, ["Discipline2", "y_2=sqrt(y_1)+z_1+z_2"])
x.add_system("OBJ", FUNC, ["Objective", "f=x^2+z_2+y_1+exp(-y_2)"])
x.add_system("G1", FUNC, ["Constraint1", "g_1=3.16-y_1"])
x.add_system("G2", FUNC, ["Constraint2", "g_2=y_2-24"])

x.add_input("D1", "x,z_1,z_2")
x.add_input("D2", "z_1,z_2")
x.add_input("OBJ", "x,z_2")

x.connect("D1", "D2", "y_1")
x.connect("D1", "OBJ", "y_1")
x.connect("D1", "G1", "y_1")
x.connect("D2", "OBJ", "y_2")
x.connect("D2", "G2", "y_2")

x.connect("D2", "D1", "y_2")

x.add_output("OBJ", "f", side="right")
x.add_output("G1", "g_1", side="right")
x.add_output("G2", "g_2", side="right")

x.write("xdsm_sellar")
예제 #30
0
GROUP = "Group"
IGROUP = "ImplicitGroup"
METAMODEL = "Metamodel"

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")
x.connect("opt", "F", "x, z")
x.connect("solver", "D1", "y_2")
x.connect("solver", "D2", "y_1")
x.connect("D1", "solver", r"\mathcal{R}(y_1)")
x.connect("solver", "F", "y_1, y_2")
x.connect("D2", "solver", r"\mathcal{R}(y_2)")
x.connect("solver", "G", "y_1, y_2")

x.connect("F", "opt", "f")
x.connect("G", "opt", "g")

x.add_output("opt", "x^*, z^*", side="left")
x.add_output("D1", "y_1^*", side="left")
x.add_output("D2", "y_2^*", side="left")
x.add_output("F", "f^*", side="left")
x.add_output("G", "g^*", side="left")
x.write("mdf")
예제 #31
0
from pyxdsm.XDSM import XDSM

#
opt = 'Optimization'
solver = 'MDA'
comp = 'ImplicitAnalysis'
group = 'Metamodel'
func = 'Function'

x = XDSM()

x.add_system('dv', func, (r'x=1', r'\text{Design Variable}'))
x.add_system('d1', func, (r'y_1=y_2^2', r'\text{Discipline 1}'))
x.add_system('d2', comp, (r'\exp(-y_1 y_2) - x y_2', r'\text{Discipline 2}'))
x.add_system('f', func, (r'y_1^2 - y_2 + 3', r'\text{Objective}'))


x.connect('dv', 'd2', 'x')
x.connect('d1', 'd2', 'y_1')
x.connect('d2', 'd1', 'y_1')
x.connect('d1', 'f', 'y_1')
x.connect('d2', 'f', 'y_2')

x.write('simple_example_xdsm')