Kicad ODE solver
Project description
Spice model generator for Kicad's NGSpice solver
Generates a Kicad model and corresponding ngspice model from the provided ordinary differential equation (ODE) to be solved by NGspice. Considered ODEs are defined in this general form.
$$\dot{x}=Ax+Bu+f(x,u)$$
$$y=Cx+Du+g(x,u)$$
where
- $x\in\mathbb{R}^n$ is the $n$ dimensional state vector
- $u\in\mathbb{R}^m$ is the $m$ dimensional input vector
- $y\in\mathbb{R}^r$ is the $r$ dimensional output vector
- $A\in\mathbb{R}^{n \times n}$ is the state matrix
- $B\in\mathbb{R}^{n \times m}$ is the input matrix
- $C\in\mathbb{R}^{r \times n}$ is the output matrix
- $D\in\mathbb{R}^{r \times m}$ is the input-to-output matrix
- $f(x,u)$ vector of functions of state and input vectors
- $g(x,u)$ vector of functions of state and input vectors
Example
Let us define an ODE where $n=2$, $m=1$, $r=2$.
import kicadODE
data = {
'A': [
[ -0.1, 1 ],
[ 0, -0.1 ],
],
'B': [
[ 1 ],
[ 0 ],
],
'C': [
[ 1e-2, 0 ],
[ 0, 1e-2 ],
],
'D': [
[ 0 ],
[ 0 ],
],
'f': [
'-0.01*x1^3-x2^3/33',
'exp(-u1)',
],
'g': [
'sin(x1*x2)',
'x1/(x2^2+1)',
],
"x0": [ 1.0, -0.3 ], # Initial conditions
"name": "test_model", # Name of Kicad model
"to_file": True, # Exports 'test_model.lib' and 'test_model.kicad_sym'
}
kicadODE.generate(data)
print(data["lib"])
print(data["sym"])
Parameters A, B, C, D
are required. If your model does not need the linear part, set A,B,C,D
zero
matrices with appropriate dimensions.
Parameters f
and g
can contain math terms which are supported by ngspice. Please, visit
this page
for a list of all supported functions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kicadODE-0.1.0.tar.gz
(44.0 kB
view hashes)
Built Distribution
kicadODE-0.1.0-py3-none-any.whl
(30.4 kB
view hashes)