Example #1
0
    'gamma_SCLB': 1.14,
    'gamma_SCPC': 1.138,
    "SC": "medium",
}
env_params = {
    "rho_water": 1027.,    
}


vnpkl_file = "/home/develop/engineering/src/scratch/pflacs_test/IRL--PFLACS--P-01.vnpkl"


rootnode = Premise("Pflacs oil&gas field, subsea", 
                parameters={ 
                    **field_params, 
                    **constants,
                    **env_params,
                },
                data={"desc": "Top-level field details, environmental and universal parameters."},
                vnpkl_fpath=vnpkl_file)
P01 = Premise("P-01 gas pipeline", 
                parent=rootnode,
                parameters={
                    **pipeline_params,
                    **process_params,
                    **design_params,
                },
                data={"desc": "P-01 gas pipeline."})

P01_1 = Premise("P-01 pipeline section 1, KP 0-0.3", 
                parent=P01,
                parameters={
Example #2
0
    "rho_cont": 275.,
    "rho_water": 1027.,
    "rho_t": 1027.,
    "SC": "medium",
    "SMYS": 450.e6,
    "SMTS": 535.e6,
    "t": 0.0212,
    "t_corr": 0.0005,
    "t_fab": 0.001,
    "T": 60,
}

vnpkl_file = "/home/develop/engineering/src/scratch/pflacs_test/pf_test.vnpkl"

basecase = Premise("Base case",
                   parameters=parameters,
                   data={"desc": "This is the base-case loadcase."},
                   vnpkl_fpath=vnpkl_file)
lc1 = Premise("Load case 1",
              parent=basecase,
              data={"desc": "This is the 1st child loadcase."})
gc1 = Premise("gchild lc1",
              parent=lc1,
              data={"desc": "This is the 1st child loadcase."})
lc2 = Premise("Load case 2",
              parent=basecase,
              data={"desc": "This is the 2nd child loadcase."})

basecase.plugin_func("pressure_containment_all", "pdover2t.dnvgl_st_f101")

lc1.rho_cont = np.linspace(100, 1000, 10)
print("lc1.rho_cont", lc1.rho_cont)
Example #3
0
    return c+d


params1 = {
    "a": 2.2,
    "b": 10,
}
params2 = {
    #"c": 100,    
    "c": np.array([10,20,30,1001.]),
    "d": 100.,
}

rootnode = Premise("Root Node", 
                parameters={ 
                    **params1, 
                },
                data={"desc": "Top-level parameters."},
                vnpkl_fpath="add_tests.vn3")

base1 = Premise("Base 1", parent=rootnode) 

rootnode.plugin_func(addAB)
rootnode.plugin_func(addCD, argmap={"return":"CplusD"})

if True:
    addab = Calc("Calc: addAB", parent=rootnode, 
                    data={"desc": "First calc."},
                    funcname="addAB") 

    addcd = Calc("Calc: addCD", parent=addab, 
                    parameters={ 
Example #4
0
"""
https://github.com/bjornaa/seawater
https://github.com/benranderson/wall
"""

from pflacs import Premise
import numpy
import wall
import seawater

base = Premise("Basecase")
base.add_param("water_depth", 110, "water depth (m)")
base.add_param("rho_seawater", 1025, "assumed water density (kg/m3)")
base.add_param("pressure", desc="pressure (Pa)")

base.plugin_func(wall.pressure_head,
                 argmap={
                     "h": "water_depth",
                     "rho": "rho_seawater"
                 })
base.pressure = base.pressure_head()
print(f'{base.name} pressure = {base.pressure}')

base.add_param("lat", 53.2, "geographical latitude")
base.add_param("S", 35, "water salinity")
base.add_param("T", 8, "water temperature (°C)")

base.plugin_func(seawater.dens)
base.add_param("rho_seawater_check", desc="calculated water density (kg/m3)")
base.rho_seawater_check = base.dens()
print(
Example #5
0
        _funcname = _d.get("funcname", None)
        _argmap = _d.get("argmap", None)
        _n = Calc(_name,
                  _parent,
                  parameters=_paras,
                  funcname=_funcname,
                  argmap=_argmap)
        _parent = _n
    return _n._root


calctree = make_calc_branch(pipemass_branch)

P101 = Premise(
    "P101",
    parameters=P101_data,
    data={
        "desc":
        "Top-level field details, environmental and universal parameters."
    })

P101.plugin_func("calc_pipe_Di", "pdover2t.pipe")
P101.plugin_func("pipe_CSA", "pdover2t.pipe")

P101_z1 = Premise("P101 zone1", parent=P101)
P101_z2 = Premise("P101 zone2", parent=P101)

#P101.plugin_func("calc_pipe_Di", "pdover2t.pipe")

calc_joint_mass = Calc("calc Di", parent=P101_z1, funcname="calc_pipe_Di")
Example #6
0
OPEN_EXISTING_STUDY = False

# SETUP_NEW_STUDY = False
# OPEN_EXISTING_STUDY = True

if SETUP_NEW_STUDY:
    print(f"Create a new study.")
    study_parameters = {
        "ys": 22.1 * 10**6,  # pipe yield strength in Pa
        "D": 110 * 10**-3,  # pipe outer diameter in m
        "P": 20 * 10**5,  # pipe internal pressure in Pa (20 bar)
        "t": 5 * 10**-3,
        "design_factor": 0.8,
    }

    basecase = Premise("Pipe study base case.", parameters=study_parameters)
    basecase.plugin_func(pipe_hoop_stress)
    basecase.plugin_func(allowable_stress_unity_check)
    #basecase.plugin_func("pressure_containment_all", "pdover2t.dnvgl_st_f101")
    #basecase.plugin_func(pdover2t.dnvgl_st_f101.pressure_containment_all)
    lc1 = Premise(
        "LoadCase1, pressure 15 bar.",
        basecase,
        parameters={
            "P": 15 * 10**5,  # pipe internal pressure in Pa
        })
    lc1_pstress = Calc(
        "Calc pipe stress",
        lc1,
        funcname="pipe_hoop_stress",
    )
Example #7
0
import unittest

from pflacs import Premise


def add_abc(a, b, c=0):
    return a + b + c

def sub_xy(x, y):
    return x - y


basecase = Premise("Base case", parameters={"a":10, "b":20, "c":30},
                data={"description": "This is the base-case loadcase."})
basecase.plugin_func(add_abc)

para1 = Premise("Parameter study 1", parent=basecase,
                data={"description": ("This is the 1st parameter study "
                "loadcase, it is effectively the same as the base-case." )
                })
para1.plugin_func(sub_xy, argmap={"x": "a", "y":"b"})

para2 = Premise("Parameter study 2", parent=basecase,
                parameters={"a":-20.8},
                data={"description": ("This is the 2nd parameter study "
                "loadcase." )
                })


print(basecase.to_texttree())
pflacs_filepath = "very_simple_study.pflacs"


def adda(a, b, c=0, d=0, e=0):
    """Add number b to number a. Optionally also add 
    any of numbers c, d, e to the result.
    """
    print(f"Function `adda` called with arguments a={a} b={b}", end="")
    if c: print(f" c={c}", end="")
    if d: print(f" d={d}", end="")
    if e: print(f" e={e}", end="")
    print()
    return a + b + c + d + e


def suba(a, b, c, d=0, e=0):
    """Subtract numbers b and c from number a. Optionally also subtract 
    either or both of numbers d and e from the result.
    """
    print(f"Function `suba` called with arguments a={a} b={b} c={c}", end="")
    if d: print(f" d={d}", end="")
    if e: print(f" e={e}", end="")
    print()
    return a - b - c - d - e


print(f"Open existing study from `pflacs` file «{pflacs_filepath}».")
basecase = Premise.openfile(pflacs_filepath)
print(basecase.to_texttree())
Example #9
0
from pflacs import Premise
import numpy
from wall import pressure_head
from seawater import dens


study_file = "external_libs_test.pflacs"

print(f"Open Existing study from `pflacs` file «{study_file}».")
#print("locals()", locals())
base = Premise.openfile(study_file)

print(f'{base.name} pressure = {base.pressure}') 

print(f'{base.get_param_desc("rho_seawater_check")} = {base.rho_seawater_check}')
if base.rho_seawater != base.rho_seawater_check:
    print(f"Warning: calculated seawater density {base.rho_seawater_check} not equal to assumed value {base.rho_seawater}.")


rho_interp = base.interp_water_density()
print(f"Interpolated water density = {rho_interp}, for salinity = {base.S} ")

rho_interp = base.interp_water_density(S=39.5)
print(f"Interpolated water density = {rho_interp}, for salinity = 39.5 ")
Example #10
0
        w = b = h
        area_hw = area_wb = area_bh = rectangle_area(h, w)
    else:
        if area_hw is None:
            area_hw = rectangle_area(h, w)
        if area_wb is None:
            area_wb = rectangle_area(w, b)
        if area_bh is None:
            area_bh = rectangle_area(b, h)
    area = 2.0 * (area_hw + area_wb + area_bh)
    return area


basecase = Premise("Study base-case", parameters={
    "w": 4,
    "b": 5,
    "h": 3.5,
})

basecase.plugin_func(rectangle_area)
basecase.plugin_func(box_volume)

print(f"Base-case rectange area = {basecase.rectangle_area()}")
print(f"Base-case cube volume = {basecase.box_volume()}")

parastudy = Premise("Parameter study",
                    parent=basecase,
                    parameters={
                        "w": np.array([1.0, 1.35, 2.0, 4.5]),
                        "b": np.linspace(2.2, 5.5, 4),
                        "h": 10.0,
#     "SC": "medium",
#     "SMYS": 450.e6,
#     "SMTS": 535.e6,
#     "t": 0.0212,
#     "t_corr": 0.0005,
#     "t_fab": 0.001,
#     "T": 60,
# }

vnpkl_file = "/home/develop/engineering/src/scratch/pflacs_test/IRL--PFLACS--P-01.vnpkl"


rootnode = Premise("Pflacs oil&gas field, subsea", 
                parameters={ 
                    **field_params, 
                    **constants,
                    **env_params,
                },
                data={"desc": "Top-level field details, environmental and universal parameters."},
                vnpkl_fpath=vnpkl_file)
P01 = Premise("P-01 gas pipeline", 
                parent=rootnode,
                parameters={
                    **pipeline_params,
                    **process_params,
                    **design_params,
                },
                data={"desc": "P-01 gas pipeline."})

P01_1 = Premise("P-01 section 1, KP 0-0.3", 
                parent=P01,
                parameters={