예제 #1
0
    def test_throttled_consumer(self):

        s = Source(PipedWater, 0.5) + Sink(PipedWater, 1.0)
        s.balance()
        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 0.5)
예제 #2
0
    def test_full_throughput_balance(self):

        s = Source(PipedWater, 1) + Sink(PipedWater, 1)
        s.balance()
        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 1)
예제 #3
0
    def test_balance_idempotence(self):

        s = Source(PipedWater, 0.5) + Sink(PipedWater, 1.0)
        s.balance()
        s.balance()

        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 0.5)
예제 #4
0
    def test_missing_consumer(self):

        # Gives but doesn't need heat
        s = Source(Power, 10) + CeilingLight()
        s.balance()

        a, b = s.subsystems
        assert_almost_equal(a.uptime, 1)
        assert_almost_equal(b.uptime, 1)
예제 #5
0
 def test_heavy_consumer(self):
     s = Source(Power, 1) + Sink(Power, 1e3)
     s.balance()
     print(s)
     assert_almost_equal(s[0].uptime, 1, 6)
     assert_almost_equal(s[1].uptime, 1e-3, 6)
예제 #6
0
 def test_heavy_producer(self):
     s = Source(Power, 1e3) + Sink(Power, 1)
     s.balance()
     assert_almost_equal(s[0].uptime, 1, 6)
     assert_almost_equal(s[1].uptime, 1, 6)
예제 #7
0
 def test_neutralize_all(self):
     s = Source(PipedWater, 2) + Source(Oxygen, 2)
     s.balance(neutralize='all')
     assert_almost_equal(s[0].uptime, 0)
     assert_almost_equal(s[1].uptime, 0)