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)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if not isinstance(kwargs['value'], Argument): coeff = Argument(label + 'coeff', kwargs['value']) else: coeff = kwargs['value'] x = nicevarlabel("x", label) x = self.core.symbols(x) if kwargs['inv_coeff']: coeff.symb = coeff.symb**-1 H = coeff.symb * x**2 / 2. self.core.add_storages([x], H) edge_data_dic = { 'label': x, 'type': 'storage', 'ctrl': kwargs['ctrl'], 'link': None } edge = (nodes[0], nodes[1], edge_data_dic) self.add_edges_from([edge]) self.core.subs.update(coeff.sub) if len(coeff.sub) == 0 and kwargs['inv_coeff']: self.core.p += [ coeff.symb**-1, ] elif len(coeff.sub) == 0: self.core.p += [ coeff.symb, ]
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)
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']})
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if not isinstance(kwargs['coeff'], Argument): coeff = Argument(label + 'coeff', kwargs['coeff']) else: coeff = kwargs['coeff'] w_label = nicevarlabel("w", label) w = self.core.symbols(w_label) z_f_ctrl = coeff.symb * w z_e_ctrl = w / coeff.symb if 'inv_coeff' in kwargs and kwargs['inv_coeff']: z_f_ctrl, z_e_ctrl = z_e_ctrl, z_f_ctrl self.core.add_dissipations([w], [z_f_ctrl]) edge_data_dic = { 'label': w, 'type': 'dissipative', 'ctrl': '?', 'z': { 'e_ctrl': z_e_ctrl, 'f_ctrl': z_f_ctrl }, 'link': None } edge = (nodes[0], nodes[1], edge_data_dic) self.add_edges_from([edge]) self.core.subs.update(coeff.sub) if len(coeff.sub) == 0: self.core.p += [ coeff.symb, ]
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)
def __init__(self, label, nodes, **kwargs): # instanciate a Graph object Graph.__init__(self, label=label) path = kwargs.pop('file') data = np.vstack(map(np.array, data_generator(path))) w_vals = data[0, :] z_vals = data[1, :] assert all(z_vals[np.nonzero(w_vals >= 0)] >= 0), 'All values z(w) for\ w>=0 must be non-negative (component {})'.format(label) assert all(z_vals[np.nonzero(w_vals < 0)] < 0), 'All values z(w) for\ w<0 must be negative (component {})'.format(label) assert all(z_vals[np.nonzero(w_vals == 0)] == 0), 'z(0) must be zero \ (component {})'.format(label) assert all(np.diff(z_vals) > 0), "z'(0) must be positive\ (component {})".format(label) ctrl = kwargs.pop('ctrl') # state variable w = symbols("w" + label) # dissipative funcion z = pwl_func(w_vals, z_vals, w, **kwargs) if ctrl == 'e': not_ctrl = 'f' else: assert ctrl == 'f' not_ctrl = 'e' # edge data data = { 'label': w, 'type': 'dissipative', 'ctrl': ctrl, 'z': { ctrl + '_ctrl': z, not_ctrl + '_ctrl': sp.sympify(0) }, 'link': None } N1, N2 = nodes # edge edge = (N1, N2, data) # init component self += edges.DissipativeNonLinear(label, [ edge, ], w, z, **kwargs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) pars = parameters_JSV2016() pars.update(kwargs) Ccoil = float(pars.pop('Ccoil')) Ncoil = float(pars.pop('Ncoil')) # remove H0 pars.pop('H0') dicpars, subs = mappars(self, **pars) # parameters pars = ['Rb', 'Rp', 'Lh', 'Lv'] Rb, Rp, Lh, Lv = self.core.symbols(pars) # nodes MASS, ELEC1, ELEC2 = nodes NMagnet = 'N' + label + 'Magnet' NCcoil = 'N' + label + 'Ccoil' self += Source(label+'Magnet', (self.datum, NMagnet), **{'type': 'mmf', # 'const': H0, }) MASS_obs = Observerec(label+'OBS', (self.datum, MASS)) self += MASS_obs q, dtq = MASS_obs.core.o() def f(q, dtq): """ cf JSV Rhodes eq (25) set dmu = (murel-1)/(murel + 1) to 1 """ dmu = 1 f1 = (q - Rp + Lv)**2 + Lh**2 f2 = (q + Rp + Lv)**2 + Lh**2 return 2*Rb**2*dmu*Rp*((f1-2*Lh**2)/f1**2 - (f2-2*Lh**2)/f2**2) * dtq falpha = (f(q, dtq)**-1).subs(dicpars) self += Gyrator(label+'MecToMag', (self.datum, NCcoil, self.datum, NMagnet), alpha=(label+'f', falpha)) self += Capacitor(label+'Ccoil', (self.datum, NCcoil), C=Ccoil) self += Gyrator(label+'MagToElec', (self.datum, NCcoil, ELEC1, ELEC2), alpha=(label+'Ncoil', Ncoil)) self.core.subs.update(subs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) pars = parameters_JSV2016() pars.update(kwargs) Ccoil = float(pars.pop('Ccoil')) Ncoil = float(pars.pop('Ncoil')) # remove H0 pars.pop('H0') dicpars, subs = mappars(self, **pars) # parameters pars = ['Rb', 'Rp', 'Lh', 'Lv'] Rb, Rp, Lh, Lv = self.core.symbols(pars) # nodes MASS, ELEC1, ELEC2 = nodes NMagnet = 'N' + label + 'Magnet' NCcoil = 'N' + label + 'Ccoil' self += Source( label + 'Magnet', (self.datum, NMagnet), **{ 'type': 'mmf', # 'const': H0, }) MASS_obs = Observerec(label + 'OBS', (self.datum, MASS)) self += MASS_obs q, dtq = MASS_obs.core.o() def f(q, dtq): """ cf JSV Rhodes eq (25) set dmu = (murel-1)/(murel + 1) to 1 """ dmu = 1 f1 = (q - Rp + Lv)**2 + Lh**2 f2 = (q + Rp + Lv)**2 + Lh**2 return 2 * Rb**2 * dmu * Rp * ((f1 - 2 * Lh**2) / f1**2 - (f2 - 2 * Lh**2) / f2**2) * dtq falpha = (f(q, dtq)**-1).subs(dicpars) self += Gyrator(label + 'MecToMag', (self.datum, NCcoil, self.datum, NMagnet), alpha=(label + 'f', falpha)) self += Capacitor(label + 'Ccoil', (self.datum, NCcoil), C=Ccoil) self += Gyrator(label + 'MagToElec', (self.datum, NCcoil, ELEC1, ELEC2), alpha=(label + 'Ncoil', Ncoil)) self.core.subs.update(subs)
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)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) dic = { 'A': 1e2, # [N.s/m] Felt damping coefficient 'B': 2.5, # [#] Hysteresis coefficient for the felt 'F': 13.8, # [N/m] Elastic characteristic force 'L': 1.5 * 1e-2, # [m] Height of the felt at rest } dic.update(kwargs) dicpars, subs = mappars(self, **dic) # parameters pars = ['L', 'F', 'A', 'B'] L, F, A, B = symbols(pars) N1, N2 = nodes xnl = symbols('q' + label) hnl = sp.Piecewise((0., xnl <= 0.), ((L * F / (B + 1)) * (xnl / L)**(B + 1), True)) hnl = hnl.subs(dicpars) # edge data data = {'label': xnl, 'type': 'storage', 'ctrl': 'e', 'link': None} self.add_edges_from([ (N1, N2, data), ]) self.core.add_storages(xnl, hnl) r = sp.Piecewise((0., xnl <= 0.), ((A * L / B) * (xnl / L)**(B - 1), True)) r = r.subs(dicpars) wnl = symbols('dtq' + label) # edge data data = { 'label': wnl, 'type': 'dissipative', 'ctrl': 'e', 'z': { 'e_ctrl': r * wnl, 'f_ctrl': sp.sympify(0) }, 'link': None } self.add_edges_from([ (N1, N2, data), ]) self.core.add_dissipations(wnl, r * wnl) self.core.subs.update(subs)
def __init__(self, label, nodes, **kwargs): # instanciate a Graph object Graph.__init__(self, label=label) assert 'file' in kwargs, "pwl.storage component need 'file' argument" path = kwargs.pop('file') vals = np.vstack(map(np.array, data_generator(path))) x_vals = vals[0, :] h_vals = vals[1, :] assert all(h_vals[np.nonzero(x_vals >= 0)] >= 0), 'All values h(x) for\ x>=0 must be non-negative (component {})'.format(label) if kwargs['integ']: assert all(h_vals[np.nonzero(x_vals < 0)] < 0), 'All values dxh(x)\ for x<0 must be negative (component {})'.format(label) else: assert all(h_vals[np.nonzero(x_vals < 0)] >= 0), 'All values h(x)\ for x<0 must be non-negative (component {})'.format(label) assert h_vals[np.nonzero(x_vals == 0)] == 0, 'dxh(0) and h(0) must be \ zero (component {})'.format(label) ctrl = kwargs.pop('ctrl') # state variable x = symbols("x" + label) # storage funcion h = pwl_func(x_vals, h_vals, x, **kwargs) # edge data data = { 'label': x, 'type': 'storage', 'ctrl': ctrl, 'file': path, 'link': None } N1, N2 = nodes # edge edge = (N1, N2, data) # init component self += edges.StorageNonLinear(label, [edge], x, h, **kwargs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'alpha' not in kwargs: alpha = 0.5 else: alpha = kwargs.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(p, alpha, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes N1 = Ndeb for n in range(nbPoles): if n < nbPoles-1: N2 = 'N'+label+str(n)+"_1" else: N2 = Nend Rn = diagR[n] # here, diagR[n] is a res (flux-controlled) self += DissipativeLinear(label+'R'+str(n), (N2, N1), ctrl='f', coeff=Rn, inv_coef=False) Qn = diagQ[n] N3 = 'N'+label+str(n)+"_2" self += StorageLinear(label+'Q'+str(n), (N3, datum), value=Qn, inv_coeff=False, ctrl='e') Nend = nodes[1] self += Transformer(label+'alpha'+str(n), (N1, N2, N3, datum), alpha=Rn) N1 = N2
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) parameters = parametersDefault(self.metadata['parameters']) parameters.update(kwargs) dicpars, subs = mappars(self, **parameters) # parameters pars = ['L', 'F', 'A', 'B'] L, F, A, B = symbols(pars) N1, N2 = nodes xnl = symbols('q' + label) hnl = sp.Piecewise((0., xnl <= 0.), ((L * F / (B + 1)) * (xnl / L)**(B + 1), True)) hnl = hnl.subs(dicpars) # edge data data = {'label': xnl, 'type': 'storage', 'ctrl': 'e', 'link': None} self.add_edges_from([ (N1, N2, data), ]) self.core.add_storages(xnl, hnl) r = sp.Piecewise((0., xnl <= 0.), ((A * L / B) * (xnl / L)**(B - 1), True)) r = r.subs(dicpars) wnl = symbols('dtq' + label) # edge data data = { 'label': wnl, 'type': 'dissipative', 'ctrl': 'e', 'z': { 'e_ctrl': r * wnl, 'f_ctrl': sp.sympify(0) }, 'link': None } self.add_edges_from([ (N1, N2, data), ]) self.core.add_dissipations(wnl, r * wnl) self.core.subs.update(subs)
def __init__(self, label, nodes, **kwargs): # instanciate a Graph object Graph.__init__(self, label=label) assert 'file' in kwargs, "pwl.storage component need 'file' argument" path = kwargs.pop('file') vals = np.vstack(map(np.array, data_generator(path))) x_vals = vals[0, :] h_vals = vals[1, :] assert all(h_vals[np.nonzero(x_vals >= 0)] >= 0), 'All values h(x) for\ x>=0 must be non-negative (component {})'.format(label) if kwargs['integ']: assert all(h_vals[np.nonzero(x_vals < 0)] < 0), 'All values dxh(x)\ for x<0 must be negative (component {})'.format(label) else: assert all(h_vals[np.nonzero(x_vals < 0)] >= 0), 'All values h(x)\ for x<0 must be non-negative (component {})'.format(label) assert h_vals[np.nonzero(x_vals == 0)] == 0, 'dxh(0) and h(0) must be \ zero (component {})'.format(label) ctrl = kwargs.pop('ctrl') # state variable x = symbols("x"+label) # storage funcion h = pwl_func(x_vals, h_vals, x, **kwargs) # edge data data = {'label': x, 'type': 'storage', 'ctrl': ctrl, 'link': None} N1, N2 = nodes # edge edge = (N1, N2, data) # init component self += edges.StorageNonLinear(label, [edge], x, h, **kwargs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'alpha' not in kwargs: alpha = 0.5 else: alpha = kwargs.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(p, alpha, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes for n in range(nbPoles): Rn = diagR[n] # here, diagR[n] is a conductance (e-ctrl) N1 = 'N'+label+str(n)+"_1" N2 = 'N'+label+str(n)+"_2" self += DissipativeLinear(label+'R'+str(n), (N1, Ndeb), inv_coeff=True, coeff=Rn, ctrl='e') Qn = diagQ[n] self += StorageLinear(label+'Q'+str(n), (N2, datum), value=Qn, ctrl='f', inv_coeff=False) self += Transformer(label+'alpha'+str(n), (N1, Nend, N2, datum), alpha=Rn**-1)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'alpha' not in kwargs: alpha = 0.5 else: alpha = kwargs.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(p, alpha, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes N1 = Ndeb for n in range(nbPoles): if n < nbPoles - 1: N2 = 'N' + label + str(n) + "_1" else: N2 = Nend Rn = diagR[n] # here, diagR[n] is a res (flux-controlled) self += DissipativeLinear(label + 'R' + str(n), (N2, N1), ctrl='f', coeff=Rn, inv_coef=False) Qn = diagQ[n] N3 = 'N' + label + str(n) + "_2" self += StorageLinear(label + 'Q' + str(n), (N3, datum), value=Qn, inv_coeff=False, ctrl='e') Nend = nodes[1] self += Transformer(label + 'alpha' + str(n), (N1, N2, N3, datum), alpha=Rn) N1 = N2
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'beta' not in kwargs: beta = 0.5 else: beta = kwargs.pop('beta') self.core.subs.update({ self.core.symbols('p_' + label): p, self.core.symbols('beta_' + label): beta }) diagRmu, diagQmu = fractionalIntegratorWeights(p, beta, **kwargs) # Truncation of poles with null Q nbPoles = diagRmu.__len__() for n in range(nbPoles): Rn = diagRmu[n] # here, diagRmu[n] is a resistance (f-ctrl) Nend = nodes[1] Ncomp = 'iN_' + label + str(n) comp = DissipativeLinear('R_' + label + str(n), (Ncomp, Nend), coeff=Rn, ctrl='f') self += comp Qn = diagQmu[n] Ndeb = nodes[0] comp = StorageLinear(label + str(n), (Ndeb, Ncomp), value=Qn, name='pL_', inv_coeff=False, ctrl='e') self += comp
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'beta' not in kwargs: beta = 0.5 else: beta = kwargs.pop('beta') self.core.subs.update({self.core.symbols('p_'+label): p, self.core.symbols('beta_'+label): beta}) diagRmu, diagQmu = fractionalIntegratorWeights(p, beta, **kwargs) # Truncation of poles with null Q nbPoles = diagRmu.__len__() for n in range(nbPoles): Rn = diagRmu[n] # here, diagRmu[n] is a resistance (f-ctrl) Nend = nodes[1] Ncomp = 'iN_'+label + str(n) comp = DissipativeLinear('R_'+label+str(n), (Ncomp, Nend), coeff=Rn, ctrl='f') self += comp Qn = diagQmu[n] Ndeb = nodes[0] comp = StorageLinear(label+str(n), (Ndeb, Ncomp), value=Qn, name='pL_', inv_coeff=False, ctrl='e') self += comp
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'beta' not in kwargs: beta = 0.5 else: beta = kwargs.pop('beta') diagR, diagQ = fractionalIntegratorWeights(p, beta, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() N, Nend = nodes for n in range(nbPoles): if n < nbPoles - 1: Ncomp = 'iN_' + label + str(n) + 'to' + str(n + 1) else: Ncomp = Nend nodes = (N, Ncomp) # here, diagRmu[n] is a conductance (effort-controlled) Rn = diagR[n] self += DissipativeLinear(label + 'R' + str(n), nodes, coeff=Rn, inv_coeff=True, ctrl='e') Qn = diagQ[n] self += StorageLinear(label + 'Q' + str(n), nodes, value=Qn, inv_coeff=False, ctrl='f') N = Ncomp
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)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'beta' not in kwargs: beta = 0.5 else: beta = kwargs.pop('beta') diagR, diagQ = fractionalIntegratorWeights(p, beta, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() N, Nend = nodes for n in range(nbPoles): if n < nbPoles-1: Ncomp = 'iN_'+label + str(n) + 'to' + str(n+1) else: Ncomp = Nend nodes = (N, Ncomp) # here, diagRmu[n] is a conductance (effort-controlled) Rn = diagR[n] self += DissipativeLinear(label + 'R' + str(n), nodes, coeff=Rn, inv_coeff=True, ctrl='e') Qn = diagQ[n] self += StorageLinear(label + 'Q' + str(n), nodes, value=Qn, inv_coeff=False, ctrl='f') N = Ncomp
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) dic = {'A': 1e2, # [N.s/m] Felt damping coefficient 'B': 2.5, # [#] Hysteresis coefficient for the felt 'F': 13.8, # [N/m] Elastic characteristic force 'L': 1.5*1e-2, # [m] Height of the felt at rest } dic.update(kwargs) dicpars, subs = mappars(self, **dic) # parameters pars = ['L', 'F', 'A', 'B'] L, F, A, B = symbols(pars) N1, N2 = nodes xnl = symbols('q'+label) hnl = sp.Piecewise((0., xnl <= 0.), ((L*F/(B+1))*(xnl/L)**(B+1), True)) hnl = hnl.subs(dicpars) # edge data data = {'label': xnl, 'type': 'storage', 'ctrl': 'e', 'link': None} self.add_edges_from([(N1, N2, data), ]) self.core.add_storages(xnl, hnl) r = sp.Piecewise((0., xnl <= 0.), ((A * L/B)*(xnl/L)**(B-1), True)) r = r.subs(dicpars) wnl = symbols('dtq'+label) # edge data data = {'label': wnl, 'type': 'dissipative', 'ctrl': 'e', 'z': {'e_ctrl': r*wnl, 'f_ctrl': sp.sympify(0)}, 'link': None} self.add_edges_from([(N1, N2, data), ]) self.core.add_dissipations(wnl, r*wnl) self.core.subs.update(subs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if 'p' not in kwargs: p = 1 else: p = kwargs.pop('p') if 'alpha' not in kwargs: alpha = 0.5 else: alpha = kwargs.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(p, alpha, **kwargs) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes for n in range(nbPoles): Rn = diagR[n] # here, diagR[n] is a conductance (e-ctrl) N1 = 'N' + label + str(n) + "_1" N2 = 'N' + label + str(n) + "_2" self += DissipativeLinear(label + 'R' + str(n), (N1, Ndeb), inv_coeff=True, coeff=Rn, ctrl='e') Qn = diagQ[n] self += StorageLinear(label + 'Q' + str(n), (N2, datum), value=Qn, ctrl='f', inv_coeff=False) self += Transformer(label + 'alpha' + str(n), (N1, Nend, N2, datum), alpha=Rn**-1)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) parameters = parametersDefault(self.metadata['parameters']) parameters.update(kwargs) g = parameters.pop('g') alpha = parameters.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(g, alpha, **parameters) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes N1 = Ndeb for n in range(nbPoles): if n < nbPoles - 1: N2 = 'N' + label + str(n) + "_1" else: N2 = Nend Rn = diagR[n] # here, diagR[n] is a res (flux-controlled) self += DissipativeLinear(label + 'R' + str(n), (N2, N1), ctrl='f', coeff=Rn, inv_coef=False) Qn = diagQ[n] N3 = 'N' + label + str(n) + "_2" self += StorageLinear(label + 'Q' + str(n), (N3, datum), value=Qn, inv_coeff=False, ctrl='e') Nend = nodes[1] self += Transformer(label + 'alpha' + str(n), (N1, N2, N3, datum), alpha=Rn) N1 = N2
def __init__(self, label, nodes, **kwargs): # instanciate a Graph object Graph.__init__(self, label=label) assert 'file' in kwargs, "pwl.dissipative component need 'file' argument" path = kwargs.pop('file') data = np.vstack(map(np.array, data_generator(path))) w_vals = data[0, :] z_vals = data[1, :] assert all(z_vals[np.nonzero(w_vals >= 0)] >= 0), 'All values z(w) for\ w>=0 must be non-negative (component {})'.format(label) assert all(z_vals[np.nonzero(w_vals >= 0)] >= 0), 'All values z(w) for\ w<0 must be negative (component {})'.format(label) assert all(z_vals[np.nonzero(w_vals == 0)] == 0), 'z(0) must be zero \ (component {})'.format(label) ctrl = kwargs.pop('ctrl') # state variable w = symbols("w" + label) # storage funcion z = pwl_func(w_vals, z_vals, w, **kwargs) # edge data data = {'label': w, 'type': 'dissipative', 'ctrl': ctrl, 'link': None} N1, N2 = nodes # edge edge = (N1, N2, data) # init component self += edges.DissipativeNonLinear(label, [ edge, ], w, z, **kwargs)
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if not isinstance(kwargs['value'], Argument): coeff = Argument(label + 'coeff', kwargs['value']) else: coeff = kwargs['value'] x = nicevarlabel("x", label) x = self.core.symbols(x) if kwargs['inv_coeff']: coeff.symb = coeff.symb**-1 H = coeff.symb * x**2/2. self.core.add_storages([x], H) edge_data_dic = {'label': x, 'type': 'storage', 'ctrl': kwargs['ctrl'], 'link': None} edge = (nodes[0], nodes[1], edge_data_dic) self.add_edges_from([edge]) self.core.subs.update(coeff.sub) if len(coeff.sub) == 0 and kwargs['inv_coeff']: self.core.p += [coeff.symb**-1, ] elif len(coeff.sub) == 0: self.core.p += [coeff.symb, ]
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) if not isinstance(kwargs['coeff'], Argument): coeff = Argument(label + 'coeff', kwargs['coeff']) else: coeff = kwargs['coeff'] w_label = nicevarlabel("w", label) w = self.core.symbols(w_label) z_f_ctrl = coeff.symb*w z_e_ctrl = w/coeff.symb if 'inv_coeff' in kwargs and kwargs['inv_coeff']: z_f_ctrl, z_e_ctrl = z_e_ctrl, z_f_ctrl self.core.add_dissipations([w], [z_f_ctrl]) edge_data_dic = {'label': w, 'type': 'dissipative', 'ctrl': '?', 'z': {'e_ctrl': z_e_ctrl, 'f_ctrl': z_f_ctrl}, 'link': None} edge = (nodes[0], nodes[1], edge_data_dic) self.add_edges_from([edge]) self.core.subs.update(coeff.sub) if len(coeff.sub) == 0: self.core.p += [coeff.symb, ]
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) parameters = parametersDefault(self.metadata['parameters']) parameters.update(kwargs) g = parameters.pop('g') beta = parameters.pop('beta') diagR, diagQ = fractionalIntegratorWeights(g, beta, **parameters) # Truncation of poles with null Q nbPoles = diagR.__len__() N, Nend = nodes for n in range(nbPoles): if n < nbPoles - 1: Ncomp = 'iN_' + label + str(n) + 'to' + str(n + 1) else: Ncomp = Nend nodes = (N, Ncomp) # here, diagRmu[n] is a conductance (effort-controlled) Rn = diagR[n] self += DissipativeLinear(label + 'R' + str(n), nodes, coeff=Rn, inv_coeff=True, ctrl='e') Qn = diagQ[n] self += StorageLinear(label + 'Q' + str(n), nodes, value=Qn, inv_coeff=False, ctrl='f') N = Ncomp
def __init__(self, label, nodes, **kwargs): Graph.__init__(self, label=label) parameters = parametersDefault(self.metadata['parameters']) parameters.update(kwargs) g = parameters.pop('g') beta = parameters.pop('beta') self.core.subs.update({ self.core.symbols('g_' + label): g, self.core.symbols('beta_' + label): beta }) diagRmu, diagQmu = fractionalIntegratorWeights(g, beta, **parameters) # Truncation of poles with null Q nbPoles = diagRmu.__len__() for n in range(nbPoles): Rn = diagRmu[n] # here, diagRmu[n] is a resistance (f-ctrl) Nend = nodes[1] Ncomp = 'iN_' + label + str(n) comp = DissipativeLinear('R_' + label + str(n), (Ncomp, Nend), coeff=Rn, ctrl='f') self += comp Qn = diagQmu[n] Ndeb = nodes[0] comp = StorageLinear(label + str(n), (Ndeb, Ncomp), value=Qn, name='pL_', inv_coeff=False, ctrl='e') self += comp
def __init__(self, label, nodes, **kwargs): parameters = parametersDefault(self.metadata['parameters']) parameters.update(kwargs) Graph.__init__(self, label=label) g = parameters.pop('g') alpha = parameters.pop('alpha') diagR, diagQ = fractionalDifferenciatorWeights(g, alpha, **parameters) # Truncation of poles with null Q nbPoles = diagR.__len__() Ndeb, Nend = nodes for n in range(nbPoles): Rn = diagR[n] # here, diagR[n] is a conductance (e-ctrl) N1 = 'N' + label + str(n) + "_1" N2 = 'N' + label + str(n) + "_2" self += DissipativeLinear(label + 'R' + str(n), (N1, Ndeb), inv_coeff=True, coeff=Rn, ctrl='e') Qn = diagQ[n] self += StorageLinear(label + 'Q' + str(n), (N2, datum), value=Qn, ctrl='f', inv_coeff=False) self += Transformer(label + 'alpha' + str(n), (N1, Nend, N2, datum), alpha=Rn**-1)
def __init__(self, label, nodes, **kwargs): pars = parameters_JSV2016() for k in kwargs.keys(): if k not in pars.keys() and str(k)[0] not in 'zw': raise AttributeError('parameter {} unknown'.format(k)) Graph.__init__(self, label=label) pars.update(kwargs) pars.update({ # [kg] Modal mass density 'Mb': pi*(pars['R']**2)*pars['M'], # [N/m] Modal stiffness 'Kb': (pars['E']*pi*pars['R']**4.)/4., }) pars.update({ # [m] Tine length for the fondamental frequency f0[Hz] 'Lb': beamLength(pars['F'], pars['Kb'], pars['Mb']) }) # [1/m] list of the nkmax first cantilever beam modes with length L k, fk = waveNumbers(pars['N'], pars['Lb'], pars['Kb'], pars['Mb']) # truncate below the Nyquist frequency fe/2 # list of the nk first modes below the Nyquist frequency fe/2 [1/m] # k = k[(fk < pars['n']/2).nonzero()] # list of the nk first frequencies below the Nyquist frequency fe/2 [Hz] # fk = fk[(fk < pars['fs']/2).nonzero()] # [#] number of simulated modes pars.update({'kmodes': k, 'fmodes': fk}) pars['N'] = len(pars['kmodes']) # [N/m**1] Modal damping coefficient pars.update({'Ab_array': pars['A']*10**(linspace(0, pars['D'], pars['N']))}) # definition of stiffnesses values coeffs = pars['Kb']*(k.flatten()**4) # definition of stiffnesses components for i, c in enumerate(coeffs): stiffness = Stiffness(label+'K'+str(i), (datum, label+'M'+str(i)), K=(label+'K'+str(i), c)) self += stiffness # definition of masses values coeffs = [pars['Mb']]*pars['N'] # definition of masses components for i, c in enumerate(coeffs): mass = Mass(label+'M'+str(i), (label+'M'+str(i), ), M=(label+'M'+str(i), c)) self += mass # definition of dampers components coeffs = list(pars['Ab_array']) # definition of dampers components for i, c in enumerate(coeffs): damper = Damper(label+'A'+str(i), (datum, label+'M'+str(i)), A=(label+'A'+str(i), c)) self += damper for n, Nn in enumerate(nodes): label_n = label+'T'+str(n) Omega = omega_cosine(pars['z'+str(n+1)]*pars['Lb'], pars['w'+str(n+1)], pars['Lb'], pars['kmodes']) # transformers associated with the coefficients of modal projection # Begining of the serial connection of transformers primals A1 = Nn # tail node for the serial connection of transformers primals if pars['N'] == 1: A2 = datum else: A2 = label_n + str(0) # iterate over coefficients values for i, o in enumerate(Omega): # define transfomer transfo = Transformer(label_n+str(i), (A1, A2, datum, label+'M'+str(i)), alpha=(label_n+'alpha'+str(i), o)) self += transfo # update nodes A1 = label_n+str(i) if i == pars['N']-2: A2 = datum else: A2 = label_n+str(i+1)