kicadODE 0.1.0

Creator: rpa-with-ash

Last updated:

Add to Cart

Description:

kicadODE 0.1.0

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.
x˙=Ax+Bu+f(x,u)
y=Cx+Du+g(x,u)
where

x∈Rn is the n dimensional state vector
u∈Rm is the m dimensional input vector
y∈Rr is the r dimensional output vector
A∈Rn×n is the state matrix
B∈Rn×m is the input matrix
C∈Rr×n is the output matrix
D∈Rr×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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.