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
Built Distribution
File details
Details for the file kicadODE-0.1.0.tar.gz
.
File metadata
- Download URL: kicadODE-0.1.0.tar.gz
- Upload date:
- Size: 44.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e70e200bd51136055d7a8ecac54f91fa7250faa81f838cf2b32ac4debdaca28d |
|
MD5 | f1a0c823ab69615fccb4c4c78686cceb |
|
BLAKE2b-256 | eae9dc1d603959a2146bee953d8659d1ff7f0a7624389fc0237b0a30e5882947 |
File details
Details for the file kicadODE-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: kicadODE-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b46888fe531e1db0c701549bdae43bdc35816fc101ca020058c1566d4874098 |
|
MD5 | d3ca70805a031ea7384a6c187628b2bf |
|
BLAKE2b-256 | da06a0a2b036aff9f77e4e21c4890024677dc5bce172135879e2c7f3b30710ae |