Beispiel #1
0
    def __init__(self, label, edges, w, z, **kwargs):
        if not hasattr(w, '__len__'):
            w = [
                w,
            ]
        if not hasattr(z, '__len__'):
            z = [
                z,
            ]
        assert len(w) == len(z),\
            'len(z)={0!s} is not equal to len(w)={1!s}.'.format(len(z), len(w))
        # init PortHamiltonianObject
        Graph.__init__(self, label=label)
        # build correspondance between labels in subs and pars (dicpars)...
        # ... and build the correspondance between symbols and subs (subs)
        dicpars, subs = mappars(self, **kwargs)
        # update dict of subs in phs
        self.core.subs.update(subs)
        # replace parameters in z by correspondances in 'dicpars'
        for i, zz in enumerate(z):
            z[i] = zz.subs(dicpars)
        for e, edge in enumerate(edges):
            if 'z' in edge[2].keys():
                for k in ['e_ctrl', 'f_ctrl']:
                    edges[e][2]['z'][k] = edge[2]['z'][k].subs(dicpars)

        # add dissipative component
        self.core.add_dissipations(w, z)
        # update phs.Graph with edges
        self.add_edges_from(edges)
Beispiel #2
0
    def __init__(self, label, edges, w, z, **kwargs):
        if not hasattr(w, '__len__'):
            w = [w, ]
        if not hasattr(z, '__len__'):
            z = [z, ]
        assert len(w) == len(z),\
            'len(z)={0!s} is not equal to len(w)={1!s}.'.format(len(z), len(w))
        # init PortHamiltonianObject
        Graph.__init__(self, label=label)
        # build correspondance between labels in subs and pars (dicpars)...
        # ... and build the correspondance between symbols and subs (subs)
        dicpars, subs = mappars(self, **kwargs)
        # update dict of subs in phs
        self.core.subs.update(subs)
        # replace parameters in z by correspondances in 'dicpars'
        for i, zz in enumerate(z):
            z[i] = zz.subs(dicpars)
        for e, edge in enumerate(edges):
            if 'z' in edge[2].keys():
                for k in ['e_ctrl', 'f_ctrl']:
                    edges[e][2]['z'][k] = edge[2]['z'][k].subs(dicpars)

        # add dissipative component
        self.core.add_dissipations(w, z)
        # update phs.Graph with edges
        self.add_edges_from(edges)
Beispiel #3
0
 def __init__(self, label, edges, **kwargs):
     # init PortHamiltonianObject
     PHSGraph.__init__(self, label=label)
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #4
0
 def __init__(self, label, edges, **kwargs):
     # init PortHamiltonianObject
     Graph.__init__(self, label=label)
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #5
0
 def __init__(self, label, edges, x, H, **kwargs):
     # init PortHamiltonianObject
     Graph.__init__(self, label=label)
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # replace parameters in H by correspondances in 'dicpars'
     H = H.subs(dicpars)
     # add dissipative component
     self.core.add_storages(x, H)
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #6
0
 def __init__(self, label, edges, x, H, **kwargs):
     # init PortHamiltonianObject
     Graph.__init__(self, label=label)
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # replace parameters in H by correspondances in 'dicpars'
     H = H.subs(dicpars)
     # add dissipative component
     self.core.add_storages(x, H)
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #7
0
 def __init__(self, label, nodes, **kwargs):
     # init PortHamiltonianObject
     PHSGraph.__init__(self, label=label)
     # pop connector type
     connector_type = kwargs.pop('connector_type')
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # replace parameters in alpha by correspondances in 'dicpars'
     alpha = self.core.symbols('alpha')
     alpha = alpha.subs(dicpars)
     # symbols for inputs and outputs:
     u1, u2 = self.core.symbols(
         [nicevarlabel('u', label + str(el)) for el in (1, 2)])
     y1, y2 = self.core.symbols(
         [nicevarlabel('y', label + str(el)) for el in (1, 2)])
     # add connector component
     ny = self.core.dims.y()
     self.core.add_ports((u1, u2), (y1, y2))
     self.core.add_connector((ny, ny + 1), alpha)
     # update phs.Graph with edges
     edge1_data = {
         'type': 'connector',
         'connector_type': connector_type,
         'alpha': alpha,
         'ctrl': '?',
         'label': y1,
         'link': y2
     }
     edge2_data = {
         'type': 'connector',
         'connector_type': connector_type,
         'alpha': None,
         'ctrl': '?',
         'label': y2,
         'link': y1
     }
     N1, N2, N3, N4 = nodes
     edges = [(N1, N2, edge1_data), (N3, N4, edge2_data)]
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #8
0
 def __init__(self, label, nodes, **kwargs):
     # init PortHamiltonianObject
     Graph.__init__(self, label=label)
     # pop connector type
     connector_type = kwargs.pop('connector_type')
     # build correspondance between labels in subs and pars (dicpars)...
     # ... and build the correspondance between symbols and subs (subs)
     dicpars, subs = mappars(self, **kwargs)
     # update dict of subs in phs
     self.core.subs.update(subs)
     # replace parameters in alpha by correspondances in 'dicpars'
     alpha = self.core.symbols('alpha')
     alpha = alpha.subs(dicpars)
     # symbols for inputs and outputs:
     u1, u2 = self.core.symbols([nicevarlabel('u', label + str(el))
                                 for el in (1, 2)])
     y1, y2 = self.core.symbols([nicevarlabel('y', label + str(el))
                                 for el in (1, 2)])
     # add connector component
     ny = self.core.dims.y()
     self.core.add_ports((u1, u2), (y1, y2))
     self.core.add_connector((ny, ny+1), alpha)
     # update phs.Graph with edges
     edge1_data = {'type': 'connector',
                   'connector_type': connector_type,
                   'alpha': alpha,
                   'ctrl': '?',
                   'label': y1,
                   'link': y2}
     edge2_data = {'type': 'connector',
                   'connector_type': connector_type,
                   'alpha': None,
                   'ctrl': '?',
                   'label': y2,
                   'link': y1}
     N1, N2, N3, N4 = nodes
     edges = [(N1, N2, edge1_data), (N3, N4, edge2_data)]
     # update phs.Graph with edges
     self.add_edges_from(edges)
Beispiel #9
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)