Created
January 30, 2019 18:32
-
-
Save Kenneth-T-Moore/7f499bff2d52b174ae0de2dd37449b37 to your computer and use it in GitHub Desktop.
Shows bug in xdsm writer.
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
from __future__ import print_function, division, absolute_import | |
from openmdao.api import Problem, Group, IndepVarComp, ExplicitComponent | |
from openmdao.api import view_model | |
from openmdao.devtools.xdsm_viewer.xdsm_writer import write_xdsm | |
class TimeComp(ExplicitComponent): | |
def setup(self): | |
self.add_input('t_initial', val=0.) | |
self.add_input('t_duration', val=1.) | |
self.add_output('time', shape=(2, )) | |
def compute(self, inputs, outputs): | |
t_initial = inputs['t_initial'] | |
t_duration = inputs['t_duration'] | |
outputs['time'][0] = t_initial | |
outputs['time'][1] = t_initial + t_duration | |
class Phase(Group): | |
def setup(self): | |
super(Phase, self).setup() | |
indep = IndepVarComp() | |
for var in ['t_initial', 't_duration']: | |
indep.add_output(var, val=1.0) | |
self.add_subsystem('time_extents', indep, promotes_outputs=['*']) | |
time_comp = TimeComp() | |
self.add_subsystem('time', time_comp) | |
self.connect('t_initial', 'time.t_initial') | |
self.connect('t_duration', 'time.t_duration') | |
self.set_order(['time_extents', 'time']) | |
p = Problem() | |
orbit_phase = Phase() | |
p.model.add_subsystem('orbit_phase', orbit_phase) | |
systems_phase = Phase() | |
p.model.add_subsystem('systems_phase', systems_phase) | |
systems_phase = Phase() | |
p.model.add_subsystem('extra_phase', systems_phase) | |
p.setup(check=True) | |
p.run_model() | |
view_model(p) | |
write_xdsm(p, 'zzz', out_format='tex') | |
print('done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment