andes.variables package

Submodules

andes.variables.dae module

class andes.variables.dae.DAE(system)[source]

Bases: object

Class for storing numerical values of the DAE system, including variables, equations and first order derivatives (Jacobian matrices).

Variable values and equation values are stored as numpy.ndarray, while Jacobians are stored as kvxopt.spmatrix. The defined arrays and descriptions are as follows:

DAE Array Description
x Array for state variable values
y Array for algebraic variable values
z Array for 0/1 limiter states (if enabled)
f Array for differential equation derivatives
Tf Left-hand side time constant array for f
g Array for algebraic equation mismatches

The defined scalar member attributes to store array sizes are

Scalar Description
m The number of algebraic variables/equations
n The number of algebraic variables/equations
o The number of limiter state flags

The derivatives of f and g with respect to x and y are stored in four kvxopt.spmatrix sparse matrices: fx, fy, gx, and gy, where the first letter is the equation name, and the second letter is the variable name.

Notes

DAE in ANDES is defined in the form of

\[\begin{split}T \dot{x} = f(x, y) \\ 0 = g(x, y)\end{split}\]

DAE does not keep track of the association of variable and address. Only a variable instance keeps track of its addresses.

alloc_or_extend_names()[source]

Allocate empty lists for names for the given size.

build_pattern(name)[source]

Build sparse matrices with stored patterns.

Call to store_row_col_idx should be made before this function.

Parameters:
name : name

jac name

clear_arrays()[source]

Reset equation and variable arrays to empty.

clear_fg()[source]

Resets equation arrays to empty

clear_ijv()[source]

Clear stored triplets.

clear_ts()[source]
clear_xy()[source]

Reset variable arrays to empty.

clear_z()[source]

Reset status arrays to empty

fg

Return a concatenated array of [f, g].

get_name(arr)[source]
get_size(name)[source]

Get the size of an array or sparse matrix based on name.

Parameters:
name : str (f, g, fx, gy, etc.)

array/sparse name

Returns:
tuple

sizes of each element in a tuple

print_array(name, values=None, tol=None)[source]
reset()[source]

Reset array sizes to zero and clear all arrays.

resize_arrays()[source]

Resize arrays to the new sizes m and n, and o.

If m > len(self.y) or n > len(self.x, arrays will be extended. Otherwise, new empty arrays will be sliced, starting from 0 to the given size.

Warning

This function should not be called directly. Instead, it is called in System.set_address which re-points variables used in power flow to the new array for dynamic analyses.

restore_sparse(names=None)[source]

Restore all sparse matrices to the sparsity pattern filled with zeros (for variable Jacobian elements) and non-zero constants.

Parameters:
names : None or list

List of Jacobian names to restore sparsity pattern

set_t(t)[source]

Helper function for setting time in-place

store()[source]

Store values and equations to in internal TimeSeries storage.

store_sparse_ijv(name, row, col, val)[source]

Store the sparse pattern triplets.

This function is to be called by System after building the complete sparsity pattern for each Jacobian matrix.

Parameters:
name : str

sparse Jacobian matrix name

row : np.ndarray

all row indices

col : np.ndarray

all col indices

val : np.ndarray

all values

write_lst(lst_path)[source]

Dump the variable name lst file.

Parameters:
lst_path

Path to the lst file.

Returns:
bool

succeed flag

write_npy(file_path)[source]

Write TDS data into NumPy uncompressed format.

write_npz(file_path)[source]

Write TDS data into NumPy compressed format.

xy

Return a concatenated array of [x, y].

xy_name

Return a concatenated list of all variable names without format.

xy_tex_name

Return a concatenated list of all variable names in LaTeX format.

xyz

Return a concatenated array of [x, y].

xyz_name

Return a concatenated list of all variable names without format.

xyz_tex_name

Return a concatenated list of all variable names in LaTeX format.

class andes.variables.dae.DAETimeSeries(dae=None)[source]

Bases: object

DAE time series data.

df
get_data(base_vars: Union[andes.core.var.BaseVar, List[andes.core.var.BaseVar]], a=None)[source]

Get time-series data for a variable instance.

Values for different variables will be stacked horizontally.

Parameters:
base_var : BaseVar or a sequence of BaseVar(s)

The variable types and internal addresses are used for looking up the data.

a : an array/list of int or None

Sub-indices into the address of base_var. Applied to each variable.

unpack(df=False)[source]

Unpack dict-stored data into arrays and/or dataframes.

Parameters:
df : bool

True to construct DataFrames self.df and self.df_z (time-consuming).

Returns:
True when done.
unpack_df()[source]

Construct pandas dataframes.

unpack_np()[source]

Unpack dict data into numpy arrays.

andes.variables.fileman module

class andes.variables.fileman.FileMan(case=None, **kwargs)[source]

Bases: object

Define a File Manager class for System

get_fullpath(fullname=None)[source]

Return the original full path if full path is specified, otherwise search in the case file path.

Parameters:
fullname : str, optional

Full name of the file. If relative, prepend input_path. Otherwise, leave it as is.

set(case=None, **kwargs)[source]

Perform the input and output set up.

andes.variables.fileman.add_suffix(fullname, suffix)[source]

Add suffix to a full file name.

andes.variables.report module

class andes.variables.report.Report(system)[source]

Bases: object

Report class to store system static analysis reports

info
update()[source]

Update values based on the requested content

write()[source]

Write report to file.

andes.variables.report.report_info(system)[source]

Module contents