예제 #1
0
    def __init__(self, label, nodes, **kwargs):
        # parameters
        pars = ['K0', 'Ksat', 'xsat']
        for par in pars:
            assert par in kwargs.keys()
        K0, Ksat, xsat = symbols(pars)
        # state  variable
        x = symbols("x"+label)
        # storage funcion
        Hlin = x**2/2
        t1 = sp.pi*x/(2*xsat)
        c1 = (8*xsat/(sp.pi*(4-sp.pi)))
        Hsat = c1 * (sp.log(sp.cos(t1)) + (t1**2)/2.)
        H = K0*(Hlin - Ksat*Hsat)
        N1, N2 = nodes

        # edge data
        data = {'label': x,
                'type': 'storage',
                'ctrl': 'f',
                'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        StorageNonLinear.__init__(self, label, [edge],
                                     x, H, **kwargs)
예제 #2
0
    def __init__(self, label, nodes, **kwargs):
        # parameters
        pars = ['K0', 'Ksat', 'xsat']
        for par in pars:
            assert par in kwargs.keys()
        K0, Ksat, xsat = symbols(pars)
        # state  variable
        x = symbols("x"+label)
        # storage funcion
        Hlin = x**2/2
        t1 = sp.pi*x/(2*xsat)
        c1 = (8*xsat/(sp.pi*(4-sp.pi)))
        Hsat = c1 * (sp.log(sp.cos(t1)) + (t1**2)/2.)
        H = K0*(Hlin - Ksat*Hsat)
        N1, N2 = nodes

        # edge data
        data = {'label': x,
                'type': 'storage',
                'ctrl': 'f',
                'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        PHSStorageNonLinear.__init__(self, label, [edge],
                                     x, H, **kwargs)
예제 #3
0
파일: port.py 프로젝트: yomguy/pyphs
    def __init__(self, label, nodes, **kwargs):

        # update default parameters
        parameters = {'ctrl': '?', 'const': None}
        parameters.update(kwargs)

        Graph.__init__(self, label=label)
        # set starting node to datum if not provided
        if nodes.__len__() == 1:
            node1 = datum
            node2 = nodes[0]
        elif nodes.__len__() == 2:
            node1 = nodes[0]
            node2 = nodes[1]
        # define symbols
        u, y = symbols((nicevarlabel('u', label),
                        nicevarlabel('y', label)))
        # add port to phs
        self.core.add_ports([u], [y])
        # check edge control type (dual of input control type in values[0])
        assert parameters['ctrl'] in ('e', 'f', '?')
        # define edge data
        edge_data = {'label': y,
                     'type': 'port',
                     'ctrl': parameters['ctrl'],
                     'link': None}
        # add edge to phs.Graph
        self.add_edges_from([(node1, node2, edge_data)])
        # check if constant value is provided
        if parameters['const'] is not None:
            self.core.subs.update({u: parameters['const']})
예제 #4
0
    def __init__(self, label, nodes, **kwargs):
        # parameters
        pars = ['K0', 'K2']
        for par in pars:
            assert par in kwargs.keys()
        K0, K2 = symbols(pars)
        # state  variable
        x = symbols("x" + label)
        # storage funcion
        H = K0 * x * (x + K2 * x**3 / 2) / 2
        N1, N2 = nodes

        # edge data
        data = {'label': x, 'type': 'storage', 'ctrl': 'e', 'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        PHSStorageNonLinear.__init__(self, label, [edge], x, H, **kwargs)
예제 #5
0
    def __init__(self, label, nodes, **kwargs):

        parameters = parametersDefault(self.metadata['parameters'])
        parameters.update(kwargs)

        # parameters
        pars = ['F1', 'F3', 'xref']

        F1, F3, xref = symbols(pars)
        # state  variable
        x = symbols("x" + label)
        # storage funcion
        H = F1 * x**2 / (2. * xref) + F3 * x**4 / (4 * xref**3)
        N1, N2 = nodes

        # edge data
        data = {'label': x, 'type': 'storage', 'ctrl': 'f', 'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        StorageNonLinear.__init__(self, label, [edge], x, H, **parameters)
예제 #6
0
    def __init__(self, label, nodes, **kwargs):
        parameters = parametersDefault(self.metadata['parameters'])
        parameters.update(kwargs)
        # parameters
        pars = ['C0', 'Csat', 'phisat']
        C_0, C_sat, phi_sat = symbols(pars)
        # state  variable
        x = symbols("x" + label)
        # storage funcion
        Hlin = x**2 / 2
        t1 = sp.pi * x / (2 * phi_sat)
        c1 = (8 * phi_sat / (sp.pi * (4 - sp.pi)))
        Hsat = c1 * (sp.log(sp.cos(t1)) + (t1**2) / 2.)
        H = (Hlin - C_sat * Hsat) / C_0
        N1, N2 = nodes

        # edge data
        data = {'label': x, 'type': 'storage', 'ctrl': 'f', 'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        StorageNonLinear.__init__(self, label, [edge], x, H, **parameters)
예제 #7
0
    def __init__(self, label, nodes, **kwargs):
        # parameters
        pars = ['K0', 'K2']
        for par in pars:
            assert par in kwargs.keys()
        K0, K2 = symbols(pars)
        # state  variable
        x = symbols("x"+label)
        # storage funcion
        H = K0*x*(x + K2*x**3/2)/2
        N1, N2 = nodes

        # edge data
        data = {'label': x,
                'type': 'storage',
                'ctrl': 'f',
                'link': None}

        # edge
        edge = (N1, N2, data)

        # init component
        StorageNonLinear.__init__(self, label, [edge],
                                     x, H, **kwargs)
예제 #8
0
    def __init__(self, label, nodes, **kwargs):
        PHSGraph.__init__(self, label=label)
        dic = {
            'A': 1e2,  # [N.s/m] Felt damping coefficient
            'B': 2.5,  # [#] Hysteresis coefficient for the felt
            'K': 5e5,  # [N/m] Stiffness of the felt
            'L': 1.5 * 1e-2,  # [m] Height of the felt at rest
        }
        dic.update(kwargs)
        dicpars, subs = mappars(self, **dic)
        # parameters
        pars = ['L', 'K', 'A', 'B']
        L, K, A, B = symbols(pars)

        xnl = symbols('q' + label)
        hnl = sp.Piecewise((0., xnl <= 0.),
                           ((L * K / (B + 1)) * (xnl / L)**(B + 1), True))
        hnl = hnl.subs(dicpars).simplify()
        # edge data
        data = {'label': xnl, 'type': 'storage', 'ctrl': 'e', 'link': None}
        self.add_edges_from([
            (nodes[0], nodes[1], data),
        ])
        self.core.add_storages(xnl, hnl)
        r = sp.Piecewise(
            (0., xnl <= 0.),
            ((A * L / B) * (xnl / L)**(B - 1), True))  # JSV eq (13)
        r = r.subs(dicpars).simplify()
        wnl = symbols('dtq' + label)
        # edge data
        data = {'label': wnl, 'type': 'dissipative', 'ctrl': 'e', 'link': None}
        self.add_edges_from([
            (nodes[0], nodes[1], data),
        ])
        self.core.add_dissipations(wnl, r * wnl)
        self.core.subs.update(subs)