# ----------------------------- CORES ------------------------------------- # this_script = os.path.realpath(__file__) here = this_script[:this_script.rfind(os.sep)] def netlist_path(label): return here + os.sep + label + '.net' def sort_outputs(core): for i in range(core.dims.y()): if not str(core.y[i]).endswith(str(i+1)): core.move_port([str(y).endswith(str(i+1)) for y in core.y].index(True), i) # build simple PHSCores c1 = netlist2core(netlist_path('phs1')) sort_outputs(c1) c2 = netlist2core(netlist_path('phs2')) sort_outputs(c2) # concatenate c1 and c2 into a new PHSCore core = c1 + c2 # define the connection core.add_connector((core.y.index(c1.y[1]), core.y.index(c2.y[1])), alpha=1) # apply the connection core.apply_connectors() # target structure matrix target = array([[0, -1, 1, 0],
import os from pyphs import (netlist2core, PHSSimulation, signalgenerator, PHSNetlist, PHSGraph) from pyphs.misc.signals.analysis import transferFunction import matplotlib.pyplot as plt import numpy as np label = 'fractional_derivator_ec' path = os.path.realpath(__file__)[:os.path.realpath(__file__).rfind(os.sep)] netlist_filename = path + os.sep + label + '.net' netlist = PHSNetlist(netlist_filename) graph = PHSGraph(netlist=netlist) core = netlist2core(netlist_filename) if __name__ == '__main__': # UNCOMMENT BELOW FOR SIMULATION and PLOT OF TRANSFER FUNCTION # !!! Very long simulation with numpy # config = {'fs': 48e3, # 'split': True, # 'pbar': True, # 'timer': True, # 'lang': 'python' # } # # simu = PHSSimulation(core, config=config) # # dur = 10.