def plot_power_balance_rlc_with_split(): # Define the simulation parameters config = { 'fs': 48e3, # Sample rate 'grad': 'discret', # in {'discret', 'theta', 'trapez'} 'theta': 0.5, # theta-scheme for the structure 'split': False, # apply core.split_linear() beforehand 'maxit': 10, # Max iteration for NL solvers 'path': path, # Path to the results folder 'pbar': False, # Display a progress bar 'timer': True, # Display minimal timing infos 'lang': 'python', # in {'python', 'c++'} } # retrieve the pyphs.Core of a linear RLC from the examples from pyphs.examples.rlc.rlc import core as rlc rlc_ = rlc.__copy__() rlc_.reduce_z() simu = Simulation(rlc_.to_method(), config=config) dur = 0.01 u = signalgenerator(which='sin', f0=800., tsig=dur, fs=simu.config['fs']) sequ = u[:, np.newaxis] simu.init(u=sequ) simu.process() simu.data.plot_powerbal(mode='single', show=False) simu.data.plot_powerbal(mode='multi', show=False) if not os.name.lower().startswith('nt'): shutil.rmtree(path) return True
def simulation_rlc_without_split(): rlc = core.__copy__() # Define the simulation parameters config = {'fs': 48e3, # Sample rate 'grad': 'discret', # in {'discret', 'theta', 'trapez'} 'theta': 0.5, # theta-scheme for the structure 'split': False, # apply core.split_linear() beforehand 'maxit': 10, # Max iteration for NL solvers 'eps': 1e-16, # Global numerical tolerance 'path': path, # Path to the results folder 'pbar': False, # Display a progress bar 'timer': True, # Display minimal timing infos 'lang': 'python', # in {'python', 'c++'} } simu = Simulation(rlc.to_method(), config=config) dur = 0.01 u = signalgenerator(which='sin', f0=800., tsig=dur, fs=simu.config['fs']) def sequ(): for el in u(): yield (el, ) simu.init(u=sequ(), nt=int(dur*simu.config['fs'])) simu.process() if not os.name.lower().startswith('nt'): shutil.rmtree(path) return True
def plot_power_balance_rlc_with_split(): # Define the simulation parameters config = { 'fs': 48e3, # Sample rate 'gradient': 'discret', # in {'discret', 'theta', 'trapez'} 'theta': 0.5, # theta-scheme for the structure 'split': True, # apply core.split_linear() beforehand 'maxit': 10, # Max iteration for NL solvers 'numtol': 1e-16, # Global numerical tolerance 'path': None, # Path to the results folder 'progressbar': True, # Display a progress bar 'timer': True, # Display minimal timing infos 'language': 'python', # in {'python', 'c++'} 'cpp_build_and_run_script': None, # compile and exec binary 'eigen_path': None, # path to Eigen library } # retrieve the pyphs.PHSCore of a linear RLC from the examples from pyphs.examples.rlc.rlc import core as rlc rlc_ = rlc.__copy__() rlc_.build_R() simu = PHSSimulation(rlc_, config=config) dur = 0.01 u = signalgenerator(which='sin', f0=800., tsig=dur, fs=simu.fs) def sequ(): for el in u(): yield (el, ) simu.init(sequ=sequ(), nt=int(dur * simu.fs)) simu.process() simu.data.plot_powerbal(mode='single', show=False) simu.data.plot_powerbal(mode='multi', show=False) return True
def plot_power_balance_rlc_with_split(): # Define the simulation parameters config = {'fs': 48e3, # Sample rate 'grad': 'discret', # in {'discret', 'theta', 'trapez'} 'theta': 0.5, # theta-scheme for the structure 'split': False, # apply core.split_linear() beforehand 'maxit': 10, # Max iteration for NL solvers 'eps': 1e-16, # Global numerical tolerance 'path': path, # Path to the results folder 'pbar': False, # Display a progress bar 'timer': True, # Display minimal timing infos 'lang': 'python', # in {'python', 'c++'} } # retrieve the pyphs.Core of a linear RLC from the examples from pyphs.examples.rlc.rlc import core as rlc rlc_ = rlc.__copy__() rlc_.reduce_z() simu = Simulation(rlc_.to_method(), config=config) dur = 0.01 u = signalgenerator(which='sin', f0=800., tsig=dur, fs=simu.config['fs']) def sequ(): for el in u(): yield (el, ) simu.init(u=sequ(), nt=int(dur*simu.config['fs'])) simu.process() simu.data.plot_powerbal(mode='single', show=False) simu.data.plot_powerbal(mode='multi', show=False) if not os.name.lower().startswith('nt'): shutil.rmtree(path) return True