[pydstool-users] Matrix in system of equation
Status: Beta
Brought to you by:
robclewley
From: Achim A. <ach...@go...> - 2011-01-12 06:29:19
|
Hi Happy new year every one! I'm new to continuation and trying to get my head around things at the moment. I've got the following system of equation: $$ \left( \begin{array}{c} \dot{s}\\ \dot{v} \end{array} \right) = \left( \begin{array}{c} v\\ -\mathbf{B}^{-1} \mathbf{A} s + V_{DC} \mathbf{B}^{-1} \mathbf{C} s \end{array} \right) $$ where A B and C are square matrices of dimension (nxn), s and v are vectors of length n and V_DC is a scalar. I tried to enter this system of equations and solve it with pyDSTool but got; 'TypeError: only length-1 arrays can be converted to Python scalars'. Here's the code: > #!/usr/bin/python > # encoding=utf8 > > import PyDSTool as DS > import numpy as np > > AA = np.matrix([[127.717469865, 2.05025780562], > [0.0521863096197, 2605.29996274]]) > BB = np.matrix([[1.65676839951e-10, 6.76971107431e-14], > [6.76971107431e-14, 8.60513163289e-11]]) > CC = np.matrix([[-5.91089367427436, 58.2428565496970], > [-9.30459729674465, 47.6048481884652]]) > > > DSargs = DS.args(name='Hopf') > > # parameters > DSargs.pars = { > 'A': AA, > 'B': BB, > 'B_I': BB.I, > 'C': CC, > 'V_DC': 0 > } > > # auxiliary helper function(s) > DSargs.fnspecs = { > 'ss': (['s'], 'sum(s)'), > 'vv': (['v'], 'sum(v)') > } > > # rhs of the differential equation > DSargs.varspecs = { > 's': 'v', > 'v': '-B_I*A*s + V_DC*B_I*C*s' > } > > # initial conditions > DSargs.ics = { > 's': np.matrix([0,0]), > 'v': np.matrix([0,0]) > } > > DSargs.info() > > ode = DS.Generator.Vode_ODEsystem(DSargs) > > # Set up continuation class > PyCont = DS.ContClass(ode) > > PCargs = DS.args(name='EQ1', type='EP-C') > PCargs.freepars = ['V_DC'] > PCargs.MaxNumPoints = 400 > PCargs.StepSize = 0.1 > PCargs.LocBifPoints = ['all'] > PCargs.SaveEigen = True > How can I deal with matrices in the system of equations? I need to work with such systems often in future as this is the form I get after applying the Galerking decomposition to continuum-mechanical dynamic systesm. Thanks for your help! Achim ps: Thanks for another awesome open-source tool! |