*simulation template for time domain gft *#save v(x:xgft) v(y:xgft) v(cos:xgft) v(sin:xgft) *#save @Vx:Xgft[i] @Vy:Xgft[i] * *#save all tran {TSTEP} {T1+3*(T5-T1)} 0 {TMAX} UIC if isdef(v(x:xgft)) constants.del = {T4-T3} constants.tstart = {T3} constants.period = {T5-T1} *For Av_iy = 1 / Tv_iy *Setcursors to the end of the null iy test constants.t0 = tstart constants.t1 = tstart + del setcursor 0 t0 setcursor 1 t1 rex = (v(x:xgft)-average(v(x:xgft)))*v(cos:xgft) imx = (v(x:xgft)-average(v(x:xgft)))*v(sin:xgft) rey = (v(y:xgft)-average(v(y:xgft)))*v(cos:xgft) imy = (v(y:xgft)-average(v(y:xgft)))*v(sin:xgft) cx_iy = (average(rex),average(imx)) cy_iy = (average(rey),average(imy)) Av_iy = cx_iy / cy_iy * * use A = 1/T to avoid divide by zero *For Av_ix = 1 / Tv_ix *Setcursors to the end of the null ix test * don't do this BLOCK, it's not needed *constants.t0 = constants.t0 + period *constants.t1 = constants.t0 + del *setcursor 0 t0 *setcursor 1 t1 *rex = (v(x:xgft)-average(v(x:xgft)))*v(cos:xgft) *imx = (v(x:xgft)-average(v(x:xgft)))*v(sin:xgft) *rey = (v(y:xgft)-average(v(y:xgft)))*v(cos:xgft) *imy = (v(y:xgft)-average(v(y:xgft)))*v(sin:xgft) *cx_ix = (average(rex),average(imx)) *cy_ix = (average(rey),average(imy)) *Av_ix = cx_ix / cy_ix * *For Ai_vy = 1 / Ti_vy *Setcursors to the end of the null vy test constants.t0 = constants.t0 + period constants.t1 = constants.t0 + del setcursor 0 t0 setcursor 1 t1 rex = (@Vx:Xgft[i]-average(@Vx:Xgft[i]))*v(cos:xgft) imx = (@Vx:Xgft[i]-average(@Vx:Xgft[i]))*v(sin:xgft) rey = (@Vy:Xgft[i]-average(@Vy:Xgft[i]))*v(cos:xgft) imy = (@Vy:Xgft[i]-average(@Vy:Xgft[i]))*v(sin:xgft) cix_vy = (average(rex),average(imx)) ciy_vy = (average(rey),average(imy)) Ai_vy = cix_vy / ciy_vy * *For Ai_vx = 1 / Ti_vx *Setcursors to the end of the null vx test constants.t0 = constants.t0 + period constants.t1 = constants.t0 + del setcursor 0 t0 setcursor 1 t1 rex = (@Vx:Xgft[i]-average(@Vx:Xgft[i]))*v(cos:xgft) imx = (@Vx:Xgft[i]-average(@Vx:Xgft[i]))*v(sin:xgft) rey = (@Vy:Xgft[i]-average(@Vy:Xgft[i]))*v(cos:xgft) imy = (@Vy:Xgft[i]-average(@Vy:Xgft[i]))*v(sin:xgft) cix_vx = (average(rex),average(imx)) ciy_vx = (average(rey),average(imy)) Ai_vx = cix_vx / ciy_vx * Aiv = Ai_vx * Av_iy T = 1 / (Ai_vy + Av_iy + Aiv) gain = db(T) phase = -phase(T) printstatus -t "gain = " printstatus -v gain printstatus -t "phase = " printstatus -v phase print gain phase else printstatus -t " You need to name the GFTs subcircuit Xgft " printstatus -t end