I am studying a circuit which will charge a capacitor till using a voltage doubler till it reaches a specified voltage value. Then it will discharge through a resistor. An SPDT switch is realised for this function using 2 SPST switches. A behavioral source is used to control these switches. But the simulation is getting stuck when this switching is about to happen. Any idea why this is happening
Version 4
SHEET 1 2296 680
WIRE 400 -112 80 -112
WIRE 656 -96 640 -96
WIRE 400 -48 400 -112
WIRE 656 16 656 -96
WIRE 400 64 400 16
WIRE 400 64 320 64
WIRE 496 64 400 64
WIRE 512 64 496 64
WIRE 640 64 576 64
WIRE 768 64 720 64
WIRE 848 64 768 64
WIRE 1024 64 928 64
WIRE 320 80 320 64
WIRE 400 80 400 64
WIRE 1024 80 1024 64
WIRE 80 96 80 -112
WIRE 496 96 496 64
WIRE 768 128 768 64
WIRE 320 208 320 144
WIRE 400 208 400 144
WIRE 80 224 80 176
WIRE 1472 224 1472 192
WIRE 496 288 496 160
WIRE 768 288 768 192
WIRE 768 288 496 288
WIRE 1024 288 1024 160
FLAG 80 224 0
FLAG 400 208 0
FLAG 320 208 0
FLAG 1472 224 0
FLAG 1472 112 Vc1
FLAG 864 16 Vc1
FLAG 912 16 0
FLAG 768 64 Vout
FLAG 1360 192 0
FLAG 1360 112 Vdc
FLAG 1024 288 0
FLAG 768 288 0
FLAG 576 -96 Vc1
FLAG 704 16 0
SYMBOL voltage 80 80 R0
WINDOW 123 0 0 Left 0
WINDOW 39 24 124 Left 2
SYMATTR SpiceLine Rser=100
SYMATTR InstName V1
SYMATTR Value SINE(0 220 60)
SYMBOL cap 384 -48 R0
SYMATTR InstName C1
SYMATTR Value 30pF
SYMATTR SpiceLine Rser=0.1
SYMBOL diode 512 80 R270
WINDOW 0 32 32 VTop 2
WINDOW 3 0 32 VBottom 2
SYMATTR InstName D1
SYMBOL diode 512 160 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D2
SYMBOL cap 752 128 R0
SYMATTR InstName C3
SYMATTR Value 100n
SYMATTR SpiceLine Rser=2
SYMBOL cap 304 80 R0
SYMATTR InstName C4
SYMATTR Value 30pF
SYMATTR SpiceLine Rser=0.1
SYMBOL cap 384 80 R0
SYMATTR InstName C2
SYMATTR Value 30pF
SYMATTR SpiceLine Rser=0.1
SYMBOL res 1008 64 R0
SYMATTR InstName R1
SYMATTR Value 1Meg
SYMBOL bv 1472 96 R0
SYMATTR InstName B1
SYMATTR Value V=if(V(Vout)>V(Vdc),5,0)
SYMBOL voltage 1360 96 R0
SYMATTR InstName V2
SYMATTR Value 145V
SYMBOL sw 944 64 R90
SYMATTR InstName SW3
SYMATTR Value S3
SYMBOL sw 736 64 R90
SYMATTR InstName SW1
SYMATTR Value S3
SYMBOL Digital\\inv 576 -160 R0
SYMATTR InstName A1
SYMATTR Value2 Vhigh=5 Vlow=0
TEXT 48 248 Left 2 !.tran 300 startup uic
TEXT 592 392 Left 2 ;.step param C LIST 100n 1u 10u
TEXT 592 432 Left 2 ;.meas TRAN t9 FIND time WHEN V(Vout)=145 TD=0 FALL=1
TEXT 592 464 Left 2 !.model S3 SW(Ron=125 Roff=1000000G Vt=2.5 Vh=-1.5)