Commit eb4b48fb authored by Blais, Chris's avatar Blais, Chris
Browse files

Committing remainder of scratch work in jupyter notebooks

parent 622fae94
Loading
Loading
Loading
Loading
+255 −1
Original line number Diff line number Diff line
%% Cell type:code id:c8f1b999 tags:

``` python
import sympy as sy
import pandas as pd
import os
import scipy as sp
import numpy as np
import math
import itertools
import sys
module_path = os.path.join(os.path.dirname(os.path.abspath('')))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")

import matplotlib.pyplot as plt
from numerical_labelling.labelling import *
```

%% Output

    path already in sys.path

%% Cell type:markdown id:8e4f0a26 tags:

## Linear case
<img src="../fig/membrane_corrected.png" width="50%">

%% Cell type:code id:a87b952f tags:

``` python
# generate constraints
def constr_mem_lin():
    """
    constraint equations for membrane example
    """

    m1, m2, m3, m4, m5, m6, m7, m8 = sy.symbols('m1 m2 m3 m4 m5 m6 m7 m8') # overall mass flow rates
    varbs = [
        m1, m2, m3, m4, m5, m6, m7, m8
        ]
    var_labels = [
        'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8'
        ]

    # Create a dictionary to store all variables and their values
    var_dict = dict(zip(var_labels, varbs))

    constr = {}
    # mass balance
    constr[0] = m1 - m2
    constr[1] = m2 - m3 + m8
    constr[2] = m3 - m4 - m5
    constr[3] = m5 - m6 - m7
    constr[4] = m7 - m8

    return constr, var_dict
```

%% Cell type:code id:92ba160f tags:

``` python
constr_lin, varbs_lin = constr_mem_lin()
```

%% Cell type:code id:8f31dfa5 tags:

``` python
jac_lin = jacsym(constr_lin.values(), varbs_lin.values())
```

%% Cell type:code id:307d5feb tags:

``` python
jac_lin
```

%% Output

    $\displaystyle \left[\begin{matrix}1 & -1 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 1 & -1 & 0 & 0 & 0 & 0 & 1\\0 & 0 & 1 & -1 & -1 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 1 & -1 & -1 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 1 & -1\end{matrix}\right]$
    Matrix([
    [1, -1,  0,  0,  0,  0,  0,  0],
    [0,  1, -1,  0,  0,  0,  0,  1],
    [0,  0,  1, -1, -1,  0,  0,  0],
    [0,  0,  0,  0,  1, -1, -1,  0],
    [0,  0,  0,  0,  0,  0,  1, -1]])

%% Cell type:code id:7c92dbab tags:

``` python
layout = [True, True, True, False, False, False, False, False]
layout_inv = [not(i) for i in layout]
layout_inv
```

%% Output

    [False, False, False, True, True, True, True, True]

%% Cell type:code id:035143cd tags:

``` python
ju = jac_lin[:,layout_inv]
jm = jac_lin[:, layout]
```

%% Cell type:code id:50a64f26 tags:

``` python
ju.rref()[0]
```

%% Output

    $\displaystyle \left[\begin{matrix}1 & 0 & 1 & 0 & 0\\0 & 1 & -1 & 0 & 0\\0 & 0 & 0 & 1 & 0\\0 & 0 & 0 & 0 & 1\\0 & 0 & 0 & 0 & 0\end{matrix}\right]$
    Matrix([
    [1, 0,  1, 0, 0],
    [0, 1, -1, 0, 0],
    [0, 0,  0, 1, 0],
    [0, 0,  0, 0, 1],
    [0, 0,  0, 0, 0]])

%% Cell type:code id:1fad065b tags:

``` python
# transfer one measured over:
layout = [False, True, True, False, False, False, False, False]
layout_inv = [not(i) for i in layout]
ju = jac_lin[:,layout_inv]
jm = jac_lin[:, layout]
ju.rref()[0]
```

%% Output

    $\displaystyle \left[\begin{matrix}1 & 0 & 0 & 0 & 0 & 0\\0 & 1 & 0 & 1 & 0 & 0\\0 & 0 & 1 & -1 & 0 & 0\\0 & 0 & 0 & 0 & 1 & 0\\0 & 0 & 0 & 0 & 0 & 1\end{matrix}\right]$
    Matrix([
    [1, 0, 0,  0, 0, 0],
    [0, 1, 0,  1, 0, 0],
    [0, 0, 1, -1, 0, 0],
    [0, 0, 0,  0, 1, 0],
    [0, 0, 0,  0, 0, 1]])

%% Cell type:markdown id:21ed7f7f tags:

## bilinear case

%% Cell type:markdown id:e1d43176 tags:
%% Cell type:code id:e1d43176 tags:

``` python
import sympy as sy
import pandas as pd
import os
import scipy as sp
import numpy as np
import math
import itertools
import sys
module_path = os.path.join(os.path.dirname(os.path.abspath('')))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")

import matplotlib.pyplot as plt
from numerical_labelling.labelling import *
from numerical_labelling.plot_layout import make_pretty_labels
```

%% Output

    path already in sys.path

%% Cell type:code id:a6ff637e tags:

``` python
def constr_spl():
    constr = {}
    m1, m2, m3 = sy.symbols("m1 m2 m3")
    x1, x2, x3 = sy.symbols("x1 x2 x3")
    varbs_sy = [m1, m2, m3, x1, x2, x3]

    constr[0] = m1 - m2 - m3
    constr[1] = x1 - x2
    constr[2] = x1 - x3

    varb_labels = [
        "m1", "m2", "m3",
        "x1", "x2", "x3",
        ]

    varbs = dict(zip(varb_labels,varbs_sy))

    return constr, varbs

def constr_spl_sup(simple_constr = False):
    "include superfluous constraint"
    constr = {}
    m1, m2, m3 = sy.symbols("m1 m2 m3")
    x1, x2, x3 = sy.symbols("x1 x2 x3")
    varbs_sy = [m1, m2, m3, x1, x2, x3]

    constr[0] = m1 - m2 - m3
    constr[1] = x1 - x2
    constr[2] = x1 - x3
    if simple_constr:
        constr[3] = m1 - m2 - m3
    else:
        constr[3] = m1*x1 - m2*x2 - m3*x3

    varb_labels = [
        "m1", "m2", "m3",
        "x1", "x2", "x3",
        ]

    varbs = dict(zip(varb_labels,varbs_sy))

    return constr, varbs
```

%% Cell type:code id:9a97895b tags:

``` python
constr_req, varbs_req = constr_spl()
constr_sup, varbs_sup = constr_spl_sup()
constr_sup_mb, varbs_sup_mb = constr_spl_sup(simple_constr=True)
jac_req = jacsym(constr_req.values(), varbs_req.values())
jac_sup = jacsym(constr_sup.values(), varbs_sup.values())
jac_sup_mb = jacsym(constr_sup_mb.values(), varbs_sup_mb.values())
```

%% Cell type:code id:2701d8e2 tags:

``` python
layout = [
    True, False, False,
    False, True, False
]

bool_measured = np.where(np.array(layout))[0]
bool_unmeasured = np.where(~np.array(layout))[0]
vb_all, vb_m, vb_um = make_pretty_labels(varbs_req, layout)
```

%% Cell type:code id:f55e7793 tags:

``` python
r1, r2, r3, r4 = sy.symbols("r1 r2 r3 r4")
rhs_syms = sy.Matrix([r1, r2, r3, r4])
```

%% Cell type:code id:4c3f3568 tags:

``` python
Ju_req = jac_req[:, list(bool_unmeasured)]
Ju_sup = jac_sup[:, list(bool_unmeasured)]
Ju_sup_mb = jac_sup_mb[:, list(bool_unmeasured)]
rref_req, rhs_req = Ju_req.rref_rhs(rhs_syms[:Ju_req.shape[0],:])
rref_sup, rhs_sup = Ju_sup.rref_rhs(rhs_syms[:Ju_sup.shape[0],:])
rref_sup_mb, rhs_sup_mb = Ju_sup_mb.rref_rhs(rhs_syms[:Ju_sup_mb.shape[0], :])
```

%% Cell type:code id:d4b906cd tags:

``` python
sy.Matrix.vstack(vb_um, rref_req)
```

%% Output

    $\displaystyle \left[\begin{matrix}m_{2} & m_{3} & x_{1} & x_{3}\\- & - & - & -\\1 & 1 & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{matrix}\right]$
    Matrix([
    [m2, m3, x1, x3],
    [ -,  -,  -,  -],
    [ 1,  1,  0,  0],
    [ 0,  0,  1,  0],
    [ 0,  0,  0,  1]])

%% Cell type:code id:aad07395 tags:

``` python
sy.Matrix.vstack(vb_um, rref_sup)
```

%% Output

    $\displaystyle \left[\begin{matrix}m_{2} & m_{3} & x_{1} & x_{3}\\- & - & - & -\\1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{matrix}\right]$
    Matrix([
    [m2, m3, x1, x3],
    [ -,  -,  -,  -],
    [ 1,  0,  0,  0],
    [ 0,  1,  0,  0],
    [ 0,  0,  1,  0],
    [ 0,  0,  0,  1]])

%% Cell type:code id:07ba3528 tags:

``` python
sy.Matrix.vstack(vb_um, rref_sup_mb)
```

%% Output

    $\displaystyle \left[\begin{matrix}m_{2} & m_{3} & x_{1} & x_{3}\\- & - & - & -\\1 & 1 & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 0 & 1\\0 & 0 & 0 & 0\end{matrix}\right]$
    Matrix([
    [m2, m3, x1, x3],
    [ -,  -,  -,  -],
    [ 1,  1,  0,  0],
    [ 0,  0,  1,  0],
    [ 0,  0,  0,  1],
    [ 0,  0,  0,  0]])

%% Cell type:code id:20d2fb5a tags:

``` python
rhs_req
```

%% Output

    $\displaystyle \left[\begin{matrix}- r_{1}\\r_{2}\\r_{2} - r_{3}\end{matrix}\right]$
    Matrix([
    [    -r1],
    [     r2],
    [r2 - r3]])

%% Cell type:code id:3257c8d7 tags:

``` python
rhs_sup
```

%% Output

    $\displaystyle \left[\begin{matrix}\frac{m_{1} r_{2} - m_{3} r_{2} + m_{3} r_{3} + r_{1} x_{3} - r_{4}}{x_{2} - x_{3}}\\\frac{- m_{1} r_{2} + m_{3} r_{2} - m_{3} r_{3} - r_{1} x_{2} + r_{4}}{x_{2} - x_{3}}\\r_{2}\\r_{2} - r_{3}\end{matrix}\right]$
    Matrix([
    [ (m1*r2 - m3*r2 + m3*r3 + r1*x3 - r4)/(x2 - x3)],
    [(-m1*r2 + m3*r2 - m3*r3 - r1*x2 + r4)/(x2 - x3)],
    [                                             r2],
    [                                        r2 - r3]])

%% Cell type:code id:56de1575 tags:

``` python
rhs_sup_mb
```

%% Output

    $\displaystyle \left[\begin{matrix}- r_{4}\\r_{2}\\r_{2} - r_{3}\\r_{1} - r_{4}\end{matrix}\right]$
    Matrix([
    [    -r4],
    [     r2],
    [r2 - r3],
    [r1 - r4]])

%% Cell type:code id:e4b4c4d8 tags:

``` python
rref_subout, rhs_subout = Ju_sup.subs({'x2':varbs_req['x3']}).rref_rhs(rhs_syms[:4, :])
rhs_subout
```

%% Output

    $\displaystyle \left[\begin{matrix}\frac{m_{1} r_{2} - m_{3} r_{2} + m_{3} r_{3} - r_{4}}{x_{3}}\\r_{2}\\r_{2} - r_{3}\\\frac{m_{1} r_{2} - m_{3} r_{2} + m_{3} r_{3} + r_{1} x_{3} - r_{4}}{x_{3}}\end{matrix}\right]$
    Matrix([
    [        (m1*r2 - m3*r2 + m3*r3 - r4)/x3],
    [                                     r2],
    [                                r2 - r3],
    [(m1*r2 - m3*r2 + m3*r3 + r1*x3 - r4)/x3]])

%% Cell type:code id:224f51bb tags:

``` python
Ju_req
```

%% Output

    $\displaystyle \left[\begin{matrix}-1 & -1 & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 1 & -1\end{matrix}\right]$
    Matrix([
    [-1, -1, 0,  0],
    [ 0,  0, 1,  0],
    [ 0,  0, 1, -1]])

%% Cell type:code id:f0f6e228 tags:

``` python
varbs_req['x2']
```

%% Output

    $\displaystyle x_{2}$
    x2

%% Cell type:markdown id:58024a89 tags:

## Bilinear failure: operating point selection

%% Cell type:markdown id:e4747f6d tags:
+2370 −441

File changed.

Preview size limit exceeded, changes collapsed.

+182 −8
Original line number Diff line number Diff line
%% Cell type:code id:6ea07368 tags:

``` python
import sys
import os
import pickle
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
module_path = os.path.dirname(os.path.dirname(os.path.abspath("")))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")
from numerical_labelling.labelling import *
from documenting_failures.test_case_bilinear import *
from numerical_labelling.plot_layout import plot_bl_layout, make_pretty_labels
from documenting_failures.setup_example_soar import define_system, get_one_result
```

%% Output

    path already in sys.path

%% Cell type:code id:6b6f21c4 tags:

``` python
# generate constraints, sy variables, and jacobian
constr_bl, varbs_bl = constr_mem_bl()
jac_bl = jacsym(constr_bl.values(), varbs_bl.values())
constr_bl
```

%% Output

    {0: m1 - m2,
     1: m2 - m3 + m8,
     2: m3 - m4 - m5,
     3: m5 - m6 - m7,
     4: m7 - m8,
     5: m1*x1 - m2*x2,
     6: m2*x2 - m3*x3 + m8*x8,
     7: m3*x3 - m4*x4 - m5*x5,
     8: m7*x7 - m8*x8,
     9: x5 - x6,
     10: x5 - x7}

%% Cell type:code id:3e017ebf tags:

``` python
nLayout = 34952
soar_layout, _, _ = int_to_bool_list(nLayout, 16)
print(soar_layout)
```

%% Output

    [False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True]

%% Cell type:code id:aa7db174 tags:

``` python
# the concentrations are listed before the mass flow rates for
# soar layout, so they need to be swapped.
# not important for this example, since mass and conc layout is symmetrical
layout = soar_layout[:8] + soar_layout[8:]
plot_bl_layout(layout_plt = layout, varbs_bl = varbs_bl)

```

%% Output

    c:\Users\tjf\Documents\01_gitlab_repos\soar_integration\fig


%% Cell type:code id:0959fba9 tags:

``` python
# m5 - m6 - m7 = 0

# m5*x5 - m6*x5 - m7*x5 = 0 no longer indep if x5 =x6 = x7
```

%% Cell type:markdown id:af0dcc67 tags:


%% Cell type:code id:35f465b4 tags:

``` python
vb_all, vb_m, vb_um = make_pretty_labels(varbs_bl, layout)
```

%% Cell type:code id:b1778bfa tags:

``` python
# get integer operating point
x0 = get_x0_bl(
            m1 = 20, m4 = 10, m6 = 10, m8 = 11,
            x1 = 4, x8 = 5
        )

x0 = {key:int(value) for key, value in x0.items()}
x0
```

%% Output

    {'m1': 20,
     'm2': 20,
     'm3': 31,
     'm4': 10,
     'm5': 21,
     'm6': 10,
     'm7': 11,
     'm8': 11,
     'x1': 4,
     'x2': 4,
     'x3': 4,
     'x4': 3,
     'x5': 5,
     'x6': 5,
     'x7': 5,
     'x8': 5}

%% Cell type:code id:9bdf4676 tags:

``` python
# numeric rref, shows only additional observable values are M7, X5, X6, and X7
obs_int, red_int, Ju_int, Ju_rref_int = observability_redundancy_labelling_rref(jac_bl, layout, x0 = x0, debug=True )
display(sy.Matrix.vstack(vb_um, Ju_rref_int))
```

%% Output

    $\displaystyle \left[\begin{array}{cccccccccccc}m_{1} & m_{2} & m_{3} & m_{5} & m_{6} & m_{7} & x_{1} & x_{2} & x_{3} & x_{5} & x_{6} & x_{7}\\- & - & - & - & - & - & - & - & - & - & - & -\\1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -31 & 0 & 0 & 0\\0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -31 & 0 & 0 & 0\\0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & -31 & 0 & 0 & 0\\0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & -31 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & -31 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & - \frac{31}{20} & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & - \frac{31}{20} & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\end{array}\right]$

%% Cell type:code id:a732168c tags:

``` python
# symbolic rref, just to check (takes about 2 min to run on my pc). shows the same
run_symbolic = False
if run_symbolic:
    obs_sym, red_sym, Ju_sym, Ju_rref_sym = observability_redundancy_labelling_rref(jac_bl, layout, debug=True )
    display(sy.Matrix.vstack(vb_um,Ju_rref_sym))
```

%% Cell type:code id:a513aba0 tags:

``` python
# run soar example:
# establish simple membrane system for testing
iIncidence = np.array(
    [   # e   P1  Mx Me1 Sp1  P2
        [-1, +1,  0,  0,  0,  0],  # 1
        [ 0, -1, +1,  0,  0,  0],  # 2
        [ 0,  0, -1, +1,  0,  0],  # 3
        [+1,  0,  0, -1,  0,  0],  # 4
        [ 0,  0,  0, -1, +1,  0],  # 5
        [+1,  0,  0,  0, -1,  0],  # 6
        [ 0,  0,  0,  0, -1, +1],  # 7
        [ 0,  0, +1,  0,  0, -1],  # 8
    ]
)

# define coordinates for plotting process graph
coordinates = np.array([
    [2, 1], #env
    [0, 0], #p1
    [0.75, 0], #mx
    [1.5, 0], #me1
    [2, -1], # sp1
    [1.5,-1]] # p2
)
pgraph = define_system(iIncidence=iIncidence, coordinates=coordinates, verbose=5)
pgraph = define_system(
    iIncidence=iIncidence, coordinates = coordinates, verbose=5,
    arcSplitter =[[5 - 1, 6 - 1, 7 - 1]],
    arcEqualComposition = [[1-1, 2-1], [7-1, 8-1], [5 - 1, 6 - 1, 7 - 1]],
    numberOfComponents = 2,
    )

pgraph.add_graph_info(verbose=5)
xMeasured_default = pgraph.xMeasured
sens, obs, red = get_one_result(pgraph, nLayout, objective="bilinear", verbose=5)
```

%% Output

    ******* DEFINE SYSTEM *******
    membrane1
    	GRAPH STRUCTURE
    	STREAM COMPOSITION
    	MEASUREMENTS
    	GROUND TRUTH
    	SYMBOLIC VARIABLES
    ******* PROCESS GRAPH *******
    	CUT SETS OF GRAPH WITHOUT ENERGY EDGES
    	CUT SETS OF GRAPH
    	CYCLES OF GRAPH
    Front_99_2_2
    ******* PROCESS GRAPH *******
    	CUT SETS OF GRAPH WITHOUT ENERGY EDGES
    	CUT SETS OF GRAPH
    	CYCLES OF GRAPH
    ******* EVALUATE OBSERVABILITY *******
    ==============================================================
    	OBSERVABILITY RULE 1
    ==============================================================
    	Rule 1a         Fraction normalization rule
         (+) Component fraction: x4_2 x8_2
    	Rule 1b         Splitter rule
    	Rule 1c(i)      Heat flow balance
    	Rule 1c(ii)     Component flow balance
         (+) Component fraction: x7_1 x7_2
    	Rule 1d     	Check convergence
    	Rule 1e         Bilinear assignment
         (+) Component flow: N4_1 N4_2 N8_1 N8_2
    ==============================================================
    	OBSERVABILITY RULE 2
    ==============================================================
    =============================================================
    	OBSERVABILITY RULE 3
    =============================================================
    	Rule 3a(i)      Cycles mass flows
         (+) Mass flow: M7
    	Rule 3a(ii)     Bilinear assignment
         (+) Component flow: N7_1 N7_2
    =============================================================
    	OBSERVABILITY RULE 4
    =============================================================
    	Rule 4a(i)      Cycles heat flows
    	Rule 4a(ii)     Cycles component flows
    	Rule 4b         Known stoichiometry
    	Rule 4c(i)      Sum of component flows
    	Rule 4c(ii)     Bilinear assignment
    	Rule 4c(iii)	Fraction normalization rule
    	Rule 4c(iv)     Splitter rule
         (+) Component fraction: x5_1 x5_2 x6_1 x6_2
    	Rule 4c(v)      Check convergence
    	Rule 4a(i)      Cycles heat flows
    	Rule 4a(ii)     Cycles component flows
    	Rule 4b         Known stoichiometry
    	Rule 4c(i)      Sum of component flows
    	Rule 4c(ii)     Bilinear assignment
    	Rule 4c(iii)	Fraction normalization rule
    	Rule 4c(iv)     Splitter rule
    	Rule 4c(v)      Check convergence
    	Rule 4e         Check convergence
    =============================================================
    	OBSERVABILITY RULE 3
    =============================================================
    	Rule 3a(i)      Cycles mass flows
    	Rule 3a(ii)     Bilinear assignment
    =============================================================
    	OBSERVABILITY RULE 4
    =============================================================
    	Rule 4a(i)      Cycles heat flows
    	Rule 4a(ii)     Cycles component flows
    	Rule 4b         Known stoichiometry
    	Rule 4c(i)      Sum of component flows
    	Rule 4c(ii)     Bilinear assignment
    	Rule 4c(iii)	Fraction normalization rule
    	Rule 4c(iv)     Splitter rule
    	Rule 4c(v)      Check convergence
    	Rule 4e         Check convergence
    =============================================================
    	OBSERVABILITY RULE 5
    =============================================================
    	Some variables remain unlabelled.
    ==============================================================
    	OBSERVABILITY RULE 6
    ==============================================================
        Cut: 1 of 50
        Cut: 2 of 50
        Cut: 3 of 50
        Cut: 4 of 50
        Cut: 5 of 50
        Cut: 6 of 50
        Cut: 7 of 50
        Cut: 8 of 50
        Cut: 9 of 50
        Cut: 10 of 50
        Cut: 11 of 50
        Cut: 12 of 50
        Cut: 13 of 50
        Cut: 14 of 50
        Cut: 15 of 50
        Cut: 16 of 50
        Cut: 17 of 50
        Cut: 18 of 50
        Cut: 19 of 50
        Cut: 20 of 50
        Cut: 21 of 50
        Cut: 22 of 50
        Cut: 23 of 50
        Cut: 24 of 50
        Cut: 25 of 50
        Cut: 26 of 50
        Cut: 27 of 50
        Cut: 28 of 50
        Cut: 29 of 50
        Cut: 30 of 50
        Cut: 31 of 50
        Cut: 32 of 50
        Cut: 33 of 50
        Cut: 34 of 50
        Cut: 35 of 50
        Cut: 36 of 50
        Cut: 37 of 50
        Cut: 38 of 50
        Cut: 39 of 50
        Cut: 40 of 50
        Cut: 41 of 50
        Cut: 42 of 50
        Cut: 43 of 50
        Cut: 44 of 50
        Cut: 45 of 50
        Cut: 46 of 50
        Cut: 47 of 50
        Cut: 48 of 50
        Cut: 49 of 50
        Cut: 50 of 50
         (-) Mass flow: M1 M2 M3 M5 M6
         (-) Component flow: N1_1 N1_2 N2_1 N2_2 N3_1 N3_2 N5_1 N5_2 N6_1 N6_2
         (-) Component fraction: x1_1 x1_2 x2_1 x2_2 x3_1 x3_2
         (-) Heat flow: H1 H2 H3 H4 H5 H6 H7 H8
         (-) Temperature: T1 T2 T3 T4 T5 T6 T7 T8
    ******* EVALUATE REDUNDANCY *******
    ==============================================================
    	REDUNDANCY RULE 1
    ==============================================================
    	Rule 1a         Fraction normalization rule
    	Rule 1b         Splitter rule
    ==============================================================
    	REDUNDANCY RULE 2
    ==============================================================
    ==============================================================
    	REDUNDANCY RULE 3
    ==============================================================
    ==============================================================
    	REDUNDANCY RULE 4
    ==============================================================
    ==============================================================
    	REDUNDANCY RULE 5
    ==============================================================
    =============================================================
    	REDUNDANCY RULE 6
    =============================================================
    =============================================================
    	REDUNDANCY RULE 7
    =============================================================
    ==============================================================
    	REDUNDANCY RULE 8
    ==============================================================
             Checking: x4_1
             Checking: M4
             Checking: x8_1
             Checking: M8
         (-) Mass flow: M4 M8
         (-) Component fraction: x4_1 x8_1

%% Cell type:code id:d1a16b95 tags:

``` python
# observability matrix from soar. first and last columns are all 1, indicating
# mass and concentration are all observable
display(obs)
```

%% Output


%% Cell type:code id:7831e484 tags:

``` python
# convert to boolean list so it is easier to see
# mass observabilities:
obs_soar_mass = np.array([True if s==1 else False for s in obs[:,-1]])
red_soar_mass = np.array([True if s==1 else False for s in red[:,-1]])

# add the concentration variables:
obs_soar_conc = np.array([True if s==1 else False for s in obs[:,0]])
red_soar_conc = np.array([True if s==1 else False for s in red[:,0]])

obs_soar = np.concatenate([obs_soar_mass, obs_soar_conc])
red_soar = np.concatenate([red_soar_mass, red_soar_conc])
```

%% Cell type:code id:08574fcf tags:

``` python
print(obs_soar)
np.array(obs_soar)
print(obs_soar), print(obs_int)
```

%% Output

    [ True  True  True  True  True  True  True  True  True  True  True  True
    [False False False  True False False  True  True False False False  True
      True  True  True  True]
    [False False False  True False False  True  True False False False  True
      True  True  True  True]

    (None, None)

%% Cell type:code id:ec136a8e tags:

``` python
# ensure we are using the same layout as the rref case:
display(pgraph.xMeasured)
```

%% Output


%% Cell type:code id:39741bde tags:
%% Cell type:code id:0d233890 tags:

``` python
```
+1989 −0

File added.

Preview size limit exceeded, changes collapsed.

+2103 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading