Skip to content

Commit

Permalink
Fix delcapify for functions #113
Browse files Browse the repository at this point in the history
  • Loading branch information
mph- committed Nov 3, 2023
1 parent df77907 commit c9756c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 12 additions & 2 deletions doc/circuits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ The system of equations can be formulated in matrix form as :math:`\mathbf{A} \m
⎢ 2 2⎥
⎣ C₂⋅s C₂⋅s ⎦

The system of equations can be shown in a number of forms: `y = Ainv b`, `Ainv b = y`, `A y = b`, and `b = A y`. The `invert` argument calculates the inverse of the `A` matrix.
The system of equations can be shown in a number of forms: `y = Ainv b`, `Ainv b = y`, `A y = b`, and `b = A y`. The `inverse` argument calculates the inverse of the `A` matrix.

The matrix is returned by the `A` attribute, the vector of unknowns by the `y` attribute, and the result vector by the `b` attribute.

Expand Down Expand Up @@ -425,7 +425,7 @@ The system of equations can be formulated in matrix form as :math:`\mathbf{A} \m
⎢ 0 0 ──── ──── + ────⎥
⎣ R₂⋅s R₃⋅s R₂⋅s⎦

The system of equations can be shown in a number of forms: `y = Ainv b`, `Ainv b = y`, `A y = b`, and `b = A y`. The `invert` argument calculates the inverse of the `A` matrix.
The system of equations can be shown in a number of forms: `y = Ainv b`, `Ainv b = y`, `A y = b`, and `b = A y`. The `invert` argument calculates the inverse of the `A` matrix (see :ref:`system-of-equations`).

The matrix is returned by the `A` attribute, the vector of unknowns by the `y` attribute, and the result vector by the `b` attribute.

Expand Down Expand Up @@ -508,6 +508,7 @@ The equations are similar for the transient response:
⎜⎢ ⎥⎟
⎝⎣ 0 1 -1 0 -L₁⋅s⎦⎠

See :ref:`system-of-equations` for formatting of the equations.

.. _state-space-analysis:

Expand Down Expand Up @@ -938,3 +939,12 @@ between accuracy and stability.
Here's an example of using the backward-Euler integration method:

>>> results = cct.sim(tv, integrator='backward-euler')


.. _system-of-equations:


System of equations
===================

A system of equations can be shown in a number of forms: `y = Ainv b`, `Ainv b = y`, `A y = b`, and `b = A y`. The `invert` argument calculates the inverse of the `A` matrix (see :ref:`system-of-equations`).
5 changes: 3 additions & 2 deletions lcapy/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4201,8 +4201,9 @@ def delcapify(expr):
for key, val in expr.items():
ret[delcapify(key)] = delcapify(val)
return ret
elif hasattr(expr, 'expr'):
return expr.expr
elif hasattr(expr, 'sympy'):
# Note, SymPy functions have an expr attribute
return expr.sympy

return expr

Expand Down
6 changes: 3 additions & 3 deletions lcapy/statespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from .tmatrix import TimeDomainMatrix
from .nmatrix import DiscreteTimeDomainMatrix
from .statespacebase import StateSpaceBase
from .texpr import t, texpr
from .texpr import texpr
from .equation import Equation
from .sym import ssym
from .sym import ssym, tsym
from sympy import diag, eye, MatMul, MatAdd, Derivative


Expand Down Expand Up @@ -45,7 +45,7 @@ def x(self):
def dotx(self):
"""Time derivative of state variable vector."""

return TimeDomainMatrix([Derivative(x1, t) for x1 in self.x.sympy])
return TimeDomainMatrix([Derivative(x1, tsym) for x1 in self.x.sympy])

@property
def x0(self):
Expand Down

0 comments on commit c9756c1

Please sign in to comment.