def test_get_inconsistent_initial_conditions(self): m = make_model() inconsistent = get_inconsistent_initial_conditions(m, m.time) self.assertIn(m.fs.b1.con[m.time[1], m.space[1]], inconsistent) self.assertIn(m.fs.b2[m.time[1], m.space[1]].b3['a'].con['d'], inconsistent) self.assertIn(m.fs.con1[m.time[1]], inconsistent) self.assertNotIn(m.fs.con2[m.space[1]], inconsistent)
def test_solve_consistent_initial_conditions(self): m = make_model() solver = SolverFactory('ipopt') solve_consistent_initial_conditions(m, m.time, solver, allow_skip=True) inconsistent = get_inconsistent_initial_conditions(m, m.time) self.assertFalse(inconsistent) self.assertTrue(m.fs.con1[m.time[1]].active) self.assertTrue(m.fs.con1[m.time[3]].active) self.assertTrue(m.fs.b1.con[m.time[1], m.space[1]].active) self.assertTrue(m.fs.b1.con[m.time[3], m.space[1]].active) with self.assertRaises(KeyError): solve_consistent_initial_conditions( m, m.time, solver, allow_skip=False, )