Note
Go to the end to download the full example code.
Matrix extraction#
This shows, how the matrix of the system can be extracted from the RCNetwork.
# sphinx_gallery_tags = ["system","matrix"]
# sphinx_gallery_thumbnail_path = "_static/examples/matrix_extraction.svg"
First, we get the network from the “Simple linear Network” example
from examples.example_setup import setup_simple_network
from pyrc import RCNetwork
from pyrc.tools.functions import sympy_to_tex
network: RCNetwork = setup_simple_network()
Get the system matrix with symbols (no values substituted)
system_matrix_symbol = network.system_matrix_symbol
You can make it a numpy matrix (not sparse):
import numpy as np
numpy_system_matrix_symbol = np.array(system_matrix_symbol.tolist())
Get the system matrix with values
system_matrix = network.system_matrix
Print the symbol matrix in LaTeX
sympy_to_tex(system_matrix_symbol, "C:\\Simulations\\my_latex.tex")