def to_method(self, config=None): """ Return the PHS numerical method associated with the PHS core for the specified configuration. Parameter --------- config: dict or None A dictionary of simulation parameters. If None, the standard pyphs.config.simulations is used (the default is None). keys and default values are 'fs': 48e3, # Sample rate (Hz) 'grad': 'discret', # In {'discret', 'theta', 'trapez'} 'theta': 0., # Theta-scheme for the structure 'split': False, # split implicit from explicit part 'maxit': 10, # Max number of iterations for NL solvers 'eps': 1e-16, # Global numerical tolerance Output ------ method : pyphs.Method The PHS numerical method associated with the PHS core for the specified configuration. """ from pyphs import Method return Method(self, config=config)
def to_simulation(self, config=None, inits=None, erase=True): """ Return a simulation associated with the PHS core for the specified configuration. Parameter --------- config: dict or None A dictionary of simulation parameters. If None, the standard pyphs.config.simulations is used (the default is None). keys and default values are 'fs': 48e3, # Sample rate (Hz) 'grad': 'discret', # In {'discret', 'theta', 'trapez'} 'theta': 0., # Theta-scheme for the structure 'split': False, # split implicit from explicit part 'maxit': 10, # Max number of iterations for NL solvers 'eps': 1e-16, # Global numerical tolerance erase : bool (optional) If True and a h5file exists with same path than simulation data, it is erased. Else, it is used to initialize the data object. The default is True. Output ------ simulation : pyphs.Simulation The simulation associated with the PHS core for the specified configuration. """ from pyphs import Method from pyphs.config import CONFIG_METHOD config_method = CONFIG_METHOD.copy() if config is None: config = {} for k in CONFIG_METHOD.keys(): if k in config.keys(): config_method.update({k: config[k]}) method = Method(self, config=config_method) return method.to_simulation(config=config, inits=inits, erase=erase)
def to_simulation(self, config=None, inits=None): """ Return a simulation associated with the PHS core for the specified configuration. Parameter --------- config: dict or None A dictionary of simulation parameters. If None, the standard pyphs.config.simulations is used (the default is None). keys and default values are 'fs': 48e3, # Sample rate (Hz) 'grad': 'discret', # In {'discret', 'theta', 'trapez'} 'theta': 0., # Theta-scheme for the structure 'split': False, # split implicit from explicit part 'maxit': 10, # Max number of iterations for NL solvers 'eps': 1e-16, # Global numerical tolerance Output ------ simulation : pyphs.Simulation The simulation associated with the PHS core for the specified configuration. """ from pyphs import Method from pyphs.config import CONFIG_METHOD config_method = CONFIG_METHOD.copy() if config is None: config = {} for k in CONFIG_METHOD.keys(): if k in config.keys(): config_method.update({k: config[k]}) method = Method(self, config=config_method) return method.to_simulation(config=config, inits=inits)
Jxx = numpy.array([[0., -1.], [1., 0.]]) core.set_Jxx(Jxx) # Physical parameters F0 = 100. L_value = 5e-1 # 500mH # f0 = (2*pi*sqrt(L*C))**-1 C_value = (2 * numpy.pi * F0)**-2 / L_value # ?F # Dictionary with core.symbols as keys and parameters value as values subs = {L: L_value, C: C_value} core.subs.update(subs) core.linear_nonlinear() # instantiate a pyphs.Evaluation object associated with a pyphs.Core method = Method(core) #method.dxH = list(map(lambda g: g.subs(dict([(ex, ex+ 0.5*edx) for ex, edx in zip(core.x, core.dx())])), core.dxH())) method.dxH = core.dxH() # Explicit Euler update: # dx = Mxx*dxH(x) + Mxy*u # x = x + dx # Mxx * dxH op_MxxDotdxH = method.Operation('dot', ('Mxx', 'dxH')) # Mxy * u op_MxyDotU = method.Operation('dot', ('Mxy', 'u')) # Mxx * dxH + Mxy * u