Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What is wrong with LTSpice transients?

Status
Not open for further replies.

hewlejd

New Member
Hello all,

I am really trying to like LTSpice, but sometimes I feel like I'm the only one who's working at the relationship. Getting to the point, I have a netlist (.cir) that I originally wrote using ORCAD PSpice 9.2, which performs a 30 second transient analysis. It works wonderfully in PSPice. The simulation is completed almost before I have even released the mouse button after clicking run, and yet, when I open the file in LTSpice (the LT stands for "Life-Time" because that's apparently how long it takes to perform a transient analysis), I have to pretty much throw in the towel after about 400 ms because the simulation speed has shrunk to about 3 ms/s which would require around 2 and a half hours to complete. I have tried playing with the simulation parameters, however, while I have been able to get it to "successfully" complete the simulation in an acceptable amount of time, the results are completely useless.
So,

1) Is LTSpice really that much less powerful than PSpice (since PSpice seems to be able to do the job without even flexing)?

2) If not, what might the real culprit be?

3) Is there any way to get LTSpice's transient analysis to simply mimic that of PSPice? (I would love not to have to go through this every time I run one of my old netlists in LTSpice, assuming it exhibits enough redeeming qualities to even make me want to use it again)

Any help would be greatly appreciated.

My netlist is included below:

Code:
* source NN   

*initial weights
.PARAM w110=-0.7162, w120=-0.1565, w1b0=-0.6006            ; Neuron 1
.PARAM w210=-0.5844, w220=0.9190, w230=0.3115, w2b0=0.8315 ; Neuron 2

* Input Patterns
.PARAM BIAS1=1, BIAS2=1
.PARAM in11=-1, in21=-1
.PARAM in12=-1, in22= 1
.PARAM in13= 1, in23=-1
.PARAM in14= 1, in24= 1

* Desired Outputs
.PARAM dout1=-1, dout2=1, dout3=1, dout4=-1

* Learning Constant
.PARAM alpha=1.5

* Activation function/derivative
.FUNC act(net) = {tanh(net)}
.FUNC der(net) = {1-tanh(net)^2}


* Input 1
Vin11 in11 0 DC {in11}
Vin12 in12 0 DC {in12}
Vin13 in13 0 DC {in13}
Vin14 in14 0 DC {in14}

* Input 2
Vin21 in21 0 DC {in21}
Vin22 in22 0 DC {in22}
Vin23 in23 0 DC {in23}
Vin24 in24 0 DC {in24}

* Desired outputs
Vdout1 dout1 0 DC {dout1}
Vdout2 dout2 0 DC {dout2}
Vdout3 dout3 0 DC {dout3}
Vdout4 dout4 0 DC {dout4}

* Partial derivatives for each weight/pattern
Xpat1 in11 in21 dw21t1 dw22t1 dw23t1 dw2bt1 dw11t1 dw12t1 dw1bt1 w11 w12 w1b w21 w22 w23 w2b out1 dout1 NETWORK
Xpat2 in12 in22 dw21t2 dw22t2 dw23t2 dw2bt2 dw11t2 dw12t2 dw1bt2 w11 w12 w1b w21 w22 w23 w2b out2 dout2 NETWORK
Xpat3 in13 in23 dw21t3 dw22t3 dw23t3 dw2bt3 dw11t3 dw12t3 dw1bt3 w11 w12 w1b w21 w22 w23 w2b out3 dout3 NETWORK
Xpat4 in14 in24 dw21t4 dw22t4 dw23t4 dw2bt4 dw11t4 dw12t4 dw1bt4 w11 w12 w1b w21 w22 w23 w2b out4 dout4 NETWORK

* Gradient update for neuron 2 weights
Ew21   w21  0     VALUE={w210-alpha*(V(dw21t1)+V(dw21t2)+V(dw21t3)+V(dw21t4))}
Ew22   w22  0     VALUE={w220-alpha*(V(dw22t1)+V(dw22t2)+V(dw22t3)+V(dw22t4))}
Ew23   w23  0     VALUE={w230-alpha*(V(dw23t1)+V(dw23t2)+V(dw23t3)+V(dw23t4))}
Ew2b   w2b  0     VALUE={w2b0-alpha*(V(dw2bt1)+V(dw2bt2)+V(dw2bt3)+V(dw2bt4))}

* Gradient update for neuron 1 weights
Ew11   w11  0     VALUE={w110-alpha*(V(dw11t1)+V(dw11t2)+V(dw11t3)+V(dw11t4))}
Ew12   w12  0     VALUE={w120-alpha*(V(dw12t1)+V(dw12t2)+V(dw12t3)+V(dw12t4))}
Ew1b   w1b  0     VALUE={w1b0-alpha*(V(dw1bt1)+V(dw1bt2)+V(dw1bt3)+V(dw1bt4))}

* Error
Eerr1  err1  0     VALUE={(V(dout1)-V(out1))}
Eerr2  err2  0     VALUE={(V(dout2)-V(out2))}
Eerr3  err3  0     VALUE={(V(dout3)-V(out3))}
Eerr4  err4  0     VALUE={(V(dout4)-V(out4))}
Eerrt  errt  0     VALUE={(V(err1)^2+V(err2)^2+V(err3)^2+V(err4)^2)/4}


													
* ------------ INTEGRATOR ------------ *
.SUBCKT INTEGRATOR in out
	G 1   0 value={V(in)}
	C 0   1 1
	R 0   1 1MEG
	E out 0 1 0 1
.ENDS INTEGRATOR
* ------------------------------------ *


* ------------- NETWORK -------------- *
.SUBCKT NETWORK in1 in2 dw21t dw22t dw23t dw2bt dw11t dw12t dw1bt w11 w12 w1b w21 w22 w23 w2b out2 dout
* Neuron 2
Enet2  net2  0     VALUE={V(w21)*V(in1)+V(w22)*V(in2)+V(w23)*V(out1)+V(w2b)*BIAS2}
Eout2  out2  0     VALUE={act(V(net2))}
Eder2  der2  0     VALUE={der(V(net2))}
Eerr2  err2  0     VALUE={(V(dout)-V(out2))}
Ederr2 derr2 0     VALUE={V(err2)*V(der2)}

Edw21  dw21  0     VALUE={V(in1)*V(derr2)}
Xdw21t dw21  dw21t INTEGRATOR

Edw22  dw22  0     VALUE={V(in2)*V(derr2)}
Xdw22t dw22  dw22t INTEGRATOR

Edw23  dw23  0     VALUE={V(out1)*V(derr2)}
Xdw23t dw23  dw23t INTEGRATOR

Edw2b  dw2b  0     VALUE={BIAS2*V(derr2)}
Xdw2bt dw2b  dw2bt INTEGRATOR

* Neuron 1
Enet1  net1  0     VALUE={V(w11)*V(in1)+V(w12)*V(in2)+V(w1b)*BIAS1}
Eout1  out1  0     VALUE={act(V(net1))}
Eder1  der1  0     VALUE={der(V(net1))}
Eerr1  err1  0	    VALUE={V(w23)*V(derr2)}
Ederr1 derr1 0     VALUE={V(err1)*V(der1)}

Edw11  dw11  0     VALUE={V(in1)*V(derr1)}
Xdw11t dw11  dw11t INTEGRATOR

Edw12  dw12  0     VALUE={V(in2)*V(derr1)}
Xdw12t dw12  dw12t INTEGRATOR

Edw1b  dw1b  0     VALUE={BIAS1*V(derr1)}
Xdw1bt dw1b  dw1bt INTEGRATOR
.ENDS
* ------------------------------------ *

.IC V(w11)={w110} V(w12)={w120} V(w1b)={w1b0} V(w21)={w210} V(w22)={w220} V(w23)={w230} V(w2b)={w2b0}
.TRAN 1MS 30S UIC
.PROBE

.END

I am also including this plot of my PSPice results as an example of what I was hoping to get from LTSpice.

**broken link removed**
 
LTspice is written to be generally syntax compatible with Pspice (as well as a few other popular versions of SPICE). To this end, it often supports multiple syntactical synonyms. However, there are a few operators/functions with mutually exclusive definitions that make it impossible for LTspice to be 100 percent compatible with all other SPICEs (I suppose LTspice could include a syntax mode command, but that might lead to licensing issues).

The most problematic difference between LTspice and Pspice syntax is with the exponentiation operand where LTspice requires two asterisks (**) instead of the Pspice carrot symbol (^). (This is used for the boolean XOR operator in LTspice.)

The bottom line: if you carefully search through your net list and replace all 4 or 5 such instances with the double asterisk, your simulation should run just fine (faster and more accurately, actually) in LTspice.

Regards -- analogspiceman

PS: This is exactly the type help you could get on the (very active) LTspice support group on Yahoo.
 
Thank you

You are a life saver. I can not thank you enough. This is like music to my ears. Again thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top