Достал здесь spice-модель трансформатора. Надо её заставить работать с ngspice на низких напряжениях.
V1 P2 P1 SIN(0 50 50)
R1 P1 P3 0.001
XMYNLTRN_T1 P3 P2 P4 P5 nl_transformer_1_0
R2 P4 P7 0.001
R3 P7 P5 res2
* transformer
.SUBCKT nl_transformer_1_0 2 1 4 3
R0 2 5 66
L0 5 6 146m
A0 (6 1) (7 0) nlt_pq_4_10_lcpl_0
A1 (7 8) nlt_pq_4_10_mcore
A2 (8 0) (9 3) nlt_pq_4_10_lcpl_1
L1 9 10 1.11m
R1 10 4 500m
.ENDS
.MODEL nlt_pq_4_10_lcpl_0 lcouple(num_turns=1.622K)
.MODEL nlt_pq_4_10_mcore core(
+ H_array=[0 13.89 51.58 222.22]
+ B_array=[0 1 1.5 1.7]
+ area=130u length=76.15m
+ input_domain=10m fraction=TRUE mode=1)
.MODEL nlt_pq_4_10_lcpl_1 lcouple(num_turns=141)
.control
tran 0.1ms 2000ms
let v1 = v(P2,P3)
let cur1 = v(P3,P1)*1e3
* let pw1 = cur1*v1
let v2 = v(P5,P4)
let cur2 = v(P7,P4)*1e3
* let pw2 = cur2*v2
run
meas tran V1 RMS v1
meas tran I1 RMS cur1
* meas tran P1 RMS pw1
meas tran V2 RMS v2
meas tran I2 RMS cur2
* meas tran P2 RMS pw2
.endc
.end
Работает как-то нестабильно. Что с ней не так?
$ echo -e "\n.param res2 = 30\n"| cat - spice/experiment-vac.cir|ngspice
Circuit:
Reducing trtol to 1 for xspice 'A' devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Warning: v1: no DC value, transient time 0 value used
Initial Transient Solution
--------------------------
Node Voltage
---- -------
p2 0
p1 0
p3 0
xmynltrn_t1.5 0
xmynltrn_t1.6 0
xmynltrn_t1.7 0
xmynltrn_t1.8 0
xmynltrn_t1.9 0
p5 0
xmynltrn_t1.10 0
p4 0
p7 0
l.xmynltrn_t1.l1#branch 0
l.xmynltrn_t1.l0#branch 0
v1#branch 0
a.xmynltrn_t1.a2#branch_0_0 0
a.xmynltrn_t1.a2#branch_1_0 0
a.xmynltrn_t1.a0#branch_0_0 0
a.xmynltrn_t1.a0#branch_1_0 0
doAnalyses: TRAN: Timestep too small; time = 0.0400057, timestep = 8.43038e-16: trouble with node "p2"
tran simulation(s) aborted
Reducing trtol to 1 for xspice 'A' devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Warning: v1: no DC value, transient time 0 value used
v1 = 3.53529e+01 from= 0.00000e+00 to= 4.00057e-02
left-hand expression is too small (need 1320201)
i1 = 8.64156e-03 from= 0.00000e+00 to= 4.00057e-02
v2 = 1.63149e-02 from= 0.00000e+00 to= 4.00057e-02
left-hand expression is too small (need 1320201)
i2 = 5.43811e-04 from= 0.00000e+00 to= 4.00057e-02
Note: No ".plot", ".print", or ".fourier" lines; no simulations run