Beispiel #1
0
def system_example():
    r""" Describe the system as a reliability block diagram

              | -- A0 -- | -- M0 -- |
              |            /        |
         E -- | -- A1 -- |          | -- S
              |            \        |
              | -- A2 -- | -- M1 -- |
    """

    alim = [Component('A_%s' % i, 2e-4) for i in xrange(3)]
    motors = [Component('M_%s' % i, 1e-4) for i in xrange(2)]
    S = System()

    S['E'] = [alim[0], alim[1], alim[2]]
    S[alim[0]] = [motors[0]]
    S[alim[1]] = [motors[0], motors[1]]
    S[alim[2]] = [motors[1]]
    S[motors[0]] = 'S'
    S[motors[1]] = 'S'

    print('The MTTF of the system is :', S.mttf)

    timerange = range(0, 2 * 365 * 24, 100)  # 2 years study
    reliability = [S.reliability(t) for t in timerange]
    plot(timerange, reliability)
    show()
Beispiel #2
0
    def test_cache(self):
        """ Perfom some tests on the cache
        """
        components = [Component('C{}'.format(i), 1e-3) for i in (0, 1, 2)]
        system = System()

        #      +-- C0 --+
        #      |        |
        # E ---|        +-- C2 -- S
        #      |        |
        #      +-- C1 --+

        system['E'] = [components[0], components[1]]
        system[components[0]] = components[2]
        system[components[1]] = components[2]
        system[components[2]] = 'S'

        self.assertAlmostEqual(system.mttf, 2000 / 3.)
        self.assertIn('mttf', system._cache)  #The mttf is cached

        components[0].lambda_ = 0.05  #Let’s change the failure rate
        self.assertEqual(system._cache, dict())  #The cache is now empty
        self.assertAlmostEqual(system.mttf, 331750 / 663.)
        self.assertIn('mttf', system._cache)  #The mttf is cached

        #now, check if it works with a shared component
        othersystem = System()
        othersystem['E'] = components[0]
        othersystem[components[0]] = 'S'

        self.assertAlmostEqual(othersystem.mttf, 20)
        components[0].lambda_ = 2e-4
        self.assertAlmostEqual(othersystem.mttf, 5000)
        self.assertAlmostEqual(system.mttf, 29000 / 33.)
Beispiel #3
0
    def setUp(self):
        #Let’s build some standard systems
        systems = {
            'series-parallel': System(),
            'parallel-series': System(),
            'simple': System()
        }

        lambdas = {'alim': 1e-4, 'motor': 2e-5}
        mus = {'alim': 5e-4, 'motor': 2e-3}

        alim = [
            Component('Alim_A', lambda_=lambdas['alim'], mu=mus['alim']),
            Component('Alim_B', lambda_=lambdas['alim'], mu=mus['alim']),
        ]
        motors = [
            Component('Motor_A', lambda_=lambdas['motor'], mu=mus['motor']),
            Component('Motor_B', lambda_=lambdas['motor'], mu=mus['motor']),
        ]

        systems['simple']['E'] = alim[0]
        systems['simple'][alim[0]] = motors[0]
        systems['simple'][motors[0]] = 'S'

        systems['series-parallel']['E'] = [alim[0], alim[1]]
        systems['series-parallel'][alim[0]] = motors[0]
        systems['series-parallel'][alim[1]] = motors[1]
        systems['series-parallel'][motors[0]] = 'S'
        systems['series-parallel'][motors[1]] = 'S'

        systems['parallel-series']['E'] = [alim[0], alim[1]]
        systems['parallel-series'][alim[0]] = [motors[0], motors[1]]
        systems['parallel-series'][alim[1]] = [motors[0], motors[1]]
        systems['parallel-series'][motors[0]] = 'S'
        systems['parallel-series'][motors[1]] = 'S'

        #Let’s build the markov equivalent system
        self.components = (alim[0], alim[1], motors[0], motors[1])
        self.process = Markovprocess(self.components,
                                     {0: 1})  #All the components work

        self.states = {
            'series-parallel': lambda x: (x[0] * x[2]) + (x[1] * x[3]),
            'parallel-series': lambda x: (x[0] + x[1]) * (x[2] + x[3]),
            'simple': lambda x: x[0] * x[2],
        }

        self.systems = systems
Beispiel #4
0
    def test_graphmanagement(self):
        """ Check if the constructing a system by its graph works as intended.
        """
        component = [Component('C%s' % i, 1e-3) for i in range(4)]
        system = System()

        #because 'E' must be the first inserted element
        with self.assertRaises(ValueError):
            system[component[0]] = 'S'

        #Assert the following constructions don’t fail.
        #from a list
        system['E'] = [component[0], component[1]]
        system[component[0]] = 'S'
        wanted = DiGraph({
            'E': [component[0].__str__(), component[1].__str__()],
            component[0].__str__(): ['S']
        })
        self.assertTrue(is_isomorphic(system._graph, wanted))

        del system[component[0]]  #This component isn’t used anymore
        #from a single element
        system['E'] = component[1]
        system[component[1]] = 'S'
        wanted = DiGraph({
            'E': [component[1].__str__()],
            component[1].__str__(): 'S'
        })
        self.assertTrue(is_isomorphic(system._graph, wanted))
Beispiel #5
0
p1= Component('p1',2.28e-4,0)
m1 = Component('m1', 2.94e-4,0)
m2 = Component('m2', 2.94e-4,0)
bus = Component ('bus',1e-4,0)
voter= Voter(p1,2,3)
alim1= Component ('alim1',2.28e-4,0)
voter2=Voter(alim1,2,3)

p1_b= Component('p1_b',2.28e-4,0)
bus_b= Component('bus_b',1)
voter_b=Voter(p1_b,2,2)
m1_b = Component('m1_b', 1)
alim1_b=Component('alim_b',1)
voter2_b=Voter(alim1,2,2)

S=System()

S['E']=[voter2]
S[m1]=S[m2]='S'
S[voter2]=[voter]
S[voter]=[bus]
S[bus]=[m1,m2]


Sb=System()

Sb['E']=[voter2]
Sb[m1]=Sb[m2]='S'
Sb[voter2]=[voter_b]
Sb[voter_b]=[bus]
Sb[bus]=[m1,m2]
Beispiel #6
0
p1 = Component('p1', 2.28e-4, 0)
voter = Voter(p1, 2, 3)
m1 = Component('m1', 2.94e-4, 0)
m2 = Component('m2', 2.94e-4, 0)
bus = Component('bus', 1e-4, 0)
alim1 = Component('alim1', 2.28e-4, 0)
alim2 = Component('alim2', 2.28e-4, 0)

p1_b = Component('p1_b', 2.28e-4, 0)
voter_b = Voter(p1_b, 2, 2)
bus_b = Component('bus_b', 1)
m1_b = Component('m1_b', 1)
alim1_b = Component('alim_b', 1)

S = System()

S['E'] = [alim1, alim2]
S[alim1] = S[alim2]
S[m1] = S[m2] = 'S'
S[alim1] = S[alim2] = [voter]
S[voter] = [bus]
S[bus] = [m1, m2]

Sb = System()

Sb['E'] = [alim1_b, alim2]
Sb[alim1_b] = Sb[alim2]
Sb[m1_b] = Sb[m2] = 'S'
Sb[alim1_b] = Sb[alim2] = [voter_b]
Sb[voter_b] = [bus_b]
#ARCHI 1
from fiabilipy import Voter,Component
from sympy import Symbol
from fiabilipy import System
import pylab as p

p1= Component('p1',2.28e-4,0)
voter= Voter(p1,2,3)
m1 = Component('m1', 2.94e-4,0)
m2 = Component('m2', 2.94e-4,0)
bus = Component ('bus',1e-4,0)
alim= Component ('alim',2.28e-4,0)

S=System()

S['E']=[alim]
S[m1]=S[m2]='S'
S[alim]=[voter]
S[voter]=[bus]
S[bus]=[m1,m2]



timerange=range(0,43800,100)

availability = [S.availability(t)for t in timerange]
p.plot(timerange,availability)
p.show()


Beispiel #8
0
#ARCHI 2
from fiabilipy import Voter,Component
from sympy import Symbol
from fiabilipy import System
import pylab as p

p1= Component('p1',2.28e-4,0)
voter= Voter(p1,2,3)
m1 = Component('m1', 2.94e-4,0)
m2 = Component('m2', 2.94e-4,0)
bus = Component ('bus',1e-4,0)
alim1= Component ('alim1',2.28e-4,0)
alim2= Component ('alim2',2.28e-4,0)

S=System()

S['E']=[alim1,alim2]
S[alim1]=S[alim2]
S[m1]=S[m2]='S'
S[alim1]=S[alim2]=[voter]
S[voter]=[bus]
S[bus]=[m1,m2]


timerange=range(0,43800,100)


availability = [S.availability(t) for t in timerange]
p.plot(timerange,availability)
p.show()
Beispiel #9
0
import fiabilipy
from fiabilipy import Component
from sympy import Symbol
t = Symbol('t', positive=True)
comp = Component('C0', 1e-4)
print(comp.reliability(100))
print(comp.reliability(t=33))
print(comp.mttf)
from fiabilipy import System
power = Component('P0', 1e-6)
motor = Component('M0', 1e-3)
print(power)
S = System()
S['E'] = [power]
S[power] = [motor]
S[motor] = 'S'
print(S.reliability(t))
print(S.mttf)
print(float(S.mttf))
a, b, c, d, e, f, g = [Component('C%i' % i, 1e-4) for i in range(7)]
S = System()
S['E'] = [a, b, c, g]
S[a] = S[g] = S[e] = S[d] = 'S'
S[b] = S[c] = [f]
S[f] = [e, d]
print(a)
print(S.mttf)
print(float(S.mttf))
print(S.reliability(t))
import pylab as p
a, b = Component('a', 1e-5), Component('b', 1e-7)
Beispiel #10
0
    def setUp(self):
        """ Here we build some standard systems we will use as test subjects
        """
        systems = {
            'simple': System(),
            'series-parallel': System(),
            'parallel-series': System(),
            'complex': System(),
            'voter': System(),
        }

        lambdas = {
            'alim': symbols('l_alim', positive=True, null=False),
            'motor': symbols('l_motor', positive=True, null=False),
        }
        mus = {
            'alim': symbols('m_alim', positive=True, null=False),
            'motor': symbols('m_motor', positive=True, null=False),
        }

        alim = [
            Component('Alim_A', lambda_=lambdas['alim'], mu=mus['alim']),
            Component('Alim_B', lambda_=lambdas['alim'], mu=mus['alim']),
            Component('Alim_C', lambda_=lambdas['alim'], mu=mus['alim']),
        ]
        motors = [
            Component('Motor_A', lambda_=lambdas['motor'], mu=mus['motor']),
            Component('Motor_B', lambda_=lambdas['motor'], mu=mus['motor']),
        ]

        voter = Voter(alim[0], M=2, N=3)

        systems['simple']['E'] = alim[0]
        systems['simple'][alim[0]] = motors[0]
        systems['simple'][motors[0]] = 'S'

        systems['series-parallel']['E'] = [alim[0], alim[1]]
        systems['series-parallel'][alim[0]] = motors[0]
        systems['series-parallel'][alim[1]] = motors[1]
        systems['series-parallel'][motors[0]] = 'S'
        systems['series-parallel'][motors[1]] = 'S'

        systems['parallel-series']['E'] = [alim[0], alim[1]]
        systems['parallel-series'][alim[0]] = [motors[0], motors[1]]
        systems['parallel-series'][alim[1]] = [motors[0], motors[1]]
        systems['parallel-series'][motors[0]] = 'S'
        systems['parallel-series'][motors[1]] = 'S'

        systems['complex']['E'] = [alim[0], alim[1], alim[2]]
        systems['complex'][alim[0]] = motors[0]
        systems['complex'][alim[1]] = [motors[0], motors[1]]
        systems['complex'][alim[2]] = motors[1]
        systems['complex'][motors[0]] = 'S'
        systems['complex'][motors[1]] = 'S'

        systems['voter']['E'] = voter
        systems['voter'][voter] = [motors[0], motors[1]]
        systems['voter'][motors[0]] = 'S'
        systems['voter'][motors[1]] = 'S'

        self.systems = systems
        self.alim = alim
        self.motors = motors
        self.voter = voter
        self.lambdas = lambdas
        self.mus = mus