The circuit description in OCS is based on (a variant of) modified nodal analysis (MNA) model for lumped-element networks.
It is easy to verify that the common charge/flux-based MNA model is a special case of the model presented below.

We consider a circuit with M elements and N nodes, the core of the MNA model is a set of N equations of the form
∑m=1MFmn=0n=1,…,N{\displaystyle \sum _{{m}=1}^{M}F_{mn}=0\qquad n=1,\,\ldots \,,N}

where Fmn{\displaystyle F_{mn}} denotes the current from the node n due to element m.

The equations above are the Kirchhoff current law (KCL) for each of the electrical nodes of the network.

The currents can be expressed in terms of the node voltages e{\displaystyle e} and the internal variables rm(m=1…M){\displaystyle r_{m}\;(m=1\ldots M)}

Notice that the variables rm{\displaystyle {r}_{m}} only appear in the equations defining the fluxes relative to the m-th element, for this reason they are sometimes referred to as internal variables of the m-th element.

The full MNA model is finally obtained by substituting the current definitions in the KCL and complementing it with a suitable number Im{\displaystyle I_{m}} of constitutive relations for the internal variables of each element
∑m=1M[Amnr˙m+Jmn(e,rm)]=0n=1,…,N{\displaystyle \sum _{{m}=1}^{M}\left[\ A_{mn}{\dot {r}}_{m}+J_{mn}\left({e},{r}_{m}\right)\right]=0\qquad {\begin{array}{l}{n}=1,\,\ldots \,,N\end{array}}}

Notice that the assumption that only time derivatives of internal variables appear above and that terms involving such derivatives are linear does not impose restrictions on the applicability of the model.

A circuit is represented in OCS by a struct variable with the fields listed below

Code: OCS structure format

cir_struct={LCR:struct% the fields of LCR are shown belowNLC:struct% NLC has the same fields as LCRnamesn:matrix% numbers of vars that are assigned a name in and.nmsnamess:cell% the names corresponding to the vars abovetotextvar:scalar% the total number of external variablestotintvar:scalar% the total number of internal variables}outstruct.LCR={1x2structarraycontainingthefields:% array has one element per blockfunc% name of the sbn file corresponding to each blocksection% string parameter to be passed to the sbn filesnextvar% number of external variables for each element of the blockvnmatrix% numbers of the external variables of each elementnintvar% number of internal variables for each element of the blockosintvar% number of the first internal variablenpar% number of parametersnparnames% number of parameter namesnrows% number of rows in the blockparnames% list of parameter namespvmatrix% list of parameter values for each element}

There are several ways of setting up the data structure for an OCS simulation.
The first approach is to just assign the fields of the data structure via Octave commands,
otherwise one can parse an ascii file written in (a subste of) SPICE netlist language or
in OCS's own netlist specification language called IFF (Interchange File Format)

The name IFF stands for "Intermediate File Format" or "Interchange File Format" it represents an ASCII file format for describing coupled electrical circuits, devices and systems. The IFF syntx described here is version 0.1b1.

A circuit description is comprised of a set of files of three different types:

The CIR file is divided into two sections describing the linear time–independent (LCR = linear circuit) and the non–linear and/or time–dependent (NLC = non–linear circuit) partitions of the circuit respectively. The syntax for the LCR and NLC section is identical. NLC can also contain linear elements, in fact the whole circuit could be described only by the NLC section but this could result in the evaluator unnecessarily recomputing local matrices for linear time–independent elements The content of CIR files is organized as follows:

"version_id" is a string identifying the version on IFF in which the file is encoded

"\n" is the new-line character string that represents anything that the Octave command "s=fscanf(file,%s)" would parse as a string i.e. any sequence of chars without white-space

"text" is any sequence of chars without a \n, this differs from string because it can contain white–space number represents anything that the Octave command "s=fscanf(file,%g)" would parse as a number

"func" is the name of a function to evaluate the elements described in the block

"n_extvar" Is the number of external variables for the elements of a block

"n_par" Is the number of parameters for the elements of a block

"n_rows" Is the number of elements in a block

n_parnames" Is the number of parameter names for the elements of a block, it corresponds to the number of par name entries. If "n_parnames" is 0 the line with the "par_names" is missing.

"pv_matrix" Is a list of n_rows x n_par numbers separated by any character the Octave command "s=fscanf(file,%g)" would consider whitespace (including "\n"). Every row (a set of n par contiguous entries) in "pv_matrix" refers to an element of the circuit. The "n_par" numbers in a row represent the values of the parameters to be passed to the function that evaluates that element.

"vnum_matrix" Is a list of "n_rows" x "n_extvar" numbers separated by any character the Octave command "s=fscanf(file,%g)" would consider white-space (including \n). Every row (a set of "n_extvar" contiguous entries) in "vnum_matrix" refers to an element of the circuit. The "n_extvar" numbers in the row represent the global numbering of the element external variables.

first all external variables of all elements in the order given by the global numbering of external variables as explicitly written in the CIR files

then the internal variables of the elements in the same order as the corresponding elements appear in the CIR file ( internal variables of non-linear elements first, then those of linear elements)

Notice that the number of internal variables of each element is not included in the IFF files. This is because elements with a number of internal variables that is huge, that depends on the value of some parameter, or even that changes in time (for example distributed elements treated with a FEM with adaptive meshing, a large linear sub- circuit that is reduce via MOR...) and therefore it is more convenient to compute the number of internal variables when initializing the system.