* Z:\home\khalils\Downloads\files\data\raw_asc\09bcc0388056_Eg1.asc
* Generated by LTspice 26.0.1 for Windows.
* .ac oct 10 .1 10Meg\n.param freq=0
* This example shows the basic principle of extracting\nthe small signal AC characteristics from time domain simulation.\n \nAfter running the simulation, execute menu command\nView=>SPICE Error Log. Then right click and select\n"Plot .step'ed .meas data". Press "yes" to the dialog\nasking if it should combine the data to complex numbers.
* To use this technique in your\nown simulations, include these\n.measure statements
* Library below included based on ModelFile attribute of instance XU1 (C:\users\khalils\AppData\Local\LTspice\lib\sym\OpAmps\UniversalOpAmp2.asy)
XU1 0 B +V -V N001 level2 Avol=1Meg GBW=10Meg Slew=10Meg Ilimit=25m Rail=0 Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
R2 A 0 1K
V3 A B SINE(0 10m {Freq}) ac 1
V2 -V 0 -5
V1 +V 0 5
R1 N001 A 10K
.tran 0 {5/Freq+.1m} .1m
.step oct param Freq .1 10Meg 3
.measure Aavg avg V(a)
.measure Bavg avg V(b)
.measure Are avg (V(a)-Aavg)*cos(360*time*Freq)
.measure Aim avg -(V(a)-Aavg)*sin(360*time*Freq)
.measure Bre avg (V(b)-Bavg)*cos(360*time*Freq)
.measure Bim avg -(V(b)-Bavg)*sin(360*time*Freq)
.measure GainMag param 20*log10(hypot(Are,Aim) / hypot(Bre,Bim))
.measure GainPhi param mod(atan2(Aim, Are) - atan2(Bim, Bre)+180,360)-180
.save V(a) V(b)
.option nomarch
.option plotwinsize=0 numdgt=15
.lib UniversalOpAmp2.lib
.backanno
.end

* LTspice schematic (.asc):
Version 4
SHEET 1 4156 1252
WIRE 1424 544 1392 544
WIRE 1520 544 1504 544
WIRE 1696 544 1520 544
WIRE 1856 544 1776 544
WIRE 1936 576 1936 560
WIRE 2032 576 2032 560
WIRE 1520 640 1520 544
WIRE 1552 640 1520 640
WIRE 1584 640 1552 640
WIRE 1696 640 1664 640
WIRE 1760 640 1696 640
WIRE 1856 656 1856 544
WIRE 1856 656 1824 656
WIRE 1760 672 1744 672
WIRE 1936 672 1936 656
WIRE 2032 672 2032 656
RECTANGLE Normal 2608 976 1488 720 2
SYMBOL voltage 2032 560 R0
SYMATTR InstName V2
SYMATTR Value -5
SYMBOL voltage 1936 560 R0
SYMATTR InstName V1
SYMATTR Value 5
SYMBOL res 1792 528 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 10K
SYMBOL res 1520 528 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 1K
SYMBOL VOLTAGE 1568 640 M90
WINDOW 0 -32 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName V3
SYMATTR Value SINE(0 10m {Freq})
SYMATTR Value2 ac 1
SYMBOL Opamps\\UniversalOpamp2 1792 656 R0
SYMATTR InstName U1
FLAG 1552 640 A
FLAG 1696 640 B
FLAG 1936 672 0
FLAG 2032 672 0
FLAG 1936 560 +V
FLAG 1792 624 +V
FLAG 2032 560 -V
FLAG 1792 688 -V
FLAG 1744 672 0
FLAG 1392 544 0
TEXT 2200 560 Left 2 !.tran 0 {5/Freq+.1m} .1m\n.step oct param Freq .1 10Meg 3
TEXT 1504 752 Left 2 !.measure Aavg avg V(a)\n.measure Bavg avg V(b)\n.measure Are avg  (V(a)-Aavg)*cos(360*time*Freq)\n.measure Aim avg -(V(a)-Aavg)*sin(360*time*Freq)\n.measure Bre avg  (V(b)-Bavg)*cos(360*time*Freq)\n.measure Bim avg -(V(b)-Bavg)*sin(360*time*Freq)\n.measure GainMag param 20*log10(hypot(Are,Aim) / hypot(Bre,Bim))\n.measure GainPhi param mod(atan2(Aim, Are) - atan2(Bim, Bre)+180,360)-180
TEXT 2200 448 Left 2 !.save V(a) V(b)\n.option nomarch\n.option plotwinsize=0 numdgt=15
TEXT 2200 648 Left 2 ;.ac oct 10 .1 10Meg\n.param freq=0
TEXT 1856 248 Center 2 ;This example shows the basic principle of extracting\nthe small signal AC characteristics from time domain simulation.\n \nAfter running the simulation, execute menu command\nView=>SPICE Error Log.  Then right click and select\n"Plot .step'ed .meas data".  Press "yes" to the dialog\nasking if it should combine the data to complex numbers.
TEXT 2200 784 Left 2 ;To use this technique in your\nown simulations, include these\n.measure statements