This blog is just to update and tell you guys that I have started a SPICE software package. Of course it'll be simple and won't do things PSPICE or B2SPICE can do but it's a great way to learn the process easier. I have already implemented the portion of the program that can simulate current sources and resistors. You can have as many nodes as you desire and it seems to work perfect (confirmed with B2SPICE). So I think that's good...
As for the software structure. I had to create a simple Complex Class and Matrix Class. The most difficult part was creating the inversion routine for the matrix. I didn't realize how complicated this was until I started to write it. I used the slowest and most real, the reduced diagonal method. I basically used linear algebra directly without any optimizations.
Anyways, this project will take a while. Once I can develop a simple engine, I'll put a GUI around it and make it better in a number of ways (if possible). Any suggestions, let me know
-----------------------
Justin Coulston
justin.coulston@gmail.com
As an Engineer, this site will provide new ways to perform old tasks specifically in Electrical and Software Engineering. Some things will be informational on RF technologies while others will be new altogether. Enjoy
Search This Blog
Showing posts with label matrix. Show all posts
Showing posts with label matrix. Show all posts
Saturday, April 10, 2010
Friday, April 9, 2010
Simulation: Basics of SPICE Modeling (Matrix Templates) - 2 of 6
Introduction
This is a continuation of the SPICE modeling series. I will attempt to explain how SPICE uses Matrix Templates to create a main matrix to perform the calculation.
SPICE Templates
Before I explain how voltage sources are used I should first explain how SPICE knows where to put information based on node numbers.
Each component in SPICE has an associated Matrix template that is added to a final matrix that performs the final calculation. As repeated from the last SPICE tutorial: [G][U]=[K] are the [G], conductance matrix, [U], unknowns matrix, and [K], knowns matrix, or the matrix with the known sources (voltage and current sources).
The initial matrix for the conductances starts with inserting the conductances between the nodes first. Each row and column corresponds with a particular node number. So we can easily construct the matrix by summing the conductances between the nodes.
This is a continuation of the SPICE modeling series. I will attempt to explain how SPICE uses Matrix Templates to create a main matrix to perform the calculation.
SPICE Templates
Before I explain how voltage sources are used I should first explain how SPICE knows where to put information based on node numbers.
Each component in SPICE has an associated Matrix template that is added to a final matrix that performs the final calculation. As repeated from the last SPICE tutorial: [G][U]=[K] are the [G], conductance matrix, [U], unknowns matrix, and [K], knowns matrix, or the matrix with the known sources (voltage and current sources).
The initial matrix for the conductances starts with inserting the conductances between the nodes first. Each row and column corresponds with a particular node number. So we can easily construct the matrix by summing the conductances between the nodes.
where n is the total number of nodes (not including ground)
So any components connected to node 1 will be summed at G11=1/R1+1/R2+ ... +1/Rn.
Now that you see how this first matrix works you can can understand how the templates can work. For example, the resistor template has a node A and node B connection points with a resistance R. Below is the matrix template
Now of course the template won't have the words node A and node B in them. So if the resistor was between nodes 3 and 6 then you would add T11 to G33, T22 to G66, T12 to G36, and T21 to G63 of the main matrix.
So you follow this for all the components. All components have some sort of matrix template. Below I will the capacitive and current sources. Inductor templates use a voltage source so we will talk about that later.
So you follow this for all the components. All components have some sort of matrix template. Below I will the capacitive and current sources. Inductor templates use a voltage source so we will talk about that later.
Labels:
circuit simulation,
Companion Model,
matrices,
matrix,
Matrix Templates,
Modeling,
Simulation,
SPICE
Sunday, April 4, 2010
Mathematics: Ohm's Law in Matrix Form
Introduction
So I was reading on Physics Forums about Ohm's Law in vector form and also SPICE analysis using matrices. So I decided to do some more research and write on the topic. From my understanding, many SPICE programs use a mixture of this technique to make node voltage analysis simpler in software. It's actually a very effective technique.
Notation
The following notation is used for complex numbers. It makes use of matrix algebra and can be used to multiple any complex numbers together. I'll do my best to describe as much as possible how this applies to circuit analysis.
[R] Real Value (Resistance, Real part of Voltage, etc)
[X] Reactance Value (Inductance, Phase component, etc)
This is the basic form to representing a component. So if we have a DC voltage source at 10V, it would be represented as so:
So to form Ohm's Law simply construct the equation:
which is equivalent to
So you see, use the dot product to find the product of the complex numbers.
Conclusion
This is a simple example but this can be expanded to be used in very complex circuits including frequency dependent components and some linear models. Anyways hope this was helpful. Let me know if you wish for more examples.
-------------------
Justin Coulston
Labels:
components,
Engineering,
Mathematics,
matrices,
matrix,
ohm's law
Subscribe to:
Posts (Atom)