The reflection coefficient, gamma, defined as Vreflected/Vforward, is obtained as follows:
z0=50.0+0.0j # define system impedance cv1=1.0+0.0j # V1 as a complex number cv2=vratio*(cos(phase2advance)+sin(phase2advance)*1.0j) # V2 as a complex number cvr=2.0*cv1-cv2 # V(R3) cz=z0*(cv2/cvr) # the same current for both DUT and R3 gamma1=(cz-z0)/(cz+z0) # a well-known formula swr=(1+abs(gamma))/(1-abs(gamma)) # another well-known formula # another method cvfwd=cv1 cvrfl=cv2-cv1 gamma2=cvrfl/cvfwd # check yourself that gamma1 and gamma2 are the same # # checking now # gamma1=(cz-z0)/(cz+z0) # a well-known formula =(cz/z0-1)/(cz/z0+1) =(cv2/cvr-1)/(cv2/cvr+1) =(cv2-cvr)/(cv2+cvr) =(cv2-(2.0*cv1-cv2))/(cv2+(2.0*cv1-cv2)) =(2.0*cv2-2.0*cv1)/(2.0*cv1) =(cv2-cv1)/cv1 =cvrfl/cvfwd =gamma2