
header <napatool.hdr>

title  "Intermodulation, a theoretical study"

fs     1.0e9

dvar   k3   -0.01       // in physical circuit, signal is clipped, k3 must therefore be negative
dvar   k2    0.1
dvar   k1    1.0

dvar   f1   10.0e6
dvar   f2   f1 + 1.0e6

dvar   f12  2.0*f1 - f2
dvar   f21  2.0*f2 - f1

dvar   a0   1.0

ivar    n   POWEROF2(18)

#*  DUT

node  in1  cosine   0.0  a0 f1 0.0
node  in2  cosine   0.0  a0 f2 0.0
node  in   sum   in1  in2

node   s0  poly  k3 k2 k1 0.0  in


#*  Theory   Third Order Product Only

node   s1  cosine   0.0 1.0  f12 0.0
node   s2  cosine   0.0 1.0  f21 0.0

node   s4  dalgebra  0.75*a0*a0*a0*k3*(s1 + s2)

directive  WINDOW   BLACKMAN_HARRIS_7

tool   fft  "~/Output/fftim.out"    in 1.0  n
tool   fft  "~/Output/fftima.out"   s0 1.0  n
tool   fft  "~/Output/fftimb.out"   s4 1.0  n

tool  tsnr  "~/Output/tsnrim.out"   in 1.0  n
tool  tsnr  "~/Output/tsnrima.out"  s0 1.0  n
tool  tsnr  "~/Output/tsnrimb.out"  s4 1.0  n

terminate  1 <= TOOL_INDEX