#This example runs a schematic then displays the RMS value of the output. # The RMS value is calculated in Python code within - see funcion rms() below # import simetrix module import simetrix as sx import math # Function to calculate RMS def rms(y, x) : prev_y = y[0] prev_x = x[0] ss = 0 for idx, v in enumerate(y): time = x[idx] ss = ss + (v*v + prev_y*prev_y + v*prev_y)/3 * (time-prev_x) prev_y = v prev_x = time return math.sqrt(ss/prev_x) # Open the schematic. The second argument, sx.SchematicOptions.VISIBLE # states that the schematic should be opened in the GUI. If omitted # the schematic would be opened behind the scenes but not made visible schem = sx.openSchematic("amp.sxsch", sx.SchematicOptions.VISIBLE) # Run simulation sim = schem.run() # Get data group created by simulation dataGroup = sim.primaryGroup # Get VOUT vector vout = dataGroup.vectorOfName("VOUT") # Display RMS value of output print("RMS=", rms(vout.ydata, vout.xdata))