Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Spice3f5 on Visual Studio express ?

Status
Not open for further replies.

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Hi ! Has anybody succeeded on porting the Spice3f5 code to Visual Studio Express?

I really would like to single-step thru that code and learn the internals of it....

Could anybody help?


I cannot figure how to port this.
I would be very greatful if somebody could share their visual studio project folder.

Kindest regards,

StoppTidigare
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
spice is a commandline tool in c.
original spice3f series has support for msvc (under msdos).

no official support for vcexpress.

but there are other derivatives from spice3fx ported for windows
compilation.

srizbf
6thmay2010
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
There is a one guy Ray from Rayslogic that has published how to modify
the the .bat-files for Microsoft C 5.1 to the Visual Studio Express C/C++ compiler.

But I need to work in a code development enviroment to be able to get a overview
more easily, since I would like to step through the code.

I've found a projectfile on
http://code.google.com/p/afdgp/downloads/detail?name=spice3f5-msvc.rar&can=2&q=

I get no build errors but running a spice command like
spice inputfile.cir -o outputfile.out

doesn't do anything...
Am I doing something wrong? I am a complete visual studio beginner.

Greatful for help

P.S. Where can I find the Spice3fx projects you mentioned?
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
the command line you mentioned is one option.

but the link you mentioned seems to be the source code (i have to verify it ).

let me know your requirement first .

are you learning spice ? or already familiar with
commandline spice tools ? i.e , you have already used
a 'spice' program ?

based on your requirement i hope i can
give some path...

srizbf
6thmay2010
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Yes, the link that I've pasted is a Visual Studio Express project folder with the Spice3f5 source code, without any build errors.

And that is exactly what I want, because my ambition is only to study the internals of Spice, but when running that ported Spice3f5 code it doesn't do anything....

At least I cannot get it to accept any spice command.

When the dos commandwindow comes up, when running the code, shouldn't I be able to run a spice-command ??

Kindest regards,
StoppTidigare
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
as you have already mentioned that you wanted to
know internals of spice , it means (or what i meant)
is 'how spice algorithms ' work.

anyway ,

if you have already built the exe file form the google source you mentioned ,

open a command window first.(run cmd.exe)

if your input file is 'abc.cir' , give the command as:

spice.exe -r abc.raw -b abc.cir

or in a simple simulation ,

spice -b abc.cir

for learning take a small circuit file as:

one battery , two resistors .
check your binary built .

if no errors are output then
you can proceed further.

if required more please post.
srizbf
7thmay2010
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Thanks for your answers friend,

but I still have the problem with that I have no workable visual studio project file.

I cannot make this project file I posted a link to to work.

Could you try it out?
And give your opinion?

Maybe I lack knowledge in how to work in Visual Studio...

Kindest regards,
StoppTidigare

If I cannot find a workable visual studio express project on Spice3f5,
I will have to pay microsoft support, and that will make a big hole in my wallet.
 

srizbf

Advanced Member level 5
Joined
Apr 3, 2010
Messages
1,995
Helped
417
Reputation
840
Reaction score
328
Trophy points
1,363
Activity points
10,985
instead my suggestion is to use mingw for such work.
it costs you 'zero' amount in your currency.
it does a windows compilation.

i suggest you to use an already built spice binary
instead of compiling and solving the building problems...

learning 'spice' then becomes learning to use the tool for building ...

i suggest to use an already available bnary..

post if you require it still.
srizbf
8thmay2010
 

romesh

Newbie level 4
Joined
Jun 7, 2008
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,305
HI
I tried it this way and it works perfactly fine
I guess you are trying to view to output file but it dont have the simulation results
just try it this way
spice3f5.exe -b netlistname.cir
and then it will generate a rawspice.raw file that contains everything and u can use this to plot your outputs
 

rapidcoder

Junior Member level 2
Joined
Jan 17, 2011
Messages
23
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Activity points
1,514
A much easier way to get to know how simulators work is just to study some book or articles on it. The original spice source code is extremely low-level and bloated (and by the way - inefficient). It is hard to understand such code, and even harder to understand the general algorithms and concepts from just reading the code. For example - to define a generic model you have to provide like 20 functions or more, even if it is a component as simple as an ideal resistor or a capacitor. In reality to precisely describe a resistor you just need one equation - the Ohm's law. Similarily for capacitor and inductor - just one short equation. The rest of the code is just accidental complexity, coming from ancient technology and ancient tools. Studying it makes no use.
 

romesh

Newbie level 4
Joined
Jun 7, 2008
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,305
yes u r absolutely right but to get the feeling how a simulator works just try to make one nothing can give u better understanding then that and spice3 source code is still useful in plenty of applications like when you want to include some new features or want to test your new devices with some addition in original BSIM3 or 4. Does it makes sense ?? :grin:
 

rapidcoder

Junior Member level 2
Joined
Jan 17, 2011
Messages
23
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Activity points
1,514
Yes, it makes sense. Nevertheless it will be hard. Even changing a single model equation might be hard, because you have to symbolically recalculate the Jacobian formulas for that model - spice does not do it automatically like the simulator engine we are currently building. If you do it wrong, you will bring the whole simulator down (= unpredictable convergence errors*; SPICE2 had some bugs of this kind). And adding something big like a new kind of analysis might be just as hard as creating your own engine from scratch. Which means, you have to know lot about simulation before you actually touch any line of code.


* The hardest part of it is that not all of convergence errors are caused by bugs in the code. So if you encounter one, you may be never sure if it is the problem with your model modification, or just a property of SPICE. For example the NR and matrix-inversion algorithms used in SPICE do not control the level of numeric round-off errors, thus they do not guarantee neither local nor global convergence. Another source of failures are non-linearities in the models (affect mostly DC analysis).
 
Last edited:

romesh

Newbie level 4
Joined
Jun 7, 2008
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,305
yes i know and m doing it since last 1 yr without much trouble for going through your convergence issues you can use source stepping gmin stepping or best way to go is use homotopy with modified newton method are a lot of excellent papers on it through which you can go through. Which can provide you enough insight even to solve upto bistable latch or chua's circuit on your own :)
 
Last edited:

rapidcoder

Junior Member level 2
Joined
Jan 17, 2011
Messages
23
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Activity points
1,514
Just out of curiosity, what features have you added to spice? Just modifed some models or something larger? :)
 

romesh

Newbie level 4
Joined
Jun 7, 2008
Messages
5
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,305
My MS project is to make changes in spice3f5 so it can be both and there are so many unresolved issues with spice to work on :)
and when it will be done i will put the post over here. is it fine with you ?
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Wow guys! Thanks for picking up the thread. Haven't visited edaboard since I posted my last on this thread. And I am returning now just in time to hear you guys discussing!!! Fate. Good Karma!

So one can actually run the project that I linked to??? Must test it. It was so long ago, I don't have any .cir files to test with. Can you romesh
please send me something simple to test the commando you suggest?

OK guys I am interested in the mathematics of transient analysis and I picked up differentating the Jacobian and Modified Newton..
Nice info.
Please tell me something about the mathematics behind transient analysis.
I am now studying numerical solutions of ODE with Runge-Kutta Methods of John Butcher
Index for tutorials
Is there a certain branch of Ordinary DE that I should study?
Please give me a pointer to a numerical methods book that really goes deep in these issues.
Kindest regards,
StoppTidigare
 

rapidcoder

Junior Member level 2
Joined
Jan 17, 2011
Messages
23
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Activity points
1,514
This book is good: Amazon.com: Circuit Simulation Methods and Algorithms (Electronic Engineering Systems) (9780849378942): Jan Ogrodzki: Books
I know the author personally ;)

Runge-Kutta is not useful for circuit simulation because it is not A-stable.
The most commonly used integration methods in simulation are trapezoidal rule and BDF (Gear's formula) of order 2.
The trapezoidal rule is simpler than BDF in implementation, but has a big disadvantage in form of "trapezoidal ringing". BDF does not suffer from this, so BDF is usually preferred choice in stiff systems (e.g. switching simulation), but BDFs are bad for high Q oscillatory circuits because of oscillation damping they introduce.
If you search good enough the web, you can find some papers introducing advanced, more complex differentiation schemes of order 2 that just like BDFs don't suffer from ringing at all and have damping factor almost 0. As far as I know, they are *not* used in SPICE-like simulators yet.

As for the NR method, you may want to read about damped NR, various continuation methods (gmin stepping, source stepping, transient timestep reduction) and homotopy methods (not used in SPICE, generally better than gmin stepping; but: harder to implement).

Is it enough?
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Hi again, I have a file rc.cir
Basic RC circuit
r 1 2 1.0
*l 1 2 1.0
c 2 0 1.0
vin 1 0 pulse (0 1) ac 1
.tran 0.1 7.0
*.ac dec 10 .01 10
.plot tran v(2) i(vin)
*.plot ac vdb(2) xlog
.end

The file is located in the same directory as the visual studio project-file.
I typed:
spice3f5 -b rc.cir
Nothing happens...
 

ahmadyan

Newbie level 5
Joined
Mar 20, 2009
Messages
8
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,343
I executed that code and it worked fine on Visual Studio 2010 (Ultimate)
Here is what I did:
Opened project in VS-2010 and converted it.
Build the solution
Copied an example circuit (rc.cir) from the original dist.
executed the spice in cmd:
c:\...\spice3f5\Debug>spice3f5.exe < rc.cir

It will dump some info on the screen and saves the result in rawspice.raw and dump some more files (like rc.read, write, etc.)

Screen dump:

Circuit: Basic RC circuit

Warning: vin: no DC value, transient time 0 value used
Circuit: Basic RC circuit
Date: Wed Nov 09 10:33:08 2011


basic rc circuit
r 1 2 1.0
*l 1 2 1.0
c 2 0 1.0
vin 1 0 pulse (0 1) ac 1
.tran 0.1 7.0
*.ac dec 10 .01 10
*.plot ac vdb(2) xlog
.end
elapsed time since last call: 0.000 seconds.

Total elapsed time: 0.000 seconds.

Current dynamic memory usage = 0,
Dynamic memory limit = 0.


rawspice.raw:
Title: Basic RC circuit
Date: Wed Nov 09 10:33:08 2011
Plotname: Transient Analysis
Flags: real
No. Variables: 4
No. Points: 66
Command: version 3f5
Variables:
0 time time
1 V(1) voltage
2 V(2) voltage
3 vin#branch current
Values:
0 0.000000000000000e+000
0.000000000000000e+000
0.000000000000000e+000
0.000000000000000e+000
1 1.000000000000000e-003
1.000000000000000e-002
9.990009990009990e-006
-9.990009990009990e-003
2 1.084056000000000e-003
1.084056000000000e-002
1.090030786509208e-005
-1.082965969213491e-002
3 1.252168000000000e-003
1.252168000000000e-002
1.286204694203642e-005
-1.250881795305796e-002
4 1.588392000000000e-003
1.588392000000000e-002
1.763224271321389e-005
-1.586628775728679e-002
5 2.260840000000000e-003
2.260840000000000e-002
...

Hope it helps


Hi again, I have a file rc.cir
Basic RC circuit
r 1 2 1.0
*l 1 2 1.0
c 2 0 1.0
vin 1 0 pulse (0 1) ac 1
.tran 0.1 7.0
*.ac dec 10 .01 10
.plot tran v(2) i(vin)
*.plot ac vdb(2) xlog
.end

The file is located in the same directory as the visual studio project-file.
I typed:
spice3f5 -b rc.cir
Nothing happens...
 

StoppTidigare

Full Member level 2
Joined
Jul 16, 2002
Messages
145
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Northern earth
Activity points
1,698
Friends!
Now when we know how to run it as a console-application.

Could somebody write a Winmain program that launches a window with a button, that runs the spice-code, either as a dll or inside the winmain-executable.

Kindest regards,

Stopptidigare
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top