# print "CWD:",os.getcwd() # top.run() # print "run done";sys.stdout.flush() # print driver.case_outputs.C4.outval # # for i,val in enumerate(invals): # self.assertEqual(driver.case_outputs.C4.outval[i], # val+3) # class SerialTests(TestCase): def test_fan_out_in_noflats_serial(self): num_inputs = 6 top, expected = model_par3_setup(num_inputs, mpi=False) driver = top.driver top.run() for name, expval in expected.items(): val = driver.case_outputs.get(name) for v1, v2 in zip(expval, val): if isinstance(v1, np.ndarray): self.assertTrue(all(v1 == v2)) else: self.assertEqual(v1, v2) if __name__ == '__main__': from openmdao.test.mpiunittest import mpirun_tests mpirun_tests()
# 2 parallel comps feeding another comp top = set_as_top(Assembly()) top.add('driver', NoDerivSimpleDriver()) top.add("C1", ABCDArrayComp(size)) top.add("C2", ABCDArrayComp(size)) top.add("C3", ABCDArrayComp(size)) top.driver.workflow.add(['C1', 'C2', 'C3']) top.connect('C1.c', 'C3.a') top.connect('C2.d', 'C3.b') top.C1.a = np.ones(size, float) * 3.0 top.C1.b = np.ones(size, float) * 7.0 top.C2.a = np.ones(size, float) * 4.0 top.C2.b = np.ones(size, float) * 5.0 top.driver.add_parameter('C1.a', low=-1000, high=1000) top.driver.add_objective('C3.d') top.run() self.assertTrue(all(top.C3.a==np.ones(size, float)*10.)) self.assertTrue(all(top.C3.b==np.ones(size, float)*-1.)) self.assertTrue(all(top.C3.c==np.ones(size, float)*9.)) self.assertTrue(all(top.C3.d==np.ones(size, float)*11.)) if __name__ == '__main__': from openmdao.test.mpiunittest import mpirun_tests mpirun_tests()