Page MenuHomec4science

matrix_dynamical_passive.py
No OneTemporary

File Metadata

Created
Wed, May 8, 09:26

matrix_dynamical_passive.py

# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
import scipy.sparse as sp
from rrompy.utilities.base.types import ListAny, paramVal
from rrompy.hfengines.base.matrix_engine_base import MatrixEngineBase
from rrompy.parameter import checkParameter
__all__ = ['MatrixDynamicalPassive']
class MatrixDynamicalPassive(MatrixEngineBase):
def __init__(self, mu0 : paramVal = [0., 10.], n : int = 1000,
omega0 : ListAny = [1.], domega0 : ListAny = [1.],
b : float = 10., verbosity : int = 10,
timestamp : bool = True):
super().__init__(verbosity = verbosity, timestamp = timestamp)
self._affinePoly = True
self.npar = 1 + len(omega0)
self.mu0 = checkParameter(mu0, self.npar)
self.nAs, self.nbs = 1 + self.npar, 1
Asize = 2 + 2 * self.npar + n
dataA0 = np.concatenate((*tuple([tuple([np.imag(o), - np.real(o),
np.real(o), np.imag(o)]) \
for o in omega0]),
[1., -200., 200., 1., 1., -400., 400., 1.],
1. + np.arange(n)))
rowA0 = np.concatenate((np.repeat(np.arange(2 * len(omega0) + 4), 2),
2 + 2 * self.npar + np.arange(n)))
cB0 = np.repeat(np.arange(0, 2 * len(omega0) + 4, 2), 4)
cB1 = np.tile([0, 1], [1, 2 * len(omega0) + 4]).reshape(-1)
colA0 = np.concatenate((cB0 + cB1, 2 + 2 * self.npar + np.arange(n)))
self.As = [sp.csr_matrix((dataA0, (rowA0, colA0)), dtype = np.complex,
shape = (Asize, Asize))]
self.As = self.As + [1.j * sp.eye(Asize, dtype = np.complex)]
for j, do0 in enumerate(domega0):
self.As = self.As + [sp.csr_matrix(([- do0, do0],
([2*j, 2*j+1], [2*j+1, 2*j])),
dtype = np.complex,
shape = (Asize, Asize))]
self.bs = [np.concatenate((b * np.ones(2 + 2 * self.npar),
np.ones(n)))]
self.thAs = self.getMonomialWeights(self.nAs)
self.thbs = self.getMonomialWeights(self.nbs)

Event Timeline