How to use the andes.models.base.ModelBase function in andes

To help you get started, we’ve selected a few andes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cuihantao / andes / andes / models / governor.py View on Github external
from cvxopt import mul, div, matrix  # NOQA

from .base import ModelBase
from ..consts import Fx0, Fy0, Gx0, Gy0  # NOQA


class GovernorBase(ModelBase):
    """Turbine governor base class"""

    def __init__(self, system, name):
        super(GovernorBase, self).__init__(system, name)
        self._group = 'Governor'
        self.param_remove('Vn')
        self._data.update({
            'gen': None,
            'pmax': 999.0,
            'pmin': 0.0,
            'R': 0.05,
            'wref0': 1.0,
        })
        self._descr.update({
            'gen': 'Generator index',
            'pmax': 'Maximum turbine output in Syn Sn',
github cuihantao / andes / andes / models / coi.py View on Github external
from cvxopt import mul, div  # NOQA

from .base import ModelBase
from ..consts import Fx0, Fy0, Gx0, Gy0  # NOQA


class COI(ModelBase):
    def __init__(self, system, name):
        super(COI, self).__init__(system, name)
        self._group = 'Calculation'
        self._data.update({
            'syn': None,
            'Td': 1,
        })
        self._descr.update({
            'syn': 'synchronous generator list',
            'Td': 'washout filter time constant',
        })
        self._params.extend({'Td'})
        self._algebs.extend(['delta', 'omega', 'dwdt'])
        self._states.extend(['xdw'])
        self.calls.update({
            'init1': True,
github cuihantao / andes / andes / models / pss.py View on Github external
from cvxopt import matrix, spmatrix
from cvxopt import mul, div

from .base import ModelBase
from ..consts import Fx0, Fy0, Gx0, Gy0  # NOQA
from ..utils.math import aeqb, sdiv


class PSS1(ModelBase):
    """Stabilizer ST2CUT with dual input signals"""

    def __init__(self, system, name):
        super().__init__(system, name)
        self._group = 'PSS'
        self._name = 'PSS1'
        self._fnamey.extend([
            'In_1', 'In_2', 'In', 'x_3', 'x_4', 'x_5', 'x_6', 'V_{SS}',
            'V_{ST}'
        ])
        self._zeros.extend(['T4'])
        self._states.extend(['x1', 'x2', 'u3', 'u4', 'u5', 'u6'])
        self._params.extend([
            'Ic1', 'Ic2', 'K1', 'T1', 'K2', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7',
            'T8', 'T9', 'T10', 'lsmax', 'lsmin', 'vcu', 'vcl', 'd1', 'd2', 'd3'
        ])
github cuihantao / andes / andes / models / pv.py View on Github external
import logging

from cvxopt import matrix, mul

from .base import ModelBase
from ..utils.math import sort_idx

logger = logging.getLogger(__name__)


class Stagen(ModelBase):
    """Static generator base class"""

    def __init__(self, system, name):
        super().__init__(system, name)
        self._group = 'StaticGen'
        self._data.update({
            'bus': None,
            'busr': None,
            'pg': 0.0,
            'qg': 0.0,
            'pmax': 1.0,
            'pmin': 0.0,
            'qmax': 0.0,
            'qmin': 0.0,
            'v0': 1.0,
            'vmax': 1.4,
github cuihantao / andes / andes / models / pq.py View on Github external
import numpy as np
from cvxopt import matrix  # NOQA
from cvxopt import mul, div  # NOQA
from scipy.sparse import coo_matrix

from .base import ModelBase
from ..consts import Gy  # NOQA
from ..utils.math import altb, agtb, aorb, nota
from ..utils.math import zeros, ones


class PQ(ModelBase):
    """Static PQ load class"""

    def __init__(self, system, name):
        super().__init__(system, name)
        self._name = 'PQ'
        self._group = 'StaticLoad'
        self._category = 'Load'
        self._data.update({
            'bus': None,
            'p': 0,
            'q': 0,
            'owner': 0,
            'vmax': 1.1,
            'vmin': 0.9,
        })
        self._units.update({
github cuihantao / andes / andes / models / event.py View on Github external
if self.t1[i] == sim_time:
                self.log('Applying load scaling on <{}> at t={}'.format(
                    load_idx, sim_time))
                old_load = self.system.__dict__[group].get_field('p', load_idx)

                new_load = mul(old_load, self.scale[i])
                if self.rand[i]:
                    new_load += self.inc[i] * self._rand_coeff[i]
                else:
                    new_load += self.inc[i]

                self.system.__dict__[group].set_field('p', load_idx, new_load)


class LoadRamp(ModelBase):
    """
    Continuous load ramping
    """
    def define(self):
        self.param_remove('Sn')
        self.param_remove('Vn')
        self._group = 'Event'

        self.param_define('load', default=None, mandatory=True, descr="load idx", tomatrix=False)
        self.param_define('group', default='StaticLoad', mandatory=True,
                          descr="load group, StaticLoad or DynLoad", tomatrix=False)
        self.param_define('t1', default=-1, mandatory=True, descr='start time', tomatrix=True)
        self.param_define('t2', default=-1, mandatory=True, descr='end time', tomatrix=True)
        self.param_define('p_rate', default=1, mandatory=False, descr='rate of ramping per hour in percentage',
                          tomatrix=True)
        self.param_define('p_amount', default=0, mandatory=False, descr='the amount of ramping per hour in pu',
github cuihantao / andes / andes / models / series.py View on Github external
from .base import ModelBase


class SeriesBase(ModelBase):
    """Base class for AC series devices"""
    def __init__(self, system, name):
        super(SeriesBase, self).__init__(system, name)
github cuihantao / andes / andes / models / wind.py View on Github external
"""Wind power classes"""
from math import ceil

from cvxopt import matrix, mul, div  # NOQA
from numpy import arange, log
from numpy.random import uniform  # NOQA

from .base import ModelBase
from ..consts import Fx0, Fy0, Gy0  # NOQA


class WindBase(ModelBase):
    """Base class for wind time series"""

    def __init__(self, system, name):
        super(WindBase, self).__init__(system, name)
        self._group = 'Wind'
        self.param_remove('Sn')
        self.param_remove('Vn')
        self._data.update({
            'T': 1,
            'Vwn': 13,
            'dt': 0.1,
            'rho': 1.225,
        })
        self._descr.update({
            'T': 'Filter time constant',
            'Vwn': 'Wind speed base',
github cuihantao / andes / andes / models / measurement.py View on Github external
dae.add_jac(Fx0, -self.iTw, self.w, self.w)

        dae.add_jac(Fx0, -self.iTw, self.w, self.xt)
        dae.add_jac(Fy0, mul(self.iTw, self.iwn, self.iTf), self.w, self.a)

        dae.add_jac(Gx0, self.iTd, self.dwdt, self.w)
        dae.add_jac(Gx0, -1, self.dwdt, self.xdw)

        dae.add_jac(Fx0, self.iTd**2, self.xdw, self.w)
        dae.add_jac(Fx0, -self.iTd, self.xdw, self.xdw)

        dae.add_jac(Gy0, -1, self.dwdt, self.dwdt)


class PMU(ModelBase):
    """Phasor measurement unit described by low-pass filters"""

    def __init__(self, system, name):
        super(PMU, self).__init__(system, name)
        self._group = 'Measurement'
        self._data.update({
            'Tv': 0.1,
            'Ta': 0.1,
            'fn': 60,
            'bus': None,
        })
        self._params.extend(['Tv', 'Ta', 'fn'])
        self._descr.update({
            'Tv': 'Voltage magnitude time constant',
            'Ta': 'Voltage angle time constant',
            'fn': 'Frequency base',
github cuihantao / andes / andes / models / zone.py View on Github external
import logging

from cvxopt import spmatrix, spdiag, matrix

from .base import ModelBase
from ..utils.math import zeros

logger = logging.getLogger(__name__)


class Zone(ModelBase):
    """Zone class"""

    def __init__(self, system, name):
        super().__init__(system, name)
        self._group = 'Topo_Zone'
        self._name = 'Zone'
        self._params.extend(['pdes', 'ptol', 'isw'])
        self._descr.update({
            'pdes':
            "Desired net interchange leaving this area",
            'ptol':
            'Interchange tolerance bandwidth',
            'isw':
            'Area slack bus idx',
        })
        self._units.update({