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

cleanup imports, add environment files

parent 377350cf
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -11,11 +11,5 @@ if soar_path not in sys.path:
else:
    print("soar toolbox already in path")

# add module path
module_path = os.path.dirname(os.path.abspath(__file__))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")

+31 −2
Original line number Diff line number Diff line
@@ -176,14 +176,14 @@ def constr_split(
        return constr, sltns
    return constr

def constr_mix(
def constr_mix_21(
        min1, min2, mout, 
        xin1, xin2, xout,
        pin1, pin2, pout, 
        constr, sltns=None
        ):
    """ 
    constraint for 2 pipes coming together
    constraint for 2 pipes coming together, 1 outlet
    """
    constr_hydraulic = min1 + min2 - mout
    constr_component = min1*xin1 + min2*xin2 - mout*xout
@@ -201,6 +201,35 @@ def constr_mix(
        return constr, sltns
    return constr

def constr_mix_31(
        min1, min2, min3, mout, 
        xin1, xin2, xin3, xout,
        pin1, pin2, pin3, pout, 
        constr, sltns=None
        ):
    """ 
    constraint for 3 pipes coming together, 1 outlet
    """
    constr_hydraulic = min1 + min2 +min3 - mout
    constr_component = min1*xin1 + min2*xin2 + min3*xin3- mout*xout
    constr_press1 = pin1 - pout
    constr_press2 = pin2 - pout
    constr_press3 = pin3 - pout

    constr = add_constraint(constr, constr_hydraulic, type="lin_hydraulic")
    constr = add_constraint(constr, constr_component, type="bl_component")
    constr = add_constraint(constr, constr_press1, type="nl_pressure")
    constr = add_constraint(constr, constr_press2, type="nl_pressure")
    constr = add_constraint(constr, constr_press3, type="nl_pressure")

    if sltns is not None:
        sltns = add_sltn(sltns, xout.name, constr_component)
        sltns = add_sltn(sltns, pout.name, constr_press1)
        sltns = add_sltn(sltns, pin2.name, constr_press2)
        sltns = add_sltn(sltns, pin3.name, constr_press3)
        return constr, sltns
    return constr


def constr_mex(
        mfeed, mperm, mret, 

numerical_labelling/context.py

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
import os
import sys

if sys.platform == "win32":
    soar_path = os.path.join(r"C:\Users\tjf\Documents\01_gitlab_repos\soar\python")
elif sys.platform == "linux":
    soar_path = os.path.join("/home/tjf/01_nawi/soar/python")
    
if soar_path not in sys.path:
    sys.path.insert(0, soar_path)
else:
    print("soar toolbox already in path")

# add module path
module_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")

+35 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ def plot_layout_any(layout_plt, layout_name, varbs,
    fig.savefig(os.path.join(fig_path, fig_name), bbox_inches="tight")


def make_pretty_labels(varbs, layout):
def make_varb_labels(varbs, layout):

    """
    make a label row for the jacobian columns, for complete jacobian (all) 
@@ -177,3 +177,37 @@ def make_pretty_labels(varbs, layout):
    varb_bar_um_pretty = sy.Matrix.vstack(varb_bar, dash_line)

    return varb_bar_all_pretty, varb_bar_m_pretty, varb_bar_um_pretty

def make_constr_labels(constrs):

    """
    make a label column for the jacobian constraint equations
    """
    # add 2 rows for variable label rows
    constr_labels = sy.Matrix([sy.Symbol(" ")]*2 + list(constrs.values()))
    
    return constr_labels

def make_labelled_matrix(varbs, constrs, layout, J):
    """
    label the rows and columns of a matrix. used for adding 
    Constraint labels to rows and variable labels to columns
    ex:
                x1   y1  x2  y2
                - - - - - - - - 
    x1 + y1      1   1   0   0
    x2 + y2      0   0   1   0

    constrs: list of row labels to be added to the left side
    varbs: list of column labels, to be added to the top
    J: sympy matrix of dim(row_labels, col_labels)
    """

    const_vec = make_constr_labels(constrs)
    vb, vbm, vbum  = make_varb_labels(varbs, layout)
    J_lab = sy.Matrix.vstack(vbum, J)
    pretty_jac = sy.Matrix.hstack(const_vec, J_lab)

    return pretty_jac

+0 −21
Original line number Diff line number Diff line
import os
import sys

if sys.platform == "win32":
    soar_path = os.path.join(r"C:\Users\tjf\Documents\01_gitlab_repos\soar\python")
elif sys.platform == "linux":
    soar_path = os.path.join("/home/tjf/01_nawi/soar/python")
    
if soar_path not in sys.path:
    sys.path.insert(0, soar_path)
else:
    print("soar toolbox already in path")

# add module path
module_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if module_path not in sys.path:
    sys.path.insert(0, module_path)
else:
    print("path already in sys.path")

Loading