Example #1
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 #2
0
if True:
    addab = Calc("Calc: addAB", parent=rootnode, 
                    data={"desc": "First calc."},
                    funcname="addAB") 

    addcd = Calc("Calc: addCD", parent=addab, 
                    parameters={ 
                        **params2, 
                    },
                    data={"desc": "2nd calc."},
                    funcname="addCD") 

    total = Calc("Calc: add results", parent=addcd, 
                    data={"desc": "add results"},
                    funcname="addAB", argmap={"a":"AplusB", "b":"CplusD", "return":"TOTAL"}) 
    base1.add_param("TOTAL", linkid=total._nodeid)
    base1.add_param("CplusD", linkid=addcd._nodeid)

    table = Table("add results", parent=total, paranames=["a","b", "c", "d", "TOTAL"])
    table2 = Table("test table", parent=base1, paranames=["a","CplusD", "TOTAL"])

    # for _n in rootnode:
    #     if callable(_n):
    #         _n()

    # for _n in rootnode:
    #     if type(_n) is Calc:
    #         _n()

    # for _n in rootnode:
    #     if type(_n) is Table: